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 179 const uint32 BRAND_MMP4 = FourCharConstToUint32('m', 'm', 'p', '4'); 180 181 182 const uint32 ASSET_INFO_TITLE_ATOM = FourCharConstToUint32('t', 'i', 't', 'l'); 183 const uint32 ASSET_INFO_DESCP_ATOM = FourCharConstToUint32('d', 's', 'c', 'p'); 184 const uint32 ASSET_INFO_PERF_ATOM = FourCharConstToUint32('p', 'e', 'r', 'f'); 185 const uint32 ASSET_INFO_AUTHOR_ATOM = FourCharConstToUint32('a', 'u', 't', 'h'); 186 const uint32 ASSET_INFO_GENRE_ATOM = FourCharConstToUint32('g', 'n', 'r', 'e'); 187 const uint32 ASSET_INFO_RATING_ATOM = FourCharConstToUint32('r', 't', 'n', 'g'); 188 const uint32 ASSET_INFO_CLSF_ATOM = FourCharConstToUint32('c', 'l', 's', 'f'); 189 const uint32 ASSET_INFO_KEYWORD_ATOM = FourCharConstToUint32('k', 'y', 'w', 'd'); 190 const uint32 ASSET_INFO_LOCINFO_ATOM = FourCharConstToUint32('l', 'o', 'c', 'i'); 191 const uint32 ASSET_INFO_CPRT_ATOM = FourCharConstToUint32('c', 'p', 'r', 't'); 192 const uint32 ASSET_INFO_ALBUM_TITLE_ATOM = FourCharConstToUint32('a', 'l', 'b', 'm'); 193 const uint32 ASSET_INFO_RECORDING_YEAR_ATOM = FourCharConstToUint32('y', 'r', 'r', 'c'); 194 195 // Movie fragment atoms 196 const uint32 MOVIE_EXTENDS_ATOM = FourCharConstToUint32('m', 'v', 'e', 'x'); 197 const uint32 MOVIE_EXTENDS_HEADER_ATOM = FourCharConstToUint32('m', 'e', 'h', 'd'); 198 const uint32 TRACK_EXTENDS_ATOM = FourCharConstToUint32('t', 'r', 'e', 'x'); 199 const uint32 MOVIE_FRAGMENT_ATOM = FourCharConstToUint32('m', 'o', 'o', 'f'); 200 const uint32 MOVIE_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('m', 'f', 'h', 'd'); 201 const uint32 TRACK_FRAGMENT_ATOM = FourCharConstToUint32('t', 'r', 'a', 'f'); 202 const uint32 TRACK_FRAGMENT_HEADER_ATOM = FourCharConstToUint32('t', 'f', 'h', 'd'); 203 const uint32 TRACK_RUN_ATOM = FourCharConstToUint32('t', 'r', 'u', 'n'); 204 const uint32 MOVIE_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('m', 'f', 'r', 'a'); 205 const uint32 TRACK_FRAGMENT_RANDOM_ACCESS_ATOM = FourCharConstToUint32('t', 'f', 'r', 'a'); 206 const uint32 MOVIE_FRAGMENT_RANDOM_ACCESS_OFFSET_ATOM = FourCharConstToUint32('m', 'f', 'r', 'o'); 207 208 // MORE TBA - add specific protocols into type value 209 210 #define PVMM_VERSION 0x00010000 211 #define WMF_VERSION 0x00010001 212 #define VERSION_3GPP4 0x00000300 213 #define VERSION_MPEG4 0x00000000 214 #define VERSION_MMP4 0x00000001 215 #define VERSION_3GPP5 0x00000100 216 #define VERSION_3GPP6 0x00000600 217 218 typedef enum 219 { 220 CODEC_TYPE_AMR_AUDIO = 1, 221 CODEC_TYPE_AAC_AUDIO = 2, 222 CODEC_TYPE_AMR_WB_AUDIO = 3 223 } AUDIO_CODEC_TYPES; 224 225 typedef enum 226 { 227 CODEC_TYPE_MPEG4_VIDEO = 4, 228 CODEC_TYPE_BASELINE_H263_VIDEO = 5, 229 CODEC_TYPE_AVC_VIDEO = 6 230 } VIDEO_CODEC_TYPES; 231 232 typedef enum 233 { 234 CODEC_TYPE_TIMED_TEXT = 7 235 236 } TEXT_CODEC_TYPES; 237 238 #define MPEG4_SP_L0 0x08 239 #define MPEG4_SP_L1 0x01 240 #define MPEG4_SP_L2 0x02 241 #define MPEG4_SP_L3 0x03 242 #define MPEG4_SSP_L0 0x10 243 #define MPEG4_SSP_L1 0x11 244 #define MPEG4_SSP_L2 0x12 245 246 #define MIN_NUM_MEDIA_TRACKS 0 247 248 #define AMR_INTERLEAVE_BUFFER_SIZE 2048 249 #define AMR_WB_INTERLEAVE_BUFFER_SIZE 4096 250 #define AAC_INTERLEAVE_BUFFER_SIZE 12000 // Calc with 96 Kbps as max 251 #define VIDEO_INTERLEAVE_BUFFER_SIZE 128000 // 2 x Bitrate @ 256 kbps 252 #define TEXT_INTERLEAVE_BUFFER_SIZE 12000 253 254 #define MAX_PV_BASE_SIMPLE_PROFILE_VOL_HEADER_SIZE 28 255 256 #define LANGUAGE_CODE_UNKNOWN 0x55C4 257 #define RATING_ENTITY_UNKNOWN 0 258 #define RATING_CRITERIA_UNKNOWN 0 259 260 #define DEFAULT_INTERLEAVE_INTERVAL 1000 261 262 //Encoding mode defines 263 264 //Please note that only SOME COMBINATIONS are allowed 265 266 //b31.....b4b3b2b1b0 - Bit Mask Definitions 267 //No bits are set - default mode - no interleaving, meta data at the end 268 //b0 is set - Media data is interleaved, BIFS and OD are still seperate tracks 269 //b1 is set - Meta data is upfront, this implies temp files are needed while authoring 270 //b2 - undefined 271 //b3 is set - Do not use temp files while authoring 272 //b4-b31 - Reserved for future use 273 274 /** 275 * This mode authors non Progressive Downloadable output files using temp files 276 * during authoring: 277 * Meta data towards the end of the clip 278 * Media data is not interleaved. Temp files are used. 279 * Media data is authored in separate media atoms for each track 280 * Temporary files are written to the same directory as the output file. 281 */ 282 #define PVMP4FF_SET_MEDIA_INTERLEAVE_MODE 0x00000001 283 284 #define PVMP4FF_SET_META_DATA_UPFRONT_MODE 0x00000002 285 286 /** 287 * This mode authors 3GPP Progressive Downloadable output files: 288 * Meta Data is upfront. 289 * Media Data is interleaved. Temp files are used. 290 * Temporary files are written to the same directory as the output file. 291 */ 292 #define PVMP4FF_3GPP_PROGRESSIVE_DOWNLOAD_MODE 0x00000003 293 294 /** 295 * This mode authors 3GPP Downloadable output files: 296 * Meta Data is towards the end of the clip. 297 * Media Data is interleaved. 298 * No temp files are used. 299 */ 300 #define PVMP4FF_3GPP_DOWNLOAD_MODE 0x00000009 301 302 #define PVMP4FF_SET_FIRST_SAMPLE_EDIT_MODE 0x00000010 303 304 // movie fragment mode 305 // 6th bit is now reserved movie fragment mode and last bit is reserved for interleaving 306 #define PVMP4FF_MOVIE_FRAGMENT_MODE 0x00000021 307 308 #define DEFAULT_MOVIE_FRAGMENT_DURATION_IN_MS 10000 309 310 #endif 311 312 313