From patchwork Sat Dec 1 19:28:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 11244 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5752A44D517 for ; Sat, 1 Dec 2018 21:31:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0097268A2DD; Sat, 1 Dec 2018 21:31:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC9DF68A2B8 for ; Sat, 1 Dec 2018 21:31:09 +0200 (EET) Received: by mail-wr1-f68.google.com with SMTP id x10so8334667wrs.8 for ; Sat, 01 Dec 2018 11:31:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eMbIEfEGXQKGTggUwwdeIWFShKqk6oYocaJ+kp0u86M=; b=Lw/vSXKnNbjMiFEoAZNNdNBj6gCVZ7v1mrM70BNwAzhaLqzYOZLbK6xBFNq3rUks9f oBagzq3AITOgHfBpTGe+gJ/HeVbSVABHyrsx8r4bucnU4PzIOWsOmt9aEelFLy6wG4hY 0sEsg28NiXEwFHu/K8SZ9Q2E+wQnIIyAUH71AYmz+zeqUilUj3hirqLZPB3buyBYC4DW 6geiSnoyO35yHfMILSmexus3PXaEaJFkPLWC92nbg1vjAewLhNLWq98cdDKi5QTz/YTe PyWGJf5c+8Q1koYJrgPreenseaMiJBuLdmJomEMVMm/h25lB829nMfaVevcjQBBLUORj YM4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eMbIEfEGXQKGTggUwwdeIWFShKqk6oYocaJ+kp0u86M=; b=W45uWyBDX62uTjWjMt4oPult5rrzEXmIbpXIvMmCyrfyO99+CLnrBXPBZOGjh+egHM 8kW6m6R8bG3oGMmZfe6Z64yIIad8tcwJenUCsQY71YLXQZIstwNStMQGRpPE1D6BvDHm ycINBH6gTm9/eR5Wu6/f+no6hGysXpxvXuVei7JU4wGjIBX/6h1CKcKy4ewUM3G6mV17 XLS7HB+rK4uEzPPuVUjGKcDjkM0U38HbkUgcpN5jNcMLdmmOTy25v8TPYCwYUIWxMkwx Sk5dWFU7vmTTPXyKD8C0/QK4Qv8iaZIzfy5q4YEHDjD4mdLLF6xfEFm9TnXd//8dzdsa CJVw== X-Gm-Message-State: AA+aEWaHZThul5lmPymARLQIlqXCNEe7q9z1yB/ZfaFj585llS4cJhmM NvJ2ATvobL1ZkgB1q0kXRJFiEE8M X-Google-Smtp-Source: AFSGD/XaDA1cXynAtrcq4JLjd8VA/FxrAWtARVI2XTMKHybT53NUq/XTNm7Aj1xwL/J/gRC4XgcJGQ== X-Received: by 2002:adf:eec9:: with SMTP id a9mr8647224wrp.242.1543692676055; Sat, 01 Dec 2018 11:31:16 -0800 (PST) Received: from localhost.localdomain (ipbcc08c44.dynamic.kabel-deutschland.de. [188.192.140.68]) by smtp.googlemail.com with ESMTPSA id 5sm5045686wmw.8.2018.12.01.11.31.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Dec 2018 11:31:15 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Dec 2018 20:28:06 +0100 Message-Id: <20181201192810.852-5-andreas.rheinhardt@googlemail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201192810.852-1-andreas.rheinhardt@googlemail.com> References: <20181201192810.852-1-andreas.rheinhardt@googlemail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] mpeg2_metadata: Additionally update AVCodecParameters X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Otherwise the muxer could add header data that is based on the old AVCodecParameters that contradicts and nullifies the modifications made to the bitstream. An option to revert to the old behaviour is included. The documentation has been updated to reflect the change. Signed-off-by: Andreas Rheinhardt --- doc/bitstream_filters.texi | 6 ++++++ libavcodec/mpeg2_metadata_bsf.c | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 80df345f26..a1558c5d69 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -487,6 +487,12 @@ table 6-6). Set the colour description in the stream (see H.262 section 6.3.6 and tables 6-7, 6-8 and 6-9). +@item full_update +If this is set, an effort is made to update the AVCodecParameters in addition +to the bitstream. If unset, muxers might add header information based upon +the old AVCodecParameters that contradicts and potentially precedes the +changes made at the bitstream level. On by default. + @end table @section mpeg4_unpack_bframes diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c index e787cb3782..e874f2fbb7 100644 --- a/libavcodec/mpeg2_metadata_bsf.c +++ b/libavcodec/mpeg2_metadata_bsf.c @@ -43,6 +43,8 @@ typedef struct MPEG2MetadataContext { int matrix_coefficients; int mpeg1_warned; + + int full_update; } MPEG2MetadataContext; @@ -253,6 +255,12 @@ static int mpeg2_metadata_init(AVBSFContext *bsf) } } + if (ctx->full_update) + ff_cbs_update_video_parameters(ctx->cbc, bsf->par_out, -1, -1, -1, + -1, -1, -1, ctx->colour_primaries, + ctx->transfer_characteristics, + ctx->matrix_coefficients, -1, -1); + err = 0; fail: ff_cbs_fragment_uninit(ctx->cbc, frag); @@ -289,6 +297,9 @@ static const AVOption mpeg2_metadata_options[] = { OFFSET(matrix_coefficients), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 255, FLAGS }, + { "full_update", "Update not only bitstream, but also AVCodecParameters", + OFFSET(full_update), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS}, + { NULL } };