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  typedef int16_t inbuf_t;
17  typedef int16_t outbuf_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_av_context->channels; }
28  void clear();
29 
30  private:
31  void Reset(void);
32  void *realloc(void *ptr, size_t old_size, size_t new_size);
33 
34  AVCodecContext *m_av_context {nullptr};
35  outbuf_t *m_out {nullptr};
36  size_t m_out_size {0};
37  inbuf_t *m_in {nullptr};
38  inbuf_t *m_inp {nullptr};
39  size_t m_in_size {0};
40  int m_outlen {0};
41  int m_inlen {0};
42  size_t m_samples_per_frame {0};
44  AVFrame *m_frame {nullptr};
45 };
46 
47 #endif
void * realloc(void *ptr, size_t old_size, size_t new_size)
bool Init(AVCodecID codec_id, int bitrate, int samplerate, int channels)
struct AVFrame AVFrame
size_t GetFrames(void *ptr, int maxlen)
size_t Encode(void *buf, int len, AudioFormat format)