From patchwork Sun Apr 11 00:43:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26854 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 56B7D44A69C for ; Sun, 11 Apr 2021 03:43:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D470687F34; Sun, 11 Apr 2021 03:43:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073105.outbound.protection.outlook.com [40.92.73.105]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DBBF468008B for ; Sun, 11 Apr 2021 03:43:11 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ifwHtSCJDLJevwzPgfqdp31C4gVM8xzubyPnNd/DxG7kJrl8qWFCAg6m5lKIIvd6OkO3+Yt2TyWTQUTWcQ+dFwRmzaEAhtu6wAMcVQnp4INm0mr2yYg81a56wVvyA2LRwGhaI+/hDfSnsWqqycB6czxtRPmUq6/TlZvyjHl/lN9yt37nX71jbtFkVQ4BijWOOEi6o5zMBPkY5HuDvNCWa3W8qY5DsoQaV0TapIkkm4cTqLvK33OeDwSm2TsmTb5RF/D3IaLbW6VFTYcmpjWcn2ogzsrqdYMQvNKKRgsuj24WB2P2j1VX4DuvxcfhgrQeCYkX/yJfZKib1wXCu/9YUw== 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-SenderADCheck; bh=3exoPzBVqDX2qWU/Tl+X+1du9qOG67dcgTYEju3Zki4=; b=DCib5u14RjhIYAKSEZe/N8iXZaerhLKPXxTIdWPpBluTLuObzM1S6OnTAoygJlO2afz8X9eW5Hfr0ZMJMaWo74+wkb8NC6rMvB2ogFlNNj9mvgn/LXwnxvzIAJ3utxcXo6V+IVJsyNf6ce0HacRbq5USz7RWsiPo7w79Sgy2hkErZSVd3YgYyPZ5vOs+cubPuLZIymma3/K/n2FSUdoFLY+CNILTAsKsLDHA8fNDCeTNp0yr7Gcpg7jVoALE/izHLhZJw3U2AumLQxFO5sW+uYSNJuEu++sIDZbEnyuDyxkLahvUz0BSvcTzgCYqj0iL8jSonFfz//xXD39PIq3gMA== 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=3exoPzBVqDX2qWU/Tl+X+1du9qOG67dcgTYEju3Zki4=; b=S0wfNc/KBKme6j/wqNaUU0FSoqFCW8QiUUnyDc2YP63hBAUeyhskpkiw89SU5OUcwGIyU5tjLXENboA3LrGZsxOTWKv1AIeDIFWU+MaMBeiyFSf8yy2hY610GC6NW8Au5IhWF2UYtybR8KCEHbOhgeqTKBrz+zSDaE2iRbcF07rtvCAgJdG3+nyEPY3zGNuB6LkoAi1F01IV6kjTjzz61B1/y+7J+0i8U9ShuA3IH2y3yUiMdiRmyU/uA3Hyar8VljzlH0uo8K/hdB/+swGikZCxSnU93gXGjhUkRo2k/vfR2FVCTuE4Dch5BauZPHWIqMkK+odme/MJpAmKT5Vr9Q== Received: from HE1EUR04FT003.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::41) by HE1EUR04HT082.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17; Sun, 11 Apr 2021 00:43:10 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0d::4f) by HE1EUR04FT003.mail.protection.outlook.com (2a01:111:e400:7e0d::273) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Sun, 11 Apr 2021 00:43:10 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:362C961CC869D00A935CA8C28B703CA3557C1EE631E62EF2C699153627616703; UpperCasedChecksum:19807653B23B82ED858A3B0C0E12CD1EC34458DFBF3A3AEFBE863CE1E50EB123; SizeAsReceived:7588; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::8128:5de5:4e94:9a21%3]) with mapi id 15.20.4020.022; Sun, 11 Apr 2021 00:43:10 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Apr 2021 02:43:01 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [J8A3NNxn10lLkzZ+tNkUZFY1sP7crNLJ] X-ClientProxiedBy: PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210411004302.219786-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.137.96) by PR0P264CA0122.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.16 via Frontend Transport; Sun, 11 Apr 2021 00:43:10 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d5970934-52a1-4151-8a75-08d8fc82c7fd X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQcOwkohpkMj5HspU+N+noEF/QoaxDLX1TL7iwI2o+YkhrpHSSyXc+l1f93nHPwlsvRMXUC2zvb80J9nNqz3KALHS/fGGuem5dH9oQ2hSVt+OIcshQux7vR0zRsb0uWF/c1ZJoGLuJGR7CVRbKLeZQwx2FqOQWzv2SvpqNWVexLCxYxx4dc1Lct7++sx/pegKyfmolr5CxH9Glyo4Tlzenbx/jWL7X1ywHaP+epfitbY3ks1EUsd8i8HU7exWezGjHOR/ETuugLuBymQIQiLa6BSkkYQ04UK7ZsIDcVeukwsdmy/3CU9lsh22Xjao3ckbGoiJJeqUqtNmQnJSNKMCHpSUNvY0usGzGd2SIFXgdVTEyD0GxjPFLIlFsPThd4OAFFpvXgVbndlolh9NTY4LobK/6pzANamFK204D16mVcItGz6t/S9BB2dyxtUypXikz3Cogvsza4uDswL4DFtzhXeBaU6yyAT/o1zto+VxE48qomLUEPd7ZGmWXOTbrEb5q5GSflUNrPO2IX7YV3x80FzJwxYUvtxC3RkyDbALrr270xALraot3OsFe1p0Smi+tRqHoLC1S1k7vpcuSPmk/W7HAVgngfi5uMX8mbneZqW3tRXdO+lZUwR/rcdJByNMVk/8YM53Fh/NPMR2bjWGCZaav8966MTWw7q28lk5oelvIlQGVoglabGqnJxB+R5hjF79/CDjOjiqTKQp6k+WvdV9MhSEmJGIRlQzd1gCpRRUp3/vad2r7T89uj7a49ChQ= X-MS-TrafficTypeDiagnostic: HE1EUR04HT082: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gAFvaknhUEuUu/t5GQ2KAJfls20fpTrkVx/HCzdFXTZ8y1hMtvw4B5qpRffr/1uYJA+6hSa+3wD3Ze6raP0UtqGODDlEITCfvHJuWspmm8Q9BE4xYNScA9pwqhpqT7oL/7+tPfXkye4nWlQoyTtwCQHCPlt8wTIjCSuBVfqK7oaDSLFuX1elqXHB9iAyBoC6jOyOmONkvRFjC3Y5EGilSFEBQmKEoo97rIi5nfv2rrM20UXpjWRVmJ7aOWCKmIjpQPOC/uNlzWTddmrxxYMVSpB11Y0yTQj4vimzJ+iI3MaioKxni20LMcu38o/8Tlj4vwToGgpzLHnjFa5ezC1NN68l0xDNqP3vEFVDFtUdFg7csB2mcoeIEckKclo5IWfxHtRvh5En052cLkQi4aK+CQ== X-MS-Exchange-AntiSpam-MessageData: h6QJPYcRyqp6OVhR8V640oVjpFhpc9FIJsoGtLIE96TG0knMlxeUuypxvUZy2CDWBNq9KABDiqnzve7BoAaoccnIxqRjZaAAXULvk+uy9HpDUL/pDPjwqX/LI5aOdqE4OfifLpB6oGuyzXkT75D2bA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5970934-52a1-4151-8a75-08d8fc82c7fd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2021 00:43:10.5734 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT003.eop-eur04.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1EUR04HT082 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/webpenc: Don't treat zero-sized packets as invalid X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Before f9043de99a23e35a34c79bfbc9ef17b27f7236d1, sending zero-sized packets to the WebP muxer led to memleaks (unless the muxer was already in animation mode). Therefore said commit simply returned immediately if such a packet were sent to the muxer. But now it turns out that such packets are not that irregular; in particular, one needs to account for them in the frame count. This patch achieves this by treating such packets the same way that they were treated before f9043de99a23e35a34c79bfbc9ef17b27f7236d1 with the only difference that they are not cached (and can therefore not leak). Fixes ticket #9179. Signed-off-by: Andreas Rheinhardt --- There is btw a big leak left in the encoder; I wonder whether we are properly closing the library. libavformat/webpenc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/webpenc.c b/libavformat/webpenc.c index ed8325c02d..3962986c32 100644 --- a/libavformat/webpenc.c +++ b/libavformat/webpenc.c @@ -56,6 +56,8 @@ static int is_animated_webp_packet(AVPacket *pkt) int skip = 0; unsigned flags = 0; + if (!pkt->size) + return 0; if (pkt->size < 4) return AVERROR_INVALIDDATA; if (AV_RL32(pkt->data) == AV_RL32("RIFF")) @@ -145,8 +147,6 @@ static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) WebpContext *w = s->priv_data; int ret; - if (!pkt->size) - return 0; ret = is_animated_webp_packet(pkt); if (ret < 0) return ret; @@ -159,7 +159,8 @@ static int webp_write_packet(AVFormatContext *s, AVPacket *pkt) int ret; if ((ret = flush(s, 0, pkt->pts)) < 0) return ret; - av_packet_ref(&w->last_pkt, pkt); + if (pkt->size > 0) + av_packet_ref(&w->last_pkt, pkt); } ++w->frame_count;