diff mbox series

[FFmpeg-devel,4/4] avcodec/mobiclip: Rewrite code to make it more clearer

Message ID AM7PR03MB666090B2DF4DE2E13B1CA9BE8F9B9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit d6c16c5217a8d2cbb754d44bf1206479fe5f906d
Headers show
Series [FFmpeg-devel,1/4] fftools/cmdutils: Fix undefined 1 << 31 | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 18, 2021, 9:13 a.m. UTC
In order to know that the earlier code did not use uninitialized
values one needs to know that the lowest four bits of each used
value of pframe_block4x4_coefficients_tab do not vanish identically.
E.g. Coverity did not get this and warned about it in ticket #1466632.
Fix this by slightly rewriting the code.

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

Patch

diff --git a/libavcodec/mobiclip.c b/libavcodec/mobiclip.c
index 6ea1c3eefa..23d64f76f6 100644
--- a/libavcodec/mobiclip.c
+++ b/libavcodec/mobiclip.c
@@ -491,7 +491,7 @@  static int add_pframe_coefficients(AVCodecContext *avctx, AVFrame *frame,
     int ret, idx = get_ue_golomb_31(gb);
 
     if (idx == 0) {
-        ret = add_coefficients(avctx, frame, bx, by, size, plane);
+        return add_coefficients(avctx, frame, bx, by, size, plane);
     } else if ((unsigned)idx < FF_ARRAY_ELEMS(pframe_block4x4_coefficients_tab)) {
         int flags = pframe_block4x4_coefficients_tab[idx];
 
@@ -505,11 +505,10 @@  static int add_pframe_coefficients(AVCodecContext *avctx, AVFrame *frame,
                 flags >>= 1;
             }
         }
+        return 0;
     } else {
-        ret = AVERROR_INVALIDDATA;
+        return AVERROR_INVALIDDATA;
     }
-
-    return ret;
 }
 
 static int adjust(int x, int size)