This patch allows the JXL parser to parse sequences of extremely small files concatenated together. (e.g. smaller than the parser buffer)
Unified · Split
| @@ -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; |