MythTV master
audiooutputdigitalencoder.h
Go to the documentation of this file.
1#ifndef AUDIOOUTPUTREENCODER
2#define AUDIOOUTPUTREENCODER
3
4extern "C" {
5#include "libavcodec/avcodec.h"
6};
7
8#include "spdifencoder.h"
10
11static constexpr ssize_t INBUFSIZE { 131072 };
12static constexpr ssize_t OUTBUFSIZE { INBUFSIZE };
13
15{
16
17 public:
20
21 bool Init(AVCodecID codec_id, int bitrate, int samplerate, int channels);
22 int Encode(void *input, int len, AudioFormat format);
23 int GetFrames(void *ptr, int maxlen);
24 int Buffered(void) const
25 // assume 32 bit samples = 4 byte
26 { return m_inlen / 4 / m_avContext->ch_layout.nb_channels; }
27 void clear();
28
29 private:
30 void Reset(void);
31 static void *realloc(void *ptr, size_t old_size, size_t new_size);
32
33 AVCodecContext *m_avContext {nullptr};
34 uint8_t *m_outbuf {nullptr};
35 ssize_t m_outSize {0};
36 // m_inbuf = 6 channel data converted to S32 or FLT samples interleaved
37 uint8_t *m_inbuf {nullptr};
38 // m_framebuf = 1 frame, deinterleaved into planar format
39 uint8_t *m_framebuf {nullptr};
40 ssize_t m_inSize {0};
41 int m_outlen {0};
42 // m_inlen = number of bytes available in m_inbuf
43 int m_inlen {0};
46 AVFrame *m_frame {nullptr};
47};
48
49#endif
AVFrame AVFrame
static constexpr ssize_t INBUFSIZE
static constexpr ssize_t OUTBUFSIZE
bool Init(AVCodecID codec_id, int bitrate, int samplerate, int channels)
int GetFrames(void *ptr, int maxlen)
int Encode(void *input, int len, AudioFormat format)
static void * realloc(void *ptr, size_t old_size, size_t new_size)