Skip to content

Commit 06ec0b6

Browse files
author
Clement Champetier
committed
Video/Audio decoders: fixed decoding when codec capabilities has CODEC_CAP_DELAY
Fix #231
1 parent ebf3d4e commit 06ec0b6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ bool AudioDecoder::decodeNextFrame(Frame& frameBuffer)
8989

9090
const bool nextPacketRead = _inputStream->readNextPacket(data);
9191
// if error or end of file
92-
if(!nextPacketRead)
92+
if(!nextPacketRead && !decodeNextFrame)
9393
{
9494
data.clear();
9595
return false;
9696
}
9797

9898
// decoding
99+
// @note could be called several times to return the remaining frames (last call with an empty packet)
100+
// @see CODEC_CAP_DELAY
99101
int ret = avcodec_decode_audio4(&_inputStream->getAudioCodec().getAVCodecContext(), &frameBuffer.getAVFrame(),
100102
&got_frame, &data.getAVPacket());
101103
if(ret < 0)

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,15 @@ bool VideoDecoder::decodeNextFrame(Frame& frameBuffer)
8787

8888
const bool nextPacketRead = _inputStream->readNextPacket(data);
8989
// if error or end of file
90-
if(!nextPacketRead)
90+
if(!nextPacketRead && !decodeNextFrame)
9191
{
9292
data.clear();
9393
return false;
9494
}
9595

9696
// decoding
97+
// @note could be called several times to return the remaining frames (last call with an empty packet)
98+
// @see CODEC_CAP_DELAY
9799
const int ret = avcodec_decode_video2(&_inputStream->getVideoCodec().getAVCodecContext(), &frameBuffer.getAVFrame(),
98100
&got_frame, &data.getAVPacket());
99101
if(ret < 0)

0 commit comments

Comments
 (0)