diff mbox series

[FFmpeg-devel,7/9] avcodec/mpegutils: Return early in ff_draw_horiz_band()

Message ID GV1P250MB0737C8F0BBE3D23A2DB9F69E8F269@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 678f1b1cf4e637be9393b717d057125b93bbabf4
Headers show
Series [FFmpeg-devel,1/9] avcodec/(ffv1|h264|png|snow)dec: Remove comment out DRAW_HORIZ_BAND cap | expand

Checks

Context Check Description
yinshiyou/make_fate_loongarch64 success Make fate finished
yinshiyou/make_loongarch64 warning New warnings during build
andriy/make_fate_x86 success Make fate finished
andriy/make_x86 warning New warnings during build

Commit Message

Andreas Rheinhardt Oct. 16, 2022, 8:46 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegutils.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index ff9418232b..afbb16e201 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -53,9 +53,14 @@  void ff_draw_horiz_band(AVCodecContext *avctx,
                         int y, int h, int picture_structure,
                         int first_field, int low_delay)
 {
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
-    int vshift = desc->log2_chroma_h;
     const int field_pic = picture_structure != PICT_FRAME;
+    const AVFrame *src;
+    int offset[AV_NUM_DATA_POINTERS];
+    int i;
+
+    if (!avctx->draw_horiz_band)
+        return;
+
     if (field_pic) {
         h <<= 1;
         y <<= 1;
@@ -67,11 +72,6 @@  void ff_draw_horiz_band(AVCodecContext *avctx,
         !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
         return;
 
-    if (avctx->draw_horiz_band) {
-        const AVFrame *src;
-        int offset[AV_NUM_DATA_POINTERS];
-        int i;
-
         if (cur->pict_type == AV_PICTURE_TYPE_B || low_delay ||
            (avctx->slice_flags & SLICE_FLAG_CODED_ORDER))
             src = cur;
@@ -86,6 +86,9 @@  void ff_draw_horiz_band(AVCodecContext *avctx,
             for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
                 offset[i] = 0;
         } else {
+            const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+            int vshift = desc->log2_chroma_h;
+
             offset[0]= y * src->linesize[0];
             offset[1]=
             offset[2]= (y >> vshift) * src->linesize[1];
@@ -97,7 +100,6 @@  void ff_draw_horiz_band(AVCodecContext *avctx,
 
         avctx->draw_horiz_band(avctx, src, offset,
                                y, picture_structure, h);
-    }
 }
 
 static char get_type_mv_char(int mb_type)