aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/jpeg2000_parser.c
diff options
context:
space:
mode:
authorTomas Härdin <git@haerdin.se>2022-05-20 14:41:38 +0200
committerTomas Härdin <git@haerdin.se>2022-06-10 10:50:12 +0200
commit01827beb70050f117a5cf6a800614b6402db7599 (patch)
tree72b8c1e660c9b8a9e6363c7eb3a6d49025f5a8bd /libavcodec/jpeg2000_parser.c
parent6704c2dd1903215f89e78dd1293247d798f58886 (diff)
downloadffmpeg-01827beb70050f117a5cf6a800614b6402db7599.tar.gz
libavcodec/jpeg2000_parser: LUTify info_marker()
This speeds find_frame_end() up by 39% according to valgrind
Diffstat (limited to 'libavcodec/jpeg2000_parser.c')
-rw-r--r--libavcodec/jpeg2000_parser.c26
1 files 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];
}
/**