From patchwork Wed Dec 7 19:00:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39648 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp871760pzb; Wed, 7 Dec 2022 11:00:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf48/R7k95VUUW4nnpMTM6gwQVGV2PTKm/Js9XZ+hVZSDxtPiHRLkHkHJ1WTuTUwP1HQb30o X-Received: by 2002:a05:6402:2912:b0:46a:c132:8a25 with SMTP id ee18-20020a056402291200b0046ac1328a25mr50425339edb.205.1670439634656; Wed, 07 Dec 2022 11:00:34 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bb6-20020a1709070a0600b007baa6e2275asi17516431ejc.236.2022.12.07.11.00.33; Wed, 07 Dec 2022 11:00:34 -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=@outlook.com header.s=selector1 header.b=Qn3VD7bj; 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 B06646801A2; Wed, 7 Dec 2022 21:00:29 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2036.outbound.protection.outlook.com [40.92.59.36]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7CA1B689D06 for ; Wed, 7 Dec 2022 21:00:22 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W7nkM3WzPh+UFbUgFo2KJASo1pYjx1+tJQwJgNBAjK7aBpoGFOHgmqNeOal9US0Y6A9rXrZHTgXZyj6jDo3Aj2C4+/q9rOygoW5fSqberxkLP0U1ZCvQOBnl2gEG+b+Ze6haoLtGF1bx6o327bz4+K+OsQlqX2YFMooNZDomQ+KfFa2h68xqt50t3cUzVLp4GwvrdlAcPu/E+OKO8mObBfxu0BOcswiAhhAACmeRMrv1bSM3z7eF9ZFyyQM6zxUBwp5m1EVmOEeNvocF287y3Z0n38de9N3Aj6K4N871zLhrLFhC0WxSFXXEbPKGQiKw2H1EXb+IUKXP0pSPSSQB5Q== 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=aoohGYLjBz5vjPPrHTaww8K9bpWphIc0xnxpOGV0aA8=; b=Lzm/pJZ7W5NDBu3GtKAw9sVHwpXr1aAI+pyGb5D3eh3ldFQNgISuhf5nE5eDitDGOr30vKNOQ2fdaHMjTvHjz5Ck08o9X54tJj84ZRtBPtd0rtDGDUmy8o0ZzYcwc39phd4KXPY9U3bclXQeFVzRkD0b5lGoRD772HcLMhUUuKMJi9/MBt/yMBb2XhGfu6214eCCUi+NHo6CrfVJxZBJSE7w1ClNGib9abs9VVGnknVuPxJDD0e+K/eigetsLFEbEIgH47ugcyfnXfO9T8XdWkYmY/ydckVM1wbfCitBX+v7lhZ99RtpDH+gE7pTMt0Vquw8jIpu1ASatZoAmcpDUg== 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=aoohGYLjBz5vjPPrHTaww8K9bpWphIc0xnxpOGV0aA8=; b=Qn3VD7bjXhF6L70gfj8LkzTSYPGY2Zy45BmIFaK3J0EvTH/COtPauFjk5Q4PoY3ZF+gHVViWrRdvss0lMITjOKznntoPhPEfH2fhkM2BgGkas3IkAaUT+Kk9WZwJ3oeBR5TnfQPZbpwtoiiS2kglvJmAEy8pYyolzXkI5Ul7g6jOJk1kGkmkbNLSJt+6KdU8NGgjNJppF94v2gE7GdDLR7j7qymPRGkaAyqzmQReioleeN8Vr7PENXUC/gAZI36SuO11Y+Afx5pTmvVswXQM1sNRsi8Iz823PTz3AyFO0Xl5GF4N2ccVneq6lDSB/IZfVpXgoWb1XpoPYi4oVovQqg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS4P250MB0462.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4b1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 19:00:21 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%6]) with mapi id 15.20.5880.014; Wed, 7 Dec 2022 19:00:20 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Dec 2022 20:00:30 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [KzqFmq/znzX1Q8utnunMSPgtWH5zEgG5] X-ClientProxiedBy: ZR0P278CA0129.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:40::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221207190034.1724795-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS4P250MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: ee050466-57ae-4087-da92-08dad88549b7 X-MS-Exchange-SLBlob-MailProps: znQPCv1HvwUpPkvdKOVt0r5Ud+YQpzGbpKbd/goBnsgf1kWeKNVnGPDFKejJJCHRtbtUTHD4QECx4N3/qfVK/djv7TI2z3eHx0fnkYLmdCIWIY6S9iz9kn0s3gYmCBeDcFeEeS304JRFkjsdvWpNeEetct4Oe6b6xXQULVLCwC1kBbNafcUuvL/ov42C8GJLoEPKooRd3hL7P0oqP7NvaNsKX4YBhQdQhtyHGQLMO8n3JR6OPgIxFijxa236VJhpLkCSQjs33Xg8JikouDeN/2Ro6yD6cKSBjHTOatsM1Sm44GwKwop5pXYxl9vFtDDDeqaZvxiFD0Kv8Q9e+SDJWOfWTxSYFY5X6xrJs8kwH879lzsggnt1tkmpLPXVnJvcJ1qSxCoW7AmJeKcGxzHiBP3sh6OCwnX810JHg2tJjZAgC9WFU5IOBY0vWFbrBg7lyDkFH6q4oox9cpqfw6cJH4nplCX2roITQZ+bhoPU/ugLmOoLaSZ7CnYEMdaKzFsxpF1O+XmbE5t4RDlmeiOMffMDZD1dWBJkwxnHNpO3uXlJIWs58NRFhLEE31PXObaXU8zHDnD1xJrXcfv0mnqI+QKyp+GRj1En03XMn9SvRLclFijEx2z7cS9M8NS+K7U0RdSoj36DKPDrVgJFZH/515RiDbHUCh49xT4C2arPxAMI2OrZb/3uPpeILpkRnKMheyITaPWZSTqB0AKhgtxM0fmYabB0op3znqAHy6ReAZ90P/hIwLlj5r9HsCk77yY4k3CTLJGGu5Q= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W43/A85BdFrAFC2TC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zsLocQylJ8MxyDe939cxogsrFIlve+USBJRWQmlpT4Md4FDt01ZjEmnrHCMhyQL7NqcB6LCNv9V9JaCdg0YA+1QdR/KNDnC28TDRZR2aZRAxP5hvwt4fl20UPE/7CNh35fW1E9IpBf4YqwOatA4o4A6vH0vka5fgtSYV47xpaXZcTfJxgGXGrSHBq8sHAu9GO4AzmcXMNVZTWewWvSuxsHljClluhUmzkEARx9z0Le8Y4Q8yNoKkOen0yHgxBG3oU6g7/s9WUXMnbjEmzt8amOsoRnUq6PPEWxk2j740E032qdNnl6SasU5SF/abKfaA8g6RawSLn1a5kX9pAagf3BwU797psR8NS994lL6ZVQxradZUttznwuS5OF8xWZt8RTvOWGXktpbLMrdj/ZyFfRJ8pCMDdLlrX4RtrghwdSp8VfvFQHsBi274duEDu/4CqluunjJ7z2viQ8hnpYn1EpYOKXrTHEfQH7iwjRZSu48jpH2L27nwQ9f/sW/P1BQCuKc3NK3yHGGXNV3fbOnhwErlkxkaLkTbQvHYUN5kLbGnOj3Gekyo6EqhuC1MksoQXLgam9qo5JYn/4tMyHr+IF6nOl6wkJHXiSDxdpdQj1mgtnw/hfrbGq3J/jjqoM1DWI4eovpC09Nh4jD61D5jN8MbdIpHyKnKkgcSbgxYsN6+O6iI/FluQs1NcKYu6uw6+2AZ4VUWKJKY7g3MRHQe9Qv89M5Ckee7KQlFfOyZpt8VEcR8sA02N8vi/21zY9b953Zpo4v50G2eH3W9wUqE93raY1c7bWVPTY3/Tux6Z4ZigazrrF2QtJvvRy4VyS7Oj9r6tfyT/A9ZtLrJzvY9PrL2fy5SE4WQaj8d0xD2KnmLLNz6e5eik0vYFFCTV0ce9kUXqePGTd5+twnkcRLe5TSWLIskrNFAEzk1AIDIfs8XJ4zZxp6K8PPMkqKOi1JCcOzY2GKxA= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee050466-57ae-4087-da92-08dad88549b7 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 19:00:20.8988 (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: AS4P250MB0462 Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/mjpegdec: Restrict AVID MJPEG to non-SMVJPEG 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: 0ZGxfurzvUsW AVID content is not supposed to be SMVJPEG; given that both these codecs involve manipulating image dimensions and cropping dimensions, it makes sense to restrict the AVID codepaths to non-SMVJPEG codecs in order not to have to think about what if SMVJPEG happens to have a codec tag indicating AVID. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 9b7465abe7..28e2839072 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -452,7 +452,8 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s) if (ret < 0) return ret; - if ((s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || + if (s->avctx->codec_id != AV_CODEC_ID_SMVJPEG && + (s->avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || s->avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) && s->orig_height < height) s->avctx->height = AV_CEIL_RSHIFT(s->orig_height, s->avctx->lowres); @@ -2927,7 +2928,8 @@ the_end: return ret; } } - if ((avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || + if (avctx->codec_id != AV_CODEC_ID_SMVJPEG && + (avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) && avctx->coded_height > s->orig_height) { frame->height = AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres); From patchwork Wed Dec 7 19:02:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39649 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp873783pzb; Wed, 7 Dec 2022 11:02:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf43i9ULFJ6lorjVGaN/Gyhpu3WeO5CvsPtHahGgh7FlOrCAGzKGocVaeVDBL7osUM3Qm4by X-Received: by 2002:aa7:d551:0:b0:468:fb2c:6c8c with SMTP id u17-20020aa7d551000000b00468fb2c6c8cmr81237565edr.340.1670439770443; Wed, 07 Dec 2022 11:02:50 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k14-20020a170906a38e00b007c0a7286cbesi12579868ejz.708.2022.12.07.11.02.48; Wed, 07 Dec 2022 11:02:50 -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=@outlook.com header.s=selector1 header.b=u3FgWah9; 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 1F13A68AFB5; Wed, 7 Dec 2022 21:02:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2046.outbound.protection.outlook.com [40.92.59.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C0E116801F2 for ; Wed, 7 Dec 2022 21:02:39 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kCoYxQPNQa/Pkx3bWSXEEJYB26YyugGoHO8AUAuMkqfzIAPE0tHa7fYGfwL8hRYfSupPukh34Tl8kchY1Slb7d/LBFd8B94AnzKRTML6Oc2/HsyFZXdlrK0foOs7Janxt5ZLGZlQcs/8jgmunFNl95QsyXoRNn62kHLnvr0q1C7e/R7o52sBcWyhDuB2d4xH8PINtKvtBMFGZPbIkW/3Twg1YeGpkw+fndOjKp13AKYvFt3aC/Cs1Cy0Vptk4QArnXeYNFiJtL4gpzidA280SigEj/DJ3v7srTwmSa/jVsikvtmAzV+fVGW9H5VdCqEhQMpxM5Z+Mu4+wTLILnsspw== 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=cqpyWtjRWxSGlWLUoDnBY9ZBBaXARIEp3F5AQKJmK18=; b=NXk8k2F3jMcxnBT92+oA32Bay8cjlcI5k+yrYJ0k0vqcSASgDb99ywQv6DdbeGobQgdBThSm6gxrZnQxbZ/jOWZItKstXKYXkIKZX7h/JUkQJyqlXugCdxDUgrvOrHmJYtF2CcFEftKE7INe55DROUGGKJ9EIQ+87X4Ov9aa88OEwzULymFEb3q9cfPKPP0zLXFr9+psSAXMd7zjn2LlfTynrhQNqKjMCg5yLcKpe5Zqe4zvtgSJFz5VIQCvev+p8LXFbNJJc+iGuCnvVaMmlkeZ1arwfbUsKjMh+GDjKa5RgGCpLXK6qFvqVqm3q6yeFF/FJoO/ngdxlAoviiLj2w== 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=cqpyWtjRWxSGlWLUoDnBY9ZBBaXARIEp3F5AQKJmK18=; b=u3FgWah9m003uM7Mh8gLs+40ZlW35OPHFT0y559XUQFSUFACdCNs91xP3m2S3PnRyTaGuPWQrW7BQKacL6/jsBVlL5Q2q88g10Ko/qik1Ml9WpaWMtepDJUVC7bOVWgf91oXkOINzBiTur1iRSsNgX6n8RzXkTeahYGDlqjLDcnHMxN80+lFy6PD1elGGxiSLuGr7Qlm2ZcI1+XTkDT+sCBIjnEE7jSoSwQhADU2wERfyeg9ArbZ1WyWfMTZ2dF4cBbPRyJ4N/1Zrjd+WyZ143ap+Y5zWCCOW+zVWZe1JvMkPPzkjQxY13a0FGY7Nnb6fHg8GAlFfoxlUa3zvna68g== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS4P250MB0462.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4b1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 19:02:37 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%6]) with mapi id 15.20.5880.014; Wed, 7 Dec 2022 19:02:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Dec 2022 20:02:47 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [qVakgpDJJK7T909oQX4c2Z4LphmKsKg7] X-ClientProxiedBy: ZR2P278CA0043.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::17) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221207190250.1724895-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS4P250MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: e9f0ba45-aa1e-4856-defd-08dad8859b62 X-MS-Exchange-SLBlob-MailProps: Vs63Iqe4sQlFh553GBY+W9LrXULtqhRnOklGlikwrZDnmHOIDamVprC3qwrH3RqPrGpaRA1MDCid7WtnlHiHs+DMVUKXtmZ3LwMMYlncRb2M8llI5wpu3bhGkCH1CJggzU5kloyUgDgHsSSlpCWb7sLDRpe7KiJr2fZo22GxpEncZdJtubb0xJgutP0GEPRTl4+HAwoSJy1AMduKkm7JATk6x7pdhyL/Nqfv+5E3mBqNiH3lOfWwrj+0gAagh/OmxlKEw5jABDhol3skSZNV2TzLktgLeFhM68VC2HL0eDIz8xv9Itt/2saTMWyCsaMSkKhxFa+GjnCdty1JhppjoMMKDprolPowJ+TaY3SyWh2xL2supWsJfAa6uveC53Fr/VSBXjU6c2IseX7JTS6EbJTLHULSY5+qAjCMjGt3RQp33Hw+jBXMnxVO9lNisFur2CzrB4tElBq/PyeuLzCge7LCEgSIIu9E/0Xl8dEtJxMbNTajZl0WWFrXy6i8xhbXLwWHoj4L/al43qr6N11rSN3N19BfqxpnuSqRBNjPLqz/cA2rVAUZhouvKLdnQMyd1Yk/RfoRrtno29soz29Efd+ai4eLwUn69u7s7c4uwCAYL5Fip789yU5iPGG2//+BigX9QMxXazrvRQJUnNKcrZkok91NgtRmM4ME1/CLAXXgyCqjrCqiHbyHxDcM6r9ewaYpT4s3BMMCZe38qml1JxTYXY9VaNu27ObLC4Zi81s= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5jbMBnInMCDtLeWduBUf0MmzKPqgvSWQ5W4vRzRLQtLUJsLQh/luGrIbgGj1oqL3poKiPweiYq0ZYCGhmUACyzPGfwvpttAHwrbrplW6Be0joWgRGE7sjWWtfC+HqShNHfa0qg7/g+FlIb3Or9nYUDWqvSvkqZDgwZkFqFggloLbfsazqTFUZEgvax3TgUSy5rneHq/mTkSjaeJyhYEym2RDXeMyMc8dXVob+GL7ZjxCJG8+rw/MvbsEV/zFJUdYy68KjGBzuQ0KAmEG3BxDjfs4/eRwD8HJZi5eJ7LjuB90GL1APQrFp1SjO4+3+GVeY+5O1URYo0By7A0hvco3wFeNVuXopG4424PFuOSd3yHovvr+SpMZG+sCGPq6hDAXS1iYSR5CUrmFxFkzOgK2Dg6lIyS4DKg00YEZG1il5C71lVCCeKV61f0WqiHw29UydO/QsZOlgeU6HeoSFcCTZLk5RWoLamj9WANFy+ZQGCk6Elamp0tlGsMIPh/t1FRlPbQOAAkKUzr3uZ4K4EFON8oJpZ8wHUNqKc4ZbJY4dMeahODJfZT+8EKftr/8ohn4iHq4ufxJVSoDVlTRD4ykss04VtIO5CHG0apthlEP1cPxwe5wcNiebe209J31vG57d/UkUKAIxaiu+qmtQXzbaHG75wmB7wDpOsGdhU7umTs= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y+l54ws1BIihVqmxFtontfotkhRqMqwnyyI8ekmeUWJxZFCRQbyILiQhoR4ZZ/0tyLYwAuZZOVqjEIdU/m8c1Y3iAThpXWTfZH3fwcxBgAq3GFlv1rELVYLJDi9be5CAovPGCewWG1Nw3+VFQXMN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hm27wTyd+eusVv8yqQrKDq0kllTXgmZlLPXmBd5l1GwukFPBqCIcei6bKz1BiaUG1HxvZAw/7urLK0/vR22ciC6fxXdU= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9f0ba45-aa1e-4856-defd-08dad8859b62 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 19:02:37.8044 (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: AS4P250MB0462 Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/mjpegdec: Move special SMVJPEG-code to SMVJPEG-only function 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: Zjz7/nUU7iV1 This automatically avoids runtime checks for whether the decoder is SMVJPEG. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 28e2839072..b88d2ab889 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2422,9 +2422,6 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) s->force_pal8 = 0; - if (avctx->codec_id == AV_CODEC_ID_SMVJPEG && s->smv_next_frame > 0) - return smv_process_frame(avctx, frame); - av_dict_free(&s->exif_metadata); av_freep(&s->stereo3d); s->adobe_transform = -1; @@ -2921,13 +2918,6 @@ the_end: av_dict_copy(&frame->metadata, s->exif_metadata, 0); av_dict_free(&s->exif_metadata); - if (avctx->codec_id == AV_CODEC_ID_SMVJPEG) { - ret = smv_process_frame(avctx, frame); - if (ret < 0) { - av_frame_unref(frame); - return ret; - } - } if (avctx->codec_id != AV_CODEC_ID_SMVJPEG && (avctx->codec_tag == MKTAG('A', 'V', 'R', 'n') || avctx->codec_tag == MKTAG('A', 'V', 'D', 'J')) && @@ -3060,6 +3050,21 @@ const FFCodec ff_thp_decoder = { #endif #if CONFIG_SMVJPEG_DECODER +static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) +{ + MJpegDecodeContext *s = avctx->priv_data; + int ret; + + if (s->smv_next_frame > 0) + return smv_process_frame(avctx, frame); + + ret = ff_mjpeg_receive_frame(avctx, frame); + if (ret < 0) + return ret; + + return smv_process_frame(avctx, frame); +} + const FFCodec ff_smvjpeg_decoder = { .p.name = "smvjpeg", CODEC_LONG_NAME("SMV JPEG"), @@ -3068,7 +3073,7 @@ const FFCodec ff_smvjpeg_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame), + FF_CODEC_RECEIVE_FRAME_CB(smvjpeg_receive_frame), .flush = decode_flush, .p.capabilities = AV_CODEC_CAP_DR1, .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | From patchwork Wed Dec 7 19:02: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: 39650 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp873979pzb; Wed, 7 Dec 2022 11:03:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf7ppu3JllMJe43a1qzVlPpGhWLLj9DKgu4LWFLexovVDB4jr081sivsVuPzQ88zEe6ogZzX X-Received: by 2002:a17:906:1b4b:b0:7c0:94d2:ea85 with SMTP id p11-20020a1709061b4b00b007c094d2ea85mr31712962ejg.27.1670439783231; Wed, 07 Dec 2022 11:03:03 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l12-20020a056402254c00b00459c1e64776si5700729edb.412.2022.12.07.11.03.02; Wed, 07 Dec 2022 11:03:03 -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=@outlook.com header.s=selector1 header.b=sEqutILn; 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 213D068A318; Wed, 7 Dec 2022 21:03:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2025.outbound.protection.outlook.com [40.92.59.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8457D68AEE0 for ; Wed, 7 Dec 2022 21:02:53 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hZNSbJaUCFOeyDZyBl00onuXdoAnCv+qUIFibF0k08O89ezVERNSLf7e5cMmJneRgkHE51y+KcHxGERjAW0VN9Kt/AZ6N8aWiWqS9uTf0GJKH0hkqmPK+4EVRz/+b/oPao+D9Y1RK30CJDnIXXJytsCyAi/wOfgJ/PnuwHeTEGkO6UuXqUwUfU/1x7RvHHqLJcA3WRsioHHUm6MADRf9WXgPMeek9y5RXy0kVh6X1fISGBRnaxUX+sdif6ez+eTvs1gsIzh0YwboEtCaq/VhAi/596ZPp6m6rHb5VVgLa/LUpZNOfCDzQoj6+JHZdef7evG9kaJ0NLy9q1QVj8KIIA== 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=J40WAdhtiWHGLPayLsIBttqYYYkEP4NjMBmS9OCJoT4=; b=cnZsyKOcKJE590L1xccZWdUH/F1MG3Lxb/kav9I5W3U/Imve4MrJyoHgPpcCAuE9HoFB0H/Ka8IaP6BRk6CAi2yJ4Xq80u4GUiHZ3nCK8VsRi+Sl1PAvOJ50gKH78aSqsZzWYz6b1zxIIGBLP4luzczVGNUx8okZz590CbR95itVsYs+BXnBRWVGFGx/8+qDHvcxxK3Fjfri4HDVOfITbd21l64uKCAPfIr1vPBuWVk7uxA6PTZphWfGNODA3KJvqWaBo97JnIWpHf+9pkCmxugtMWYJfMxgp1Qza9BSDAQji8puF6giHS3eXTEklA42p52jYR4wtipdGAgDk20o4g== 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=J40WAdhtiWHGLPayLsIBttqYYYkEP4NjMBmS9OCJoT4=; b=sEqutILnzlcbu5GaGyJwg6d1FJugurocEO+01bfpzM0t6qYRUaPEPIbxl463vVTBqemmqQGR+G09k6QWJHgWrEo8A7iR/Qpkdc3TS/P1BGzrShj98XkowIjV8yTkpf/BH7OfQBBGc0EW3u7fkMeUTI87eGayt20M5BocqviCi981MIepNYU1adkQ+a26hCYcXju2D8MioEOa2fi8/DUM8dYzUh4mf5RdRMQdUIJNvVOhOU3joYvCrvKJO894SFjbzlj3vmbVSXVfP6yggDpGzeQeg/nhvac/z0c9jobK7kdjKJU5jEdECbPEATSbs3f5+yFYnAPZ8G07JGlN4Qh8rg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS4P250MB0462.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4b1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 19:02:52 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%6]) with mapi id 15.20.5880.014; Wed, 7 Dec 2022 19:02:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Dec 2022 20:02:48 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [zyv06Il5DtlSToRXcDUG7X9rsuDwJtPv] X-ClientProxiedBy: ZR2P278CA0043.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::17) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221207190250.1724895-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS4P250MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 44649562-9d19-4bad-8862-08dad885a411 X-MS-Exchange-SLBlob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GgJCGuCS4eepwKOEm99Dke1qqAgzmk+ZfjVNzPn/QRe1mvo2UsfGV4vsJk0RE9ynwLTDlD/p2PUyOO+fd/JFSA6W0s3i/8LkFFIUX1jSc52rF+ANuoIxe2c96A52wBty4rN9to2zCryoqZPs8fetHMlpix00UnWZd2FMAjhs9kSyvea7vlKVVPiwah4M1a1Pv+ugcAJW5007pqvA8Ol4BtJvhrKL/R7cbYJt4RS1cYYjsrivBHOhL3ZS63lJLnzlfPvRjlG88WKxY1p1+JQZxmmk1qubhvi4PUVtNucdPB3wQZMYvCFKEEVMAiIRTlZtpHvZ/5xQx3tbmSmZBl9bsfWJ9wvH6XxPV3UsdPlURSc367wS/8y6WGgCufKwcN84J3KMMFn1GSitGxxThSyg9vtpSiOo7nu5QvyBOFIze+iA6rfYkN9U2D9/PTElmwu4sYyglYIs5GnfaHk4lwKAfiKV1xjUl38SM+EtQClxmJBSR+g++BJOb/0Y7UjpOMR4Y4nDhqyz8aFwi9W99Lnr5FpECZUuZNzhnCEGvXAjE4nbj/DIZTExTiEHjV+0Zhti1bQ9z6csELfGTADR9hoZXx0k5/QK8Kqd0HpZJdpf263rvbZLzEV/W8Mkb6uywX7lFUgKIkRlQj2Lv+U/1Jy8wSu1ZyaEa9GlJgwR2c7NEBzzE= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44649562-9d19-4bad-8862-08dad885a411 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 19:02:52.3238 (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: AS4P250MB0462 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/mjpegdec: Avoid checks whose results are known at compile-time 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: lWatCDxRRzmi Namely the result of the check for smv_next_frame > 0 in smv_process_frame(). Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index b88d2ab889..2abc42a082 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2349,24 +2349,9 @@ static void reset_icc_profile(MJpegDecodeContext *s) // SMV JPEG just stacks several output frames into one JPEG picture // we handle that by setting up the cropping parameters appropriately -static int smv_process_frame(AVCodecContext *avctx, AVFrame *frame) +static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame) { MJpegDecodeContext *s = avctx->priv_data; - int ret; - - if (s->smv_next_frame > 0) { - av_assert0(s->smv_frame->buf[0]); - av_frame_unref(frame); - ret = av_frame_ref(frame, s->smv_frame); - if (ret < 0) - return ret; - } else { - av_assert0(frame->buf[0]); - av_frame_unref(s->smv_frame); - ret = av_frame_ref(s->smv_frame, frame); - if (ret < 0) - return ret; - } av_assert0((s->smv_next_frame + 1) * avctx->height <= avctx->coded_height); @@ -2379,8 +2364,6 @@ static int smv_process_frame(AVCodecContext *avctx, AVFrame *frame) if (s->smv_next_frame == 0) av_frame_unref(s->smv_frame); - - return 0; } static int mjpeg_get_packet(AVCodecContext *avctx) @@ -3055,14 +3038,28 @@ static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) MJpegDecodeContext *s = avctx->priv_data; int ret; - if (s->smv_next_frame > 0) - return smv_process_frame(avctx, frame); + if (s->smv_next_frame > 0) { + av_assert0(s->smv_frame->buf[0]); + ret = av_frame_ref(frame, s->smv_frame); + if (ret < 0) + return ret; + + smv_process_frame(avctx, frame); + return 0; + } ret = ff_mjpeg_receive_frame(avctx, frame); if (ret < 0) return ret; - return smv_process_frame(avctx, frame); + av_assert0(frame->buf[0]); + av_frame_unref(s->smv_frame); + ret = av_frame_ref(s->smv_frame, frame); + if (ret < 0) + return ret; + + smv_process_frame(avctx, frame); + return 0; } const FFCodec ff_smvjpeg_decoder = { From patchwork Wed Dec 7 19:02:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39651 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp874094pzb; Wed, 7 Dec 2022 11:03:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ma2DTgU5dKg/vVnaAk9/HgeqaxMZd1Z2gzs/Ec6ztBiVpI2D36C4LzoBuJHeGdbmLH3EX X-Received: by 2002:a50:ff04:0:b0:46b:19aa:cfc4 with SMTP id a4-20020a50ff04000000b0046b19aacfc4mr40851143edu.384.1670439791343; Wed, 07 Dec 2022 11:03:11 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id tz14-20020a170907c78e00b0078e1d213812si13967194ejc.184.2022.12.07.11.03.10; Wed, 07 Dec 2022 11:03:11 -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=@outlook.com header.s=selector1 header.b=bQ7Mh6Wr; 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 CBE2868B276; Wed, 7 Dec 2022 21:03:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2025.outbound.protection.outlook.com [40.92.59.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E04C68AF4E for ; Wed, 7 Dec 2022 21:02:58 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e/tdluyf4HgHnrN4x1AbEveYZw5cb6AoJXWArwdUOBRm81R8jVjarGbf3CfHNx1a2UG2zQBe4HK0dq6v1iyDXYUFIu/w2cApQmOpbfEB6DUEk7LzMhEB5K8r9hsDxZmqcPfeg3FbiSZUOTR7g6URzk8tVX8uH3MM7Ypci4hrB9zv8Ie8nGXLva7U6xK7zCsafYPJY3HtJVmD4ZlGt/SWCgyPgGJhtogmYMykIq6IQG0gIpp6Vve/s4fUo9tNVUQHjjkxhVeA6FWqCUioJk1gPc8H811cpOIvH2Q/UQihCucows5evRgTL7ghZL5eTgtbazqIIHiJjq6DJxM5IBMqIA== 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=RU0/VtY5iG5zcd7Ilk2dh//cxwdISPfE9HVcOdUPQNw=; b=Kd3xBzUKTxYNeEVgnyvrSEn/aDdfMla7Ivfvd2grJY7rGOioeY/KyyiRqH/k9GJgQutoIOTFvAUhaa0X7J0vQoDveH+c+HI9+0Cirj+Htaf43ORVnWKfIulZmmbCIANuFT7cIeMyXU142hxaaRb9RqamPmBi+DWBT+6Dcsfb8jbTdOPmx6pA7NrbtxQ6JyDnqjl+hPHWZggDLjrJqxf2NasY2z7iItjG0Yx1UbRTCADCPB4L+b4ZM9bCV5/StPVhJdKsaAUxlzZWUo37ROsqKAqyeAaQXPL7Q38ja32W02czsEOCQMtxglbBcTQ6KOMOaAyxCGF2lI0G1F5oCAunZA== 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=RU0/VtY5iG5zcd7Ilk2dh//cxwdISPfE9HVcOdUPQNw=; b=bQ7Mh6WrWzfipdP3W2lXaohTZNnqVmYzSAVraxdEMMgEyybNnXgxv9HS7u8JSO+U4+HDGun3pxARdYvMjE10/IQ1BhW+TItZxixVgWWDsYKfa/rrazjt99HkjBGU+sVcB+f4jivJ2UYRUmUMR+MDYxVHCrvbX8KHoK9BF/7agXsQeOhzZLaJyUJ7JwFJLjLcN1PwMXpUxNOlTxdxfhxC6wYyJybXsIuQK/jDN7gfPvM62Xs09LudVzYj8h9AsGWFOmpyKSyPH+DT+gaffYL1DNM10VIq2hXGM0mcd1Eloe8dQ0UWcHCz+PBcEm6vZpWzKP7aot4c49hyccWrP33mqQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS4P250MB0462.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4b1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 19:02:54 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%6]) with mapi id 15.20.5880.014; Wed, 7 Dec 2022 19:02:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Dec 2022 20:02:49 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [ifT2v3DjN+7Vk6qcjsD4VnVEYQsNe1sd] X-ClientProxiedBy: ZR2P278CA0043.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::17) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221207190250.1724895-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS4P250MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 62e4b70c-6937-4882-57cc-08dad885a515 X-MS-Exchange-SLBlob-MailProps: EgT5Wr3QDKwv8c23SHrwi4NNoC0VDHb7Y7hb0E2i1yTre5hablHWHFbnFrhhd46UO08xDuDLJ8ajQYkrfxDswetBfPsP0nLHoWcxTbKczSzqpJNDelnmNIhjqVZQuBo50dJP8NVqQ8/xlHMyxMS/Bk3HbZjt30Im9gp7u2zDersVDNI3TyLZZMX50qEP1YbFFJ0gVsWn3tWu15vWds/ibnBmSCznVe8esFCSIHmLyjmMP7lcujgAhDoZreeBuAmJaedAJCx12Vd9j/HpYMlVCq81qvaaCgUCjUYixKwmUS346ZrXRLhia4kTjU6z218qblEz1NOjzwXDvHoJDGddF9K7zqztGvxkpj1N3W/CCiDB0rltTnLIgLqPShnpxycHkGu/9QZdXMfbQiFdh7wd0pQx/XTnLEeMmre6klh45xX1Dp5qXr8TsUjsqHlm4YRbq628fpvEDrVAeXXfYjd9hPg+6XutYbofwOqGdW4R8ENbhwSNVdtqWgcenTSXv3VYCYA9Klxzdy0FgqZBSj7tt5qYJGwAEpti0y7td9mhPME0vnwe8+iCdA17hCmFkK3xuvWtR46qeVM85suc2j45tqUU/r5LPeX8HLIdrK9RDChAT8byXP0dBNF1JDJi/q3OXZQAgFz8TennWIL53aQEZIIaNQssE+o6HJXEp4SRy1j/3trKHhVp0lEyF4rgGbXN9Ivce/mO2R0jtrjvh5fhMydZitCixcG/DYzokrH0UM4= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: R+sWKo2OGL64W2cPowx4Ufg2XwHqSL0fFp8v+0N+if+AMT3R34xpeoyPiiKuezmOkSGhy5boqnFhOqnlOReKLg7Nez+fiih9b0NrXCYDAxixblRuiYhAgZQrJi9NKw2zispL4TxH30R5lIUithF4Hs3nSwZNCn9CnsGiNW5D/4UXTiua+LHTqiLCty7rQsUVVw4cU066Qs83WVeRUbqGEKuixQxm1N2WG/LKYmbwCFTj4SQVu7kw08Im3ZayDJoBw67fERud05sZzFKvfVI0opMObc+A1LwRQnwD8i8XNwhbA2cJLIzVr4RHjitNK1QGyH26/H99jK1vIRcESB4xLeKS4a1v2VnoniieoFMTL34V3M2a1ayIx9OhvXTet7RmXc60SLU2yVMWd0sPosHxwkPQGHwcUDfbLaDcLfkmqh/xqG5p+Cx1UGB1ahVR4b/hxr8UJS48GSv8Z8dogZNJ1X+RI4SsBp+Gekhd2X8iGiaiz5zx041DLd915fR5yHmhaSUFxAMyG/3BHM+UJByMW99PVhops7duR1YP3eOKvZ6RohyEWwUG47oJ8c+76+3MQk4ggpkvSEIR3sriiD3Gh+uvx9Ge32KWau9hthtCsGfPAkQACzyvVpm6V2uH/MSk4hNa1CGnzgkMlVx+w4mG+g== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PG6WE/7LkFA2igLGN1oGa2GJ8lAnIVey+y1uZy9LHGiPT3N35z1wbaN7+e5yo7TfZuoHRp3Ex8GFqmXGZ3ONaRPIpL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Mm/48TjCb6hJ/5lRqDux1b1KGdgIzonSW7ushMqMUpiT7+u1TBFYU0a6kTZbYQsGuOZ8n3bwXXUwbgO+iSgETTI9RQFJl8R+EJdYG8iKpOqNkW7VbS/AweVEtTT1VfppCdnewNKj93GI= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62e4b70c-6937-4882-57cc-08dad885a515 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 19:02:54.0579 (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: AS4P250MB0462 Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/mjpegdec: Only use receive_frame for SMVJPEG 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: XtCKgvCbO7u0 Only one codec using mjpegdec.c actually creates multiple frames from a single packet, namely SMVJPEG. The other can use the ordinary decode callback just fine. This e.g. has the advantage of confining the special SP5X/AMV code to sp5xdec.c. This reverts most of commit e9a2a8777317d91af658f774c68442ac4aa726ec; of course it is not a simple revert: Way too much has changed; furthermore, outright reverting the sp5xdec.c changes would readd a stack packet to sp5x_decode_frame() which is not desired. In order to avoid this without modifying the given AVPacket, a variant of ff_mjpeg_decode_frame() with explicit buf and size parameters has been added. Signed-off-by: Andreas Rheinhardt --- Weird that these receive_frame decoders have FF_CODEC_CAP_SETS_PKT_DTS set, despite this flag only being used for decode_frame decoders. libavcodec/jpeglsdec.c | 5 ++- libavcodec/mjpegdec.c | 80 ++++++++++++++++++------------------------ libavcodec/mjpegdec.h | 11 +++--- libavcodec/sp5xdec.c | 32 ++++++++--------- 4 files changed, 59 insertions(+), 69 deletions(-) diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index 2e6d018ea6..ec163b8964 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -558,8 +558,7 @@ const FFCodec ff_jpegls_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame), + FF_CODEC_DECODE_CB(ff_mjpeg_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SETS_PKT_DTS, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 2abc42a082..aa1a6b5208 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -131,8 +131,6 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) s->picture_ptr = s->picture; } - s->pkt = avctx->internal->in_pkt; - s->avctx = avctx; ff_blockdsp_init(&s->bdsp); ff_hpeldsp_init(&s->hdsp, avctx->flags); @@ -2366,31 +2364,9 @@ static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame) av_frame_unref(s->smv_frame); } -static int mjpeg_get_packet(AVCodecContext *avctx) -{ - MJpegDecodeContext *s = avctx->priv_data; - int ret; - - av_packet_unref(s->pkt); - ret = ff_decode_get_packet(avctx, s->pkt); - if (ret < 0) - return ret; - -#if CONFIG_SP5X_DECODER || CONFIG_AMV_DECODER - if (avctx->codec_id == AV_CODEC_ID_SP5X || - avctx->codec_id == AV_CODEC_ID_AMV) { - ret = ff_sp5x_process_packet(avctx, s->pkt); - if (ret < 0) - return ret; - } -#endif - - s->buf_size = s->pkt->size; - - return 0; -} - -int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) +int ff_mjpeg_decode_frame_from_buf(AVCodecContext *avctx, AVFrame *frame, + int *got_frame, const AVPacket *avpkt, + const uint8_t *buf, const int buf_size) { MJpegDecodeContext *s = avctx->priv_data; const uint8_t *buf_end, *buf_ptr; @@ -2405,6 +2381,8 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) s->force_pal8 = 0; + s->buf_size = buf_size; + av_dict_free(&s->exif_metadata); av_freep(&s->stereo3d); s->adobe_transform = -1; @@ -2412,12 +2390,9 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) if (s->iccnum != 0) reset_icc_profile(s); - ret = mjpeg_get_packet(avctx); - if (ret < 0) - return ret; redo_for_pal8: - buf_ptr = s->pkt->data; - buf_end = s->pkt->data + s->pkt->size; + buf_ptr = buf; + buf_end = buf + buf_size; while (buf_ptr < buf_end) { /* find start next marker */ start_code = ff_mjpeg_find_marker(s, &buf_ptr, buf_end, @@ -2429,7 +2404,7 @@ redo_for_pal8: } else if (unescaped_buf_size > INT_MAX / 8) { av_log(avctx, AV_LOG_ERROR, "MJPEG packet 0x%x too big (%d/%d), corrupt data?\n", - start_code, unescaped_buf_size, s->pkt->size); + start_code, unescaped_buf_size, buf_size); return AVERROR_INVALIDDATA; } av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%"PTRDIFF_SPECIFIER"\n", @@ -2568,7 +2543,6 @@ eoi_parser: } if (avctx->skip_frame == AVDISCARD_ALL) { s->got_picture = 0; - ret = AVERROR(EAGAIN); goto the_end_no_picture; } if (s->avctx->hwaccel) { @@ -2580,10 +2554,9 @@ eoi_parser: } if ((ret = av_frame_ref(frame, s->picture_ptr)) < 0) return ret; + *got_frame = 1; s->got_picture = 0; - frame->pkt_dts = s->pkt->dts; - if (!s->lossless && avctx->debug & FF_DEBUG_QP) { int qp = FFMAX3(s->qscale[0], s->qscale[1], @@ -2909,15 +2882,20 @@ the_end: frame->crop_top = frame->height - avctx->height; } - ret = 0; - the_end_no_picture: av_log(avctx, AV_LOG_DEBUG, "decode frame unused %"PTRDIFF_SPECIFIER" bytes\n", buf_end - buf_ptr); + return buf_ptr - buf; +} - return ret; +int ff_mjpeg_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, + AVPacket *avpkt) +{ + return ff_mjpeg_decode_frame_from_buf(avctx, frame, got_frame, + avpkt, avpkt->data, avpkt->size); } + /* mxpeg may call the following function (with a blank MJpegDecodeContext) * even without having called ff_mjpeg_decode_init(). */ av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx) @@ -2993,7 +2971,7 @@ const FFCodec ff_mjpeg_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame), + FF_CODEC_DECODE_CB(ff_mjpeg_decode_frame), .flush = decode_flush, .p.capabilities = AV_CODEC_CAP_DR1, .p.max_lowres = 3, @@ -3001,7 +2979,6 @@ const FFCodec ff_mjpeg_decoder = { .p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | - FF_CODEC_CAP_SETS_PKT_DTS | FF_CODEC_CAP_ICC_PROFILES, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_MJPEG_NVDEC_HWACCEL @@ -3023,12 +3000,11 @@ const FFCodec ff_thp_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame), + FF_CODEC_DECODE_CB(ff_mjpeg_decode_frame), .flush = decode_flush, .p.capabilities = AV_CODEC_CAP_DR1, .p.max_lowres = 3, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SETS_PKT_DTS, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif @@ -3036,6 +3012,9 @@ const FFCodec ff_thp_decoder = { static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) { MJpegDecodeContext *s = avctx->priv_data; + AVPacket *const pkt = avctx->internal->in_pkt; + int64_t pkt_dts; + int got_frame = 0; int ret; if (s->smv_next_frame > 0) { @@ -3048,10 +3027,21 @@ static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) return 0; } - ret = ff_mjpeg_receive_frame(avctx, frame); + ret = ff_decode_get_packet(avctx, pkt); + if (ret < 0) + return ret; + + ret = ff_mjpeg_decode_frame(avctx, frame, &got_frame, pkt); + pkt_dts = pkt->dts; + av_packet_unref(pkt); if (ret < 0) return ret; + if (!got_frame) + return AVERROR(EAGAIN); + + frame->pkt_dts = pkt_dts; + av_assert0(frame->buf[0]); av_frame_unref(s->smv_frame); ret = av_frame_ref(s->smv_frame, frame); diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h index 2cb218902c..13c524d597 100644 --- a/libavcodec/mjpegdec.h +++ b/libavcodec/mjpegdec.h @@ -57,8 +57,6 @@ typedef struct MJpegDecodeContext { GetBitContext gb; int buf_size; - AVPacket *pkt; - int start_code; /* current start code */ int buffer_size; uint8_t *buffer; @@ -173,7 +171,12 @@ int ff_mjpeg_build_vlc(VLC *vlc, const uint8_t *bits_table, const uint8_t *val_table, int is_ac, void *logctx); int ff_mjpeg_decode_init(AVCodecContext *avctx); int ff_mjpeg_decode_end(AVCodecContext *avctx); -int ff_mjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame); +int ff_mjpeg_decode_frame(AVCodecContext *avctx, + AVFrame *frame, int *got_frame, + AVPacket *avpkt); +int ff_mjpeg_decode_frame_from_buf(AVCodecContext *avctx, + AVFrame *frame, int *got_frame, + const AVPacket *avpkt, const uint8_t *buf, int buf_size); int ff_mjpeg_decode_dqt(MJpegDecodeContext *s); int ff_mjpeg_decode_dht(MJpegDecodeContext *s); int ff_mjpeg_decode_sof(MJpegDecodeContext *s); @@ -184,6 +187,4 @@ int ff_mjpeg_find_marker(MJpegDecodeContext *s, const uint8_t **buf_ptr, const uint8_t *buf_end, const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size); -int ff_sp5x_process_packet(AVCodecContext *avctx, AVPacket *avpkt); - #endif /* AVCODEC_MJPEGDEC_H */ diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c index 394448c5a9..dfed725500 100644 --- a/libavcodec/sp5xdec.c +++ b/libavcodec/sp5xdec.c @@ -32,21 +32,23 @@ #include "mjpegdec.h" #include "sp5x.h" -int ff_sp5x_process_packet(AVCodecContext *avctx, AVPacket *avpkt) + +static int sp5x_decode_frame(AVCodecContext *avctx, + AVFrame *frame, int *got_frame, + AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - AVBufferRef *buf_recoded; uint8_t *recoded; int i = 0, j = 0; + int ret; if (!avctx->width || !avctx->height) return -1; - buf_recoded = av_buffer_allocz(buf_size + 1024); - if (!buf_recoded) + recoded = av_mallocz(buf_size + 1024); + if (!recoded) return -1; - recoded = buf_recoded->data; /* SOI */ recoded[j++] = 0xFF; @@ -83,12 +85,12 @@ int ff_sp5x_process_packet(AVCodecContext *avctx, AVPacket *avpkt) recoded[j++] = 0xFF; recoded[j++] = 0xD9; - av_buffer_unref(&avpkt->buf); - avpkt->buf = buf_recoded; - avpkt->data = recoded; - avpkt->size = j; + ret = ff_mjpeg_decode_frame_from_buf(avctx, frame, got_frame, + avpkt, recoded, j); + + av_free(recoded); - return 0; + return ret < 0 ? ret : avpkt->size; } #if CONFIG_SP5X_DECODER @@ -100,11 +102,10 @@ const FFCodec ff_sp5x_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame), + FF_CODEC_DECODE_CB(sp5x_decode_frame), .p.capabilities = AV_CODEC_CAP_DR1, .p.max_lowres = 3, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SETS_PKT_DTS, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif #if CONFIG_AMV_DECODER @@ -116,10 +117,9 @@ const FFCodec ff_amv_decoder = { .priv_data_size = sizeof(MJpegDecodeContext), .init = ff_mjpeg_decode_init, .close = ff_mjpeg_decode_end, - FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame), + FF_CODEC_DECODE_CB(sp5x_decode_frame), .p.max_lowres = 3, .p.capabilities = AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SETS_PKT_DTS, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif From patchwork Wed Dec 7 19:02:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39652 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp874233pzb; Wed, 7 Dec 2022 11:03:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DSfiAsDOwCZDTzHl9MhGRgoNbEjSmk8kTaa5yD3cDZzWmGSN5g6Uvc749/KC4j/ubfzI7 X-Received: by 2002:a17:906:3a15:b0:7c1:b65:ad79 with SMTP id z21-20020a1709063a1500b007c10b65ad79mr6879400eje.402.1670439800272; Wed, 07 Dec 2022 11:03:20 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q20-20020a056402519400b0046b3407a453si5502980edd.162.2022.12.07.11.03.19; Wed, 07 Dec 2022 11:03:20 -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=@outlook.com header.s=selector1 header.b=fuDEasRH; 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 D3CB268AF4E; Wed, 7 Dec 2022 21:03:10 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03olkn2025.outbound.protection.outlook.com [40.92.59.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B49CB68AF4E for ; Wed, 7 Dec 2022 21:03:03 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D5UgcG1n7OhvxwBcfnPR8oFB5z7b7lDnT9DIHbo63eVsjWmr2GynH3Upz2ahM48IKl6Q6MshPb6DQD+ksE3u7H4vp5QB5eREUpAdGCrjzBkev0iYVT7rufagIE6ftzhRVV3JndtAUIcC40+wcukk+rWGuB5Q1rfWx4MMuEND8ka8xcYRShlyeWG1tg1e3OhTpLj+jXKkmGr/Rez53SfOhl50xJWACyFMnRTOnpd4+TcWQkHE4yOZSi5OH+WJLU/DevfiBhohN1zqoh4+pzryZA7kQEPx6Dc5JnKjQeQCblczhSPUwPIbjw4o5ux4Z3A/jAt+sV8TBtAbx8qzipVkHw== 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=jdyyLkDTqj4R/e8x8zqbRNQZvyN1a+PaRQBB9wbEd50=; b=MQ5u8pkhjBbOwFe/KDwZGLt/1KppLYNXsWe2B9nzfCgvwGIfVdWzureW7JUk+5ze3c/L5uouDdojdFUCK5n64oD0FCbovmOfnX1urgAXoZq3B3oGLTWce11vXHwQxBDVaW5YYJDOR1h4p2FC9d3Xo4mGwS8L3p9CTTETGWpIvpnPnZxQNWCTF1U9xWYoKyWckXjTKMmA182+vR4jb5SCE43nbutY1heQWuNFsXan4kNryOLGT5LIbR2G5vk3VgV47kSXHsVgXOR4Rd6nKiQ/RFxJh/pEAKxxDCKT424dA+XO+0TK/oVwTrTIFEThuNJ7f+9lRtQMLAsu2Iz+zYyuhQ== 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=jdyyLkDTqj4R/e8x8zqbRNQZvyN1a+PaRQBB9wbEd50=; b=fuDEasRHy/XpCzXBf8llgsk4golwon8Y1lixofmgNIER3V543PE8j6K8qQv4KKGoPobI0LqxQPYQTL+lkeY4bUaLj5XXOy/ApsuOFofUPHcddUXGIlh/aG4hRuNp+LKTnA2qU6l6ApFZoJrtQ+xW+/UaEvygDIyi+uovg/3xieeWRWQMe1XPUdXvz/72cxl5ta4Zp4IEHYBjNRbSB00R/BXmgLsSTtZeIuIBMOpsqeIGO8yqE1YzsVA+Tqbo0KZZhnKuQrfBf8tcWZ3sLE7ma1zBwMFdgJvnBShahUA+FcpYD0ldmYhzaziZw7x0DFjMXpsBYN4A+/CUNqzJyVJJUw== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS4P250MB0462.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4b1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 19:02:55 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::da14:61e3:630a:70b5%6]) with mapi id 15.20.5880.014; Wed, 7 Dec 2022 19:02:55 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 7 Dec 2022 20:02:50 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [tV9c4ar+KLWBOKdyg0EbxZ6S/fG62qWB] X-ClientProxiedBy: ZR2P278CA0043.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::17) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221207190250.1724895-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS4P250MB0462:EE_ X-MS-Office365-Filtering-Correlation-Id: 68c5df20-0522-4908-1c41-08dad885a5cf X-MS-Exchange-SLBlob-MailProps: feAVlmA1hHV/PwpqnNcqbRSsN4qoZ5B2d4eQL+0zFVQcVuczQY/CL0izQ6mInsFa4iTMZf8LX6ul7/stGpGhwnb/iiu0gMACTbzITODZHq6p/ObBCwUUZFgc+7jsT5EUYrbqN3locTcpGo9A1nOEJfVUKh3e93TcKhEwjuriCTru6yVWJfUtPJrC+B5Gm241OzS5Lat7UbMSDLqsnNKJbJRfOxSI4vmY6D+PEAF7nBu4WGJ/BW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JegqsWFeR0cJ8ZarF0KX3Q55UvCvFEExjiYMZA6cvYE4PZJAbT1mCxKt0dxRyzzBcUjz9hGZVs+coh9TbIOWbymNZUlT8ZXEnnvowzb0cqmCdjNzDMS6bihMcuH9McTinQCoDF7dHLHYB8bJ4oLyZKFBzPudUCAUpFIXJerbm61HlIx9KhdknOBbT8DG/Oe1xuP9VSPCl9rNs+1LVit7yHqaRr9FpXWjyri+uRrtcd34M5m4W6TaTxZCwlhJqcjgTfHAJvVo+FNuDX6F/6CGib5DE0+AmI5G6BRi+3cpQXRHY1xlnGapUgrBJ0vTgKbIhUfzevbr+aY/H9MGPGuBqbUAykiA3RxqL/QxAC7WDOaPrwYFHyg3DK6D6CvYPWQTxzJhOqrn2O++A= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68c5df20-0522-4908-1c41-08dad885a5cf X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 19:02:55.2441 (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: AS4P250MB0462 Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/mjpegdec: Move smv_process_frame() to other SMV stuff 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: 9UNjKLOipt4P Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegdec.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index aa1a6b5208..ea6f724049 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -2345,25 +2345,6 @@ static void reset_icc_profile(MJpegDecodeContext *s) s->iccnum = 0; } -// SMV JPEG just stacks several output frames into one JPEG picture -// we handle that by setting up the cropping parameters appropriately -static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame) -{ - MJpegDecodeContext *s = avctx->priv_data; - - av_assert0((s->smv_next_frame + 1) * avctx->height <= avctx->coded_height); - - frame->width = avctx->coded_width; - frame->height = avctx->coded_height; - frame->crop_top = FFMIN(s->smv_next_frame * avctx->height, frame->height); - frame->crop_bottom = frame->height - (s->smv_next_frame + 1) * avctx->height; - - s->smv_next_frame = (s->smv_next_frame + 1) % s->smv_frames_per_jpeg; - - if (s->smv_next_frame == 0) - av_frame_unref(s->smv_frame); -} - int ff_mjpeg_decode_frame_from_buf(AVCodecContext *avctx, AVFrame *frame, int *got_frame, const AVPacket *avpkt, const uint8_t *buf, const int buf_size) @@ -3009,6 +2990,25 @@ const FFCodec ff_thp_decoder = { #endif #if CONFIG_SMVJPEG_DECODER +// SMV JPEG just stacks several output frames into one JPEG picture +// we handle that by setting up the cropping parameters appropriately +static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame) +{ + MJpegDecodeContext *s = avctx->priv_data; + + av_assert0((s->smv_next_frame + 1) * avctx->height <= avctx->coded_height); + + frame->width = avctx->coded_width; + frame->height = avctx->coded_height; + frame->crop_top = FFMIN(s->smv_next_frame * avctx->height, frame->height); + frame->crop_bottom = frame->height - (s->smv_next_frame + 1) * avctx->height; + + s->smv_next_frame = (s->smv_next_frame + 1) % s->smv_frames_per_jpeg; + + if (s->smv_next_frame == 0) + av_frame_unref(s->smv_frame); +} + static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame) { MJpegDecodeContext *s = avctx->priv_data;