From patchwork Fri Sep 23 15:40:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38195 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp543448pzh; Fri, 23 Sep 2022 08:41:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6eJNm9LcyPiJCgIKboZeV9Cbsh1BIjn9i53Q0IH44nyo86AkTXogMmL5/5PBXJOKc3k1xL X-Received: by 2002:a17:907:2c74:b0:77d:5a0e:bb8f with SMTP id ib20-20020a1709072c7400b0077d5a0ebb8fmr7203324ejc.579.1663947663653; Fri, 23 Sep 2022 08:41:03 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s1-20020a508d01000000b0044f0eedd1d7si8173651eds.438.2022.09.23.08.41.02; Fri, 23 Sep 2022 08:41:03 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=mAMOLuIX; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 91D4068B9F1; Fri, 23 Sep 2022 18:40:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-oln040092066051.outbound.protection.outlook.com [40.92.66.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD05368B9F1 for ; Fri, 23 Sep 2022 18:40:52 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nx/zyW84lAZGi+m28iZi58yqJwsJOhntiVaVlpplztQxMNHbJOFH/AHAc12QeT8RMTlO2jcyFJvwg0uucJdvZuFguZ2xCkwYaMK813sC6sHtSEI8FSUeIBl4xTm3d0jKi6bHpuhLgGYjjpevIHcGAlREA3DJb/tPPNio/yqKqGP67cBhxtGIFVeuuDsKinchHAXHGghNmb/NiQysmtirAvYA/E6/LugUziHRsv5vscTYlk9qcG9tqDzI5LPxr7JwCDnnaedSpxuDvc8ARiwm6J7ynYmLvGo9MEtnnrEb09d78efOtNixdTXC9Tyhdn64kjl58S28Agvy7ndcFUTdjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Mq6CflNJjf6AfxMwej6OqhChT8dmOZS3sxFhZL13Ps8=; b=hmnU2DimjKL2kzTx4xj5mBkmiaD/WykXEB2HO24UkP5xlOnkIXyn0LA9dK8EEkGV7aQr7Fca8j4U2HGCqrp3NbY8pxB7I887d1n1Z4PLLWwKX8RtnUVRIKYAlwciIFqUVSd8cn7TiOXGjd3cpDBtS8uH6EHUYkekcnbboj9wCXv2mTMO3NGY0aT/QTi0YMehgwFrAfJwdMuySTgDhI+8Un2bo3qnrJ+fUtdGPbALUU2ZCTv0KMVAXGXWisxAbGVVbcaHDpyoTR6sesE5TNItC6DXUaGMh2Ki1Pux5pH3vpX7G9CTXbQsZrKktOqPA069MO4Yl0bs/P2UvMcBxD967Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Mq6CflNJjf6AfxMwej6OqhChT8dmOZS3sxFhZL13Ps8=; b=mAMOLuIXRmpmKRmyiV0nuqkBNzTbQadCtQyUyI+UDNBTRaUcGCI2KYWGFlWaevewsBzY06va5bejYCe0nI08e6iD7f4m5fbEvCzu6W59ZJenjE9Fw3Xwu0haZL8Rdxlu+mMzM6kCpLPghafO8Eoya/uMHTQ/lD+fdXk37C3iDTyQdA/qw+iLJczz1+uNddeKqk/fi+GOrQU+LPRFJU2sBGS85KDSnUKsTuloYwRt5JQxGSj/UFnbW7EovioqdvzxH4K28cMIrjIDplqzANLykHrYqiGwzfCQoyWsJ+9HiRXI9otbOL7zoumIETQ5haiR3kfNYY+s7bF5CoyiUyuLXw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0036.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:14f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.20; Fri, 23 Sep 2022 15:40:51 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::85ac:1b92:90f:dc18]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::85ac:1b92:90f:dc18%4]) with mapi id 15.20.5654.016; Fri, 23 Sep 2022 15:40:51 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 23 Sep 2022 17:40:48 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [Wse/w9ooM4pd2dXkfO3xm1VaaowDsqYS] X-ClientProxiedBy: ZR0P278CA0036.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1c::23) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20220923154049.1432734-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0036:EE_ X-MS-Office365-Filtering-Correlation-Id: 873bbbd9-91f0-4e49-209e-08da9d79fe6f X-MS-Exchange-SLBlob-MailProps: EgT5Wr3QDKzgWmsM/PqOIfG1x8QGmUo9vInoTfGrjFFSDYnObV71U8U6YqDWE56QHg13mJizPP5cAXHBJkwKD63ceObMUgoV5VHlLSX/JhdGrLujiZ8Z34n7kltUV6ZUmfj2Xr0FKg7TXhYXr3v4E4SfsToS2upsB5ROH9wihYVzk1fJtPoH82BLI0XtgkWZtKUVyRXj1VlpG1VttjKDG6eJUsawpJTXgM/kmdlfnLEwZzUu1Sp1wbrPa4rxI+e32Jz8MHZCuWENMGa8acmzt7UXjoQdsKLioRO6FmwHpz81+fZEkoA1NKa0I4+PfuDW6DMFcbR0tjg6gDnIqnQusQ01Ep3Sqt/nH8crPn3903j12b/Ymoq/yxFTZwB/PCl44TZBo/6UOk+bv87+Bk4IVnQQkxpAcOD2+8vFsoiHyYJeeFauIsLrFEmXJkuJqhp/tZzgEVnWl64F9Jf6Tbo3cbsesGkst/LhbD1kDBPTi6PtUn8yNYiykut18/7LfjUVOAB/Np+9D1om0rlk6iP4AmTADV3dnwYzNOQ7ZzpLMhGKaa4Dvt0O3/K0dm+QsaoeWSPPXQlBf4iI/8sqLunwywzBAlk/NEl6mWXC93rsa0QJHJTc5fmsU+eKATFA4K/hbq7oJeMYNUMr4aE/fvkXmKoOwkCdngcQfwrHZFy8cuJilqr12hO/2XGyowsiP5WRybxRmnXTF+pmaFbIjukp0/FYfE5xUgosPG1ljjbCzKg= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NzrJZI5Y2wIlKV6mbvEECpto155XvX0X6dPK7vpH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CmiQpuZdiWVrd9/ov3gvbPil4IdJ2WfUQMZTFQGE9xkO0PplRjn+TjwWjnAIVlsgQF61c3T4mof3GvyQB1qS+drJ4cttj5j5Pta6bodKWNqVXk2TE7J3yRvwZ6qJT+aS5mTJGJHPleECuYuAz1bVJwG3BeFniCGrbkOpsJPHkaSA8XbD3n27CBqcVTvLQVH0XQpuBsd0PH+9if27Or4JqMOkWAcZjuxDqI9peWWNRr8VLcNDLjYYQbKyJnYniTQLxpprC3H/3goitYlfYZtncCM+FhvK6Jw8py1qp3YeYvLFC8+S4Rb2W5/Pl6EpRaUZajM5y5qu0KY51KzNW/XSAb/s6X4li4pV56r4tvjevWoUOJPHjt38/LNtfCJTLFSwC9qsiOj19ezF5zy7kyZrcNSqlK76zAPpNDVIl1l/B7ji5svO48pD/3Rl9Sk4Pm1Vpugyo8bSg9FRzeBdDbuUtzkQSUuixPveIPK8SACL9Syef19dqNlBN38QAov9bQNp/fudZJHV4NbxE5+t1c2zjkC7fFxAcCaALVnodMdiCDo9L1liy/Lj1Ljr19A1yZukBtz7T1m3HTbj2rEPOSmv7zyq3IA7ysF7n8wRUoUHMZSxoLRYEfrjO05iXJxZ9PPgBK+d39+2NtwKLPZ59eV8luYWrNafv+9HTf/l5WMV2xkknjVFkSbk/EPCaUZV0VkPV0AggebyQ338VBIZm30KseRRxi/0pDoaQktAUS6zEhjZque5klhzwkc8JBCROBNVeWQmFxJPSekSXzvTUCI1eSAHdu231hRJNE0CjXoMsHsMCoBnM+iMyAvyv9zC5pB3D/MgLvx7S/22REbvwK5wp9nzKDDnwGqUanNhsyAWkfdbNLIgrqfL6owEQNEdyeOMzwOJ66NQyUWAReRK1VrZENMhO3h5nrQwiiJ1dlWGb X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 873bbbd9-91f0-4e49-209e-08da9d79fe6f X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2022 15:40:51.4445 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0036 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/jpeg2000dec: Set sample aspect ratio before getting buffer 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sGMOSuBZ9XTL That way the SAR will be automatically set on the AVFrame. Signed-off-by: Andreas Rheinhardt --- If I am not mistaken, then the earlier code would set the sar with a delay of one frame on the returned frames in case there is a sar change mid-stream. But I don't have a sample for this. libavcodec/jpeg2000dec.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 7d9661f29f..c3f2a7aa03 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -2519,6 +2519,10 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (ret = jpeg2000_read_main_headers(s)) goto end; + if (s->sar.num && s->sar.den) + avctx->sample_aspect_ratio = s->sar; + s->sar.num = s->sar.den = 0; + /* get picture buffer */ if ((ret = ff_thread_get_buffer(avctx, picture, 0)) < 0) goto end; @@ -2547,9 +2551,6 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) memcpy(picture->data[1], s->palette, 256 * sizeof(uint32_t)); - if (s->sar.num && s->sar.den) - avctx->sample_aspect_ratio = s->sar; - s->sar.num = s->sar.den = 0; return bytestream2_tell(&s->g);