[vlc-commits] [Git][videolan/vlc][master] demux: mp4: add support for ISO/IEC 23003-5 audio

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Jan 6 10:27:21 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
c8d319ed by Francois Cartegnie at 2022-01-06T09:45:28+00:00
demux: mp4: add support for ISO/IEC 23003-5 audio

refs #26427

- - - - -


3 changed files:

- modules/demux/mp4/essetup.c
- modules/demux/mp4/libmp4.c
- modules/demux/mp4/libmp4.h


Changes:

=====================================
modules/demux/mp4/essetup.c
=====================================
@@ -1036,6 +1036,35 @@ int SetupAudioES( demux_t *p_demux, const mp4_track_t *p_track,
             break;
         }
 
+        case ATOM_ipcm:
+        case ATOM_fpcm:
+        {
+            const MP4_Box_t *p_pcmC = MP4_BoxGet( p_sample, "pcmC" );
+            if( p_pcmC )
+            {
+                const vlc_fourcc_t lookup = i_sample_type +
+                        BOXDATA(p_pcmC)->i_sample_size +
+                       (BOXDATA(p_pcmC)->i_format_flags & 0x01);
+                const vlc_fourcc_t lookuptable[10][2] =
+                {
+                    { ATOM_fpcm + 32 + 0, VLC_CODEC_F32B },
+                    { ATOM_fpcm + 32 + 1, VLC_CODEC_F32L },
+                    { ATOM_fpcm + 64 + 0, VLC_CODEC_F64B },
+                    { ATOM_fpcm + 64 + 1, VLC_CODEC_F64L },
+                    { ATOM_ipcm + 16 + 0, VLC_CODEC_S16B },
+                    { ATOM_ipcm + 16 + 1, VLC_CODEC_S16L },
+                    { ATOM_ipcm + 24 + 0, VLC_CODEC_S24B },
+                    { ATOM_ipcm + 24 + 1, VLC_CODEC_S24L },
+                    { ATOM_ipcm + 32 + 0, VLC_CODEC_S32B },
+                    { ATOM_ipcm + 32 + 1, VLC_CODEC_S32L },
+                };
+                for( size_t i = 0; i<10; i++ )
+                    if( lookuptable[i][0] == lookup )
+                        p_fmt->i_codec = lookuptable[i][1];
+            }
+            break;
+        }
+
         case ATOM_in24:
             p_fmt->i_original_fourcc =
             p_fmt->i_codec = p_enda && BOXDATA(p_enda)->i_little_endian == 1 ?


=====================================
modules/demux/mp4/libmp4.c
=====================================
@@ -2496,6 +2496,20 @@ static int MP4_ReadBox_enda( stream_t *p_stream, MP4_Box_t *p_box )
     MP4_READBOX_EXIT( 1 );
 }
 
+static int MP4_ReadBox_pcmC( stream_t *p_stream, MP4_Box_t *p_box )
+{
+    MP4_READBOX_ENTER( MP4_Box_data_pcmC_t, NULL );
+    if(i_read != 6)
+        MP4_READBOX_EXIT( 0 );
+    uint32_t temp;
+    MP4_GET4BYTES(temp);
+    if(temp != 0) /* support only v0 */
+        MP4_READBOX_EXIT( 0 );
+    MP4_GET1BYTE(p_box->data.p_pcmC->i_format_flags);
+    MP4_GET1BYTE(p_box->data.p_pcmC->i_sample_size);
+    MP4_READBOX_EXIT( 1 );
+}
+
 static void MP4_FreeBox_sample_soun( MP4_Box_t *p_box )
 {
     free( p_box->data.p_sample_soun->p_qt_description );
@@ -4973,6 +4987,7 @@ static const struct
     { ATOM_fiel,    MP4_ReadBox_fiel,         0 },
     { ATOM_glbl,    MP4_ReadBox_Binary,       0 },
     { ATOM_enda,    MP4_ReadBox_enda,         0 },
+    { ATOM_pcmC,    MP4_ReadBox_pcmC,         0 }, /* ISO-IEC 23003-5 */
     { ATOM_iods,    MP4_ReadBox_iods,         0 },
     { ATOM_pasp,    MP4_ReadBox_pasp,         0 },
     { ATOM_btrt,    MP4_ReadBox_btrt,         0 }, /* codecs bitrate stsd/????/btrt */


=====================================
modules/demux/mp4/libmp4.h
=====================================
@@ -220,6 +220,11 @@ typedef int64_t stime_t;
 #define ATOM_fLaC VLC_FOURCC( 'f', 'L', 'a', 'C' )
 #define ATOM_dfLa VLC_FOURCC( 'd', 'f', 'L', 'a' )
 
+/* ISO-IEC 23003-5 */
+#define ATOM_fpcm VLC_FOURCC( 'f', 'p', 'c', 'm' )
+#define ATOM_ipcm VLC_FOURCC( 'i', 'p', 'c', 'm' )
+#define ATOM_pcmC VLC_FOURCC( 'p', 'c', 'm', 'C' )
+
 /* XiphQT */
 #define ATOM_fCtS VLC_FOURCC( 'f', 'C', 't', 'S' )
 #define ATOM_vCtH VLC_FOURCC( 'v', 'C', 't', 'H' )
@@ -1427,6 +1432,12 @@ typedef struct
 
 } MP4_Box_data_enda_t;
 
+typedef struct
+{
+    uint8_t i_format_flags;
+    uint8_t i_sample_size;
+} MP4_Box_data_pcmC_t;
+
 typedef struct
 {
     uint32_t i_entry_count;
@@ -1736,6 +1747,7 @@ typedef union MP4_Box_data_s
     MP4_Box_data_chan_t *p_chan;
     MP4_Box_data_srat_t *p_srat;
     MP4_Box_data_enda_t *p_enda;
+    MP4_Box_data_pcmC_t *p_pcmC;
     MP4_Box_data_keys_t *p_keys;
     MP4_Box_data_iods_t *p_iods;
     MP4_Box_data_btrt_t *p_btrt;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c8d319ed0f7df205ac5d278119e2819f7653549b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/c8d319ed0f7df205ac5d278119e2819f7653549b
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list