[FFmpeg-devel] [PATCH 2/2] lavc/encode: set frame_number for encoders using receive_packet()

Anton Khirnov anton at khirnov.net
Mon Dec 13 12:47:26 EET 2021


It is currently set in encode_simple_internal(), which is only called
for encoders using the "simple" encoding API.
---
 libavcodec/encode.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 5575cf23db..618be0573d 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -247,11 +247,8 @@ end:
     if (ret < 0 || !got_packet)
         av_packet_unref(avpkt);
 
-    if (frame) {
-        if (!ret)
-            avctx->frame_number++;
+    if (frame)
         av_frame_unref(frame);
-    }
 
     if (got_packet)
         // Encoders must always return ref-counted buffers.
@@ -383,6 +380,8 @@ int attribute_align_arg avcodec_send_frame(AVCodecContext *avctx, const AVFrame
             return ret;
     }
 
+    avctx->frame_number++;
+
     return 0;
 }
 
-- 
2.33.0



More information about the ffmpeg-devel mailing list