[vlc-commits] demux: libmp4: SmDm is fixed point

Francois Cartegnie git at videolan.org
Wed Aug 22 10:55:26 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Aug 22 10:43:14 2018 +0200| [dcb0c69563163968c2538504d9f619ab69fe44be] | committer: Francois Cartegnie

demux: libmp4: SmDm is fixed point

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

 modules/demux/mp4/libmp4.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index 046186d61b..f3c7b58676 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1916,7 +1916,7 @@ static int MP4_ReadBox_SmDm( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_Box_data_SmDm_t *p_SmDm = p_box->data.p_SmDm;
 
     /* SmDm: version/flags RGB */
-    /* mdcv: version/flags GBR */
+    /* mdcv: version/flags GBR or not */
     if( p_box->i_type != ATOM_mdcv )
     {
         uint8_t i_version;
@@ -1933,11 +1933,29 @@ static int MP4_ReadBox_SmDm( stream_t *p_stream, MP4_Box_t *p_box )
     {
         int index = (p_box->i_type != ATOM_mdcv) ? RGB2GBR[i/2] + i%2 : i;
         MP4_GET2BYTES( p_SmDm->primaries[index] );
+
+        /* convert from fixed point to 0.00002 resolution */
+        if(p_box->i_type != ATOM_mdcv)
+            p_SmDm->primaries[index] = 50000 *
+                    (double)p_SmDm->primaries[index] / (double)(1<<16);
     }
     for(int i=0; i<2; i++)
+    {
         MP4_GET2BYTES( p_SmDm->white_point[i] );
+        if(p_box->i_type != ATOM_mdcv)
+            p_SmDm->white_point[i] = 50000 *
+                    (double)p_SmDm->white_point[i] / (double)(1<<16);
+    }
+
     MP4_GET4BYTES( p_SmDm->i_luminanceMax );
     MP4_GET4BYTES( p_SmDm->i_luminanceMin );
+    if(p_box->i_type != ATOM_mdcv)
+    {
+        p_SmDm->i_luminanceMax = 10000 *
+                (double)p_SmDm->i_luminanceMax / (double) (1<<8);
+        p_SmDm->i_luminanceMin = 10000 *
+                (double)p_SmDm->i_luminanceMin / (double) (1<<14);
+    }
 
     MP4_READBOX_EXIT( 1 );
 }



More information about the vlc-commits mailing list