Changeset 210
- Timestamp:
- 12/22/06 21:28:07 (2 years ago)
- Files:
-
- trunk/CommonUtils.c (modified) (2 diffs)
- trunk/CommonUtils.h (modified) (1 diff)
- trunk/FFusionCodec.c (modified) (4 diffs)
- trunk/FFusionCodec.r (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CommonUtils.c
r163 r210 8 8 */ 9 9 10 #include "avcodec.h" 10 11 #include "CommonUtils.h" 11 12 … … 202 203 } /* write_data() */ 203 204 205 206 207 #define MP4ESDescrTag 0x03 208 #define MP4DecConfigDescrTag 0x04 209 #define MP4DecSpecificDescrTag 0x05 210 211 // based off of mov_mp4_read_descr_len from mov.c in ffmpeg's libavformat 212 static int readDescrLen(UInt8 **buffer) 213 { 214 int len = 0; 215 int count = 4; 216 while (count--) { 217 int c = *(*buffer)++; 218 len = (len << 7) | (c & 0x7f); 219 if (!(c & 0x80)) 220 break; 221 } 222 return len; 223 } 224 225 // based off of mov_mp4_read_descr from mov.c in ffmpeg's libavformat 226 static int readDescr(UInt8 **buffer, int *tag) 227 { 228 int len; 229 *tag = *(*buffer)++; 230 return readDescrLen(buffer); 231 } 232 233 // based off of mov_read_esds from mov.c in ffmpeg's libavformat 234 ComponentResult ReadESDSDescExt(Handle descExt, UInt8 **buffer, int *size) 235 { 236 UInt8 *esds = (UInt8 *) *descExt; 237 int tag, len; 238 239 *size = 0; 240 241 esds += 4; // version + flags 242 len = readDescr(&esds, &tag); 243 esds += 2; // ID 244 if (tag == MP4ESDescrTag) 245 esds++; // priority 246 247 len = readDescr(&esds, &tag); 248 if (tag == MP4DecConfigDescrTag) { 249 esds++; // object type id 250 esds++; // stream type 251 esds += 3; // buffer size db 252 esds += 4; // max bitrate 253 esds += 4; // average bitrate 254 255 len = readDescr(&esds, &tag); 256 if (tag == MP4DecSpecificDescrTag) { 257 *buffer = calloc(1, len + FF_INPUT_BUFFER_PADDING_SIZE); 258 if (*buffer) { 259 memcpy(*buffer, esds, len); 260 *size = len; 261 } 262 } 263 } 264 265 return noErr; 266 } trunk/CommonUtils.h
r163 r210 31 31 uint8_t *write_data(uint8_t *target, uint8_t* data, int32_t data_size); 32 32 33 // mallocs the buffer and copies the codec-specific description to it, in the same format 34 // as is specified in Matroska and is used in libavcodec 35 ComponentResult ReadESDSDescExt(Handle descExt, UInt8 **buffer, int *size); 36 33 37 #ifdef __cplusplus 34 38 } trunk/FFusionCodec.c
r209 r210 410 410 char altivec = 0; 411 411 Byte* myptr; 412 long count = 0; 413 Handle imgDescExt; 412 414 413 415 // We first open libavcodec library and the codec corresponding … … 456 458 break; 457 459 460 case 'mp4v': // MPEG4 part 2 in mov/mp4 461 glob->quicktimeDoesReorder = true; 458 462 case 'divx': // DivX 4 459 463 case 'DIVX': … … 554 558 // avc1 requires the avcC extension 555 559 if (glob->componentType == 'avc1') { 556 long count = 0; 557 Handle imgDescExt; 560 CountImageDescriptionExtensionType(p->imageDescription, 'avcC', &count); 558 561 559 CountImageDescriptionExtensionType(p->imageDescription, 'avcC', &count);560 562 if (count >= 1) { 561 563 imgDescExt = NewHandle(0); 562 564 GetImageDescriptionExtension(p->imageDescription, &imgDescExt, 'avcC', 1); 563 565 564 glob->avContext->extradata = malloc(GetHandleSize(imgDescExt));566 glob->avContext->extradata = calloc(1, GetHandleSize(imgDescExt) + FF_INPUT_BUFFER_PADDING_SIZE); 565 567 memcpy(glob->avContext->extradata, *imgDescExt, GetHandleSize(imgDescExt)); 566 568 glob->avContext->extradata_size = GetHandleSize(imgDescExt); 569 570 DisposeHandle(imgDescExt); 571 } 572 } else if (glob->componentType == 'mp4v') { 573 CountImageDescriptionExtensionType(p->imageDescription, 'esds', &count); 574 575 if (count >= 1) { 576 imgDescExt = NewHandle(0); 577 GetImageDescriptionExtension(p->imageDescription, &imgDescExt, 'esds', 1); 578 579 ReadESDSDescExt(imgDescExt, &glob->avContext->extradata, &glob->avContext->extradata_size); 567 580 568 581 DisposeHandle(imgDescExt); … … 1229 1242 case 'FMP4': 1230 1243 case 'SMP4': 1244 case 'mp4v': 1231 1245 err = GetComponentResource((Component)glob->self, codecInfoResourceType, kMPEG4CodecInfoResID, (Handle *)&tempCodecInfo); 1232 1246 break; trunk/FFusionCodec.r
r209 r210 1925 1925 }; 1926 1926 1927 // XXX: can we do this without claiming Apple's manufacturer (and thus unregistering their decoder)? 1928 resource 'thng' (304) { 1929 decompressorComponentType, // Type 1930 'mp4v', // SubType 1931 'appl', // Manufacturer 1932 0, // - use componentHasMultiplePlatforms 1933 0, 1934 0, 1935 0, 1936 'STR ', // Name Type 1937 kMPEG4NameResID, // Name ID 1938 'STR ', // Info Type 1939 kMPEG4NameResID, // Info ID 1940 0, // Icon Type 1941 0, // Icon ID 1942 kFFusionCodecVersion + 0x10000, // Version 1943 componentHasMultiplePlatforms + // Registration Flags 1944 componentDoAutoVersion, // Registration Flags 1945 0, // Resource ID of Icon Family 1946 { 1947 kFFusionDecompressionFlags, 1948 'dlle', // Entry point found by symbol name 'dlle' resource 1949 256, // ID of 'dlle' resource 1950 platformPowerPCNativeEntryPoint, 1951 kFFusionDecompressionFlags, 1952 'dlle', 1953 256, 1954 platformIA32NativeEntryPoint, 1955 }; 1956 }; 1957 1927 1958 1928 1959 //--------------------------------------------------------------------------- 1929 1960 // H264 Components 1930 1961 //--------------------------------------------------------------------------- 1931 resource 'thng' (30 4) {1962 resource 'thng' (305) { 1932 1963 decompressorComponentType, // Type 1933 1964 'H264', // SubType … … 1959 1990 }; 1960 1991 1961 resource 'thng' (30 5) {1992 resource 'thng' (306) { 1962 1993 decompressorComponentType, // Type 1963 1994 'h264', // SubType … … 1989 2020 }; 1990 2021 1991 resource 'thng' (30 6) {2022 resource 'thng' (307) { 1992 2023 decompressorComponentType, // Type 1993 2024 'X264', // SubType … … 2019 2050 }; 2020 2051 2021 resource 'thng' (30 7) {2052 resource 'thng' (308) { 2022 2053 decompressorComponentType, // Type 2023 2054 'x264', // SubType … … 2049 2080 }; 2050 2081 2051 resource 'thng' (30 8) {2082 resource 'thng' (309) { 2052 2083 decompressorComponentType, // Type 2053 2084 'DAVC', // SubType … … 2079 2110 }; 2080 2111 2081 resource 'thng' (3 09) {2112 resource 'thng' (310) { 2082 2113 decompressorComponentType, // Type 2083 2114 'VSSH', // SubType … … 2109 2140 }; 2110 2141 2111 resource 'thng' (31 0) {2142 resource 'thng' (311) { 2112 2143 decompressorComponentType, // Type 2113 2144 'AVC1', // SubType … … 2139 2170 }; 2140 2171 2141 resource 'thng' (31 1) {2172 resource 'thng' (312) { 2142 2173 decompressorComponentType, // Type 2143 2174 'avc1', // SubType … … 2173 2204 // Flash Video Codecs 2174 2205 //--------------------------------------------------------------------------- 2175 resource 'thng' (31 2) {2206 resource 'thng' (313) { 2176 2207 decompressorComponentType, // Type 2177 2208 'FLV1', // SubType … … 2203 2234 }; 2204 2235 2205 resource 'thng' (31 3) {2236 resource 'thng' (314) { 2206 2237 decompressorComponentType, // Type 2207 2238 'FSV1', // SubType … … 2237 2268 // VP6 Components 2238 2269 //--------------------------------------------------------------------------- 2239 resource 'thng' (31 4) {2270 resource 'thng' (315) { 2240 2271 decompressorComponentType, // Type 2241 2272 'VP60', // SubType … … 2267 2298 }; 2268 2299 2269 resource 'thng' (31 5) {2300 resource 'thng' (316) { 2270 2301 decompressorComponentType, // Type 2271 2302 'VP61', // SubType … … 2297 2328 }; 2298 2329 2299 resource 'thng' (31 6) {2330 resource 'thng' (317) { 2300 2331 decompressorComponentType, // Type 2301 2332 'VP62', // SubType … … 2327 2358 }; 2328 2359 2329 resource 'thng' (31 7) {2360 resource 'thng' (318) { 2330 2361 decompressorComponentType, // Type 2331 2362 'VP6F', // SubType … … 2361 2392 // Intel H.263 Components 2362 2393 //--------------------------------------------------------------------------- 2363 resource 'thng' (31 8) {2394 resource 'thng' (319) { 2364 2395 decompressorComponentType, // Type 2365 2396 'I263', // SubType … … 2391 2422 }; 2392 2423 2393 resource 'thng' (3 19) {2424 resource 'thng' (320) { 2394 2425 decompressorComponentType, // Type 2395 2426 'i263', // SubType … … 2425 2456 // VP3 Components 2426 2457 //--------------------------------------------------------------------------- 2427 resource 'thng' (32 0) {2458 resource 'thng' (321) { 2428 2459 decompressorComponentType, // Type 2429 2460 'VP30', // SubType … … 2455 2486 }; 2456 2487 2457 resource 'thng' (32 1) {2488 resource 'thng' (322) { 2458 2489 decompressorComponentType, // Type 2459 2490 'VP31', // SubType
