From patchwork Wed Apr 3 15:43:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 47752 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9f96:b0:1a3:b6bb:3029 with SMTP id mm22csp485123pzb; Wed, 3 Apr 2024 08:43:45 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV5ceht81wqVKb1B4etXTfxsmwDw/wWJUEibTr3pHncg3VxVx7MngMJz4Ix+RxPFRzx26hZgrxlO9LhzbOUJFwel16I3YEtwSs7cw== X-Google-Smtp-Source: AGHT+IHtwayxhuLiP4p13jOrwTzJY3WDe4Pksimw7dW+LCdz7nx3KynvsB+GLNOdONwqG1kBCJht X-Received: by 2002:ac2:5208:0:b0:516:a1f8:8283 with SMTP id a8-20020ac25208000000b00516a1f88283mr6219200lfl.2.1712159025131; Wed, 03 Apr 2024 08:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712159025; cv=none; d=google.com; s=arc-20160816; b=Kw1m0bVMyZDMDrGPo1fMHmeJotHdncW/2G0JM5QD6b/71GndJnuD/2N9UreJVpL6Ll DweHE1iYnpy9X3u0Jdp3VaLEdYmLR+Lf2ZnQ86ybWZiwAWR6ChCt4drB0Xr5/Euz73y+ Hi2v6C8TixjAipkgbT7aVcDUeALOkTapmX93AuDt4HwonVlQdQ5EQwW/HQLLYBTCkoKG L4UUPb2ACTlpAeY4ZM7a+l/hk66+6IqxBRKZKYPNfHPuLsYNW1vkfloT/lZwCVblGyZ8 F+V2Qd5GIwXuW0wE2v8sg4fBIM91NJ7YzY5nj4Yc6tvrcsS8u5YVlRoSEOQ2/NTPB3Gw YjTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=uCRt+NWneDE6PNGYVIYRo70Cb5zSVVRw45gdMKhiM9c=; fh=xmAeKtysnShNOmkhiJmYkS30uw4Fu2hvBJ7qlIwukxQ=; b=mm400wTa85654QYUmqA7vztlfnaf3tVjT6idCadPSmQLy6ykp/ONpgXHEeWZVIv88a 0lIXSU2/D7U+6QQrZKu2KjBEZoQn7+9KEazjBE2PKMFqSfbHXjQYThXRF0JYwnwHoDzk +OX5EfGJlkNorQeYflpS1WR91UVg4+X6bK8gmNtWTS0pke/UdPzyqE9AhdFzot9p3u04 wnqoZXMhKhpLKvP6TOwBBapTdmTi2IiDHyVvt3V+3rtLcBuWj3zkTB/FBWk4Bhd969rg BFLZuaQklzv88ofxRBnDD5trUUy4vNeUbqvmfmzC5HAQ/Yyl8b5a56JuInV5g84ILXau LnlQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b="uY/3Bg7s"; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fj19-20020a0564022b9300b0056dc938aad5si4243023edb.117.2024.04.03.08.43.43; Wed, 03 Apr 2024 08:43:45 -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=@haasn.xyz header.s=mail header.b="uY/3Bg7s"; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 83DA968D15F; Wed, 3 Apr 2024 18:43:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AA3AE68CE36 for ; Wed, 3 Apr 2024 18:43:33 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1712159013; bh=EtLIoShw5LrbqC2ir/+8zb4HM0lyOrhoxavuBMN1nkw=; h=From:To:Cc:Subject:Date:From; b=uY/3Bg7s+cCK7gG8rPxVgmlK/g4AXrXICC3kPX9NjjZMhosS0fFGwMDIJ0UOhUxq/ c/ENzCvdzuBTN0Wj5/Kpyk6TJ6Kfa4GeIMYDYMSgKao0cxcwCywTwOIv+gFKWapNGo GSObDKFHYMjcw+SzY5cjj3RpiZkpWYI57gxgds1w= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 742C04105D; Wed, 3 Apr 2024 17:43:33 +0200 (CEST) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Wed, 3 Apr 2024 17:43:21 +0200 Message-ID: <20240403154330.71585-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10] avcodec: add dolbyvision option X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: J3AA7MjeFbmo From: Niklas Haas Tri-state yes/no/auto option. Allows users to set `dolbyvision` to `no` to suppress coding dolby vision even when supported by the target codec. --- doc/APIchanges | 3 +++ doc/codecs.texi | 12 ++++++++++++ libavcodec/avcodec.h | 11 +++++++++++ libavcodec/options_table.h | 2 ++ libavcodec/version.h | 2 +- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7eda1321cb0..a4484ceb670 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2024-03-23 - f17e18d2922 - lavc 61.6.100 - avcodec.h + Add AVCodecContext.dolbyvision option. + 2024-04-xx - xxxxxxxxxx - lavu 59.12.100 - dovi_meta.h Add AVDOVIMetadata.ext_block_{offset,size}, AVDOVIMetadata.num_ext_blocks, AVDOVIDmData and AVDOVIDmLevel{1..6,8..11,254..255}, av_dovi_get_ext() diff --git a/doc/codecs.texi b/doc/codecs.texi index 6bdeb664e72..7203adc0489 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -1018,6 +1018,18 @@ Note: The required alignment depends on if @code{AV_CODEC_FLAG_UNALIGNED} is set CPU. @code{AV_CODEC_FLAG_UNALIGNED} cannot be changed from the command line. Also hardware decoders will not apply left/top Cropping. +@item dolbyvision @var{integer} (@emph{encoding,video}) +Whether to encode Dolby Vision metadata when transcoding. +Possible values: +@table @samp +@item auto +Enable when coded frames contain Dolby Vision side data (default) +@item yes/on +Enable always, error out when frames do not contain metadata +@item no/off +Disable always, strip any tagged metadata +@end table + @end table diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 83dc487251c..f54f758608d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2075,6 +2075,17 @@ typedef struct AVCodecContext { */ AVFrameSideData **decoded_side_data; int nb_decoded_side_data; + + /** + * Video encoding only. Whether to mark the coded stream as Dolby Vision. + * If set to FF_DOLBYVISION_AUTO, this will be enabled only if + * decoded_side_data contains a valid RPU. + * + * If enabled, sending frames without AV_FRAME_DATA_DOVI_METADATA is + * considered an error. + */ + int dolbyvision; +#define FF_DOLBYVISION_AUTO -1 } AVCodecContext; /** diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 7a2ef3474e7..d92269d2ff7 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -407,6 +407,8 @@ static const AVOption avcodec_options[] = { {"mastering_display_metadata", .default_val.i64 = AV_PKT_DATA_MASTERING_DISPLAY_METADATA, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, {"content_light_level", .default_val.i64 = AV_PKT_DATA_CONTENT_LIGHT_LEVEL, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, {"icc_profile", .default_val.i64 = AV_PKT_DATA_ICC_PROFILE, .type = AV_OPT_TYPE_CONST, .flags = A|D, .unit = "side_data_pkt" }, +{"dolbyvision", "flag stream as Dolby Vision", OFFSET(dolbyvision), AV_OPT_TYPE_INT, {.i64 = FF_DOLBYVISION_AUTO }, -1, 1, V|E, .unit = "dolbyvision" }, +{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_DOLBYVISION_AUTO }, .flags = V|E, .unit = "dolbyvision" }, {NULL}, }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 7aa95fc3f1c..da54f878874 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 5 +#define LIBAVCODEC_VERSION_MINOR 6 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \