From patchwork Tue Jun 21 02:30:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36358 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1976242pzb; Mon, 20 Jun 2022 19:31:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uTgTJlhO0eXqhOZ9DsJzQeQXzaxQiKvBIrH49txAcVLeC8FuC3RYMqhrroHmbCQGCNVk5j X-Received: by 2002:a17:906:221b:b0:708:a007:5a77 with SMTP id s27-20020a170906221b00b00708a0075a77mr23987410ejs.566.1655778669347; Mon, 20 Jun 2022 19:31:09 -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 e26-20020a056402331a00b0043586cdd881si882346eda.260.2022.06.20.19.31.08; Mon, 20 Jun 2022 19:31:09 -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=fhNTGSxq; 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 5942868B60F; Tue, 21 Jun 2022 05:31:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2037.outbound.protection.outlook.com [40.92.89.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AAE6F68B4BF for ; Tue, 21 Jun 2022 05:30:57 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hm8/ltt3yFQssdG/nT2F9yRGGEfmx85lfSvF+XhGlGPxQyzUOYTyvmSsb/UCu6ApNUOKpzSRuOCLU5aBipGY82wxvmHDZvmAA75mvB+z8DHdFEB7Dv1HcG3K01UYA5cBJbzWZVvyBbP5Pj2I16iqi4A+W9wq5btx3H/7OKt7BVaji0nslv7Z1bJjr4vubuD4Jr0U7/dLnIKH8Ow3KHPGsWRYisxvwa9bCtoLGSh3VTEqUe5S9pk9ElxX/PZLmJmJ07e0PUisxMNgyqjYY5ENWjaTrkwuy0l6gzbz3dvHaUdYuXDj6xoPkagfuAGZWb0wlHstbGE930fFFhrHwh+6NA== 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=+sl/7Rk/91iC8L48rH3I3OE/5AjSg+ff33ggmHC8ePE=; b=TGD/p7Tn7sxaVQOGsV6rVAV/FPo3hgiMgMTy0vZUE2daSTVPjr+JmQd1vRyDe/o8ZyH8WeQHpnCdnReCx2XTPfl7ABn/3bqSNKw9aCJbF4mUVelp8J1k7Al13xrY+McKGqbhOlJIHwy8XNpKcmJnKmbNv6r5/aShmu/OC0zoK++CrF44hQMiqzXjZ5ZYH2IyqYtQL88zlYSAQAucqXiCBWwIKj3OZjbrAtNxKujW0sy/Y43s5HMasC/ADBGX6eHdhEZhvkmgJLaTwkDHcWyXCsUaVvPfV0hmtLKZmyL13LE8R1Bc+tapZpsGP2Sz1lL3mJPRLqlJ+yU57fqrHf0UuQ== 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=+sl/7Rk/91iC8L48rH3I3OE/5AjSg+ff33ggmHC8ePE=; b=fhNTGSxqCS/VyUgi5rK9FdtF6YZd8Y/v6w/DhC6SB5PtyGhvw/KbM0k/dAaM/5Fz/Dl58BopLiNyk4hFNLOSKjDX89BLNFlsMSakdcAU2mYvuSIYsTNVd5twbtnLl02GvYe/RchOUNUReRxBErIYegvAcpfobFwrDnpn505zTksdKMNCW4qkTShQwCL1+CIbp3YhRLdir/nhxwG85qSQled+6ctuC5DS8+Cqi4U8XRLswm6EMYhJaSxTHHn7mEtYdhEKq7VMwWNGsGEvRwVXtqujjhcBymOA+iycUVn8yUimzLjLEnXfkL3a0II2NDX4oYD1oxcQBfK3DrUi3NAmSg== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB9074.eurprd01.prod.exchangelabs.com (2603:10a6:102:2b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 02:30:54 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 02:30:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 04:30:33 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [vGgQP8w4+nxWVlCVtWhSgB+CeO+KIzPj] X-ClientProxiedBy: ZR0P278CA0017.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:16::27) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621023038.3322391-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ca2a92dd-9966-4a3d-b9f5-08da532e0c9a X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEtlA26CjnCS1VxapTOXeNoSgarjVwEegyw+Hz2Ngrivg0TdY6wZ5KDSt+k4fZHph25h79zViuqo70HVAf2m1xlrSEoQV4WkuHktXef6l8TWfn8/YuC0E7PaHBLjagQ+3QqIlHpeMUGuBXxWcmWGXBzRaKLNFo3aXokrwL+NpimwdcnSZf13QEkeXtIcCSYvDb3BDCt9p+haOmEhzT3knbpXtNbwJYV3GszPfxxRYp6R6zsC9ley9aNOy13KIQIR3EBKBXWZZUVFQgp0OmABqLl16usQPqqIsKNR9v/02Tjc/wgQ5n7AtX/FM+bzlocZ7+C9C3MN9AfU4FV4y0DMAkEyvOvHHTzoPEpgZS+Uo6uV0LkxZ1YhSSyw+t+MkiOJ4xbtbpGxdVFe1dnhzPf0znX46kK0ZfN5J0b3dPfMF1rMyKSEoHLSrtt4+HnnQ9AQnsj/XdAO0LRWSOjgSKA0R34fzp2AHf2/1KxWVPqosm/EqkAoFK4xb2qEps+ag+l2j8hQAeuwRq8qBo8zon7IryN5cKBMO9fVVKvReO9F6PgVkiFPPOAgzsB6RO+H+IJqAG704PUBpyT5z1Y4m+OAnFrAz8YaT71rFpxEO0dfnct1OFxRef7UknssKr9jvztSwIu1CxqWzMQ+viXyzRb5pODXCM+vGE5yy8Snbo6MW4qvDxIh8M8hab/EkMz0s8/qw1KlRRugWxpH6v6VgfSRfiyiuaaA1QwK6eXyDEkQqPeKcPsBXl5mo0Fri8qx+ciqBU1ifTik7A271WGguBsWb9i3 X-MS-TrafficTypeDiagnostic: PAXPR01MB9074:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8oMAG+u7A05F+TZRoFwiJYaq2J0ncp0giu50lVbvFiBQNHcRllsewyCJxBGqhY91D6LBejcj0p7X5Jy1zGb+Hpk7qzBDNDS24rw3GQZrdBNJoa0c34+zv3Lx8OCBb5wqU4BpGMrOzew8Ci31XhQA38rMJDVb9Td/yBmAcP+PnynwDt28jv6lIjVDi5Y0J3KmY1tbljLBsb/VUq8G8ztV+1VhKATMpDyNuWZqn29XreZ7P22ha5mps+MpQqCaXUUShz5WUiPVFjbHjW32NBjLHg4mIEfFvA4MQrqHHNcdhg8ZPGLjYWaPr6mN12VbvYyVWirhu/4fHftmRffJ9PWAPOf539AMyMkYDmzEXl5V+J7rbn+xlQGQGUJZYSzkpEiiN06En713MqhPA+8giXlu4Ailp5P6oQqqUThPys+U/qrJys+xgtLiLPKB9enUlIBi0+FcST3qPxw/hdbaupHZIJH5cfZSeP68lal32xkriYvdJzLVF/JXsmnoNqmF6wBAPrBdrNKvdNf+0F5Of98ATar10U7w8iQm/GQbBchyff5QLo8JXxlRvoigl1JXQGU9dgYIsSgg5CLOZKPFnzGuxw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FN5RvtC9dHXBPTa/bAYHwfr+JtfNJ9L0eLKIrQRLxH72U/kTncKgGH5FoFQxctU+WAoI3EfJ0cCvfXb4p8ZzjnLgDtHLl/L8LFTBPoKvVEmhbN7E9ZwpWCUVdGX3bf28o2ASDbo1LzHSRsOnJi+MzDtevAWV6BZUA7lAXDWCrBm3BXn068AEoQT64UNwZHEwdK0tbMUPvv2fEjv66zoHNVr18vYqd9Dhf+Y2bQ0gvrFQy22DWH5LApE9WcKHBaO5zcAa+/BaLpBGPdsx810191GAOSE02WLTp/epHY6U/xsZNqoPnKIkIZmKkMiw2uxK3NkPNWTB/IXr3m/kvdobgTMY9WyxXfemQ1FixvizOd/6fJqQl+/YnS8cQORBtRN/T982dhjApKRHbNb3z/GvKPgb9Io9KIC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W722Z1DA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca2a92dd-9966-4a3d-b9f5-08da532e0c9a X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 02:30:47.5164 (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: PAXPR01MB9074 Subject: [FFmpeg-devel] [PATCH 1/6] avformat/matroskaenc: Split assembling CodecPrivate from writing it 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: GMiq3B+snBhK This is in preparation for splitting writing and updating extradata more thoroughly later. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 74 ++++++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 163af8aec8..b4756832eb 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1099,9 +1099,9 @@ static int get_aac_sample_rates(AVFormatContext *s, MatroskaMuxContext *mkv, } #endif -static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, - const AVCodecParameters *par, - AVIOContext *dyn_cp) +static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, + const AVCodecParameters *par, + unsigned *size_to_reserve) { switch (par->codec_id) { case AV_CODEC_ID_VORBIS: @@ -1112,7 +1112,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, return ff_isom_write_av1c(dyn_cp, par->extradata, par->extradata_size, 1); else - put_ebml_void(pb, 4 + 3); + *size_to_reserve = 4 + 3; break; #if CONFIG_MATROSKA_MUXER case AV_CODEC_ID_FLAC: @@ -1139,7 +1139,7 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, if (par->extradata_size) avio_write(dyn_cp, par->extradata, par->extradata_size); else - put_ebml_void(pb, MAX_PCE_SIZE + 2 + 4); + *size_to_reserve = 4 + MAX_PCE_SIZE + 2; break; #endif default: @@ -1153,21 +1153,21 @@ static int mkv_write_native_codecprivate(AVFormatContext *s, AVIOContext *pb, return 0; } -static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, - AVCodecParameters *par, - int native_id, int qt_id) +static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, + AVCodecParameters *par, + int native_id, int qt_id, + uint8_t **codecpriv, int *codecpriv_size, + unsigned *size_to_reserve) { MatroskaMuxContext av_unused *const mkv = s->priv_data; - AVIOContext *dyn_cp; - uint8_t *codecpriv; - int ret, codecpriv_size; + int ret; - ret = avio_open_dyn_buf(&dyn_cp); - if (ret < 0) - return ret; + *size_to_reserve = 0; if (native_id) { - ret = mkv_write_native_codecprivate(s, pb, par, dyn_cp); + ret = mkv_assemble_native_codecprivate(s, dyn_cp, par, size_to_reserve); + if (ret < 0) + return ret; #if CONFIG_MATROSKA_MUXER } else if (par->codec_type == AVMEDIA_TYPE_VIDEO) { if (qt_id) { @@ -1193,7 +1193,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, if (!par->codec_tag && par->codec_id != AV_CODEC_ID_RAWVIDEO) { av_log(s, AV_LOG_ERROR, "No bmp codec tag found for codec %s\n", avcodec_get_name(par->codec_id)); - ret = AVERROR(EINVAL); + return AVERROR(EINVAL); } ff_put_bmp_header(dyn_cp, par, 0, 0, mkv->flipped_raw_rgb); @@ -1204,7 +1204,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, if (!tag) { av_log(s, AV_LOG_ERROR, "No wav codec tag found for codec %s\n", avcodec_get_name(par->codec_id)); - ret = AVERROR(EINVAL); + return AVERROR(EINVAL); } if (!par->codec_tag) par->codec_tag = tag; @@ -1213,14 +1213,32 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, #endif } - if (ret >= 0) { - codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv); - if ((ret = dyn_cp->error) >= 0 && codecpriv_size) - put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, - codecpriv_size); - } - ffio_free_dyn_buf(&dyn_cp); - return ret; + *codecpriv_size = avio_get_dyn_buf(dyn_cp, codecpriv); + if (dyn_cp->error < 0) + return dyn_cp->error; + return 0; +} + +static int mkv_write_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, + AVCodecParameters *par, + int native_id, int qt_id, AVIOContext *pb) +{ + AVIOContext *const dyn_bc = mkv->tmp_bc; + uint8_t *codecpriv; + unsigned size_to_reserve; + int ret, codecpriv_size; + + ret = mkv_assemble_codecprivate(s, dyn_bc, par, native_id, qt_id, + &codecpriv, &codecpriv_size, &size_to_reserve); + if (ret < 0) + goto end; + if (codecpriv_size) + put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, codecpriv_size); + if (size_to_reserve) + put_ebml_void(pb, size_to_reserve); +end: + ffio_reset_dyn_buf(dyn_bc); + return 0; } #define MAX_VIDEO_COLOR_ELEMS 20 @@ -1833,7 +1851,7 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, if (!IS_WEBM(mkv) || par->codec_id != AV_CODEC_ID_WEBVTT) { track->codecpriv_offset = avio_tell(pb); - ret = mkv_write_codecprivate(s, pb, par, native_id, qt_id); + ret = mkv_write_codecprivate(s, mkv, par, native_id, qt_id, pb); if (ret < 0) return ret; } @@ -2626,7 +2644,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) return ret; memcpy(par->extradata, side_data, side_data_size); avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - mkv_write_codecprivate(s, mkv->track.bc, par, 1, 0); + mkv_write_codecprivate(s, mkv, par, 1, 0, mkv->track.bc); filler = MAX_PCE_SIZE + 2 + 4 - (avio_tell(mkv->track.bc) - track->codecpriv_offset); if (filler) put_ebml_void(mkv->track.bc, filler); @@ -2649,7 +2667,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) } par->extradata = side_data; avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - mkv_write_codecprivate(s, mkv->track.bc, par, 1, 0); + mkv_write_codecprivate(s, mkv, par, 1, 0, mkv->track.bc); par->extradata = old_extradata; } break; From patchwork Tue Jun 21 02:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36359 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1977182pzb; Mon, 20 Jun 2022 19:34:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vHX2VLHVajCsntNng6qUCRWKtCfgU64Vjq1u5J3HwA0rmTPgGjHYnSFY7052H/dK3T74WH X-Received: by 2002:a17:906:58cb:b0:70a:751c:91fc with SMTP id e11-20020a17090658cb00b0070a751c91fcmr23260551ejs.258.1655778879629; Mon, 20 Jun 2022 19:34:39 -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 m4-20020a056402050400b004358320ac70si3944870edv.419.2022.06.20.19.34.39; Mon, 20 Jun 2022 19:34:39 -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=UTCr7Usr; 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 B7B8F68B646; Tue, 21 Jun 2022 05:34:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2015.outbound.protection.outlook.com [40.92.89.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18D8C68B476 for ; Tue, 21 Jun 2022 05:34:30 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A2YJYHcqGMDkZEqYAnbZQJcGjZFW7tn6b2AmlMEyBSaRtZLKEMu5Or9UqzkvByoJiGTz5TaJ0UbA/W9zyWL8tWW5T9yfQL9D9rx6NRcDJMyLDxSd3F7KRQqkrkUr2EmcRFD18mbo6ZkoEda/PqLVsM7VO6QFb029KxDKm65bBBTkce/CJ9PzfF+56n0/Y5lHB3S8emEXe2GgR3UB21YqW8dHqcCAkMFDdqoV2aPSX9q57M16gRDh2jxCA43g4laRBFIKij59F/83jx+HA9t/blpYqqo2MJZgDIzAd2LTMPQCdFjHHJ9i/uZd60mubXsBXn0Npch8zx6rHHx3IZe6eQ== 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=HtRfuaWFNfZRjpWhLa1DWsg1Houw6UOKtaqWNfYvpxI=; b=Oeq6msjlWgBkPzNZVe0f9oAUt4vMB1il7Ty70hDLE204jPnrPpI4R24I/gZwWSI5CWCQhFw9iJrcGRfkKv48a1QEiuIzs7IL54lENnYpJ6qT6htzeaeGf9pttqVaZf+HCj2OquIpbDJdxcNNer1ZuEGQFRiOmXHXABDbrw4O90yIqYj2yloG2hEAuttlrtjSUOrGuxsAXl3iA+CNctqqzrA/ZIKWjSbg9kS+pcIYD6iCOdrMX7KpkWR1+8v5IBlpZmufteN1AFRjZJ9Nf4lf15UHea0xPKUOenb47sU68Tq60l3KyAZXRgMDvm8DPVp75FhZfO0sDhFWt7k5vHVKRA== 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=HtRfuaWFNfZRjpWhLa1DWsg1Houw6UOKtaqWNfYvpxI=; b=UTCr7UsrAxuhFt2J7okxxRTeAnYo2cCafcjK5cWj9o0Q2ZqmflAZX+ypI1KwF7LNtp7f5wFWu8i2jPMXGRyNg+Mo9/sUtxyAGqeAvFj3ABWEJt69Jx87b6N3DXS1XUBYhqcIkSviog+O/WWsAWexEOOJf0lxu8u4BvLQW5cafmMb7Pdrb13oSy58U1t6Kcs4MPV7SQgdvRBbRe1iizzBNcE0xwDogPcE7EstGS5RxaDVP2z9HppRWAp0DKa8C4QQKhTfJ7P5dGZDtgC6TVdm2j58vDKf/2l87ivLkqssSvO7bwGrf8FLYxujfYaV6UGabE1L97dJTbbirpN3E41A/Q== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB9074.eurprd01.prod.exchangelabs.com (2603:10a6:102:2b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 02:34:27 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 02:34:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 04:34:14 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [iK+KBDaxY5k5q6JFbbrJRXBzqSkj15yh] X-ClientProxiedBy: ZR0P278CA0187.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::9) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621023418.3322554-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab58a39b-4792-4c75-2c72-08da532e8fb0 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiStnrXejT7dVEa0U1z4ilPml6toqxg0j92c53f35ii3N0eu24VWYFUdJoT/35GTFt4OgRM1qKDj9OEwn6XOu0edo/IdfNsOKg7U5poaXOt0aPfDCL+XiBGLl9S0yKNsytV3qxMykBlJy0JyZgXutBgKtv32H+XVgj5X2/5qNaMQ46ga6vm55wdVw88FyIf+i60D7oajyYGfejm+lBw+UB2pEiPgnonGsRsdHsghLjbbk/EeApDlwsGEG31OTWPHcv+ofje/We3nR61GZpnnvE+H20q+KnYif30Y8gWaOSxIsDRvQSCitQ/52qM3uPLuU8J8azX1fwmIxxvyPDNwevMgAoyhv1WKyUMNf3GpF7oO+HS9em9Y8uybfCQVYaCblx3B+jD4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WjYkZzLm5ZgfV81vQbDhkeKoh73oOqay1Df6rQwOej9Rp6wb7zNZ9OMrz6H61F6SSyB50L3cGQpGqW+esf3HiyGK8HMJ68CcVTdX+SuBTI21R3ksCNGfuYv2Djk4MhFDBnMm5fe0k9ubj3MuW/tPHmalIOkajv9lEBKfRFRVMgxoSnSMdRuAgVRIclI1VuA//u4ku8uIR3lT4LsPDVxnM3HwA6AGVF07PSEucH9awf38xHusCKqdxvSJYJS68gPP7hCMLIfxizjzQnwMGFNgvSKPeTLZmVMUZByZkCdciJEO0jR7uY1s14K674xwNl/KDe4Vjr0Yb6gvHdIubx9A+i2jrWKtJCdSrzLJ3K8D6wuUrgsexHpUG2tZj6U4vXKCyTDc6P2TcA2g/C/C1lkceF/ifjSPJdXyMY9h7OkQd47P0uV4zzgLKtESZRTmbEmYJ2Vax5lSj5GrQBBDMg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab58a39b-4792-4c75-2c72-08da532e8fb0 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 02:34:27.3759 (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: PAXPR01MB9074 Subject: [FFmpeg-devel] [PATCH 2/6] avformat/matroskaenc: Avoid swapping codecpar->extradata temporarily 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: +Bwi3CUEVwLo Instead pass extradata and extradata_size explicitly. (It is not perfect, as ff_put_(wav|bmp)_header() still uses the extradata embedded in codecpar, but this is not an issue as long as their CodecPrivate isn't updated.) Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 82 ++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 35 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index b4756832eb..93d10332a4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -990,7 +990,8 @@ static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp, } static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, - const AVCodecParameters *par) + const AVCodecParameters *par, + const uint8_t *extradata, int extradata_size) { const uint8_t *header_start[3]; int header_len[3]; @@ -1002,7 +1003,7 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, else first_header_size = 42; - err = avpriv_split_xiph_headers(par->extradata, par->extradata_size, + err = avpriv_split_xiph_headers(extradata, extradata_size, first_header_size, header_start, header_len); if (err < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); @@ -1020,22 +1021,23 @@ static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, } #if CONFIG_MATROSKA_MUXER -static int put_wv_codecpriv(AVIOContext *pb, const AVCodecParameters *par) +static int put_wv_codecpriv(AVIOContext *pb, const uint8_t *extradata, int extradata_size) { - if (par->extradata && par->extradata_size == 2) - avio_write(pb, par->extradata, 2); + if (extradata && extradata_size == 2) + avio_write(pb, extradata, 2); else avio_wl16(pb, 0x410); // fallback to the most recent version return 0; } static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb, - const AVCodecParameters *par) + const AVCodecParameters *par, + const uint8_t *extradata, int extradata_size) { int write_comment = (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE && !(par->ch_layout.u.mask & ~0x3ffffULL) && !ff_flac_is_native_layout(par->ch_layout.u.mask)); - int ret = ff_flac_write_header(pb, par->extradata, par->extradata_size, + int ret = ff_flac_write_header(pb, extradata, extradata_size, !write_comment); if (ret < 0) @@ -1101,43 +1103,45 @@ static int get_aac_sample_rates(AVFormatContext *s, MatroskaMuxContext *mkv, static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, const AVCodecParameters *par, + const uint8_t *extradata, + int extradata_size, unsigned *size_to_reserve) { switch (par->codec_id) { case AV_CODEC_ID_VORBIS: case AV_CODEC_ID_THEORA: - return put_xiph_codecpriv(s, dyn_cp, par); + return put_xiph_codecpriv(s, dyn_cp, par, extradata, extradata_size); case AV_CODEC_ID_AV1: - if (par->extradata_size) - return ff_isom_write_av1c(dyn_cp, par->extradata, - par->extradata_size, 1); + if (extradata_size) + return ff_isom_write_av1c(dyn_cp, extradata, + extradata_size, 1); else *size_to_reserve = 4 + 3; break; #if CONFIG_MATROSKA_MUXER case AV_CODEC_ID_FLAC: - return put_flac_codecpriv(s, dyn_cp, par); + return put_flac_codecpriv(s, dyn_cp, par, extradata, extradata_size); case AV_CODEC_ID_WAVPACK: - return put_wv_codecpriv(dyn_cp, par); + return put_wv_codecpriv(dyn_cp, extradata, extradata_size); case AV_CODEC_ID_H264: - return ff_isom_write_avcc(dyn_cp, par->extradata, - par->extradata_size); + return ff_isom_write_avcc(dyn_cp, extradata, + extradata_size); case AV_CODEC_ID_HEVC: - return ff_isom_write_hvcc(dyn_cp, par->extradata, - par->extradata_size, 0); + return ff_isom_write_hvcc(dyn_cp, extradata, + extradata_size, 0); case AV_CODEC_ID_ALAC: - if (par->extradata_size < 36) { + if (extradata_size < 36) { av_log(s, AV_LOG_ERROR, "Invalid extradata found, ALAC expects a 36-byte " "QuickTime atom."); return AVERROR_INVALIDDATA; } else - avio_write(dyn_cp, par->extradata + 12, - par->extradata_size - 12); + avio_write(dyn_cp, extradata + 12, + extradata_size - 12); break; case AV_CODEC_ID_AAC: - if (par->extradata_size) - avio_write(dyn_cp, par->extradata, par->extradata_size); + if (extradata_size) + avio_write(dyn_cp, extradata, extradata_size); else *size_to_reserve = 4 + MAX_PCE_SIZE + 2; break; @@ -1146,8 +1150,8 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn if (CONFIG_MATROSKA_MUXER && par->codec_id == AV_CODEC_ID_PRORES && ff_codec_get_id(ff_codec_movvideo_tags, par->codec_tag) == AV_CODEC_ID_PRORES) { avio_wl32(dyn_cp, par->codec_tag); - } else if (par->extradata_size && par->codec_id != AV_CODEC_ID_TTA) - avio_write(dyn_cp, par->extradata, par->extradata_size); + } else if (extradata_size && par->codec_id != AV_CODEC_ID_TTA) + avio_write(dyn_cp, extradata, extradata_size); } return 0; @@ -1155,6 +1159,7 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, AVCodecParameters *par, + const uint8_t *extradata, int extradata_size, int native_id, int qt_id, uint8_t **codecpriv, int *codecpriv_size, unsigned *size_to_reserve) @@ -1165,7 +1170,9 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, *size_to_reserve = 0; if (native_id) { - ret = mkv_assemble_native_codecprivate(s, dyn_cp, par, size_to_reserve); + ret = mkv_assemble_native_codecprivate(s, dyn_cp, par, + extradata, extradata_size, + size_to_reserve); if (ret < 0) return ret; #if CONFIG_MATROSKA_MUXER @@ -1175,13 +1182,13 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, par->codec_tag = ff_codec_get_tag(ff_codec_movvideo_tags, par->codec_id); if ( ff_codec_get_id(ff_codec_movvideo_tags, par->codec_tag) == par->codec_id - && (!par->extradata_size || ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(par->extradata + 4)) != par->codec_id) + && (!extradata_size || ff_codec_get_id(ff_codec_movvideo_tags, AV_RL32(extradata + 4)) != par->codec_id) ) { - avio_wb32(dyn_cp, 0x5a + par->extradata_size); + avio_wb32(dyn_cp, 0x5a + extradata_size); avio_wl32(dyn_cp, par->codec_tag); ffio_fill(dyn_cp, 0, 0x5a - 8); } - avio_write(dyn_cp, par->extradata, par->extradata_size); + avio_write(dyn_cp, extradata, extradata_size); } else { if (!ff_codec_get_tag(ff_codec_bmp_tags, par->codec_id)) av_log(s, AV_LOG_WARNING, "codec %s is not supported by this format\n", @@ -1196,6 +1203,8 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, return AVERROR(EINVAL); } + /* If vfw extradata updates are supported, this will have + * to be updated to pass extradata(_size) explicitly. */ ff_put_bmp_header(dyn_cp, par, 0, 0, mkv->flipped_raw_rgb); } } else if (par->codec_type == AVMEDIA_TYPE_AUDIO) { @@ -1209,6 +1218,7 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, if (!par->codec_tag) par->codec_tag = tag; + /* Same comment as for ff_put_bmp_header applies here. */ ff_put_wav_header(s, dyn_cp, par, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX); #endif } @@ -1221,6 +1231,7 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, static int mkv_write_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, AVCodecParameters *par, + const uint8_t *extradata, int extradata_size, int native_id, int qt_id, AVIOContext *pb) { AVIOContext *const dyn_bc = mkv->tmp_bc; @@ -1228,7 +1239,8 @@ static int mkv_write_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, unsigned size_to_reserve; int ret, codecpriv_size; - ret = mkv_assemble_codecprivate(s, dyn_bc, par, native_id, qt_id, + ret = mkv_assemble_codecprivate(s, dyn_bc, par, extradata, extradata_size, + native_id, qt_id, &codecpriv, &codecpriv_size, &size_to_reserve); if (ret < 0) goto end; @@ -1851,7 +1863,8 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, if (!IS_WEBM(mkv) || par->codec_id != AV_CODEC_ID_WEBVTT) { track->codecpriv_offset = avio_tell(pb); - ret = mkv_write_codecprivate(s, mkv, par, native_id, qt_id, pb); + ret = mkv_write_codecprivate(s, mkv, par, par->extradata, par->extradata_size, + native_id, qt_id, pb); if (ret < 0) return ret; } @@ -2644,7 +2657,8 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) return ret; memcpy(par->extradata, side_data, side_data_size); avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - mkv_write_codecprivate(s, mkv, par, 1, 0, mkv->track.bc); + mkv_write_codecprivate(s, mkv, par, side_data, side_data_size, + 1, 0, mkv->track.bc); filler = MAX_PCE_SIZE + 2 + 4 - (avio_tell(mkv->track.bc) - track->codecpriv_offset); if (filler) put_ebml_void(mkv->track.bc, filler); @@ -2659,16 +2673,14 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) break; case AV_CODEC_ID_FLAC: if (side_data_size && mkv->track.bc) { - uint8_t *old_extradata = par->extradata; if (side_data_size != par->extradata_size) { av_log(s, AV_LOG_ERROR, "Invalid FLAC STREAMINFO metadata for output stream %d\n", pkt->stream_index); return AVERROR(EINVAL); } - par->extradata = side_data; avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - mkv_write_codecprivate(s, mkv, par, 1, 0, mkv->track.bc); - par->extradata = old_extradata; + mkv_write_codecprivate(s, mkv, par, side_data, side_data_size, + 1, 0, mkv->track.bc); } break; #endif From patchwork Tue Jun 21 02:34:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36360 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1977221pzb; Mon, 20 Jun 2022 19:34:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vHt+1Weh9Z0WfFyyUzSuavmJSBgrGqlVsUzjVOoxayng807rJ11u25fuJo6OvzvDs4bYq8 X-Received: by 2002:a05:6402:2402:b0:435:3418:61b5 with SMTP id t2-20020a056402240200b00435341861b5mr28554956eda.82.1655778888853; Mon, 20 Jun 2022 19:34:48 -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 bm22-20020a0564020b1600b00435679a5cc7si10397090edb.560.2022.06.20.19.34.48; Mon, 20 Jun 2022 19:34:48 -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=RyKtfnQO; 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 D2A3368B666; Tue, 21 Jun 2022 05:34:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2015.outbound.protection.outlook.com [40.92.89.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 442D368B476 for ; Tue, 21 Jun 2022 05:34:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YM9d7Wu8+P45i0aq1APpC6rScNWHozB6Cppu+y40chORiloHYaFZmpE7s7t2DS1w2aulKCkVMxkgmseVqoPDbJJhr5FfXq59/e6uFFuTrgd0BlNJ+i/qnDE9udNYTtZW2mEv3OAY/OnY4QTOsbJvPSdRcRm8otFvIpOD19CP9fMwXSfbeGWwDr9vQh1NFyx+yYuQYxwzIAnT5rRhlTxpbvlYqloc6zMv8ricQzLV2cYS5rDFD5yAtTyYKiZHvHDijp3zZ4OsrFRnZVxm9Ff7dxn46x9iH4NiWNqQocJWtWUrn8jcrANJYKD2bCUZ83eCmsTGZQJcWWoysXtGafGvyw== 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=+h7X81XhmCBgyPujEbpLnxxSL9tT/OERXerkcB2wJZA=; b=gX/BqhNAunu9x367bILJ5l6wn2UdXv31Ncc/NizWPXvEJp8GgjNlIKznK/meIqDREfTeLab2osmZ+pmPVpJjpBWUDerSZxsdnKBzx209EJiw0SPXDWwznL4JrcCkDnrxuJWjjPplJCuXKl1STkIToByZCHadFTof/LieY4zow/+fZEwe/Tiih1dqsTCv9mJqdHKWpl1oZjJ48icUIJrYpp2+9Oodh8i5wRMH6LUhe0Uoev95dq0JqZLlILaes302tsARvg6cZQNPArYwdu14W7AK+WFwsrl4n06+KNjn9MfoHChK4WfB9KXx9Wztg/s5jSRuDZRqLCzBGBy/nL5GJQ== 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=+h7X81XhmCBgyPujEbpLnxxSL9tT/OERXerkcB2wJZA=; b=RyKtfnQOX4fM3n+ChMa6wNGJx7FE0JuhGYtt5SmzsmHkKKCkALFpCda+ZhUw3DPmY1ckZP7d6gQBo05n9Fq7pQyUxjmlv6HFtI3ogWxu3XYUH04h+bxNtwDgrsf/qJTl644ubqO2C5/wDxyr/0iJgFGALWoYrnHDq3O4bdSJlbU6JtgVpRroqYxGoxX/QcKHxrQgACbsTXVHDhxAAfuSbbwdN2StoN2AX2eE/9JFj36KUoKsDv32Bk7hZfZTKdyFAqGqajXg1PBFilmEPIwp5k2oMn7HcU3g/h1DvbcyTuQNl0Eg1NeD+5u/cnzHMqqb8JXFxTrXOoPdc4oOV6Z6Kg== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB9074.eurprd01.prod.exchangelabs.com (2603:10a6:102:2b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 02:34:30 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 02:34:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 04:34:15 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [G8cPzpFVSjZogKG8rCZyzgYaWQ8NUcSt] X-ClientProxiedBy: ZR0P278CA0187.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::9) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621023418.3322554-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d43ed32a-cefe-4fb2-3b87-08da532e912b X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEtlA26CjnCS1VxapTOXeNoSgarjVwEegyw+Hz2Ngrivg+D5DQB9KkAWUJN8BGtIFTTpmGyJ5A1ZV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5sEpBszzlYEdC3d6PHceyY3O+r1fcdgESgw1wS1r6Vp8OuaMwWoqqm3ZK77Kxf67Km319ZSoUbVrrk3YK+gkEWzP08cJCMrsxlFj0JqHJwEeTJVaiL+3XGbfp0siAFFuMQzaZnxKaQzh1m4qp5EnUTSUGrF7TjA4NsuDtp49x4Ty+tkL0Oy9yXDIqEZ6w/uyufeliZPLahXT9AxQLX8iwOLzXXlVUQ/V514H64yJ73eYqnP4Gcx4YzpXNEMJCThdDhj5sDvGB2aAn+TbPHGhvZC5DcI8MDTZ72b5nwP1OdJ1r4nRrqII+vW/SeJsbSblmEEpHrs6WHcFDDtBQvCa8xysx8sh3E3lyJ+7VYs231EXtykG4YH3XIpqYyGo67Me/NdKWWTJvkrfyPeoS/OFlCxB2/BUbG0kQJs9sO0l/YZ8N775HjkzTN9G34nJ+5gojbY/OCkXbS1FQW6w92EJ0Nxllz4wkuceG63BLarSTwIzJSRvuxue6BJTV/O7SUcv9Xq09okYN+8aIHLRRJI6PLRoVJ+MlB0gPC9mMzXmK/sXx8uJWwdYdty6Y5vcOdAWS63/sHxhtuHI96Jim/VsdrJSYbBO33pVYRoU5P6A3MX5/mcvE0EGiDGnMxIhkU9Z1Luz36Pb8R4ujMsZ1ofzPgQA0PQi2kfAEVuFLiCEQJnypPE0bFdyJQI9eZvbB7bO8qG6wcdDU/tCLHWrd1uNdAYMbjMWOGViPdpRva7LAdiv1Kn7ytM0S9fzEcOhnxqTQA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d43ed32a-cefe-4fb2-3b87-08da532e912b X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 02:34:29.8133 (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: PAXPR01MB9074 Subject: [FFmpeg-devel] [PATCH 3/6] avformat/matroskaenc: Split updating CodecPrivate from writing it 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: pj+/J6urcpG/ Up until now, updating extradata was very ad-hoc: The amount of space reserved for extradata was not recorded when writing the header; instead the AAC code simply presumed that it was enough. This commit changes this by recording how much space is available. This brings with it that the code for writing of and reserving space for the CodecPrivate and for updating it diverges. They are therefore split; this allows to put other common tasks like seeking to right offset as well as writing padding (in case the new extradata did not fill the whole reserved space) to this common function. The code for filling up the reserved space is smarter than the code it replaces; therefore it is no longer necessary to reserve more than necessary just to be sure that one can add an EBML Void element (whose minimum size is two) lateron. This is the reason for the change to the aac-autobsf-adtstoasc test. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 120 ++++++++++++++++++--------- tests/ref/fate/aac-autobsf-adtstoasc | 4 +- 2 files changed, 84 insertions(+), 40 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 93d10332a4..250015419f 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -184,7 +184,8 @@ typedef struct mkv_track { int64_t last_timestamp; int64_t duration; int64_t duration_offset; - int64_t codecpriv_offset; + int codecpriv_offset; + unsigned codecpriv_size; ///< size reserved for CodecPrivate excluding header+length field int64_t ts_offset; /* This callback will be called twice: First with a NULL AVIOContext * to return the size of the (Simple)Block's data via size @@ -1116,7 +1117,7 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn return ff_isom_write_av1c(dyn_cp, extradata, extradata_size, 1); else - *size_to_reserve = 4 + 3; + *size_to_reserve = 4; break; #if CONFIG_MATROSKA_MUXER case AV_CODEC_ID_FLAC: @@ -1143,7 +1144,7 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn if (extradata_size) avio_write(dyn_cp, extradata, extradata_size); else - *size_to_reserve = 4 + MAX_PCE_SIZE + 2; + *size_to_reserve = MAX_PCE_SIZE; break; #endif default: @@ -1162,17 +1163,16 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, const uint8_t *extradata, int extradata_size, int native_id, int qt_id, uint8_t **codecpriv, int *codecpriv_size, - unsigned *size_to_reserve) + unsigned *max_payload_size) { MatroskaMuxContext av_unused *const mkv = s->priv_data; + unsigned size_to_reserve = 0; int ret; - *size_to_reserve = 0; - if (native_id) { ret = mkv_assemble_native_codecprivate(s, dyn_cp, par, extradata, extradata_size, - size_to_reserve); + &size_to_reserve); if (ret < 0) return ret; #if CONFIG_MATROSKA_MUXER @@ -1226,31 +1226,72 @@ static int mkv_assemble_codecprivate(AVFormatContext *s, AVIOContext *dyn_cp, *codecpriv_size = avio_get_dyn_buf(dyn_cp, codecpriv); if (dyn_cp->error < 0) return dyn_cp->error; + *max_payload_size = *codecpriv_size + size_to_reserve; + return 0; } -static int mkv_write_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, - AVCodecParameters *par, - const uint8_t *extradata, int extradata_size, - int native_id, int qt_id, AVIOContext *pb) +static void mkv_put_codecprivate(AVIOContext *pb, unsigned max_payload_size, + const uint8_t *codecpriv, unsigned codecpriv_size) +{ + unsigned total_codecpriv_size = 0, total_size; + + av_assert1(codecpriv_size < max_payload_size); + + if (!max_payload_size) + return; + + total_size = 2 + ebml_length_size(max_payload_size) + max_payload_size; + + if (codecpriv_size) { + unsigned length_size = ebml_length_size(codecpriv_size); + + total_codecpriv_size = 2U + length_size + codecpriv_size; + if (total_codecpriv_size + 1 == total_size) { + /* It is impossible to add one byte of padding via an EBML Void. */ + length_size++; + total_codecpriv_size++; + } + put_ebml_id(pb, MATROSKA_ID_CODECPRIVATE); + put_ebml_length(pb, codecpriv_size, length_size); + avio_write(pb, codecpriv, codecpriv_size); + } + if (total_codecpriv_size < total_size) + put_ebml_void(pb, total_size - total_codecpriv_size); +} + +static int mkv_update_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, + uint8_t *side_data, int side_data_size, + AVCodecParameters *par, AVIOContext *pb, + mkv_track *track) { AVIOContext *const dyn_bc = mkv->tmp_bc; uint8_t *codecpriv; - unsigned size_to_reserve; + unsigned max_payload_size; int ret, codecpriv_size; - ret = mkv_assemble_codecprivate(s, dyn_bc, par, extradata, extradata_size, - native_id, qt_id, - &codecpriv, &codecpriv_size, &size_to_reserve); + ret = mkv_assemble_codecprivate(s, dyn_bc, par, + side_data, side_data_size, 1, 0, + &codecpriv, &codecpriv_size, &max_payload_size); if (ret < 0) - goto end; - if (codecpriv_size) - put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, codecpriv_size); - if (size_to_reserve) - put_ebml_void(pb, size_to_reserve); -end: + goto fail; + if (codecpriv_size > track->codecpriv_size) { + ret = AVERROR(ENOSPC); + goto fail; + } + avio_seek(pb, track->codecpriv_offset, SEEK_SET); + mkv_put_codecprivate(pb, track->codecpriv_size, + codecpriv, codecpriv_size); + + if (!par->extradata_size) { + ret = ff_alloc_extradata(par, side_data_size); + if (ret < 0) + goto fail; + memcpy(par->extradata, side_data, side_data_size); + } +fail: ffio_reset_dyn_buf(dyn_bc); - return 0; + return ret; } #define MAX_VIDEO_COLOR_ELEMS 20 @@ -1862,16 +1903,24 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, } if (!IS_WEBM(mkv) || par->codec_id != AV_CODEC_ID_WEBVTT) { + uint8_t *codecpriv; + int codecpriv_size, max_payload_size; track->codecpriv_offset = avio_tell(pb); - ret = mkv_write_codecprivate(s, mkv, par, par->extradata, par->extradata_size, - native_id, qt_id, pb); + ret = mkv_assemble_codecprivate(s, mkv->tmp_bc, par, + par->extradata, par->extradata_size, + native_id, qt_id, + &codecpriv, &codecpriv_size, &max_payload_size); if (ret < 0) - return ret; + goto fail; + mkv_put_codecprivate(pb, max_payload_size, codecpriv, codecpriv_size); + track->codecpriv_size = max_payload_size; } end_ebml_master(pb, track_master); +fail: + ffio_reset_dyn_buf(mkv->tmp_bc); - return 0; + return ret; } static int mkv_write_tracks(AVFormatContext *s) @@ -2645,23 +2694,17 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) #if CONFIG_MATROSKA_MUXER case AV_CODEC_ID_AAC: if (side_data_size && mkv->track.bc) { - int filler, output_sample_rate = 0; + int output_sample_rate = 0; ret = get_aac_sample_rates(s, mkv, side_data, side_data_size, &track->sample_rate, &output_sample_rate); if (ret < 0) return ret; if (!output_sample_rate) output_sample_rate = track->sample_rate; // Space is already reserved, so it's this or a void element. - ret = ff_alloc_extradata(par, side_data_size); + ret = mkv_update_codecprivate(s, mkv, side_data, side_data_size, + par, mkv->track.bc, track); if (ret < 0) return ret; - memcpy(par->extradata, side_data, side_data_size); - avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - mkv_write_codecprivate(s, mkv, par, side_data, side_data_size, - 1, 0, mkv->track.bc); - filler = MAX_PCE_SIZE + 2 + 4 - (avio_tell(mkv->track.bc) - track->codecpriv_offset); - if (filler) - put_ebml_void(mkv->track.bc, filler); avio_seek(mkv->track.bc, track->sample_rate_offset, SEEK_SET); put_ebml_float(mkv->track.bc, MATROSKA_ID_AUDIOSAMPLINGFREQ, track->sample_rate); put_ebml_float(mkv->track.bc, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate); @@ -2678,9 +2721,10 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) pkt->stream_index); return AVERROR(EINVAL); } - avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - mkv_write_codecprivate(s, mkv, par, side_data, side_data_size, - 1, 0, mkv->track.bc); + ret = mkv_update_codecprivate(s, mkv, side_data, side_data_size, + par, mkv->track.bc, track); + if (ret < 0) + return ret; } break; #endif diff --git a/tests/ref/fate/aac-autobsf-adtstoasc b/tests/ref/fate/aac-autobsf-adtstoasc index 8b6d9d96ee..57bfcae18b 100644 --- a/tests/ref/fate/aac-autobsf-adtstoasc +++ b/tests/ref/fate/aac-autobsf-adtstoasc @@ -1,5 +1,5 @@ -29daa1e1985dac4baae0774a0b56149d *tests/data/fate/aac-autobsf-adtstoasc.matroska -6644 tests/data/fate/aac-autobsf-adtstoasc.matroska +4342e4f3f93b16514bda511b3b7fd93a *tests/data/fate/aac-autobsf-adtstoasc.matroska +6642 tests/data/fate/aac-autobsf-adtstoasc.matroska #extradata 0: 2, 0x0030001c #tb 0: 1/1000 #media_type 0: audio From patchwork Tue Jun 21 02:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36361 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1977247pzb; Mon, 20 Jun 2022 19:34:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uJrcHLhnqf4f41wlesNy3++foR7gOo8GWL5Xj2kHIvTi62O7BupojBAvTN6rQ3g22t6j1M X-Received: by 2002:a17:906:519b:b0:711:fb34:16f4 with SMTP id y27-20020a170906519b00b00711fb3416f4mr24287297ejk.275.1655778897662; Mon, 20 Jun 2022 19:34:57 -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 p21-20020a17090664d500b00722e3682c3bsi805917ejn.257.2022.06.20.19.34.57; Mon, 20 Jun 2022 19:34:57 -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=hEFpUUz1; 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 D2B5F68B679; Tue, 21 Jun 2022 05:34:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2015.outbound.protection.outlook.com [40.92.89.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 64B7568B476 for ; Tue, 21 Jun 2022 05:34:40 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LCRMDfryTCvZuJE/1LOzYVO9xGRVTfSyeORCImngQf6Oc9Xzrw/zZJhwR85zViKcRhHLnCKzFS7T8zZzvZch0o5fe5flw7q9+SxELPd/J7V/YRvYq3v5dNecCD4VVhqY93NoT6aID+DVeJyw5PGGp04i4G9XfziSDsoHKmdXoEpxqee9ex0pmbcP9fJi11ocVOLcbsoqLU3N7QAiV3y/JTa6+LK+puNuxYF5vr0ho3Eh0s01uIJ7Nn68D1LvmifXmBQWQoGtXonAacTCV6wwehMcCB7yPVgyjmpkOk1CJLbovaSX1qPA9IKusH2hEcMC/Kfh2F3rR6Cxo6e/QFLe8w== 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=KEiZCuvjHU2LebOipLzEQ5B0+7CH9GwpwZZo4AekplU=; b=E7nfdzyNKFL0c63ZEn3hr06mmhm5OOasz/xQdVBLek/FJAirzA3nRAvphBbaK3ftPH8G/0X9xPFfzmwiKjVzg8N5ZkAVN7DZWxF72GNlEn4V5cNs+hjoiOTX+/OdaLbuCobiXd3TVW4Q8pkJFzoBv9DWcMfnFQ56YLiz1RoFzVcaX8xeLgNoH6LKhn08fsqZvp1t0WI4CXgUeAoWKgwIKucil0ejVzasoXba4jnQxSmo17T5PryTWYGawVenq+3rJLwjZ1YmbdcGFjt5fc5cxNzNmMs/JtC1EYuju+9liTwdWyoevEkObg0VKsLvnl7qhUp7QoPL4jgtHIZhOOU1IA== 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=KEiZCuvjHU2LebOipLzEQ5B0+7CH9GwpwZZo4AekplU=; b=hEFpUUz1lCLO1B8lSQG68SO5aaqkWoGQnWoiPd3lPDuKskM+sdofmB9dxA51azVT5ss2iftRglVUbAzMJw0P46xnaDfCC94yXB1CIQ+i4FVfAn8WQYzweQ53rpxfORdfX7T84M3LbbNx3ePs3Zh6UXwboANGujL/PclcQjNmtwxlQsNGbr/kMTS0YLR0KJhyDfL7Kin5UcEDPqrDljUJ3c59W3JP1IYlzxTTvH75V/uys6L42E+BNFiKCgYNQNaExAXqtAtjhDImaL5mv5Q2zgvwAQIja9c1MQo7JegVXCZ7hZq2CkoYOtIj/awjcK+D3JlToqeFdW1Y9NsaA4zktw== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB9074.eurprd01.prod.exchangelabs.com (2603:10a6:102:2b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 02:34:34 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 02:34:34 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 04:34:16 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [TKf3SyW1trOvt0Lc8C3HmCQe8LiOFRs0] X-ClientProxiedBy: ZR0P278CA0187.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::9) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621023418.3322554-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8ef8d1d-95d0-4077-61ad-08da532e93a5 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNX0VAkTI1HkVlw3wOKrPnCsnxKo4EcKmjlVR68jirKv+doUCHzOfFa34C82Qcc3JU89tVgQsXelO8gbKep9AYDtuz5N+v255nVyPXOv8spT1T3CDegk5strLdaZYj4Nj1tSR9dTeTFkcfzC2ySLvnB9ACnOElSuY45poxCZv34a0p9BtX1ljhCj5Pzsfc6/5cDtIpJUKCRRRSzQBhzvgeqM2YkGtnFkiThLe+PiUaxec5Yuy9tGfJ+35s1/TTpoVBlct8a8kWZf9yboTs0lqUvwYyYjYa784NFYf6PvA+E8F7i51u+a5fefsy1miVlAwZvMrzVCKtWOGznHyDUh468qpqKEqJAFQ5MfacnHtnL0HIxKWiiIsBJiXuraCeaFyaO1zpUx3RD7rIFyos4WkXa5ElETMofzF39/vewXwfjy9lUiptNdB5oJdF/54SdwJnuh1iDAy4JUvBNpvpvUo5eAL2yEMYzpoEYD8XjZfGSI0MvgE2IxKfrFyISqq5iLZVQEOniVKuhdoVMHEmRVLiJQsfLu+1oXGRa5wqL1zJFbm3NIR8MirUv/NdTPRoMhQlY2qwxXpfEVpzQ8gEKI8zh68rWd9s200i6VtKCEbtjMKuZS4vxXLo8ECK2OUNupk+0oYvH74rfBQmyhyo8IW4j0VrSNlbU5mhCQBNDQGOP0Er3zpsuzt0MhuDo+QoIsaH1RJUPI2ZyLS2u4x9/dS3yykQQTPKdC6Rk= X-MS-TrafficTypeDiagnostic: PAXPR01MB9074:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B7shujSpgeWgDwiIDnH9/I54xqu6km4JNXvjbX5PgcO5ja51Iv+PZIef9SaW8luYZdMl89M6YMinMzKXQDxIKCgrn+8mZLcCpEMKMjO1er+4WYIEC1R54k40UsvAipxfcPHOwnqNOtn7Q426EviMQLlRjCFcNYGIblxOTGcJavUJex5KOtweHfhX/XL9G0r64A1UOdEq8i1Auazn2lLjD5eomdgVN9PdRMwOxYC9ZyilY6+jMos4OUYPDfafGOcXS4r5z8SbeEQPQywCqO/L+oL4JPM57Q3V7f2pvg6wa7+qhpaYonRK76shy+0opQXSMm+LFc08kz56jifB9rdEIAH4RGVTA62qlwcqIH8cKu6EGGgzoRGQjomm1d35GK5SJqGh2EAEYARvQPdI8DfRWVpqiv7Mvtq0lDSsOaqI8xqoGZ/m77xrZ6QwcYA93dZ6X8u3ixp9SrtsRayavQkbJsGqRPbKUHsUbLX9AD7WK6ZFLnKK4+gF57h+Hk2dblhbImEgiuTpCa00bXWcZtZYrP7r+X3Ow9OkhKSQSOEpyayNfJe10Kb6gi+zuCrCKwIceFQLL5h2PzmO3mUiJgoxCw== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Q6gU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++x80mBE/8chqQdDtzN9J4mlDP8izpBt9yrFSvZJU4NZ5Qx3zPYlnGJq9T0wJi1PTyTI5osiPflpcSHPffcceCoGZf/O6dnUK/3zoVKechc1rPYoWaAQunpGoHvlmKQGGKyScMiY+vwLDuO31sHqoAxj0hKs17Oo4q02I3ugVkDaHz/egssHubVW2+1DRJjfWYAGAKD6OaMfiQaMi7WltVUkGxBU5ihfOwWuH3kBcosBDWr0m3UBT9/wi4m40EcacJ582hFswJm4iIDsqxAaNmj8o0cHqVBJPITMaH0pIFppX1Cmh3LPaE/gE2mtjFAxpmGdvbUH0GlzxD6NEo0imcBoSIGKpzaOhc0W7hjz9zTNiSaCsX+wPW2NNkPEXay1sqNRaD+KMDI2IgmaL/hMsbpiLuPw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8ef8d1d-95d0-4077-61ad-08da532e93a5 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 02:34:34.0005 (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: PAXPR01MB9074 Subject: [FFmpeg-devel] [PATCH 4/6] avcodec/av1: Add upper bound for the size of a sane sequence header 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: oZvay+inlxXd It will be used by the Matroska muxer to reserve a certain number of bytes for the CodecPrivate in case no extradata is initially available (as it is for the libaom-av1 encoder). Signed-off-by: Andreas Rheinhardt --- libavcodec/av1.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/av1.h b/libavcodec/av1.h index 951a18ecb2..384f7cddc7 100644 --- a/libavcodec/av1.h +++ b/libavcodec/av1.h @@ -175,4 +175,10 @@ enum { AV1_RESTORE_SWITCHABLE = 3, }; +// Sequence Headers are actually unbounded because one can use +// an arbitrary number of leading zeroes when encoding via uvlc. +// The following estimate is based around using the lowest number +// of bits for uvlc encoding. +#define AV1_SANE_SEQUENCE_HEADER_MAX_BITS 3138 + #endif /* AVCODEC_AV1_H */ From patchwork Tue Jun 21 02:34:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36362 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1977274pzb; Mon, 20 Jun 2022 19:35:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sLHRdzE7c6+8fF3Z4vsp5w1Nx6sNWsqQxcLr/4SF6kWIjMSH30xQGhfSYlOmsiR2RC3v8g X-Received: by 2002:a17:906:1003:b0:718:c108:663c with SMTP id 3-20020a170906100300b00718c108663cmr23378255ejm.252.1655778906667; Mon, 20 Jun 2022 19:35:06 -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 nd11-20020a170907628b00b00718d0fffd0asi13323807ejc.840.2022.06.20.19.35.06; Mon, 20 Jun 2022 19:35:06 -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=AUvjtwKP; 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 AD69168B5A0; Tue, 21 Jun 2022 05:34:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2015.outbound.protection.outlook.com [40.92.89.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8564B68B5A0 for ; Tue, 21 Jun 2022 05:34:45 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IbbQ3wVo4Rg39F+jTmCqs87JBviz0PPUcroeZK4h6OI2OraTWSuTfJUG97+CTpnFOxQalZR+pC8CC1JDBFuJBBTnzenULZ45RPA6t9sRedteJyG5zTNiHPQeifyzNh6IvUMlzoh9h4cxQkLBnX4O+747pNnbH172fOPYR9RIRxXm3E1GEMYLJCE0ce7D2tmP3BETOUx4+2tQPNmu1hWI8O7OeeWo6Bjb2OBgeRNHvFSTTnvxSFymLNFrAssqCGTBW6G8DxvpPOfhWupcU+bfEgh0Ei/n0qFo6uKtqDpv6oQg3+6nDHGlX+Rr7idd8bFwmzZAuJGZne+2KgVSFqdYeg== 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=ufk5D6ZBWfbIr4j6HUT9AGjGKhBATu5M/2/owV9zLok=; b=EHh3fUmSiPhvAUI3wjE/fGwiYRNMD7CDjsf7CTZXVqNwvz2diKl34bmArkkoRytSKl58zFCKXIdHOnLerCdoVf1pw+oiCrGx6jdJKreEESZQFX/FSKDSjhGsPC0KYSEjNeTa5mayxbhwGlGmAe5k7t8r3DhQq143AFdv7j30JDUgZebWX7Gh4xLbBcEYSO7r95jy0RsPdaCcnlgBCo/2+TCp9Y0noZo72KadJXBERtRKuTKGXJVZEekzVm80VMVXre/mWdtgIL1YfnLaWn4ZTJQvwH7Qa3TLWeH+KrIfGtJoxQBQMe8J/OXkRBGtatZpWTceTcooWy6PULw6Hidp4Q== 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=ufk5D6ZBWfbIr4j6HUT9AGjGKhBATu5M/2/owV9zLok=; b=AUvjtwKPvrvnjqOsMp2nGaxY52Wo7ZRXji14Fo/adVO8mdlAMTfbYc+dsvzKu/pMXqBkY/zxdMgVC6uEd7mIOdAJT839NOFK/cZQieLR4NAmCeHJ9iWaS4G0xfm7ON/AYh+imaDMBdmMpXcVN0sAGacCwcGz3Lu+53/LYTjehYAnxuTuU/I957EVvw4JVPJCAVDHrDDYWTkhj4Fy/bVNJBfmNTtcUcW8nGUzGgIMdhcob0Q33cN2F7boF6aezLKni+1OVTU5HKPP8MObbT5+7qjUDuwMbDuuhaHN3oHFkTxPaDJyDYU3JqN0BWCmbK5A7Y46PNVPtqJk8e4Nwy0nUQ== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB9074.eurprd01.prod.exchangelabs.com (2603:10a6:102:2b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 02:34:36 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 02:34:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 04:34:17 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [KjOT2MHKnl6TkYH6ENk+yEDylYzlxzCA] X-ClientProxiedBy: ZR0P278CA0187.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::9) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621023418.3322554-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a708a2e-8171-4bfa-6234-08da532e94cf X-MS-Exchange-SLBlob-MailProps: ZTmCor6bjd+txgLjEkup8ou8XEaNp8HXfzcEGGKRH15czYnyo74c5sWhBRDi/WWyqDNScAbXY2JkkYMJCSYmWWyBiT8PUkr5bKgX8jHTAF9I8e0F3ZcwgtVlIfB+a7P+8+yn59+u+lVv2xCKIcY8172vCEbEstbAeK6OIYaSYS2iQPp/6LABt22zcWGwRNwOvjMYo/ss9WvTobHehWVm+PLm2jofCkKGDHdYQZdY8byUotsyKLNBeXkAWOWRtJk5duKVA5TIFoB2gBpMGwfU1bZRcMMn6G64jLhXdtX+fcZuXg+1yuYv4CbbkYngPiaNdOOCTBMPyNI+qZBOSclxk/2JEbVu5I1rQUeRk/j/J+aan/OLo+CJNDdHnPNco+4M+mM2ceK+rLzlLgUaKTCAkdRAON/dgTbjbWrdeAjHaXB2iNd5j1OeXs4R36TgTE/Ea0JlTs2AvFUQdfiVvd0FEgZQOcjkZ7XlKquHnSV9ryak6QXW9bzR3T19c5b4dsRP/EK3XsX1H6pBzyHLgjvpBD6vgSExnpSvnn64q2KwBsO8+Pu1c+CCtoZZllY5BzryFvsnb8uw0Ey6rkxQ+85ln9ZDWdRtfu82KSXRAlIwR5zMpQT19laea79DbmNw63mAzCNvI04GZLLaGho1yR53/J0ELOZgd96kNRaGxneTeEE/eCDeCUPpetKY6lFuSN/LOMQR9IVyTUIwIXVQrt3WPIR4NF0gwQPQQ0FGQj/DQvUCYoxDDBdchWJBw5vKZo/FZZ0aiuwF40uyvuXtRuhebh/1Kek7/4yiMMU3HunxzXlBE47bik4nuMJoSPnVsf30 X-MS-TrafficTypeDiagnostic: PAXPR01MB9074:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E7iz2FQXHcB3o0Vob2p8xuNI+45ZMsIzpmtU5d5Ce1re5wTjK3YCdiJtyZfOgAmWbZY+1db3aF6NuvR5cT037u1RF7u1Omqgroy/Mhs6NipVdKN2aUPsdtEhiK8zTqbp6HK7QF0fRHYtORYaD8+fL/znL00hp7lW//Mi8WzBQPC+rM0IEEtX7NIT09Fw6p9R1HcPfzbyc6D7knQfuyxtILv1i9u/1msqw1qfOc48dwsQJKoQGJdktvq9HqiU4ecTNDKNgJrUDAdZNwNu6Hqte75Vvdh0rgfsCKZxQSC4TH+hHDDN1tJPsgD626RDetV4sWPXUeoc62/rl9o0sYspzsb6GKbV5sImB8T5EbnSAFBg38EE68XrUek6Zzng9jfL74E7sz1KZL/qLqFmpX9W9GPTmH3puiwxkrNf1hRmYOMLXKjwTW+Cc3/ORjxlWZqKjfM6Mf66xEx5q1NznnVaszeQCDynITdmXuojPgzfUn6tIuxRY5nYEc0bGylkgnqzOhhm4bt+KztrCVMzol5CGhvJNiy8awZuFCK6ouHfoSlHQZNu3Itxsw2J9pXEKFxU9AKtBtiQZFAqT9ViqNTPp2MVwHPhBVOosUZnz1KsBMwB4wi2XFgMoUedh0F5ehyv X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +kFFn09xS5DAL+6TkchQ/7V9j44VzdDfwljoa7ZPirWXVpIiGa06hgUrkDMOHXABt0EwQN01uK+kBSw6O3dR0pAH0WqKGWn+ta11G2+ToKWANuc79FbATlad22rmj9h5FWk8Q8jm0N/7NuHhVqLku9J9ON32syoguwJpg7+pFYvj5Sydu1eNdvUoDovAlheGQ78Ag1QoggcErziCaRpf0iodw1d6j7VMYEEijS8gg9bRlkl757izStPWg6seEf5EHWOVqpJtC122AolQaFLZP8jgqXW2cf1FPHcSxUF6o/Gpby3lK5S8u16l1FHg2vydpmqTAZD5ACVAt62Vru140V+pzq9kZUabeXvRri9VG7irilxcdJdaAPnJMzLJvjxVXqd//w1/m27ca6DjOhQnS6TtjPoyXx416e7VANko2Z9x7ZEhViiprPuxJZ8o8bWAHk7dcdasjvUrQJkjG26fmk7g96H3XYWzmsBckpVz+/AY0dbFO29bHrwf1Ox8OtsCVg7H8kT+VjXkDzCBLMUyzUwpShXUlXVV6YAyf2DmhAzoJlU/Z7eES+c2tmNP48c7YNv1SzLZtsFJ1bEOTsbaX+ai9Imh24aaeFVLlT3owpM+dTGYllpQiOCxJN57vphoxu5UrUIYDMr1nXcJCmMHJUInX6829nNkXu2wVZU4KiuwaVLtL4fbDQjYuPcflwPIEgujH2uAXjF8n7eVHYDM1GOyHuBjajSEExwouYFfEP7oAA7mJZbiluYTZPvAtgYZDNf/Cks76Y/p862h+0u34Gh5v9tcS2J431cYBauumRIvVH3h95W4ym/AB0iGmGIru5V4MzjCcg6/7bLiUm2B4Ra9K+71seTKcSunUFGCdPre3eD7XazW7+uSBIoMgHXNy9UDy4G8EOb6DknaATzmm/CoCdirHuXZ1hyfCrl7MklA2S8M91vd/dGvBAkvQBYZkz7kU9vSsNJuAIEMGna3I0DhGoNU6SkHSivpXTs38TCYF74hQJs4MUbZgCUH4dX7+UYsZgCHJKL1LZT77nB0QWJoI2HpY8swDEJgOolcb+uUW7XPtOe6/sGvQe3lVrFT11WbiTWZREePIio4vfiLDlyi+R7TB4iN6pkbTk9Qx+sl3bQxMoy2ZVRaparUPG8OlGwltyn2we1lufrr6rLUs2GmszqEFRDH0Kl04M5nFmnwFzDa/OJ9ZwJJWDw3LLTxX+Aqi+e/+Rp3xYquremCA8u64aXHJxvw4hXTZVevLFAqcLijEwLYsGgpVHTcFNldGOnwsCU/6cobVv+2nhC1CjHCecytfs3cgpS2VK7qQnSV4pDRZIwEvvc8BfrUvVYEOpKeD50XTLDSfMYE146btbNhSVt0JdTqWQj5gBWUbtCJdqNyXr128zQN4aTi6AoP1uwrLht6H7/hJcW/SBGGRIxNb3kEcZWBfyrlFxrcqhKD2zxC4tEncKpNVbERUlxJR9ptmLSuRWaB0FIWGBYweQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a708a2e-8171-4bfa-6234-08da532e94cf X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 02:34:35.9066 (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: PAXPR01MB9074 Subject: [FFmpeg-devel] [PATCH 5/6] avformat/matroskaenc: Improve handling of AV1 extradata 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: P5VUsSfnTEkD Up until now, only the first four bytes (the ones preceding the OBU) were written because not enough space has been reserved for the complete CodecPrivate. This commit changes this by increasing the space reserved for the CodecPrivate (it is big enough for every sane sequence header plus something extra); the code falls back to writing four bytes in case the increased space turns out to be insufficient. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 250015419f..b240ca0a06 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -56,6 +56,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/stereo3d.h" +#include "libavcodec/av1.h" #include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" @@ -1117,7 +1118,7 @@ static int mkv_assemble_native_codecprivate(AVFormatContext *s, AVIOContext *dyn return ff_isom_write_av1c(dyn_cp, extradata, extradata_size, 1); else - *size_to_reserve = 4; + *size_to_reserve = (AV1_SANE_SEQUENCE_HEADER_MAX_BITS + 7) / 8 + 100; break; #if CONFIG_MATROSKA_MUXER case AV_CODEC_ID_FLAC: @@ -1263,7 +1264,7 @@ static void mkv_put_codecprivate(AVIOContext *pb, unsigned max_payload_size, static int mkv_update_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, uint8_t *side_data, int side_data_size, AVCodecParameters *par, AVIOContext *pb, - mkv_track *track) + mkv_track *track, unsigned alternative_size) { AVIOContext *const dyn_bc = mkv->tmp_bc; uint8_t *codecpriv; @@ -1275,9 +1276,12 @@ static int mkv_update_codecprivate(AVFormatContext *s, MatroskaMuxContext *mkv, &codecpriv, &codecpriv_size, &max_payload_size); if (ret < 0) goto fail; - if (codecpriv_size > track->codecpriv_size) { + if (codecpriv_size > track->codecpriv_size && !alternative_size) { ret = AVERROR(ENOSPC); goto fail; + } else if (codecpriv_size > track->codecpriv_size) { + av_assert1(alternative_size < track->codecpriv_size); + codecpriv_size = alternative_size; } avio_seek(pb, track->codecpriv_offset, SEEK_SET); mkv_put_codecprivate(pb, track->codecpriv_size, @@ -2702,7 +2706,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) if (!output_sample_rate) output_sample_rate = track->sample_rate; // Space is already reserved, so it's this or a void element. ret = mkv_update_codecprivate(s, mkv, side_data, side_data_size, - par, mkv->track.bc, track); + par, mkv->track.bc, track, 0); if (ret < 0) return ret; avio_seek(mkv->track.bc, track->sample_rate_offset, SEEK_SET); @@ -2722,7 +2726,7 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) return AVERROR(EINVAL); } ret = mkv_update_codecprivate(s, mkv, side_data, side_data_size, - par, mkv->track.bc, track); + par, mkv->track.bc, track, 0); if (ret < 0) return ret; } @@ -2732,27 +2736,12 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) // See https://bugs.chromium.org/p/aomedia/issues/detail?id=2012 case AV_CODEC_ID_AV1: if (side_data_size && mkv->track.bc && !par->extradata_size) { - AVIOContext *dyn_cp; - uint8_t *codecpriv; - int codecpriv_size; - ret = avio_open_dyn_buf(&dyn_cp); - if (ret < 0) - return ret; - ff_isom_write_av1c(dyn_cp, side_data, side_data_size, 1); - codecpriv_size = avio_get_dyn_buf(dyn_cp, &codecpriv); - if ((ret = dyn_cp->error) < 0 || - !codecpriv_size && (ret = AVERROR_INVALIDDATA)) { - ffio_free_dyn_buf(&dyn_cp); - return ret; - } - avio_seek(mkv->track.bc, track->codecpriv_offset, SEEK_SET); - // Do not write the OBUs as we don't have space saved for them - put_ebml_binary(mkv->track.bc, MATROSKA_ID_CODECPRIVATE, codecpriv, 4); - ffio_free_dyn_buf(&dyn_cp); - ret = ff_alloc_extradata(par, side_data_size); + // If the reserved space doesn't suffice, only write + // the first four bytes of the av1C. + ret = mkv_update_codecprivate(s, mkv, side_data, side_data_size, + par, mkv->track.bc, track, 4); if (ret < 0) return ret; - memcpy(par->extradata, side_data, side_data_size); } else if (!par->extradata_size) return AVERROR_INVALIDDATA; break; From patchwork Tue Jun 21 02:34:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36363 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1977327pzb; Mon, 20 Jun 2022 19:35:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vxOUCWP7yvzfFaCodcdOb0S2NfRUQBI5zCyq0xCO1pxALDxE+l1Bny03sLJ6LiHTuY6O6b X-Received: by 2002:a17:907:7211:b0:722:e200:5410 with SMTP id dr17-20020a170907721100b00722e2005410mr1461044ejc.614.1655778915857; Mon, 20 Jun 2022 19:35:15 -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 ji1-20020a170907980100b006ff0c6bd81dsi12547346ejc.167.2022.06.20.19.35.15; Mon, 20 Jun 2022 19:35:15 -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=Q1Hosc1N; 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 A310568B691; Tue, 21 Jun 2022 05:34:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2015.outbound.protection.outlook.com [40.92.89.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A619A68B64B for ; Tue, 21 Jun 2022 05:34:50 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LC6HXSQXCjyYrAjEuuhg9ya/pRKF1trPd3+CsS7HrbUxU/DvDu7fjHZ8mR52aKu4cEb6zbvP91fGyVi3JghjAXMag0iVBC4Ck5+ACPGm+psb+le4zlvtUfSwhWP10b44uXdbxFpm/HXMiCrS5wGO36hBBZwFWDbM8xYzuAXjJVjRYV6Wa7BivkxmdWQbQPi5auDi+c95WUB9uSlsVPq750viQzjMCea8BukhpOHaglNhRTnXZ3k71Ghut251mphZAZdjL58O7vXbcI94qzpDnksEtpJ+5RxP01YP2rkzbAyPWKcgK3xB8TK7EdwYQsfy+qTRZp0GrQNQOo/AQE80hg== 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=j7EhDAjXRCrDd3gRd0NlYLXam9HlP1BgGar9XaXwqYU=; b=FbV2vRpg3W9uUw/PZnBS0DkZW2NUWnaOA+0hsIb+gx2lWn7AHElwsLX3H4uebOUvgGbMfjhRRzouciFDsndpm51t7/hfPifiR69sZs2ugf4x1068J8aE6hJYJRfVdL9FtppXDjkM94FlETp0Ceb3DYn6W8e+WNRYbmRQK9mEtwD1QPXlEqCAf2tW8jFRMvPqGmVKeQEKYnWMEu0E+QkX4WuFq6MXJIB+75O60NBLNr2xyZjRv1ZnHVehl/osx5yyShPrXWDPJMra0a37RxbAXyh90NLFiSWtm66N9fURmufYZ4vQKa2rRC0aEdVM9uVEWRhkY//RBhlWM1UZx3W8Sw== 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=j7EhDAjXRCrDd3gRd0NlYLXam9HlP1BgGar9XaXwqYU=; b=Q1Hosc1NICdgqn8zb/NxbK1HkOftu4umH9cU1iiKExUKuUh9PF5Tz15439dK5WSjFrDBpLN81Gw74rwKUr6GY6QzRpsyp6jTB6eqFwhgbu4QXVyigoBW2TgeAjM99i4MyuQTtlnCsP5nvR25hh6Cwq1IPYR1EvazqNGjOqDbgvx7HyOsjn9v6skJPhLtNYfI9VjsBM5+LMNAsnUiBU0/0wy+Hv5BSUjIjObfJlm9YcXAuFxORerkAJqdNC/MJGQok7fQ0RpY8qikGWKhyi+QZK4Buqdgxy3w6aD36of6Ru4VQ9D+Thvk/EiRknMKBeqWUOw9jVeKGEkIi/N1Uio//g== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by PAXPR01MB9074.eurprd01.prod.exchangelabs.com (2603:10a6:102:2b4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.18; Tue, 21 Jun 2022 02:34:37 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 02:34:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 04:34:18 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [2HJpRa2wwNZa3bDygvNdav+Tos4RuFLN] X-ClientProxiedBy: ZR0P278CA0187.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:44::9) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621023418.3322554-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8b557e13-5463-4c8e-8bba-08da532e95e1 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEtlA26CjnCS1VxapTOXeNoS/uY/UdmJqDCsnkyEBSeI8fG1IDTj5Z9xU737v2ICMjg16iEHSphWp7Ed0xaqvPllW9bmOCgvTg8WsnQ20FCnHnn7WXSwWEZ06I5ZnbUuqgC/yZOYf3fVYetCYHIuTS8RNvjr91cc0z3QrSoVZS/zMb2R8FpQMkjiygL//vV3bSc8RV5gGVD9D4L/pNg3fFJF2XloQmydu90s5N3eKqfoOQ2OAlXol5sBdkZmdt8d0GWzMa6TVCmbjujKT4dS+8MstaikScQvC63Qzl4jCQ7+yKmIxVjnxis0/JrnznEvpxvc1hMEAeQC8tPP41fT9wecGMlWWE7nwZuunBaulXiU+5t+zFS4vXQaUKKfFmGNbRcKLuHin7f+rExuFhB+/Ctd9OUlAYEb153bY99kM1PCnUDSew4n7OdhW4ooiy+3Wfpc97Y6naoz3maTeriL6FozlO9zqLQApIGiovhvTq0zpo13sfSb0Apx7eLY1bZlyseEAAl1Myey6zZhyCQPFuUjai4Tb6O2hVtnW3TsmOgVUp+M7wVdczDnineeyKUeCz0Hxky67B7xvuF7ruvoQu5zZ3DtG+4bxpMb37b4CsZNJJc4iqeunBPIjHcxqlLxBgnkJHaWVtCacgeWgKlxirhyqjRI8pO1Oz2q+kA1FRc3OXK1xBj+a4mxD5Y3sBRk5b6h+x2THFtrAdogJLEAF/L3ywqsuezY0925TAFIoQKD22pt/Bc3ZeYnQJjfjaGFyM5tz0Mrg1IS3ZpL7LhzMZ1y X-MS-TrafficTypeDiagnostic: PAXPR01MB9074:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7fw6MX54AmGlXP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0sjYJgnBa21ndVZ1QJHiSxUqvXb9kHyB5lmew6EGNQnf+AGehsZHw0sQXGUK+VRLjAg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b557e13-5463-4c8e-8bba-08da532e95e1 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 02:34:37.7346 (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: PAXPR01MB9074 Subject: [FFmpeg-devel] [PATCH 6/6] avformat/matroskaenc: Fix outdated comment 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: UfZnpPDhl0mt Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index b240ca0a06..acb50017b6 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -2732,8 +2732,8 @@ static int mkv_check_new_extra_data(AVFormatContext *s, const AVPacket *pkt) } break; #endif - // FIXME: Remove the following once libaom starts propagating extradata during init() - // See https://bugs.chromium.org/p/aomedia/issues/detail?id=2012 + // FIXME: Remove the following once libaom starts propagating proper extradata during init() + // See https://bugs.chromium.org/p/aomedia/issues/detail?id=2208 case AV_CODEC_ID_AV1: if (side_data_size && mkv->track.bc && !par->extradata_size) { // If the reserved space doesn't suffice, only write From patchwork Tue Jun 21 03:22:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 36364 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1991909pzb; Mon, 20 Jun 2022 20:22:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u0Nfw8A+sg+IS7l4Hvm3JYXopgfFQOI22o3ngrGZEo1vWsh3s/k7JA2iW08gC0ZSuehOic X-Received: by 2002:a17:907:2992:b0:70c:4ddf:5d88 with SMTP id eu18-20020a170907299200b0070c4ddf5d88mr23366013ejc.20.1655781747793; Mon, 20 Jun 2022 20:22:27 -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 g19-20020a170906349300b0071208964108si14097814ejb.635.2022.06.20.20.22.26; Mon, 20 Jun 2022 20:22:27 -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=qcvOe19j; 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 7F17468B609; Tue, 21 Jun 2022 06:22:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075034.outbound.protection.outlook.com [40.92.75.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 61B2268B5C8 for ; Tue, 21 Jun 2022 06:22:16 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M7exU15OTrZDZBp0vjbVh6hCF2duGxito7wMtEb4XaQX/+iDEhnDHYIfJ4dzFReZrtCWAe9/uDyYmpMIm7LuP6QaVGDxLJfMUl3p8YWuabn00CNotapdI/V1tJc7e5Ufxs0UgKjJPfMRJrZvZLktMn982/qR718D3Vz2wLZ3C77fn+zOHL16aAj6QK5Wlef9VJfq5mSYYl8iSMSK2kLp3MmYRyav408lvhwaUTztBp96TAQ3wP2DiVIYMbp/tNrgRpXnHAzw7ZcooNV9CMCf1QJD/43a4fwlfUgS0BmNIJgQCGJuJE6P5+VNC0W/+n1ylu57tof9fBo889WZDKmx1g== 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=mdgaoLgcb/8SDe9HOn/BaCvkLO5Lh+LZvZefiANaNwM=; b=mfh5G8LTjJ6clIhMsy5A8lBtxcZQmX7edcXhEYWCKPwpYom906N/Zbc1TkP6wBS8S6k/8olmlmepdbeiB6c4YBeaA68vps0/I8+PP7BHwzc/U9+q9ootELZalbMu2qaL+NIKS6oh+pKb6PcZoO+56XlxPAIx3oYezDmOq3cDQgN1O9MzO2Q51QfxfENYhsovCUC7jdPM7Vz6wPdWKB4EpyHLHF8ruKTogKPZJE5qoR7eeAULgJ2Pk9yMZqpUiwXznrWkavhLpYKWMDqEwYRx9Uc660HzPQUauDVWcNWVezs3Cyc3pjUu/RKTn1y7NO+5Iu6IXe59gjPdVQNrPHlWtw== 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=mdgaoLgcb/8SDe9HOn/BaCvkLO5Lh+LZvZefiANaNwM=; b=qcvOe19jJcSzJd7KlpjgINCPFAsKp6n0SUJJ/SJ9mwWNLz/ETS7p8pel2Zad9tuNjDVRFUBlodRZnRYu59Vdjv0/EGQfs7Gj7kCZTM4JMINlq5nLZ5pG7rj8CTrCgYDQcdCMLSxMjTfJ4M/+fuU/0b+n5giSwelEqicRAVouqv369qcedRvq+GmJf2VNV0GhVyMR8tU1vX9vnMdKCUByYkh97RCHlkwy+Hpsb4ITiX9IVhr5CLnHS00NKGjjBBs49yi35wBk54UAFOnJVRUB/0vuKrY0sWMAToVkjYJhecOTOxK889I0oBL5h5cn4vFCOG3O/YORcvoSy/aPIFc++A== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by AM8PR01MB7962.eurprd01.prod.exchangelabs.com (2603:10a6:20b:36d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.13; Tue, 21 Jun 2022 03:22:14 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::60b9:9f29:40cc:f01c%10]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 03:22:14 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 Jun 2022 05:22:07 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [Y4qD+wtcR2Qlw2XFXfPSn5HgdN4tIUC1] X-ClientProxiedBy: AS9PR01CA0024.eurprd01.prod.exchangelabs.com (2603:10a6:20b:540::29) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: <20220621032207.3325324-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff9bb2c8-8b07-4676-fe49-08da53353cb3 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiStnrXejT7dVEa0U1z4ilPmI/nKZGxPu8ovZoHS8YmFqA4kAjGGAXLBSy3z9NHlzuLx1TBebmVi5r1JaJYZ5mhi4/+W90+xM8WmwJhOVH6adzr1O7icDg8snA7yeKsyNsdd/gMYH1+U10yA4wqD5bM94XDFlew+tN8QwdQKgPUXIsaRJZFHg2SPFaAcHNUd0jLONP7x7DP5YlOOIdS4d1RMcpkPHV3XLmFg5qDiIu/An8FOPzHCEO+dZL6fsZg3NgDgDYpdmwFdS96tn+g1JgsqR8Ve1XdOtmXyYPlynFnMLU5Xb5pw8LIdSLMx3lpIHzktqHjEbJMr8uLkrDuRJnC8h/BjJ4R1mNqoX2zIWkCnE1QuNvsTPV5zJts2NRPMXXyDYelI9GwelxScee9DHnYhneMcWMuCFhn9bLrZb7Nus5L6yJewMed/N3SoGEVMVdGMJbwjS5D14FyHgB8euBlMIQ/6vSkyyVwrNQ1ati5G3YF3WwR0CYwyr0bdqgIuZNXpD3Vr6S54Xs4/Rb4CcGjAK/jo7j4QqgU2zK5KsuwkdL85jV3nAQCaX5N9UxOAq/mRbAfBGQIIDuDVsZZ7YCXM8TBA0lbjr2jkS00wzmmYV3nXiTZTCYfyv9T6NDQj8rV3qaYfM1kPV0Z0o99x2GjYNmDSDjgdwHtONXYwh10FDnM9kpmwhUrtyR20VSJtpcNKSkedckRoY42CSqq03rXt/kfbcyRrMFL/IVDCWQOgdQNIOe8dmIYbw57lzhKgMbg= X-MS-TrafficTypeDiagnostic: AM8PR01MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PnsecnOCzEk/E6vdVT5v2JDcC49JwZyN0ORBpkuwDT1prn3NbdYwtmfHWqUlpXIprtbbE04apJJc8p4JGM1w082BxPY0uakm72S7jIkltLAhu77m8ZhjjEO/GAovxcSJoODrDwxdqyeur35ngFjTckRbYIpHRXowzwz6S6KV7/RScpSDPWUIjrGPwoDX0JiHIVpejHPm47MTN7W0a+DadkcDQ8bs2Fv1mY0Q6THTGCb7nAnchU291ZgJtAWmtuzvKC85db6+WmQThXDt9jwPiY+psVZTFAwKIUFbsK7fRLqxxiGfmojeFYZxqc9O2c+V6dW4we4JLEvHZKWNPfH7CXpxt1v/kGtN0PsnE9GQ130QbJqIlrBWFSXHgPLrQ8O1ry2bSqwmmdqDLowm1/j8NG84GHaxucksOp78NCo0W8oWguNBwJ0zeVEJowL9Xy5UjoWtMG6aYTVgdZ0Sq8AxZ47xQuQoom1D93P7Kv+NyK4C4SBpdPuyqfEW8KHh1XGxN9GNeNq3fsDXG/t4B+GfQOBG1VouVU9sGw1WOQn03WTpT4aodkQQM4k5BL9nrnJFOxn9KFnqQFu06hnxRMVfSQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WbSYajFKPHpYoo1Q+stZDWQEPuVuIx/DCpN0lNDYRQ3S5Z6f4Q+jE9s2ncR1dDtr9rbeUSkfam/IHlVqu3PQfF2AHdBZUMGtbJWW5cWNlquKGSoE1X2d9hXk1xmScIfbx1SPkWnCG3VxCwDQBLyxFpM+R1Yj9EOHn3FwMxJp9QJrx2C1Rw86xW6Zo+PeK+mknkvq1E9QRscuz4D22xywa/MSfeytzOvCV2BT5RrP5VjmWwGvQiufjnhXLSKiAX6/FYB1wVFAdAx5uoiCnvOX7lc2R/GjN85OOS86xDFRBJul065YSb59fgZPWDbb4T41PXQnZuL5DWMV03K+J96RiqGAbumn0tpPv18PDAcAGmTE7x+XgaYg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ZKawf+RQbegLtxrSzb+1dXoXt5tGx1NRp+JQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff9bb2c8-8b07-4676-fe49-08da53353cb3 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 03:22:14.5803 (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: AM8PR01MB7962 Subject: [FFmpeg-devel] [PATCH 7/7] avformat/matroskaenc: Reuse dynamic buffer 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: /t9hRDg2ZPeT Avoids some allocations. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index acb50017b6..bfc397dbe6 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -222,7 +222,8 @@ typedef struct MatroskaMuxContext { * to write the length field of EBML Masters. * Every user has to reset the buffer after using it and * different uses may not overlap. It is currently used in - * mkv_write_tag(). */ + * mkv_write_tag(), in mkv_assemble_cues() as well as in + * mkv_update_codecprivate() and mkv_write_track(). */ AVIOContext *tmp_bc; AVPacket *cur_audio_pkt; @@ -941,17 +942,10 @@ static int mkv_add_cuepoint(MatroskaMuxContext *mkv, int stream, int64_t ts, return 0; } -static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp, +static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp, AVIOContext *cuepoint, const mkv_cues *cues, mkv_track *tracks, int num_tracks, uint64_t offset) { - AVIOContext *cuepoint; - int ret; - - ret = avio_open_dyn_buf(&cuepoint); - if (ret < 0) - return ret; - for (mkv_cuepoint *entry = cues->entries, *end = entry + cues->num_entries; entry < end;) { uint64_t pts = entry->pts; @@ -981,14 +975,13 @@ static int mkv_assemble_cues(AVStream **streams, AVIOContext *dyn_cp, end_ebml_master(cuepoint, track_positions); } while (++entry < end && entry->pts == pts); size = avio_get_dyn_buf(cuepoint, &buf); - if ((ret = cuepoint->error) < 0) - break; + if (cuepoint->error < 0) + return cuepoint->error; put_ebml_binary(dyn_cp, MATROSKA_ID_POINTENTRY, buf, size); ffio_reset_dyn_buf(cuepoint); } - ffio_free_dyn_buf(&cuepoint); - return ret; + return 0; } static int put_xiph_codecpriv(AVFormatContext *s, AVIOContext *pb, @@ -2964,7 +2957,7 @@ redo_cues: if (ret < 0) return ret; - ret = mkv_assemble_cues(s->streams, cues, &mkv->cues, + ret = mkv_assemble_cues(s->streams, cues, mkv->tmp_bc, &mkv->cues, mkv->tracks, s->nb_streams, offset); if (ret < 0) { ffio_free_dyn_buf(&cues);