Changeset 163
- Timestamp:
- 10/15/06 17:42:46 (2 years ago)
- Files:
-
- trunk/CommonUtils.c (modified) (1 diff)
- trunk/CommonUtils.h (modified) (1 diff)
- trunk/MatroskaCodecIDs.cpp (modified) (1 diff)
- trunk/MatroskaCodecIDs.h (modified) (6 diffs)
- trunk/ff_private.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CommonUtils.c
r156 r163 182 182 } 183 183 184 /* write the int32_t data to target & then return a pointer which points after that data */ 185 uint8_t *write_int32(uint8_t *target, int32_t data) 186 { 187 return write_data(target, (uint8_t*)&data, sizeof(data)); 188 } /* write_int32() */ 189 190 /* write the int16_t data to target & then return a pointer which points after that data */ 191 uint8_t *write_int16(uint8_t *target, int16_t data) 192 { 193 return write_data(target, (uint8_t*)&data, sizeof(data)); 194 } /* write_int16() */ 195 196 /* write the data to the target adress & then return a pointer which points after the written data */ 197 uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size) 198 { 199 if(data_size > 0) 200 memcpy(target, data, data_size); 201 return (target + data_size); 202 } /* write_data() */ 203 trunk/CommonUtils.h
r156 r163 22 22 short ThreeCharLangCodeToQTLangCode(char *lang); 23 23 24 /* write the int32_t data to target & then return a pointer which points after that data */ 25 uint8_t *write_int32(uint8_t *target, int32_t data); 26 27 /* write the int16_t data to target & then return a pointer which points after that data */ 28 uint8_t *write_int16(uint8_t *target, int16_t data); 29 30 /* write the data to the target adress & then return a pointer which points after the written data */ 31 uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size); 32 24 33 #ifdef __cplusplus 25 34 } trunk/MatroskaCodecIDs.cpp
r159 r163 242 242 243 243 AddImageDescriptionExtension(imgDesc, imgDescExt, kSampleDescriptionExtensionReal); 244 245 DisposeHandle((Handle) imgDescExt); 246 } 247 return noErr; 248 } 249 250 // the esds atom creation is based off of the routines for it in ffmpeg's movenc.c 251 static unsigned int descrLength(unsigned int len) 252 { 253 int i; 254 for(i=1; len>>(7*i); i++); 255 return len + 1 + i; 256 } 257 258 static uint8_t* putDescr(uint8_t *buffer, int tag, unsigned int size) 259 { 260 int i= descrLength(size) - size - 2; 261 *buffer++ = tag; 262 for(; i>0; i--) 263 *buffer++ = (size>>(7*i)) | 0x80; 264 *buffer++ = size & 0x7F; 265 return buffer; 266 } 267 268 // ESDS layout: 269 // + version (4 bytes) 270 // + ES descriptor 271 // + Track ID (2 bytes) 272 // + Flags (1 byte) 273 // + DecoderConfig descriptor 274 // + Object Type (1 byte) 275 // + Stream Type (1 byte) 276 // + Buffersize DB (3 bytes) 277 // + Max bitrate (4 bytes) 278 // + VBR/Avg bitrate (4 bytes) 279 // + DecoderSpecific info descriptor 280 // + codecPrivate (codecPrivate->GetSize()) 281 // + SL descriptor 282 // + dunno (1 byte) 283 284 ComponentResult DescExt_mp4v(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir) 285 { 286 if (!tr_entry || !desc) return paramErr; 287 ImageDescriptionHandle imgDesc = (ImageDescriptionHandle) desc; 288 289 if (dir == kToSampleDescription) { 290 KaxCodecPrivate *codecPrivate = FindChild<KaxCodecPrivate>(*tr_entry); 291 KaxTrackNumber *trackNum = FindChild<KaxTrackNumber>(*tr_entry); 292 293 int vosLen = codecPrivate ? codecPrivate->GetSize() : 0; 294 int trackID = trackNum ? uint16(*trackNum) : 1; 295 int decoderSpecificInfoLen = vosLen ? descrLength(vosLen) : 0; 296 297 Handle imgDescExt = NewHandle(4 + descrLength(3 + descrLength(13 + decoderSpecificInfoLen) + descrLength(1))); 298 UInt8 *pos = (UInt8 *) *imgDescExt; 299 300 pos = write_int32(pos, 0); // version 301 302 // ES Descriptor 303 pos = putDescr(pos, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) + descrLength(1)); 304 pos = write_int16(pos, EndianS16_NtoB(trackID)); 305 *pos++ = 0; // no flags 306 307 // DecoderConfig descriptor 308 pos = putDescr(pos, 0x04, 13 + decoderSpecificInfoLen); 309 310 // Object type indication, see http://gpac.sourceforge.net/tutorial/mediatypes.htm 311 *pos++ = 0x20; 312 313 // streamtype (video) 314 *pos++ = 0x11; 315 316 // 3 bytes: buffersize DB (not sure how to get easily) 317 *pos++ = 0; 318 pos = write_int16(pos, 0); 319 320 // max bitrate, not sure how to get easily 321 pos = write_int32(pos, 0); 322 323 // vbr 324 pos = write_int32(pos, 0); 325 326 if (vosLen) { 327 pos = putDescr(pos, 0x05, vosLen); 328 pos = write_data(pos, codecPrivate->GetBuffer(), vosLen); 329 } 330 331 // SL descriptor 332 pos = putDescr(pos, 0x06, 1); 333 *pos++ = 0x02; 334 335 AddImageDescriptionExtension(imgDesc, imgDescExt, 'esds'); 244 336 245 337 DisposeHandle((Handle) imgDescExt); trunk/MatroskaCodecIDs.h
r157 r163 85 85 kSubFormatVobSub = 'SPU ', 86 86 87 // the following 4CCs aren't official, nor have any decoder support87 // the following 4CCs don't have decoder support yet 88 88 kMPEG1VisualCodecType = 'mp1v', 89 89 kMPEG2VisualCodecType = 'mp2v', … … 115 115 116 116 117 118 117 // these functions modify the AudioStreamBasicDescription properly for the audio format 119 118 ComponentResult ASBDExt_AC3(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 120 119 ComponentResult ASBDExt_LPCM(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 121 120 ComponentResult ASBDExt_AAC(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd); 121 122 122 123 123 struct ASBDExtensionFunc { … … 126 126 }; 127 127 128 staticconst struct ASBDExtensionFunc kMatroskaASBDExtensionFuncs[] = {128 const struct ASBDExtensionFunc kMatroskaASBDExtensionFuncs[] = { 129 129 { kAudioFormatMPEG4AAC, ASBDExt_AAC }, 130 130 { kAudioFormatAC3, ASBDExt_AC3 }, … … 144 144 ComponentResult DescExt_VobSub(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 145 145 ComponentResult DescExt_Real(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 146 ComponentResult DescExt_mp4v(KaxTrackEntry *tr_entry, SampleDescriptionHandle desc, DescExtDirection dir); 147 146 148 147 149 struct CodecDescExtFunc { … … 150 152 }; 151 153 152 staticconst struct CodecDescExtFunc kMatroskaSampleDescExtFuncs[] = {154 const struct CodecDescExtFunc kMatroskaSampleDescExtFuncs[] = { 153 155 { kH264CodecType, DescExt_H264 }, 154 156 { kAudioFormatXiphVorbis, DescExt_XiphVorbis }, … … 159 161 { kVideoFormatReal8, DescExt_Real }, 160 162 { kVideoFormatReal9, DescExt_Real }, 163 { kMPEG4VisualCodecType, DescExt_mp4v }, 161 164 }; 165 162 166 163 167 short GetTrackLanguage(KaxTrackEntry *tr_entry); trunk/ff_private.c
r162 r163 24 24 #include "avcodec.h" 25 25 #include "Codecprintf.h" 26 #include "CommonUtils.h" 26 27 27 28 #include <CoreServices/CoreServices.h> … … 423 424 return result; 424 425 } /* create_extension() */ 425 426 /* write the int32_t data to target & then return a pointer which points after that data */427 uint8_t *write_int32(uint8_t *target, int32_t data)428 {429 return write_data(target, (uint8_t*)&data, sizeof(data));430 } /* write_int32() */431 432 /* write the int16_t data to target & then return a pointer which points after that data */433 uint8_t *write_int16(uint8_t *target, int16_t data)434 {435 return write_data(target, (uint8_t*)&data, sizeof(data));436 } /* write_int16() */437 438 /* write the data to the target adress & then return a pointer which points after the written data */439 uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size)440 {441 if(data_size > 0)442 memcpy(target, data, data_size);443 return (target + data_size);444 } /* write_data() */445 446 426 447 427 /* Add the meta data that lavf exposes to the movie */
