21#ifndef __CODEC_AUDIO_H
22#define __CODEC_AUDIO_H
25#include <libavcodec/avcodec.h>
34#define CODEC_EAC3 0x08
52#define IEC61937_PREAMBLE1 0xF872
53#define IEC61937_PREAMBLE2 0x4E1F
54#define DTS_PREAMBLE_16BE_1 0x7FFE
55#define DTS_PREAMBLE_16BE_2 0x8001
60#define DTS1_FRAME_SIZE 512
61#define DTS2_FRAME_SIZE 1024
62#define DTS3_FRAME_SIZE 2048
63#define AC3_FRAME_SIZE 1536
64#define EAC3_FRAME_SIZE 6144
65#define TRUEHD_FRAME_SIZE 15360
67#define MAX_FRAME_SIZE EAC3_FRAME_SIZE
78 void Open(AVCodecID, AVCodecParameters * =
nullptr, AVRational = { .num = 1, .den = 90000 });
80 void Decode(
const AVPacket *);
cAudioDecoder - Audio decoder class
int DecodePassthrough(const AVPacket *, AVFrame *)
Passthrough audio data.
uint16_t m_spdifOutput[MAX_FRAME_SIZE *2]
SPDIF output buffer.
int UpdateFormat(void)
Handle audio format changes.
AVCodecContext * m_pAudioCtx
ffmpeg audio codec context
virtual ~cAudioDecoder(void)
Audio decoder class destructor.
int m_currentHwSampleRate
current hw sample rate
void FlushBuffers(void)
Flush the audio decoder.
int m_currentHwNumChannels
current number of hw channels
void Decode(const AVPacket *)
Decode an audio packet.
AVFrame * m_pFrame
decoded ffmpeg audio frame
int m_spdifIndex
index into SPDIF output buffer
int m_passthroughMask
passthrough mask to be set
AVCodecID m_codecId
current codec id
int m_currentPassthrough
current passthrough mask
AVCodecID GetCodecId() const
cAudioDecoder(cSoftHdAudio *)
Audio decoder class constructor.
int m_spdifRepeatCount
SPDIF repeat counter.
int64_t m_lastPts
last seen PTS
int m_currentSampleRate
current sample rate
cSoftHdAudio * m_pAudio
audio module
void SetPassthrough(int)
Set audio pass-through mask.
int m_currentNumChannels
current number of channels
void Open(AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 })
Open and initiate the audio decoder.
void Close(void)
Close the audio decoder.
cSoftHdAudio - Audio class
IEC61937
IEC Data type enumeration.
@ IEC61937_TRUEHD
TrueHD data (not used)
@ IEC61937_DTS3
DTS type III (2048 samples)
@ IEC61937_DTS2
DTS type II (1024 samples)
@ IEC61937_DTSHD
DTS HD data (not used)
@ IEC61937_EAC3
E-AC-3 data.
@ IEC61937_DTS1
DTS type I (512 samples)