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;