Re: [libav-devel] [PATCH] configure: Escape elements being filtered

2017-04-07 Thread Luca Barbato
On 06/04/2017 18:25, Diego Biurrun wrote:
> I still haven't seen the problem this is supposed to fix.

You can either install ekopath or run the configure as mentioned on the
box I pointed out.

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] hevc: Add NEON 16x16 IDCT

2017-04-07 Thread Martin Storsjö

On Wed, 5 Apr 2017, Alexandra Hájková wrote:


The speedup vs C code is around 8x.


On my devboards, the speedup seems to be 6x on Cortex-A9, 7x on A7, 9x on 
A53, and 13x on A8. So this can probably be amended into "around 6-13x".



---
libavcodec/arm/hevc_idct.S| 187 ++
libavcodec/arm/hevcdsp_init_arm.c |   4 +
2 files changed, 191 insertions(+)

diff --git a/libavcodec/arm/hevc_idct.S b/libavcodec/arm/hevc_idct.S
index 4124fc8..b4279db 100644
--- a/libavcodec/arm/hevc_idct.S
+++ b/libavcodec/arm/hevc_idct.S
@@ -222,7 +222,194 @@ function ff_hevc_idct_8x8_\bitdepth\()_neon, export=1
endfunc
.endm

+.macro butterfly e, o, tmp_p, tmp_m
+vadd.s32\tmp_p, \e, \o
+vsub.s32\tmp_m, \e, \o
+.endm
+
+.macro tr16_8x4 in0, in1, in2, in3, in4, in5, in6, in7
+tr_4x4_8\in0, \in2, \in4, \in6, q8, q9, q10, q11, q12, q13, 
q14, q15
+
+vmull.s16   q12, \in1, \in0[0]
+vmull.s16   q13, \in1, \in0[1]
+vmull.s16   q14, \in1, \in0[2]
+vmull.s16   q15, \in1, \in0[3]
+sum_sub q12, \in3, \in0[1], +
+sum_sub q13, \in3, \in0[3], -
+sum_sub q14, \in3, \in0[0], -
+sum_sub q15, \in3, \in0[2], -
+
+sum_sub q12, \in5, \in0[2], +
+sum_sub q13, \in5, \in0[0], -
+sum_sub q14, \in5, \in0[3], +
+sum_sub q15, \in5, \in0[1], +
+
+sum_sub q12, \in7, \in0[3], +
+sum_sub q13, \in7, \in0[2], -
+sum_sub q14, \in7, \in0[1], +
+sum_sub q15, \in7, \in0[0], -
+
+butterfly   q8,  q12, q0, q7
+butterfly   q9,  q13, q1, q6
+butterfly   q10, q14, q2, q5
+butterfly   q11, q15, q3, q4
+add r4,  sp,  #512
+vst1.s16{q0-q1}, [r4, :128]!
+vst1.s16{q2-q3}, [r4, :128]!
+vst1.s16{q4-q5}, [r4, :128]!
+vst1.s16{q6-q7}, [r4, :128]
+.endm
+
+.macro load16 in0, in1, in2, in3, in4, in5, in6, in7
+vld1.s16{\in0}, [r1, :64], r2
+vld1.s16{\in1}, [r3, :64], r2
+vld1.s16{\in2}, [r1, :64], r2
+vld1.s16{\in3}, [r3, :64], r2
+vld1.s16{\in4}, [r1, :64], r2
+vld1.s16{\in5}, [r3, :64], r2
+vld1.s16{\in6}, [r1, :64], r2
+vld1.s16{\in7}, [r3, :64], r2
+.endm
+
+.macro add_member in, t0, t1, t2, t3, t4, t5, t6, t7, op0, op1, op2, op3, op4, 
op5, op6, op7
+sum_sub q5, \in, \t0, \op0
+sum_sub q6, \in, \t1, \op1
+sum_sub q7, \in, \t2, \op2
+sum_sub q8, \in, \t3, \op3
+sum_sub q9, \in, \t4, \op4
+sum_sub q10,\in, \t5, \op5
+sum_sub q11,\in, \t6, \op6
+sum_sub q12,\in, \t7, \op7
+.endm
+
+.macro butterfly16 in0, in1, in2, in3, in4, in5, in6, in7
+vadd.s32q4, \in0, \in1
+vsub.s32\in0, \in0, \in1
+vadd.s32\in1, \in2, \in3
+vsub.s32\in2, \in2, \in3
+vadd.s32\in3, \in4, \in5
+vsub.s32\in4, \in4, \in5
+vadd.s32\in5, \in6, \in7
+vsub.s32\in6, \in6, \in7
+.endm
+
+.macro store16 in0, in1, in2, in3, in4, in5, in6, in7
+vst1.s16\in0, [r1, :64], r2
+vst1.s16\in1, [r3, :64], r4
+vst1.s16\in2, [r1, :64], r2
+vst1.s16\in3, [r3, :64], r4
+vst1.s16\in4, [r1, :64], r2
+vst1.s16\in5, [r3, :64], r4
+vst1.s16\in6, [r1, :64], r2
+vst1.s16\in7, [r3, :64], r4
+.endm
+
+.macro scale out0, out1, out2, out3, out4, out5, out6, out7, in0, in1, in2, 
in3, in4, in5, in6, in7, shift
+vqrshrn.s32 \out0, \in0, \shift
+vqrshrn.s32 \out1, \in1, \shift
+vqrshrn.s32 \out2, \in2, \shift
+vqrshrn.s32 \out3, \in3, \shift
+vqrshrn.s32 \out4, \in4, \shift
+vqrshrn.s32 \out5, \in5, \shift
+vqrshrn.s32 \out6, \in6, \shift
+vqrshrn.s32 \out7, \in7, \shift
+.endm
+
+.macro tr_16x4 horiz, shift, in, out
+add r1,  \in, \horiz
+add r3,  \in, #(\horiz + 64)
+mov r2,  #128
+load16  d0, d1, d2, d3, d4, d5, d6, d7
+movrel  r1, trans
+
+tr16_8x4d0, d1, d2, d3, d4, d5, d6, d7
+
+add r1,  \in, #(\horiz + 32)
+add r3,  \in, #(\horiz + 64 + 32)
+mov r2,  #128
+load16  d8, d9, d2, d3, d4, d5, d6, d7
+movrel  r1, trans + 16
+vld1.s16{q0}, [r1, :128]
+vmull.s16   q5, d8, d0[0]
+vmull.s16   q6, d8, d0[1]
+vmull.s16   q7, d8, d0[2]
+vmull.s16   q8, d8, d0[3]
+

Re: [libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread James Almer
On 4/7/2017 3:20 PM, Vittorio Giovara wrote:
> On Fri, Apr 7, 2017 at 8:13 PM, James Almer  wrote:
>> On 4/7/2017 1:48 PM, Vittorio Giovara wrote:
>>> On Fri, Apr 7, 2017 at 2:27 PM, Steve Lhomme  wrote:
 + * @note The struct should be allocated with 
 av_mastering_display_metadata_alloc()
 + *   and its size is not a part of the public ABI.
 + */
 +typedef struct AVMasteringDisplayMetadata {
 +} AVMasteringDisplayMetadata;
 +
 +/**
 + * Allocate an AVMasteringDisplayMetadata structure and set its fields to
 + * default values. The resulting struct can be freed using av_freep().
 + *
 + * @return An AVMasteringDisplayMetadata filled with default values or 
 NULL
 + * on failure.
 + */
 +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
>>>
>>> This signature might be problematic, it should host a size_t* which
>>> should be filled with the size of the struct, like it's done for other
>>> side data (except stereo3d for historical reasons).
>>
>> That will mean different signature between projects.
>>
>> And for that matter, why were you against me trying to add a replacement
>> alloc function with this parameter, then?
> 
> Because I don't think it's an issue big enough to warrant an API
> change over existing code.
> 
> On the other hand this new code in Libav so hopefully the code should
> be fixed before committing and there is no need to break anything.
> It's unfortunate that the signature will be different but either
> documentation or ABI is currently violated in ffmpeg, there is no need
> to replicate this behaviour in libav, in my opinion.

We could add a function that returns size for this and every other
similar struct, even if they already have an alloc function that
also returns the struct size like Spherical.
Something like that is in any case needed for av_*_new_side_data(),
as those function do their own memory allocation.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread Vittorio Giovara
On Fri, Apr 7, 2017 at 8:13 PM, James Almer  wrote:
> On 4/7/2017 1:48 PM, Vittorio Giovara wrote:
>> On Fri, Apr 7, 2017 at 2:27 PM, Steve Lhomme  wrote:
>>> + * @note The struct should be allocated with 
>>> av_mastering_display_metadata_alloc()
>>> + *   and its size is not a part of the public ABI.
>>> + */
>>> +typedef struct AVMasteringDisplayMetadata {
>>> +} AVMasteringDisplayMetadata;
>>> +
>>> +/**
>>> + * Allocate an AVMasteringDisplayMetadata structure and set its fields to
>>> + * default values. The resulting struct can be freed using av_freep().
>>> + *
>>> + * @return An AVMasteringDisplayMetadata filled with default values or NULL
>>> + * on failure.
>>> + */
>>> +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
>>
>> This signature might be problematic, it should host a size_t* which
>> should be filled with the size of the struct, like it's done for other
>> side data (except stereo3d for historical reasons).
>
> That will mean different signature between projects.
>
> And for that matter, why were you against me trying to add a replacement
> alloc function with this parameter, then?

Because I don't think it's an issue big enough to warrant an API
change over existing code.

On the other hand this new code in Libav so hopefully the code should
be fixed before committing and there is no need to break anything.
It's unfortunate that the signature will be different but either
documentation or ABI is currently violated in ffmpeg, there is no need
to replicate this behaviour in libav, in my opinion.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread James Almer
On 4/7/2017 1:48 PM, Vittorio Giovara wrote:
> On Fri, Apr 7, 2017 at 2:27 PM, Steve Lhomme  wrote:
>> + * @note The struct should be allocated with 
>> av_mastering_display_metadata_alloc()
>> + *   and its size is not a part of the public ABI.
>> + */
>> +typedef struct AVMasteringDisplayMetadata {
>> +} AVMasteringDisplayMetadata;
>> +
>> +/**
>> + * Allocate an AVMasteringDisplayMetadata structure and set its fields to
>> + * default values. The resulting struct can be freed using av_freep().
>> + *
>> + * @return An AVMasteringDisplayMetadata filled with default values or NULL
>> + * on failure.
>> + */
>> +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
> 
> This signature might be problematic, it should host a size_t* which
> should be filled with the size of the struct, like it's done for other
> side data (except stereo3d for historical reasons).

That will mean different signature between projects.

And for that matter, why were you against me trying to add a replacement
alloc function with this parameter, then?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread Vittorio Giovara
On Fri, Apr 7, 2017 at 2:27 PM, Steve Lhomme  wrote:
> + * @note The struct should be allocated with 
> av_mastering_display_metadata_alloc()
> + *   and its size is not a part of the public ABI.
> + */
> +typedef struct AVMasteringDisplayMetadata {
> +} AVMasteringDisplayMetadata;
> +
> +/**
> + * Allocate an AVMasteringDisplayMetadata structure and set its fields to
> + * default values. The resulting struct can be freed using av_freep().
> + *
> + * @return An AVMasteringDisplayMetadata filled with default values or NULL
> + * on failure.
> + */
> +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);

This signature might be problematic, it should host a size_t* which
should be filled with the size of the struct, like it's done for other
side data (except stereo3d for historical reasons).
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/3 v2] avutil/spherical: add functions to retrieve and request projection names

2017-04-07 Thread Luca Barbato
On 07/04/2017 16:09, James Almer wrote:
> +int av_spherical_from_name(const char *name);

It can directly output the enum now, it is fine both ways to me.

Thank you for amending it :)

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 1/3 v2] avutil/spherical: add functions to retrieve and request projection names

2017-04-07 Thread James Almer
Signed-off-by: James Almer 
---
 doc/APIchanges|  4 
 libavutil/spherical.c | 28 
 libavutil/spherical.h | 24 
 libavutil/version.h   |  2 +-
 4 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index a0ca3b7ac..bafac8b4a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2017-04-xx - xxx - lavu 56.1.0 - spherical.h
+  Add AV_SPHERICAL_UNKNOWN, av_spherical_projection_name(),
+  av_spherical_from_name().
+
 2017-03-xx - xxx - lavc 57.37.0 - avcodec.h
   Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at
   a later point.
diff --git a/libavutil/spherical.c b/libavutil/spherical.c
index f5accc487..127d7e5b8 100644
--- a/libavutil/spherical.c
+++ b/libavutil/spherical.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "common.h"
 #include "mem.h"
 #include "spherical.h"
 
@@ -50,3 +51,30 @@ void av_spherical_tile_bounds(AVSphericalMapping *map,
 *right  = orig_width  - width  - *left;
 *bottom = orig_height - height - *top;
 }
+
+static const char *spherical_projection_names[] = {
+[AV_SPHERICAL_EQUIRECTANGULAR]  = "equirectangular",
+[AV_SPHERICAL_CUBEMAP]  = "cubemap",
+[AV_SPHERICAL_EQUIRECTANGULAR_TILE] = "tiled equirectangular",
+};
+
+const char *av_spherical_projection_name(enum AVSphericalProjection projection)
+{
+if ((unsigned)projection >= FF_ARRAY_ELEMS(spherical_projection_names))
+return "unknown";
+
+return spherical_projection_names[projection];
+}
+
+int av_spherical_from_name(const char *name)
+{
+int i;
+
+for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
+size_t len = strlen(spherical_projection_names[i]);
+if (!strncmp(spherical_projection_names[i], name, len))
+return i;
+}
+
+return AV_SPHERICAL_UNKNOWN;
+}
diff --git a/libavutil/spherical.h b/libavutil/spherical.h
index fd662cf67..ffd52c69c 100644
--- a/libavutil/spherical.h
+++ b/libavutil/spherical.h
@@ -50,6 +50,11 @@
  */
 enum AVSphericalProjection {
 /**
+ * Unknown projection.
+ */
+AV_SPHERICAL_UNKNOWN = -1,
+
+/**
  * Video represents a sphere mapped on a flat surface using
  * equirectangular projection.
  */
@@ -206,6 +211,25 @@ void av_spherical_tile_bounds(AVSphericalMapping *map,
   size_t width, size_t height,
   size_t *left, size_t *top,
   size_t *right, size_t *bottom);
+
+/**
+ * Provide a human-readable name of a given AVSphericalProjection.
+ *
+ * @param projection The input AVSphericalProjection.
+ *
+ * @return The name of the AVSphericalProjection, or "unknown".
+ */
+const char *av_spherical_projection_name(enum AVSphericalProjection 
projection);
+
+/**
+ * Get the AVSphericalProjection form a human-readable name.
+ *
+ * @param name The input string.
+ *
+ * @return The AVSphericalProjection value if found, AV_SPHERICAL_UNKNOWN
+ * otherwise.
+ */
+int av_spherical_from_name(const char *name);
 /**
  * @}
  * @}
diff --git a/libavutil/version.h b/libavutil/version.h
index b8425ea2c..fd72ff431 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR  0
+#define LIBAVUTIL_VERSION_MINOR  1
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.12.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] matroska: Read only the data written in the scratch buffer

2017-04-07 Thread James Almer
On 4/7/2017 6:43 AM, Luca Barbato wrote:
> The private buffer is 20bytes but depending on the type only 12 bytes
> are actually filled.
> ---
> 
> Like this, in case somebody does a similar copy+paste.
> 
>  libavformat/matroskaenc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 34d9833..b8c434a 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -686,7 +686,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
> AVIOContext *pb,
>  avio_wb32(, spherical->bound_left);
>  avio_wb32(, spherical->bound_right);
>  put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
> -private, sizeof(private));
> +private, avio_tell());
>  break;
>  case AV_SPHERICAL_CUBEMAP:
>  ffio_init_context(, private, 12, 1, NULL, NULL, NULL, NULL);
> @@ -696,7 +696,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
> AVIOContext *pb,
>  avio_wb32(, 0); // layout
>  avio_wb32(, spherical->padding);
>  put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
> -private, sizeof(private));
> +private, avio_tell());
>  break;
>  default:
>  av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
> --
> 2.9.2

LGTM.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 7/8] lavc: Add Content Light Level side metadata found in HEVC

2017-04-07 Thread Steve Lhomme
These data are necessary when transmitting HDR over HDMI.

Signed-off-by: James Almer 
---
 doc/APIchanges|  3 +++
 libavcodec/avcodec.h  |  7 +++
 libavcodec/decode.c   |  1 +
 libavcodec/hevc_sei.c | 15 +++
 libavcodec/hevcdec.c  | 18 ++
 libavcodec/hevcdec.h  |  5 +
 libavcodec/version.h  |  4 ++--
 7 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 4c35f727e6..ace50b2a3d 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2016-04-06 - xxx - lavc 58.2.0 - avcodec.h
+  Add AV_PKT_DATA_CONTENT_LIGHT_LEVEL packet side data.
+
 2016-04-xx - xxx - lavu 56.2.0 - mastering_display_metadata.h
   Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, 
av_content_light_metadata_alloc()
   and av_content_light_metadata_create_side_data() API, and 
AVContentLightMetadata
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fc1f2a4dfc..1d41badea6 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1075,6 +1075,13 @@ enum AVPacketSideDataType {
  * of the AVMasteringDisplayMetadata struct.
  */
 AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
+
+/**
+ * Content light level (based on CTA-861.3). This metadata should be
+ * associated with a video stream and containts data in the form of the
+ * AVContentLightMetadata struct.
+ */
+AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
 };
 
 typedef struct AVPacketSideData {
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 4a05b8d089..3ed5cc4fd6 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1030,6 +1030,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 { AV_PKT_DATA_STEREO3D,  AV_FRAME_DATA_STEREO3D },
 { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE },
 { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
+{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
 };
 
 frame->color_primaries = avctx->color_primaries;
diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1105b51493..e41b8262bc 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -99,6 +99,19 @@ static int decode_nal_sei_mastering_display_info(HEVCContext 
*s)
 return 0;
 }
 
+static int decode_nal_sei_content_light_info(HEVCContext *s)
+{
+GetBitContext *gb = >HEVClc.gb;
+// Max and average light levels
+s->max_content_light_level = get_bits_long(gb, 16);
+s->max_pic_average_light_level = get_bits_long(gb, 16);
+// As this SEI message comes before the first frame that references it,
+// initialize the flag to 2 and decrement on IRAP access unit so it
+// persists for the coded video sequence (e.g., between two IRAPs)
+s-> sei_content_light_present = 2;
+return  0;
+}
+
 static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 {
 GetBitContext *gb = >HEVClc.gb;
@@ -155,6 +168,8 @@ static int decode_nal_sei_prefix(HEVCContext *s, int type, 
int size)
 return decode_nal_sei_display_orientation(s);
 case SEI_TYPE_MASTERING_DISPLAY_INFO:
 return decode_nal_sei_mastering_display_info(s);
+case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+return decode_nal_sei_content_light_info(s);
 default:
 av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 30d9194c60..22ca33a9f7 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2455,6 +2455,24 @@ static int set_side_data(HEVCContext *s)
"min_luminance=%f, max_luminance=%f\n",
av_q2d(metadata->min_luminance), 
av_q2d(metadata->max_luminance));
 }
+// Decrement the mastering display flag when IRAP frame has 
no_rasl_output_flag=1
+// so the side data persists for the entire coded video sequence.
+if (s->sei_content_light_present > 0 &&
+IS_IRAP(s) && s->no_rasl_output_flag) {
+s->sei_content_light_present--;
+}
+if (s->sei_content_light_present) {
+AVContentLightMetadata *metadata =
+av_content_light_metadata_create_side_data(out);
+if (!metadata)
+return AVERROR(ENOMEM);
+metadata->MaxCLL  = s->max_content_light_level;
+metadata->MaxFALL = s->max_pic_average_light_level;
+
+av_log(s->avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n");
+av_log(s->avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n",
+   metadata->MaxCLL, metadata->MaxFALL);
+}
 
 return 0;
 }
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index cb8bd2e7e5..ffc3fdcac2 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -553,6 +553,11 @@ typedef struct HEVCContext {
 uint32_t max_mastering_luminance;
 

[libav-devel] [PATCH 8/8] avformat/dump : Display Content Light Level metadata

2017-04-07 Thread Steve Lhomme
Signed-off-by: James Almer 
---
 libavformat/dump.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index 3645e82d7b..090d5c1a9b 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -325,6 +325,14 @@ static void dump_mastering_display_metadata(void *ctx, 
AVPacketSideData* sd) {
av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
 }
 
+static void dump_content_light_metadata(void *ctx, AVPacketSideData* sd)
+{
+AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data;
+av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, "
+   "MaxCLL=%d, MaxFALL=%d",
+   metadata->MaxCLL, metadata->MaxFALL);
+}
+
 static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData 
*sd)
 {
 AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
@@ -416,6 +424,9 @@ static void dump_sidedata(void *ctx, AVStream *st, const 
char *indent)
 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
 dump_mastering_display_metadata(ctx, );
 break;
+case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
+dump_content_light_metadata(ctx, );
+break;
 default:
 av_log(ctx, AV_LOG_WARNING,
"unknown side data type %d (%d bytes)", sd.type, sd.size);
-- 
2.11.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 6/8] lavu: add support for Content Light Level side metadata

2017-04-07 Thread Steve Lhomme
As found in HEVC.

Signed-off-by: James Almer 
---
 doc/APIchanges |  5 +
 libavutil/frame.h  |  6 ++
 libavutil/mastering_display_metadata.c | 23 
 libavutil/mastering_display_metadata.h | 39 ++
 libavutil/version.h|  2 +-
 5 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index e8bb5a4012..4c35f727e6 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,11 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2016-04-xx - xxx - lavu 56.2.0 - mastering_display_metadata.h
+  Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, 
av_content_light_metadata_alloc()
+  and av_content_light_metadata_create_side_data() API, and 
AVContentLightMetadata
+  type to export content light level video properties.
+
 2017-04-xx - xxx - lavc 58.1.1 - avcodec.h
   Add AV_PKT_DATA_MASTERING_DISPLAY_METADATA.
 
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 881d8f0051..a6b50feb49 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -105,6 +105,12 @@ enum AVFrameSideDataType {
  * mastering display color volume.
  */
 AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
+
+/**
+ * Content light level (based on CTA-861.3). This payload contains data in
+ * the form of the AVContentLightMetadata struct.
+ */
+AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/mastering_display_metadata.c 
b/libavutil/mastering_display_metadata.c
index e1683e55c7..6069347617 100644
--- a/libavutil/mastering_display_metadata.c
+++ b/libavutil/mastering_display_metadata.c
@@ -41,3 +41,26 @@ AVMasteringDisplayMetadata 
*av_mastering_display_metadata_create_side_data(AVFra
 
 return (AVMasteringDisplayMetadata *)side_data->data;
 }
+
+AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size)
+{
+AVContentLightMetadata *metadata = 
av_mallocz(sizeof(AVContentLightMetadata));
+
+if (size)
+*size = sizeof(*metadata);
+
+return metadata;
+}
+
+AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
*frame)
+{
+AVFrameSideData *side_data = av_frame_new_side_data(frame,
+
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
+
sizeof(AVContentLightMetadata));
+if (!side_data)
+return NULL;
+
+memset(side_data->data, 0, sizeof(AVContentLightMetadata));
+
+return (AVContentLightMetadata *)side_data->data;
+}
diff --git a/libavutil/mastering_display_metadata.h 
b/libavutil/mastering_display_metadata.h
index 936533fec4..847b0b62c6 100644
--- a/libavutil/mastering_display_metadata.h
+++ b/libavutil/mastering_display_metadata.h
@@ -86,4 +86,43 @@ AVMasteringDisplayMetadata 
*av_mastering_display_metadata_alloc(void);
  */
 AVMasteringDisplayMetadata 
*av_mastering_display_metadata_create_side_data(AVFrame *frame);
 
+/**
+ * Content light level needed by to transmit HDR over HDMI (CTA-861.3).
+ *
+ * To be used as payload of a AVFrameSideData or AVPacketSideData with the
+ * appropriate type.
+ *
+ * @note The struct should be allocated with av_content_light_metadata_alloc()
+ *   and its size is not a part of the public ABI.
+ */
+typedef struct AVContentLightMetadata {
+/**
+ * Max content light level (cd/m^2).
+ */
+unsigned MaxCLL;
+
+/**
+ * Max average light level per frame (cd/m^2).
+ */
+unsigned MaxFALL;
+} AVContentLightMetadata;
+
+/**
+ * Allocate an AVContentLightMetadata structure and set its fields to
+ * default values. The resulting struct can be freed using av_freep().
+ *
+ * @return An AVContentLightMetadata filled with default values or NULL
+ * on failure.
+ */
+AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size);
+
+/**
+ * Allocate a complete AVContentLightMetadata and add it to the frame.
+ *
+ * @param frame The frame which side data is added to.
+ *
+ * @return The AVContentLightMetadata structure to be filled by caller.
+ */
+AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame 
*frame);
+
 #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index fd72ff431d..2c85120b64 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR  1
+#define LIBAVUTIL_VERSION_MINOR  2
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.11.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 5/8] lavf/dump.c: Print mastering display metadata

2017-04-07 Thread Steve Lhomme
From: Neil Birkbeck 

Signed-off-by: Neil Birkbeck 
Signed-off-by: Michael Niedermayer 
---
 libavformat/dump.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index c56895628d..3645e82d7b 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -25,6 +25,7 @@
 #include "libavutil/display.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/replaygain.h"
 #include "libavutil/spherical.h"
@@ -307,6 +308,23 @@ static void dump_cpb(void *ctx, AVPacketSideData *sd)
cpb->vbv_delay);
 }
 
+static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) {
+AVMasteringDisplayMetadata* metadata = 
(AVMasteringDisplayMetadata*)sd->data;
+av_log(ctx, AV_LOG_INFO, "Mastering Display Metadata, "
+   "has_primaries:%d has_luminance:%d "
+   "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) "
+   "min_luminance=%f, max_luminance=%f\n",
+   metadata->has_primaries, metadata->has_luminance,
+   av_q2d(metadata->display_primaries[0][0]),
+   av_q2d(metadata->display_primaries[0][1]),
+   av_q2d(metadata->display_primaries[1][0]),
+   av_q2d(metadata->display_primaries[1][1]),
+   av_q2d(metadata->display_primaries[2][0]),
+   av_q2d(metadata->display_primaries[2][1]),
+   av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]),
+   av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
+}
+
 static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData 
*sd)
 {
 AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data;
@@ -395,6 +413,9 @@ static void dump_sidedata(void *ctx, AVStream *st, const 
char *indent)
 av_log(ctx, AV_LOG_INFO, "spherical: ");
 dump_spherical(ctx, st->codecpar, );
 break;
+case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
+dump_mastering_display_metadata(ctx, );
+break;
 default:
 av_log(ctx, AV_LOG_WARNING,
"unknown side data type %d (%d bytes)", sd.type, sd.size);
-- 
2.11.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 4/8] libavcodec:add packet level support for mastering metadata

2017-04-07 Thread Steve Lhomme
From: Neil Birkbeck 

Some containers, like webm/mkv, will contain this mastering metadata.
This is analogous to the way 3D fpa data is handled (in frame and
packet side data).

Signed-off-by: Neil Birkbeck 
Signed-off-by: Michael Niedermayer 
---
 doc/APIchanges   | 3 +++
 libavcodec/avcodec.h | 7 +++
 libavcodec/decode.c  | 1 +
 libavcodec/version.h | 2 +-
 4 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5ce112262a..e8bb5a4012 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2017-04-xx - xxx - lavc 58.1.1 - avcodec.h
+  Add AV_PKT_DATA_MASTERING_DISPLAY_METADATA.
+
 2017-04-xx - xxx - lavu 56.1.0 - mastering_display_metadata.h
   Add mastering_display_metadata.h/c, av_mastering_display_metadata_alloc() 
   and av_mastering_display_metadata_create_side_data() API, and 
AVMasteringDisplayMetadata
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1c58fe2d68..fc1f2a4dfc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1068,6 +1068,13 @@ enum AVPacketSideDataType {
  * to the AVSphericalMapping structure.
  */
 AV_PKT_DATA_SPHERICAL,
+
+/**
+ * Mastering display metadata (based on SMPTE-2086:2014). This metadata
+ * should be associated with a video stream and containts data in the form
+ * of the AVMasteringDisplayMetadata struct.
+ */
+AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
 };
 
 typedef struct AVPacketSideData {
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index e4f6a0d727..4a05b8d089 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1029,6 +1029,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 { AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL },
 { AV_PKT_DATA_STEREO3D,  AV_FRAME_DATA_STEREO3D },
 { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE },
+{ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
 };
 
 frame->color_primaries = avctx->color_primaries;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 8943ef3d0f..774230b1ef 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 58
 #define LIBAVCODEC_VERSION_MINOR  1
-#define LIBAVCODEC_VERSION_MICRO  0
+#define LIBAVCODEC_VERSION_MICRO  1
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
2.11.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 3/8] lavc/hevc Parse SEI_TYPE_MASTERING_DISPLAY_INFO and propagate content into the AVMasteringDisplayMetadata side data.

2017-04-07 Thread Steve Lhomme
From: Neil Birkbeck 

Add support for parsing SEI_TYPE_MASTERING_DISPLAY_INFO and propagate contents 
into
the AVMasteringDisplayMetadata side data. Primaries are ordered in RGB order and
the values are converted to rationals ([0,1] for CEI 1931 Chroma coords,
and cd/m^2 for luma).

Signed-off-by: Neil Birkbeck 
Signed-off-by: Michael Niedermayer 
---
 libavcodec/hevc_sei.c | 26 ++
 libavcodec/hevcdec.c  | 52 +++
 libavcodec/hevcdec.h  |  7 +++
 3 files changed, 85 insertions(+)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1f8554ad5f..1105b51493 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -75,6 +75,30 @@ static int decode_nal_sei_decoded_picture_hash(HEVCContext 
*s)
 return 0;
 }
 
+static int decode_nal_sei_mastering_display_info(HEVCContext *s)
+{
+GetBitContext *gb = >HEVClc.gb;
+int i;
+// Mastering primaries
+for (i = 0; i < 3; i++) {
+s->display_primaries[i][0] = get_bits(gb, 16);
+s->display_primaries[i][1] = get_bits(gb, 16);
+}
+// White point (x, y)
+s->white_point[0] = get_bits(gb, 16);
+s->white_point[1] = get_bits(gb, 16);
+
+// Max and min luminance of mastering display
+s->max_mastering_luminance = get_bits_long(gb, 32);
+s->min_mastering_luminance = get_bits_long(gb, 32);
+
+// As this SEI message comes before the first frame that references it,
+// initialize the flag to 2 and decrement on IRAP access unit so it
+// persists for the coded video sequence (e.g., between two IRAPs)
+s->sei_mastering_display_info_present = 2;
+return 0;
+}
+
 static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
 {
 GetBitContext *gb = >HEVClc.gb;
@@ -129,6 +153,8 @@ static int decode_nal_sei_prefix(HEVCContext *s, int type, 
int size)
 return decode_nal_sei_frame_packing_arrangement(s);
 case SEI_TYPE_DISPLAY_ORIENTATION:
 return decode_nal_sei_display_orientation(s);
+case SEI_TYPE_MASTERING_DISPLAY_INFO:
+return decode_nal_sei_mastering_display_info(s);
 default:
 av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
 skip_bits_long(gb, 8 * size);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 6fe05d1b01..30d9194c60 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -27,6 +27,7 @@
 #include "libavutil/common.h"
 #include "libavutil/display.h"
 #include "libavutil/internal.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/md5.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -2404,6 +2405,57 @@ static int set_side_data(HEVCContext *s)
s->sei_hflip, s->sei_vflip);
 }
 
+// Decrement the mastering display flag when IRAP frame has 
no_rasl_output_flag=1
+// so the side data persists for the entire coded video sequence.
+if (s->sei_mastering_display_info_present > 0 &&
+IS_IRAP(s) && s->no_rasl_output_flag) {
+s->sei_mastering_display_info_present--;
+}
+if (s->sei_mastering_display_info_present) {
+// HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b
+const int mapping[3] = {2, 0, 1};
+const int chroma_den = 5;
+const int luma_den = 1;
+int i;
+AVMasteringDisplayMetadata *metadata =
+av_mastering_display_metadata_create_side_data(out);
+if (!metadata)
+return AVERROR(ENOMEM);
+
+for (i = 0; i < 3; i++) {
+const int j = mapping[i];
+metadata->display_primaries[i][0].num = s->display_primaries[j][0];
+metadata->display_primaries[i][0].den = chroma_den;
+metadata->display_primaries[i][1].num = s->display_primaries[j][1];
+metadata->display_primaries[i][1].den = chroma_den;
+}
+metadata->white_point[0].num = s->white_point[0];
+metadata->white_point[0].den = chroma_den;
+metadata->white_point[1].num = s->white_point[1];
+metadata->white_point[1].den = chroma_den;
+
+metadata->max_luminance.num = s->max_mastering_luminance;
+metadata->max_luminance.den = luma_den;
+metadata->min_luminance.num = s->min_mastering_luminance;
+metadata->min_luminance.den = luma_den;
+metadata->has_luminance = 1;
+metadata->has_primaries = 1;
+
+av_log(s->avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n");
+av_log(s->avctx, AV_LOG_DEBUG,
+   "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, 
%5.4f)\n",
+   av_q2d(metadata->display_primaries[0][0]),
+   av_q2d(metadata->display_primaries[0][1]),
+   av_q2d(metadata->display_primaries[1][0]),
+   av_q2d(metadata->display_primaries[1][1]),
+   

[libav-devel] [PATCH 1/8] hevc: properly handle no_rasl_output_flag when removing pictures from the DPB

2017-04-07 Thread Steve Lhomme
From: Hendrik Leppkes 

Fixes ticket #4185.

Reviewed-By: Mickael Raulet 
Signed-off-by: Hendrik Leppkes 
---
 libavcodec/hevcdec.c | 3 +++
 libavcodec/hevcdec.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 6a04858587..6fe05d1b01 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2421,6 +2421,8 @@ static int hevc_frame_start(HEVCContext *s)
 s->is_decoded= 0;
 s->first_nal_type= s->nal_unit_type;
 
+s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s);
+
 if (s->ps.pps->tiles_enabled_flag)
 lc->end_of_tiles_x = s->ps.pps->column_width[0] << 
s->ps.sps->log2_ctb_size;
 
@@ -3007,6 +3009,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 s->seq_output = s0->seq_output;
 s->pocTid0= s0->pocTid0;
 s->max_ra = s0->max_ra;
+s->no_rasl_output_flag = s0->no_rasl_output_flag;
 
 s->is_nalff= s0->is_nalff;
 s->nal_length_size = s0->nal_length_size;
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index ff192f67ae..64089bde75 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -484,6 +484,7 @@ typedef struct HEVCContext {
 int bs_height;
 
 int is_decoded;
+int no_rasl_output_flag;
 
 HEVCPredContext hpc;
 HEVCDSPContext hevcdsp;
-- 
2.11.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata

2017-04-07 Thread Steve Lhomme
From: Neil Birkbeck 

Adding mastering display metadata struct to avutil. The mastering display 
metadata contains information
about the mastering display color volume (SMPTE 2086:2014).

This info comes from HEVC in the SEI_TYPE_MASTERING_DISPLAY_INFO and is soon to 
be included in MKV:
https://mailarchive.ietf.org/arch/search/?email_list=cellar=1=sZyfPTM-QY69P-0omfOIiTN622o
so it is similar to SEI FPA / stereo_mode in MKV and as such this patch follows 
how AVStereo3D is implemented.

I'll add support to HEVC in a follow-up (and MKV when spec is approved).

Signed-off-by: Neil Birkbeck 
Signed-off-by: Michael Niedermayer 
---
 doc/APIchanges |  5 ++
 libavutil/Makefile |  2 +
 libavutil/frame.h  |  6 +++
 libavutil/mastering_display_metadata.c | 43 
 libavutil/mastering_display_metadata.h | 89 ++
 libavutil/version.h|  2 +-
 6 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 libavutil/mastering_display_metadata.c
 create mode 100644 libavutil/mastering_display_metadata.h

diff --git a/doc/APIchanges b/doc/APIchanges
index a0ca3b7ac0..5ce112262a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,11 @@ libavutil: 2017-03-23
 
 API changes, most recent first:
 
+2017-04-xx - xxx - lavu 56.1.0 - mastering_display_metadata.h
+  Add mastering_display_metadata.h/c, av_mastering_display_metadata_alloc() 
+  and av_mastering_display_metadata_create_side_data() API, and 
AVMasteringDisplayMetadata
+  type to export mastering metadata video properties.
+
 2017-03-xx - xxx - lavc 57.37.0 - avcodec.h
   Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at
   a later point.
diff --git a/libavutil/Makefile b/libavutil/Makefile
index 60e180c79d..3c5aca49e4 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -38,6 +38,7 @@ HEADERS = adler32.h   
  \
   log.h \
   macros.h  \
   mathematics.h \
+  mastering_display_metadata.h  \
   md5.h \
   mem.h \
   opt.h \
@@ -94,6 +95,7 @@ OBJS = adler32.o  
  \
log.o\
log2_tab.o   \
mathematics.o\
+   mastering_display_metadata.o \
md5.o\
mem.o\
opt.o\
diff --git a/libavutil/frame.h b/libavutil/frame.h
index f9ffb5bbbf..881d8f0051 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -99,6 +99,12 @@ enum AVFrameSideDataType {
  * libavutil/spherical.h.
  */
 AV_FRAME_DATA_SPHERICAL,
+/**
+ * Mastering display metadata associated with a video frame. The payload is
+ * an AVMasteringDisplayMetadata type and contains information about the
+ * mastering display color volume.
+ */
+AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
 };
 
 enum AVActiveFormatDescription {
diff --git a/libavutil/mastering_display_metadata.c 
b/libavutil/mastering_display_metadata.c
new file mode 100644
index 00..e1683e55c7
--- /dev/null
+++ b/libavutil/mastering_display_metadata.c
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2016 Neil Birkbeck 
+ *
+ * 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 
+#include 
+
+#include "mastering_display_metadata.h"
+#include "mem.h"
+
+AVMasteringDisplayMetadata 

Re: [libav-devel] [PATCH] matroskaenc: fix writing ProjectionPrivate element on Cubemap projections

2017-04-07 Thread Vittorio Giovara
On Fri, Apr 7, 2017 at 11:54 AM, Hendrik Leppkes  wrote:
> On Fri, Apr 7, 2017 at 11:32 AM, Vittorio Giovara
>  wrote:
>> On Thu, Apr 6, 2017 at 10:45 PM, James Almer  wrote:
>>> Calling put_ebml_binary() with sizeof(private) as argument is currently
>>> only valid for Equirectangular projections.
>>>
>>> Signed-off-by: James Almer 
>>> ---
>>> Please, be more careful when making cosmetic changes to make sure they
>>> don't also change how the code works.
>>> Not only this was writing invalid Cubemap files, but also dumping
>>> uninitialized data from stack in them.
>>
>> Hello James,
>> unfortunately this mistake was present in the original patch
>> (https://patches.libav.org/patch/63023/) and the cosmetic change you
>> mention was only to break the line past the 80th column.
>> Thanks for the fix anyway, probably Luca's approach is more future proof 
>> though.
>
> The issue wasn't present in the original patch because it used a
> separate (properly sized) private buffer, instead of using a shared
> one for all cases.

ok my bad then
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] matroskaenc: fix writing ProjectionPrivate element on Cubemap projections

2017-04-07 Thread Hendrik Leppkes
On Fri, Apr 7, 2017 at 11:32 AM, Vittorio Giovara
 wrote:
> On Thu, Apr 6, 2017 at 10:45 PM, James Almer  wrote:
>> Calling put_ebml_binary() with sizeof(private) as argument is currently
>> only valid for Equirectangular projections.
>>
>> Signed-off-by: James Almer 
>> ---
>> Please, be more careful when making cosmetic changes to make sure they
>> don't also change how the code works.
>> Not only this was writing invalid Cubemap files, but also dumping
>> uninitialized data from stack in them.
>
> Hello James,
> unfortunately this mistake was present in the original patch
> (https://patches.libav.org/patch/63023/) and the cosmetic change you
> mention was only to break the line past the 80th column.
> Thanks for the fix anyway, probably Luca's approach is more future proof 
> though.

The issue wasn't present in the original patch because it used a
separate (properly sized) private buffer, instead of using a shared
one for all cases.

- Hendrik
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH] matroska: Read only the data written in the scratch buffer

2017-04-07 Thread Luca Barbato
The private buffer is 20bytes but depending on the type only 12 bytes
are actually filled.
---

Like this, in case somebody does a similar copy+paste.

 libavformat/matroskaenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 34d9833..b8c434a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -686,7 +686,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
 avio_wb32(, spherical->bound_left);
 avio_wb32(, spherical->bound_right);
 put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
-private, sizeof(private));
+private, avio_tell());
 break;
 case AV_SPHERICAL_CUBEMAP:
 ffio_init_context(, private, 12, 1, NULL, NULL, NULL, NULL);
@@ -696,7 +696,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
AVIOContext *pb,
 avio_wb32(, 0); // layout
 avio_wb32(, spherical->padding);
 put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
-private, sizeof(private));
+private, avio_tell());
 break;
 default:
 av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
--
2.9.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] matroskaenc: fix writing ProjectionPrivate element on Cubemap projections

2017-04-07 Thread Vittorio Giovara
On Thu, Apr 6, 2017 at 10:45 PM, James Almer  wrote:
> Calling put_ebml_binary() with sizeof(private) as argument is currently
> only valid for Equirectangular projections.
>
> Signed-off-by: James Almer 
> ---
> Please, be more careful when making cosmetic changes to make sure they
> don't also change how the code works.
> Not only this was writing invalid Cubemap files, but also dumping
> uninitialized data from stack in them.

Hello James,
unfortunately this mistake was present in the original patch
(https://patches.libav.org/patch/63023/) and the cosmetic change you
mention was only to break the line past the 80th column.
Thanks for the fix anyway, probably Luca's approach is more future proof though.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 13/25] hwcontext: Improve allocation in derived contexts

2017-04-07 Thread Anton Khirnov
Quoting Mark Thompson (2017-04-02 20:37:13)
> On 31/03/17 20:14, Anton Khirnov wrote:
> > Quoting Mark Thompson (2017-03-05 00:57:40)
> >> Use the flags argument of av_hwframe_ctx_create_derived() to pass the
> >> mapping flags which will be used on allocation.  Also, set the format
> >> and hardware context on the allocated frame automatically - the user
> >> should not be required to do this themselves.
> >> ---
> >>  libavutil/hwcontext.c  | 14 +-
> >>  libavutil/hwcontext.h  |  4 +++-
> >>  libavutil/hwcontext_internal.h |  5 +
> >>  3 files changed, 21 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> >> index 4a47e258a..03cdd4701 100644
> >> --- a/libavutil/hwcontext.c
> >> +++ b/libavutil/hwcontext.c
> >> @@ -459,6 +459,11 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, 
> >> AVFrame *frame, int flags)
> >>  // and map the frame immediately.
> >>  AVFrame *src_frame;
> >>  
> >> +frame->format = ctx->format;
> >> +frame->hw_frames_ctx = av_buffer_ref(hwframe_ref);
> >> +if (!frame->hw_frames_ctx)
> >> +return AVERROR(ENOMEM);
> > 
> > Shouldn't this be done in av_hwframe_map() below?
> 
> No?  hw_frames_ctx needs to be set on the destination frame for 
> av_hwframe_map() to work.

Right, I wasn't thinking. Should be ok then.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 12/25] hwcontext: Add frame context mapping for nontrivial contexts

2017-04-07 Thread Anton Khirnov
Quoting Mark Thompson (2017-04-02 20:43:54)
> On 02/04/17 11:13, Anton Khirnov wrote:
> > Quoting Mark Thompson (2017-03-05 00:57:39)
> >> Some frames contexts are not usable without additional format-specific
> >> state in hwctx.  This adds new functions map_frames_from and
> >> map_frames_to to set this up appropriately when deriving a frames
> >> context which will require it to be set.
> >> ---
> >>  libavutil/hwcontext.c  | 9 -
> >>  libavutil/hwcontext_internal.h | 5 +
> >>  2 files changed, 13 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> >> index 8195a7245..4a47e258a 100644
> >> --- a/libavutil/hwcontext.c
> >> +++ b/libavutil/hwcontext.c
> >> @@ -820,7 +820,14 @@ int av_hwframe_ctx_create_derived(AVBufferRef 
> >> **derived_frame_ctx,
> >>  goto fail;
> >>  }
> >>  
> >> -ret = av_hwframe_ctx_init(dst_ref);
> >> +ret = AVERROR(ENOSYS);
> >> +if (src->internal->hw_type->map_frames_from)
> >> +ret = src->internal->hw_type->map_frames_from(dst, src, flags);
> >> +if (ret == AVERROR(ENOSYS) &&
> >> +dst->internal->hw_type->map_frames_to)
> >> +ret = dst->internal->hw_type->map_frames_to(dst, src, flags);
> >> +if (ret == AVERROR(ENOSYS))
> >> +ret = 0;
> > 
> > So if I'm reading this correctly, av_hwframe_ctx_init() is now never
> > called, even for cases where it used to be. What's the deal with that?
> 
> It never did anything - see the ctx->internal->source_frames check there.

Ok, then should that check be dropped?

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] configure: Escape elements being filtered

2017-04-07 Thread Luca Barbato
On 06/04/2017 18:25, Diego Biurrun wrote:
> On Thu, Apr 06, 2017 at 06:14:29PM +0200, Luca Barbato wrote:
>> The function is used to filter out ldflags arguments that may contain $.
>> Update filter() as well to be consistent.
>> ---
>>
>> Ping in form of updated patch.
>>
>>  configure | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> I still haven't seen the problem this is supposed to fix.
> 

Log on the machine I mentioned and issue and pass --cc=pathcc as I wrote
before :)

lu

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] matroskaenc: fix writing ProjectionPrivate element on Cubemap projections

2017-04-07 Thread Luca Barbato
On 06/04/2017 22:45, James Almer wrote:
> Calling put_ebml_binary() with sizeof(private) as argument is currently
> only valid for Equirectangular projections.
> 
> Signed-off-by: James Almer 
> ---
> Please, be more careful when making cosmetic changes to make sure they
> don't also change how the code works.
> Not only this was writing invalid Cubemap files, but also dumping
> uninitialized data from stack in them.
> 
>  libavformat/matroskaenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 34d983324..f6dade751 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -696,7 +696,7 @@ static int mkv_write_video_projection(AVFormatContext *s, 
> AVIOContext *pb,
>  avio_wb32(, 0); // layout
>  avio_wb32(, spherical->padding);
>  put_ebml_binary(dyn_cp, MATROSKA_ID_VIDEOPROJECTIONPRIVATE,
> -private, sizeof(private));
> +private, 12);
>  break;
>  default:
>  av_log(s, AV_LOG_WARNING, "Unknown projection type\n");
> 

Probably would be safer to use avio_tell() in both cases?

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/3] avutil/spherical: add functions to retrieve and request projection names

2017-04-07 Thread Luca Barbato
On 04/04/2017 22:24, James Almer wrote:
> +const char *av_spherical_projection_name(enum AVSphericalProjection 
> projection)
> +{
> +if ((unsigned)projection >= FF_ARRAY_ELEMS(spherical_projection_names))
> +return "unknown";
> +
> +return spherical_projection_names[projection];
> +}
> +
> +int av_spherical_from_name(const char *name)
> +{
> +int i;
> +
> +for (i = 0; i < FF_ARRAY_ELEMS(spherical_projection_names); i++) {
> +size_t len = strlen(spherical_projection_names[i]);
> +if (!strncmp(spherical_projection_names[i], name, len))
> +return i;
> +}
> +
> +return -1;
> +}

Having an explicit NONE or UNKNOWN with the negative value sounds
better. Then av_spherical_from_name can output the enum directly...

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel