MythTV  master
audiooutputdigitalencoder.h
Go to the documentation of this file.
1 #ifndef AUDIOOUTPUTREENCODER
2 #define AUDIOOUTPUTREENCODER
3 
4 extern "C" {
5 #include "libavcodec/avcodec.h"
6 };
7 
8 #include "spdifencoder.h"
9 #include "audiooutputsettings.h"
10 
11 #define INBUFSIZE 131072
12 #define OUTBUFSIZE INBUFSIZE
13 
15 {
16  using inbuf_t = int16_t;
17  using outbuf_t = int16_t;
18 
19  public:
22 
23  bool Init(AVCodecID codec_id, int bitrate, int samplerate, int channels);
24  size_t Encode(void *buf, int len, AudioFormat format);
25  size_t GetFrames(void *ptr, int maxlen);
26  int Buffered(void) const
27  { return m_inlen / sizeof(inbuf_t) / m_avContext->channels; }
28  void clear();
29 
30  private:
31  void Reset(void);
32  static void *realloc(void *ptr, size_t old_size, size_t new_size);
33 
34  AVCodecContext *m_avContext {nullptr};
35  outbuf_t *m_out {nullptr};
36  size_t m_outSize {0};
37  inbuf_t *m_in {nullptr};
38  inbuf_t *m_inp {nullptr};
39  size_t m_inSize {0};
40  int m_outlen {0};
41  int m_inlen {0};
42  size_t m_samplesPerFrame {0};
44  AVFrame *m_frame {nullptr};
45 };
46 
47 #endif
AudioOutputDigitalEncoder::GetFrames
size_t GetFrames(void *ptr, int maxlen)
Definition: audiooutputdigitalencoder.cpp:301
AudioOutputDigitalEncoder::~AudioOutputDigitalEncoder
~AudioOutputDigitalEncoder()
Definition: audiooutputdigitalencoder.cpp:38
AudioOutputDigitalEncoder::Init
bool Init(AVCodecID codec_id, int bitrate, int samplerate, int channels)
Definition: audiooutputdigitalencoder.cpp:88
spdifencoder.h
AudioOutputDigitalEncoder::Encode
size_t Encode(void *buf, int len, AudioFormat format)
Definition: audiooutputdigitalencoder.cpp:145
AudioOutputDigitalEncoder::m_outlen
int m_outlen
Definition: audiooutputdigitalencoder.h:40
AudioOutputDigitalEncoder::m_inp
inbuf_t * m_inp
Definition: audiooutputdigitalencoder.h:38
AudioOutputDigitalEncoder::realloc
static void * realloc(void *ptr, size_t old_size, size_t new_size)
Definition: audiooutputdigitalencoder.cpp:70
AudioOutputDigitalEncoder::m_inSize
size_t m_inSize
Definition: audiooutputdigitalencoder.h:39
AudioOutputDigitalEncoder::clear
void clear()
Definition: audiooutputdigitalencoder.cpp:314
AudioOutputDigitalEncoder::m_inlen
int m_inlen
Definition: audiooutputdigitalencoder.h:41
AudioOutputDigitalEncoder::m_spdifEnc
SPDIFEncoder * m_spdifEnc
Definition: audiooutputdigitalencoder.h:43
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
AudioOutputDigitalEncoder
Definition: audiooutputdigitalencoder.h:14
AudioOutputDigitalEncoder::Buffered
int Buffered(void) const
Definition: audiooutputdigitalencoder.h:26
AudioOutputDigitalEncoder::m_avContext
AVCodecContext * m_avContext
Definition: audiooutputdigitalencoder.h:34
AudioOutputDigitalEncoder::m_outSize
size_t m_outSize
Definition: audiooutputdigitalencoder.h:36
AudioOutputDigitalEncoder::m_in
inbuf_t * m_in
Definition: audiooutputdigitalencoder.h:37
AudioOutputDigitalEncoder::outbuf_t
int16_t outbuf_t
Definition: audiooutputdigitalencoder.h:17
AudioOutputDigitalEncoder::AudioOutputDigitalEncoder
AudioOutputDigitalEncoder(void)
Definition: audiooutputdigitalencoder.cpp:23
SPDIFEncoder
Definition: spdifencoder.h:14
AudioOutputDigitalEncoder::m_samplesPerFrame
size_t m_samplesPerFrame
Definition: audiooutputdigitalencoder.h:42
AudioFormat
AudioFormat
Definition: audiooutputsettings.h:25
AudioOutputDigitalEncoder::inbuf_t
int16_t inbuf_t
Definition: audiooutputdigitalencoder.h:16
audiooutputsettings.h
AudioOutputDigitalEncoder::m_out
outbuf_t * m_out
Definition: audiooutputdigitalencoder.h:35
AudioOutputDigitalEncoder::Reset
void Reset(void)
Definition: audiooutputdigitalencoder.cpp:57
AudioOutputDigitalEncoder::m_frame
AVFrame * m_frame
Definition: audiooutputdigitalencoder.h:44