diff mbox series

[FFmpeg-devel,3/7] avcodec/iff: Return early when possible

Message ID DB6PR0101MB22144D99865EC86A021087A68F869@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit d0df74553bebdc33e960ea9bce9bfb323c0a1bd7
Headers show
Series [FFmpeg-devel,1/7] avcodec/iff: Split extract_header into extradata and packet part | 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 July 12, 2022, 10:27 a.m. UTC
It allows to save one level of indentation.

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

Patch

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index f14644471b..13912e9133 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -223,7 +223,9 @@  static int extract_header(AVCodecContext *const avctx)
             return AVERROR_INVALIDDATA;
         }
 
-    if (buf_size >= 41) {
+    if (buf_size < 41)
+        return 0;
+
         s->compression  = bytestream_get_byte(&buf);
         s->bpp          = bytestream_get_byte(&buf);
         s->ham          = bytestream_get_byte(&buf);
@@ -316,7 +318,6 @@  static int extract_header(AVCodecContext *const avctx)
                     s->ham_palbuf[(1 << s->bpp) + i] = s->ham_palbuf[i] | 0xFF000000;
             }
         }
-    }
 
     return 0;
 }
@@ -1470,10 +1471,12 @@  static int parse_packet_header(AVCodecContext *const avctx,
     IffContext *s = avctx->priv_data;
     int i;
 
-    if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) {
         uint32_t chunk_id;
         uint64_t data_size;
 
+    if (avctx->codec_tag != MKTAG('A', 'N', 'I', 'M'))
+        return 0;
+
         bytestream2_skip(gb, 4);
         while (bytestream2_get_bytes_left(gb) >= 1) {
             chunk_id  = bytestream2_get_le32(gb);
@@ -1517,7 +1520,6 @@  static int parse_packet_header(AVCodecContext *const avctx,
                 bytestream2_skip(gb, data_size + (data_size&1));
             }
         }
-    }
 
     return 0;
 }