diff mbox series

[FFmpeg-devel,v4,2/8] avpriv_find_start_code(): readability enhancement part 1

Message ID 20220916182002.122699-3-scott.the.elm@gmail.com
State New
Headers show
Series rewrite avpriv_find_start_code() for clarity | 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

Scott Theisen Sept. 16, 2022, 6:19 p.m. UTC
No functional change.
---
 libavcodec/utils.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 2f57418ff7..d6ab21b1a0 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1006,10 +1006,11 @@  const uint8_t *avpriv_find_start_code(const uint8_t *av_restrict p,
         }
     }
 
-    p = FFMIN(p, end) - 4;
-    *state = AV_RB32(p);
-
-    return p + 4;
+    if (p > end)
+        p = end;
+    // read the previous 4 bytes, i.e. bytes {p - 4, p - 3, p - 2, p - 1}
+    *state = AV_RB32(p - 4);
+    return p;
 }
 
 AVCPBProperties *av_cpb_properties_alloc(size_t *size)