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
1454{1454{
1455 JXLParseContext *ctx = s->priv_data;1455 JXLParseContext *ctx = s->priv_data;
1456 int next = END_NOT_FOUND, ret;1456 int next = END_NOT_FOUND, ret;
1457 const uint8_t *pbuf = ctx->pc.buffer;
1458 int pindex = ctx->pc.index;
1457 1459
1458 *poutbuf_size = 0;1460 *poutbuf_size = 0;
1459 *poutbuf = NULL;1461 *poutbuf = NULL;
1460 1462
1461 if (!ctx->pc.index)1463 if (!ctx->pc.index) {
1462 goto flush;1464 if (ctx->pc.overread)
1465 goto flush;
1466 pbuf = buf;
1467 pindex = buf_size;
1468 }
1463 1469
1464 if ((!ctx->container || !ctx->codestream_length) && !ctx->next) {1470 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);
1466 if (ret < 0)1472 if (ret < 0)
1467 goto flush;1473 goto flush;
1468 ctx->next = ret;1474 ctx->next = ret;
@@ -1471,7 +1477,7 @@ static int jpegxl_parse(AVCodecParserContext *s, AVCodecContext *avctx, · 2 unmodified lines
1471 }1477 }
1472 1478
1473 if (ctx->container && ctx->next >= 0) {1479 if (ctx->container && ctx->next >= 0) {
1474 ret = skip_boxes(ctx, ctx->pc.buffer, ctx->pc.index);1480 ret = skip_boxes(ctx, pbuf, pindex);
1475 if (ret < 0) {1481 if (ret < 0) {
1476 if (ret == AVERROR_INVALIDDATA)1482 if (ret == AVERROR_INVALIDDATA)
1477 ctx->next = -1;1483 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