History

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)

Leo Izen committed 2 years ago

Commit c4be0801 parent 019b3ea1 file · +10 −4Browse files

Showing the changes to libavcodec (1 of 1 file). Show all

Unified · Split

libavcodec/jpegxl_parser.c+10−4
@@ -1454,15 +1454,21 @@ static int jpegxl_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 1453 unmodified lines
14541454 {
14551455 JXLParseContext *ctx = s->priv_data;
14561456 int next = END_NOT_FOUND, ret;
1457+ const uint8_t *pbuf = ctx->pc.buffer;
1458+ int pindex = ctx->pc.index;
14571459
14581460 *poutbuf_size = 0;
14591461 *poutbuf = NULL;
14601462
1461− if (!ctx->pc.index)
1462− goto flush;
1463+ if (!ctx->pc.index) {
1464+ if (ctx->pc.overread)
1465+ goto flush;
1466+ pbuf = buf;
1467+ pindex = buf_size;
1468+ }
14631469
14641470 if ((!ctx->container || !ctx->codestream_length) && !ctx->next) {
1465− ret = try_parse(s, avctx, ctx, ctx->pc.buffer, ctx->pc.index);
1471+ ret = try_parse(s, avctx, ctx, pbuf, pindex);
14661472 if (ret < 0)
14671473 goto flush;
14681474 ctx->next = ret;
@@ -1471,7 +1477,7 @@ static int jpegxl_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 2 unmodified lines
14711477 }
14721478
14731479 if (ctx->container && ctx->next >= 0) {
1474− ret = skip_boxes(ctx, ctx->pc.buffer, ctx->pc.index);
1480+ ret = skip_boxes(ctx, pbuf, pindex);
14751481 if (ret < 0) {
14761482 if (ret == AVERROR_INVALIDDATA)
14771483 ctx->next = -1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t