Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-19 Thread Moritz Barsnick
On Tue, Dec 18, 2018 at 13:41:06 -0800, Mohammad Izadi wrote:

Nit:

>  #define LIBAVUTIL_VERSION_MAJOR  56
> -#define LIBAVUTIL_VERSION_MINOR  24
> +#define LIBAVUTIL_VERSION_MINOR  25
>  #define LIBAVUTIL_VERSION_MICRO 101

When bumping minor, you need to reset micro to 100.

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-18 Thread Mohammad Izadi
From: Mohammad Izadi 

The dynamic metadata contains data for color volume transform - application 4 
of SPMTE 2094-40:2016 standard. The data comes from HEVC in the 
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35.

I'll add support to HEVC in a follow-up.
---
 libavutil/Makefile   |   2 +
 libavutil/frame.c|   1 +
 libavutil/frame.h|   7 +
 libavutil/hdr_dynamic_metadata.c |  47 +
 libavutil/hdr_dynamic_metadata.h | 344 +++
 libavutil/version.h  |   2 +-
 6 files changed, 402 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/hdr_dynamic_metadata.c
 create mode 100644 libavutil/hdr_dynamic_metadata.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index caddc7e155..7dcb92b06b 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -31,6 +31,7 @@ HEADERS = adler32.h   
  \
   file.h\
   frame.h   \
   hash.h\
+  hdr_dynamic_metadata.h\
   hmac.h\
   hwcontext.h   \
   hwcontext_cuda.h  \
@@ -119,6 +120,7 @@ OBJS = adler32.o
\
fixed_dsp.o  \
frame.o  \
hash.o   \
+   hdr_dynamic_metadata.o   \
hmac.o   \
hwcontext.o  \
imgutils.o   \
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 9b3fb13e68..34a6210d9e 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -840,6 +840,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table 
properties";
 case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table data";
 #endif
+case AV_FRAME_DATA_DYNAMIC_HDR_PLUS: return "HDR Dynamic Metadata 
SMPTE2094-40 (HDR10+)";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 66f27f44bd..4de3d4e6d1 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -166,6 +166,13 @@ enum AVFrameSideDataType {
  * function in libavutil/timecode.c.
  */
 AV_FRAME_DATA_S12M_TIMECODE,
+
+/**
+ * HDR dynamic metadata associated with a video frame. The payload is
+ * an AVDynamicHDRPlus type and contains information for color
+ * volume transform - application 4 of SPMTE 2094-40:2016 standard.
+ */
+AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/hdr_dynamic_metadata.c b/libavutil/hdr_dynamic_metadata.c
new file mode 100644
index 00..7e4d7dec10
--- /dev/null
+++ b/libavutil/hdr_dynamic_metadata.c
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2018 Mohammad Izadi 
+ *
+ * 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 "hdr_dynamic_metadata.h"
+#include "mem.h"
+
+AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size)
+{
+AVDynamicHDRPlus *hdr_plus = av_mallocz(sizeof(AVDynamicHDRPlus));
+if (!hdr_plus)
+return NULL;
+
+if (size)
+*size = sizeof(*hdr_plus);
+
+return hdr_plus;
+}
+
+AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+
AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
+
sizeof(AVDynamicHDRPlus));
+if (!side_data)
+return NULL;
+
+memset(side_data->data, 0, sizeof(AVDynamicHDRPlus));
+
+return (AVDynamicHDRPlus *)side_data->data;
+}
diff --git 

Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-17 Thread Vittorio Giovara
On Tue, Dec 18, 2018 at 12:04 AM Mohammad Izadi  wrote:

> As Jan mentioned, we need to specify the kind of the HDR metadata. Here are
> some alternatives:
>
> AVDynamicHDRPlus
> AVSMPTE2094App4 (Application 4 is HDR10+ while Dolby is application 1)
> AVHDRPlusMetadata
>
> Which one do you prefer?


IMO AVDynamicHDRPlus or AVHDRPlusMetadata.
Thanks,
Vittorio


> --
> Best,
> Mohammad
>
>
> On Mon, Dec 17, 2018 at 3:07 PM Jan Ekström  wrote:
>
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-17 Thread Mohammad Izadi
As Jan mentioned, we need to specify the kind of the HDR metadata. Here are
some alternatives:

AVDynamicHDRPlus
AVSMPTE2094App4 (Application 4 is HDR10+ while Dolby is application 1)
AVHDRPlusMetadata

Which one do you prefer?


--
Best,
Mohammad


On Mon, Dec 17, 2018 at 3:07 PM Jan Ekström  wrote:

> On Tue, Dec 18, 2018 at 12:58 AM Vittorio Giovara
>  wrote:
> >
> > On Mon, Dec 17, 2018 at 5:53 PM Jan Ekström  wrote:
> >
> > > On Tue, Dec 18, 2018 at 12:41 AM Vittorio Giovara
> > >  wrote:
> > > >
> > > > I like
> > > VeryLongJavaLikeNamingForFunctionsAndDataTypesAsWellAsEnumsOfCourse
> > > > as much as the next guy, but this is overly too long and the related
> > > > structure name (AVDynamicMetadataSMPTE2094_40) is inconsistent with
> the
> > > > public type naming present in this project.
> > > >
> > > > If I may suggest, please use the following names:
> > > > - AV_FRAME_DATA_DYNAMIC_HDR for frame data type: it is obviously
> > > metadata,
> > > > and the fact that is based on SMPTE2094-40 should not be hardcoded
> in the
> > > > name
> > > > - dynamic_hdr.h as header name: again the fact that it's metadata
> does
> > > not
> > > > be carried everywhere
> > > > - AVDynamicHDR as structure name: short and to the point, and without
> > > spec
> > > > numbers or underscores
> > > >
> > >
> > > I don't think SMPTE ST.2094-XX utilized the same fields?
> > >
> > > I think SMPTE ST.2094-40 is Samsung's dynamic metadata which is effect
> > > usually called "HDR10+" ? Not just calling it AVDynamicHDR could come
> > > up useful if we plan on adding support for SMPTE ST.2094-10 which is
> > > one part of what's called "Dolby Vision" (even though it is just
> > > dynamic metadata - because of course you have to stick everything
> > > under a single marketing name).
> > >
> >
> > It's still technically dynamic metadata but I get your point.
> > It could maybe be stored in dynamic_hdr.h header, and call it
> > AVDynamicHDRPlus to differenciate it from the future AVDolbyVisionHDR.
> What
> > do you think?
> >
>
> The other alternative would have been to make sure that the structure
> can take the values that are "essential" from those separate
> specifications.
>
> I do not have a heavy opinion one way or another (separate structure
> per spec or single with all the required data), but just had to
> mention it because it would have otherwise been a singular "dynamic
> HDR metadata" entity while it unfortunately seems that these things
> have splintered into multiple competing alternatives... (of which
> Samsung's and Dolby's things seem to be those getting most use)
>
> Jan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-17 Thread Jan Ekström
On Tue, Dec 18, 2018 at 12:58 AM Vittorio Giovara
 wrote:
>
> On Mon, Dec 17, 2018 at 5:53 PM Jan Ekström  wrote:
>
> > On Tue, Dec 18, 2018 at 12:41 AM Vittorio Giovara
> >  wrote:
> > >
> > > I like
> > VeryLongJavaLikeNamingForFunctionsAndDataTypesAsWellAsEnumsOfCourse
> > > as much as the next guy, but this is overly too long and the related
> > > structure name (AVDynamicMetadataSMPTE2094_40) is inconsistent with the
> > > public type naming present in this project.
> > >
> > > If I may suggest, please use the following names:
> > > - AV_FRAME_DATA_DYNAMIC_HDR for frame data type: it is obviously
> > metadata,
> > > and the fact that is based on SMPTE2094-40 should not be hardcoded in the
> > > name
> > > - dynamic_hdr.h as header name: again the fact that it's metadata does
> > not
> > > be carried everywhere
> > > - AVDynamicHDR as structure name: short and to the point, and without
> > spec
> > > numbers or underscores
> > >
> >
> > I don't think SMPTE ST.2094-XX utilized the same fields?
> >
> > I think SMPTE ST.2094-40 is Samsung's dynamic metadata which is effect
> > usually called "HDR10+" ? Not just calling it AVDynamicHDR could come
> > up useful if we plan on adding support for SMPTE ST.2094-10 which is
> > one part of what's called "Dolby Vision" (even though it is just
> > dynamic metadata - because of course you have to stick everything
> > under a single marketing name).
> >
>
> It's still technically dynamic metadata but I get your point.
> It could maybe be stored in dynamic_hdr.h header, and call it
> AVDynamicHDRPlus to differenciate it from the future AVDolbyVisionHDR. What
> do you think?
>

The other alternative would have been to make sure that the structure
can take the values that are "essential" from those separate
specifications.

I do not have a heavy opinion one way or another (separate structure
per spec or single with all the required data), but just had to
mention it because it would have otherwise been a singular "dynamic
HDR metadata" entity while it unfortunately seems that these things
have splintered into multiple competing alternatives... (of which
Samsung's and Dolby's things seem to be those getting most use)

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-17 Thread Vittorio Giovara
On Mon, Dec 17, 2018 at 5:53 PM Jan Ekström  wrote:

> On Tue, Dec 18, 2018 at 12:41 AM Vittorio Giovara
>  wrote:
> >
> > On Mon, Dec 10, 2018 at 2:50 PM Mohammad Izadi 
> wrote:
> >
> > > From: Mohammad Izadi 
> > >
> > > The dynamic metadata contains data for color volume transform -
> > > application 4 of SPMTE 2094-40:2016 standard. The data comes from HEVC
> in
> > > the SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35.
> > >
> > > I'll add support to HEVC in a follow-up.
> > >
> > > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > > index 9b3fb13e68..c5f30b6847 100644
> > > --- a/libavutil/frame.c
> > > +++ b/libavutil/frame.c
> > > @@ -840,6 +840,7 @@ const char *av_frame_side_data_name(enum
> > > AVFrameSideDataType type)
> > >  case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table
> > > properties";
> > >  case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table
> > > data";
> > >  #endif
> > > +case AV_FRAME_DATA_HDR_DYNAMIC_METADATA_SMPTE2094_40: return "HDR
> > > Dynamic Metadata SMPTE2094-40";
> > >
> >
> > I like
> VeryLongJavaLikeNamingForFunctionsAndDataTypesAsWellAsEnumsOfCourse
> > as much as the next guy, but this is overly too long and the related
> > structure name (AVDynamicMetadataSMPTE2094_40) is inconsistent with the
> > public type naming present in this project.
> >
> > If I may suggest, please use the following names:
> > - AV_FRAME_DATA_DYNAMIC_HDR for frame data type: it is obviously
> metadata,
> > and the fact that is based on SMPTE2094-40 should not be hardcoded in the
> > name
> > - dynamic_hdr.h as header name: again the fact that it's metadata does
> not
> > be carried everywhere
> > - AVDynamicHDR as structure name: short and to the point, and without
> spec
> > numbers or underscores
> >
>
> I don't think SMPTE ST.2094-XX utilized the same fields?
>
> I think SMPTE ST.2094-40 is Samsung's dynamic metadata which is effect
> usually called "HDR10+" ? Not just calling it AVDynamicHDR could come
> up useful if we plan on adding support for SMPTE ST.2094-10 which is
> one part of what's called "Dolby Vision" (even though it is just
> dynamic metadata - because of course you have to stick everything
> under a single marketing name).
>

It's still technically dynamic metadata but I get your point.
It could maybe be stored in dynamic_hdr.h header, and call it
AVDynamicHDRPlus to differenciate it from the future AVDolbyVisionHDR. What
do you think?


> Just my 20 cents.
>
> Jan
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-17 Thread Jan Ekström
On Tue, Dec 18, 2018 at 12:41 AM Vittorio Giovara
 wrote:
>
> On Mon, Dec 10, 2018 at 2:50 PM Mohammad Izadi  wrote:
>
> > From: Mohammad Izadi 
> >
> > The dynamic metadata contains data for color volume transform -
> > application 4 of SPMTE 2094-40:2016 standard. The data comes from HEVC in
> > the SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35.
> >
> > I'll add support to HEVC in a follow-up.
> >
> ---
> >  libavutil/Makefile   |   2 +
> >  libavutil/frame.c|   1 +
> >  libavutil/frame.h|   7 +
> >  libavutil/hdr_dynamic_metadata.c |  40 
> >  libavutil/hdr_dynamic_metadata.h | 344 +++
> >  libavutil/version.h  |   2 +-
> >  6 files changed, 395 insertions(+), 1 deletion(-)
> >  create mode 100644 libavutil/hdr_dynamic_metadata.c
> >  create mode 100644 libavutil/hdr_dynamic_metadata.h
> >
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index caddc7e155..7dcb92b06b 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -31,6 +31,7 @@ HEADERS = adler32.h
> >\
> >file.h\
> >frame.h   \
> >hash.h\
> > +  hdr_dynamic_metadata.h\
> >
>
> There
>
> >hmac.h\
> >hwcontext.h   \
> >hwcontext_cuda.h  \
> > @@ -119,6 +120,7 @@ OBJS = adler32.o
> >   \
> > fixed_dsp.o  \
> > frame.o  \
> > hash.o   \
> > +   hdr_dynamic_metadata.o   \
> > hmac.o   \
> > hwcontext.o  \
> > imgutils.o   \
> > diff --git a/libavutil/frame.c b/libavutil/frame.c
> > index 9b3fb13e68..c5f30b6847 100644
> > --- a/libavutil/frame.c
> > +++ b/libavutil/frame.c
> > @@ -840,6 +840,7 @@ const char *av_frame_side_data_name(enum
> > AVFrameSideDataType type)
> >  case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table
> > properties";
> >  case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table
> > data";
> >  #endif
> > +case AV_FRAME_DATA_HDR_DYNAMIC_METADATA_SMPTE2094_40: return "HDR
> > Dynamic Metadata SMPTE2094-40";
> >
>
> I like VeryLongJavaLikeNamingForFunctionsAndDataTypesAsWellAsEnumsOfCourse
> as much as the next guy, but this is overly too long and the related
> structure name (AVDynamicMetadataSMPTE2094_40) is inconsistent with the
> public type naming present in this project.
>
> If I may suggest, please use the following names:
> - AV_FRAME_DATA_DYNAMIC_HDR for frame data type: it is obviously metadata,
> and the fact that is based on SMPTE2094-40 should not be hardcoded in the
> name
> - dynamic_hdr.h as header name: again the fact that it's metadata does not
> be carried everywhere
> - AVDynamicHDR as structure name: short and to the point, and without spec
> numbers or underscores
>

I don't think SMPTE ST.2094-XX utilized the same fields?

I think SMPTE ST.2094-40 is Samsung's dynamic metadata which is effect
usually called "HDR10+" ? Not just calling it AVDynamicHDR could come
up useful if we plan on adding support for SMPTE ST.2094-10 which is
one part of what's called "Dolby Vision" (even though it is just
dynamic metadata - because of course you have to stick everything
under a single marketing name).

Just my 20 cents.

Jan
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-17 Thread Vittorio Giovara
On Mon, Dec 10, 2018 at 2:50 PM Mohammad Izadi  wrote:

> From: Mohammad Izadi 
>
> The dynamic metadata contains data for color volume transform -
> application 4 of SPMTE 2094-40:2016 standard. The data comes from HEVC in
> the SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35.
>
> I'll add support to HEVC in a follow-up.
>
---
>  libavutil/Makefile   |   2 +
>  libavutil/frame.c|   1 +
>  libavutil/frame.h|   7 +
>  libavutil/hdr_dynamic_metadata.c |  40 
>  libavutil/hdr_dynamic_metadata.h | 344 +++
>  libavutil/version.h  |   2 +-
>  6 files changed, 395 insertions(+), 1 deletion(-)
>  create mode 100644 libavutil/hdr_dynamic_metadata.c
>  create mode 100644 libavutil/hdr_dynamic_metadata.h
>
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index caddc7e155..7dcb92b06b 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -31,6 +31,7 @@ HEADERS = adler32.h
>\
>file.h\
>frame.h   \
>hash.h\
> +  hdr_dynamic_metadata.h\
>

There

>hmac.h\
>hwcontext.h   \
>hwcontext_cuda.h  \
> @@ -119,6 +120,7 @@ OBJS = adler32.o
>   \
> fixed_dsp.o  \
> frame.o  \
> hash.o   \
> +   hdr_dynamic_metadata.o   \
> hmac.o   \
> hwcontext.o  \
> imgutils.o   \
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index 9b3fb13e68..c5f30b6847 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -840,6 +840,7 @@ const char *av_frame_side_data_name(enum
> AVFrameSideDataType type)
>  case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table
> properties";
>  case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table
> data";
>  #endif
> +case AV_FRAME_DATA_HDR_DYNAMIC_METADATA_SMPTE2094_40: return "HDR
> Dynamic Metadata SMPTE2094-40";
>

I like VeryLongJavaLikeNamingForFunctionsAndDataTypesAsWellAsEnumsOfCourse
as much as the next guy, but this is overly too long and the related
structure name (AVDynamicMetadataSMPTE2094_40) is inconsistent with the
public type naming present in this project.

If I may suggest, please use the following names:
- AV_FRAME_DATA_DYNAMIC_HDR for frame data type: it is obviously metadata,
and the fact that is based on SMPTE2094-40 should not be hardcoded in the
name
- dynamic_hdr.h as header name: again the fact that it's metadata does not
be carried everywhere
- AVDynamicHDR as structure name: short and to the point, and without spec
numbers or underscores


>  }
>  return NULL;
>  }
> diff --git a/libavutil/hdr_dynamic_metadata.c
> b/libavutil/hdr_dynamic_metadata.c
> new file mode 100644
> index 00..59dfcc84e4
> --- /dev/null
> +++ b/libavutil/hdr_dynamic_metadata.c
> @@ -0,0 +1,40 @@
> +
> +#include "hdr_dynamic_metadata.h"
> +#include "mem.h"
> +
> +AVDynamicMetadataSMPTE2094_40
> *av_dynamic_metadata_smpte2094_40_alloc(void)
>

you need to return the size of allocation back to the caller, see
spherical.h as example (especially since you document that "its size is not
a part of the public ABI.")

+/**
> + * Option for overlapping elliptical pixel selectors in an image.
> + */
> +enum AVOverlapProcessOption {
> +AV_OVERLAP_PROCESS_WEIGHTED_AVERAGING = 0,
> +AV_OVERLAP_PROCESS_LAYERING = 1,
> +};
>

I'm not a fan of these names, but i've bikeshed enough


> +
> +/**
> + * Percentile represents the percentile at a specific percentage in
> + * a distribution.
> + */
> +typedef struct AVPercentile {
> +/**
> + * The percentage value corresponding to a spesific percentile
> linearized
>

typo 'spesific'

+ * RGB value in the processing window in the scene. The value shall be
> in
> + * the range of 0 to100, inclusive.
> + */
> +uint8_t percentage;
> +/**
> + * The linearized maxRGB value at a specific percentile in the
> processing
> + * window in the scene. The value shall be in the range of 0 to 1,
> inclusive
> + * and in multiples of 0.1.
> + */
> +AVRational percentile;
> +} AVPercentile;
> +
>
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH] Add HDR dynamic metadata struct (for SPMTE 2094-40) to libavutil.

2018-12-10 Thread Mohammad Izadi
From: Mohammad Izadi 

The dynamic metadata contains data for color volume transform - application 4 
of SPMTE 2094-40:2016 standard. The data comes from HEVC in the 
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35.

I'll add support to HEVC in a follow-up.
---
 libavutil/Makefile   |   2 +
 libavutil/frame.c|   1 +
 libavutil/frame.h|   7 +
 libavutil/hdr_dynamic_metadata.c |  40 
 libavutil/hdr_dynamic_metadata.h | 344 +++
 libavutil/version.h  |   2 +-
 6 files changed, 395 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/hdr_dynamic_metadata.c
 create mode 100644 libavutil/hdr_dynamic_metadata.h

diff --git a/libavutil/Makefile b/libavutil/Makefile
index caddc7e155..7dcb92b06b 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -31,6 +31,7 @@ HEADERS = adler32.h   
  \
   file.h\
   frame.h   \
   hash.h\
+  hdr_dynamic_metadata.h\
   hmac.h\
   hwcontext.h   \
   hwcontext_cuda.h  \
@@ -119,6 +120,7 @@ OBJS = adler32.o
\
fixed_dsp.o  \
frame.o  \
hash.o   \
+   hdr_dynamic_metadata.o   \
hmac.o   \
hwcontext.o  \
imgutils.o   \
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 9b3fb13e68..c5f30b6847 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -840,6 +840,7 @@ const char *av_frame_side_data_name(enum 
AVFrameSideDataType type)
 case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table 
properties";
 case AV_FRAME_DATA_QP_TABLE_DATA:   return "QP table data";
 #endif
+case AV_FRAME_DATA_HDR_DYNAMIC_METADATA_SMPTE2094_40: return "HDR Dynamic 
Metadata SMPTE2094-40";
 }
 return NULL;
 }
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 66f27f44bd..1b65a34ab3 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -166,6 +166,13 @@ enum AVFrameSideDataType {
  * function in libavutil/timecode.c.
  */
 AV_FRAME_DATA_S12M_TIMECODE,
+
+/**
+ * HDR dynamic metadata associated with a video frame. The payload is
+ * an AVDynamicMetadataSMPTE2094_40 type and contains information for color
+ * volume transform - application 4 of SPMTE 2094-40:2016 standard.
+ */
+AV_FRAME_DATA_HDR_DYNAMIC_METADATA_SMPTE2094_40,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/hdr_dynamic_metadata.c b/libavutil/hdr_dynamic_metadata.c
new file mode 100644
index 00..59dfcc84e4
--- /dev/null
+++ b/libavutil/hdr_dynamic_metadata.c
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2018 Mohammad Izadi 
+ *
+ * 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 "hdr_dynamic_metadata.h"
+#include "mem.h"
+
+AVDynamicMetadataSMPTE2094_40 *av_dynamic_metadata_smpte2094_40_alloc(void)
+{
+return av_mallocz(sizeof(AVDynamicMetadataSMPTE2094_40));
+}
+
+AVDynamicMetadataSMPTE2094_40 
*av_dynamic_metadata_smpte2094_40_create_side_data(AVFrame *frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+
AV_FRAME_DATA_HDR_DYNAMIC_METADATA_SMPTE2094_40,
+
sizeof(AVDynamicMetadataSMPTE2094_40));
+if (!side_data)
+return NULL;
+
+memset(side_data->data, 0, sizeof(AVDynamicMetadataSMPTE2094_40));
+
+return (AVDynamicMetadataSMPTE2094_40 *)side_data->data;
+}