From patchwork Fri Nov 3 16:09:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44496 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:181:818d:5e7f with SMTP id q28csp660673pzh; Fri, 3 Nov 2023 09:08:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ/haT7S1wg6Mk7KyYqD4bOtZOYJIkH6tO2P3zI5PfTKI7oDn+Y3Fdrb3k+WsIOlXF1GFX X-Received: by 2002:a17:907:31ca:b0:9bf:4915:22c4 with SMTP id xf10-20020a17090731ca00b009bf491522c4mr7705724ejb.67.1699027727402; Fri, 03 Nov 2023 09:08:47 -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 u16-20020a170906109000b0098e1bbc3db1si1071373eju.791.2023.11.03.09.08.46; Fri, 03 Nov 2023 09:08:47 -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=PIp5waym; 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 8E99668CD7B; Fri, 3 Nov 2023 18:08:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2093.outbound.protection.outlook.com [40.92.65.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1373068CCFE for ; Fri, 3 Nov 2023 18:08:35 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fksQb3dA3+tdDl1J3tPHanLeT8CLUPYhm5UW/hklCyeHaa6MuO482HSWfbyhcWoZ4QxPi1Yx333f4lz84Ty5pJve2pljZ8808XO7T7GjtSU9NkIcnNiZxayVUROL/kd7y/6FcT30RNXHSoYZDX31BcFk23nH5W5ay7Z7EkyDVPO49Fsr/WM8yOIvyN9eUjGadvjV2m3GiNuaUf5OZ2n05Fs7vNfayDU8+/97Hx4fueOp6a3IO17QXtrZaz8eFYC9s1BGtKrOpIUG2VopgADTOJEShqrl3ddD6Ewr3C5mM2dfZtxE6jeOq+5y83foBIovHdDXRnCdfSuRLYS8PYdXRw== 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=NNAyiB9RHxVkiiDAbQ8sGIS/XQaJJeauxuHHgFgQa2s=; b=fmVWL9ZJKDqUIooSvyGd4LPtLjIiZz2BPMZASnSoxE+cnaGEGy2AvlgVNJsN4s49mFuGQQVqKZgudenAa055IMPP/uBkzftYeE//OS5ZnH1FN+WsftG8cyUcEqq0NUgSYe5OdYGOvdcHzugwJ0eWyeIZIP0q+Y0wlwssEdv+V2f/StNRsK3NTINkcevTlabvlGO0NRJS0BobcCZShXgFlyK1/eU/3yhM4Cd7iv+9SpS7AuLOn8Zvr84iTj7Mu8CKu8OBAbPYHwlSMSN3rnYPhU55Hl1MS17ORG2sNviTAqMEoL9UK7wcN/Ly4CFHF6czQkznADiSHFf4f/oKx1n5Zg== 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=NNAyiB9RHxVkiiDAbQ8sGIS/XQaJJeauxuHHgFgQa2s=; b=PIp5waymTHMui8qn5fMY0N3os9z5BlRGF3XFTIITE0BDx49EjPSx/C4Bx5GukCqMY/w8E9D8/fmh9qKWkSBTtG1vrKuw+WFUGo55znz89nMEKjYnkkAx9ZNTr092Al1X1CdIh9ycyQsTDcAed17ZxnUrX/P1VD1QDcjGqG+oybsihKOFg+ru1N2wVlNiGcaUZHi/XVUFY3G6PZFHU3BP7bjuyse5SVWH5+PWadhFvsQ2MuAIT5BX6c0BhRBbwijLr5n4gJpTloMakHfdyEeYo2nKpK9Zc2B+GkmlL/N6yRNtpZSrkll6Zxk+s47dpy1hd/SP7FXGgghjmnKSBIxjng== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS8P250MB0331.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Fri, 3 Nov 2023 16:08:32 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde%3]) with mapi id 15.20.6954.020; Fri, 3 Nov 2023 16:08:32 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Nov 2023 17:09:44 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [7yrW6uuJfp4hiN8pLKl6OK7VCyej8tbKf4/igp38d5c=] X-ClientProxiedBy: ZR0P278CA0101.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::16) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20231103160946.81095-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS8P250MB0331:EE_ X-MS-Office365-Filtering-Correlation-Id: 11b296dc-6e91-4420-dbb2-08dbdc87205d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yDD5eK3LWwq7075HjT9CYmsy6bwfsDcAC0js2XMhl7wVsSDbeEVl9zNAyldlcBqJ+14E5/5QojwMpZz+79LfNjv32ooYAXs6iA/4/Mq8X+5XuwFwizfDCVlshHwJ9FqPnKhX8YXTpFUDPv+J52HY9BjQKasQxR/XhsMUGxteybYBZliUAADuMrkeF+eKujBu98UsQOh5YX12JJX1wXTwaptP7/gIvWokaK3sey8iOgENVwlPzDeGx4dfrasklJg+hTGgg8XkD7iQVQiSvKJoiLDuU6LKfyLuweI8hFhDmiZsUIi/Q8YHABsBOMDAWVueljw9mdaSc9bPkEdu4TmfXFTZRBmEU7iunz4bRiEbzv0gcc6OaTEUL6zvxdXUgpxZ+zI7JfuZCN5oAu0NyksJgF59jI0+y76OKtxpVw1RIGyoh6cHEM0j0jo+RFBFlEAHysNBKFOll8AKTdum3lRbkhJLIhk4lxxt0MsIXPIfu7kY82dZiJzIMrPa9XCPCzN/NS2bcWuRX75aCeKqC1hJJjhSYN5NcO/7WOtDf3hSeFIxb7E3w40D3jeLfwLorBu9uZWdU4GVxBkDyqzjwFljJViF8GeUWZRVAS2hXGbsu/PqsRrgW6UyoYHtr4XG11Hb X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rhiC9Lqs7m9fIatYz0oXT5NiYfMKSph3YeeuYv7B938OjbpdoCe9OzrlPj4jfT8RSQ+mMPI+vPPKTgWmdmK3bAj/SoDo+xbpRvUuO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7rCRvwZKAUvVJkC/5Xs2+vYR6V6JtAxO1gPAGZqzJdEa63EtWRScd68i4tkwOGe+VugpyaaWyLL8Ck9erbKWX3jZ97zD8DQ48 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11b296dc-6e91-4420-dbb2-08dbdc87205d X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 16:08:32.7827 (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: AS8P250MB0331 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/webpenc: Return early to reduce indentation 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: d7pwv8qVh0iv Signed-off-by: Andreas Rheinhardt --- libavformat/webpenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index fb0cca3922..9ac353c967 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -80,12 +80,13 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) { WebpContext *w = s->priv_data; AVStream *st = s->streams[0]; - - if (w->last_pkt->size) { int skip = 0; unsigned flags = 0; int vp8x = 0; + if (!w->last_pkt->size) + return 0; + if (AV_RL32(w->last_pkt->data) == AV_RL32("RIFF")) skip = 12; @@ -139,7 +140,6 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) } avio_write(s->pb, w->last_pkt->data + skip, w->last_pkt->size - skip); av_packet_unref(w->last_pkt); - } return 0; } From patchwork Fri Nov 3 16:11:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44498 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:181:818d:5e7f with SMTP id q28csp661756pzh; Fri, 3 Nov 2023 09:10:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpiV9Mnagl87Y0NVC8j1F065PJnI0tvhZFQupUxILUnnL3Sf2GCfZeXT2xY+that1B/yHJ X-Received: by 2002:a17:907:1b02:b0:9ae:82b4:e309 with SMTP id mp2-20020a1709071b0200b009ae82b4e309mr7816013ejc.0.1699027809043; Fri, 03 Nov 2023 09:10:09 -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 wv9-20020a170907080900b009cd4b465082si1163894ejb.831.2023.11.03.09.09.57; Fri, 03 Nov 2023 09:10:09 -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=aRo8bCXW; 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 07EEE68C961; Fri, 3 Nov 2023 18:09:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2042.outbound.protection.outlook.com [40.92.65.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9D1E268C961 for ; Fri, 3 Nov 2023 18:09:48 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kg8dGQK17y0s2FQwVqrc/EjvTARI+0IecCEWqowIBscFnUEXFecONIQDkWmuibDWUl8b4QTLxa7PQ4CYSRlqRHcjeYZSLOe4hRinybdmwCS0SA0GZFgSj8Dq5X8DOY4+6pt89xx5Gyx5Xn9o2jmIz/5b4IP5ZPaQXP/3QMXHFt7qsgAQzUPb0CK/PIPYkD+2txR4lc/zznJb9H9tVnMFkCC0k46hqTdNCfoNIUFk70ERJ76NZ+SlHe7T9axvwIqZVeFa695EcbmK3GjR8azh/RCdAYUWHLYx8aqo9zyOV5YrgQ2oRf+7/wL/im98eeaogbEZYDhHXqYBzBd1XcWqMA== 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=rcsIA6ST6cd12vtGU7XE6qTPlXTyBeVtGdFqLrUPmMU=; b=RPLAx9N+uwIkeTJwqkLpJ/LP4br4Onr4O08TjSD1iJC3du3njpp+kBxvOi/986vnNPdIVBW5gRLVUsWz/ozUt2pzJBs4pddum1VY0T98iCQs3jD5Cu+HkUWv4p2FQKyTzAiKJ+5GPB8AMgumiu8T/Z1a5uVcVbmgJyXfoCdtCA9wPgQzc9jrtuaTEBpbRk913FuLNvxECaLqdOzxk2vY7uvsjQJpsalgFXPx9e8pQ3nsWsDDfN6cCyX0wWiNokMVtZzh4+dKTXG/kwqbNT2rM4RF1GQ53jo379FcvKZvE9gYVPn9T8aOMN5OsNph8yYEJG1eEk59X4MDb8IF9SoE8A== 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=rcsIA6ST6cd12vtGU7XE6qTPlXTyBeVtGdFqLrUPmMU=; b=aRo8bCXWxW/ERRgHTmAt2t3SyN9wus3sH3nqjoupDf0MfG4cgGYrLwp4m9YSbx5xathjp9tWsuZmetfEtpNTW+r5nXqFGFW4lDdAzTC94wIGy0vrIv531nLtjzwAWL0TnQ/e7XprSC5ZaaRzWZXtPPH/cOVo4sAGgo8knGKCTPMxoaVRfKvBdoFAAwlAyG3EOzswnImA6IFhAginu3+gfTLwwFCM+Zz0Dop84KgtZxCaHDJHmvPzU0EkLkWyuTc3nlzTMIVJgBl8FILAcJbiZm5zf5GLvM/EcAQAVnCFNteRcGgiNv+LaqH4z9wuTnobMFOx0gFyJEUcA8PZswFh9g== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS8P250MB0331.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Fri, 3 Nov 2023 16:09:47 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde%3]) with mapi id 15.20.6954.020; Fri, 3 Nov 2023 16:09:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Nov 2023 17:11:00 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [rEZEXnEKd20RfH/rGx8E26f9qH9G6qxqlVwDwT4RyLk=] X-ClientProxiedBy: ZR0P278CA0104.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::19) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20231103161101.81135-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS8P250MB0331:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fb65bb3-9dc1-42ee-c7c9-08dbdc874ca6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jc8EX9nY+r2FmscxcY62p/GvCYcePpYnCzvB/d926KtjwHbd1bhoxhzY8EuuDrlqNG93zSXqyeG3URowwuFy+JpUsZZbbbB1C2mJJcy7GZWLG0QNytjb0ohjaL1QMjan0NN5wm0tP9/z+qHPqlEVEykcSs3o6coiLrdim82FwIg8y76lXY4yHaUmXhAmBUeg+DSkZmhxRF0+d5A66Gep/joGCIq41iHBgwM/eqG6+DHLjHus7RGctRWApEztM3691obIL5AjXRIM3ZY4YdEP+kHpfJrxKW2PRdwh3yaNifu+yp1Ih1PAi8V35B/dOsodTDNibFi/7N7eWETGQeLPnLOx0wsxUUJH5nycMgCg2OKDhcuhzeisU2q+uyCTZopIHGKb8LuC4BIFlWjgfUChUGv0NrdlRT1iXZv3JOTkHp8WjxAhB753IQnZqJD3XRqBzCC8avJzxPNgcgX6yNVf5NnWYOpkJo6Nfu6Y46GZwNMlwbQmUxxCOHsc3NM9S7SA94DVBGlWJoz8Kt04/mthQ2plaYtGm8qDB08zLiZSgkkQ6IFddUVwDzWzqZPCXmbPtasI1oTne4+VLI1ak/udcvetQTQUlPz4bzugJdY+Kbn3b7DLm3R/KsBWRpWJc4aS X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-M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y840CjBGQFvtV4bwXw93aJp6A6OlcDecbcUqzDaBGLEqDYmXJoNNugncdM9qnePOR+WNJ1iSVF2NO3TOHRndChw6ofvp6eDGhwR2DTV7hJG4GKdsYRZP0oxVmYzb31MznGWrkHWwSm19jKdE602vy90sMu1DcIIG5bE4SWH7anvC0CWfBrEk8rVdLNL1s24Ya30gwdjwGowAi9kOslLNDyCg4tUp8 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6fb65bb3-9dc1-42ee-c7c9-08dbdc874ca6 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 16:09:47.0363 (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: AS8P250MB0331 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/webpenc: Reindent after the previous commit 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: DsB66Eut8jiS Signed-off-by: Andreas Rheinhardt --- libavformat/webpenc.c | 94 +++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index 9ac353c967..d4acea7ba6 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -80,66 +80,66 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) { WebpContext *w = s->priv_data; AVStream *st = s->streams[0]; - int skip = 0; - unsigned flags = 0; - int vp8x = 0; + int skip = 0; + unsigned flags = 0; + int vp8x = 0; if (!w->last_pkt->size) return 0; - if (AV_RL32(w->last_pkt->data) == AV_RL32("RIFF")) - skip = 12; + if (AV_RL32(w->last_pkt->data) == AV_RL32("RIFF")) + skip = 12; - if (AV_RL32(w->last_pkt->data + skip) == AV_RL32("VP8X")) { - flags |= w->last_pkt->data[skip + 4 + 4]; - vp8x = 1; - skip += AV_RL32(w->last_pkt->data + skip + 4) + 8; - } + if (AV_RL32(w->last_pkt->data + skip) == AV_RL32("VP8X")) { + flags |= w->last_pkt->data[skip + 4 + 4]; + vp8x = 1; + skip += AV_RL32(w->last_pkt->data + skip + 4) + 8; + } - if (!w->wrote_webp_header) { - avio_write(s->pb, "RIFF\0\0\0\0WEBP", 12); - w->wrote_webp_header = 1; - if (w->frame_count > 1) // first non-empty packet - w->frame_count = 1; // so we don't count previous empty packets. - } + if (!w->wrote_webp_header) { + avio_write(s->pb, "RIFF\0\0\0\0WEBP", 12); + w->wrote_webp_header = 1; + if (w->frame_count > 1) // first non-empty packet + w->frame_count = 1; // so we don't count previous empty packets. + } - if (w->frame_count == 1) { - if (!trailer) { - vp8x = 1; - flags |= 2 + 16; - } - - if (vp8x) { - avio_write(s->pb, "VP8X", 4); - avio_wl32(s->pb, 10); - avio_w8(s->pb, flags); - avio_wl24(s->pb, 0); - avio_wl24(s->pb, st->codecpar->width - 1); - avio_wl24(s->pb, st->codecpar->height - 1); - } - if (!trailer) { - avio_write(s->pb, "ANIM", 4); - avio_wl32(s->pb, 6); - avio_wl32(s->pb, 0xFFFFFFFF); - avio_wl16(s->pb, w->loop); - } + if (w->frame_count == 1) { + if (!trailer) { + vp8x = 1; + flags |= 2 + 16; } - if (w->frame_count > trailer) { - avio_write(s->pb, "ANMF", 4); - avio_wl32(s->pb, 16 + w->last_pkt->size - skip); - avio_wl24(s->pb, 0); + if (vp8x) { + avio_write(s->pb, "VP8X", 4); + avio_wl32(s->pb, 10); + avio_w8(s->pb, flags); avio_wl24(s->pb, 0); avio_wl24(s->pb, st->codecpar->width - 1); avio_wl24(s->pb, st->codecpar->height - 1); - if (w->last_pkt->pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE) { - avio_wl24(s->pb, pts - w->last_pkt->pts); - } else - avio_wl24(s->pb, w->last_pkt->duration); - avio_w8(s->pb, 0); } - avio_write(s->pb, w->last_pkt->data + skip, w->last_pkt->size - skip); - av_packet_unref(w->last_pkt); + if (!trailer) { + avio_write(s->pb, "ANIM", 4); + avio_wl32(s->pb, 6); + avio_wl32(s->pb, 0xFFFFFFFF); + avio_wl16(s->pb, w->loop); + } + } + + if (w->frame_count > trailer) { + avio_write(s->pb, "ANMF", 4); + avio_wl32(s->pb, 16 + w->last_pkt->size - skip); + avio_wl24(s->pb, 0); + avio_wl24(s->pb, 0); + avio_wl24(s->pb, st->codecpar->width - 1); + avio_wl24(s->pb, st->codecpar->height - 1); + if (w->last_pkt->pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE) { + avio_wl24(s->pb, pts - w->last_pkt->pts); + } else + avio_wl24(s->pb, w->last_pkt->duration); + avio_w8(s->pb, 0); + } + avio_write(s->pb, w->last_pkt->data + skip, w->last_pkt->size - skip); + av_packet_unref(w->last_pkt); return 0; } From patchwork Fri Nov 3 16:11:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44497 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:181:818d:5e7f with SMTP id q28csp661724pzh; Fri, 3 Nov 2023 09:10:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3a5xt1YPA2zThm7G5pTUW2o/dAcjA7b/sxrebH+rmLm7vXsmJ7kpdY8aFB9BlCN5znRHd X-Received: by 2002:a50:9b5e:0:b0:542:fe59:2234 with SMTP id a30-20020a509b5e000000b00542fe592234mr3361427edj.6.1699027807452; Fri, 03 Nov 2023 09:10:07 -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 d21-20020a056402079500b005401adf8d10si1054623edy.684.2023.11.03.09.10.07; Fri, 03 Nov 2023 09:10:07 -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="Fz0jglS/"; 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 1EF0B68C8C6; Fri, 3 Nov 2023 18:09:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01olkn2042.outbound.protection.outlook.com [40.92.65.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E235B68CBE7 for ; Fri, 3 Nov 2023 18:09:53 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oPtAS8EE3rTx0Z1cfSOgsBqhsAmelGoEQXsjKpmwmYWRtcwjnTGIwA8qO2ackbBfdurYwTrnx0ECX7lU61Ggdiac4cmjE462PcOzjMlp6fjAssXHGjcKIFeOKw6PU2zOKwdApvbMm7YA9WpyfRWzL1Bv0gAg9QYLNYCnPwGCMk0RbmUY8kHEFi/9B1F5YFxIuvNjY857yFSrS1yOCjRQB5ZnfLGUp/gUe6Mg98eaTMmYBzcaaL6MMZM40ZDe17yNwct+KpghdgosQ69nRthSIcPzzYkG9C1nxqDI5xVEyryLWztj07ahU8xc2bPEdCFKAIpU9KKNHZmPYZDzV+gO+w== 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=FUMYXZpLNmrLJSqzeJRfvcMlRMMd1wSeL/86SI8gM1o=; b=lVLBWj0V9iezItEG1IBRAihzFyWqYdquQX5Eay3UJx1LUELnnlmZtqgS5C/3CvC2bmwZrR15WGCh/iO/1eEQyG3nMoQAPymmnaXHprBtba1Ou2LW4TyLBziHOxZTvjwEpLurldAv0dfkn5wMxxQuUCG6IZ1zJBEv6YT5Nx45N1/AMxrxfClKuqReg5J3cgEFunlAOqLKx6N/3JB03wJJ1DmFgpIWSqMKSF0ynkBi/dTrDDAnaGfA9aNh8Vsfif0Rfx5EbocUGOFurrbdGvSE8sPdrRaDkkWJJZrT1s/1xHg1F14XpRLkZN+9OVDsnuqD2XPslyq09o+l7K20SqQHCg== 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=FUMYXZpLNmrLJSqzeJRfvcMlRMMd1wSeL/86SI8gM1o=; b=Fz0jglS/vq+QafXC0Hk5hGMlbkh7kOGf+SXViFKiKbcv+CfgRBHuaQhjEOXdhqvBQtfLOIUCWtIhzEBqmkRCUCZojAuNf2AgWGQOJcNNFkseevwVeBuOShKjBBNOAX1b23ozQ7sqqlivbhLIQg9RACFUjdQTYllcCfoA2+JjcQpfi4cDcDEpY8uRkyod23nUvPwaRJPYQ0J5IibRGQve5kGU/i1v9EyTPKOopFCshXyGxomZiw0qgfRlLaNoVplC4tEnZTQrHmsHxzJAjGSztIZR2N5MKukqJMUlmOsP7lEQ7hb0Meck6zuPspChRT1hructX05YEaR6JBqT8wEdIQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS8P250MB0331.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:37e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.21; Fri, 3 Nov 2023 16:09:48 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde%3]) with mapi id 15.20.6954.020; Fri, 3 Nov 2023 16:09:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 3 Nov 2023 17:11:01 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [iHoMj9Bxx1MjMO6eSSZEDwoH4uiV2r9tuFffo23BuAA=] X-ClientProxiedBy: ZR0P278CA0104.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::19) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20231103161101.81135-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS8P250MB0331:EE_ X-MS-Office365-Filtering-Correlation-Id: 5de03ef7-91a5-429f-72b5-08dbdc874daf X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LD4DKLmdcE0KVOHu+9CDAgqWwKR+ltOFYhAWYkzh6nX5r7jJnooJHcvjrMEKh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H9eUQhshFD9h5qWpw5CfpclFgupW78ssFM6dIDjqlWJv2mgvHBcI5Z21CK55xv7r6NTv0vqT5e4c05alSewK6X4FJTQg6HYMC8IdPn2b7gHe+f+AQGxTsoj6Zv58pA+AaTD3utKqvhN+8Ha5eDho7Gi2k0Yd3tjLuq7uJlt9KRTt75gxqAtJkCytAd8W+MQZCwLML1TFrcuGXhYDTDpOEMx6bfBAEIti/hgyAKnJq7Xfu4ae5INvaSasVZWnjnKP/vPoPbkFb542AMpld3aMEVqzScYxs8NWBwkNrgvpNcvpkvffWQEXB5rKhAn0GU4ks1WE4e1xh4Gu7RrBSc9Ik6WZInJkgVwJCsl9ga1HHzi25xkFIo3YNTS3N0yDnXKTXjd6F7tn+5Ldg1jc4kQc1daCq+GWa7Yzy5j3fE+963zn/a+KymSI8uKLMloiVmFxi93wT8hU1l7PPxTfSdnhLD58iYus+0q+XdUpu2S3O7JrpjkRkUFqTn+7Ddbd1Niw4Elp2mjtlvOrgn2vTpnh1FWHN3YZtZ9MTTeYfrNm5QTvwCnAR/abg2e51jzPlNXuOZCt9E9KRfZ5c//zFpc5e0Rhkvl9pVm8idDMyyqV2Tz2O0Ld9QfbM8O+dThTbe8mscYl4KRunSNAou3jjG5IQp9Ty47B31j4L6SpSBcZ9vTQTgKqmkQdGHEEdVlTa66/c+G+hZfQS6wHqSDF8q3FVrLo7Zv+za6+n/fIys13B70I5w8w00ud6LlNi7asS3G3Ra1GL9V99driZ2wtoylcafTeydMkfYfhI2kb3BIjZX3g0XP2XNTudzrrDGwXH5jflOJ86ExF5xa X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5de03ef7-91a5-429f-72b5-08dbdc874daf X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2023 16:09:48.7591 (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: AS8P250MB0331 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/webpenc: Write correct size for single images when unseekable 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: L2R6XTcaZZ5F The earlier code writes the file and then tries to patch up the size later. This is avoidable for the common case of a single image because one can know the complete size in advance and write it. Fixes ticket #4609. Signed-off-by: Andreas Rheinhardt --- libavformat/webpenc.c | 68 ++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index d4acea7ba6..ea7a321975 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -21,6 +21,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" +#include "libavcodec/bytestream.h" #include "avformat.h" #include "internal.h" #include "mux.h" @@ -76,11 +77,16 @@ static int is_animated_webp_packet(AVPacket *pkt) return 0; } +/** + * Returns 1 if it has written a RIFF header with a correct length field + */ static int flush(AVFormatContext *s, int trailer, int64_t pts) { WebpContext *w = s->priv_data; AVStream *st = s->streams[0]; - int skip = 0; + uint8_t buf[12 /* RIFF+WEBP */ + 18 /* VP8X */ + + 14 /* ANIM */ + 24 /* ANMF */], *bufp = buf; + int writing_webp_header = 0, skip = 0; unsigned flags = 0; int vp8x = 0; @@ -97,7 +103,10 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) } if (!w->wrote_webp_header) { - avio_write(s->pb, "RIFF\0\0\0\0WEBP", 12); + bytestream_put_le32(&bufp, MKTAG('R', 'I', 'F', 'F')); + bytestream_put_le32(&bufp, 0); /* Size to be patched later */ + bytestream_put_le32(&bufp, MKTAG('W', 'E', 'B', 'P')); + writing_webp_header = 1; w->wrote_webp_header = 1; if (w->frame_count > 1) // first non-empty packet w->frame_count = 1; // so we don't count previous empty packets. @@ -110,38 +119,41 @@ static int flush(AVFormatContext *s, int trailer, int64_t pts) } if (vp8x) { - avio_write(s->pb, "VP8X", 4); - avio_wl32(s->pb, 10); - avio_w8(s->pb, flags); - avio_wl24(s->pb, 0); - avio_wl24(s->pb, st->codecpar->width - 1); - avio_wl24(s->pb, st->codecpar->height - 1); + bytestream_put_le32(&bufp, MKTAG('V', 'P', '8', 'X')); + bytestream_put_le32(&bufp, 10); + bytestream_put_byte(&bufp, flags); + bytestream_put_le24(&bufp, 0); + bytestream_put_le24(&bufp, st->codecpar->width - 1); + bytestream_put_le24(&bufp, st->codecpar->height - 1); } if (!trailer) { - avio_write(s->pb, "ANIM", 4); - avio_wl32(s->pb, 6); - avio_wl32(s->pb, 0xFFFFFFFF); - avio_wl16(s->pb, w->loop); + bytestream_put_le32(&bufp, MKTAG('A', 'N', 'I', 'M')); + bytestream_put_le32(&bufp, 6); + bytestream_put_le32(&bufp, 0xFFFFFFFF); + bytestream_put_le16(&bufp, w->loop); } } if (w->frame_count > trailer) { - avio_write(s->pb, "ANMF", 4); - avio_wl32(s->pb, 16 + w->last_pkt->size - skip); - avio_wl24(s->pb, 0); - avio_wl24(s->pb, 0); - avio_wl24(s->pb, st->codecpar->width - 1); - avio_wl24(s->pb, st->codecpar->height - 1); + bytestream_put_le32(&bufp, MKTAG('A', 'N', 'M', 'F')); + bytestream_put_le32(&bufp, 16 + w->last_pkt->size - skip); + bytestream_put_le24(&bufp, 0); + bytestream_put_le24(&bufp, 0); + bytestream_put_le24(&bufp, st->codecpar->width - 1); + bytestream_put_le24(&bufp, st->codecpar->height - 1); if (w->last_pkt->pts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE) { - avio_wl24(s->pb, pts - w->last_pkt->pts); + bytestream_put_le24(&bufp, pts - w->last_pkt->pts); } else - avio_wl24(s->pb, w->last_pkt->duration); - avio_w8(s->pb, 0); + bytestream_put_le24(&bufp, w->last_pkt->duration); + bytestream_put_byte(&bufp, 0); } + if (trailer && writing_webp_header) + AV_WL32(buf + 4, bufp - (buf + 8) + w->last_pkt->size - skip); + avio_write(s->pb, buf, bufp - buf); avio_write(s->pb, w->last_pkt->data + skip, w->last_pkt->size - skip); av_packet_unref(w->last_pkt); - return 0; + return trailer && writing_webp_header; } static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) @@ -185,11 +197,13 @@ static int webp_write_trailer(AVFormatContext *s) if ((ret = flush(s, 1, AV_NOPTS_VALUE)) < 0) return ret; - filesize = avio_tell(s->pb); - if (avio_seek(s->pb, 4, SEEK_SET) == 4) { - avio_wl32(s->pb, filesize - 8); - // Note: without the following, avio only writes 8 bytes to the file. - avio_seek(s->pb, filesize, SEEK_SET); + if (!ret) { + filesize = avio_tell(s->pb); + if (avio_seek(s->pb, 4, SEEK_SET) == 4) { + avio_wl32(s->pb, filesize - 8); + // Note: without the following, avio only writes 8 bytes to the file. + avio_seek(s->pb, filesize, SEEK_SET); + } } }