diff mbox series

[FFmpeg-devel,10/13] avcodec/mpegvideo_enc: Don't call av_frame_copy_props() unnecessarily

Message ID AS8P250MB0744D0A3F7D042D02284DC508FC9A@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 2a8ac5a780539022b77d80a01ec102dec98df763
Headers show
Series [FFmpeg-devel,01/13] avcodec/mpegvideo_enc: Fix abort on allocation errors | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 6, 2023, 2:46 a.m. UTC
It is unnecessary in case of user-supplied frames, because
it happens directly after a av_frame_ref() with the same
src and dst.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegvideo_enc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 26a596430d..cb6b801b2a 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1168,6 +1168,11 @@  static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
             ret = alloc_picture(s, pic);
             if (ret < 0)
                 return ret;
+            ret = av_frame_copy_props(pic->f, pic_arg);
+            if (ret < 0) {
+                ff_mpeg_unref_picture(s->avctx, pic);
+                return ret;
+            }
 
             for (int i = 0; i < 3; i++) {
                 int src_stride = pic_arg->linesize[i];
@@ -1209,11 +1214,6 @@  static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg)
             }
             emms_c();
         }
-        ret = av_frame_copy_props(pic->f, pic_arg);
-        if (ret < 0) {
-            ff_mpeg_unref_picture(s->avctx, pic);
-            return ret;
-        }
 
         pic->display_picture_number = display_picture_number;
         pic->f->pts = pts; // we set this here to avoid modifying pic_arg