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 <jamr...@gmail.com>
---
 libavcodec/encode.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 9a4140f91a..aac32cd0f4 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -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;
-- 
2.31.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to