@@ -259,11 +259,6 @@ end:
av_frame_unref(frame);
}
- if (got_packet)
- // Encoders must always return ref-counted buffers.
- // Side-data only packets have no data and can be not ref-counted.
- av_assert0(!avpkt->data || avpkt->buf);
-
return ret;
}
@@ -301,14 +296,15 @@ static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt
ret = avctx->codec->receive_packet(avctx, avpkt);
if (ret < 0)
av_packet_unref(avpkt);
- else
- // Encoders must always return ref-counted buffers.
- // Side-data only packets have no data and can be not ref-counted.
- av_assert0(!avpkt->data || avpkt->buf);
} else
ret = encode_simple_receive_packet(avctx, avpkt);
- if (ret == AVERROR_EOF)
+ if (!ret) {
+ // Encoders must always return ref-counted buffers.
+ av_assert0(!avpkt->data || avpkt->buf);
+ // Side-data only packets have no data and can be not ref-counted.
+ av_assert0(avpkt->data || avpkt->side_data);
+ } else if (ret == AVERROR_EOF)
avci->draining_done = 1;
return ret;
The current checks ensured that if they contained data, it was refcounted, but then wrongly assumed that side data was present if there was no data, instead of checking for it. Signed-off-by: James Almer <jamrial@gmail.com> --- libavcodec/encode.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)