From patchwork Wed Jan 19 21:19:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33665 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5180810iog; Wed, 19 Jan 2022 13:20:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxbxmNFII6fw9iQNQYjMs24JFeLKX987AL2IDSGS4SPIGplYFyuJyXHMHAb73l13VtaI2O X-Received: by 2002:a50:fc16:: with SMTP id i22mr19678036edr.345.1642627206018; Wed, 19 Jan 2022 13:20:06 -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 ds1si570574ejc.775.2022.01.19.13.20.05; Wed, 19 Jan 2022 13:20:06 -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=k+IPk6YP; 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 4459F68B186; Wed, 19 Jan 2022 23:20:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2031.outbound.protection.outlook.com [40.92.91.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 429E468B02E for ; Wed, 19 Jan 2022 23:19:55 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WIHh2xFpxY+0T3plqG9fwffU6JDtJ8q/ufyY1PcGBtMRrj6DelKzjDwBupfpG1/mmLrWSSKSN1MGeWwUomPKDQs5vBiP2JQ9i8ZtXdVIa4EA+Iwu49kRTuS9rPyOYfoUYptMcuXjnwE1o+pJ+RR4RHhiYBbFtCB/saNvFP5xOE0YG4CBsYznt5tLJyCLyu0QPM3mBboqYL9kv6EeD3E6pEtcfYihhJpvhhUnZd8U397t06FjnRSu2wHDqfkyv3opc60ph89lcz+pSl4Y0TExTFtYRgfZP0JxY6myV2Er9e2SLAA4spGBbtwvujcopHj4v4wv76wJDAX2bt5xKYdjSA== 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=roDDi7nxxcFKo1ds6mJOMS4cflg0KcZblyfk/A4/uhs=; b=Lqd5Y9iiVbnHtmNyOMeUtd+VUs0RJjcDM4n9iJSZ1cPTXp1S4Ahj5G4a5HRcnUtXEJnJYbfbvle/AmbBb4gFkEjHuGncs+mbdasas96ZQ0CHhAzB6jBXGfoCmPopB/8udYcVbGYudmsZOuSxGnIhWzNqAICC9q3KUAtS8XmCUxknBWlU1VUzZ2ik67vocGiMuAd1dbSm6YQqvto78EXxxA5QsHowWXSlbvQF2ft7dA9xRcsq0BsIwbrFhTYzHfoCJE4bn0BUiqzLsFdZsB3DBYWYqubrThRZWA8vsmoKELYltQZs+aMTtPrUtysIrpcBMbpcWi/QLST9k3P8H5Q+Hw== 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=roDDi7nxxcFKo1ds6mJOMS4cflg0KcZblyfk/A4/uhs=; b=k+IPk6YP/JXHWjT5xidQKzOEh6fnumpnXIKtt+CPeD9mEIqtmGWyYBzWaz6j3YsJ1FHYkVqvLd+P+K17IcgsjFUMjdEIuopGtqCEc+Twa44VjKuKl4KBlKHRp/LKfWKqBgBZKGV0GgYQ/uSse7CWFUns0W5S3Ua5ghBxhQyvYeKog+QgwH7D7u/zGh6WiYWC8xruF5FfzDzy4k7f1fRsGgQXSsCbbNTHNJ3FL+uqbr+s2HFqJA4lXalvCCIEgRqxWFn/rQC0tQyK65j+JSd3s2OucrhB8EfmvLmonqlQ/hvKuYs6FaxvC0Hh/TlOJFOsYXQqfNfZqQG3LZCBdGUfVw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS4PR03MB8156.eurprd03.prod.outlook.com (2603:10a6:20b:4e3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 21:19:52 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 21:19:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jan 2022 22:19:40 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 X-TMN: [FzQYSaT6x13Ax5gG/F+MY51jdVkMV44y] X-ClientProxiedBy: AM9P195CA0009.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::14) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220119211945.1070615-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 028b7a14-eff5-430a-b511-08d9db916e74 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTWvhYxqNXkVg0MddlohE8xaCLXDmBSzDPZygHQACBVDAD5YawpDznKT7NeTyj21mfvOYUt/Rvpa5hR8JwK2nfgoELL675rEVeWVVgjYyNzE8Fb+whuB0xge5rrqxdFHXBPYfzQIIy0myeamRH/M4lNYuqxSBHWbs3cy5cOm3k7vRRTMsuVqSEH2XcFM7ZVPJfdB3MPLtQii0AWAyF8MpWVdpf4//aNZIpDNBaizlz4OosvE1Bkod2X7CogEdlcQEJVqZSCW12thwyYq7FGmlfVPWdhQ2riaE9iPmJMNeX8urNtTO6Nb1/L4BsXUmjSGytNSFp5A2XmKqPqC0Nd7p/xBtJmHenW6Pqi3SG28qh2kPIq6l/ji9m6/jFGOEEFHNe9unTAcJ3yjttMKVXQA8j2tNePSDVPTSbNl/gva/I8yZbBmM6FGOqaSw6XtzLHNa4sjX+vuctM5s1KxSfzVR0Lx0OyBZJtGOIHpPGT1kW6oddp0wgieZVRJK6kytfJAMfrhRdhX7rJF69TUlte+aMVbQKcF+OlMWjXOv/0Qv5GKMnvDTwp/Nw/LpRNBnOxjZLPEmCMSq6NMsWpXM3l1dbjSzKWRf7tzWkbT1q6zb3nwufoiPEhBPiKCACBQWUvuEZdSct5gR8BeKb2pPy0GlvI2x0hbpv+pxcpB212+QdJoUl5R/1w7NofyxWXZX7tr4WBHtLvs+1qiscE52QLlGaigH9w0DuiGsB0vJNena/Qoc+ih9KzRZrUkUF6I5cBLgA= X-MS-TrafficTypeDiagnostic: AS4PR03MB8156:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QHFM+9drpIb+7QhQoH1AcjU5MjtjVpyQvBsfv12hJgvNNQy1nk3Wi+3FXF57CFstMYIXLRgCxZqSPadFwNaPprd7y17cy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ROt+UEZ8MF1AOdrYABiKkUHJhWsojP/NbWoFGHG6QN+J8gzAVGKHhxv6k2g+b5/eRodBhjt5e+kZ+e6IjF2SFuN3ZykNgSN7yPmpH2l/ariWC+R+YQDFYpOF3Iu5/lcWhH/0xwlK3+bYIrG8TLd49IbTPGeGXygNL85DcZ6JSTq02856J5Sj1bwAdXnyAmITqbiD2Q1PHHWSODfO78eoI5+FVRiFpcXqud8eDxwvxquXa2rbfl+6pqEwAzPr7iqW4gvb6OEA9YzlJTP/vaCMBSPyCHrPh+omvJ5CkmqS0ybEDq7wR3OTcoFqFLrXVd09oTaUVTPGnT0Q0jRgP4oQtC1nyCJHx+/El+AlkOkYbB6+6U4RtfW97N5GTm3sgs4cKUhWrqwUt+i489pNzmwWE7xHP4FowuCEdcDD0N6cu1sH4b2XMBJl4JoB55u2Ck01upoooZ1/R4Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 028b7a14-eff5-430a-b511-08d9db916e74 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:19:52.2643 (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: AS4PR03MB8156 Subject: [FFmpeg-devel] [PATCH v2 1/6] avformat/mux: Remove assert based on faulty assumptions 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: WNPh/IiXfHlL This assert is based upon the wrong assumption that the noninterleaved codepath is never used; if it is used, max_interleave_delta is irrelevant. It furthermore ignores audio_preload. Signed-off-by: Andreas Rheinhardt --- libavformat/mux.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/mux.c b/libavformat/mux.c index c387f8ec6e..e34fd88f05 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -697,7 +697,6 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) ); } } else { - av_assert2(pkt->dts == AV_NOPTS_VALUE || pkt->dts >= 0 || s->max_interleave_delta > 0); if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) { av_log(s, AV_LOG_WARNING, "Packets poorly interleaved, failed to avoid negative " From patchwork Wed Jan 19 21:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33666 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5187224iog; Wed, 19 Jan 2022 13:29:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyCu95RaixrHhaCJqiqrmpstp4q6VQdz/UattCup7CpJW95BYmmeRZD1Tg8M2qPaq7Z/izv X-Received: by 2002:a05:6402:6d4:: with SMTP id n20mr6263522edy.69.1642627799376; Wed, 19 Jan 2022 13:29:59 -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 kx3si474344ejc.685.2022.01.19.13.29.58; Wed, 19 Jan 2022 13:29:59 -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=fwGWDlmv; 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 37A5168B18F; Wed, 19 Jan 2022 23:29:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075047.outbound.protection.outlook.com [40.92.75.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0527B68B04C for ; Wed, 19 Jan 2022 23:29:49 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mVb0sv0oM+14pL3qNw7UDqO7oBnvSwI1bc0wE+9/olkp/Kt23Bqw47LMH0iK2tBUM4SbLQmSWdJW0zijBUddPIZ0tSQbuQAkVnT2IAHaD8gWRJpAO4Ga5H2hlvnjWqXHkoj/oUdfzQDpTysTgOIctQbHtgP7mVtfmJtxRxxw1vPwv0Z6HWYIdQ5YSQVtJRaIK/gY83lt9heVhfjLwuRyG4dccrKwFy3NWqDVwKLwPTl8ox6F0cHEYpr7pGpGeTSFEmVj3+Rb5CDrjvkuMl4vKiKHy8QNpr5E60AXOoAQ3pCSWqLUAzojBgCzNtggP50X6PtHAh1JlmwbIKkNyHK20g== 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=/oO1msTNqAvOwRt+wmycOepg+6XKBp/ILzfvmQrDuls=; b=BL6/62Uf2bT0q1EmhG0KVlJlWZ93o6+SqUxhGPTCZ9T6MG78y33B00Cz8P0/5H04aCirjTNqYIobWqqXuxVvzSPSyMu008P7Iot7uIGd5FFDGhrCwwz0AOEHd3xwn1NRLQMx/LwC5yRjCsTe55fjs0v5wl8fQEjq8MNZHhNJaHxPgFPmN0d7k+pO7JCeznd53Gw3beckIoF5mS/d1WiOOxdQoPAeJ5UpX2EIRJqPEPMu+Cw3hD9IyI0NGLSRfE7xum9Tw+5jefzRUI4X5IbdCraGO1isDMrwgVXG61LRXJcKrXPECMxUiKZieA4oVGH46EaCXWjawepW0yy4T3ItIQ== 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=/oO1msTNqAvOwRt+wmycOepg+6XKBp/ILzfvmQrDuls=; b=fwGWDlmvdAZxcMjeqo4XKpqFgTsOfWuMl9313pt/yA9f6V2omkaH0G08tIjDDnBvkQiF985KHm1pxb9fmVyG4cjrmmC9xtofkDFjADszGysq6F6BjXlgYENBnfirHkf5ZOr+zFUDXhi1X0UPs7P4xAiY60HArjIzFxCQ1+cOD6dMYy89z2RePsO6jeSKesEhtCSOWf9zeaGV//Oo8ax0tHG8RjdoSedLKJR+gv45S2W30SsPi65kMzq8CnO5+qsxkm07wJzosQLwIVD0vMy/dD+nWy35hW/eXOPrzBDPPh8FbplbMofYgMd7WFatY45ElebBhRuRFwAFaGoLTcwPnw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DBBPR03MB6796.eurprd03.prod.outlook.com (2603:10a6:10:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 21:29:48 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 21:29:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jan 2022 22:29:36 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Yj+zmgOCxyJN5Q/nG/wqaOEymo1Gn2Q2] X-ClientProxiedBy: AM8P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff25a5b7-532b-4814-2f7d-08d9db92d1d2 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTWvhYxqNXkVg0MddlohE8x3NN4xh3kOrExlX86/Z18ZFRi3fDZp0KBiJs71OwJHxdrZev53D9nJuWSxe9jNHi5xSZWwbRdYk/0EOaj2do3+2GyJRSR/en3hnQ5UrIT0WmpykfVqj1h++5pW0ffxbMKwcR/n12EdTfArpMjKrQNUH3hnzjZRBlIwW/nHUfB6HwQEO5v3X4HHE3bTB6BfUGhfuBwoCvbrAfuH1tTGEP/TsdzHCE91y6Gq87qZ2Ugr8KH+lNbYlt0JGRX8LYc9LOXrDuyfrjSnHJdNUMf2krZ1tdntgwORJVh9gIYUCJRXpy7vhgXEjA4E19lQlDviNucxDEIQmfWNubwjzQMPJGXa/trY9rOg0rsh3rE2VmL+anZzlYsAT6QF1uopJFDSpmPRqUdVPs7OgHPcKh+U3rY5o4C149g89p1+zq+M5A0gr7lgHC7wzzYPRMIXiGCFgSM/iA0PJ8vI5ofxaduMMoDW8fVdZIz9vBrCpt715UOaboEFeDE2lFcgu02CQVVG9WaZMA6X1QulhD3+xvcM4Z0I2HQaqoYI+8aZTHzguTJlvlJ0GsXchKgdRSTyu9p89ry60+4ih+OgD6fva7Ebs7cfe1X/cfaOJNKp/pkzLEaEQ4dU/PtmElWdx1TaIuSsB9rtZqVwjzLqZMRkNOopR0n0MDasYX8ZKtnxHR+RcLfq6UdnalT6UKdsn+uLB8Zp38vVyKutXjFHBS2/fW9jhUonsM5ZnPwq6+Ijuqv/iG/ltI= X-MS-TrafficTypeDiagnostic: DBBPR03MB6796:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s6mDimyrj1PlLaGelLQS2pN5fBIchWccmU/75M9KjzlL7QLtE0tR6tevbXxHfpQokrex0/L2uKKH0FMgWc4KxmWLt5fzmqSEIiH4kxfvNPoJUbsgT8/CZa7MbToon8jH24lr/Z8M890HIDyhIZYAguU9cRHnudau+AdOHodVrclNaiO8JajPm8xIkAqtoEA78oWUP9ydizQR3EThWt3fYM8Cria5Vi64uXWttItmIDUCrm6R8b99nSzfNQm3po12LyYlZggTeV7EfwSZNI1XjE8p+jgLZCYGoM8FYIlB8pQmSzMrt60RcDOmN2LXR5Cs2Y3ZfEq1fUKVxaKf98RxzII46Y7b/mBPLSqWgO433atP6aNyB0pcoavYkdXIMk7/p8G7s5eIND0XjLBpHJkdeZaOmwHXNwWnArX90OeNVj85zbeKVgTNkOXkKhD6FwAKw5QZfZbrsop2p3CrnKWNH6H0hynpmWRTA/LnmGdS+WQApqmOc8rj5MOdPI8wmoQKjE4rdxr2zgZglxkLe5DcV5R8nfBQFdphgxxtUqMK7xDZ86THg5DcSZaHViMTZpOyR4iXzF7R/V7OHI8jMGl5Aw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3cZP/9HZTi6pnPGvKoH8ixSx+AKp9K9TA9Atz/GVghwwEKDK9A2JhuxZPGPw29mGkOS2xBDgT8be0i3ULP6xpMVnUSKKk6y/m3DhzlcE7wL5PTebSAIh0KB1Ux/hZrsQmbkQihUpnkPbOUzs0wnZ+QfuyAPlgceHtaPQc5HpX0YKgGnLakPfFlZioFaFVEt4YM6hD4g1fFaHEuEDN0QhZ4d7Yyq6wXe83O6/6cVK//oEONy/Ea1Q41X1/xkslXrgJyNDNPHmyeyMS1lR5UQ8gURZHY1x0XvtKuDT1A3BJBoKVa0fgMxSaV2uwse1XVYobcW7QwEWAX8KjykyTPRMA/IWx7Rz+VkNOIdjMIB8aa5V5qtnyGOtgUm08AyzwjlrvvE9PkMFu/fWYZMSoQtZmhhIBCLYEhAJAwAE0hBocu2yODcJil6f18fxiYDLZ2KbpnBKTeuwP+k26O1/w3LZB8aTbWmx94RwCNEQVBDP4PY2kV2k89tpkXeYBruOuVZvE3paeC54GFx7oJ00fbygiWoP2ICcfKfqGDAX6fqbaL7pz80PllG2XiBG+Xlxx9DD46bnsS26t6m7oFUF3IN5D134aNVUdwuBd+q2jVS8fryOxixZdKZcf4Xd4d0qeRdbpI0VAGbrJNnqG6r+RThRsOPnZLgkwzUVmHFbKXvi5UMlGggRaSWvA0Lr36BlOwNdA3Bx3UkbThdhEHWeReKyNX8317E1CHXDLXtDQDJxmbws5n/7+/HYODinbkMn5/7gd0rH4iD0Vcmu1mIrod2f816EmS/aaegC1pnlt+nKW2vWyA1jGZgqskYJbQ6GVTfHDCiHndf1JCF7Ks6DUC0C5DlbXWdkLC+bHLDvoXR8G+M/+BjxAbilsGadKMdXbeO3RSrEiK0CYvLcsEfjeXsOIh+CPBS/zxcgYsfGGCzHzL/KEZAOzmyMW5WRBbcrcD7DTsFZUe1wFPKSbyjQFspK5w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff25a5b7-532b-4814-2f7d-08d9db92d1d2 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:29:48.3748 (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: DBBPR03MB6796 Subject: [FFmpeg-devel] [PATCH v2 2/6] fate/matroska: Add test for avoiding negative timestamps 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: /IxKck9cQIHi This tests the issue from tickets #4536, #5784; the output of this test is currently broken. Signed-off-by: Andreas Rheinhardt --- Now only performing codec copy. tests/fate/matroska.mak | 17 +++++++++ tests/ref/fate/matroska-avoid-negative-ts | 42 +++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/ref/fate/matroska-avoid-negative-ts diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index 2fcac34d62..b65a76411b 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -90,6 +90,23 @@ FATE_MATROSKA_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL MOV_DEMUXER \ += fate-matroska-dovi-write-config7 fate-matroska-dovi-write-config7: CMD = transcode mov $(TARGET_SAMPLES)/mov/dovi-p7.mp4 matroska "-map 0 -c copy -cues_to_front yes -reserve_index_space 40 -metadata_header_padding 64339" "-map 0 -c copy" "" "-show_entries stream_side_data_list" +# This tests the scenario like tickets #4536, #5784 where +# the first packet (with the overall lowest dts) is a video packet, +# whereas an audio packet to be muxed later has the overall lowest pts +# which happens to be negative and therefore needs to be shifted. +# This is currently buggy (the timestamps of the video frames muxed +# before the first audio frame are not shifted). +# (-ss 1.09 ensures that a video frame has the lowest dts of all packets; +# yet there is an audio packet with the overall lowest pts. output_ts_offset +# makes the pts of the audio packet, but not the leading video packet negative +# so that we run into the above issue.) +FATE_MATROSKA-$(call ALLYES, FILE_PROTOCOL MPEGTS_DEMUXER MPEGVIDEO_PARSER \ + MPEG2VIDEO_DECODER EXTRACT_EXTRADATA_BSF \ + MP3FLOAT_DECODER MATROSKA_MUXER \ + MATROSKA_DEMUXER FRAMECRC_MUXER PIPE_PROTOCOL) \ + += fate-matroska-avoid-negative-ts +fate-matroska-avoid-negative-ts: CMD = transcode mpegts $(TARGET_SAMPLES)/mpeg2/t.mpg matroska "-c copy -ss 1.09 -output_ts_offset -60ms" "-c copy -t 0.4" + # This tests writing the MS-compatibility modes V_MS/VFW/FOURCC and A_MS/ACM. # It furthermore tests writing the Cues at the front if the cues_to_front # option is set and more than enough space has been reserved in advance. diff --git a/tests/ref/fate/matroska-avoid-negative-ts b/tests/ref/fate/matroska-avoid-negative-ts new file mode 100644 index 0000000000..a687c8f63c --- /dev/null +++ b/tests/ref/fate/matroska-avoid-negative-ts @@ -0,0 +1,42 @@ +3349536550047c5c553215003ba2acb7 *tests/data/fate/matroska-avoid-negative-ts.matroska +973070 tests/data/fate/matroska-avoid-negative-ts.matroska +#extradata 0: 22, 0x2885037c +#tb 0: 1/1000 +#media_type 0: video +#codec_id 0: mpeg2video +#dimensions 0: 352x288 +#sar 0: 12/11 +#tb 1: 1/1000 +#media_type 1: audio +#codec_id 1: mp3 +#sample_rate 1: 44100 +#channel_layout 1: 4 +#channel_layout_name 1: mono +0, -37, 24, 40, 9156, 0xe5bd034a, S=1, 40 +1, 0, 0, 26, 417, 0x7198c15e +0, 3, 3, 40, 1740, 0x29ac4480, F=0x0 +0, 24, 123, 40, 3672, 0x98652013, F=0x0 +1, 26, 26, 26, 417, 0x3c67c32d +1, 52, 52, 26, 417, 0x8c24b1ca +1, 78, 78, 26, 417, 0x6ee576b7 +0, 83, 83, 40, 2532, 0xa2c42769, F=0x0 +1, 104, 104, 26, 417, 0x407603db +0, 123, 203, 40, 1728, 0xae823d3b, F=0x0 +1, 130, 130, 26, 417, 0xcf2804d2 +1, 156, 156, 26, 417, 0xcf2804d2 +0, 163, 163, 40, 1028, 0x286ac52a, F=0x0 +1, 182, 182, 26, 417, 0xcf2804d2 +0, 203, 283, 40, 1916, 0xd378899e, F=0x0 +1, 208, 208, 26, 417, 0xcf2804d2 +1, 235, 235, 26, 417, 0xcf2804d2 +0, 243, 243, 40, 1168, 0x424e12cf, F=0x0 +1, 261, 261, 26, 417, 0xcf2804d2 +0, 283, 363, 40, 1660, 0x5cec156c, F=0x0 +1, 287, 287, 26, 417, 0xcf2804d2 +1, 313, 313, 26, 417, 0xef163d04 +0, 323, 323, 40, 1004, 0xac0dce29, F=0x0 +1, 339, 339, 26, 417, 0x2a009b3a +0, 363, 443, 40, 3008, 0x0fc798bf, F=0x0 +1, 365, 365, 26, 417, 0xbedccb9d +1, 365, 365, 26, 417, 0x2214be3f +1, 391, 391, 26, 417, 0x8953b878 From patchwork Wed Jan 19 21:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33667 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5187377iog; Wed, 19 Jan 2022 13:30:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNZki3nROHuT2i/3Z8s2Jtmrqm+az4YNHAYmnsEGc5uyVS2XcdiLwEz/vN1jCJApClz2Qf X-Received: by 2002:a17:907:1c88:: with SMTP id nb8mr3547257ejc.110.1642627808816; Wed, 19 Jan 2022 13:30:08 -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 q4si539166edb.472.2022.01.19.13.30.08; Wed, 19 Jan 2022 13:30:08 -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=KYMefDg9; 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 6E79968B1A0; Wed, 19 Jan 2022 23:30:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075047.outbound.protection.outlook.com [40.92.75.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 270C768B17A for ; Wed, 19 Jan 2022 23:29:55 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fXAWHZHsQLU4IvEhq5oIdKQ07HMF9av/a4pJ2erfMpWXObWRAcsFsANy9YjClpKyCtNhjUUqWovuarp4VLw3ehckgryNjXm2qs50efVjdHgdxB41YblkhvrfUFCda7sUl3g9pZPMNG2OFe2aIcrmtdwX9vcRqIsmro15ma5xRiYW62uvnpdSOmzlkkVseOTJTO3nWhkI+XYjKOH0F5Zp6d1hTFpgs4yKHxj8BPhSBTZXEJn5G2oQszgdnMUEiPova1F4JSRYr9vaCR+4Imf79NMoALkcm+JrJfG7eH5esnJ1w2JiOhL1xaq3Hx/H8h4nOSMXoCGPjbmt7hjR1SOl8Q== 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=XWxYFJ6M9DQRt1xEDhmaDM8EFwhFnusAjsZ+Fi9L63c=; b=FRvc3JKBS32tpZGOLY6ezCGsbgzIKpcFYvWa7PJZoPEIqc/1MzHRtmgFJS5Puh/UHEGpLrXEzxd+oBP8FkLTiwz9EoRsZGL94MeTCtZWPZAp6JQMiszZ0RizYXJj0C5zU1cSV+i80beLrpv6an/FvGTG7BB0rm6ZQOarvDTKf7KclNXE56kgnE2BGVo58ILPgtOz21Z0x2VrHRmRsVn0jxzx1+T4wBgofg/ucPHZiJNcK4UAKMfCMMcwAbldxsqQkuvzjbgGN0et74r8XbFto+kg08hVZdf1vpVhOKXGxcauzDoQrbtavGVcXcI7xQPQNWV12fvT53qc/E/HO1IeoQ== 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=XWxYFJ6M9DQRt1xEDhmaDM8EFwhFnusAjsZ+Fi9L63c=; b=KYMefDg9hWX8U3+T5iIOptZqPB0e2cJmKhtd14+o0yeFEPPa2/o0JzGYtsfiugZSwzU8T2scTzFlCzDq331mjHd/uZA8CvDBsSOjkPVFujxD4OUaSYbBurqc5BGK5rlBqmKyF3nqTCI7aT12MKYhrqrCAxVYH8QJVixIuZf7l8kqdGqO7q8GBDwBcw/fDWUG5sufVUzbH7+W2kWywIfkR0p2gL/HdnmS0ZTSI5Rp2THzpljFSFxbjVxsgzjadu1YCzE495E5uxQj3ldQfth6vipc/H/OxdpT1uWnnQvpkx8QybwLXRoZXKTUFB/LWXIc3Y5/bOT/LbJPJnxc6GHPbw== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DBBPR03MB6796.eurprd03.prod.outlook.com (2603:10a6:10:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 21:29:53 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 21:29:53 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jan 2022 22:29:37 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> References: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> X-TMN: [Ml3ieP1Or50nyxBoL8fHJcPZl4RHwMeY] X-ClientProxiedBy: AM8P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220119212940.1071477-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 50a3f6dd-e6f8-4190-4dd4-08d9db92d4b5 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEu2NlvrW5n64XaJ9+lJW+MeCSqumr8FZTDFhrxcb3ToXokbVBaxhsVESgbnRSd7Y8QmtvmpPX6KAICAj1+nW1UGfrovJYYVUsHxhiraN9ELXZ94C6uIa0jwfg43m+QxhDQaaoSsB+7KM9YngwIOK6C13OUI7esnlGy/Kj2Afwex1f3vPCFe27K6KQQk3HbPr/wbHhX52zHfk3oD84tCTvvH38JyRdYTIr5eEKB0vveuuSXyaLzZHrRrrbjl8totVEwzi+kluhhFJnQ28w7RpVT2PJnEeR31a3mT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/3EVvqg21tQc+wGchGpWNuOcXJig5J6EOkSFOCvmw3swQNtRWyw+bGQQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 50a3f6dd-e6f8-4190-4dd4-08d9db92d4b5 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:29:53.1870 (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: DBBPR03MB6796 Subject: [FFmpeg-devel] [PATCH v2 3/6] avformat/avformat: Add AVFMT_AVOID_NEG_TS_DISABLED 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: moS3kqPDYbxz And also don't use explicit constants in the movenc test. Signed-off-by: Andreas Rheinhardt --- libavformat/avformat.h | 1 + libavformat/mux.c | 2 +- libavformat/options_table.h | 2 +- libavformat/tests/movenc.c | 4 ++-- libavformat/webm_chunk.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6ce367e854..cd253fb28e 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1533,6 +1533,7 @@ typedef struct AVFormatContext { */ int avoid_negative_ts; #define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format +#define AVFMT_AVOID_NEG_TS_DISABLED 0 ///< Do not shift timestamps even when they are negative. #define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative #define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0 diff --git a/libavformat/mux.c b/libavformat/mux.c index e34fd88f05..a1917878a5 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -421,7 +421,7 @@ static int init_pts(AVFormatContext *s) if (s->avoid_negative_ts < 0) { av_assert2(s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO); if (s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS)) { - s->avoid_negative_ts = 0; + s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED; } else s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE; } diff --git a/libavformat/options_table.h b/libavformat/options_table.h index 62c5bb40a3..86d836cfeb 100644 --- a/libavformat/options_table.h +++ b/libavformat/options_table.h @@ -95,7 +95,7 @@ static const AVOption avformat_options[] = { {"max_ts_probe", "maximum number of packets to read while waiting for the first timestamp", OFFSET(max_ts_probe), AV_OPT_TYPE_INT, { .i64 = 50 }, 0, INT_MAX, D }, {"avoid_negative_ts", "shift timestamps so they start at 0", OFFSET(avoid_negative_ts), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, E, "avoid_negative_ts"}, {"auto", "enabled when required by target format", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_AUTO }, INT_MIN, INT_MAX, E, "avoid_negative_ts"}, -{"disabled", "do not change timestamps", 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, INT_MIN, INT_MAX, E, "avoid_negative_ts"}, +{"disabled", "do not change timestamps", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_DISABLED }, INT_MIN, INT_MAX, E, "avoid_negative_ts"}, {"make_non_negative", "shift timestamps so they are non negative", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE }, INT_MIN, INT_MAX, E, "avoid_negative_ts"}, {"make_zero", "shift timestamps so they start at 0", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_AVOID_NEG_TS_MAKE_ZERO }, INT_MIN, INT_MAX, E, "avoid_negative_ts"}, {"dump_separator", "set information dump field separator", OFFSET(dump_separator), AV_OPT_TYPE_STRING, {.str = ", "}, 0, 0, D|E}, diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c index 2af72f11c7..ddcb053bf2 100644 --- a/libavformat/tests/movenc.c +++ b/libavformat/tests/movenc.c @@ -455,7 +455,7 @@ int main(int argc, char **argv) init_count_warnings(); init_out("empty-moov-no-elst-no-adjust"); av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); - av_dict_set(&opts, "avoid_negative_ts", "0", 0); + av_dict_set(&opts, "avoid_negative_ts", "disabled", 0); init(1, 0); mux_gops(2); finish(); @@ -578,7 +578,7 @@ int main(int argc, char **argv) // one before. av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); - av_dict_set(&opts, "avoid_negative_ts", "0", 0); + av_dict_set(&opts, "avoid_negative_ts", "disabled", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); skip_gops(1); diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 24390e8e74..9348e6680a 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -127,7 +127,7 @@ fail: s->avoid_negative_ts = oc->avoid_negative_ts; ffformatcontext(s)->avoid_negative_ts_use_pts = ffformatcontext(oc)->avoid_negative_ts_use_pts; - oc->avoid_negative_ts = 0; + oc->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED; return 0; } From patchwork Wed Jan 19 21:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33668 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5187501iog; Wed, 19 Jan 2022 13:30:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdlaryNaNKDdLROmtNfLCjDzXi5bqr0H9zexEPgI4p3ZoMIFt+jQoSsvHuNOI2DYVj08kp X-Received: by 2002:a17:907:6092:: with SMTP id ht18mr6529667ejc.471.1642627817980; Wed, 19 Jan 2022 13:30:17 -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 e10si594102ejm.93.2022.01.19.13.30.17; Wed, 19 Jan 2022 13:30:17 -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=L371lfNJ; 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 38F6A68B1A5; Wed, 19 Jan 2022 23:30:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075047.outbound.protection.outlook.com [40.92.75.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 54F4668B17A for ; Wed, 19 Jan 2022 23:30:00 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oIAEeqCSnWCG/AyiD/N40B5TyUjhybKqaMgnJ4QOZnn4hldG+dk/RrxUmVOckcOizlJKmoOKVPo4FuBXfwiF62TM/4U2dEKQYoGTvllhRB1k7b6DHTXDuaI/dupUuPZIMjqyb0SXaK4aCj43ZQ8i1ezCAqbUV2hqa5Xem8lvw3ar1cyp8+ZsP1DsrpJgp6kqvfPg3peF0xKw5zz187Ajb6VdV28uYTx7mdOhihAXQxzXIV/7iPIs7isaP8bKa2umOdWCHOkKRrXPjRFDb6yPdlN0O7b24hPe0GSy2itduCeKFyY8Q1bTf+eEf7pBNHGCZqCWvxxDFDRm3FPuxsR3Aw== 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=mvWoQK2ULV2WPMTJzjt08VuF7Bx/eU/myHO/Q+yLVyc=; b=Jxap7+H0T0B7cnXHvMLMGE13IOW1LaBz2FcF0wfh/1dp5/v6X7iRusXbAj0vimhzH/sJDhWHyU105pKjnyt0f4NXO2Kth1fY65NtcjWVKCx/o0F0DAnjt4LD3YxdG3OAWcbxWFkornGCZ3S/X1sk1cjJu0BoS1JBFCwjbLiZqfK3tHiLMI7vdCmBU5OQHuSaabsnDKgSubCINEGZt98+9Ovs3cpmn6xwS+/b+63iRCD1UQHlVnDeVU9FziBva1823gx9P5Y9tmGgIlmCHZz4rnDIDhrUvAtTiZ656rSYY/clKyiGTaa0maBp4tFzYwCJ/ZbpZ9ejY78WO8nIhdVm+A== 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=mvWoQK2ULV2WPMTJzjt08VuF7Bx/eU/myHO/Q+yLVyc=; b=L371lfNJd2b3e61WMuI2Vazu4ulXAL+JkazpdKO0Va3NC6z+HDe0/6HDNn7CSepH+olxU4iOGi/E/joXwWNwVsOAwnPUpajFQ1iGmzuUZBBzTbqAbrmcwqEhifE5q427TKPkGz9bIiWvCvb+TixMQjRSAUUGcY4y8dd+7bB6icBeYGTpNRfGF6XDtLasDIi4+CtugJ5aJWwwEk65xx7VfGVhltI1pK1cmJ1nb1JxHgAir2eDMnUX1IK1ONEHsuPfg8DmbHO7leUYAYCzUpUlc31pXKuSUDqh32fOlav5HwZyuL2vuMBom1HsA/RCQ42Rj9cfMk+4Z1LcG/kwqxoG6g== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DBBPR03MB6796.eurprd03.prod.outlook.com (2603:10a6:10:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 21:29:55 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 21:29:55 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jan 2022 22:29:38 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> References: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> X-TMN: [rC4Hjv2vfTq0+IAChTaJCHfyq8yCPrfG] X-ClientProxiedBy: AM8P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220119212940.1071477-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 66b0b91c-08a2-4049-e943-08d9db92d5e2 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTWvhYxqNXkVg0MddlohE8xZ1eEMiaORGzeU0LwdhUMfxOk9nhPYqztFZ7JwG2BHvvxLP/Qpq5PuHXa8aEBbvM3DYfI342OvwIKw4YkqokAC07dN+a/fmwHJPGd5KD4RC0jIHSKJj2nNr+9ZQP/Uq1x3qNrHLDdccQkjxmP9dwTnS4JmaeWLUq6b08g4NGJzCTJOrDE0ooTGFayyfWDwOY5gFWOLN5vBXdzustmgpso7hN98DiLoVxp8BPkj2OD8zufpHRPt/DrJFjIVY91jHcGosvkJKj3WOe6ZOZtrgFObUs8ZzdkzR/QmFmBOGn+7UNEM5JryiWNJ+QxB1qklqpAY4Ol2UqnLb/Mr8iguSxGVRCTFcsPQMBBM3agArFI0VUfCskkNNVzco86p/FupIPiiOAlmNN6RogsJBH1b/yYUn1GlZsyaZQRj7jPCawAjAmpAGVOOa91HOrxDXSrAuW63WA9Up59fJkyzb+NVVYw/Sho5B8NHuBfP4F9lAzpvcsiqGM0OKRGFWYIs6LGfAmUAWgmGe5jKfahztwjeXArFEZ2ErW6IRd2dL/wJ0CiarKOBJYLixpwmBIXF7ndi9q7DDbX3xJ8igRStAlCb+ZHfSK0ePlC3HNFrrBCFboSd5ivvaB1bkqt8wJCp5QJg/Il4dpj2s1VqB0Sxn4vPQxMO55CaEnKgezjbbaH3JjZHVjz8oiMzWoNKBeU0A4cJQJBcjlBaElOh6re8cLhOhxESIP/nAmXoXk9L2ZdGvMi9oM= X-MS-TrafficTypeDiagnostic: DBBPR03MB6796:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qUujUHfNZgb8RmqdLmLnvw2tcT5rOVHc1pUFrDine081hujG+2XhER+3vqhBgN87xHYqq6NhWT64KEcBqWs0CPBjZ+qfG3Btvp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Jj4ojVkEhzvgK2cU8U+yy+EyYxUNnUnzm028RTh+b10YtQRAHacGUQ8p+SVokeiPEsYBCYVl7QqcpKreW7HU/qp9gaM8dnDTDx27B5LKECyNxhMf3FUxlMDrAMWehtULoMH68ty8lkMd3moXaldSRZNX1o6VJM82Jj7U2sKEhd4rKr2ohicQsyiMEJgKOdQYg56fddo2XewHY8IKcI56pdSMtT5SccgOoXTAPELjwNh2NoSxsdy9UfsEVRdF5ltfzTlAEGOsU7FLFlUdu5nK+e9zhNM1h+fhcgYZt4PjgvFE/RymqhFSjoLm4KF6OT8G/RWk64odKNifALgfJhaSCjDNNmtdr0k8e2Wa30rWue/MQkfnIt3VhoA+pcgBBPOcxh0MSVK2VnUA/fkRyuBkcYbtt9PXUmg2PXa5wzNdXxbPtpkd4FjKtqSfBRdvCyeUXKusCQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66b0b91c-08a2-4049-e943-08d9db92d5e2 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:29:55.1792 (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: DBBPR03MB6796 Subject: [FFmpeg-devel] [PATCH v2 4/6] avformat/mux: Preserve sync even if later packet has negative ts 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: OXMYjm0iwR6Z write_packet() has code to shift the packets timestamps to make them nonnegative or even make them start at ts zero; this code inspects every packet that is written and if a packet with negative timestamp (whether this is dts or pts depends upon another flag; basically: Matroska uses pts, everyone else dts) is encountered, this is offset to make the timestamp zero. All further packets will be offset accordingly (with the offset converted according to the streams' timebases). This is based around an assumption, namely that the timestamps are indeed non-decreasing, so that the first packet with negative timestamps is the first packet with timestamps. This assumption is often fulfilled given that the default interleavement function by default interleaves per dts; yet there are scenarios in which it may not be fulfilled: a) av_write_frame() instead of av_interleaved_write_frame() is used. b) The audio_preload option is used. c) When the timestamps that are made nonnegative/zero are pts (i.e. with Matroska), because the packet with the smallest dts is not necessarily the packet with the smallest pts. d) Possibly with custom interleavement functions. In these cases the relative sync of the first few packet(s) is offset relative to the later packets. This contradicts the documentation ("When shifting is enabled, all output timestamps are shifted by the same amount"). Therefore this commit changes this: As soon as the first packet with valid timestamps is output, it is checked and recorded whether the timestamps need to be shifted. Further packets are no longer checked for needing to be offset; instead they are simply offset. In the cases above this leads to packets with negative timestamps (and the appropriate warnings) instead of desync. This will mostly be fixed in the next commit. This commit also factors handling the avoid_negative_ts stuff out of write_packet() in order to be able to return immediately. Tickets #4536 and #5784 as well as the matroska-avoid-negative-ts-test are examples of c); as has been said, some timestamps are now negative, yet the ref file update does not show it because ffmpeg.c sanitizes the timestamps (-copyts disables it; ffprobe and mkvinfo also show the original timestamps). Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 23 +++-- libavformat/mux.c | 111 +++++++++++++--------- libavformat/options.c | 1 - tests/fate/matroska.mak | 4 +- tests/ref/fate/matroska-avoid-negative-ts | 6 +- 5 files changed, 81 insertions(+), 64 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index bffb8e66ff..f24c68703f 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -82,6 +82,17 @@ typedef struct FFFormatContext { */ int nb_interleaved_streams; + /** + * Whether the timestamp shift offset has already been determined. + * -1: disabled, 0: not yet determined, 1: determined. + */ + enum { + AVOID_NEGATIVE_TS_DISABLED = -1, + AVOID_NEGATIVE_TS_UNKNOWN = 0, + AVOID_NEGATIVE_TS_KNOWN = 1, + } avoid_negative_ts_status; +#define AVOID_NEGATIVE_TS_ENABLED(status) ((status) >= 0) + /** * The interleavement function in use. Always set for muxers. */ @@ -135,18 +146,6 @@ typedef struct FFFormatContext { */ int raw_packet_buffer_size; - /** - * Offset to remap timestamps to be non-negative. - * Expressed in timebase units. - * @see AVStream.mux_ts_offset - */ - int64_t offset; - - /** - * Timebase for the timestamp offset. - */ - AVRational offset_timebase; - #if FF_API_COMPUTE_PKT_FIELDS2 int missing_ts_warning; #endif diff --git a/libavformat/mux.c b/libavformat/mux.c index a1917878a5..0810b674a7 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -388,6 +388,8 @@ fail: static int init_pts(AVFormatContext *s) { + FFFormatContext *const si = ffformatcontext(s); + /* init PTS generation */ for (unsigned i = 0; i < s->nb_streams; i++) { AVStream *const st = s->streams[i]; @@ -418,13 +420,16 @@ static int init_pts(AVFormatContext *s) } } + si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_UNKNOWN; if (s->avoid_negative_ts < 0) { av_assert2(s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO); if (s->oformat->flags & (AVFMT_TS_NEGATIVE | AVFMT_NOTIMESTAMPS)) { s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_DISABLED; + si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_DISABLED; } else s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE; - } + } else if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_DISABLED) + si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_DISABLED; return 0; } @@ -638,6 +643,64 @@ static void guess_pkt_duration(AVFormatContext *s, AVStream *st, AVPacket *pkt) } } +static void handle_avoid_negative_ts(FFFormatContext *si, FFStream *sti, + AVPacket *pkt) +{ + AVFormatContext *const s = &si->pub; + int64_t offset; + + if (!AVOID_NEGATIVE_TS_ENABLED(si->avoid_negative_ts_status)) + return; + + if (si->avoid_negative_ts_status == AVOID_NEGATIVE_TS_UNKNOWN) { + int use_pts = si->avoid_negative_ts_use_pts; + int64_t ts = use_pts ? pkt->pts : pkt->dts; + + if (ts == AV_NOPTS_VALUE) + return; + if (ts < 0 || + ts > 0 && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) { + for (unsigned i = 0; i < s->nb_streams; i++) { + AVStream *const st2 = s->streams[i]; + FFStream *const sti2 = ffstream(st2); + sti2->mux_ts_offset = av_rescale_q_rnd(-ts, + sti->pub.time_base, + st2->time_base, + AV_ROUND_UP); + } + } + si->avoid_negative_ts_status = AVOID_NEGATIVE_TS_KNOWN; + } + + offset = sti->mux_ts_offset; + + if (pkt->dts != AV_NOPTS_VALUE) + pkt->dts += offset; + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts += offset; + + if (si->avoid_negative_ts_use_pts) { + if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < 0) { + av_log(s, AV_LOG_WARNING, "failed to avoid negative " + "pts %s in stream %d.\n" + "Try -avoid_negative_ts 1 as a possible workaround.\n", + av_ts2str(pkt->pts), + pkt->stream_index + ); + } + } else { + if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) { + av_log(s, AV_LOG_WARNING, + "Packets poorly interleaved, failed to avoid negative " + "timestamp %s in stream %d.\n" + "Try -max_interleave_delta 0 as a possible workaround.\n", + av_ts2str(pkt->dts), + pkt->stream_index + ); + } + } +} + /** * Shift timestamps and call muxer; the original pts/dts are not kept. * @@ -663,51 +726,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) if (pkt->pts != AV_NOPTS_VALUE) pkt->pts += offset; } - - if (s->avoid_negative_ts > 0) { - int64_t offset = sti->mux_ts_offset; - int64_t ts = si->avoid_negative_ts_use_pts ? pkt->pts : pkt->dts; - - if (si->offset == AV_NOPTS_VALUE && ts != AV_NOPTS_VALUE && - (ts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) { - si->offset = -ts; - si->offset_timebase = st->time_base; - } - - if (si->offset != AV_NOPTS_VALUE && !offset) { - offset = sti->mux_ts_offset = - av_rescale_q_rnd(si->offset, - si->offset_timebase, - st->time_base, - AV_ROUND_UP); - } - - if (pkt->dts != AV_NOPTS_VALUE) - pkt->dts += offset; - if (pkt->pts != AV_NOPTS_VALUE) - pkt->pts += offset; - - if (si->avoid_negative_ts_use_pts) { - if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < 0) { - av_log(s, AV_LOG_WARNING, "failed to avoid negative " - "pts %s in stream %d.\n" - "Try -avoid_negative_ts 1 as a possible workaround.\n", - av_ts2str(pkt->pts), - pkt->stream_index - ); - } - } else { - if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) { - av_log(s, AV_LOG_WARNING, - "Packets poorly interleaved, failed to avoid negative " - "timestamp %s in stream %d.\n" - "Try -max_interleave_delta 0 as a possible workaround.\n", - av_ts2str(pkt->dts), - pkt->stream_index - ); - } - } - } + handle_avoid_negative_ts(si, sti, pkt); if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) { AVFrame **frame = (AVFrame **)pkt->data; diff --git a/libavformat/options.c b/libavformat/options.c index 1634388acb..2d55d3ad6e 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -174,7 +174,6 @@ AVFormatContext *avformat_alloc_context(void) return NULL; } - si->offset = AV_NOPTS_VALUE; si->shortest_end = AV_NOPTS_VALUE; return s; diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index b65a76411b..da1fdbd5ea 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -94,8 +94,8 @@ fate-matroska-dovi-write-config7: CMD = transcode mov $(TARGET_SAMPLES)/mov/dovi # the first packet (with the overall lowest dts) is a video packet, # whereas an audio packet to be muxed later has the overall lowest pts # which happens to be negative and therefore needs to be shifted. -# This is currently buggy (the timestamps of the video frames muxed -# before the first audio frame are not shifted). +# This is currently buggy (the timestamps are not shifted properly: +# the first audio packet has negative pts). # (-ss 1.09 ensures that a video frame has the lowest dts of all packets; # yet there is an audio packet with the overall lowest pts. output_ts_offset # makes the pts of the audio packet, but not the leading video packet negative diff --git a/tests/ref/fate/matroska-avoid-negative-ts b/tests/ref/fate/matroska-avoid-negative-ts index a687c8f63c..1b9b2f2786 100644 --- a/tests/ref/fate/matroska-avoid-negative-ts +++ b/tests/ref/fate/matroska-avoid-negative-ts @@ -1,4 +1,4 @@ -3349536550047c5c553215003ba2acb7 *tests/data/fate/matroska-avoid-negative-ts.matroska +90cf5a330659140d47ec11208f525908 *tests/data/fate/matroska-avoid-negative-ts.matroska 973070 tests/data/fate/matroska-avoid-negative-ts.matroska #extradata 0: 22, 0x2885037c #tb 0: 1/1000 @@ -12,11 +12,11 @@ #sample_rate 1: 44100 #channel_layout 1: 4 #channel_layout_name 1: mono -0, -37, 24, 40, 9156, 0xe5bd034a, S=1, 40 +0, -37, 43, 40, 9156, 0xe5bd034a, S=1, 40 1, 0, 0, 26, 417, 0x7198c15e 0, 3, 3, 40, 1740, 0x29ac4480, F=0x0 -0, 24, 123, 40, 3672, 0x98652013, F=0x0 1, 26, 26, 26, 417, 0x3c67c32d +0, 43, 123, 40, 3672, 0x98652013, F=0x0 1, 52, 52, 26, 417, 0x8c24b1ca 1, 78, 78, 26, 417, 0x6ee576b7 0, 83, 83, 40, 2532, 0xa2c42769, F=0x0 From patchwork Wed Jan 19 21:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33669 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5187647iog; Wed, 19 Jan 2022 13:30:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJynbVVVynkyAWfgr/pLGXvG8SyrHfxybJtx/ov0yKmzyAvAFJnqYL0qZ5GKwa58AZvc3Ncd X-Received: by 2002:a17:907:7212:: with SMTP id dr18mr26847583ejc.646.1642627828954; Wed, 19 Jan 2022 13:30:28 -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 he43si634423ejc.723.2022.01.19.13.30.28; Wed, 19 Jan 2022 13:30:28 -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=sDJ0+7QZ; 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 F1D6E68B191; Wed, 19 Jan 2022 23:30:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075047.outbound.protection.outlook.com [40.92.75.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7149D68B192 for ; Wed, 19 Jan 2022 23:30:00 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LDQpMIVMOynhCzMWyjj+De0mo+kTG9g2UtmsfMqKKEg+sWT+VI1vClZu26/kHEtbi3rJaIJSP/4OWez8zlZ2GMhrVKwhE4g0UJiGoNv0yw0kfjpESJiY8qVsfcXRiFwvw6u3gbPY2bWIhWSrcb49dxXlSWCqvTq/BqMqNtig2Z21ky6fj2w/j0U8OpRbpREqyywuXXEtJL7IPkT/WFaZPoMytDU70EYZtdNxylrcwsU2qclWBs1g2uw63IrEEY8tGo+A7k/UlgWKgBBm1Emsez9M/lx9F5frgNH01yCUWTvXMpvP89ItQYKkJmkcp496w1DA5OeR0d7zLobIoRs5Kw== 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=0Xw0jHmpENJjN4f6a0BLjZdKs2jKmiXrj+7JAR3Y1ZE=; b=GfkZFvpx4NLr7b+Oo+0HitwpCUaOe1GNdIuMGVsmN1J54M0O++kOgusXLtmOTgn6lwpg3bGv3f6Z/t0FnRQYvmLwS3tPgx9uEwFZTtj2YHLFQHAkHzyWosj3doW6giR9ZRlnv7m70pYfTVZQR3cnTKMTzMOtjULgY+cRmK9u0tji/Bt3ns58a0hIB2gV7EnD2NM3gzZEoPrbBO01f22WSHOcH4tlaHaosPk5C/3f/YPdcZYm80EeThGN4nfIgGYfPp3JcKSfodrMf9xbDnCeLY7CW2WzZW7QjeOAuXwYXyqCEEieHRDXpe/8edqUl0r5kQws55S6bior6ReBIP3QYQ== 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=0Xw0jHmpENJjN4f6a0BLjZdKs2jKmiXrj+7JAR3Y1ZE=; b=sDJ0+7QZJUFGqtCyzs97BWh00uPUWzBt0NhS9Y4xRGLXntl8+ONADomVmsdi59lj8anKVSXz50gPbQEFAdnXmPkyupHSXNk6nsKwr8fyiIs9pV+Ix8Z0izDhCz2z1ccHPenj4jTt946qp0fReA0l/8tn5rbyPpICZC/tznoEG/sUu2a/+jYKA0LWIpH60Cq6vCiHzySqo03/ckddj7XFVy8Rs8Jz/IPzwakh8VsjaNQdrkMYURCXhpGfIP6gmeUfwLRnyC2gLRIyLW8z+XtRL6qOwaHaXnFx8BEjt9WQ2sl6mc9+C572hUvk5FknPbTFOZRcQvF8lxbHgXDdyGx9GQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DBBPR03MB6796.eurprd03.prod.outlook.com (2603:10a6:10:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 21:29:58 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 21:29:56 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jan 2022 22:29:39 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> References: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> X-TMN: [12q8DxsQRL7rlOkzQ8euk28vOcMbuIOd] X-ClientProxiedBy: AM8P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220119212940.1071477-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28ec0f0e-cea3-4965-c48e-08d9db92d6df X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWEWN7T2ifwOOBerboM6zGymGJr9DniNZjWeC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p9AiZwGqFlnBeFQ8/9AC1d6cENC8F0ng4rl9p1s8+9dAKe9Sry09dugDVFR4kLIQryuIubKjAIWvBsf2qhK14ivA6BT6RfOiE2MnkPM1uoobB4kg7qmx0wNBmq5mcqAo1agMlk0LxkB2x8pamn3EvK3BCP7nts8HMZZQnc7+nfibg3zFOWKXV7BNLVPtUnzKWKar3paCZD2ug3sSqu8m7wRaWYEzLQDcWLyica+07Uwn7U3SWqW6FfyaRCO9Xgk/U7xsmQj6Q5UgjxjYZpHAPkoh1Rng== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28ec0f0e-cea3-4965-c48e-08d9db92d6df X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:29:56.8676 (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: DBBPR03MB6796 Subject: [FFmpeg-devel] [PATCH v2 5/6] avformat/mux: Peek into the muxing queue for avoid_negative_ts 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: LIuxZhKY+c14 Peeking into the muxing queue can improve the estimate of the lowest timestamp needed for avoid_negative_ts in case the lowest timestamp is in a packet other than the first packet to be muxed. This fixes tickets #4536 and #5784 as well as the output from the matroska-avoid-negative-ts FATE-test. Signed-off-by: Andreas Rheinhardt --- libavformat/avformat.h | 2 +- libavformat/mux.c | 21 +++++++++++++++++++-- tests/fate/matroska.mak | 2 -- tests/ref/fate/matroska-avoid-negative-ts | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index cd253fb28e..b4b8075ae6 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1527,7 +1527,7 @@ typedef struct AVFormatContext { /** * Avoid negative timestamps during muxing. * Any value of the AVFMT_AVOID_NEG_TS_* constants. - * Note, this only works when using av_interleaved_write_frame. (interleave_packet_per_dts is in use) + * Note, this works better when using av_interleaved_write_frame(). * - muxing: Set by user * - demuxing: unused */ diff --git a/libavformat/mux.c b/libavformat/mux.c index 0810b674a7..53eb56f0af 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -655,16 +655,33 @@ static void handle_avoid_negative_ts(FFFormatContext *si, FFStream *sti, if (si->avoid_negative_ts_status == AVOID_NEGATIVE_TS_UNKNOWN) { int use_pts = si->avoid_negative_ts_use_pts; int64_t ts = use_pts ? pkt->pts : pkt->dts; + AVRational tb = sti->pub.time_base; if (ts == AV_NOPTS_VALUE) return; + + /* Peek into the muxing queue to improve our estimate + * of the lowest timestamp if av_interleaved_write_frame() is used. */ + for (const PacketListEntry *pktl = si->packet_buffer.head; + pktl; pktl = pktl->next) { + AVRational cmp_tb = s->streams[pktl->pkt.stream_index]->time_base; + int64_t cmp_ts = use_pts ? pktl->pkt.pts : pktl->pkt.dts; + if (cmp_ts == AV_NOPTS_VALUE) + continue; + if (s->output_ts_offset) + cmp_ts += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, cmp_tb); + if (av_compare_ts(cmp_ts, cmp_tb, ts, tb) < 0) { + ts = cmp_ts; + tb = cmp_tb; + } + } + if (ts < 0 || ts > 0 && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) { for (unsigned i = 0; i < s->nb_streams; i++) { AVStream *const st2 = s->streams[i]; FFStream *const sti2 = ffstream(st2); - sti2->mux_ts_offset = av_rescale_q_rnd(-ts, - sti->pub.time_base, + sti2->mux_ts_offset = av_rescale_q_rnd(-ts, tb, st2->time_base, AV_ROUND_UP); } diff --git a/tests/fate/matroska.mak b/tests/fate/matroska.mak index da1fdbd5ea..784b55f6e0 100644 --- a/tests/fate/matroska.mak +++ b/tests/fate/matroska.mak @@ -94,8 +94,6 @@ fate-matroska-dovi-write-config7: CMD = transcode mov $(TARGET_SAMPLES)/mov/dovi # the first packet (with the overall lowest dts) is a video packet, # whereas an audio packet to be muxed later has the overall lowest pts # which happens to be negative and therefore needs to be shifted. -# This is currently buggy (the timestamps are not shifted properly: -# the first audio packet has negative pts). # (-ss 1.09 ensures that a video frame has the lowest dts of all packets; # yet there is an audio packet with the overall lowest pts. output_ts_offset # makes the pts of the audio packet, but not the leading video packet negative diff --git a/tests/ref/fate/matroska-avoid-negative-ts b/tests/ref/fate/matroska-avoid-negative-ts index 1b9b2f2786..02790a3985 100644 --- a/tests/ref/fate/matroska-avoid-negative-ts +++ b/tests/ref/fate/matroska-avoid-negative-ts @@ -1,4 +1,4 @@ -90cf5a330659140d47ec11208f525908 *tests/data/fate/matroska-avoid-negative-ts.matroska +804842437b2be0a1604ce33c6b08c800 *tests/data/fate/matroska-avoid-negative-ts.matroska 973070 tests/data/fate/matroska-avoid-negative-ts.matroska #extradata 0: 22, 0x2885037c #tb 0: 1/1000 From patchwork Wed Jan 19 21:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 33670 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5187774iog; Wed, 19 Jan 2022 13:30:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrFSZKuxKGcmY7HNzel2NXgxPtDPFu8TY3rD+mi+ZLKWErlaQfokeYyi9jAYqf7RTJM9y1 X-Received: by 2002:a05:6402:6d4:: with SMTP id n20mr6266228edy.69.1642627839513; Wed, 19 Jan 2022 13:30:39 -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 y5si576868edc.609.2022.01.19.13.30.39; Wed, 19 Jan 2022 13:30:39 -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=XSWGFq9N; 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 B04E868B17A; Wed, 19 Jan 2022 23:30:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075047.outbound.protection.outlook.com [40.92.75.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9679D68B194 for ; Wed, 19 Jan 2022 23:30:00 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AUw04hBUMXX3hEAv15A3Ejs6rAJ+fY/eWsXVqZ/CDxh4RNVDwiiQ1+1IyNs4yoKv0MupJ5ftseN5E1mlpdzhUhPArSCp81P8o85uIGjK2LGVcu1AqPOT6kgFKtq7yrEgTsoG0rnbbYk6us5H8Z6dSCbK8t8jbGBQ601PfTzici0o1bUwwyi3jvu6LHqW+Zsxfkallmfm0hPw4RHWmziM3o2xPH/jg3lB/Tl/pMZ7dlUZbDPQA69Wou80ZpIr0oBw55vAidNi2y/H+so+OCRTPrFSkCIb3yC7KS9z4OE8Xb5GremAF4UbaYvUbiVJbIBJ/yTTGPNZZeJJoQkn8nR5DA== 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=rSk5NMXxjhfQZfv1As+uXde0COrt5s4t6PiWjiKdTOA=; b=Td2hQBk/naXSJPJbfesLRbIIzGZgpPC8YUhxKgr9ShLKyi4gvDzH1YvuWIXsZSFur25yY+HDPC750o8JYXGSuq4mziayp9SM76ZNhfcy29TkE64M/sABsnX6RGsDY3bMuHDm3uagMSzusoT20t5kvzW1oS5s2/VpD054BwPrrLx5jaGlhNqRFgikRGt8Bmm2jIwLcofM9zOcJiBDouDQUkQJCfnwoRiMwBoDmgzIFowfk9THGEn5Kbe/1DDIVLxjwbWwrfUT5dqNXwOP9ZclNNnfpYXYn+54jg2wx5ub7I7zFhfasGYw8kLZI1LI5pRb/ep70ia93ydHph4mnB6OPg== 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=rSk5NMXxjhfQZfv1As+uXde0COrt5s4t6PiWjiKdTOA=; b=XSWGFq9Neho+298ZTPcbhkDJPAM4AvcSnpWlrKfytb++LHcoWsKwrBQBxyoT3DoI2fSF/VVzToCMofz2LC181asc8gRASkADWWK7eki4A38yQCT6DxHUxrvRVlOcXOio7d/MpZxPMYMm+3TVhGP2ZEzC8cNw4h6uVYGzQIWprvZrV8eOQo7TCP1CKjlz9aagQTdp+KtgTwjC2TcCh8Gl5IAvqaND+7oTFxW/Sru4lNQPi14xOikUVka7uiQqbnibT8hb4dx3eV5adQC720ZRcs/0iLaYWwbTZ6mIwG1R5UZTDZCsj551qHO81AaQAsgL9Izm8CAFNP8U2wrQ/LXcpA== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DBBPR03MB6796.eurprd03.prod.outlook.com (2603:10a6:10:207::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Wed, 19 Jan 2022 21:29:58 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::19fc:be9f:2c9c:53f5%9]) with mapi id 15.20.4909.008; Wed, 19 Jan 2022 21:29:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Jan 2022 22:29:40 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> References: <20220119212940.1071477-1-andreas.rheinhardt@outlook.com> X-TMN: [w78o+soYDich9C3Z3xEikcOW15TrUfYf] X-ClientProxiedBy: AM8P191CA0030.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:21a::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220119212940.1071477-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bc77ea7c-ba03-4819-5d5d-08d9db92d792 X-MS-Exchange-SLBlob-MailProps: dEG5jEBie8ly5QJPaej/k4qcRLlrUm4DlA29d9eqfiuMHp4CO5eLprm/iUXOKAUMbV1WIBmXKFipQvf87q1yzbbVVV9ayMXOJ02vwBwQ5E9Ij4EUpcZ+dSxMVjP2hS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hl1H9gDkDaHKnCgs7s/hfuO+6Jv6mGMvLkoSB6zRFl45dgMR19Ql3yoCbPkis+dx4U0ULaexXvAnEs9BcurAooF1iFJTOkmM673Ri9VLnZuMqnwdMY/tzKNV75M3PrxXqiS7/8a9cg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bc77ea7c-ba03-4819-5d5d-08d9db92d792 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 21:29:57.9924 (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: DBBPR03MB6796 Subject: [FFmpeg-devel] [PATCH v2 6/6] avformat/hls: Remove redundant cast 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: Je8cTWnEtIBV Signed-off-by: Andreas Rheinhardt --- libavformat/hls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 8c526f748f..4568e72cb2 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2024,7 +2024,7 @@ static int hls_read_header(AVFormatContext *s) if (seg && seg->key_type == KEY_SAMPLE_AES && pls->is_id3_timestamped && pls->audio_setup_info.codec_id != AV_CODEC_ID_NONE) { void *iter = NULL; - while ((in_fmt = (const AVInputFormat *)av_demuxer_iterate(&iter))) + while ((in_fmt = av_demuxer_iterate(&iter))) if (in_fmt->raw_codec_id == pls->audio_setup_info.codec_id) break; } else {