* [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI
@ 2023-01-10 21:19 Jan Ekström
2023-01-10 21:19 ` [FFmpeg-devel] [PATCH 2/4] avutil: introduce AVAmbientViewingEnvironment side data Jan Ekström
` (4 more replies)
0 siblings, 5 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-10 21:19 UTC (permalink / raw)
To: ffmpeg-devel
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.
---
libavcodec/cbs_h2645.c | 6 ++++++
libavcodec/cbs_sei.h | 6 ++++++
libavcodec/cbs_sei_syntax_template.c | 17 +++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 4ee06003c3..80e48829af 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1500,6 +1500,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
sizeof(SEIRawAlternativeTransferCharacteristics),
SEI_MESSAGE_RW(sei, alternative_transfer_characteristics),
},
+ {
+ SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT,
+ 1, 0,
+ sizeof(SEIRawAmbientViewingEnvironment),
+ SEI_MESSAGE_RW(sei, ambient_viewing_environment),
+ },
SEI_MESSAGE_TYPE_END,
};
diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index c7a7a95be0..1c327a4689 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -65,6 +65,12 @@ typedef struct SEIRawAlternativeTransferCharacteristics {
uint8_t preferred_transfer_characteristics;
} SEIRawAlternativeTransferCharacteristics;
+typedef struct SEIRawAmbientViewingEnvironment {
+ uint32_t ambient_illuminance;
+ uint16_t ambient_light_x;
+ uint16_t ambient_light_y;
+} SEIRawAmbientViewingEnvironment;
+
typedef struct SEIRawMessage {
uint32_t payload_type;
uint32_t payload_size;
diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c
index 0ef7b42ed9..6a7cc36dda 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -144,6 +144,23 @@ static int FUNC(alternative_transfer_characteristics)
return 0;
}
+static int FUNC(ambient_viewing_environment)
+ (CodedBitstreamContext *ctx, RWContext *rw,
+ SEIRawAmbientViewingEnvironment *current,
+ SEIMessageState *state)
+{
+ static const uint16_t max_ambient_light_value = 50000;
+ int err;
+
+ HEADER("Ambient Viewing Environment");
+
+ u(32, ambient_illuminance, 1, MAX_UINT_BITS(32));
+ u(16, ambient_light_x, 0, max_ambient_light_value);
+ u(16, ambient_light_y, 0, max_ambient_light_value);
+
+ return 0;
+}
+
static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw,
SEIRawMessage *current)
{
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 2/4] avutil: introduce AVAmbientViewingEnvironment side data
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI Jan Ekström
@ 2023-01-10 21:19 ` 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
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Jan Ekström @ 2023-01-10 21:19 UTC (permalink / raw)
To: ffmpeg-devel
This enables exposing H.274 Ambient Viewing Environment
metadata in the framework.
---
doc/APIchanges | 6 +++
libavutil/Makefile | 2 +
libavutil/ambient_viewing_environment.c | 51 ++++++++++++++++++
libavutil/ambient_viewing_environment.h | 72 +++++++++++++++++++++++++
libavutil/frame.c | 1 +
libavutil/frame.h | 5 ++
libavutil/version.h | 2 +-
7 files changed, 138 insertions(+), 1 deletion(-)
create mode 100644 libavutil/ambient_viewing_environment.c
create mode 100644 libavutil/ambient_viewing_environment.h
diff --git a/doc/APIchanges b/doc/APIchanges
index 328028f293..f13b4f1149 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,12 @@ libavutil: 2021-04-27
API changes, most recent first:
+2023-01-10 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h
+ Adds a new structure for holding H.274 Ambient Viewing Environment metadata,
+ AVAmbientViewingEnvironment.
+ Adds a new AVFrameSideDataType entry AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
+ for it.
+
2022-12-xx - xxxxxxxxxx - lavc 59.55.100 - avcodec.h
Add AV_HWACCEL_FLAG_UNSAFE_OUTPUT.
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 3d9c07aea8..29b06665f5 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -4,6 +4,7 @@ DESC = FFmpeg utility library
HEADERS = adler32.h \
aes.h \
aes_ctr.h \
+ ambient_viewing_environment.h \
attributes.h \
audio_fifo.h \
avassert.h \
@@ -102,6 +103,7 @@ BUILT_HEADERS = avconfig.h \
OBJS = adler32.o \
aes.o \
aes_ctr.o \
+ ambient_viewing_environment.o \
audio_fifo.o \
avstring.o \
avsscanf.o \
diff --git a/libavutil/ambient_viewing_environment.c b/libavutil/ambient_viewing_environment.c
new file mode 100644
index 0000000000..e7d150796e
--- /dev/null
+++ b/libavutil/ambient_viewing_environment.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stddef.h>
+#include "ambient_viewing_environment.h"
+#include "frame.h"
+#include "mem.h"
+
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size)
+{
+ AVAmbientViewingEnvironment *env =
+ av_mallocz(sizeof(AVAmbientViewingEnvironment));
+ if (!env)
+ return NULL;
+
+ if (size)
+ *size = sizeof(*env);
+
+ return env;
+}
+
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame)
+{
+ AVFrameSideData *side_data =
+ av_frame_new_side_data(frame,
+ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
+ sizeof(AVAmbientViewingEnvironment));
+ if (!side_data)
+ return NULL;
+
+ memset(side_data->data, 0, side_data->size);
+
+ return (AVAmbientViewingEnvironment *)side_data->data;
+}
diff --git a/libavutil/ambient_viewing_environment.h b/libavutil/ambient_viewing_environment.h
new file mode 100644
index 0000000000..e5e4ac2173
--- /dev/null
+++ b/libavutil/ambient_viewing_environment.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
+#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
+
+#include <stddef.h>
+#include "frame.h"
+#include "rational.h"
+
+/**
+ * Ambient viewing environment metadata as defined by H.274. The values are
+ * saved in AVRationals so that they keep their exactness, while allowing for
+ * easy access to a double value with f.ex. av_q2d.
+ *
+ * @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and
+ * it must be allocated using av_ambient_viewing_environment_alloc.
+ */
+typedef struct AVAmbientViewingEnvironment {
+ /**
+ * Environmental illuminance of the ambient viewing environment in lux.
+ */
+ AVRational ambient_illuminance;
+
+ /**
+ * Normalized x chromaticity coordinate of the environmental ambient light
+ * in the nominal viewing environment according to the CIE 1931 definition
+ * of x and y as specified in ISO/CIE 11664-1.
+ */
+ AVRational ambient_light_x;
+
+ /**
+ * Normalized y chromaticity coordinate of the environmental ambient light
+ * in the nominal viewing environment according to the CIE 1931 definition
+ * of x and y as specified in ISO/CIE 11664-1.
+ */
+ AVRational ambient_light_y;
+} AVAmbientViewingEnvironment;
+
+/**
+ * Allocate an AVAmbientViewingEnvironment structure.
+ *
+ * @return the newly allocated struct or NULL on failure
+ */
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size);
+
+/**
+ * Allocate and add an AVAmbientViewingEnvironment structure to an existing
+ * AVFrame as side data.
+ *
+ * @return the newly allocated struct, or NULL on failure
+ */
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame);
+
+#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */
diff --git a/libavutil/frame.c b/libavutil/frame.c
index de4ad1f94d..fa9b11aa54 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -831,6 +831,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
case AV_FRAME_DATA_DETECTION_BBOXES: return "Bounding boxes for object detection and classification";
case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data";
case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata";
+ case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment";
}
return NULL;
}
diff --git a/libavutil/frame.h b/libavutil/frame.h
index e60a82f6c0..bbe909ee2d 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -209,6 +209,11 @@ enum AVFrameSideDataType {
* volume transform - CUVA 005.1-2021.
*/
AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
+
+ /**
+ * Ambient viewing environment metadata, as defined by H.274.
+ */
+ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
};
enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index 3b616ea489..60f96af5df 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 57
-#define LIBAVUTIL_VERSION_MINOR 43
+#define LIBAVUTIL_VERSION_MINOR 44
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment 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:19 ` Jan Ekström
2023-01-10 21:35 ` James Almer
2023-01-14 20:03 ` 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
` (2 subsequent siblings)
4 siblings, 2 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-10 21:19 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffprobe.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index d2f126d9d6..15c61e1c7c 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -33,6 +33,7 @@
#include "libavformat/version.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/version.h"
+#include "libavutil/ambient_viewing_environment.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
@@ -2268,6 +2269,17 @@ static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid *m
}
}
+static void print_ambient_viewing_environment(WriterContext *w,
+ const AVAmbientViewingEnvironment *env)
+{
+ if (!env)
+ return;
+
+ print_q("ambient_illuminance", env->ambient_illuminance, '/');
+ print_q("ambient_light_x", env->ambient_light_x, '/');
+ print_q("ambient_light_y", env->ambient_light_y, '/');
+}
+
static void print_pkt_side_data(WriterContext *w,
AVCodecParameters *par,
const AVPacketSideData *side_data,
@@ -2704,6 +2716,9 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
print_dynamic_hdr_vivid(w, metadata);
+ } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
+ print_ambient_viewing_environment(
+ w, (const AVAmbientViewingEnvironment *)sd->data);
}
writer_print_section_footer(w);
}
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 4/4] avcodec/h2645_sei: add support for Ambient Viewing Environment SEI
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment 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:19 ` [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames Jan Ekström
@ 2023-01-10 21:19 ` Jan Ekström
2023-01-10 21:33 ` James Almer
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
4 siblings, 1 reply; 16+ messages in thread
From: Jan Ekström @ 2023-01-10 21:19 UTC (permalink / raw)
To: ffmpeg-devel
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
+ };
}
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]
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/4] avutil: introduce AVAmbientViewingEnvironment side data
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
0 siblings, 0 replies; 16+ messages in thread
From: James Almer @ 2023-01-10 21:25 UTC (permalink / raw)
To: ffmpeg-devel
On 1/10/2023 6:19 PM, Jan Ekström wrote:
> This enables exposing H.274 Ambient Viewing Environment
> metadata in the framework.
> ---
> doc/APIchanges | 6 +++
> libavutil/Makefile | 2 +
> libavutil/ambient_viewing_environment.c | 51 ++++++++++++++++++
> libavutil/ambient_viewing_environment.h | 72 +++++++++++++++++++++++++
> libavutil/frame.c | 1 +
> libavutil/frame.h | 5 ++
> libavutil/version.h | 2 +-
> 7 files changed, 138 insertions(+), 1 deletion(-)
> create mode 100644 libavutil/ambient_viewing_environment.c
> create mode 100644 libavutil/ambient_viewing_environment.h
>
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 328028f293..f13b4f1149 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -14,6 +14,12 @@ libavutil: 2021-04-27
>
> API changes, most recent first:
>
> +2023-01-10 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h
Mention frame.h here too.
> + Adds a new structure for holding H.274 Ambient Viewing Environment metadata,
> + AVAmbientViewingEnvironment.
> + Adds a new AVFrameSideDataType entry AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
> + for it.
> +
> 2022-12-xx - xxxxxxxxxx - lavc 59.55.100 - avcodec.h
> Add AV_HWACCEL_FLAG_UNSAFE_OUTPUT.
>
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index 3d9c07aea8..29b06665f5 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -4,6 +4,7 @@ DESC = FFmpeg utility library
> HEADERS = adler32.h \
> aes.h \
> aes_ctr.h \
> + ambient_viewing_environment.h \
> attributes.h \
> audio_fifo.h \
> avassert.h \
> @@ -102,6 +103,7 @@ BUILT_HEADERS = avconfig.h \
> OBJS = adler32.o \
> aes.o \
> aes_ctr.o \
> + ambient_viewing_environment.o \
> audio_fifo.o \
> avstring.o \
> avsscanf.o \
> diff --git a/libavutil/ambient_viewing_environment.c b/libavutil/ambient_viewing_environment.c
> new file mode 100644
> index 0000000000..e7d150796e
> --- /dev/null
> +++ b/libavutil/ambient_viewing_environment.c
> @@ -0,0 +1,51 @@
> +/*
> + * Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include <stddef.h>
> +#include "ambient_viewing_environment.h"
> +#include "frame.h"
Nit: no need for this one since it's included by the above header.
> +#include "mem.h"
> +
> +AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size)
> +{
> + AVAmbientViewingEnvironment *env =
> + av_mallocz(sizeof(AVAmbientViewingEnvironment));
> + if (!env)
> + return NULL;
> +
> + if (size)
> + *size = sizeof(*env);
> +
> + return env;
> +}
> +
> +AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame)
> +{
> + AVFrameSideData *side_data =
> + av_frame_new_side_data(frame,
> + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
> + sizeof(AVAmbientViewingEnvironment));
> + if (!side_data)
> + return NULL;
> +
> + memset(side_data->data, 0, side_data->size);
> +
> + return (AVAmbientViewingEnvironment *)side_data->data;
> +}
> diff --git a/libavutil/ambient_viewing_environment.h b/libavutil/ambient_viewing_environment.h
> new file mode 100644
> index 0000000000..e5e4ac2173
> --- /dev/null
> +++ b/libavutil/ambient_viewing_environment.h
> @@ -0,0 +1,72 @@
> +/*
> + * Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
> +#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
> +
> +#include <stddef.h>
> +#include "frame.h"
> +#include "rational.h"
> +
> +/**
> + * Ambient viewing environment metadata as defined by H.274. The values are
> + * saved in AVRationals so that they keep their exactness, while allowing for
> + * easy access to a double value with f.ex. av_q2d.
> + *
> + * @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and
> + * it must be allocated using av_ambient_viewing_environment_alloc.
> + */
> +typedef struct AVAmbientViewingEnvironment {
> + /**
> + * Environmental illuminance of the ambient viewing environment in lux.
> + */
> + AVRational ambient_illuminance;
> +
> + /**
> + * Normalized x chromaticity coordinate of the environmental ambient light
> + * in the nominal viewing environment according to the CIE 1931 definition
> + * of x and y as specified in ISO/CIE 11664-1.
> + */
> + AVRational ambient_light_x;
> +
> + /**
> + * Normalized y chromaticity coordinate of the environmental ambient light
> + * in the nominal viewing environment according to the CIE 1931 definition
> + * of x and y as specified in ISO/CIE 11664-1.
> + */
> + AVRational ambient_light_y;
> +} AVAmbientViewingEnvironment;
> +
> +/**
> + * Allocate an AVAmbientViewingEnvironment structure.
> + *
> + * @return the newly allocated struct or NULL on failure
> + */
> +AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size);
> +
> +/**
> + * Allocate and add an AVAmbientViewingEnvironment structure to an existing
> + * AVFrame as side data.
> + *
> + * @return the newly allocated struct, or NULL on failure
> + */
> +AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame);
> +
> +#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index de4ad1f94d..fa9b11aa54 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -831,6 +831,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
> case AV_FRAME_DATA_DETECTION_BBOXES: return "Bounding boxes for object detection and classification";
> case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data";
> case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata";
> + case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment";
> }
> return NULL;
> }
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index e60a82f6c0..bbe909ee2d 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -209,6 +209,11 @@ enum AVFrameSideDataType {
> * volume transform - CUVA 005.1-2021.
> */
> AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
> +
> + /**
> + * Ambient viewing environment metadata, as defined by H.274.
> + */
> + AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
> };
>
> enum AVActiveFormatDescription {
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 3b616ea489..60f96af5df 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
> */
>
> #define LIBAVUTIL_VERSION_MAJOR 57
> -#define LIBAVUTIL_VERSION_MINOR 43
> +#define LIBAVUTIL_VERSION_MINOR 44
> #define LIBAVUTIL_VERSION_MICRO 100
>
> #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
Should be ok.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 4/4] avcodec/h2645_sei: add support for Ambient Viewing Environment SEI
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
0 siblings, 0 replies; 16+ messages in thread
From: James Almer @ 2023-01-10 21:33 UTC (permalink / raw)
To: ffmpeg-devel
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI Jan Ekström
` (2 preceding siblings ...)
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:34 ` James Almer
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 " Jan Ekström
4 siblings, 0 replies; 16+ messages in thread
From: James Almer @ 2023-01-10 21:34 UTC (permalink / raw)
To: ffmpeg-devel
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.
> ---
> libavcodec/cbs_h2645.c | 6 ++++++
> libavcodec/cbs_sei.h | 6 ++++++
> libavcodec/cbs_sei_syntax_template.c | 17 +++++++++++++++++
> 3 files changed, 29 insertions(+)
>
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 4ee06003c3..80e48829af 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -1500,6 +1500,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
> sizeof(SEIRawAlternativeTransferCharacteristics),
> SEI_MESSAGE_RW(sei, alternative_transfer_characteristics),
> },
> + {
> + SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT,
> + 1, 0,
> + sizeof(SEIRawAmbientViewingEnvironment),
> + SEI_MESSAGE_RW(sei, ambient_viewing_environment),
> + },
> SEI_MESSAGE_TYPE_END,
> };
>
> diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
> index c7a7a95be0..1c327a4689 100644
> --- a/libavcodec/cbs_sei.h
> +++ b/libavcodec/cbs_sei.h
> @@ -65,6 +65,12 @@ typedef struct SEIRawAlternativeTransferCharacteristics {
> uint8_t preferred_transfer_characteristics;
> } SEIRawAlternativeTransferCharacteristics;
>
> +typedef struct SEIRawAmbientViewingEnvironment {
> + uint32_t ambient_illuminance;
> + uint16_t ambient_light_x;
> + uint16_t ambient_light_y;
> +} SEIRawAmbientViewingEnvironment;
> +
> typedef struct SEIRawMessage {
> uint32_t payload_type;
> uint32_t payload_size;
> diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c
> index 0ef7b42ed9..6a7cc36dda 100644
> --- a/libavcodec/cbs_sei_syntax_template.c
> +++ b/libavcodec/cbs_sei_syntax_template.c
> @@ -144,6 +144,23 @@ static int FUNC(alternative_transfer_characteristics)
> return 0;
> }
>
> +static int FUNC(ambient_viewing_environment)
> + (CodedBitstreamContext *ctx, RWContext *rw,
> + SEIRawAmbientViewingEnvironment *current,
> + SEIMessageState *state)
> +{
> + static const uint16_t max_ambient_light_value = 50000;
> + int err;
> +
> + HEADER("Ambient Viewing Environment");
> +
> + u(32, ambient_illuminance, 1, MAX_UINT_BITS(32));
> + u(16, ambient_light_x, 0, max_ambient_light_value);
> + u(16, ambient_light_y, 0, max_ambient_light_value);
> +
> + return 0;
> +}
> +
> static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw,
> SEIRawMessage *current)
> {
Should be ok.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames
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
1 sibling, 0 replies; 16+ messages in thread
From: James Almer @ 2023-01-10 21:35 UTC (permalink / raw)
To: ffmpeg-devel
On 1/10/2023 6:19 PM, Jan Ekström wrote:
> ---
> fftools/ffprobe.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index d2f126d9d6..15c61e1c7c 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -33,6 +33,7 @@
> #include "libavformat/version.h"
> #include "libavcodec/avcodec.h"
> #include "libavcodec/version.h"
> +#include "libavutil/ambient_viewing_environment.h"
> #include "libavutil/avassert.h"
> #include "libavutil/avstring.h"
> #include "libavutil/bprint.h"
> @@ -2268,6 +2269,17 @@ static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid *m
> }
> }
>
> +static void print_ambient_viewing_environment(WriterContext *w,
> + const AVAmbientViewingEnvironment *env)
> +{
> + if (!env)
> + return;
> +
> + print_q("ambient_illuminance", env->ambient_illuminance, '/');
> + print_q("ambient_light_x", env->ambient_light_x, '/');
> + print_q("ambient_light_y", env->ambient_light_y, '/');
> +}
> +
> static void print_pkt_side_data(WriterContext *w,
> AVCodecParameters *par,
> const AVPacketSideData *side_data,
> @@ -2704,6 +2716,9 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
> } else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
> AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
> print_dynamic_hdr_vivid(w, metadata);
> + } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
> + print_ambient_viewing_environment(
> + w, (const AVAmbientViewingEnvironment *)sd->data);
> }
> writer_print_section_footer(w);
> }
Should be ok.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH v2 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI Jan Ekström
` (3 preceding siblings ...)
2023-01-10 21:34 ` [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: " James Almer
@ 2023-01-11 18:57 ` Jan Ekström
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 2/4] avutil: introduce AVAmbientViewingEnvironment side data Jan Ekström
` (3 more replies)
4 siblings, 4 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-11 18:57 UTC (permalink / raw)
To: ffmpeg-devel
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.
---
libavcodec/cbs_h2645.c | 6 ++++++
libavcodec/cbs_sei.h | 6 ++++++
libavcodec/cbs_sei_syntax_template.c | 17 +++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 4ee06003c3..80e48829af 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -1500,6 +1500,12 @@ static const SEIMessageTypeDescriptor cbs_sei_common_types[] = {
sizeof(SEIRawAlternativeTransferCharacteristics),
SEI_MESSAGE_RW(sei, alternative_transfer_characteristics),
},
+ {
+ SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT,
+ 1, 0,
+ sizeof(SEIRawAmbientViewingEnvironment),
+ SEI_MESSAGE_RW(sei, ambient_viewing_environment),
+ },
SEI_MESSAGE_TYPE_END,
};
diff --git a/libavcodec/cbs_sei.h b/libavcodec/cbs_sei.h
index c7a7a95be0..1c327a4689 100644
--- a/libavcodec/cbs_sei.h
+++ b/libavcodec/cbs_sei.h
@@ -65,6 +65,12 @@ typedef struct SEIRawAlternativeTransferCharacteristics {
uint8_t preferred_transfer_characteristics;
} SEIRawAlternativeTransferCharacteristics;
+typedef struct SEIRawAmbientViewingEnvironment {
+ uint32_t ambient_illuminance;
+ uint16_t ambient_light_x;
+ uint16_t ambient_light_y;
+} SEIRawAmbientViewingEnvironment;
+
typedef struct SEIRawMessage {
uint32_t payload_type;
uint32_t payload_size;
diff --git a/libavcodec/cbs_sei_syntax_template.c b/libavcodec/cbs_sei_syntax_template.c
index 0ef7b42ed9..6a7cc36dda 100644
--- a/libavcodec/cbs_sei_syntax_template.c
+++ b/libavcodec/cbs_sei_syntax_template.c
@@ -144,6 +144,23 @@ static int FUNC(alternative_transfer_characteristics)
return 0;
}
+static int FUNC(ambient_viewing_environment)
+ (CodedBitstreamContext *ctx, RWContext *rw,
+ SEIRawAmbientViewingEnvironment *current,
+ SEIMessageState *state)
+{
+ static const uint16_t max_ambient_light_value = 50000;
+ int err;
+
+ HEADER("Ambient Viewing Environment");
+
+ u(32, ambient_illuminance, 1, MAX_UINT_BITS(32));
+ u(16, ambient_light_x, 0, max_ambient_light_value);
+ u(16, ambient_light_y, 0, max_ambient_light_value);
+
+ return 0;
+}
+
static int FUNC(message)(CodedBitstreamContext *ctx, RWContext *rw,
SEIRawMessage *current)
{
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH v2 2/4] avutil: introduce AVAmbientViewingEnvironment side data
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 " Jan Ekström
@ 2023-01-11 18:57 ` Jan Ekström
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames Jan Ekström
` (2 subsequent siblings)
3 siblings, 0 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-11 18:57 UTC (permalink / raw)
To: ffmpeg-devel
This enables exposing H.274 Ambient Viewing Environment
metadata in the framework.
---
doc/APIchanges | 6 +++
libavutil/Makefile | 2 +
libavutil/ambient_viewing_environment.c | 49 +++++++++++++++++
libavutil/ambient_viewing_environment.h | 72 +++++++++++++++++++++++++
libavutil/frame.c | 1 +
libavutil/frame.h | 5 ++
libavutil/version.h | 2 +-
7 files changed, 136 insertions(+), 1 deletion(-)
create mode 100644 libavutil/ambient_viewing_environment.c
create mode 100644 libavutil/ambient_viewing_environment.h
diff --git a/doc/APIchanges b/doc/APIchanges
index 328028f293..4356f8bbd5 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,12 @@ libavutil: 2021-04-27
API changes, most recent first:
+2023-01-10 - xxxxxxxxxx - lavu 57.44.100 - ambient_viewing_environment.h frame.h
+ Adds a new structure for holding H.274 Ambient Viewing Environment metadata,
+ AVAmbientViewingEnvironment.
+ Adds a new AVFrameSideDataType entry AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
+ for it.
+
2022-12-xx - xxxxxxxxxx - lavc 59.55.100 - avcodec.h
Add AV_HWACCEL_FLAG_UNSAFE_OUTPUT.
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 3d9c07aea8..29b06665f5 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -4,6 +4,7 @@ DESC = FFmpeg utility library
HEADERS = adler32.h \
aes.h \
aes_ctr.h \
+ ambient_viewing_environment.h \
attributes.h \
audio_fifo.h \
avassert.h \
@@ -102,6 +103,7 @@ BUILT_HEADERS = avconfig.h \
OBJS = adler32.o \
aes.o \
aes_ctr.o \
+ ambient_viewing_environment.o \
audio_fifo.o \
avstring.o \
avsscanf.o \
diff --git a/libavutil/ambient_viewing_environment.c b/libavutil/ambient_viewing_environment.c
new file mode 100644
index 0000000000..c47458cfa8
--- /dev/null
+++ b/libavutil/ambient_viewing_environment.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "ambient_viewing_environment.h"
+#include "mem.h"
+
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size)
+{
+ AVAmbientViewingEnvironment *env =
+ av_mallocz(sizeof(AVAmbientViewingEnvironment));
+ if (!env)
+ return NULL;
+
+ if (size)
+ *size = sizeof(*env);
+
+ return env;
+}
+
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame)
+{
+ AVFrameSideData *side_data =
+ av_frame_new_side_data(frame,
+ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
+ sizeof(AVAmbientViewingEnvironment));
+ if (!side_data)
+ return NULL;
+
+ memset(side_data->data, 0, side_data->size);
+
+ return (AVAmbientViewingEnvironment *)side_data->data;
+}
diff --git a/libavutil/ambient_viewing_environment.h b/libavutil/ambient_viewing_environment.h
new file mode 100644
index 0000000000..e5e4ac2173
--- /dev/null
+++ b/libavutil/ambient_viewing_environment.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2023 Jan Ekström <jeebjp@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
+#define AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H
+
+#include <stddef.h>
+#include "frame.h"
+#include "rational.h"
+
+/**
+ * Ambient viewing environment metadata as defined by H.274. The values are
+ * saved in AVRationals so that they keep their exactness, while allowing for
+ * easy access to a double value with f.ex. av_q2d.
+ *
+ * @note sizeof(AVAmbientViewingEnvironment) is not part of the public ABI, and
+ * it must be allocated using av_ambient_viewing_environment_alloc.
+ */
+typedef struct AVAmbientViewingEnvironment {
+ /**
+ * Environmental illuminance of the ambient viewing environment in lux.
+ */
+ AVRational ambient_illuminance;
+
+ /**
+ * Normalized x chromaticity coordinate of the environmental ambient light
+ * in the nominal viewing environment according to the CIE 1931 definition
+ * of x and y as specified in ISO/CIE 11664-1.
+ */
+ AVRational ambient_light_x;
+
+ /**
+ * Normalized y chromaticity coordinate of the environmental ambient light
+ * in the nominal viewing environment according to the CIE 1931 definition
+ * of x and y as specified in ISO/CIE 11664-1.
+ */
+ AVRational ambient_light_y;
+} AVAmbientViewingEnvironment;
+
+/**
+ * Allocate an AVAmbientViewingEnvironment structure.
+ *
+ * @return the newly allocated struct or NULL on failure
+ */
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_alloc(size_t *size);
+
+/**
+ * Allocate and add an AVAmbientViewingEnvironment structure to an existing
+ * AVFrame as side data.
+ *
+ * @return the newly allocated struct, or NULL on failure
+ */
+AVAmbientViewingEnvironment *av_ambient_viewing_environment_create_side_data(AVFrame *frame);
+
+#endif /* AVUTIL_AMBIENT_VIEWING_ENVIRONMENT_H */
diff --git a/libavutil/frame.c b/libavutil/frame.c
index de4ad1f94d..fa9b11aa54 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -831,6 +831,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
case AV_FRAME_DATA_DETECTION_BBOXES: return "Bounding boxes for object detection and classification";
case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data";
case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata";
+ case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment";
}
return NULL;
}
diff --git a/libavutil/frame.h b/libavutil/frame.h
index e60a82f6c0..bbe909ee2d 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -209,6 +209,11 @@ enum AVFrameSideDataType {
* volume transform - CUVA 005.1-2021.
*/
AV_FRAME_DATA_DYNAMIC_HDR_VIVID,
+
+ /**
+ * Ambient viewing environment metadata, as defined by H.274.
+ */
+ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
};
enum AVActiveFormatDescription {
diff --git a/libavutil/version.h b/libavutil/version.h
index 3b616ea489..60f96af5df 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 57
-#define LIBAVUTIL_VERSION_MINOR 43
+#define LIBAVUTIL_VERSION_MINOR 44
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH v2 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames
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 ` 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
3 siblings, 0 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-11 18:57 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffprobe.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index c18aee9846..b9310a2d25 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -33,6 +33,7 @@
#include "libavformat/version.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/version.h"
+#include "libavutil/ambient_viewing_environment.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
@@ -2268,6 +2269,17 @@ static void print_dynamic_hdr_vivid(WriterContext *w, const AVDynamicHDRVivid *m
}
}
+static void print_ambient_viewing_environment(WriterContext *w,
+ const AVAmbientViewingEnvironment *env)
+{
+ if (!env)
+ return;
+
+ print_q("ambient_illuminance", env->ambient_illuminance, '/');
+ print_q("ambient_light_x", env->ambient_light_x, '/');
+ print_q("ambient_light_y", env->ambient_light_y, '/');
+}
+
static void print_pkt_side_data(WriterContext *w,
AVCodecParameters *par,
const AVPacketSideData *side_data,
@@ -2704,6 +2716,9 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
} else if (sd->type == AV_FRAME_DATA_DYNAMIC_HDR_VIVID) {
AVDynamicHDRVivid *metadata = (AVDynamicHDRVivid *)sd->data;
print_dynamic_hdr_vivid(w, metadata);
+ } else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
+ print_ambient_viewing_environment(
+ w, (const AVAmbientViewingEnvironment *)sd->data);
}
writer_print_section_footer(w);
}
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH v2 4/4] avcodec/h2645_sei: add support for Ambient Viewing Environment SEI
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 ` Jan Ekström
2023-01-13 19:39 ` [FFmpeg-devel] [PATCH v2 1/4] avcodec/cbs_{h2645, sei}: " Jan Ekström
3 siblings, 0 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-11 18:57 UTC (permalink / raw)
To: ffmpeg-devel
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 | 45 ++++++++++++++++++++++++++++++++++++++
libavcodec/h2645_sei.h | 8 +++++++
tests/ref/fate/hevc-dv-rpu | 12 ++++++++++
3 files changed, 65 insertions(+)
diff --git a/libavcodec/h2645_sei.c b/libavcodec/h2645_sei.c
index 3ff89e4fdd..6e4a9a1af2 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,6 @@ 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.present = 0;
}
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]
--
2.39.0
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH v2 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment SEI
2023-01-11 18:57 ` [FFmpeg-devel] [PATCH v2 " Jan Ekström
` (2 preceding siblings ...)
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 ` Jan Ekström
3 siblings, 0 replies; 16+ messages in thread
From: Jan Ekström @ 2023-01-13 19:39 UTC (permalink / raw)
To: ffmpeg-devel
On Wed, Jan 11, 2023 at 8:57 PM Jan Ekström <jeebjp@gmail.com> 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.
> ---
Applied the set as the initial version was generally OK'd, and all
nits were poked.
Jan
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames
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
1 sibling, 1 reply; 16+ messages in thread
From: Stefano Sabatini @ 2023-01-14 20:03 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On date Tuesday 2023-01-10 23:19:48 +0200, Jan Ekström wrote:
> ---
> fftools/ffprobe.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
Missing doc/ffprobe.xsd changes?
LGTM otherwise.
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames
2023-01-14 20:03 ` Stefano Sabatini
@ 2023-01-14 20:59 ` Jan Ekström
2023-01-15 1:14 ` Stefano Sabatini
0 siblings, 1 reply; 16+ messages in thread
From: Jan Ekström @ 2023-01-14 20:59 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sat, Jan 14, 2023 at 10:03 PM Stefano Sabatini <stefasab@gmail.com> wrote:
>
> On date Tuesday 2023-01-10 23:19:48 +0200, Jan Ekström wrote:
> > ---
> > fftools/ffprobe.c | 15 +++++++++++++++
> > 1 file changed, 15 insertions(+)
>
> Missing doc/ffprobe.xsd changes?
>
> LGTM otherwise.
>
I quickly checked ffprobe.xsd and it doesn't seem to define any of the
side data entries that it prints out, other than
frameSideDataTimecodeList ? So if each packet/frame side data type
output should have been added there, it seems to have been neglected
for quite a while.
Jan
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/4] ffprobe: expose AVAmbientViewingEnvironment side data in AVFrames
2023-01-14 20:59 ` Jan Ekström
@ 2023-01-15 1:14 ` Stefano Sabatini
0 siblings, 0 replies; 16+ messages in thread
From: Stefano Sabatini @ 2023-01-15 1:14 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On date Saturday 2023-01-14 22:59:31 +0200, Jan Ekström wrote:
> On Sat, Jan 14, 2023 at 10:03 PM Stefano Sabatini <stefasab@gmail.com> wrote:
> >
> > On date Tuesday 2023-01-10 23:19:48 +0200, Jan Ekström wrote:
> > > ---
> > > fftools/ffprobe.c | 15 +++++++++++++++
> > > 1 file changed, 15 insertions(+)
> >
> > Missing doc/ffprobe.xsd changes?
> >
> > LGTM otherwise.
> >
>
> I quickly checked ffprobe.xsd and it doesn't seem to define any of the
> side data entries that it prints out, other than
> frameSideDataTimecodeList ? So if each packet/frame side data type
> output should have been added there, it seems to have been neglected
> for quite a while.
I see, so feel free to push as is, fixing this has a broader scope
(can be done separately I guess).
_______________________________________________
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2023-01-15 1:14 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 21:19 [FFmpeg-devel] [PATCH 1/4] avcodec/cbs_{h2645, sei}: add support for Ambient Viewing Environment 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
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
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