1 /*****************************************************************************
2  * mpeg4.h: MPEG4 ISO-14496-1 definitions
3  *****************************************************************************
4  * Copyright (C) 2001-2019 VLC authors, VideoLAN and VideoLabs
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20 #ifndef MP4_MPEG4_H
21 #define MP4_MPEG4_H
22 
23 #include <vlc_codec.h>
24 #include "../../packetizer/dts_header.h"
25 
MPEG4_Codec_By_ObjectType(uint8_t oti,const uint8_t * p_dsi,size_t i_dsi,vlc_fourcc_t * pi_codec,int * pi_profile)26 static inline bool MPEG4_Codec_By_ObjectType(uint8_t oti,
27                                               const uint8_t *p_dsi,
28                                               size_t i_dsi,
29                                               vlc_fourcc_t *pi_codec,
30                                               int *pi_profile)
31 {
32     /* See 14496-1 and http://mp4ra.org/#/object_types */
33     switch(oti)
34     {
35         case 0x20: /* MPEG4 VIDEO */
36             *pi_codec = VLC_CODEC_MP4V;
37             break;
38         case 0x21: /* H.264 */
39             *pi_codec = VLC_CODEC_H264;
40             break;
41         case 0x40:
42         case 0x41:
43             *pi_codec = VLC_CODEC_MP4A;
44             if(i_dsi >= 2 && p_dsi[0] == 0xF8 && (p_dsi[1]&0xE0)== 0x80)
45                 *pi_codec = VLC_CODEC_ALS;
46             break;
47         case 0x60:
48         case 0x61:
49         case 0x62:
50         case 0x63:
51         case 0x64:
52         case 0x65: /* MPEG2 video */
53             *pi_codec = VLC_CODEC_MPGV;
54             break;
55             /* Theses are MPEG2-AAC */
56         case 0x66: /* main profile */
57         case 0x67: /* Low complexity profile */
58         case 0x68: /* Scaleable Sampling rate profile */
59             *pi_codec = VLC_CODEC_MP4A;
60             break;
61             /* True MPEG 2 audio */
62         case 0x69:
63             *pi_codec = VLC_CODEC_MPGA;
64             break;
65         case 0x6a: /* MPEG1 video */
66             *pi_codec = VLC_CODEC_MPGV;
67             break;
68         case 0x6b: /* MPEG1 audio */
69             *pi_codec = VLC_CODEC_MPGA;
70             break;
71         case 0x6c: /* jpeg */
72             *pi_codec = VLC_CODEC_JPEG;
73             break;
74         case 0x6d: /* png */
75             *pi_codec = VLC_CODEC_PNG;
76             break;
77         case 0x6e: /* jpeg2000 */
78             *pi_codec = VLC_FOURCC('M','J','2','C');
79             break;
80         case 0xa3: /* vc1 */
81             *pi_codec = VLC_CODEC_VC1;
82             break;
83         case 0xa4:
84             *pi_codec = VLC_CODEC_DIRAC;
85             break;
86         case 0xa5:
87             *pi_codec = VLC_CODEC_A52;
88             break;
89         case 0xa6:
90             *pi_codec = VLC_CODEC_EAC3;
91             break;
92         case 0xa9: /* dts */
93             *pi_codec = VLC_CODEC_DTS;
94             break;
95         case 0xaa: /* DTS-HD HRA */
96         case 0xab: /* DTS-HD Master Audio */
97             *pi_codec = VLC_CODEC_DTS;
98             break;
99         case 0xac: /* Extension Substream containing only LBR */
100             *pi_codec = VLC_CODEC_DTS;
101             break;
102         case 0xDD:
103             *pi_codec = VLC_CODEC_VORBIS;
104             break;
105         default:
106             return false;
107     }
108     return true;
109 }
110 
111 #endif
112