diff options
author | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-12-07 17:20:42 +0100 |
---|---|---|
committer | Christian Gmeiner <christian.gmeiner@gmail.com> | 2009-12-07 17:20:42 +0100 |
commit | 481aa2a974ec2d122af9da644662e7a4593b09a8 (patch) | |
tree | 5406dc368b6885f44a5ee229c4c514cd7f1ac715 /dxr3audiodecoder.c | |
parent | 961b570ff897b54beabdcb4c54e59049203ce10a (diff) | |
download | vdr-plugin-dxr3-481aa2a974ec2d122af9da644662e7a4593b09a8.tar.gz vdr-plugin-dxr3-481aa2a974ec2d122af9da644662e7a4593b09a8.tar.bz2 |
simplify support for different ffmpeg versions
Diffstat (limited to 'dxr3audiodecoder.c')
-rw-r--r-- | dxr3audiodecoder.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c index b909485..99b68d2 100644 --- a/dxr3audiodecoder.c +++ b/dxr3audiodecoder.c @@ -111,43 +111,21 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff lastBitrate = buf[2]; } } -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 26, 0) - uint8_t *ptr = const_cast<uint8_t *>(buf); - while (length > 0) { - out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(51, 29, 0) - len = avcodec_decode_audio(contextAudio, (short *)(&pcmbuf), &out_size, ptr, frameSize); -#else - len = avcodec_decode_audio2(contextAudio, (short *)(&pcmbuf), &out_size, ptr, frameSize); -#endif - - 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); - } - } - - length -= len; - ptr += len; - } -#else + // setup AVPacket avpkt.data = const_cast<uint8_t *>(buf); avpkt.size = frameSize; while (length > 0) { - out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(51, 29, 0) + len = avcodec_decode_audio(contextAudio, (short *)(&pcmbuf), &out_size, avpkt.data, frameSize); +#elif LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 26, 0) + len = avcodec_decode_audio2(contextAudio, (short *)(&pcmbuf), &out_size, avpkt.data, frameSize); +#else len = avcodec_decode_audio3(contextAudio, (short *)(&pcmbuf), &out_size, &avpkt); +#endif if (len < 0) { esyslog("[dxr3-decoder] failed to decode audio"); @@ -166,7 +144,6 @@ void cDxr3AudioDecoder::Decode(cDxr3PesFrame *frame, uint32_t pts, cDxr3SyncBuff length -= len; avpkt.data += len; } -#endif } // ================================== |