From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 4/4] avcodec/h2645_sei: add support for Ambient Viewing Environment SEI
Date: Tue, 10 Jan 2023 18:33:52 -0300
Message-ID: <37398597-0728-94e3-f614-fb978d5e7693@gmail.com> (raw)
In-Reply-To: <20230110211949.8195-4-jeebjp@gmail.com>
On 1/10/2023 6:19 PM, Jan Ekström wrote:
> Defined by H.274, this SEI message is utilized by iPhones to save
> the nominal ambient viewing environment for the display of recorded
> HDR content. The contents of the message are exposed to API users
> as AVFrame side data containing AVAmbientViewingEnvironment.
>
> As the DV RPU test sample is from an iPhone and includes Ambient
> Viewing Environment SEI messages, its test result gets updated.
> ---
> libavcodec/h2645_sei.c | 47 ++++++++++++++++++++++++++++++++++++++
> libavcodec/h2645_sei.h | 8 +++++++
> tests/ref/fate/hevc-dv-rpu | 12 ++++++++++
> 3 files changed, 67 insertions(+)
>
> diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
> index 3ff89e4fdd..5083079cb1 100644
> --- a/libavcodec/h2645_sei.c
> +++ b/libavcodec/h2645_sei.c
> @@ -25,6 +25,7 @@
>
> #include "config_components.h"
>
> +#include "libavutil/ambient_viewing_environment.h"
> #include "libavutil/display.h"
> #include "libavutil/film_grain_params.h"
> #include "libavutil/pixdesc.h"
> @@ -320,6 +321,31 @@ static int decode_alternative_transfer(H2645SEIAlternativeTransfer *s,
> return 0;
> }
>
> +static int decode_ambient_viewing_environment(H2645SEIAmbientViewingEnvironment *s,
> + GetByteContext *gb)
> +{
> + static const uint16_t max_ambient_light_value = 50000;
> +
> + if (bytestream2_get_bytes_left(gb) < 8)
> + return AVERROR_INVALIDDATA;
> +
> + s->ambient_illuminance = bytestream2_get_be32u(gb);
> + if (!s->ambient_illuminance)
> + return AVERROR_INVALIDDATA;
> +
> + s->ambient_light_x = bytestream2_get_be16u(gb);
> + if (s->ambient_light_x > max_ambient_light_value)
> + return AVERROR_INVALIDDATA;
> +
> + s->ambient_light_y = bytestream2_get_be16u(gb);
> + if (s->ambient_light_y > max_ambient_light_value)
> + return AVERROR_INVALIDDATA;
> +
> + s->present = 1;
> +
> + return 0;
> +}
> +
> static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h,
> enum AVCodecID codec_id, GetBitContext *gb)
> {
> @@ -383,6 +409,9 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
> return decode_frame_packing_arrangement(&h->frame_packing, gb, codec_id);
> case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
> return decode_alternative_transfer(&h->alternative_transfer, gbyte);
> + case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
> + return decode_ambient_viewing_environment(&h->ambient_viewing_environment,
> + gbyte);
> default:
> return FF_H2645_SEI_MESSAGE_UNHANDLED;
> }
> @@ -609,6 +638,20 @@ int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
> avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
> }
>
> + if (sei->ambient_viewing_environment.present) {
> + H2645SEIAmbientViewingEnvironment *env =
> + &sei->ambient_viewing_environment;
> +
> + AVAmbientViewingEnvironment *dst_env =
> + av_ambient_viewing_environment_create_side_data(frame);
> + if (!dst_env)
> + return AVERROR(ENOMEM);
> +
> + dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 10000);
> + dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 50000);
> + dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 50000);
> + }
> +
> return 0;
> }
>
> @@ -622,4 +665,8 @@ void ff_h2645_sei_reset(H2645SEI *s)
> av_freep(&s->unregistered.buf_ref);
> av_buffer_unref(&s->dynamic_hdr_plus.info);
> av_buffer_unref(&s->dynamic_hdr_vivid.info);
> +
> + s->ambient_viewing_environment = (H2645SEIAmbientViewingEnvironment){
> + .present = 0
This is unnecessarily zeroing the whole struct by extension. Just set
the one field alone.
> + };
> }
> diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
> index f3ee9af524..e07ae10376 100644
> --- a/libavcodec/h2645_sei.h
> +++ b/libavcodec/h2645_sei.h
> @@ -76,6 +76,13 @@ typedef struct H2645SEIAlternativeTransfer {
> int preferred_transfer_characteristics;
> } H2645SEIAlternativeTransfer;
>
> +typedef struct H2645SEIAmbientViewingEnvironment {
> + int present;
> + uint32_t ambient_illuminance;
> + uint16_t ambient_light_x;
> + uint16_t ambient_light_y;
> +} H2645SEIAmbientViewingEnvironment;
> +
> typedef struct H2645SEIFilmGrainCharacteristics {
> int present;
> int model_id;
> @@ -108,6 +115,7 @@ typedef struct H2645SEI {
> H2645SEIDisplayOrientation display_orientation;
> H2645SEIAlternativeTransfer alternative_transfer;
> H2645SEIFilmGrainCharacteristics film_grain_characteristics;
> + H2645SEIAmbientViewingEnvironment ambient_viewing_environment;
> } H2645SEI;
>
> enum {
> diff --git a/tests/ref/fate/hevc-dv-rpu b/tests/ref/fate/hevc-dv-rpu
> index 1980ab13ea..aaf0223eab 100644
> --- a/tests/ref/fate/hevc-dv-rpu
> +++ b/tests/ref/fate/hevc-dv-rpu
> @@ -3,6 +3,12 @@
> side_data_type=H.26[45] User Data Unregistered SEI message
> [/SIDE_DATA]
> [SIDE_DATA]
> +side_data_type=Ambient viewing environment
> +ambient_illuminance=3140000/10000
> +ambient_light_x=15635/50000
> +ambient_light_y=16450/50000
> +[/SIDE_DATA]
> +[SIDE_DATA]
> side_data_type=Dolby Vision RPU Data
> [/SIDE_DATA]
> [SIDE_DATA]
> @@ -120,6 +126,12 @@ source_diagonal=42
> [/FRAME]
> [FRAME]
> [SIDE_DATA]
> +side_data_type=Ambient viewing environment
> +ambient_illuminance=3140000/10000
> +ambient_light_x=15635/50000
> +ambient_light_y=16450/50000
> +[/SIDE_DATA]
> +[SIDE_DATA]
> side_data_type=Dolby Vision RPU Data
> [/SIDE_DATA]
> [SIDE_DATA]
LGTM.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2023-01-10 21:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: " Jan Ekström
2023-01-10 21:19 ` [FFmpeg-devel] [PATCH 2/4] avutil: introduce AVAmbientViewingEnvironment side data Jan Ekström
2023-01-10 21:25 ` James Almer
2023-01-10 21:19 ` [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames Jan Ekström
2023-01-10 21:35 ` James Almer
2023-01-14 20:03 ` Stefano Sabatini
2023-01-14 20:59 ` Jan Ekström
2023-01-15 1:14 ` Stefano Sabatini
2023-01-10 21:19 ` [FFmpeg-devel] [PATCH 4/4] avcodec/h2645_sei: add support for Ambient Viewing Environment SEI Jan Ekström
2023-01-10 21:33 ` James Almer [this message]
2023-01-10 21:34 ` [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: " James Almer
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 " Jan Ekström
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 2/4] avutil: introduce AVAmbientViewingEnvironment side data Jan Ekström
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames Jan Ekström
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 4/4] avcodec/h2645_sei: add support for Ambient Viewing Environment SEI Jan Ekström
2023-01-13 19:39 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/cbs_{h2645, sei}: " Jan Ekström
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=37398597-0728-94e3-f614-fb978d5e7693@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git