diff mbox series

[FFmpeg-devel,4/8] libavcodec/jpeg2000_parser: LUTify info_marker()

Message ID f6ed6aafe63460228efc73a1b231be3d2aea9239.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 a.m. UTC

Comments

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

>  jpeg2000_parser.c |   26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 7661a5b239a94ccba349c916a390d957479a9771  0004-libavcodec-jpeg2000_parser-LUTify-info_marker.patch
> From d84f106d1eac7a3ea98935d11dc65e0afe8a8fb6 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
> Date: Fri, 20 May 2022 14:41:38 +0200
> Subject: [PATCH 4/8] libavcodec/jpeg2000_parser: LUTify info_marker()
> 
> This speeds find_frame_end() up by 39% according to valgrind
> ---
>  libavcodec/jpeg2000_parser.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

From d84f106d1eac7a3ea98935d11dc65e0afe8a8fb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Fri, 20 May 2022 14:41:38 +0200
Subject: [PATCH 4/8] libavcodec/jpeg2000_parser: LUTify info_marker()

This speeds find_frame_end() up by 39% according to valgrind
---
 libavcodec/jpeg2000_parser.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c
index c6d8416d43..88e4a142f8 100644
--- a/libavcodec/jpeg2000_parser.c
+++ b/libavcodec/jpeg2000_parser.c
@@ -65,13 +65,25 @@  static inline void reset_context(JPEG2000ParserContext *m)
 */
 static uint8_t info_marker(uint16_t marker)
 {
-    if (marker == 0xFF92 || marker == 0xFF4F ||
-        marker == 0xFF90 || marker == 0xFF93 ||
-        marker == 0xFFD9)
-        return 0;
-    else
-        if (marker > 0xFF00) return 1;
-    return 0;
+    static const uint8_t lut[256] = {
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 0xFF4F
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xFF90 0xFF92 0xFF93
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, // 0xFFD9
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    };
+    return marker < 0xFF00 ? 0 : lut[marker & 0xFF];
 }
 
 /**
-- 
2.30.2