[FFmpeg-cvslog] avcodec/jpegxl_parser: fix parsing sequences of extremely small files
Leo Izen
git at videolan.org
Tue Dec 5 12:55:29 EET 2023
ffmpeg | branch: master | Leo Izen <leo.izen at gmail.com> | Mon Nov 27 09:10:07 2023 -0500| [c4be080e65a37cac5ef8ce6ba7a9e1a59cb9b7dd] | committer: Leo Izen
avcodec/jpegxl_parser: fix parsing sequences of extremely small files
This patch allows the JXL parser to parse sequences of extremely small
files concatenated together. (e.g. smaller than the parser buffer)
Signed-off-by: Leo Izen <leo.izen at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c4be080e65a37cac5ef8ce6ba7a9e1a59cb9b7dd
---
libavcodec/jpegxl_parser.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c
index 750872f17f..006eb6b295 100644
--- a/libavcodec/jpegxl_parser.c
+++ b/libavcodec/jpegxl_parser.c
@@ -1454,15 +1454,21 @@ static int jpegxl_parse(AVCodecParserContext *s, AVCodecContext *avctx,
{
JXLParseContext *ctx = s->priv_data;
int next = END_NOT_FOUND, ret;
+ const uint8_t *pbuf = ctx->pc.buffer;
+ int pindex = ctx->pc.index;
*poutbuf_size = 0;
*poutbuf = NULL;
- if (!ctx->pc.index)
- goto flush;
+ if (!ctx->pc.index) {
+ if (ctx->pc.overread)
+ goto flush;
+ pbuf = buf;
+ pindex = buf_size;
+ }
if ((!ctx->container || !ctx->codestream_length) && !ctx->next) {
- ret = try_parse(s, avctx, ctx, ctx->pc.buffer, ctx->pc.index);
+ ret = try_parse(s, avctx, ctx, pbuf, pindex);
if (ret < 0)
goto flush;
ctx->next = ret;
@@ -1471,7 +1477,7 @@ static int jpegxl_parse(AVCodecParserContext *s, AVCodecContext *avctx,
}
if (ctx->container && ctx->next >= 0) {
- ret = skip_boxes(ctx, ctx->pc.buffer, ctx->pc.index);
+ ret = skip_boxes(ctx, pbuf, pindex);
if (ret < 0) {
if (ret == AVERROR_INVALIDDATA)
ctx->next = -1;
More information about the ffmpeg-cvslog
mailing list