]> git.sesse.net Git - vlc/commitdiff
demux: libmp4: parse fiel extension atom
authorFrancois Cartegnie <fcvlcdev@free.fr>
Wed, 14 Jan 2015 16:28:41 +0000 (17:28 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Wed, 14 Jan 2015 17:01:50 +0000 (18:01 +0100)
modules/demux/mp4/libmp4.c
modules/demux/mp4/libmp4.h

index 7faaaa8beb39aec9f6752f74671166f5ca7ba2c8..03097c1ea7468499e142572bf44c56082113ebe9 100644 (file)
@@ -1871,6 +1871,30 @@ static int MP4_ReadBox_dvc1( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+static int MP4_ReadBox_fiel( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_Box_data_fiel_t *p_fiel;
+    MP4_READBOX_ENTER( MP4_Box_data_fiel_t );
+    p_fiel = p_box->data.p_fiel;
+    if(i_read < 2)
+        MP4_READBOX_EXIT( 0 );
+    if(p_peek[0] == 2) /* Interlaced */
+    {
+        /*
+         * 0 – There is only one field.
+         * 1 – T is displayed earliest, T is stored first in the file.
+         * 6 – B is displayed earliest, B is stored first in the file.
+         * 9 – B is displayed earliest, T is stored first in the file.
+         * 14 – T is displayed earliest, B is stored first in the file.
+        */
+        if(p_peek[1] == 1 || p_peek[1] == 9)
+            p_fiel->i_flags = BLOCK_FLAG_TOP_FIELD_FIRST;
+        else if(p_peek[1] == 6 || p_peek[1] == 14)
+            p_fiel->i_flags = BLOCK_FLAG_BOTTOM_FIELD_FIRST;
+    }
+    MP4_READBOX_EXIT( 1 );
+}
+
 static int MP4_ReadBox_enda( stream_t *p_stream, MP4_Box_t *p_box )
 {
     MP4_Box_data_enda_t *p_enda;
@@ -3673,6 +3697,7 @@ static const struct
     { ATOM_dac3,    MP4_ReadBox_dac3,         MP4_FreeBox_Common, 0 },
     { ATOM_dec3,    MP4_ReadBox_dec3,         MP4_FreeBox_Common, 0 },
     { ATOM_dvc1,    MP4_ReadBox_dvc1,         MP4_FreeBox_Common, 0 },
+    { ATOM_fiel,    MP4_ReadBox_fiel,         MP4_FreeBox_Common, 0 },
     { ATOM_glbl,    MP4_ReadBox_Binary,       MP4_FreeBox_Binary, ATOM_FFV1 },
     { ATOM_enda,    MP4_ReadBox_enda,         MP4_FreeBox_Common, 0 },
     { ATOM_iods,    MP4_ReadBox_iods,         MP4_FreeBox_Common, 0 },
index 0486ed94dbf101d55d6503aa52795edb14a51d37..6a646598b66ffd014f30b946762e47392aa3c7ed 100644 (file)
 #define ATOM_avcC VLC_FOURCC( 'a', 'v', 'c', 'C' )
 #define ATOM_m4ds VLC_FOURCC( 'm', '4', 'd', 's' )
 
+#define ATOM_fiel VLC_FOURCC( 'f', 'i', 'e', 'l' )
 #define ATOM_glbl VLC_FOURCC( 'g', 'l', 'b', 'l' )
 #define ATOM_hvcC VLC_FOURCC( 'h', 'v', 'c', 'C' )
 
@@ -1224,6 +1225,11 @@ typedef struct
 
 } MP4_Box_data_dvc1_t;
 
+typedef struct
+{
+    uint32_t i_flags;
+} MP4_Box_data_fiel_t;
+
 typedef struct
 {
     uint16_t i_little_endian;
@@ -1414,6 +1420,7 @@ typedef union MP4_Box_data_s
     MP4_Box_data_dac3_t *p_dac3;
     MP4_Box_data_dec3_t *p_dec3;
     MP4_Box_data_dvc1_t *p_dvc1;
+    MP4_Box_data_fiel_t *p_fiel;
     MP4_Box_data_chan_t *p_chan;
     MP4_Box_data_enda_t *p_enda;
     MP4_Box_data_keys_t *p_keys;