[vlc-devel] [PATCH 1/2] avcodec: video: update the decoder output when HDR10 metadata change

Steve Lhomme robux4 at videolabs.io
Thu Apr 6 17:42:40 CEST 2017


So the output format is actually updated with HDR10 metadata. If the demuxer or
packetizer didn't fill these metadata the vout will not know it's outputing
HDR10.
---
 modules/codec/avcodec/video.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index b6a12b7def..f027eaec45 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -1035,6 +1035,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
         p_pic->b_progressive = !frame->interlaced_frame;
         p_pic->b_top_field_first = frame->top_field_first;
 
+        bool format_changed = false;
 #if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 16, 101 ) )
         const AVFrameSideData *metadata =
                 av_frame_get_side_data( frame,
@@ -1065,6 +1066,14 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
                 p_pic->format.mastering.white_point[0] = hdr_meta->white_point[0].num;
                 p_pic->format.mastering.white_point[1] = hdr_meta->white_point[1].num;
             }
+
+            if ( memcmp( &p_dec->fmt_out.video.mastering,
+                         &p_pic->format.mastering,
+                         sizeof(p_pic->format.mastering) ) )
+            {
+                p_dec->fmt_out.video.mastering = p_pic->format.mastering;
+                format_changed = true;
+            }
         }
 #endif
 #if (LIBAVUTIL_VERSION_MICRO >= 100 && LIBAVUTIL_VERSION_INT >= AV_VERSION_INT( 55, 54, 100 ) )
@@ -1077,10 +1086,20 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block, bool *error
                     (const AVContentLightMetadata *) metadata_lt->data;
             p_pic->format.ligthing.MaxCLL = light_meta->MaxCLL;
             p_pic->format.ligthing.MaxFALL = light_meta->MaxFALL;
+            if ( memcmp( &p_dec->fmt_out.video.ligthing,
+                         &p_pic->format.ligthing,
+                         sizeof(p_pic->format.ligthing) ) )
+            {
+                p_dec->fmt_out.video.ligthing  = p_pic->format.ligthing;
+                format_changed = true;
+            }
         }
 #endif
         av_frame_free(&frame);
 
+        if (format_changed)
+            decoder_UpdateVideoFormat( p_dec );
+
         /* Send decoded frame to vout */
         if (i_pts > VLC_TS_INVALID)
         {
-- 
2.11.1



More information about the vlc-devel mailing list