From patchwork Sat Oct 9 15:13:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31014 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1977618ioa; Sat, 9 Oct 2021 08:13:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzldYwP4gz2GvF7O034MMpXon3N9HZtqLsjRWvjG0xM+11Us1h2TDmtvT1tam2XhToB2OqM X-Received: by 2002:a05:6402:424a:: with SMTP id g10mr2399361edb.158.1633792421277; Sat, 09 Oct 2021 08:13:41 -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 g1si3241349edk.532.2021.10.09.08.13.39; Sat, 09 Oct 2021 08:13:41 -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=YVvN29Ab; 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 EB89D6881B1; Sat, 9 Oct 2021 18:13:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072035.outbound.protection.outlook.com [40.92.72.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4AA6B6881B1 for ; Sat, 9 Oct 2021 18:13:29 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dns8ODc1zDHVAnb5ShUULx1Az9W1rLdrWcqPFUCBeLO+jyrlTKvLHq8u2wHkvCm2RLLIwpXhJRI73On1l0JeYck73L71JEV2Jvmzd3YQPUqgBCMxhl8tNGiQ1QX7KR+m1BRBZIIdjxCr8wkwwFReKPoqgTQRNxi3/lqyqPKdj/2adA94TcCq0D9uT/ms36v26WSwfPjXGTxNnbTNDz8zeZXzy2hZi5/xAYwq0uJh/dUTl+Q0bnC+6O9GMc4cYN+NTYVRjL5IetvFqvwo+xBhrgzqXObBFzTvDdrVF2qeA/T/2+pvz1TjC++l+xLsJ88mvttbxusU++sLOUvPqutTvA== 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=202n+ZdtNNkFQsAuGz3lIC+oBvve7+/u1eOile0I3IY=; b=APj7YZt2x9gLM60ljO79IOv3CTnSAp9ZTaZ96Du6LuCZmatvUf3SASjo1EK9IgNldrRqxMVQyIltDX4re6I4pwHMqn9Bm6kYwG98ccF3UIXL74zwI7RUjH+fmrYMu7XaDY3mBmNLSGSggFQa4Rh8YpaGnjou36XuSOEWbxQK3uY5W5YsokvqeOdz20Nxd74U/EZRTTmNtws76GjgvNlu+zZ5baPnWB0RlTXOJVQCzXW60qkvo9NHmHLq3D9+/4uLFHJ8aP4TCvrtP6nYV+VstyC4ELDUIDErbvTLxklbte4+rcpO92kdF4ZH96L2b6hpU7G1jhB7P2AvLsO7imo1BQ== 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=202n+ZdtNNkFQsAuGz3lIC+oBvve7+/u1eOile0I3IY=; b=YVvN29AbB4SxmTcCL+Ok+pZlJ42lh7PV+Ph0mgI5X96w8fdnTSx/LSgzCoDp2cxdob0KFz66o2TmiDMM6de81tJsLnw4QgIoVZ1R++q+//Bdyqv2Ib5EnQ750YctbAhJ3UXFEDguzDlv+6Sbv8ql+AiuDpvVZDlP1aAGfcswrCwyht2VXB5dHcu2xrwlsuALnSayikhw8rk7Yc3AVUX6Ah8PinLGQFE6IEEn7TsXpqCQ2odS31vZSrytY6xLFTeYoSLK3gBA7GsBZJQItML+6Abc13aIooOdP7qhFHd/hLdECoyslTSQPdcCIcjAjiX070+TsioAhfPNTMlYvOYvBg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4885.eurprd03.prod.outlook.com (2603:10a6:20b:87::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Sat, 9 Oct 2021 15:13:22 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%7]) with mapi id 15.20.4566.026; Sat, 9 Oct 2021 15:13:22 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Oct 2021 17:13:12 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [UMbOt6OiOXNzoiSAg3O+wISr3jKRd4Dj] X-ClientProxiedBy: AM0PR02CA0033.eurprd02.prod.outlook.com (2603:10a6:208:3e::46) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211009151314.1723302-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.170.49) by AM0PR02CA0033.eurprd02.prod.outlook.com (2603:10a6:208:3e::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Sat, 9 Oct 2021 15:13:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 097f099f-de75-4939-02fd-08d98b375542 X-MS-Exchange-SLBlob-MailProps: EpEO96k6Wom1YuMMyazFFMoNlUqEzrs+zDW9/ScSKdmuNQucbR6NtcvKikoyXKMk4xAzOummR/drL6Gh/YV0g868aURrb/YXZByns6Mp1S6EaTRpvfFR1DgM+AXzs8cXWzr6UyBOHH3oeSSnbRYBxPpdxiB8uy3glGmHNUEM+H7GjksMAXybyWDV2UCOSiN2bhkgQ1sCaCuzv0Sy3qr9Azb5qTZNoD4Hdh19o5MOXI1Ql7Yi5odVPi+xi+1cHpgSo7MhPfl6HK/0G/p8EyLpY9AZJbR+fC8LYKspCmgSG9tCrhszyi1KTiDYTMVTyYoFvSiCU55XQgJKnoRCXLVtHOrkdZt1B2q58zg0N3j6Iv7pLS+y6o5VvHRgpcQ7/YwVcZM5XjHd6yW2ACKpgGuUqArc9A1C6SV3tuJGnbMm6BFg677qvmSn9nmufCMMG5BocxweE0FzYbyxOn1qHEpIaSidnxjaKBXAlEWjbXLspJGaWuLwq+IgCeWgsrOGl1jq/IquWJPSKt1UGFKsWIQMgNhpfRIG3Lvr02CYSo3EYflfCEMwYSmO8lGVEeaXoOs36eOJwgouArsicjzoBWXFSdwejY6T96U/RTbMtd2Huooqp7l6ybqoZmIhdV6Pc49Vr0xwc414EW/e0F+OyJV9M4TSZze6ckrGVR3kx4d9k1POY/Y3p9/AVd1KBRYDK6jW1HrpBrWhJbBW4VBV+EgYa/6Z7PwsA5E8K48QhPYSI97I8iI7njENQ6ZXrybJpURmPKwdfrYuFbY= X-MS-TrafficTypeDiagnostic: AM6PR03MB4885: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pc1ZBBBT48OGSQyMYunYl4Lh2DRaCz4Ksrg/Q+MTuEnLZV3zQnLGP0XC0v/9M7M2c8RWpfobi/hef9YDmhp4iWcW3/GIGnzFebY97x3jzUGO1lVhbiW5R2gtb9XONBEM1w09mPu6U0gmC8Pyi90eQNkQbbpo2ht5Anir1VtYHMtc2WSF1o2L/RyhfkEa1vf6+tVTT5n2RQWmYKlmJBCruIReW0/vZJWHtsrieZIkrh2v+UzuOuj8wTe+gk2YgB60NBpwV+6tQ85MdAMZ7AmSPmVmx1yRbH9QMvcrPz7xS/ylkidq7OL6dIXUB3K1hVQPLaz/LIMB/K28cC1sWe7BtWn06Au2X9uIH6rBirPYeWkTlUFlTWFNDfOPYsIbuLkzyL+L1feIHdUCH/j88/PoabU2hrNpnfi88qAwKazEC36ZhP/jGdMfWOgSNzuGaVcx X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P/7OgJVZ6b50UDG3g/RtY9C/ybBFIR0agznWm9/0Kw1VXXiLzvYhDcQJZcQGUbLadwaHGDj7dglOZ59olBjH+1iMVbpjaufvL959HoPiAsMdCCSfxOx6SoYsl62WQAFpU0pi0htYKbd3HM4gaM6N8A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 097f099f-de75-4939-02fd-08d98b375542 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2021 15:13:22.2603 (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: AM6PR03MB4885 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/mux: Store pointer to interleavement func in FFFormatContext 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: o6gFSejNhCtA It avoids branches lateron and will allow to easily avoid the overhead of the linked list currently in use in case there is only one stream. Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 6 ++++++ libavformat/mux.c | 17 +++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index f1ae7db365..223befdbc0 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -81,6 +81,12 @@ typedef struct FFFormatContext { */ int nb_interleaved_streams; + /** + * The interleavement function in use. Always set for muxers. + */ + int (*interleave_packet)(struct AVFormatContext *s, AVPacket *pkt, + int flush, int has_packet); + /** * This buffer is only needed when packets were already buffered but * not decoded, for example to get the codec parameters in MPEG diff --git a/libavformat/mux.c b/libavformat/mux.c index a6e1a08be0..f4f1bc289e 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -334,6 +334,7 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT) si->nb_interleaved_streams++; } + si->interleave_packet = of->interleave_packet ? of->interleave_packet : ff_interleave_packet_per_dts; if (!s->priv_data && of->priv_data_size > 0) { s->priv_data = av_mallocz(of->priv_data_size); @@ -1054,19 +1055,6 @@ const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream) return NULL; } -/** - * A wrapper around AVOutputFormat.interleave_packet. - * See its documentation for details. - */ -static int interleave_packet(AVFormatContext *s, AVPacket *pkt, - int flush, int has_packet) -{ - if (s->oformat->interleave_packet) { - return s->oformat->interleave_packet(s, pkt, flush, has_packet); - } else - return ff_interleave_packet_per_dts(s, pkt, flush, has_packet); -} - static int check_bitstream(AVFormatContext *s, FFStream *sti, AVPacket *pkt) { int ret; @@ -1089,8 +1077,9 @@ static int check_bitstream(AVFormatContext *s, FFStream *sti, AVPacket *pkt) static int interleaved_write_packet(AVFormatContext *s, AVPacket *pkt, int flush, int has_packet) { + FFFormatContext *const si = ffformatcontext(s); for (;; ) { - int ret = interleave_packet(s, pkt, flush, has_packet); + int ret = si->interleave_packet(s, pkt, flush, has_packet); if (ret <= 0) return ret; From patchwork Sat Oct 9 15:14:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31015 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1978403ioa; Sat, 9 Oct 2021 08:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzsBkNckl5mtXuZTshZkPMSG3dONvKehJHLRH3mq/O+PFcfrxOFKPx9/AhO+RXQt0aa6Bc X-Received: by 2002:a50:becb:: with SMTP id e11mr24614740edk.161.1633792466844; Sat, 09 Oct 2021 08:14:26 -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 oz44si4182692ejc.470.2021.10.09.08.14.26; Sat, 09 Oct 2021 08:14:26 -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=CBT46VwJ; 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 40761680137; Sat, 9 Oct 2021 18:14:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072019.outbound.protection.outlook.com [40.92.72.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F39B2680137 for ; Sat, 9 Oct 2021 18:14:17 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VHyG/lejyS9xRJiBFJB4Znl4Z8w7yj1EJcjxSqKlsRKfCR3kFc1smSw2WRX+qy598qMWFSUqHDBQrgu9BFqekfYkuZxhXMMK+6IBxGoQhgPXQOBausVMt2TuRlLLO97kaDNtNY/gjnAolHdQTkh2Wm6qaVf+Il1PZzFVosnv6ZUOZU7UxD+FpJm4JX2Xz01c4wS+dPCJ4vhH/WP4vgFOCHNNa/tHQ36b2US1UTJLpvw9s4R94GuY7yumphZaCAjKVEDelCVr+8n3C4upKiCNzGhh3UyZVatmPYQ7PoCBj0VBmMHVn/aOFXnoJcZcE6gMVe5UAgT2qD67Wuv7EiQ7uw== 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=z0vjoCzULCeXWngt7ktOcdj9M0yDyWkzLV82yV3G2c4=; b=QycLNoqJXllkdYgoky19X9F1RvlgZT1G9yMm28Xe25W5vEApME7sGJAPt1ILl0xbwUPhBQVcdd4od3NGwPL92SXBFbBRqZEGRUOXTTFFBvnbBhTOS5Rkypc0q68wPZTBdNTqwHbkq2Gqs4oM/KCwRT8gDNp6LmRyqrYEvwMPzQcMRjr/VRa0r/Q2da6Ai48672z5ToG8z4dGNYfb0k8fCCddktQ/kjwKgc0ip2KRc0PFrZcUJxJD9WJQONVALMKPJpeF4v3BeRBfB4lB3q+xKHcnrCQZLDQ27QvZQL4KO2e7G8V63Uukzcb8kZ/oa7pF2cWeHygtVWaoo95tCA9nAg== 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=z0vjoCzULCeXWngt7ktOcdj9M0yDyWkzLV82yV3G2c4=; b=CBT46VwJG572a14vmYgkiioxGiOaEECoMBd//RAacr2hr3CCNlLBB2c2fKRGHfUN0ECt5/2e4BYfo6lID7KPdmhTxb52qRHRhXrGSKak6CxVNiH2INYoGta/PqzfYhNnjrQpL1m++69vhm0lBwAlEHRBHkGIC7NVdRUy5be5aaCaNjRyU0QgjQszOVi82OSPMfbxdLGYqxezsCRzXYrllaHCwHH4SjswwNnlFJbubQy9KYTZTc30ymGeVF7Cx4qtBYpLkVMCvpczDTMO/Jfz2i5u6sqqronOPo5Arql92GWaOaL5ImZZHHS4qLXoD4SS0oxtdhy/ZZW9yyxoEBjAVQ== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4885.eurprd03.prod.outlook.com (2603:10a6:20b:87::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Sat, 9 Oct 2021 15:14:17 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%7]) with mapi id 15.20.4566.026; Sat, 9 Oct 2021 15:14:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Oct 2021 17:14:09 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [evTQmtOidKD/99O9AhqDcpFjWJMKy+FF] X-ClientProxiedBy: AM4PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:200:89::13) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211009151410.1723366-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.170.49) by AM4PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:200:89::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.21 via Frontend Transport; Sat, 9 Oct 2021 15:14:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b292097e-8b7f-4476-988d-08d98b3775f5 X-MS-Exchange-SLBlob-MailProps: EpEO96k6Wom1YuMMyazFFMoNlUqEzrs+Hdr2JjrlAwKvMX5Ku6O+ds0CEyMkNKcgVKRhmLeHxK9mvNxm9q/EMosVEEn2NjoycoJaFYwVxhAuIRzjJNP4uJWi3DT5VVTrxAJ3q0Y5gMF7nEMtCj5LkV7kiXyD4pMp9OcWf8boGdUcAvjT/bwlFq3NsdBQlMPZ55MiIliOBRt/urkux9l7iKzUOA6Eva+5ooUxLzZ4zVUI+3GMdB2FR5u2Rh+HHprdnGcWRt7UBuEbyJqqwBkQ1It4xbvr3p8fdytVUzdrNWrHr8ohOSCCHiuWevPE2AZHJM4v4rAueZ0u+gaD63hN+Ntcypyq5mnTHiE2UY9wZtvmaauRqDSzQutmESUFBzMa90vKEcKDb1AhhsAPrpsPQ4wBn8idcJLzCbgYkN1dapEBtodOM69Hfht5c6ruWAUi+Sd7fNHxKXPJsQRHkXfmC2yJjLUIN702OOaIhznedx02eAeMNBR3EKs5F3zujwnbgjA3h6dyXrDC+XGoPw2gpyH5Hzn73NFlW5Y4RVl8RADqT50u9SV/JMPSU/IxQ8p1lrwWBMd3sJi7qa9+NdfpI5TJ+VoPCWmzjQTb+70JjHl5oYLxFr4ySSz4GpQbeTjU4nFxCqa4MCA+CoDCd+8vP40gmgCagevLmaAObxt980VD1hCLeeFtqImS9rqSQ61wPZRCnDhB4HV9ieYPqIjNjyGOyLiAaAYIFsKULSLDNDctEQHmoxC0b3ZvLId1I/T3Bz3WoOYNSGY= X-MS-TrafficTypeDiagnostic: AM6PR03MB4885: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JVwIdb8y7mWl6bCEW7SKTvQhhKnubzZd9CEn+aQWT7/ifxwAQJX67YPb1RVTxfv/JxAFfEqyyUMx/tUN38rFDM2AG6rxKO2Hyazq4PrMeDYAAMbfdSJgovJB/4wJ6Qm2YnuUrugdBz8RfpNdqv+zTMCiL8BRay0Z/nAlXSiOXVehb0G6t21/caOEqC1lN2/7jkdKEs3QaGS39LN3iTL9kouvY03OnPN+vhk2Uvg2yLpZUjoy5GtfVvhA1361atL8Wrr3E6iCH5ds9KGEbhvG81L7KiCtDmNBRgoZLJkDhp6Wi+k0JVVAdmMQqePyga29CYQa78KzQEbSjNzP8tWeEbuxg08yDeUo0zP8gLlne3sqxVxeHYvoA89wheOXEemEQWPZ7a9l0M3khzYPqv2cXhoorzZ0uhtS46EvTy5zolSRTLI4tWJM33YGhq3iGffk X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HVhezzXtxEM8f2F1JnZ7gPk2lU/QYAy1+nnUpde9TkXopxsEE54LfPaHAcI30K/0VssOt3neiNVqfckbpOjZuoRcyJHXyK8El9ggTcD6rMJpwjyBWvyy4Ne54jSp8eQVQbW8/cIUhN73yeSKRUxibA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b292097e-8b7f-4476-988d-08d98b3775f5 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2021 15:14:17.0308 (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: AM6PR03MB4885 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/mux: Avoid overhead of packet list in case of single streams 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: i1tXeeJCE6qd Signed-off-by: Andreas Rheinhardt --- libavformat/internal.h | 7 +++++++ libavformat/mux.c | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index 223befdbc0..867b5de514 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -760,6 +760,13 @@ int ff_add_attached_pic(AVFormatContext *s, AVStream *st, AVIOContext *pb, int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, int flush, int has_packet); +/** + * Interleave packets directly in the order in which they arrive + * without any sort of buffering. + */ +int ff_interleave_packet_passthrough(AVFormatContext *s, AVPacket *pkt, + int flush, int has_packet); + void ff_free_stream(AVFormatContext *s, AVStream *st); unsigned int ff_codec_get_tag(const AVCodecTag *tags, enum AVCodecID id); diff --git a/libavformat/mux.c b/libavformat/mux.c index f4f1bc289e..a6129720dd 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -334,7 +334,10 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) if (par->codec_type != AVMEDIA_TYPE_ATTACHMENT) si->nb_interleaved_streams++; } - si->interleave_packet = of->interleave_packet ? of->interleave_packet : ff_interleave_packet_per_dts; + si->interleave_packet = of->interleave_packet ? of->interleave_packet : + si->nb_interleaved_streams > 1 ? + ff_interleave_packet_per_dts : + ff_interleave_packet_passthrough; if (!s->priv_data && of->priv_data_size > 0) { s->priv_data = av_mallocz(of->priv_data_size); @@ -1026,6 +1029,12 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, } } +int ff_interleave_packet_passthrough(AVFormatContext *s, AVPacket *pkt, + int flush, int has_packet) +{ + return has_packet; +} + int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset) { AVStream *st; From patchwork Sat Oct 9 15:14:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 31016 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp1978576ioa; Sat, 9 Oct 2021 08:14:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl2Fn97B/r2mepJuR/xpX6QQuCNwMyKQxRlVGwvIkEE4JOMyJdj/SOzknbRPfCvnTdoPXw X-Received: by 2002:a50:e142:: with SMTP id i2mr24027236edl.107.1633792476527; Sat, 09 Oct 2021 08:14:36 -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 ot24si3308088ejb.562.2021.10.09.08.14.36; Sat, 09 Oct 2021 08:14:36 -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="m6S/aiFx"; 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 5172668A789; Sat, 9 Oct 2021 18:14:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072019.outbound.protection.outlook.com [40.92.72.19]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1734D68A56C for ; Sat, 9 Oct 2021 18:14:23 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cbFbf3lHl0oPU32/ChbsH/A//0yQnWQa6oaXPizqNLz/9+vn7QYm7Z939iVbiVPwq5+0HPIcXelsUp7DijzsT0rzyuS6yFDxIEdaqs94KE4BlBQ8kYUe0Ch9n3XkaenTPxmlUsYUw4k3ofQJvtDqaj8TtDDL2k1VDEf2dgwuXkCV36q/Whga1jspZcm9yb8fi9GYw1dJdaneVyKDf1Gj7+1hvABDdSaVGBzWXUGiymVDGujtOac8HNbfADNCqm9SxBw93lwb9qSUN4oXEtZL1uCr8Hu9VlsKco/QgYnQwnWOuLpONYgRcPPmhZpaGZafRx3dNB18spxKnKx0K6brxg== 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=enfdbPg4OTg8eqcuYBHaLXxwgF6YBfbtyv9+8wMyFF4=; b=DwWqP4gasr578s6va5R+rLsrj6PrrRXbS/Le86sVzY7yjt4lyFRLT8LH4eJaTQHQRKdLBlzGgy6EKar88JsNhviwlsr+k3UBWY7XQGX8vSiQQ+fZ5X6hnkxYADXCbFfeScF9n/hTMDzV3/vhpvXWtaVB4pcS/aNuQZ2AWcxgHqoIGKLzNF18Bwl9el4o4F5FeE8tpplTb9O3cOylZoKnpD1syfs21mV+lk9SyC9Yu7DX4GqvskBIqN35Wlz1UGnxKOggzvHCPDed/7CTrjcu11gamEstTzDkZamz5h6LYny4UPikCkEadBHiDZadBXBnAC5RoX/W6JqbDymeU8ByKA== 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=enfdbPg4OTg8eqcuYBHaLXxwgF6YBfbtyv9+8wMyFF4=; b=m6S/aiFxZFSrbGU4aBU9raWbq5lu9Vfeit4nm5nmlpGUn9VtAjK7CO0WGDT/9Pzr/YN6+YHg/9rb0kpjrLZghvpVWSSDPgIHESL7y/hpQJN0Z3yD/xz0u2qI2dQJPdUVsR3xUoGBl5PX7jh7UvbkIfeg0YbidSdU2mx+pofHeRfyAJe3RprEV2h0efkwfioSih19Eu4gFmo7Sv7Co9xb7bg5lSpAKEU4Sooj7Hbi5+zWFfQmXvxW77531nMYXygBkhYh8SayglNieaH3jF0t/H5KQ1e21qHD61kf7QukMz2KqfjMeqg64iCvs0q56RoEvETZdAzDLv2dWXnf19CjRg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4885.eurprd03.prod.outlook.com (2603:10a6:20b:87::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.22; Sat, 9 Oct 2021 15:14:18 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::700f:d70b:3bb8:4d51%7]) with mapi id 15.20.4566.026; Sat, 9 Oct 2021 15:14:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Oct 2021 17:14:10 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: X-TMN: [pOvAYqlJttrUCyoRPceN1rkJ+/4zDlBF] X-ClientProxiedBy: AM4PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:200:89::13) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211009151410.1723366-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.170.49) by AM4PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:200:89::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.21 via Frontend Transport; Sat, 9 Oct 2021 15:14:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d7a70431-886e-416e-0dd9-08d98b3776a0 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UI7lQ8fAmmKaIBr/2ZR7WfRkZdM0uHikrvNLQCLVqZxj1X+cmIFMK0HfLd3+fsuOpLHSI4bHnTgsIgHeS4Y0/phbMg7RP8iWBPMcMNsFBJ9ni7IWyaULnShZvWu0iyfteGUBUEO2wNBWtu5j9Z+xmgrdcwViqOPv7iW+gPOawmZHIMfpM+9okY7pTSWFmpWVlhBWyFut1EP2V9Exf4FzvGfAgbl0nkgMWBsV8qYXJX25yruJaRxAg/h+Og+GwI4DG8iaFNHrjhtYh4sQ3xLSdU19G9WOUNlr0CzVaHYhJptDy+PLYqDw5YWTM36HURupYVzNAdELhKEVqOMAQRIB9jdXDd3SeWaj7oA1wmNuj7SFPLfafEI0NJwXZWcAtY1DMBVXNuUzYkVLNkvYN6DeZb0QiW0eqJ/eAjZvDLcHAwVYue3iHyfHKxzebVLBtS5UAoWmjufzjMOiSFBlBi+BPHxb9u2cRBpKUYooeNGyKIspOz3DJ6RuBiFbJcTCJYf73elZnPoqGR0ci+r+JKHD4DjjFhpdpsMprKEMhShzBADZaQ9uxgia5aAiAcIC8ads5eXMBZSauter/fMMzbJ6psptXCeS1KK+HL+wclqKH9VaNy9X+i0BccaUrDXrPI1JKeLfK7Kzw7MLNAMRy4VM8bh4INS7hPPhmAvFNo+7XppZhAmFGXjwR9rWrUaqTABw5Cy+F+GkUxnrA== X-MS-TrafficTypeDiagnostic: AM6PR03MB4885: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 74fksjl1Dbj3dgIpDjFtwHjDNIKapYbB93I75tm6EP14v9ryfL/plWHK0UwkRYhWIhm7FAYh98BAAHp3MIDUrmTeWAF8Oyz8xxROMhjhohNxFexEq00upK0wafYK8U+/0yKh55IZRDGOErOTe6YssZ4kyNf6D8UzVbDxhMSQVllBoNGoeqt2DaEyblLGXZQLrIm6St7+HsdoVdNdD4/jzj6Rq1PE9TJqtGDQNCoc1lvE9Hq4TSFT++jN51no+1W6UU611mTLHw0Kr61Lvq1Z6xTfad4reXwCyiHi5xveeYYkKyWZgzPp+Ocmhv5MIxwonhQyzdObX+i4Pu7NRBfG4fIoakFxoSseX0D5nLFolusR0hWuLORFM2cdURIY+I7Weesbis1Pjmaz5i+venisxoZc0Mwy4aNbhoCDyw8dMpBkocz1gsl5Y5KWBWCCQqAF X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UiW9OAPXbbgrtVDCg7jEEccx3dXElo81q/wc14mh+WILJxv1YfIJPWcxPYV4CjKuhTiH3m3WDdDLJJd6fdtmeJTaBs5X3nEE2mTEd6jpbk57/Juhek9sVkxS9TJLq8NcEHG6u8ZIWKEKMb6tbLZX/Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7a70431-886e-416e-0dd9-08d98b3776a0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Oct 2021 15:14:18.1499 (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: AM6PR03MB4885 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/nullenc: Use ff_interleave_packet_passthrough() 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: L9HluC3rj/ym It avoids the overhead of the packet list; furthermore, using ff_interleave_packet_per_dts() is wrong for the null muxer anyway, because said muxer accepts packets without timestamps, which ff_interleave_packet_per_dts() can't handle. Signed-off-by: Andreas Rheinhardt --- libavformat/nullenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/nullenc.c b/libavformat/nullenc.c index 7354913726..d4769d5920 100644 --- a/libavformat/nullenc.c +++ b/libavformat/nullenc.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt) { @@ -33,4 +34,5 @@ const AVOutputFormat ff_null_muxer = { .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME, .write_packet = null_write_packet, .flags = AVFMT_VARIABLE_FPS | AVFMT_NOFILE | AVFMT_NOTIMESTAMPS, + .interleave_packet = ff_interleave_packet_passthrough, };