From patchwork Thu Sep 1 21:23:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 37603 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:139a:b0:8f:1db5:eae2 with SMTP id w26csp545276pzh; Thu, 1 Sep 2022 14:24:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR7AJFSYJA/Umfeaf0O/WAWOniQL0FgVB/hqwZVYROPaQy/IvHeIGkFwvkn4RfZlUbuvkJsB X-Received: by 2002:a17:907:7394:b0:73d:cd06:aacd with SMTP id er20-20020a170907739400b0073dcd06aacdmr26111725ejc.180.1662067474953; Thu, 01 Sep 2022 14:24:34 -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 sd2-20020a1709076e0200b0070795e99fe3si184362ejc.984.2022.09.01.14.24.34; Thu, 01 Sep 2022 14:24:34 -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=u52wQ50S; 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 7BBBC68B9B9; Fri, 2 Sep 2022 00:24:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2098.outbound.protection.outlook.com [40.92.89.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1AD7768B054 for ; Fri, 2 Sep 2022 00:24:23 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhPIyMc9tr4guXhq9YZTsMSkFZn+o+kVEPIQZGtxZZhaYGjdJMtK5UDZBiEyhfRxxgZrBA/wsJqz/U7BKzckFxXZyGc6bucgoqHreXPKjX/SQxwalSdRZxWup++eYdmGgjovfhYi+LGqhdYCHCLQgTlIfDhvxWppX9mRlElQLjdtTpjT7xoAymcVMp2SUx42pDbbb6Pb62qVdE347XbbImIOrJYwgswqF7UhTlTrbX+1CyBrCpyu85encGDoUZ5eDzfgHbpUhYT2YWXIK62bEzaGmDijas1PSw5v5M9YiAkOGcQWx4YipSsov9nJ19QmC7lXND66OSAyOmhMoQLtSw== 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=DuAOcusJioHJIEBFWqbCNJge32YFksotZQ9wg8jAuI8=; b=kBG8ZLPG1YY2DE8qLwhqU5kpWpF4hgpQmivupegjBtp0sHuM/XVvn0D+sLb3ZWKlOx+LJtYLiElNLsJ6Cwi6L7UKO9KL/mP2BfC7UUJd1JSyxugd6MaU92q0tuOE8oJXljFTYR8jNsMVbrDSGGdzCpXMoGxWV5xpTmFHpNFHcGjzdLAqw/hOLt5J3caeXQyv8CEGWW46DcCSfYbIbw6d14e87mxnT5GFR6PZw3h3IllzCoAsmSCfGS7uGwseg8cYYbLP7xphUDVnqswqjNWSwmxsddr6lX/mSvL/nbbMfyH5Zdke6giRSc3Uy45tdVym+DtIyGMzOtBGZeLWtPNX8A== 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=DuAOcusJioHJIEBFWqbCNJge32YFksotZQ9wg8jAuI8=; b=u52wQ50SFkpwC5cRtYLJxRG+mGrBK56SLSd7c1BMTwPefijgHkwelkkL7DgubYCllrJlQQN1e4AiuJqXEsH1y6eUpCTdTh1A0Gn9C0QBEGX/567vj7WsY6LPTqAPAZ5Xh/2sUt5AVTaAJ9NgcPMammtnraHk5N5hBYjJm9pktFrINEoLGynK01jBgEMPDtaZX++4WF1xujErQlqNljyPKnve8LbzJ6/acH519TdJEVQJ/ah5SghBK5kGRxKOKkxiFmd4ub+TsNES5LDZRd0pEeCvJ3k/YTxEeZ113SAjssCROaGIHGaNWxfaMb7R0bw6oa2K/g3Xsr0j1OHh8vJ8cQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PAXP250MB0424.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:287::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Thu, 1 Sep 2022 21:24:21 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::90cc:8832:55f1:c7d6]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::90cc:8832:55f1:c7d6%7]) with mapi id 15.20.5588.010; Thu, 1 Sep 2022 21:24:21 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 1 Sep 2022 23:23:58 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [0bWMoCk4AAhVbIcr4kTlGrOB4Cz53kSb] X-ClientProxiedBy: ZR0P278CA0185.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::18) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20220901212403.2622789-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a580ad20-14d4-4fdb-7e5b-08da8c6055d3 X-MS-Exchange-SLBlob-MailProps: ZILSnhm0P3nBJnOPH7CaP06/PjPoSCFAmMCDuQZAqvU3V7zQcZ9Y5StxYRk5E+LiIYJrUbmXcfMLRQlXXMErHXxZz6/1s+Bq5Oba/Gb98qcS5L7XlyIjnmTA1FUHisZ/qzt9iYjMsaBQqyWWueWQAXZwXviaolPcz2UPVAHaYUgEtY7jIvejscASMpCfRdZeiy8v9ux8Dhvom256omR2n0BdCUwIarME1IMRI3bWIjHOuXNj+MNp9YfQXBB2zAVNMhVBtjofiFkqav5XtxmEaoqEQKAFtwwCEDsh6HQFCZ7fGV29kJdAJ9tAYbbv2KSD1I8aPlWEvZDU8CU0aXESVVQMD1ZussuS/wEBJRwaupCaxcO3vijDnIOHv/qTGKz58EOnyTqkMo/EsczTOPh3ts25dZAxvuqccLJ0A5qaqhaLEtjVikAH8JdzmiKcqZBB47miOwo58lfthFh/hrRE/o99UVcWNFbjEbxbhgGr3fAJEmGwkiPh2dWo/0qEj7kz0DHowxmFwaK3oP21zh73RYKzP3Qt59SrVlk0chatFoHMYeasSPhj1T+PWn+yp+IQl8FOTdVpEv0fkNsCdVUWEK4qiC5nOc0xQaKChmrTrmNFioebftOeRZ6eJq7gm11tkklndke9DwvZOJ5P6t0lM3dDYgjWFgYfrTIFeY0WHkg56NaSY+0t9isGeBjgLuBYuxdbBJkH9GAVdCXTRLp584MqIXvZTU7D5TMghtxAmpMtWztAKYPEYfXUNmvvhQQ2ADzjY1W9eOYVOWxHe3tZieyn8ik4M6vg X-MS-TrafficTypeDiagnostic: PAXP250MB0424:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: muHKr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6KMLjDf4zG2EY/Kld3ikbSGsFitvB6WYLYGW0VawUXAExnizC3i4cxr6T5uCnM2Ba4OIhh9aQbVYb+wocagpI3v7Rfdb26arRvym+vV+7MgvdstB0qTyABHCAMRD+4twLqXOMfJO9JPUCCHJiDWc+e1MEqrG8D/3OErNEWvR5tUtTrS3sw5dd4jZzBJskle2/dArKlEn+SOqC77UpN9Cn/qaItJMz/vmL8gP6xkhlYDnDc22To3iyL+JvKIOOKzCDYMpLEe9MbUTRhOvU7BB6D3YN4+oeUURErJGnVdpPQf6O6zgZAhA6hw/jE+Tz9/84Byafzmqdk9g7DIHT20DDSM+DCUgUNIVs3fDj6GlagQEwcV9pQHLJ2QwW3eeDXxA1Zzn7VrITSwtGSQXX2Y2vvfxe7yNpSpCI68vuh3oX4mrzF9q46VGBrPQ50U38oOSL9dioACJb+T9NA7XjLJe147ZWt7Sgt9R96yytzBiekMAjBO14sbvivpZQ70EVVniWJYbTC0Oocfi2dcLADO65a0w8soZDXupQB5AmELpefCqc9468mYeJysjYe8aNVQlMn7O3afDFoI1wNy7JpjXQ0T/ZmhggSij/8kukhCnQDYN6fxtIRvYQlT+MVkriD21USkTnzBq5hp9fliYmJn+ybPgvEj86wUKvSUlqgtnS2aOvMA65CHsQURDY+sMPQE+a+SGvsAQy0gkvG853R27+Q0QsvaE1o+wYW3f1Bo0vIL+X2L/+nLKwiQwv0FfJCgq6EGMl049yCE+VHmeJBlrHVcRYbX+aBXdC742xpvq8V1a9llS+EHmdYmE1k6sh7YZIK2uSRBQhxKcaF1WpjEnie5CAQ4ZTawSdgWqF62d09RbI9MVT3KHQHwP5BvvcRiyYZifDNJUL5mgkdcEstF+iJb0phlhSleoz36wqqdJ14AkicCIeEgac= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a580ad20-14d4-4fdb-7e5b-08da8c6055d3 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2022 21:24:21.3518 (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: PAXP250MB0424 Subject: [FFmpeg-devel] [PATCH 3/8] avformat/matroskaenc: Only write DiscardPadding if nonzero 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: luXA1ImbCHj0 It is possible for the trailing padding to be zero, namely e.g. if the AV_PKT_DATA_SKIP_SAMPLES side data is used for leading padding. Matroska supports this (use a negative DiscardPadding), but players do not; at least Firefox refuses to play such a file. So for now only write DiscardPadding if it is trailing padding and nonzero. The fate-matroska-ogg-opus-remux was affected by this. (I wish CodecDelay would not exist and DiscardPadding would be used to instead trim the codec delay away (with the Block timestamp corresponding to the time at which the actually output audio is output).) Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 12 +++++++----- tests/ref/fate/matroska-ogg-opus-remux | 10 +++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 1256bdfe36..de6c993e6a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2591,7 +2591,6 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, uint8_t *side_data; size_t side_data_size; uint64_t additional_id; - int64_t discard_padding = 0; unsigned track_number = track->track_num; EBML_WRITER(9); @@ -2619,10 +2618,13 @@ static int mkv_write_block(void *logctx, MatroskaMuxContext *mkv, AV_PKT_DATA_SKIP_SAMPLES, &side_data_size); if (side_data && side_data_size >= 10) { - discard_padding = av_rescale_q(AV_RL32(side_data + 4), - (AVRational){1, par->sample_rate}, - (AVRational){1, 1000000000}); - ebml_writer_add_sint(&writer, MATROSKA_ID_DISCARDPADDING, discard_padding); + int64_t discard_padding = AV_RL32(side_data + 4); + if (discard_padding) { + discard_padding = av_rescale_q(discard_padding, + (AVRational){1, par->sample_rate}, + (AVRational){1, 1000000000}); + ebml_writer_add_sint(&writer, MATROSKA_ID_DISCARDPADDING, discard_padding); + } } side_data = av_packet_get_side_data(pkt, diff --git a/tests/ref/fate/matroska-ogg-opus-remux b/tests/ref/fate/matroska-ogg-opus-remux index b69c29df8e..1fa776ef01 100644 --- a/tests/ref/fate/matroska-ogg-opus-remux +++ b/tests/ref/fate/matroska-ogg-opus-remux @@ -1,5 +1,5 @@ -605e8e89efb3028e261dd10255c7f59a *tests/data/fate/matroska-ogg-opus-remux.matroska -10207 tests/data/fate/matroska-ogg-opus-remux.matroska +a3f98769fe55bc5234cf75fb1949749a *tests/data/fate/matroska-ogg-opus-remux.matroska +10200 tests/data/fate/matroska-ogg-opus-remux.matroska #extradata 0: 19, 0x399c0471 #tb 0: 1/1000 #media_type 0: audio @@ -57,7 +57,7 @@ dts_time=-0.007000 duration=20 duration_time=0.020000 size=402 -pos=543 +pos=540 flags=K_ [/PACKET] [PACKET] @@ -70,7 +70,7 @@ dts_time=0.013000 duration=20 duration_time=0.020000 size=216 -pos=956 +pos=949 flags=K_ [/PACKET] [PACKET] @@ -83,7 +83,7 @@ dts_time=0.033000 duration=20 duration_time=0.020000 size=215 -pos=1179 +pos=1172 flags=K_ [/PACKET] [STREAM]