diff options
author | Tomas Härdin <git@haerdin.se> | 2022-05-20 11:38:25 +0200 |
---|---|---|
committer | Tomas Härdin <git@haerdin.se> | 2022-06-10 10:50:12 +0200 |
commit | 1ee994e168dfdbed2909570e3b479b790cb2b0e8 (patch) | |
tree | 86b103099a3155d11e94aaebe9eeafcc9f8a1edd /libavcodec/jpeg2000_parser.c | |
parent | 7f3f3539e8884d541c2614819f51cc91bdf0aec4 (diff) | |
download | ffmpeg-1ee994e168dfdbed2909570e3b479b790cb2b0e8.tar.gz |
libavcodec/jpeg2000_parser: Speed up long skips
Diffstat (limited to 'libavcodec/jpeg2000_parser.c')
-rw-r--r-- | libavcodec/jpeg2000_parser.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/jpeg2000_parser.c b/libavcodec/jpeg2000_parser.c index 2975e71482..34a5487e90 100644 --- a/libavcodec/jpeg2000_parser.c +++ b/libavcodec/jpeg2000_parser.c @@ -95,6 +95,17 @@ static int find_frame_end(JPEG2000ParserContext *m, const uint8_t *buf, int buf_ state64 = state64 << 8 | buf[i]; m->bytes_read++; if (m->skip_bytes) { + // handle long skips + if (m->skip_bytes > 8) { + // need -9 else buf_size - i == 8 ==> i == buf_size after this, + // and thus i == buf_size + 1 after the loop + int skip = FFMIN(FFMIN((int64_t)m->skip_bytes - 8, buf_size - i - 9), INT_MAX); + if (skip > 0) { + m->skip_bytes -= skip; + i += skip; + m->bytes_read += skip; + } + } m->skip_bytes--; continue; } |