From patchwork Tue Aug 8 14:36:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vittorio Giovara X-Patchwork-Id: 4655 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.46.211 with SMTP id u202csp4335102vsu; Tue, 8 Aug 2017 07:37:01 -0700 (PDT) X-Received: by 10.223.166.162 with SMTP id t31mr2957376wrc.52.1502203021655; Tue, 08 Aug 2017 07:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502203021; cv=none; d=google.com; s=arc-20160816; b=fav0n3UiRIuSVV4znjcEYZgxZji0TIQNQt19wFBVYxATeN9qvgeAcbWcVloeAmCob+ aStFKJgROXxHSwY6daXbcqf9FvfjO0c9p2m+d0y7jZwE93BVAbKLZwG2gkpOKjM5AXIT 0PRsaeJEPpBhAfl7BCUuKrKbUJ3B0i1zWr2kqRWo5+5yuxeZ1NBQqu5jncpC3npnil5u 3VTt/0ZK96+WvMHfHgLa6E811XaGVNEsc+wqYKZC4G2x0eaMADMXQAqpvVYXwyflaAnC FMcyzO2MkWcdMrQ/cJ9PhzO7qTE/LM8H8gdM4ToyzmzBzITHBZ6xtEE3HtFU4PtnF8O2 4vBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=Tnl/Wl9i4+6MjpMKbbjaw1QpYJ6pDyW69NgmCV6a4bU=; b=wp7B6GQZbuzweLAwJEbuxkUTPk77bRFfejHxgd/qeu6XI0jbfUC4tYCFG2kLo6e/X2 BV3ySwnLs7VBUL9HAffZEV4xKYvkY1WrmTDO3oB0dbHkY6PS4OFunMrX9JFe8QUE8B0a TeXTxAUbOVQShQulpzmg192LtQxvwxh2miw9chE9FBhuglZevox5yDlLwHqOoFcaDC8R KgcYPUl+S4YvPHFzL2RgR1ZCroFvJYi21rIkTpi6eukMIW98h29FdChsdbyAatNtl9ud MamW2U8ykidrO5tO0wfAxICuNWsC1frSqYBdtqGABqPur107CU7Ijk4bU2/qIy7af23z ECZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=uXCKF2tJ; 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=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p18si1312673wma.33.2017.08.08.07.37.01; Tue, 08 Aug 2017 07:37:01 -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=@gmail.com header.s=20161025 header.b=uXCKF2tJ; 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=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4CCB568799F; Tue, 8 Aug 2017 17:36:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 97969680957 for ; Tue, 8 Aug 2017 17:36:49 +0300 (EEST) Received: by mail-qk0-f196.google.com with SMTP id m84so3258106qki.5 for ; Tue, 08 Aug 2017 07:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=wIN1Lnhls9gag+d/NaJ4P0xnmmtvIB5XVWF0cKfDn+A=; b=uXCKF2tJLwNoOFgx0K5tfem+5pX8ICltuydi4rwqf2bqZFclH/enxODQLPQKhQA5RJ pY1IT6VR58SqmHqOzZfEVtmWnyyZXf6DeEzDGBmPrgB11/TNzHaD493cvXyKRnj56Ts2 bmWjapTdR1swody8KSGES025slHSfPU0eF7f1HUMMrXCQLDN+nx6+IS1FeLnct+moj1u yEKLg8I4klsyNcBPCMckMnSWaEvo3afoGWgUSpvej1Y+kXHVwyvZDb35RuF1K9BA2KDh IrytbDf9v+U7VDOWTlFqKJAT4yB/tSV5QTZLlx455MY6udoMEAj3YUHO5j5qZMvlcwUZ +SWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=wIN1Lnhls9gag+d/NaJ4P0xnmmtvIB5XVWF0cKfDn+A=; b=QMGzFTyy8zzIKdj6q9fq0qX+C/HwLp3sdBTrA41vHfmZVIxfYgZ42j4BpXacWX9L8w yhU356aq/0x/l9ZyQObuI4tP/orrMA2zQSEvaZL04kM92Vy5W7mtrxrr0p4u77Vz1al/ 7w63gLAR6sV09paF20t8VB3+dUDiCw2RIjbUJ24etO2hp/vnFBp1i8BMtQN/cA4nHN6L j3hj15fw9xA1QNaw7S5NUIRnMnoXjaJOr0uUgFMs/91Sms9VWerd018hPEydceigPST5 VMIbM/tWtYY1LWsEHxOXaGC5rRx8HhaLx7kSxju2IpLEQpZmZeM4VZLaZMgvK480FWnH Ri0A== X-Gm-Message-State: AHYfb5hV0s66jXYhEfKgV3u2ED8kHcYU7xzkhYgmMFB8K7tS+DkUEzfU h1QoL2fstbzr3kRa X-Received: by 10.55.7.139 with SMTP id 133mr5478502qkh.165.1502203010299; Tue, 08 Aug 2017 07:36:50 -0700 (PDT) Received: from vimacbookpro.vimeo.iac.corp ([151.38.130.27]) by smtp.gmail.com with ESMTPSA id a27sm743821qtd.22.2017.08.08.07.36.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Aug 2017 07:36:49 -0700 (PDT) From: Vittorio Giovara To: ffmpeg-devel@ffmpeg.org Date: Tue, 8 Aug 2017 16:36:47 +0200 Message-Id: <20170808143647.11777-1-vittorio.giovara@gmail.com> X-Mailer: git-send-email 2.13.2 Subject: [FFmpeg-devel] [PATCH] h264: Add support for alternative transfer characterics SEI 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The use of this SEI is for backward compatibility in HLG HDR systems: older devices that cannot interpret the "arib-std-b67" transfer will get the compatible transfer (usually bt709 or bt2020) from the VUI, while newer devices that can interpret HDR will read the SEI and use its value instead. Signed-off-by: Vittorio Giovara --- libavcodec/h264_sei.c | 11 +++++++++++ libavcodec/h264_sei.h | 9 ++++++++- libavcodec/h264_slice.c | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index a7e627eba3..889bea2ee0 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -382,6 +382,14 @@ static int decode_green_metadata(H264SEIGreenMetaData *h, GetBitContext *gb) return 0; } +static int decode_alternative_transfer(H264SEIAlternativeTransfer *h, + GetBitContext *gb) +{ + h->present = 1; + h->preferred_transfer_characteristics = get_bits(gb, 8); + return 0; +} + int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, const H264ParamSets *ps, void *logctx) { @@ -437,6 +445,9 @@ int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, case SEI_TYPE_GREEN_METADATA: ret = decode_green_metadata(&h->green_metadata, gb); break; + case SEI_TYPE_ALTERNATIVE_TRANSFER: + ret = decode_alternative_transfer(&h->alternative_transfer, gb); + break; default: av_log(logctx, AV_LOG_DEBUG, "unknown SEI type %d\n", type); } diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index da3b391860..5f5d895e89 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -32,7 +32,8 @@ typedef enum { SEI_TYPE_RECOVERY_POINT = 6, ///< recovery point (frame # to decoder sync) SEI_TYPE_FRAME_PACKING = 45, ///< frame packing arrangement SEI_TYPE_DISPLAY_ORIENTATION = 47, ///< display orientation - SEI_TYPE_GREEN_METADATA = 56 ///< GreenMPEG information + SEI_TYPE_GREEN_METADATA = 56, ///< GreenMPEG information + SEI_TYPE_ALTERNATIVE_TRANSFER = 147, ///< alternative transfer } SEI_Type; /** @@ -144,6 +145,11 @@ typedef struct H264SEIGreenMetaData { uint16_t xsd_metric_value; } H264SEIGreenMetaData; +typedef struct H264SEIAlternativeTransfer { + int present; + int preferred_transfer_characteristics; +} H264SEIAlternativeTransfer; + typedef struct H264SEIContext { H264SEIPictureTiming picture_timing; H264SEIAFD afd; @@ -154,6 +160,7 @@ typedef struct H264SEIContext { H264SEIFramePacking frame_packing; H264SEIDisplayOrientation display_orientation; H264SEIGreenMetaData green_metadata; + H264SEIAlternativeTransfer alternative_transfer; } H264SEIContext; struct H264ParamSets; diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 4e7eba4adb..ebff7b33e3 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1287,6 +1287,12 @@ static int h264_export_frame_props(H264Context *h) h->avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; } + if (h->sei.alternative_transfer.present && + av_color_transfer_name(h->sei.alternative_transfer.preferred_transfer_characteristics) && + h->sei.alternative_transfer.preferred_transfer_characteristics != AVCOL_TRC_UNSPECIFIED) { + h->avctx->color_trc = cur->f->color_trc = h->sei.alternative_transfer.preferred_transfer_characteristics; + } + return 0; }