diff mbox series

[FFmpeg-devel,7/8] libavcodec/jpeg2000_parser: Localize m->bytes_read

Message ID 497a7012a874adea218562dbb405e87996fa77f8.camel@acc.umu.se
State New
Headers show
Series [FFmpeg-devel,1/8] libavcodec/jpeg2000_parser: Speed up long skips | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Tomas Härdin May 31, 2022, 10:01 a.m. UTC

Comments

Michael Niedermayer June 1, 2022, 4:38 p.m. UTC | #1
On Tue, May 31, 2022 at 12:01:12PM +0200, Tomas Härdin wrote:
> 

>  jpeg2000_parser.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> a16f2b29057a6e89ef7a03529fb4c66ecc704094  0007-libavcodec-jpeg2000_parser-Localize-m-bytes_read.patch
> From 7b5e442033f0691bddbe2c2a0292f4abffd46c3d Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
> Date: Fri, 20 May 2022 14:50:00 +0200
> Subject: [PATCH 7/8] libavcodec/jpeg2000_parser: Localize m->bytes_read
> 
> Another 6%
> ---
>  libavcodec/jpeg2000_parser.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

This didnt apply without #1 so i could not test but it should be ok

thx

[...]
diff mbox series

Patch

From 7b5e442033f0691bddbe2c2a0292f4abffd46c3d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Fri, 20 May 2022 14:50:00 +0200
Subject: [PATCH 7/8] libavcodec/jpeg2000_parser: Localize m->bytes_read

Another 6%
---
 libavcodec/jpeg2000_parser.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c
index e66ef0e1f0..de73196855 100644
--- a/libavcodec/jpeg2000_parser.c
+++ b/libavcodec/jpeg2000_parser.c
@@ -95,6 +95,7 @@  static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_
     ParseContext *pc= &m->pc;
     int i;
     uint64_t state64 = pc->state64;
+    uint64_t bytes_read = m->bytes_read;
 
     if (buf_size == 0) {
         return 0;
@@ -102,7 +103,7 @@  static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_
 
     for (i = 0; i < buf_size; i++) {
         state64 = state64 << 8 | buf[i];
-        m->bytes_read++;
+        bytes_read++;
         if (m->skip_bytes) {
             // handle long skips
             if (m->skip_bytes > 8) {
@@ -112,7 +113,7 @@  static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_
                 if (skip > 0) {
                     m->skip_bytes -= skip;
                     i += skip;
-                    m->bytes_read += skip;
+                    bytes_read += skip;
                 }
             }
             m->skip_bytes--;
@@ -141,7 +142,7 @@  static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_
             }
             m->fheader_read--;
         }
-        if ((state64 & 0xFFFFFFFF) == 0x0000000C && m->bytes_read >= 3) { // Indicates start of JP2 file. Check signature next.
+        if ((state64 & 0xFFFFFFFF) == 0x0000000C && bytes_read >= 3) { // Indicates start of JP2 file. Check signature next.
             m->fheader_read = 8;
         } else if ((state64 & 0xFFFF) == 0xFF4F) {
             m->in_codestream = 1;
@@ -180,6 +181,7 @@  static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_
     }
 
     pc->state64 = state64;
+    m->bytes_read = bytes_read;
     return END_NOT_FOUND;
 }
 
-- 
2.30.2