diff options
Diffstat (limited to 'dxr3audiodecoder.c')
| -rw-r--r-- | dxr3audiodecoder.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c index f3dd0ca..8c7e6e1 100644 --- a/dxr3audiodecoder.c +++ b/dxr3audiodecoder.c @@ -108,6 +108,7 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff } } +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 26, 0) uint8_t *ptr = const_cast<uint8_t *>(buf); while (length > 0) { @@ -136,6 +137,33 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff length -= len; ptr += len; } +#else + avpkt.data = const_cast<uint8_t *>(buf); + avpkt.size = length; + + while (avpkt.size > 0) { + out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + + len = avcodec_decode_audio3(contextAudio, (short *)(&pcmbuf), &out_size, &avpkt); + + if (len < 0) { + esyslog("[dxr3-decoder] failed to decode audio"); + return; + } + + if (out_size) { + cFixedLengthFrame* pTempFrame = aBuf.Push(pcmbuf, + out_size, pts); + if (pTempFrame) { + pTempFrame->SetChannelCount(contextAudio->channels); + pTempFrame->SetSampleRate(contextAudio->sample_rate); + } + } + + avpkt.size -= len; + avpkt.data += len; + } +#endif } // ================================== |
