vdr-plugin-softhddevice-drm-gles 1.6.2
Audio Decoder

FFMpeg Audio Decoder Frontend. More...

Classes

class  cAudioDecoder
 Audio Decoder. More...
 

Enumerations

enum  PassthroughMask { CODEC_AC3 = (1 << 2) , CODEC_EAC3 = (1 << 3) , CODEC_DTS = (1 << 4) }
 Bits used for the passthrough mask. More...
 
enum  IEC61937Type {
  IEC61937_NULL = 0x00 , IEC61937_AC3 = 0x01 , IEC61937_EAC3 = 0x15 , IEC61937_DTS1 = 0x0B ,
  IEC61937_DTS2 = 0x0C , IEC61937_DTS3 = 0x0D , IEC61937_DTSHD = 0x11 , IEC61937_TRUEHD = 0x16
}
 IEC Data type. More...
 
enum  IEC61937Preamble { IEC61937_PREAMBLE1 = 0xF872 , IEC61937_PREAMBLE2 = 0x4E1F , DTS_PREAMBLE_16BE_1 = 0x7FFE , DTS_PREAMBLE_16BE_2 = 0x8001 }
 IEC Preambles. More...
 
enum  CodecFrameSizes {
  DTS1_FRAME_SIZE = 512 , DTS2_FRAME_SIZE = 1024 , DTS3_FRAME_SIZE = 2048 , AC3_FRAME_SIZE = 1536 ,
  EAC3_FRAME_SIZE = 6144 , MAX_FRAME_SIZE = EAC3_FRAME_SIZE , TRUEHD_FRAME_SIZE = 15360
}
 Codec frame sizes for spdif. More...
 

Functions

 cAudioDecoder::cAudioDecoder (cSoftHdAudio *)
 Create a new audio decoder for the given audio context.
 
 cAudioDecoder::~cAudioDecoder (void)
 
void cAudioDecoder::Open (AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 })
 Open and initiate the audio decoder.
 
void cAudioDecoder::Close (void)
 Close the audio decoder.
 
int cAudioDecoder::DecodePassthrough (const AVPacket *, AVFrame *)
 Passthrough audio data.
 
int cAudioDecoder::UpdateFormat (void)
 Handle audio format changes.
 
void cAudioDecoder::Decode (const AVPacket *)
 Decode an audio packet.
 
void cAudioDecoder::FlushBuffers (void)
 Flush the audio decoder buffers.
 
void cAudioDecoder::ResetSpdif (void)
 
void cAudioDecoder::SetPassthroughMask (int)
 Set audio pass-through mask.
 

Detailed Description

FFMpeg Audio Decoder Frontend.

Enumeration Type Documentation

◆ CodecFrameSizes

Codec frame sizes for spdif.

Enumerator
DTS1_FRAME_SIZE 
DTS2_FRAME_SIZE 
DTS3_FRAME_SIZE 
AC3_FRAME_SIZE 
EAC3_FRAME_SIZE 
MAX_FRAME_SIZE 
TRUEHD_FRAME_SIZE 

(not used)

Definition at line 67 of file codec_audio.h.

◆ IEC61937Preamble

IEC Preambles.

Enumerator
IEC61937_PREAMBLE1 
IEC61937_PREAMBLE2 
DTS_PREAMBLE_16BE_1 
DTS_PREAMBLE_16BE_2 

Definition at line 57 of file codec_audio.h.

◆ IEC61937Type

IEC Data type.

Enumerator
IEC61937_NULL 

no data

IEC61937_AC3 

AC-3 data.

IEC61937_EAC3 

E-AC-3 data.

IEC61937_DTS1 

DTS type I (512 samples)

IEC61937_DTS2 

DTS type II (1024 samples)

IEC61937_DTS3 

DTS type III (2048 samples)

IEC61937_DTSHD 

DTS HD data (not used)

IEC61937_TRUEHD 

TrueHD data (not used)

Definition at line 43 of file codec_audio.h.

◆ PassthroughMask

Bits used for the passthrough mask.

0x01 and 0x02 are kept unused for compatibility with an existing setup.conf

Enumerator
CODEC_AC3 

AC-3 bit mask.

CODEC_EAC3 

E-AC-3 bit mask.

CODEC_DTS 

DTS bit mask.

Definition at line 34 of file codec_audio.h.

Function Documentation

◆ cAudioDecoder()

cAudioDecoder::cAudioDecoder ( cSoftHdAudio audio)

Create a new audio decoder for the given audio context.

Parameters
audioaudio context

Definition at line 41 of file codec_audio.cpp.

References L_CODEC, LOGDEBUG2, LOGFATAL, cAudioDecoder::m_passthroughMask, and cAudioDecoder::m_pFrame.

◆ Close()

void cAudioDecoder::Close ( void  )

◆ Decode()

◆ DecodePassthrough()

int cAudioDecoder::DecodePassthrough ( const AVPacket avpkt,
AVFrame frame 
)
private

Passthrough audio data.

Build spdif headers depending on the codec and send the data to the audio device. Currently supported: AC3, EAC3, DTS

Parameters
avpktundecoded audio packet
framedecoded audio frame
Return values
0codec is not supported for passthrough, use Filter to handle the data
-1sth went wrong, data will be discarded
1data accepted if finished, spdif header was created and data was sent to passthrough device

Definition at line 136 of file codec_audio.cpp.

References AC3_FRAME_SIZE, CODEC_AC3, CODEC_DTS, CODEC_EAC3, DTS1_FRAME_SIZE, DTS2_FRAME_SIZE, DTS3_FRAME_SIZE, DTS_PREAMBLE_16BE_1, DTS_PREAMBLE_16BE_2, EAC3_FRAME_SIZE, cSoftHdAudio::EnqueueSpdif(), IEC61937_AC3, IEC61937_DTS1, IEC61937_DTS2, IEC61937_DTS3, IEC61937_EAC3, IEC61937_NULL, IEC61937_PREAMBLE1, IEC61937_PREAMBLE2, LOGERROR, cAudioDecoder::m_currentHwSampleRate, cAudioDecoder::m_passthroughMask, cAudioDecoder::m_pAudio, cAudioDecoder::m_pAudioCtx, cAudioDecoder::m_spdifIndex, cAudioDecoder::m_spdifOutput, cAudioDecoder::m_spdifRepeatCount, cAudioDecoder::ResetSpdif(), and cSoftHdAudio::SetTimebase().

Referenced by cAudioDecoder::Decode().

◆ FlushBuffers()

void cAudioDecoder::FlushBuffers ( void  )

Flush the audio decoder buffers.

Also resets the last PTS and Codec ID

Definition at line 421 of file codec_audio.cpp.

References AV_NOPTS_VALUE, L_CODEC, LOGDEBUG2, cAudioDecoder::m_codecId, cAudioDecoder::m_lastPts, cAudioDecoder::m_pAudioCtx, and cAudioDecoder::ResetSpdif().

Referenced by cSoftHdDevice::FlushAudio().

◆ Open()

void cAudioDecoder::Open ( AVCodecID  codecId,
AVCodecParameters par = nullptr,
AVRational  timebase = { .num = 1, .den = 90000 } 
)

Open and initiate the audio decoder.

Parameters
codecIdaudio codec id
paraudio codec parameters
timebasetimebase
Todo:
FIXME: errors shouldn't be fatal, maybe just disable audio

Definition at line 67 of file codec_audio.cpp.

References L_CODEC, LOGDEBUG2, LOGERROR, LOGFATAL, cAudioDecoder::m_codecId, cAudioDecoder::m_currentHwNumChannels, cAudioDecoder::m_currentHwSampleRate, cAudioDecoder::m_currentNumChannels, cAudioDecoder::m_currentPassthrough, cAudioDecoder::m_currentSampleRate, cAudioDecoder::m_passthroughMask, and cAudioDecoder::m_pAudioCtx.

Referenced by cSoftHdDevice::PlayAudio(), and cSoftHdDevice::SetAudioCodec().

◆ ResetSpdif()

void cAudioDecoder::ResetSpdif ( void  )
private

◆ SetPassthroughMask()

void cAudioDecoder::SetPassthroughMask ( int  mask)

Set audio pass-through mask.

Parameters
maskcodec mask to enable (AC-3, E-AC-3, DTS)

Definition at line 444 of file codec_audio.cpp.

References CODEC_AC3, CODEC_DTS, CODEC_EAC3, L_CODEC, LOGDEBUG2, and cAudioDecoder::m_passthroughMask.

Referenced by cSoftHdDevice::SetPassthroughMask().

◆ UpdateFormat()

◆ ~cAudioDecoder()

cAudioDecoder::~cAudioDecoder ( void  )

Definition at line 51 of file codec_audio.cpp.

References cAudioDecoder::Close(), and cAudioDecoder::m_pFrame.