[FFmpeg-cvslog] libavcodec/jpeg2000_parser: LUTify info_marker()

Tomas Härdin git at videolan.org
Fri Jun 10 12:11:57 EEST 2022


ffmpeg | branch: master | Tomas Härdin <git at haerdin.se> | Fri May 20 14:41:38 2022 +0200| [01827beb70050f117a5cf6a800614b6402db7599] | committer: Tomas Härdin

libavcodec/jpeg2000_parser: LUTify info_marker()

This speeds find_frame_end() up by 39% according to valgrind

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01827beb70050f117a5cf6a800614b6402db7599
---

 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 20672fbf46..4cb7db4225 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];
 }
 
 /**



More information about the ffmpeg-cvslog mailing list