From patchwork Mon Nov 27 14:10:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Izen X-Patchwork-Id: 44829 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bca6:b0:181:818d:5e7f with SMTP id fx38csp3382647pzb; Mon, 27 Nov 2023 06:10:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxtCGN82hAI4uUb2OojCGM2KrUUq4URkxheAPiMMk6eW0rSNgw38d2X4Kugj5Bh3IBKlse X-Received: by 2002:ac2:48b0:0:b0:50a:71d8:c94f with SMTP id u16-20020ac248b0000000b0050a71d8c94fmr7123212lfg.60.1701094257347; Mon, 27 Nov 2023 06:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701094257; cv=none; d=google.com; s=arc-20160816; b=CXOasUPtEs+TAUxgfP5p7s8mttrHKakoOe1p2OmAWtDyFstag7261TrdldkRcnFb1Z Wv9IseAkro2Io95aifd2wq24S2zx0+VIcjCUCLNHTcN8wX+XLMnv1D5RmV8x7GufqI9k XX/MJCeix9eDUf4LgEj7X3tEgX3X55qyKt4IMDRKHxDPT8CsI3A3zaO3XY91Im0efNGg EEO++cFucgSFoXu9Y5n4UaD5ntb1iEM8mMM3fMZxgnlUT6NF0N2iXujvKuELrO5+6KIh VFfEDtA2SOJj4h/9+MjsTGQMoF1K6Xl1vVEDODnFxSv9xN0aZIRvtjGbpIYt3Gu5Sg0z aQFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=0wkk4zIz98mE01nr+ZihwTL4gYjk7a1bA62pKwUWxJc=; fh=+bdjGe20eEUjtjncwA1dnEEVYNfJL4vyhV+sIRR4l+g=; b=c8nBZ8mtaLNl2Xaob0LEpViQnqXE0KbHQC4AKkEzl9o8jrhNkKILSFMQ0l6DIj5jRr U8iML1JNauRNn8avFqOJMsp0sJUr+wivRIdCnp8J5PNi1imEZAdxK02Oj5pLiF8xr+cX lK4cPMZBEL5SXxoN5RHHMkHISNnycmeH/3HFpIB6+gKaf+33bBR3LwSve+kyZIKBW2ee e3D2sPucPpOIakbM70jFwysYJvxYol6MIkDt5Gs1MKJMXsyiAUbFZyD5nsLNfoIo6/hy RljSP2J4it7BFiZxtI3gTTr73JM4MTXgS3RJewrvBMDscOXHwIZtL0Imx6dZuv4UvDN0 cI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=WnnttLh2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 22-20020a508e16000000b0054b4f63354dsi1574253edw.493.2023.11.27.06.10.56; Mon, 27 Nov 2023 06:10:57 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=WnnttLh2; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A4F7068CF29; Mon, 27 Nov 2023 16:10:24 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 78DF268CD3F for ; Mon, 27 Nov 2023 16:10:14 +0200 (EET) Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-77773d3246aso3173485a.1 for ; Mon, 27 Nov 2023 06:10:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701094213; x=1701699013; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FBbZANov46ynIfWYgvrkbCcQDXJVS2J3qSQa6VJhbNw=; b=WnnttLh28dpbUBdj1rsOuDMI4MiKJUSpNizIySZxmIXWIoqnDK8SWklpR3iTlnHp4F 30A2n9Zu1kBWHesus4AVlpYKVPYckZTFi6S8r+QGNonf7ncFZVR81645+UkgN5c+oveS vBcqqmQPdDIdkPHhF7heV6HNzYf5faMjrl5h6zioygpKvnaFiADj4xdUmgohjqQ2HNPD QTU4LLdS9cx0kpCUAAgkjOXvph4HkKPw8ZFoDzaAcpsu9pczLnUWVpCFUpzUYLbn7imY YFvSnmhH9w253JC9EPtVoVRTpG1JAS4zJ/NEZKbpfPENCM/Kgg1cDDLyBWOP7zvkNXiO JCzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701094213; x=1701699013; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FBbZANov46ynIfWYgvrkbCcQDXJVS2J3qSQa6VJhbNw=; b=NlcHbQoBqtihbHfCyoBXrX5JZ3NbZj+5iKK5zZL6qRAm35nBBg7ZSazywFZXJCa9iK +EDcASiM2HBa9SGh/yewlfcRiBHRU2q9J2TMbzfEUG8wyIcv3v1gmz84C5xf5VJ9Psx/ UCH8+QzyIb3iYw4MBC/MNVbaMQlHFzdxEjyz9LQ96REB79ZlaCjc/ZZFVgRh1Zelo4q/ vTh/9s26GfO/MlxOfPLtZTUF8F5ioCpvjT1aFwcOo5yXG8kdHcQ4mU5JeKKWuCe7DH1g rPNQiwvQ9MPtJWzq5Qdk6ndFlhx2If3I0ZYtjSX2+PqiDXyoRW9oRkzbSRwAze06kNLZ V4sw== X-Gm-Message-State: AOJu0Yz2YyuwwnqQkuzmzaqfo2dQrDuXMZPLG4/nMzcQD4bpVKUsZTMh wH+9u6VnJ57h36anDs3ikhwpyKqxQjQ= X-Received: by 2002:a05:620a:25d3:b0:773:a789:cd15 with SMTP id y19-20020a05620a25d300b00773a789cd15mr12691765qko.6.1701094213142; Mon, 27 Nov 2023 06:10:13 -0800 (PST) Received: from gauss.local (c-68-56-149-176.hsd1.mi.comcast.net. [68.56.149.176]) by smtp.gmail.com with ESMTPSA id tp13-20020a05620a3c8d00b0077d72f820adsm3699365qkn.115.2023.11.27.06.10.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 06:10:12 -0800 (PST) From: Leo Izen To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Nov 2023 09:10:07 -0500 Message-ID: <20231127141008.183621-3-leo.izen@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231127141008.183621-1-leo.izen@gmail.com> References: <20231127141008.183621-1-leo.izen@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/3] avcodec/jpegxl_parser: fix parsing sequences of extremely small files X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Leo Izen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: uPUOPPw7CFe7 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 --- 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;