summaryrefslogtreecommitdiff
path: root/convert.h
blob: b275cbf27591df1b17c6086713ffd8a0a7e90214 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * convert.h
 */

#ifndef __CONVERT_H
#define __CONVERT_H

#include "postdata.h"
#include "mpa-frame.h"
#include "a-tools.h"

extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/mem.h>
#include <libavutil/channel_layout.h> // https://www.ffmpeg.org/doxygen/2.2/libmp3lame_8c_source.html
}


class cConvert {
private:
        AVCodec *decoder_codec, *encoder_codec;
        AVCodecContext *decoder_ctx, *encoder_ctx;
        int decoder_open, encoder_open;

        abuffer decoder_buf, encoder_buf, mpa_frame_buf;

        void init_decoder(void);
        void decode_mpa_frame(mpeg_audio_frame *mpa_frame);
        void init_encoder(const char *codec, int bit_rate, int sample_rate,
                int channels);
public:
        cConvert(const cPostData &postdata);
        ~cConvert();

        abuffer *reencode_mpa_frame(mpeg_audio_frame *mpa_frame,
                float volume = 1);
};

#endif /* __CONVERT_H */