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

Francois Cartegnie git at videolan.org
Mon Mar 30 16:15:41 CEST 2020


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

demux: mp4: split MPEG4 object types lookup

(cherry picked from commit 016e4de3c8c8bcaec926d258d69cea418e3e69fd)

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

 modules/demux/Makefile.am   |   1 +
 modules/demux/mp4/essetup.c |  80 +++----------------------------
 modules/demux/mp4/mpeg4.h   | 111 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 119 insertions(+), 73 deletions(-)

diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index b011e7dec2..f7992fee1b 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -208,6 +208,7 @@ libmp4_plugin_la_SOURCES = demux/mp4/mp4.c demux/mp4/mp4.h \
                            demux/mp4/fragments.c demux/mp4/fragments.h \
                            demux/mp4/libmp4.c demux/mp4/libmp4.h \
                            demux/mp4/languages.h \
+                           demux/mp4/mpeg4.h \
                            demux/av1_unpack.h \
                            demux/asf/asfpacket.c demux/asf/asfpacket.h \
                            demux/mp4/avci.h \
diff --git a/modules/demux/mp4/essetup.c b/modules/demux/mp4/essetup.c
index 9c27ed04e5..bc37414251 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>
@@ -54,78 +54,6 @@ static void SetupESDS( demux_t *p_demux, mp4_track_t *p_track, const MP4_descrip
     /* First update information based on i_objectTypeIndication */
     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( 0xaa ): /* DTS-HD HRA */
-    case( 0xab ): /* DTS-HD Master Audio */
-        p_track->fmt.i_profile = PROFILE_DTS_HD;
-        /* fallthrough */
-    case( 0xa9 ): /* dts */
-        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 )
@@ -146,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..9d666982d2
--- /dev/null
+++ b/modules/demux/mp4/mpeg4.h
@@ -0,0 +1,111 @@
+/*****************************************************************************
+ * 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_codec = VLC_CODEC_DTS;
+            break;
+        case 0xac: /* Extension Substream containing only LBR */
+            *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