Changeset 1042
- Timestamp:
- 04/20/09 21:09:28 (1 year ago)
- Files:
-
- trunk/FFusionCodec.c (modified) (1 diff)
- trunk/ff_MovieImport.c (modified) (1 diff)
- trunk/ff_private.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/FFusionCodec.c
r1039 r1042 233 233 if(CFStringGetFileSystemRepresentation(absLocation, fileRep, 1024)) 234 234 if(FSPathMakeRef((UInt8 *)fileRep, updateCheckRef, NULL) != noErr) 235 return; //We have failed235 goto err; //We have failed 236 236 } 237 237 pthread_t thread; 238 238 pthread_create(&thread, NULL, launchUpdateChecker, updateCheckRef); 239 240 return; 241 err: 242 free(updateCheckRef); 239 243 } 240 244 trunk/ff_MovieImport.c
r1031 r1042 376 376 enum CodecID id = codec_get_id(codec_bmp_tags, BSWAP(fourcc)); 377 377 378 if (id == CODEC_ID_MJPEG || id == CODEC_ID_DVVIDEO || id == CODEC_ID_RAWVIDEO || id == CODEC_ID_ NONE || id == CODEC_ID_MSVIDEO1)378 if (id == CODEC_ID_MJPEG || id == CODEC_ID_DVVIDEO || id == CODEC_ID_RAWVIDEO || id == CODEC_ID_MSVIDEO1) 379 379 *valid = 0; 380 380 trunk/ff_private.c
r1031 r1042 210 210 AVCodecContext *codec; 211 211 UInt32 ioSize; 212 OSStatus err ;212 OSStatus err = noErr; 213 213 214 214 uint8_t *cookie = NULL; … … 228 228 229 229 /* Ask the AudioToolbox about vbr of the codec */ 230 // FIXME this sets vbr even if it was encoded in CBR mode 231 // which means our mBytesPerPacket is wrong for CBR mp3 (does not really matter) 230 232 ioSize = sizeof(UInt32); 231 233 AudioFormatGetProperty(kAudioFormatProperty_FormatIsVBR, sizeof(AudioStreamBasicDescription), &asbd, &ioSize, &map->vbr); 232 234 235 cookie = create_cookie(codec, &cookieSize, asbd.mFormatID, map->vbr); 236 233 237 /* ask the toolbox about more information */ 234 ioSize = sizeof(AudioStreamBasicDescription); 235 AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL, &ioSize, &asbd); 238 // FIXME the cookie for AAC is wrong somehow, passing it in breaks FormatInfo & ASBDFromESDS 239 // either fix it (like in MKV) or just ignore it 240 if (asbd.mFormatID != kAudioFormatMPEG4AAC) { 241 ioSize = sizeof(AudioStreamBasicDescription); 242 err = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, cookieSize, &cookie, &ioSize, &asbd); 243 if (err || !asbd.mFormatID) 244 fprintf(stderr, "AudioFormatGetProperty dislikes the magic cookie (error %ld / format id %lx)\n", err, asbd.mFormatID); 245 } 236 246 237 247 /* Set some fields of the AudioStreamBasicDescription. Then ask the AudioToolbox … … 239 249 asbd.mSampleRate = codec->sample_rate; 240 250 asbd.mChannelsPerFrame = codec->channels; 241 if(!map->vbr && asbd.mBytesPerPacket == 0) /* This works for all the tested codecs. but is there any better way? */251 if(!map->vbr && !asbd.mBytesPerPacket) /* This works for all the tested codecs. but is there any better way? */ 242 252 asbd.mBytesPerPacket = codec->block_align; /* this is tested for alaw/mulaw/msadpcm */ 243 asbd.mFramesPerPacket = codec->frame_size; /* works for mp3, all other codecs this is 0 anyway */ 244 asbd.mBitsPerChannel = codec->bits_per_coded_sample; 245 246 // this probably isn't quite right; FLV doesn't set frame_size or block_align, 247 // but we need > 0 frames per packet or Apple's mp3 decoder won't work 253 254 /* 255 FIXME: 256 - at least ffmp3 does not set these values without parsing+the decoder being enabled 257 (so we avoid overwriting them from above for now) 258 - it is unclear whether the ASBD values correspond to decoded or encoded data (same for lavc) 259 - this should be 0 for formats with variable framesPerPacket 260 - lavc frame_size is in bytes, mFramesPerPacket is in frames (maybe) 261 */ 262 if (!asbd.mFramesPerPacket) 263 asbd.mFramesPerPacket = codec->frame_size; 248 264 if (asbd.mFormatID == kAudioFormatMPEG4AAC) 249 265 asbd.mFramesPerPacket = 1024; 250 else if (asbd.mBytesPerPacket == 0 && asbd.mFramesPerPacket == 0)266 if (!asbd.mFramesPerPacket && !asbd.mBytesPerPacket) 251 267 asbd.mFramesPerPacket = 1; 268 asbd.mBitsPerChannel = codec->bits_per_coded_sample; 252 269 253 270 // if we don't have mBytesPerPacket, we can't import as CBR. Probably should be VBR, and the codec … … 309 326 } 310 327 311 if (asbd.mSampleRate > 0) { 312 err = QTSoundDescriptionCreate(&asbd, aclSize == 0 ? NULL : &acl, aclSize, NULL, 0, kQTSoundDescriptionKind_Movie_LowestPossibleVersion, &sndHdl); 328 if (asbd.mSampleRate > 0) { 329 err = QTSoundDescriptionCreate(&asbd, aclSize == 0 ? NULL : &acl, aclSize, cookie, cookieSize, kQTSoundDescriptionKind_Movie_LowestPossibleVersion, &sndHdl); 330 313 331 if(err) { 314 332 fprintf(stderr, "AVI IMPORTER: Error %ld creating the sound description\n", err); 315 return err; 316 } 317 318 /* Create the magic cookie */ 319 cookie = create_cookie(codec, &cookieSize, asbd.mFormatID, map->vbr); 320 if(cookie) { 321 err = QTSoundDescriptionSetProperty(sndHdl, kQTPropertyClass_SoundDescription, kQTSoundDescriptionPropertyID_MagicCookie, 322 cookieSize, cookie); 323 if(err) fprintf(stderr, "AVI IMPORTER: Error %ld appending the magic cookie to the sound description\n", err); 324 av_free(cookie); 333 goto bail; 334 } 335 336 // QTSoundDescriptionCreate sets this to 576 which is wrong 337 if ((**sndHdl).version == 1 && asbd.mFormatID == kAudioFormatMPEGLayer3) { 338 SoundDescriptionV1Handle v1h = (SoundDescriptionV1Handle)sndHdl; 339 (**v1h).samplesPerPacket = 1152; 325 340 } 326 341 } 327 342 map->sampleHdl = (SampleDescriptionHandle)sndHdl; 328 343 map->asbd = asbd; 344 345 bail: 346 if(cookie) 347 av_free(cookie); 329 348 330 349 return noErr;
