1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2010-2015 L-SMASH project
6 * Authors: Takashi Hirata <silverfilain@gmail.com>
7 * Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
9 * Permission to use, copy, modify, and/or distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 *****************************************************************************/
22 /* This file is available under an ISC license. */
27 /***************************************************************************
29 ***************************************************************************/
31 /* ODProfileLevelIndication */
34 MP4SYS_OD_PLI_Forbidden
= 0x00, /* Forbidden */
35 MP4SYS_OD_PLI_NOT_SPECIFIED
= 0xFE, /* no OD profile specified */
36 MP4SYS_OD_PLI_NONE_REQUIRED
= 0xFF, /* no OD capability required */
37 } mp4sys_ODProfileLevelIndication
;
39 /* sceneProfileLevelIndication */
42 MP4SYS_SCENE_PLI_RESERVED
= 0x00, /* Reserved for ISO use */
43 MP4SYS_SCENE_PLI_Simple2D_L1
= 0x01, /* Simple 2D L1 */
44 MP4SYS_SCENE_PLI_Simple2D_L2
= 0x02, /* Simple 2D L2 */
45 MP4SYS_SCENE_PLI_Audio_L1
= 0x03, /* Audio L1 */
46 MP4SYS_SCENE_PLI_Audio_L2
= 0x04, /* Audio L2 */
47 MP4SYS_SCENE_PLI_Audio_L3
= 0x05, /* Audio L3 */
48 MP4SYS_SCENE_PLI_Audio_L4
= 0x06, /* Audio L4 */
49 MP4SYS_SCENE_PLI_3D_Audio_L1
= 0x07, /* 3D Audio L1 */
50 MP4SYS_SCENE_PLI_3D_Audio_L2
= 0x08, /* 3D Audio L2 */
51 MP4SYS_SCENE_PLI_3D_Audio_L3
= 0x09, /* 3D Audio L3 */
52 MP4SYS_SCENE_PLI_3D_Audio_L4
= 0x0A, /* 3D Audio L4 */
53 MP4SYS_SCENE_PLI_Basic2D_L1
= 0x0B, /* Basic 2D L1 */
54 MP4SYS_SCENE_PLI_Core2D_L1
= 0x0C, /* Core 2D L1 */
55 MP4SYS_SCENE_PLI_Core2D_L2
= 0x0D, /* Core 2D L2 */
56 MP4SYS_SCENE_PLI_Advanced2D_L1
= 0x0E, /* Advanced 2D L1 */
57 MP4SYS_SCENE_PLI_Advanced2D_L2
= 0x0F, /* Advanced 2D L2 */
58 MP4SYS_SCENE_PLI_Advanced2D_L3
= 0x10, /* Advanced 2D L3 */
59 MP4SYS_SCENE_PLI_Main2D_L1
= 0x11, /* Main 2D L1 */
60 MP4SYS_SCENE_PLI_Main2D_L2
= 0x12, /* Main 2D L2 */
61 MP4SYS_SCENE_PLI_Main2D_L3
= 0x13, /* Main 2D L3 */
62 MP4SYS_SCENE_PLI_NOT_SPECIFIED
= 0xFE, /* no scene profile specified */
63 MP4SYS_SCENE_PLI_NONE_REQUIRED
= 0xFF, /* no scene capability required */
64 } mp4sys_sceneProfileLevelIndication
;
66 /* 14496-2 Profile and level indication and restrictions */
69 MP4SYS_VISUAL_PLI_Reserved
= 0x00, /* 0b00000000, Reserved */
70 MP4SYS_VISUAL_PLI_Simple_PL1
= 0x01, /* 0b00000001, Simple Profile/Level 1 */
71 MP4SYS_VISUAL_PLI_Simple_PL2
= 0x02, /* 0b00000010, Simple Profile/Level 2 */
72 MP4SYS_VISUAL_PLI_Simple_PL3
= 0x03, /* 0b00000011, Simple Profile/Level 3 */
73 MP4SYS_VISUAL_PLI_Simple_Scalable_PL1
= 0x11, /* 0b00010001, Simple Scalable Profile/Level 1 */
74 MP4SYS_VISUAL_PLI_Simple_Scalable_PL2
= 0x12, /* 0b00010010, Simple Scalable Profile/Level 2 */
75 MP4SYS_VISUAL_PLI_Core_PL1
= 0x21, /* 0b00100001, Core Profile/Level 1 */
76 MP4SYS_VISUAL_PLI_Core_PL2
= 0x22, /* 0b00100010, Core Profile/Level 2 */
77 MP4SYS_VISUAL_PLI_Main_PL2
= 0x32, /* 0b00110010, Main Profile/Level 2 */
78 MP4SYS_VISUAL_PLI_Main_PL3
= 0x33, /* 0b00110011, Main Profile/Level 3 */
79 MP4SYS_VISUAL_PLI_Main_PL4
= 0x34, /* 0b00110100, Main Profile/Level 4 */
80 MP4SYS_VISUAL_PLI_N_bit_PL2
= 0x42, /* 0b01000010, N-bit Profile/Level 2 */
81 MP4SYS_VISUAL_PLI_Scalable_Texture_PL1
= 0x51, /* 0b01010001, Scalable Texture Profile/Level 1 */
82 MP4SYS_VISUAL_PLI_Simple_Face_Animation_PL1
= 0x61, /* 0b01100001, Simple Face Animation Profile/Level 1 */
83 MP4SYS_VISUAL_PLI_Simple_Face_Animation_PL2
= 0x62, /* 0b01100010, Simple Face Animation Profile/Level 2 */
84 MP4SYS_VISUAL_PLI_Simple_FBA_PL1
= 0x63, /* 0b01100011, Simple FBA Profile/Level 1 */
85 MP4SYS_VISUAL_PLI_Simple_FBA_PL2
= 0x64, /* 0b01100100, Simple FBA Profile/Level 2 */
86 MP4SYS_VISUAL_PLI_Basic_Animated_Texture_PL1
= 0x71, /* 0b01110001, Basic Animated Texture Profile/Level 1 */
87 MP4SYS_VISUAL_PLI_Basic_Animated_Texture_PL2
= 0x72, /* 0b01110010, Basic Animated Texture Profile/Level 2 */
88 MP4SYS_VISUAL_PLI_H264_AVC
= 0x7F, /* ISO/IEC 14496-10 Advanced Video Codec / H.264, defined in ISO/IEC 14496-1:2010 */
89 /* NOTE: Some other implementations seem to use 0x15(0b00010101) for AVC, but I think that's wrong. */
90 MP4SYS_VISUAL_PLI_Hybrid_PL1
= 0x81, /* 0b10000001, Hybrid Profile/Level 1 */
91 MP4SYS_VISUAL_PLI_Hybrid_PL2
= 0x82, /* 0b10000010, Hybrid Profile/Level 2 */
92 MP4SYS_VISUAL_PLI_Advanced_Real_Time_Simple_PL1
= 0x91, /* 0b10010001, Advanced Real Time Simple Profile/Level 1 */
93 MP4SYS_VISUAL_PLI_Advanced_Real_Time_Simple_PL2
= 0x92, /* 0b10010010, Advanced Real Time Simple Profile/Level 2 */
94 MP4SYS_VISUAL_PLI_Advanced_Real_Time_Simple_PL3
= 0x93, /* 0b10010011, Advanced Real Time Simple Profile/Level 3 */
95 MP4SYS_VISUAL_PLI_Advanced_Real_Time_Simple_PL4
= 0x94, /* 0b10010100, Advanced Real Time Simple Profile/Level 4 */
96 MP4SYS_VISUAL_PLI_Core_Scalable_PL1
= 0xA1, /* 0b10100001, Core Scalable Profile/Level1 */
97 MP4SYS_VISUAL_PLI_Core_Scalable_PL2
= 0xA2, /* 0b10100010, Core Scalable Profile/Level2 */
98 MP4SYS_VISUAL_PLI_Core_Scalable_PL3
= 0xA3, /* 0b10100011, Core Scalable Profile/Level3 */
99 MP4SYS_VISUAL_PLI_Advanced_Coding_Efficiency_PL1
= 0xB1, /* 0b10110001, Advanced Coding Efficiency Profile/Level 1 */
100 MP4SYS_VISUAL_PLI_Advanced_Coding_Efficiency_PL2
= 0xB2, /* 0b10110010, Advanced Coding Efficiency Profile/Level 2 */
101 MP4SYS_VISUAL_PLI_Advanced_Coding_Efficiency_PL3
= 0xB3, /* 0b10110011, Advanced Coding Efficiency Profile/Level 3 */
102 MP4SYS_VISUAL_PLI_Advanced_Coding_Efficiency_PL4
= 0xB4, /* 0b10110100, Advanced Coding Efficiency Profile/Level 4 */
103 MP4SYS_VISUAL_PLI_Advanced_Core_PL1
= 0xC1, /* 0b11000001, Advanced Core Profile/Level 1 */
104 MP4SYS_VISUAL_PLI_Advanced_Core_PL2
= 0xC2, /* 0b11000010, Advanced Core Profile/Level 2 */
105 MP4SYS_VISUAL_PLI_Advanced_Scalable_Texture_L1
= 0xD1, /* 0b11010001, Advanced Scalable Texture/Level1 */
106 MP4SYS_VISUAL_PLI_Advanced_Scalable_Texture_L2
= 0xD2, /* 0b11010010, Advanced Scalable Texture/Level2 */
107 MP4SYS_VISUAL_PLI_Advanced_Scalable_Texture_L3
= 0xD3, /* 0b11010011, Advanced Scalable Texture/Level3 */
108 MP4SYS_VISUAL_PLI_NOT_SPECIFIED
= 0xFE, /* no visual profile specified */
109 MP4SYS_VISUAL_PLI_NONE_REQUIRED
= 0xFF, /* no visual capability required */
110 } mp4sys_visualProfileLevelIndication
;
112 /* graphicsProfileLevelIndication */
115 MP4SYS_GRAPHICS_PLI_RESERVED
= 0x00, /* Reserved for ISO use */
116 MP4SYS_GRAPHICS_PLI_Simple2D_L1
= 0x01, /* Simple2D profile L1 */
117 MP4SYS_GRAPHICS_PLI_Simple2D_Text_L1
= 0x02, /* Simple 2D + Text profile L1 */
118 MP4SYS_GRAPHICS_PLI_Simple2D_Text_L2
= 0x03, /* Simple 2D + Text profile L2 */
119 MP4SYS_GRAPHICS_PLI_Core2D_L1
= 0x04, /* Core 2D profile L1 */
120 MP4SYS_GRAPHICS_PLI_Core2D_L2
= 0x05, /* Core 2D profile L2 */
121 MP4SYS_GRAPHICS_PLI_Advanced2D_L1
= 0x06, /* Advanced 2D profile L1 */
122 MP4SYS_GRAPHICS_PLI_Advanced2D_L2
= 0x07, /* Advanced 2D profile L2 */
123 MP4SYS_GRAPHICS_PLI_NOT_SPECIFIED
= 0xFE, /* no graphics profile specified */
124 MP4SYS_GRAPHICS_PLI_NONE_REQUIRED
= 0xFF, /* no graphics capability required */
125 } mp4sys_graphicsProfileLevelIndication
;
127 /* Just for mp4sys_setup_ES_Descriptor, to facilitate to make ES_Descriptor */
130 uint16_t ES_ID
; /* Maybe 0 in stsd(esds), or alternatively, lower 16 bits of the TrackID */
131 lsmash_mp4sys_object_type_indication objectTypeIndication
;
132 lsmash_mp4sys_stream_type streamType
;
133 uint32_t bufferSizeDB
; /* byte unit, NOT bit unit. */
135 uint32_t avgBitrate
; /* 0 if VBR */
136 void *dsi_payload
; /* AudioSpecificConfig or so */
137 uint32_t dsi_payload_length
; /* size of dsi_payload */
138 } mp4sys_ES_Descriptor_params_t
;
140 struct lsmash_mp4sys_decoder_specific_info_tag
143 uint32_t payload_length
;
146 #ifndef MP4SYS_INTERNAL
148 typedef void mp4sys_descriptor_t
;
149 typedef void mp4sys_ES_Descriptor_t
;
150 typedef void mp4sys_ObjectDescriptor_t
;
152 void mp4sys_remove_descriptor( mp4sys_descriptor_t
*descriptor
);
154 /* ES_ID of the ES Descriptor is stored as 0 when the ES Descriptor is built into sample descriptions in MP4 file format
155 * since the lower 16 bits of the track_ID is used, instead of ES_ID, for the identifier of the elemental stream within the track. */
156 mp4sys_ES_Descriptor_t
*mp4sys_create_ES_Descriptor( uint16_t ES_ID
);
157 mp4sys_ObjectDescriptor_t
*mp4sys_create_ObjectDescriptor( uint16_t ObjectDescriptorID
);
158 int mp4sys_create_ES_ID_Inc( mp4sys_ObjectDescriptor_t
*od
, uint32_t Track_ID
);
160 int mp4sys_to_InitialObjectDescriptor
162 mp4sys_ObjectDescriptor_t
*od
,
163 uint8_t include_inline_pli
,
164 mp4sys_ODProfileLevelIndication od_pli
,
165 mp4sys_sceneProfileLevelIndication scene_pli
,
166 mp4a_audioProfileLevelIndication audio_pli
,
167 mp4sys_visualProfileLevelIndication visual_pli
,
168 mp4sys_graphicsProfileLevelIndication graph_pli
171 int mp4sys_update_DecoderConfigDescriptor
173 mp4sys_ES_Descriptor_t
*esd
,
174 uint32_t bufferSizeDB
,
179 uint32_t mp4sys_update_descriptor_size( mp4sys_descriptor_t
*descriptor
);
180 int mp4sys_write_descriptor( lsmash_bs_t
*bs
, mp4sys_descriptor_t
*descriptor
);
181 void mp4sys_print_descriptor( FILE *fp
, mp4sys_descriptor_t
*descriptor
, int indent
);
182 mp4sys_descriptor_t
*mp4sys_get_descriptor( lsmash_bs_t
*bs
, mp4sys_descriptor_t
*parent
);
184 int mp4sys_setup_summary_from_DecoderSpecificInfo( lsmash_audio_summary_t
*summary
, mp4sys_ES_Descriptor_t
*esd
);
186 /* to facilitate to make ES_Descriptor */
187 mp4sys_ES_Descriptor_t
*mp4sys_setup_ES_Descriptor( mp4sys_ES_Descriptor_params_t
*params
);
189 #endif /* #ifndef MP4SYS_INTERNAL */
191 #endif /* #ifndef MP4SYS_H */