From patchwork Sun Feb 21 19:51:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 25879 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 B658A44A325 for ; Sun, 21 Feb 2021 21:56:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 795C468A846; Sun, 21 Feb 2021 21:53:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BFF9068A8E2 for ; Sun, 21 Feb 2021 21:53:38 +0200 (EET) Received: by mail-wr1-f45.google.com with SMTP id v14so16892706wro.7 for ; Sun, 21 Feb 2021 11:53:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W7ndWcExdP5tgseH7GKoA2hosE9QcgGDABUWcwJ4fRQ=; b=srEI8/R/C/LM3MuoDZvtdramwzTmhc8Yx0MnsjWLdt99MBmCKEnpz6X5Jw9+Ns7YcM Xe7AaTd6asAqQwNOEacnrpK/wRw/ga3c7e/HPsGwXhRsejsd1WV/DbZG1I1CoWjSknFN yVCcyvhN3YBjfZQffuhmFEGgwbdMPOh2wZHmcO9xgdmanLPbWXotfKMIkpgR1poDnNeA StLychrkj1VbLxRsnTTiRnBDtFVxucrYBqho5oLtKAno3cJiDhxEj4OchIEWypSGHdiB MW/sirDEF6jKNpI3j6+sm/pqIvLIH0X+HFTEso83QznptEYxeucQrHJGpGiS0O5UZ8qn yCtQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=W7ndWcExdP5tgseH7GKoA2hosE9QcgGDABUWcwJ4fRQ=; b=n7Z3xgLiP/nDg7E4Bm8jzSgj6MPfVDMknBil44jyB9/S0ipKKoK+BKY5IdkLYIhRCn +cMtSG4z9XonOXKN0+RmvIjT+oK6mNnsW3Zx4cwHa7oR99C5tWb0A8xZSO1z8uBKjMM+ SXL7mk8fzh2ACy027cRPrtTVDBTGJzwvvAeC05MAC5vVYyRrLbqVUT7b+tmms8CIHz1J 0ICaJgfEnKnxN4DRPk0I2D+0aUcMLhl5gnzknJwgMFd+mjtVdF0tBsorJqZzQQ/yln6Z vIC+WGa9+yKQ0FHU/Qwp2hyyDVzyJ46jw8nhSPrdAZx/VZeZO6cyUoJ/NRQnu/PsOl4m YQAA== X-Gm-Message-State: AOAM5305+jMY20nH5grALg3Z+vWBRIyZbIC3R5tFrCgaCdEgomyCh6x9 9m9csiimwYMzQtSsoPk3ykDT8By0+vjH5g== X-Google-Smtp-Source: ABdhPJzPu6LEYqtLE76wsjWdbq+FXnxXqNzDsBePeAwAgN7s8HJWqU5RFdk0QPAWTTHLsbn9pZ1bEA== X-Received: by 2002:a5d:6b47:: with SMTP id x7mr18859431wrw.170.1613937218327; Sun, 21 Feb 2021 11:53:38 -0800 (PST) Received: from localhost.localdomain (cpc91226-cmbg18-2-0-cust7.5-4.cable.virginm.net. [82.0.29.8]) by smtp.gmail.com with ESMTPSA id z18sm1780372wrs.19.2021.02.21.11.53.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 11:53:37 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Sun, 21 Feb 2021 19:51:19 +0000 Message-Id: <20210221195125.1901683-12-sw@jkqxz.net> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221195125.1901683-1-sw@jkqxz.net> References: <20210221195125.1901683-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 12/18] h264_metadata_bsf: Support HDR metadata 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- doc/bitstream_filters.texi | 17 +++++++++++++++++ libavcodec/h264_metadata_bsf.c | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 60e729484d..0ff76b86f0 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -285,6 +285,23 @@ level_idc value (for example, @samp{42}), or the special name @samp{auto} indicating that the filter should attempt to guess the level from the input stream properties. +@item mastering_display +@item content_light_level +Manipulate mastering display colour volume (see H.264 section D.2.29) +and content light level info (see H.264 section D.2.31) SEI messages in +the stream. + +Possible actions: +@table @samp +@item insert +Insert this type of message, taking the values from packet side-data. +@item remove +Remove all instances of this message. +@item extract +Extract the content of this type of message, attaching it to the packets +as side-data. +@end table + @end table @section h264_mp4toannexb diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 6511c4b776..069d65432e 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -78,6 +78,9 @@ typedef struct H264MetadataContext { int flip; int level; + + int mastering_display; + int content_light_level; } H264MetadataContext; @@ -449,6 +452,20 @@ static int h264_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt, return err; } + if (pkt) { + err = ff_cbs_bsf_apply_metadata(bsf, pkt, au, + CBS_METADATA_MASTERING_DISPLAY, + ctx->mastering_display); + if (err < 0) + return err; + + err = ff_cbs_bsf_apply_metadata(bsf, pkt, au, + CBS_METADATA_CONTENT_LIGHT_LEVEL, + ctx->content_light_level); + if (err < 0) + return err; + } + if (pkt) ctx->done_first_au = 1; @@ -609,6 +626,14 @@ static const AVOption h264_metadata_options[] = { { LEVEL("6.2", 62) }, #undef LEVEL + BSF_ELEMENT_OPTIONS_PIRE("mastering_display", + "Mastering display colour volume SEI", + mastering_display, FLAGS), + + BSF_ELEMENT_OPTIONS_PIRE("content_light_level", + "Content light level information SEI", + content_light_level, FLAGS), + { NULL } };