From patchwork Wed Jun 19 23:45:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 13634 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 81728448AA5 for ; Thu, 20 Jun 2019 02:55:58 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 62F1168AAF0; Thu, 20 Jun 2019 02:55:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4DB2268AB40 for ; Thu, 20 Jun 2019 02:55:50 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id m3so1067672wrv.2 for ; Wed, 19 Jun 2019 16:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UBl1gzei5X0K3irhSXkP/dc86H7CAhVJ053+9Vcr9pg=; b=UL44plFTXQYwClXeWAcKgKLrpuoVxTka/iBTnVXwWTe2sONZJR6rIVaGPFrjA7ihmA kTLIN2BbXhUhZUS8REFVEwvbsmg6ovGJh8vq+KdQHwXP+j6cl0NFPB5U+KvfpMTmgUdN LuCUxw9xi/G3CksfIG39pWz4l56pLcYmjVe6+sgDshybAQoDqnR+IIFbDAc1XRPdNdmX fJPPVf8qZUuMDmNQO8iSzakgjjuX1L5TLmnd59QNQ1psffliDs8tpyMu3Px0nwUnoaZ3 knyjXWMOCTjwKPJtSAgdasYu99vdcbRybjchQeo/00TednCMC810AZbRHzJItzNDwTr4 9z+w== 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=UBl1gzei5X0K3irhSXkP/dc86H7CAhVJ053+9Vcr9pg=; b=sC5Ovq48vo021nZN2HW50A8JmLz4R4TG0ZpSyvEhl+WOGRTIYr8ny1ayb5gVwoKQJ7 AxepAKS/V5dn7U73UUxR20uSZqK0LUjR2zBsNdkYgcg6AGhlfMFmxfIhViwd9lfSeipR o7XE5iViQ5CDAwoLUbasmwCmiIwPmM9gqV6ThLDDqDuNKf2c7DYBSlfM4hx+2jBoyPHx Lt/VzBrfu/aZAeGPtEyQ5XfAcV8e2XU6sJhuSRyH+wjfrW+UiZcXiFmnL9a/4zSTc32B qOguzvJGkRiqaAOgK/uuyLzOQoOeGGuttXbOkd8W4XQHG1PZYI6IsxFXtW6FjIgFeCeB xl9w== X-Gm-Message-State: APjAAAX9VVRQ0v3vsmndzrwaoMRSKwr6aN7JI85Ndmmnhm0G5yEoW53a biPNv4SamonMB2+f7dwj4F+xWQMX X-Google-Smtp-Source: APXvYqwMVoEnYol5EPgc7yNQclPPWZskmNMTZrca1NJ1Kdolc0eMq/Xf7yjXBO5uFHBGy/0geRdXhw== X-Received: by 2002:a5d:4992:: with SMTP id r18mr2168993wrq.107.1560988549482; Wed, 19 Jun 2019 16:55:49 -0700 (PDT) Received: from localhost.localdomain (ipbcc063db.dynamic.kabel-deutschland.de. [188.192.99.219]) by smtp.gmail.com with ESMTPSA id t63sm2758989wmt.6.2019.06.19.16.55.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 16:55:48 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 20 Jun 2019 01:45:17 +0200 Message-Id: <20190619234521.15619-19-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190619234521.15619-1-andreas.rheinhardt@gmail.com> References: <20190617034223.21195-1-andreas.rheinhardt@gmail.com> <20190619234521.15619-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 27/31] 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 potentially 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 f625c8f768..e5ce7bc0a3 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -490,6 +490,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 3f371a028d..8396922979 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; @@ -249,6 +251,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_reset(ctx->cbc, frag); @@ -287,6 +295,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 } };