* [FFmpeg-devel] [PATCH 0/2] JPEG XL parser bug fixes @ 2023-11-23 23:45 Leo Izen 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpegxl_parse{, r}: use correct ISOBMFF extended size location Leo Izen 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files Leo Izen 0 siblings, 2 replies; 8+ messages in thread From: Leo Izen @ 2023-11-23 23:45 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Leo Izen Two bug fixes related to the JPEG XL parser. They're not exactly related and don't need to be applied in sequence. Leo Izen (2): avcodec/jpegxl_parse{,r}: use correct ISOBMFF extended size location avcodec/jpegxl_parser: fix parsing sequences of extremely small files libavcodec/jpegxl_parse.c | 6 +++--- libavcodec/jpegxl_parser.c | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 1/2] avcodec/jpegxl_parse{, r}: use correct ISOBMFF extended size location 2023-11-23 23:45 [FFmpeg-devel] [PATCH 0/2] JPEG XL parser bug fixes Leo Izen @ 2023-11-23 23:45 ` Leo Izen 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files Leo Izen 1 sibling, 0 replies; 8+ messages in thread From: Leo Izen @ 2023-11-23 23:45 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Leo Izen According to ISO/IEC 14996-12, size == 1 means a 64-bit extended-size field occurs *after* the 32-bit box type, not before. This fix should allow correct parsing of JXL files with extended-size boxes. Signed-off-by: Leo Izen <leo.izen@gmail.com> --- libavcodec/jpegxl_parse.c | 6 +++--- libavcodec/jpegxl_parser.c | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/jpegxl_parse.c b/libavcodec/jpegxl_parse.c index eb28e80867..7cfdd3e7d5 100644 --- a/libavcodec/jpegxl_parse.c +++ b/libavcodec/jpegxl_parse.c @@ -462,8 +462,10 @@ int ff_jpegxl_collect_codestream_header(const uint8_t *input_buffer, int input_l return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be32(&gb); + tag = bytestream2_get_le32(&gb); + if (size == 1) { - if (bytestream2_get_bytes_left(&gb) < 12) + if (bytestream2_get_bytes_left(&gb) < 8) return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be64(&gb); head_size = 16; @@ -474,8 +476,6 @@ int ff_jpegxl_collect_codestream_header(const uint8_t *input_buffer, int input_l if (size) size -= head_size; - tag = bytestream2_get_le32(&gb); - if (tag == MKTAG('j','x','l','p')) { uint32_t idx; if (bytestream2_get_bytes_left(&gb) < 4) diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c index 630fc8a60b..750872f17f 100644 --- a/libavcodec/jpegxl_parser.c +++ b/libavcodec/jpegxl_parser.c @@ -1342,7 +1342,7 @@ static int skip_boxes(JXLParseContext *ctx, const uint8_t *buf, int buf_size) while (1) { uint64_t size; - int head_size = 4; + int head_size = 8; if (bytestream2_peek_le16(&gb) == FF_JPEGXL_CODESTREAM_SIGNATURE_LE) break; @@ -1353,16 +1353,17 @@ static int skip_boxes(JXLParseContext *ctx, const uint8_t *buf, int buf_size) return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be32(&gb); + bytestream2_skip(&gb, 4); // tag if (size == 1) { - if (bytestream2_get_bytes_left(&gb) < 12) + if (bytestream2_get_bytes_left(&gb) < 8) return AVERROR_BUFFER_TOO_SMALL; size = bytestream2_get_be64(&gb); - head_size = 12; + head_size = 16; } if (!size) return AVERROR_INVALIDDATA; /* invalid ISOBMFF size */ - if (size <= head_size + 4 || size > INT_MAX - ctx->skip) + if (size <= head_size || size > INT_MAX - ctx->skip) return AVERROR_INVALIDDATA; ctx->skip += size; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files 2023-11-23 23:45 [FFmpeg-devel] [PATCH 0/2] JPEG XL parser bug fixes Leo Izen 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpegxl_parse{, r}: use correct ISOBMFF extended size location Leo Izen @ 2023-11-23 23:45 ` Leo Izen 2023-11-26 10:56 ` Anton Khirnov 1 sibling, 1 reply; 8+ messages in thread From: Leo Izen @ 2023-11-23 23:45 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Leo Izen 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@gmail.com> --- 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; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files Leo Izen @ 2023-11-26 10:56 ` Anton Khirnov 2023-11-26 13:47 ` Leo Izen 0 siblings, 1 reply; 8+ messages in thread From: Anton Khirnov @ 2023-11-26 10:56 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Leo Izen Would be nice to have tests for these. -- Anton Khirnov _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files 2023-11-26 10:56 ` Anton Khirnov @ 2023-11-26 13:47 ` Leo Izen 2023-11-26 18:07 ` Thilo Borgmann via ffmpeg-devel 0 siblings, 1 reply; 8+ messages in thread From: Leo Izen @ 2023-11-26 13:47 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: samples-request On 11/26/23 05:56, Anton Khirnov wrote: > Would be nice to have tests for these. > I have a sample at: https://buzo.us/l.jxl It would test both of these patches. I can send a fate test for these to the ML if the sample gets uploaded. I CC'd samples-request@ffmpeg.org as well. - Leo Izen (Traneptora) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files 2023-11-26 13:47 ` Leo Izen @ 2023-11-26 18:07 ` Thilo Borgmann via ffmpeg-devel 2023-11-26 23:33 ` Leo Izen 0 siblings, 1 reply; 8+ messages in thread From: Thilo Borgmann via ffmpeg-devel @ 2023-11-26 18:07 UTC (permalink / raw) To: Leo Izen Cc: Thilo Borgmann, samples-request, FFmpeg development discussions and patches > Am 26.11.2023 um 14:47 schrieb Leo Izen <leo.izen@gmail.com>: > On 11/26/23 05:56, Anton Khirnov wrote: >> Would be nice to have tests for these. > > I have a sample at: https://buzo.us/l.jxl > > It would test both of these patches. I can send a fate test for these to the ML if the sample gets uploaded. I CC'd samples-request@ffmpeg.org as well. Can do this in a bit. What about the file you‘d sent to samples-request in August, is there still a test to be pushed about it as well? -Thilo _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files 2023-11-26 18:07 ` Thilo Borgmann via ffmpeg-devel @ 2023-11-26 23:33 ` Leo Izen 2023-11-27 9:49 ` Thilo Borgmann via ffmpeg-devel 0 siblings, 1 reply; 8+ messages in thread From: Leo Izen @ 2023-11-26 23:33 UTC (permalink / raw) To: FFmpeg Development; +Cc: samples-request On 11/26/23 13:07, Thilo Borgmann wrote: > > >> Am 26.11.2023 um 14:47 schrieb Leo Izen <leo.izen@gmail.com>: >> On 11/26/23 05:56, Anton Khirnov wrote: >>> Would be nice to have tests for these. >> >> I have a sample at: https://buzo.us/l.jxl >> >> It would test both of these patches. I can send a fate test for these to the ML if the sample gets uploaded. I CC'd samples-request@ffmpeg.org as well. > > Can do this in a bit. What about the file you‘d sent to samples-request in August, is there still a test to be pushed about it as well? > > -Thilo There is not, that sample from August was already uploaded and the fate test utilizing it has been merged. - Leo Izen (Traneptora) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files 2023-11-26 23:33 ` Leo Izen @ 2023-11-27 9:49 ` Thilo Borgmann via ffmpeg-devel 0 siblings, 0 replies; 8+ messages in thread From: Thilo Borgmann via ffmpeg-devel @ 2023-11-27 9:49 UTC (permalink / raw) To: Leo Izen, FFmpeg Development; +Cc: Thilo Borgmann, samples-request On 27.11.23 00:33, Leo Izen wrote: > On 11/26/23 13:07, Thilo Borgmann wrote: >> >> >>> Am 26.11.2023 um 14:47 schrieb Leo Izen <leo.izen@gmail.com>: >>> On 11/26/23 05:56, Anton Khirnov wrote: >>>> Would be nice to have tests for these. >>> >>> I have a sample at: https://buzo.us/l.jxl >>> >>> It would test both of these patches. I can send a fate test for >>> these to the ML if the sample gets uploaded. I CC'd >>> samples-request@ffmpeg.org as well. >> >> Can do this in a bit. What about the file you‘d sent to >> samples-request in August, is there still a test to be pushed about >> it as well? >> >> -Thilo > > There is not, that sample from August was already uploaded and the > fate test utilizing it has been merged. Ok, then its done: e19bb66167c096e86f8cf567a7df3528 fate-suite/jxl/l.jxl -Thilo _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-11-27 9:49 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-23 23:45 [FFmpeg-devel] [PATCH 0/2] JPEG XL parser bug fixes Leo Izen 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 1/2] avcodec/jpegxl_parse{, r}: use correct ISOBMFF extended size location Leo Izen 2023-11-23 23:45 ` [FFmpeg-devel] [PATCH 2/2] avcodec/jpegxl_parser: fix parsing sequences of extremely small files Leo Izen 2023-11-26 10:56 ` Anton Khirnov 2023-11-26 13:47 ` Leo Izen 2023-11-26 18:07 ` Thilo Borgmann via ffmpeg-devel 2023-11-26 23:33 ` Leo Izen 2023-11-27 9:49 ` Thilo Borgmann via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git