[vlc-commits] demux: mp4: split MPEG4 object types lookup

Francois Cartegnie git at videolan.org
Mon May 20 16:58:02 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue May 14 16:27:35 2019 +0200| [016e4de3c8c8bcaec926d258d69cea418e3e69fd] | committer: Francois Cartegnie

demux: mp4: split MPEG4 object types lookup

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

 modules/demux/Makefile.am   |   4 +-
 modules/demux/mp4/essetup.c |  86 +++------------------------------
 modules/demux/mp4/mpeg4.h   | 113 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+), 80 deletions(-)

diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 536781d9a1..59ce3003fb 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -210,7 +210,9 @@ libmp4_plugin_la_SOURCES = demux/mp4/mp4.c demux/mp4/mp4.h \
                            demux/mp4/languages.h \
                            demux/mp4/heif.c demux/mp4/heif.h \
                            demux/mp4/avci.h \
-                           demux/mp4/essetup.c demux/mp4/meta.c \
+                           demux/mp4/essetup.c \
+                           demux/mp4/meta.c \
+                           demux/mp4/mpeg4.h \
                            demux/mp4/coreaudio.h \
                            demux/av1_unpack.h \
                            demux/asf/asfpacket.c demux/asf/asfpacket.h \
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 631d4382eb..44ea84eb14 100644
--- a/modules/demux/mp4/essetup.c
+++ b/modules/demux/mp4/essetup.c
@@ -27,8 +27,8 @@
 #include "mp4.h"
 #include "avci.h"
 #include "../xiph.h"
-#include "../../packetizer/dts_header.h"
 #include "../../packetizer/iso_color_tables.h"
+#include "mpeg4.h"
 
 #include <vlc_demux.h>
 #include <vlc_aout.h>
@@ -52,86 +52,8 @@ static void SetupGlobalExtensions( mp4_track_t *p_track, MP4_Box_t *p_sample )
 static void SetupESDS( demux_t *p_demux, mp4_track_t *p_track, const MP4_descriptor_decoder_config_t *p_decconfig )
 {
     /* First update information based on i_objectTypeIndication */
-    /* See 14496-1 and http://mp4ra.org/#/object_types */
     switch( p_decconfig->i_objectProfileIndication )
     {
-    case( 0x20 ): /* MPEG4 VIDEO */
-        p_track->fmt.i_codec = VLC_CODEC_MP4V;
-        break;
-    case( 0x21 ): /* H.264 */
-        p_track->fmt.i_codec = VLC_CODEC_H264;
-        break;
-    case( 0x40):
-    case( 0x41):
-        p_track->fmt.i_codec = VLC_CODEC_MP4A;
-        if( p_decconfig->i_decoder_specific_info_len >= 2 &&
-                p_decconfig->p_decoder_specific_info[0]       == 0xF8 &&
-                (p_decconfig->p_decoder_specific_info[1]&0xE0) == 0x80 )
-        {
-            p_track->fmt.i_codec = VLC_CODEC_ALS;
-        }
-        break;
-    case( 0x60):
-    case( 0x61):
-    case( 0x62):
-    case( 0x63):
-    case( 0x64):
-    case( 0x65): /* MPEG2 video */
-        p_track->fmt.i_codec = VLC_CODEC_MPGV;
-        break;
-        /* Theses are MPEG2-AAC */
-    case( 0x66): /* main profile */
-    case( 0x67): /* Low complexity profile */
-    case( 0x68): /* Scaleable Sampling rate profile */
-        p_track->fmt.i_codec = VLC_CODEC_MP4A;
-        break;
-        /* True MPEG 2 audio */
-    case( 0x69):
-        p_track->fmt.i_codec = VLC_CODEC_MPGA;
-        break;
-    case( 0x6a): /* MPEG1 video */
-        p_track->fmt.i_codec = VLC_CODEC_MPGV;
-        break;
-    case( 0x6b): /* MPEG1 audio */
-        p_track->fmt.i_codec = VLC_CODEC_MPGA;
-        break;
-    case( 0x6c ): /* jpeg */
-        p_track->fmt.i_codec = VLC_CODEC_JPEG;
-        break;
-    case( 0x6d ): /* png */
-        p_track->fmt.i_codec = VLC_CODEC_PNG;
-        break;
-    case( 0x6e ): /* jpeg2000 */
-        p_track->fmt.i_codec = VLC_FOURCC( 'M','J','2','C' );
-        break;
-    case( 0xa3 ): /* vc1 */
-        p_track->fmt.i_codec = VLC_CODEC_VC1;
-        break;
-    case( 0xa4 ):
-        p_track->fmt.i_codec = VLC_CODEC_DIRAC;
-        break;
-    case( 0xa5 ):
-        p_track->fmt.i_codec = VLC_CODEC_A52;
-        break;
-    case( 0xa6 ):
-        p_track->fmt.i_codec = VLC_CODEC_EAC3;
-        break;
-    case( 0xa9 ): /* dts */
-        p_track->fmt.i_codec = VLC_CODEC_DTS;
-        break;
-    case( 0xaa ): /* DTS-HD HRA */
-    case( 0xab ): /* DTS-HD Master Audio */
-        p_track->fmt.i_profile = PROFILE_DTS_HD;
-        p_track->fmt.i_codec = VLC_CODEC_DTS;
-        break;
-    case( 0xac ): /* Extension Substream containing only LBR */
-        p_track->fmt.i_profile = PROFILE_DTS_EXPRESS;
-        p_track->fmt.i_codec = VLC_CODEC_DTS;
-        break;
-    case( 0xDD ):
-        p_track->fmt.i_codec = VLC_CODEC_VORBIS;
-        break;
-
         /* Private ID */
     case( 0xe0 ): /* NeroDigital: dvd subs */
         if( p_track->fmt.i_cat == SPU_ES )
@@ -152,6 +74,12 @@ static void SetupESDS( demux_t *p_demux, mp4_track_t *p_track, const MP4_descrip
 
         /* Fallback */
     default:
+        if( MPEG4_Codec_By_ObjectType( p_decconfig->i_objectProfileIndication,
+                                       p_decconfig->p_decoder_specific_info,
+                                       p_decconfig->i_decoder_specific_info_len,
+                                       &p_track->fmt.i_codec,
+                                       &p_track->fmt.i_profile ) )
+            break;
         /* Unknown entry, but don't touch i_fourcc */
         msg_Warn( p_demux,
                   "unknown objectProfileIndication(0x%x) (Track[ID 0x%x])",
diff --git a/modules/demux/mp4/mpeg4.h b/modules/demux/mp4/mpeg4.h
new file mode 100644
index 0000000000..536c813dac
--- /dev/null
+++ b/modules/demux/mp4/mpeg4.h
@@ -0,0 +1,113 @@
+/*****************************************************************************
+ * mpeg4.h: MPEG4 ISO-14496-1 definitions
+ *****************************************************************************
+ * Copyright (C) 2001-2019 VLC authors, VideoLAN and VideoLabs
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifndef MP4_MPEG4_H
+#define MP4_MPEG4_H
+
+#include <vlc_codec.h>
+#include "../../packetizer/dts_header.h"
+
+static inline bool MPEG4_Codec_By_ObjectType(uint8_t oti,
+                                              const uint8_t *p_dsi,
+                                              size_t i_dsi,
+                                              vlc_fourcc_t *pi_codec,
+                                              int *pi_profile)
+{
+    /* See 14496-1 and http://mp4ra.org/#/object_types */
+    switch(oti)
+    {
+        case 0x20: /* MPEG4 VIDEO */
+            *pi_codec = VLC_CODEC_MP4V;
+            break;
+        case 0x21: /* H.264 */
+            *pi_codec = VLC_CODEC_H264;
+            break;
+        case 0x40:
+        case 0x41:
+            *pi_codec = VLC_CODEC_MP4A;
+            if(i_dsi >= 2 && p_dsi[0] == 0xF8 && (p_dsi[1]&0xE0)== 0x80)
+                *pi_codec = VLC_CODEC_ALS;
+            break;
+        case 0x60:
+        case 0x61:
+        case 0x62:
+        case 0x63:
+        case 0x64:
+        case 0x65: /* MPEG2 video */
+            *pi_codec = VLC_CODEC_MPGV;
+            break;
+            /* Theses are MPEG2-AAC */
+        case 0x66: /* main profile */
+        case 0x67: /* Low complexity profile */
+        case 0x68: /* Scaleable Sampling rate profile */
+            *pi_codec = VLC_CODEC_MP4A;
+            break;
+            /* True MPEG 2 audio */
+        case 0x69:
+            *pi_codec = VLC_CODEC_MPGA;
+            break;
+        case 0x6a: /* MPEG1 video */
+            *pi_codec = VLC_CODEC_MPGV;
+            break;
+        case 0x6b: /* MPEG1 audio */
+            *pi_codec = VLC_CODEC_MPGA;
+            break;
+        case 0x6c: /* jpeg */
+            *pi_codec = VLC_CODEC_JPEG;
+            break;
+        case 0x6d: /* png */
+            *pi_codec = VLC_CODEC_PNG;
+            break;
+        case 0x6e: /* jpeg2000 */
+            *pi_codec = VLC_FOURCC('M','J','2','C');
+            break;
+        case 0xa3: /* vc1 */
+            *pi_codec = VLC_CODEC_VC1;
+            break;
+        case 0xa4:
+            *pi_codec = VLC_CODEC_DIRAC;
+            break;
+        case 0xa5:
+            *pi_codec = VLC_CODEC_A52;
+            break;
+        case 0xa6:
+            *pi_codec = VLC_CODEC_EAC3;
+            break;
+        case 0xa9: /* dts */
+            *pi_codec = VLC_CODEC_DTS;
+            break;
+        case 0xaa: /* DTS-HD HRA */
+        case 0xab: /* DTS-HD Master Audio */
+            *pi_profile = PROFILE_DTS_HD;
+            *pi_codec = VLC_CODEC_DTS;
+            break;
+        case 0xac: /* Extension Substream containing only LBR */
+            *pi_profile = PROFILE_DTS_EXPRESS;
+            *pi_codec = VLC_CODEC_DTS;
+            break;
+        case 0xDD:
+            *pi_codec = VLC_CODEC_VORBIS;
+            break;
+        default:
+            return false;
+    }
+    return true;
+}
+
+#endif



More information about the vlc-commits mailing list