[vlc-commits] demux: mp4: read vp8/9/10 mastering display

Francois Cartegnie git at videolan.org
Tue Mar 6 11:40:39 CET 2018


vlc/vlc-3.0 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Mar  5 16:35:38 2018 +0100| [393ab4ffd4b66e7763514f4787d25d458c44249a] | committer: Francois Cartegnie

demux: mp4: read vp8/9/10 mastering display

(cherry picked from commit f29e7827d49baa9f3c33b6aaf36804ce6ef08caf)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=393ab4ffd4b66e7763514f4787d25d458c44249a
---

 modules/demux/mp4/essetup.c | 11 +++++++++++
 modules/demux/mp4/libmp4.c  | 16 ++++++++++++++++
 modules/demux/mp4/libmp4.h  | 10 ++++++++++
 3 files changed, 37 insertions(+)

diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index b7a6ad9157..c6dff52d81 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -716,6 +716,17 @@ int SetupVideoES( demux_t *p_demux, mp4_track_t *p_track, MP4_Box_t *p_sample )
                                 p_data->i_codec_init_datasize );
                     }
                 }
+
+                const MP4_Box_t *p_SmDm = MP4_BoxGet( p_sample, "SmDm" );
+                if( p_SmDm && BOXDATA(p_SmDm) )
+                {
+                    memcpy( p_track->fmt.video.mastering.primaries,
+                            BOXDATA(p_SmDm)->primaries, sizeof(uint16_t) * 6 );
+                    memcpy( p_track->fmt.video.mastering.white_point,
+                            BOXDATA(p_SmDm)->white_point, sizeof(uint16_t) * 2 );
+                    p_track->fmt.video.mastering.max_luminance = BOXDATA(p_SmDm)->i_luminanceMax;
+                    p_track->fmt.video.mastering.min_luminance = BOXDATA(p_SmDm)->i_luminanceMin;
+                }
             }
         }
         break;
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index c88b7d2a9d..eacbf420b9 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1993,6 +1993,21 @@ static int MP4_ReadBox_vpcC( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+static int MP4_ReadBox_SmDm( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_SmDm_t, NULL );
+    MP4_Box_data_SmDm_t *p_SmDm = p_box->data.p_SmDm;
+
+    for(int i=0; i<6; i++)
+        MP4_GET2BYTES( p_SmDm->primaries[i] );
+    for(int i=0; i<2; i++)
+        MP4_GET2BYTES( p_SmDm->white_point[i] );
+    MP4_GET4BYTES( p_SmDm->i_luminanceMax );
+    MP4_GET4BYTES( p_SmDm->i_luminanceMin );
+
+    MP4_READBOX_EXIT( 1 );
+}
+
 static void MP4_FreeBox_WMA2( MP4_Box_t *p_box )
 {
     FREENULL( p_box->data.p_WMA2->p_extra );
@@ -4425,6 +4440,7 @@ static const struct
     { ATOM_vpcC,    MP4_ReadBox_vpcC,         ATOM_vp08 },
     { ATOM_vpcC,    MP4_ReadBox_vpcC,         ATOM_vp09 },
     { ATOM_vpcC,    MP4_ReadBox_vpcC,         ATOM_vp10 },
+    { ATOM_SmDm,    MP4_ReadBox_SmDm,         ATOM_vpcC }, /* vpx mastering display */
     { ATOM_dac3,    MP4_ReadBox_dac3,         0 },
     { ATOM_dec3,    MP4_ReadBox_dec3,         0 },
     { ATOM_dvc1,    MP4_ReadBox_dvc1,         ATOM_vc1  },
diff --git a/modules/demux/mp4/libmp4.h b/modules/demux/mp4/libmp4.h
index f129e1d166..dd65e8da1d 100644
--- a/modules/demux/mp4/libmp4.h
+++ b/modules/demux/mp4/libmp4.h
@@ -384,6 +384,7 @@ typedef int64_t stime_t;
 #define ATOM_gsst VLC_FOURCC( 'g', 's', 's', 't' )
 #define ATOM_gstd VLC_FOURCC( 'g', 's', 't', 'd' )
 #define ATOM_colr VLC_FOURCC( 'c', 'o', 'l', 'r' )
+#define ATOM_SmDm VLC_FOURCC( 'S', 'm', 'D', 'm' )
 
 #define ATOM_0x40PRM VLC_FOURCC( '@', 'P', 'R', 'M' )
 #define ATOM_0x40PRQ VLC_FOURCC( '@', 'P', 'R', 'Q' )
@@ -1285,6 +1286,14 @@ typedef struct
 
 typedef struct
 {
+    uint16_t primaries[3*2]; /* G,B,R / x,y */
+    uint16_t white_point[2]; /* x,y */
+    uint32_t i_luminanceMax;
+    uint32_t i_luminanceMin;
+} MP4_Box_data_SmDm_t;
+
+typedef struct
+{
     WAVEFORMATEX Format;
     uint32_t i_extra;
     char    *p_extra;
@@ -1682,6 +1691,7 @@ typedef union MP4_Box_data_s
     MP4_Box_data_tsel_t *p_tsel;
     MP4_Box_data_load_t *p_load;
     MP4_Box_data_vpcC_t *p_vpcC;
+    MP4_Box_data_SmDm_t *p_SmDm;
 
     MP4_Box_data_tfra_t *p_tfra;
     MP4_Box_data_mfro_t *p_mfro;



More information about the vlc-commits mailing list