diff mbox series

[FFmpeg-devel,09/30] lavc/libx264: reorder control flow in setup_roi() to reduce nesting depth

Message ID 20221127170351.11477-9-anton@khirnov.net
State Accepted
Commit 9ed5b0ac3b14af51f014fb1d567b9d6bf35490ac
Headers show
Series [FFmpeg-devel,01/30] lavc/libx264: factor out setting up the input frame | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Nov. 27, 2022, 5:03 p.m. UTC
---
 libavcodec/libx264.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index f0f8990cf9..342d07a829 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -338,13 +338,6 @@  static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth,
 {
     X264Context *x4 = ctx->priv_data;
 
-    if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
-        if (!x4->roi_warned) {
-            x4->roi_warned = 1;
-            av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
-        }
-    } else {
-        if (frame->interlaced_frame == 0) {
             int mbx = (frame->width + MB_SIZE - 1) / MB_SIZE;
             int mby = (frame->height + MB_SIZE - 1) / MB_SIZE;
             int qp_range = 51 + 6 * (bit_depth - 8);
@@ -353,6 +346,20 @@  static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth,
             uint32_t roi_size;
             float *qoffsets;
 
+    if (x4->params.rc.i_aq_mode == X264_AQ_NONE) {
+        if (!x4->roi_warned) {
+            x4->roi_warned = 1;
+            av_log(ctx, AV_LOG_WARNING, "Adaptive quantization must be enabled to use ROI encoding, skipping ROI.\n");
+        }
+        return 0;
+    } else if (frame->interlaced_frame) {
+        if (!x4->roi_warned) {
+            x4->roi_warned = 1;
+            av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
+        }
+        return 0;
+    }
+
             roi = (const AVRegionOfInterest*)data;
             roi_size = roi->self_size;
             if (!roi_size || size % roi_size != 0) {
@@ -395,13 +402,6 @@  static int setup_roi(AVCodecContext *ctx, x264_picture_t *pic, int bit_depth,
 
             pic->prop.quant_offsets = qoffsets;
             pic->prop.quant_offsets_free = av_free;
-        } else {
-            if (!x4->roi_warned) {
-                x4->roi_warned = 1;
-                av_log(ctx, AV_LOG_WARNING, "interlaced_frame not supported for ROI encoding yet, skipping ROI.\n");
-            }
-        }
-    }
 
     return 0;
 }