• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /*********************************************************************************/
19 /*
20     This PVA_FF_Atom Class is the base class for all other Atoms in the MPEG-4 File
21     Format.
22 */
23 
24 
25 #ifndef __AtomDefs_H__
26 #define __AtomDefs_H__
27 
28 #ifndef OSCL_BASE_H_INCLUDED
29 #include "oscl_base.h"
30 #endif
31 
32 #ifndef OSCL_BIN_STREAM_H_INCLUDED
33 #include "oscl_bin_stream.h"
34 #endif
35 
36 #include "pv_mp4ffcomposer_config.h"
37 static const int32 MEDIA_DATA_IN_MEMORY = 0;
38 static const int32 MEDIA_DATA_ON_DISK = 1;
39 
40 static const uint32 DEFAULT_PRESENTATION_TIMESCALE = 1000; // For milliseconds
41 static const uint32 INITIAL_TRACK_ID = 1; // Initial track ID for first track added to this movie
42 
43 static const int32 MEDIA_TYPE_UNKNOWN = 10;
44 
45 // PVA_FF_MediaInformationHeaderAtom types
46 static const int32 MEDIA_INFORMATION_HEADER_TYPE_AUDIO = 0;
47 static const int32 MEDIA_INFORMATION_HEADER_TYPE_VISUAL = 1;
48 static const int32 MEDIA_INFORMATION_HEADER_TYPE_HINT = 2;
49 static const int32 MEDIA_INFORMATION_HEADER_TYPE_MPEG4 = 3;
50 
51 static const int32 UNKNOWN_ATOM = 0;
52 static const int32 UNKNOWN_DESCRIPTOR = 1;
53 static const int32 UNKNOWN_HANDLER = 2;
54 
55 static const int32 CODING_TYPE_I = 0;
56 static const int32 CODING_TYPE_P = 1;
57 static const int32 CODING_TYPE_B = 2;
58 static const int32 CODING_TYPE_SPRITE = 3;
59 
60 // Mpeg-4 file types
61 static const int32 FILE_TYPE_AUDIO = 1;
62 static const int32 FILE_TYPE_VIDEO = 2;
63 static const int32 FILE_TYPE_AUDIO_VIDEO = 3; // logical ORing of above
64 static const int32 FILE_TYPE_STILL_IMAGE = 4;
65 static const int32 FILE_TYPE_STILL_IMAGE_AUDIO = 5; // logical ORing of above
66 static const int32 FILE_TYPE_TIMED_TEXT = 8;
67 static const int32 FILE_TYPE_AUDIO_TEXT = 9;
68 static const int32 FILE_TYPE_VIDEO_TEXT = 10;
69 static const int32 FILE_TYPE_AUDIO_VIDEO_TEXT = 11;
70 
71 // Scalability settings on the Mpeg4 file
72 static const int32 STREAM_SCALABILITY_NONE = 0;
73 static const int32 STREAM_SCALABILITY_TEMPORAL = 1;
74 static const int32 STREAM_SCALABILITY_SPATIAL = 2;
75 static const int32 STREAM_SCALABILITY_BOTH = 3; // logical ORing of above
76 
77 static const uint32 INVALID_TRACK_ID = 0;
78 
79 // The following are the allowable protocols with respect to the hint tracks:
80 // HINT_PROTOCOL_TEMPORAL_SCALABILITY - Video stream encoded with PacketVideo Temporal Scalability
81 // HINT_PROTOCOL_SPATIAL_SCALABILITY - Video stream encoded with PacketVideo Spatial Scalability
82 // 'pvst' - Video stream encoded with both PacketVideo Spatial and Temporal scalability
83 // HINT_PROTOCOL_BASE_LAYER_ONLY - Video stream encoded with Base Layer only
84 // *** Note that only HINT_PROTOCOL_TEMPORAL_SCALABILITY and HINT_PROTOCOL_BASE_LAYER_ONLY video protocols are supported in version 1.0 ***
85 // 'pvau' - Audio encoding with simple hint track
86 
87 
88 static const int32 OBJ_DESCR_TAG            = 0x1;
89 static const int32 INITIAL_OBJ_DESCR_TAG    = 0x2;
90 static const int32 ES_DESCR_TAG         = 0x3;
91 static const int32 DEC_CONFIG_DESCR_TAG = 0x4;
92 static const int32 DEC_SPEC_INFO_TAG        = 0x5;
93 static const int32 SL_CONFIG_DESCR_TAG  = 0x6;
94 //
95 static const int32 IPMP_DESCR_PTR_TAG       = 0xa;
96 static const int32 IPMP_DESCR_TAG           = 0xb;
97 //
98 static const int32 ES_ID_INC_DESCR_TAG  = 0xe;
99 static const int32 ES_ID_REF_DESCR_TAG  = 0xf;
100 //
101 static const int32 MP4_IOD_TAG  = 0x10;
102 static const int32 MP4_OD_TAG   = 0x11;
103 
104 
105 
106 #define FourCharConstToUint32(a, b, c, d) ( (uint32(a) << 24) | (uint32(b) << 16) | (uint32(c) << 8) | uint32(d) )
107 
108 const uint32 HINT_PROTOCOL_BASE_LAYER_ONLY = FourCharConstToUint32('p', 'v', 'b', 'l');
109 const uint32 HINT_PROTOCOL_TEMPORAL_SCALABILITY = FourCharConstToUint32('p', 'v', 't', 's');
110 const uint32 HINT_PROTOCOL_SPATIAL_SCALABILITY = FourCharConstToUint32('p', 'v', 's', 's');
111 const uint32 HINT_PROTOCOL_SPATIAL_TEMPORAL = FourCharConstToUint32('p', 'v', 's', 't');
112 const uint32 HINT_PROTOCOL_STILL_IMAGE = FourCharConstToUint32('p', 'v', 's', 'i');
113 const uint32 HINT_PROTOCOL_AUDIO = FourCharConstToUint32('p', 'v', 'a', 'u');
114 const uint32 PACKETVIDEO_FOURCC = FourCharConstToUint32('p', 'v', 'm', 'm');
115 
116 
117 const uint32    MOVIE_ATOM = FourCharConstToUint32('m', 'o', 'o', 'v');
118 const uint32    MOVIE_HEADER_ATOM = FourCharConstToUint32('m', 'v', 'h', 'd');
119 const uint32    TRACK_ATOM = FourCharConstToUint32('t', 'r', 'a', 'k');
120 const uint32    ESD_ATOM = FourCharConstToUint32('e', 's', 'd', 's');
121 const uint32    TRACK_HEADER_ATOM = FourCharConstToUint32('t', 'k', 'h', 'd');
122 const uint32    TRACK_REFERENCE_ATOM = FourCharConstToUint32('t', 'r', 'e', 'f');
123 const uint32    MEDIA_ATOM = FourCharConstToUint32('m', 'd', 'i', 'a');
124 const uint32    EDIT_ATOM = FourCharConstToUint32('e', 'd', 't', 's');
125 const uint32    EDIT_LIST_ATOM = FourCharConstToUint32('e', 'l', 's', 't');
126 const uint32    MEDIA_HEADER_ATOM = FourCharConstToUint32('m', 'd', 'h', 'd');
127 const uint32    HANDLER_ATOM = FourCharConstToUint32('h', 'd', 'l', 'r');
128 const uint32    MEDIA_INFORMATION_ATOM = FourCharConstToUint32('m', 'i', 'n', 'f');
129 const uint32    VIDEO_MEDIA_HEADER_ATOM = FourCharConstToUint32('v', 'm', 'h', 'd');
130 const uint32    SOUND_MEDIA_HEADER_ATOM = FourCharConstToUint32('s', 'm', 'h', 'd');
131 const uint32    HINT_MEDIA_HEADER_ATOM = FourCharConstToUint32('h', 'm', 'h', 'd');
132 const uint32    MPEG4_MEDIA_HEADER_ATOM = FourCharConstToUint32('n', 'm', 'h', 'd');
133 const uint32    DATA_INFORMATION_ATOM = FourCharConstToUint32('d', 'i', 'n', 'f');
134 const uint32    DATA_REFERENCE_ATOM = FourCharConstToUint32('d', 'r', 'e', 'f');
135 const uint32    DATA_ENTRY_URL_ATOM = FourCharConstToUint32('u', 'r', 'l', ' ');
136 const uint32    DATA_ENTRY_URN_ATOM = FourCharConstToUint32('u', 'r', 'n', ' ');
137 const uint32    SAMPLE_TABLE_ATOM = FourCharConstToUint32('s', 't', 'b', 'l');
138 const uint32    TIME_TO_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 't', 's');
139 const uint32    COMPOSITION_OFFSET_ATOM = FourCharConstToUint32('c', 't', 't', 's');
140 const uint32    SAMPLE_DESCRIPTION_ATOM = FourCharConstToUint32('s', 't', 's', 'd');
141 const uint32    SAMPLE_SIZE_ATOM = FourCharConstToUint32('s', 't', 's', 'z');
142 const uint32    SAMPLE_TO_CHUNK_ATOM = FourCharConstToUint32('s', 't', 's', 'c');
143 const uint32    CHUNK_OFFSET_ATOM = FourCharConstToUint32('s', 'r', 'c', 'o');
144 const uint32    SYNC_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 's', 's');
145 const uint32    SHADOW_SYNC_SAMPLE_ATOM = FourCharConstToUint32('s', 't', 's', 'h');
146 const uint32    DEGRADATION_PRIORITY_ATOM = FourCharConstToUint32('s', 't', 'd', 'p');
147 const uint32    OBJECT_DESCRIPTOR_ATOM = FourCharConstToUint32('i', 'o', 'd', 's');
148 const uint32    MEDIA_DATA_ATOM = FourCharConstToUint32('m', 'd', 'a', 't');
149 const uint32    SKIP_ATOM = FourCharConstToUint32('f', 'r', 'e', 'e');
150 const uint32    FREE_SPACE_ATOM = FourCharConstToUint32('s', 'k', 'i', 'p');
151 const uint32    USER_DATA_ATOM = FourCharConstToUint32('u', 'd', 't', 'a');
152 const uint32    MEDIA_TYPE_AUDIO = FourCharConstToUint32('s', 'o', 'u', 'n');
153 const uint32    MEDIA_TYPE_VISUAL = FourCharConstToUint32('v', 'i', 'd', 'e');
154 const uint32    MEDIA_TYPE_TEXT = FourCharConstToUint32('t', 'e', 'x', 't');
155 
156 const uint32    MPEG_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 's');
157 const uint32    AUDIO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'a');
158 const uint32    VIDEO_SAMPLE_ENTRY = FourCharConstToUint32('m', 'p', '4', 'v');
159 
160 const uint32    FILE_TYPE_ATOM = FourCharConstToUint32('f', 't', 'y', 'p');
161 const uint32    PVMM_BRAND = FourCharConstToUint32('p', 'v', 'm', 'm');
162 const uint32    BRAND_3GPP4 = FourCharConstToUint32('3', 'g', 'p', '4');
163 const uint32    BRAND_3GPP5 = FourCharConstToUint32('3', 'g', 'p', '5');
164 const uint32    BRAND_3GPP6 = FourCharConstToUint32('3', 'g', 'p', '6');
165 const uint32    BRAND_MPEG4 = FourCharConstToUint32('m', 'p', '4', '1');
166 
167 const uint32    TREF_TYPE_OD = FourCharConstToUint32('m', 'p', 'o', 'd');
168 const uint32    TREF_TYPE_DEPEND = FourCharConstToUint32('d', 'p', 'n', 'd');
169 
170 const uint32    TEXT_SAMPLE_ENTRY = FourCharConstToUint32('t', 'x', '3', 'g');
171 const uint32    AMR_SAMPLE_ENTRY = FourCharConstToUint32('s', 'a', 'm', 'r');
172 const uint32    AMR_WB_SAMPLE_ENTRY = FourCharConstToUint32('s', 'a', 'w', 'b');
173 const uint32    H263_SAMPLE_ENTRY = FourCharConstToUint32('s', '2', '6', '3');
174 const uint32    AMR_SPECIFIC_ATOM = FourCharConstToUint32('d', 'a', 'm', 'r');
175 const uint32    H263_SPECIFIC_ATOM = FourCharConstToUint32('d', '2', '6', '3');
176 const uint32    AVC_SAMPLE_ENTRY = FourCharConstToUint32('a', 'v', 'c', '1');
177 const uint32    AVC_CONFIGURATION_BOX = FourCharConstToUint32('a', 'v', 'c', 'C');
178 const uint32    MPEG4_BITRATE_BOX = FourCharConstToUint32('b', 't', 'r', 't');
179 
180 const uint32    BRAND_MMP4 = FourCharConstToUint32('m', 'm', 'p', '4');
181 
182 
183 const uint32    ASSET_INFO_TITLE_ATOM = FourCharConstToUint32('t', 'i', 't', 'l');
184 const uint32    ASSET_INFO_DESCP_ATOM = FourCharConstToUint32('d', 's', 'c', 'p');
185 const uint32    ASSET_INFO_PERF_ATOM = FourCharConstToUint32('p', 'e', 'r', 'f');
186 const uint32    ASSET_INFO_AUTHOR_ATOM = FourCharConstToUint32('a', 'u', 't', 'h');
187 const uint32    ASSET_INFO_GENRE_ATOM = FourCharConstToUint32('g', 'n', 'r', 'e');
188 const uint32    ASSET_INFO_RATING_ATOM = FourCharConstToUint32('r', 't', 'n', 'g');
189 const uint32    ASSET_INFO_CLSF_ATOM = FourCharConstToUint32('c', 'l', 's', 'f');
190 const uint32    ASSET_INFO_KEYWORD_ATOM = FourCharConstToUint32('k', 'y', 'w', 'd');
191 const uint32    ASSET_INFO_LOCINFO_ATOM = FourCharConstToUint32('l', 'o', 'c', 'i');
192 const uint32    ASSET_INFO_CPRT_ATOM =  FourCharConstToUint32('c', 'p', 'r', 't');
193 const uint32    ASSET_INFO_ALBUM_TITLE_ATOM =  FourCharConstToUint32('a', 'l', 'b', 'm');
194 const uint32    ASSET_INFO_RECORDING_YEAR_ATOM =  FourCharConstToUint32('y', 'r', 'r', 'c');
195 
196 // Movie fragment atoms
197 const uint32    MOVIE_EXTENDS_ATOM = FourCharConstToUint32('m', 'v', 'e', 'x');
198 const uint32    MOVIE_EXTENDS_HEADER_ATOM = FourCharConstToUint32('m', 'e', 'h', 'd');
199 const uint32    TRACK_EXTENDS_ATOM = FourCharConstToUint32('t', 'r', 'e', 'x');
200 const uint32    MOVIE_FRAGMENT_ATOM = FourCharConstToUint32('m', 'o', 'o', 'f');
201 const uint32    MOVIE_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('m', 'f', 'h', 'd');
202 const uint32    TRACK_FRAGMENT_ATOM = FourCharConstToUint32('t', 'r', 'a', 'f');
203 const uint32    TRACK_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('t', 'f', 'h', 'd');
204 const uint32    TRACK_RUN_ATOM = FourCharConstToUint32('t', 'r', 'u', 'n');
205 const uint32    MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('m', 'f', 'r', 'a');
206 const uint32    TRACK_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('t', 'f', 'r', 'a');
207 const uint32    MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM = FourCharConstToUint32('m', 'f', 'r', 'o');
208 
209 // MORE TBA - add specific protocols into type value
210 
211 #define PVMM_VERSION  0x00010000
212 #define WMF_VERSION   0x00010001
213 #define VERSION_3GPP4 0x00000300
214 #define VERSION_MPEG4 0x00000000
215 #define VERSION_MMP4  0x00000001
216 #define VERSION_3GPP5 0x00000100
217 #define VERSION_3GPP6 0x00000600
218 
219 typedef enum
220 {
221     CODEC_TYPE_AMR_AUDIO = 1,
222     CODEC_TYPE_AAC_AUDIO = 2,
223     CODEC_TYPE_AMR_WB_AUDIO = 3
224 } AUDIO_CODEC_TYPES;
225 
226 typedef enum
227 {
228     CODEC_TYPE_MPEG4_VIDEO = 4,
229     CODEC_TYPE_BASELINE_H263_VIDEO = 5,
230     CODEC_TYPE_AVC_VIDEO = 6
231 } VIDEO_CODEC_TYPES;
232 
233 typedef enum
234 {
235     CODEC_TYPE_TIMED_TEXT = 7
236 
237 } TEXT_CODEC_TYPES;
238 
239 #define MPEG4_SP_L0    0x08
240 #define MPEG4_SP_L1    0x01
241 #define MPEG4_SP_L2    0x02
242 #define MPEG4_SP_L3    0x03
243 #define MPEG4_SSP_L0   0x10
244 #define MPEG4_SSP_L1   0x11
245 #define MPEG4_SSP_L2   0x12
246 
247 #define MIN_NUM_MEDIA_TRACKS 0
248 
249 #define AMR_INTERLEAVE_BUFFER_SIZE    2048
250 #define AMR_WB_INTERLEAVE_BUFFER_SIZE 4096
251 #define AAC_INTERLEAVE_BUFFER_SIZE   12000  // Calc with 96 Kbps as max
252 #define VIDEO_INTERLEAVE_BUFFER_SIZE 256000
253 #define TEXT_INTERLEAVE_BUFFER_SIZE  12000
254 
255 #define MAX_PV_BASE_SIMPLE_PROFILE_VOL_HEADER_SIZE 28
256 
257 #define LANGUAGE_CODE_UNKNOWN   0x55C4
258 #define RATING_ENTITY_UNKNOWN   0
259 #define RATING_CRITERIA_UNKNOWN 0
260 
261 #define DEFAULT_INTERLEAVE_INTERVAL 1000
262 
263 //Encoding mode defines
264 
265 //Please note that only SOME COMBINATIONS are allowed
266 
267 //b31.....b4b3b2b1b0 - Bit Mask Definitions
268 //No bits are set - default mode - no interleaving, meta data at the end
269 //b0 is set - Media data is interleaved, BIFS and OD are still seperate tracks
270 //b1 is set - Meta data is upfront, this implies temp files are needed while authoring
271 //b2 - undefined
272 //b3 is set - Do not use temp files while authoring
273 //b4-b31 - Reserved for future use
274 
275 /**
276  * This mode authors non Progressive Downloadable output files using temp files
277  * during authoring:
278  * Meta data towards the end of the clip
279  * Media data is not interleaved. Temp files are used.
280  * Media data is authored in separate media atoms for each track
281  * Temporary files are written to the same directory as the output file.
282  */
283 #define PVMP4FF_SET_MEDIA_INTERLEAVE_MODE   0x00000001
284 
285 #define PVMP4FF_SET_META_DATA_UPFRONT_MODE  0x00000002
286 
287 /**
288  * This mode authors 3GPP Progressive Downloadable output files:
289  * Meta Data is upfront.
290  * Media Data is interleaved. Temp files are used.
291  * Temporary files are written to the same directory as the output file.
292  */
293 #define PVMP4FF_3GPP_PROGRESSIVE_DOWNLOAD_MODE 0x00000003
294 
295 /**
296  * This mode authors 3GPP Downloadable output files:
297  * Meta Data is towards the end of the clip.
298  * Media Data is interleaved.
299  * No temp files are used.
300  */
301 #define PVMP4FF_3GPP_DOWNLOAD_MODE  0x00000009
302 
303 #define PVMP4FF_SET_FIRST_SAMPLE_EDIT_MODE  0x00000010
304 
305 // movie fragment mode
306 // 6th bit is now reserved movie fragment mode and last bit is reserved for interleaving
307 #define PVMP4FF_MOVIE_FRAGMENT_MODE 0x00000021
308 
309 #define DEFAULT_MOVIE_FRAGMENT_DURATION_IN_MS 10000
310 
311 class PVMP4FFComposerAudioEncodeParams
312 {
313     public:
PVMP4FFComposerAudioEncodeParams()314         PVMP4FFComposerAudioEncodeParams()
315         {
316             samplingRate = 0;
317             numberOfChannels = 2;
318             bitsPerSample = 16;
319         }
320 
321         uint32 samplingRate;
322         uint32 numberOfChannels;
323         uint32 bitsPerSample;
324 };
325 
326 #endif
327 
328 
329