From patchwork Sat Dec 1 19:28:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 11245 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 9664644D517 for ; Sat, 1 Dec 2018 21:31:16 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 35DB868A319; Sat, 1 Dec 2018 21:31:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D06836801D9 for ; Sat, 1 Dec 2018 21:31:15 +0200 (EET) Received: by mail-wm1-f65.google.com with SMTP id y1so2052855wmi.3 for ; Sat, 01 Dec 2018 11:31:22 -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=8Cxa51rWYWonFnnHn/xApPGPT5QkVjSyiiT9YlcP/Ng=; b=UrYqBy/iVqKKkKEA+4HqGKW4wyOZpSC8yy9hR7y4Vbt3SoURFzYOvanp10kFGQWo4n thF1Z24hdenc/J8j8Nd8Cp71tlDfIer7Al1zwexu70VWmVrdF3alJzkQIaGzzqbxDyJ/ cQG3lhMSw8cizo5odfCNNbtH9BYghm6x6B6SAGxVguSG3e56T9lgdM88Kp8jEHxN3d9S YVlE9/z1KfBuRH+euGZchdT7Gm8R5/RId2pOYxIpzJFqKU9jSIScCiZkcjZl+JbjcsvD d1Zrx/VlSLGxlOymAV5J9iV5TvxTvpkt1DFVrWylrD1BqOJVHnA6W2kqGIzV1B9Wlqlr z6NQ== 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=8Cxa51rWYWonFnnHn/xApPGPT5QkVjSyiiT9YlcP/Ng=; b=npeOmx7HxVwKURpPxOSvw87/cysZG53iCXy7QdkHS3RA9RHxsQQXEC/h/iKjTk5ZqA R6le7Q/2+uoKQLG6ScBfwrHW41khoTnYjLWi9y0/xNIAHkIz5kiZdFH5Gnv+H9oHKYQF 0kn3TgVRsRHkOcH23kqbYlWobGazWMguW4RuqWVbJRfxIQUfYI2lCAduUz2qYpjpE0ur 6dTDo5O00+fj/LESi5go3lmKZ1PtzQ15sgs+ycnAv29nAyEhr8iTKwNWXy9bDPk124Tm k/vgTdcfT3o5TpfT9Wm81Ejgtp5IfByM+R5GHFWqrkjrxISW9cg7Hiwom8MqN0wekzct EYuw== X-Gm-Message-State: AA+aEWYxzXbSHVDXHKe2SqOdjxxMLLCeaFuMR2Y3TWQhsi4mDjNT+6aw SA2Kd9tachWB3cQMijePnWuQEbNn X-Google-Smtp-Source: AFSGD/VEFnqBbZfHbtPJBOl6Gk57umNDIvPilXRpc8vUjeuWeSb5HJa3X38jj3V5caR628tb7gT5GA== X-Received: by 2002:a1c:85d2:: with SMTP id h201mr2835464wmd.151.1543692681772; Sat, 01 Dec 2018 11:31:21 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Dec 2018 11:31:21 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sat, 1 Dec 2018 20:28:08 +0100 Message-Id: <20181201192810.852-7-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 6/8] vp9_metadata: 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" This commit adds an option to not only update the bitstream parameters when using the vp9_metadata bitstream filter, but also the relevant AVCodecParameters. The new option is on by default. This commit also adds documentation for this value. Signed-off-by: Andreas Rheinhardt --- doc/bitstream_filters.texi | 15 ++++++++++----- libavcodec/vp9_metadata_bsf.c | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 7ab535b58c..f5bf4aa93e 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -656,9 +656,7 @@ Modify metadata embedded in a VP9 stream. @table @option @item color_space -Set the color space value in the frame header. Note that any frame -set to RGB will be implicitly set to PC range and that RGB is -incompatible with profiles 0 and 2. +Set the color space value in the frame header. @table @samp @item unknown @item bt601 @@ -670,12 +668,19 @@ incompatible with profiles 0 and 2. @end table @item color_range -Set the color range value in the frame header. Note that any value -imposed by the color space will take precedence over this value. +Set the color range value in the frame header. Note that this cannot +be set in RGB streams. @table @samp @item tv @item pc @end table + +@item full_update +If this is set, the AVCodecParameters are updated 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 vp9_superframe diff --git a/libavcodec/vp9_metadata_bsf.c b/libavcodec/vp9_metadata_bsf.c index 9170083c06..1b03a4dea4 100644 --- a/libavcodec/vp9_metadata_bsf.c +++ b/libavcodec/vp9_metadata_bsf.c @@ -34,6 +34,8 @@ typedef struct VP9MetadataContext { int color_range; int color_warnings; + + int full_update; } VP9MetadataContext; @@ -115,6 +117,22 @@ static int vp9_metadata_init(AVBSFContext *bsf) { VP9MetadataContext *ctx = bsf->priv_data; + if (ctx->full_update) { + AVCodecParameters *par = bsf->par_out; + static const enum AVColorSpace colorspaces[] = { + AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, AVCOL_SPC_SMPTE170M, + AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB + }; + + if (ctx->color_space >= 0 && (ctx->color_space != VP9_CS_RGB || par->profile & 1)) + par->color_space = colorspaces[ctx->color_space]; + + if (par->color_space == AVCOL_SPC_RGB) + par->color_range = AVCOL_RANGE_JPEG; + else if (ctx->color_range >= 0) + par->color_range = ctx->color_range + 1; + } + return ff_cbs_init(&ctx->cbc, AV_CODEC_ID_VP9, bsf); } @@ -153,6 +171,9 @@ static const AVOption vp9_metadata_options[] = { { "pc", "PC (full) range", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .flags = FLAGS, .unit = "cr" }, + { "full_update", "Update not only bitstream, but also AVCodecParameters", + OFFSET(full_update), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS}, + { NULL } };