From patchwork Sat Jun 10 18:31:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42029 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1980135pzb; Sat, 10 Jun 2023 11:31:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4QGh9aYwGmSgx85j0vGH1vRWhCGB/vo3gli/BC4m0EEbnyjFeFbfGiDBfDoXOIPQhHHkro X-Received: by 2002:aa7:d047:0:b0:514:95ce:fb24 with SMTP id n7-20020aa7d047000000b0051495cefb24mr1504846edo.40.1686421882815; Sat, 10 Jun 2023 11:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686421882; cv=none; d=google.com; s=arc-20160816; b=RvuIEDNPVI4YVzuRKI50/SiXA++g5tVoJsqnzZi6D8hj6ePDBBOKn3Z0uJG4L55D9c iUWOybRvUMZimBy10zdE7lXRtwBk1D9XnR8PUZ2U9lDcRrzEBmPHHvYDskNTD2vW3OCJ VubYHXOqZl0mzhE9HahvmBWSiqljTS1JmfIwjZU5OYVHHsKviB6p/pisrWhD1+r8aSZO hrzVH+zIgeIRlD8RHWI9Lj01MH+9eOPVZ3aK/wSp4Pwen0fs869ePUwcp/XCZ3rEsSG6 gxqRs2KyAY69Ay4jqZthT/CkXjcVgOadwOHFxHpYv68oaW8LlmTgI+jsaVwRjxTtGadH GgUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=ZSZQKCFkfA9NdhDa6Pr/zih/llY0p51j3NY5RFSgvIQ=; b=xgyTjV0Pw0XYc7iPT+pVUAKi+04rm5+TB5FJdl8SAcKujkAfnexA5sn1EP8J4PadeJ llk42xc9PSNM0ZbHQ0VbuW576b5FliW9KYeYnuptwJOpCpIKa8XUfcDQg4L2h3zcEQE9 zCp7Exsi0J0soibL5HQGPdO36wXtldP3EW3UZUPwOs44Oh+nVe/wx75pnwv6W4S5Slji kEiFLiDG5z7o5K4D/WWdoRksFsr5xBf0m1d7x/GSLkLEhWOpb/7Ib7RSLa8vcHPXwTQx ct7P77/6/H/gYoV9zmXLRNWNsbWgqWi0ZF7CPXRaBlQuWrkup9rUAquoimGH+YT4awBu W9Mg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k12-20020aa7d8cc000000b00516a193597esi3745546eds.508.2023.06.10.11.31.22; Sat, 10 Jun 2023 11:31:22 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5901868C238; Sat, 10 Jun 2023 21:31:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-02-1.mymagenta.at (mail-02-1.mymagenta.at [80.109.253.248]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2656668BE2D for ; Sat, 10 Jun 2023 21:31:11 +0300 (EEST) Received: from [192.168.232.136] (helo=ren-mail-psmtp-mg02.) by mail-02.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1q83Mk-002Mwk-GN for ffmpeg-devel@ffmpeg.org; Sat, 10 Jun 2023 20:31:10 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg02. with ESMTP id 83Mkqh99MbZLD83MkqrD2f; Sat, 10 Jun 2023 20:31:10 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=6484c16f a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=b94tihQPeBZ0Eo0hxYQA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 10 Jun 2023 20:31:08 +0200 Message-Id: <20230610183109.24802-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4xfOt7t3tewVzs4dB2kZUa44Cq5J6gmCVwrRRmzcreU0XbIn+M7veMMvvaF1nt++2hb1pT0oUgFrl8e4XmkMZcZhGJcfk1ESZ9DRIJAq+F9XGQmqYUtpp4 y7dVlCXzYAqJNsYKsJpcAOaRIVFxKjX1Zv7zupYj/UJiGXQvwdpoJYpjVWWYrh+xEUTkZni2i2EahQ== Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Check for reduction factor and image offset 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZwRa+gfG8sU/ This combination is not working (it writes out of array) Signed-off-by: Michael Niedermayer --- libavcodec/jpeg2000dec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 0e95cca64e..d6f2a5938e 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -238,6 +238,11 @@ static int get_siz(Jpeg2000DecoderContext *s) return AVERROR_INVALIDDATA; } + if (s->reduction_factor && (s->image_offset_x || s->image_offset_y) ){ + av_log(s->avctx, AV_LOG_ERROR, "reduction factor with image offsets is not fully implemented"); + return AVERROR_PATCHWELCOME; + } + s->ncomponents = ncomponents; if (s->tile_width <= 0 || s->tile_height <= 0) { From patchwork Sat Jun 10 18:31:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42030 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1980179pzb; Sat, 10 Jun 2023 11:31:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5jsswxR8+9cgA6wE0OKOFOkJZEnoG2uml4pWhzJuAvUaGxg0KJ0iCE+anl8NmWB9vTrW4J X-Received: by 2002:a05:6402:114c:b0:50b:fb85:8608 with SMTP id g12-20020a056402114c00b0050bfb858608mr1866727edw.25.1686421892967; Sat, 10 Jun 2023 11:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686421892; cv=none; d=google.com; s=arc-20160816; b=m3raP1QyzTWj7Y++eH40gOpNkmBEA0R87OpDqTs4e+CCqW4w755iW6cm3vHnOLYqO8 QdjP4yB9ekJhM2AtjngpNVDkiz4FqXPKPJ1YX3+UTzIHHrXxyYz0BkKP/nrXSZxqKTgX 63vbmXRmVkOlcUfnByLuIkSqmVVfaiVE8qjvp6Y2Lu07+cexy4mgnMhMvfRX1G4uS0dF wKUdg6A/0lGcK+aHxYuBdp6QcpHgolQEgchuP9fI7Rif3+koTXNpvY+NWhM5BBj0RDVr wxiN1rh0M8UQSfpHuW0B7NPHw5jegxOzvaN7k+m2Nz4Nj1bOMQaJghgvRq2kAlgSuKDY HKZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=4S8DUsMRbroPASeQeah5SegSualQed57XVakixr+BF0=; b=0IRM+RJxiyZYb4X5+VlgcqPksUqQzTn/yyQaB+0HBglz6Bx//HosISJBZnRdhv9ZEv T/9OKSfSGPU5feOOT/4FSLFSshWnd7MSeD5r8E9VXSRMB8JOncQ/5Oukhn11ulTbbDbd eZiwbDIYj6B1iVrSK48x58/7HwsrjBmrxv5N6d8+VAZu8iNOWO56S+il61c3UaJukAZN PwyDbTxdb6u+e4ksfYJyBUHxrF9nul+IpDQyKQzc8boKBP/hjrXkh7Aq41krK6b4gM2D pQzu1D0bpzLE4GJiypOtoygbRhuUPlq2NtCmlwj0uJEKsQROLbrFXvyOR3WdGeYuKvMZ VJEA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n17-20020aa7d051000000b00514b3dadb55si3723424edo.440.2023.06.10.11.31.32; Sat, 10 Jun 2023 11:31:32 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D18768C2DD; Sat, 10 Jun 2023 21:31:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-01-1.mymagenta.at (mail-01-1.mymagenta.at [80.109.253.246]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5EB1B68C1E4 for ; Sat, 10 Jun 2023 21:31:11 +0300 (EEST) Received: from [192.168.232.136] (helo=ren-mail-psmtp-mg02.) by mail-01.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1q83Mk-008ptB-53 for ffmpeg-devel@ffmpeg.org; Sat, 10 Jun 2023 20:31:10 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg02. with ESMTP id 83Mlqh99bbZLD83MlqrD2h; Sat, 10 Jun 2023 20:31:11 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=6484c16f a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=QPWRdqB2bE_9f4uji3IA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 10 Jun 2023 20:31:09 +0200 Message-Id: <20230610183109.24802-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230610183109.24802-1-michael@niedermayer.cc> References: <20230610183109.24802-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4xfOt7t3tewVzs4dB2kZUa44Cq5J6gmCVwrRRmzcreU0XbIn+M7veMMvvaF1nt++2hb1pT0oUgFrl8e4XmkMZcZhGJcfk1ESZ9DRIJAq+F9XGQmqYUtpp4 y7dVlCXzYAqJNsYKsJpcAOaRIVFxKjX1Zv7zupYj/UJiGXQvwdpoJYpjVWWYrh+xEUTkZni2i2EahQ== Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: jpeg2000 has its own lowres option 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 46xc6i0S6eBX jpeg2000 overrides the global lowres variable with a lowres field called reduction_factor ffmpeg -lowres X causes the reduction_factor to be set ffplay -lowres X causes both lowres and the reduction_factor to be set ossfuss sets only lowres only the ffmpeg variant works. This patch tries to make the other 2 work. Alternative we could just error out if things are inconsistent. More complex restructuring should be limited to the master branch to keep this reasonably easy to backport Fixes: out of array access Fixes: 59672/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpeg2000dec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index d6f2a5938e..dc484344ab 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -308,7 +308,7 @@ static int get_siz(Jpeg2000DecoderContext *s) dimy = FFMAX(dimy, ff_jpeg2000_ceildiv(o_dimy, s->cdy[i])); } - ret = ff_set_dimensions(s->avctx, dimx, dimy); + ret = ff_set_dimensions(s->avctx, dimx << s->avctx->lowres, dimy << s->avctx->lowres); if (ret < 0) return ret; @@ -2426,6 +2426,14 @@ static av_cold int jpeg2000_decode_init(AVCodecContext *avctx) { Jpeg2000DecoderContext *s = avctx->priv_data; + if (avctx->lowres) + av_log(avctx, AV_LOG_WARNING, "lowres is overriden by reduction_factor but set anyway\n"); + if (!s->reduction_factor && avctx->lowres < JPEG2000_MAX_RESLEVELS) { + s->reduction_factor = avctx->lowres; + } + if (avctx->lowres != s->reduction_factor && avctx->lowres) + return AVERROR(EINVAL); + ff_jpeg2000dsp_init(&s->dsp); ff_jpeg2000_init_tier1_luts();