Changeset 816
- Timestamp:
- 02/27/08 20:47:34 (5 months ago)
- Files:
-
- trunk/Codecprintf.c (modified) (3 diffs)
- trunk/Codecprintf.h (modified) (1 diff)
- trunk/FFusionCodec.c (modified) (26 diffs)
- trunk/MatroskaCodecIDs.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/Codecprintf.c
r332 r816 15 15 #ifdef DEBUG_BUILD 16 16 #define CODEC_HEADER "Perian Codec: " 17 #define FILELOG 17 18 18 19 static int Codecvprintf(FILE *fileLog, const char *format, va_list va, int print_header) … … 24 25 { 25 26 if(print_header) 26 fprintf( glob->fileLog, CODEC_HEADER);27 fprintf(fileLog, CODEC_HEADER); 27 28 ret = vfprintf(fileLog, format, va); 28 fflush( glob->fileLog);29 fflush(fileLog); 29 30 } 30 31 else … … 47 48 va_list va; 48 49 va_start(va, format); 49 ret = Codecvprintf(fileLog, format, va, 1);50 ret = Codecvprintf(fileLog, format, va, !fileLog); 50 51 va_end(va); 51 52 return ret; 52 53 } 53 54 54 void FourCCprintf (char *string, unsigned long a)55 const char *FourCCString(FourCharCode c) 55 56 { 56 if (a < 64) 57 { 58 Codecprintf(NULL, "%s%ld\n", string, a); 59 } 60 else 61 { 62 Codecprintf(NULL, "%s%c%c%c%c\n", string, 63 (unsigned char)((a >> 24) & 0xff), 64 (unsigned char)((a >> 16) & 0xff), 65 (unsigned char)((a >> 8) & 0xff), 66 (unsigned char)(a & 0xff)); 67 } 57 static unsigned char fourcc[5] = {0}; 58 int i; 59 60 for (i = 0; i < 4; i++) fourcc[i] = c >> 8*(3-i); 61 62 return (char*)fourcc; 68 63 } 64 65 void FourCCprintf (char *string, FourCharCode a) 66 { 67 Codecprintf(NULL, "%s%s\n", string, FourCCString(a)); 68 } 69 69 70 #else 70 71 #define Codecvprintf(file, fmt, va, print_header) /**/ trunk/Codecprintf.h
r214 r816 14 14 #ifdef DEBUG_BUILD 15 15 int Codecprintf(FILE *, const char *format, ...); 16 void FourCCprintf(char *string, unsigned long a); 16 void FourCCprintf(char *string, FourCharCode a); 17 const char *FourCCString(FourCharCode c); 17 18 #else 18 19 #define Codecprintf(file, fmt, ...) /**/ trunk/FFusionCodec.c
r806 r816 132 132 //--------------------------------------------------------------------------- 133 133 134 static OSErr FFusionDecompress( AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length);134 static OSErr FFusionDecompress(FFusionGlobals glob, AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length); 135 135 static int FFusionGetBuffer(AVCodecContext *s, AVFrame *pic); 136 136 static void FFusionReleaseBuffer(AVCodecContext *s, AVFrame *pic); … … 145 145 extern void initLib(); 146 146 extern CFMutableStringRef GetHomeDirectory(); 147 148 #define FFCodecprintf(x...) if (glob->fileLog) Codecprintf(glob->fileLog, x); 149 #define not(x) ((x) ? "" : "not ") 147 150 148 151 //--------------------------------------------------------------------------- … … 241 244 242 245 // FourCCprintf("Opening component for type ", descout.componentSubType); 243 244 246 // Allocate memory for our globals, set them up and inform the component manager that we've done so 245 247 … … 264 266 glob->data.frames = NULL; 265 267 glob->begin.parser = NULL; 266 #ifdef FILELOG 267 glob->fileLog = fopen("/tmp/perian.log", "a"); 268 #else 269 glob->fileLog = NULL; 270 #endif 268 if (getenv("PerianDebugLogging")) glob->fileLog = fopen("/tmp/perian.log", "a"); 269 else glob->fileLog = NULL; 271 270 272 271 // c = FindNextComponent(c, &cd); … … 306 305 } 307 306 307 FFCodecprintf("%p opened for '%s'\n", glob, FourCCString(glob->componentType)); 308 308 return err; 309 309 } … … 315 315 pascal ComponentResult FFusionCodecClose(FFusionGlobals glob, ComponentInstance self) 316 316 { 317 FFCodecprintf("%p closed.\n", glob); 318 317 319 // Make sure to close the base component and deallocate our storage 318 319 320 if (glob) 320 321 { … … 417 418 pascal ComponentResult FFusionCodecInitialize(FFusionGlobals glob, ImageSubCodecDecompressCapabilities *cap) 418 419 { 420 Boolean doExperimentalFlags = getenv("PerianExperimentalQTFlags") != NULL; 419 421 420 422 // Secifies the size of the ImageSubCodecDecompressRecord structure … … 433 435 cap->subCodecSupportsOutOfOrderDisplayTimes = true; 434 436 cap->baseCodecShouldCallDecodeBandForAllFrames = true; 435 cap->subCodecSupportsScheduledBackwardsPlaybackWithDifferenceFrames = true;437 cap->subCodecSupportsScheduledBackwardsPlaybackWithDifferenceFrames = !doExperimentalFlags; 436 438 437 439 // XXX enabling this seems to cause rare visible artifacts in h.264? 438 // cap->subCodecSupportsDrawInDecodeOrder = true;440 cap->subCodecSupportsDrawInDecodeOrder = doExperimentalFlags; 439 441 cap->subCodecSupportsDecodeSmoothing = true; 440 442 } … … 468 470 // to the fourCC if it has not been done before 469 471 472 FFCodecprintf("%p Preflight called.\n", glob); 473 470 474 if (!glob->avCodec) 471 475 { … … 686 690 } 687 691 692 FFCodecprintf("%p preflighted for %dx%d '%s'. (%d bytes of extradata)\n", glob, (**p->imageDescription).width, (**p->imageDescription).height, FourCCString(glob->componentType), glob->avContext->extradata_size); 693 688 694 if(glob->avContext->extradata_size != 0 && glob->begin.parser != NULL) 689 695 ffusionParseExtraData(glob->begin.parser, glob->avContext->extradata, glob->avContext->extradata_size); … … 786 792 capabilities->flags |= codecCanAsync | codecCanAsyncWhen; 787 793 794 FFCodecprintf("%p Preflight requesting colorspace '%s'. (error %d)\n", glob, FourCCString(pos[0]), err); 795 788 796 return err; 789 797 } … … 822 830 FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 823 831 int redisplayFirstFrame = 0; 832 int type = 0; 833 int skippable = 0; 824 834 825 835 ////// … … 847 857 myDrp->frameData = NULL; 848 858 myDrp->buffer = NULL; 859 860 FFCodecprintf("%p BeginBand #%d. (%sdecoded, packed %d)\n", glob, p->frameNumber, not(myDrp->decoded), glob->packedType); 849 861 850 862 if (!glob->avContext) { … … 897 909 { 898 910 int parsedBufSize; 899 int type = 0;900 int skippable = 0;901 911 uint8_t *buffer = (uint8_t *)drp->codecData; 902 912 int bufferSize = p->bufferSize; … … 921 931 else 922 932 { 923 Codecprintf( NULL, "parse failed frame %d with size %d\n", p->frameNumber, bufferSize);933 Codecprintf(glob->fileLog, "parse failed frame %d with size %d\n", p->frameNumber, bufferSize); 924 934 if(glob->data.unparsedFrames.dataSize != 0) 925 Codecprintf( NULL, ", parser had extra data\n");935 Codecprintf(glob->fileLog, ", parser had extra data\n"); 926 936 } 927 937 } … … 1012 1022 myDrp->frameNumber = p->frameNumber; 1013 1023 myDrp->GOPStartFrameNumber = glob->begin.lastIFrame; 1024 1025 FFCodecprintf("%p BeginBand: frame #%d type %d. (%sskippable)\n", glob, myDrp->frameNumber, type, not(skippable)); 1014 1026 return noErr; 1015 1027 } 1016 1028 1017 static OSErr PrereqDecompress(FrameData *prereq, AVCodecContext *context, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture) 1018 { 1029 static OSErr PrereqDecompress(FFusionGlobals glob, FrameData *prereq, AVCodecContext *context, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture) 1030 { 1031 FFCodecprintf("%p prereq-decompressing frame #%d.\n", glob, prereq->frameNumber); 1032 1019 1033 FrameData *preprereq = FrameDataCheckPrereq(prereq); 1020 1034 if(preprereq) 1021 PrereqDecompress( preprereq, context, dataProc, width, height, picture);1035 PrereqDecompress(glob, preprereq, context, dataProc, width, height, picture); 1022 1036 1023 1037 unsigned char *dataPtr = (unsigned char *)prereq->buffer; 1024 1038 int dataSize = prereq->dataSize; 1025 1039 1026 OSErr err = FFusionDecompress( context, dataPtr, dataProc, width, height, picture, dataSize);1040 OSErr err = FFusionDecompress(glob, context, dataPtr, dataProc, width, height, picture, dataSize); 1027 1041 1028 1042 return err; … … 1035 1049 1036 1050 FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 1051 1052 FFCodecprintf("%p DecodeBand #%d qtType %d. (packed %d)\n", glob, myDrp->frameNumber, drp->frameType, glob->packedType); 1037 1053 1038 1054 avcodec_get_frame_defaults(&tempFrame); … … 1043 1059 { 1044 1060 /* Skipped some frames in here */ 1061 FFCodecprintf("%p - frames skipped.\n", glob); 1045 1062 if(drp->frameType == kCodecFrameTypeKey || myDrp->GOPStartFrameNumber > glob->decode.lastFrame || myDrp->frameNumber < glob->decode.lastFrame) 1046 1063 { 1047 1064 /* If this is a key frame or the P frame before us is after the last frame (skip ahead), or we are before the last decoded frame (skip back) * 1048 1065 * then we are in a whole new GOP */ 1066 FFCodecprintf("%p - in a new GOP.\n", glob); 1049 1067 avcodec_flush_buffers(glob->avContext); 1050 1068 } … … 1059 1077 if(nextFrame != NULL) 1060 1078 { 1061 FFusionDecompress(glob ->avContext, nextFrame->buffer, NULL, myDrp->width, myDrp->height, &tempFrame, nextFrame->dataSize);1079 FFusionDecompress(glob, glob->avContext, nextFrame->buffer, NULL, myDrp->width, myDrp->height, &tempFrame, nextFrame->dataSize); 1062 1080 if(tempFrame.data[0] != NULL) 1063 1081 { … … 1085 1103 if(prereq) 1086 1104 { 1087 err = PrereqDecompress( prereq, glob->avContext, NULL, myDrp->width, myDrp->height, &tempFrame);1105 err = PrereqDecompress(glob, prereq, glob->avContext, NULL, myDrp->width, myDrp->height, &tempFrame); 1088 1106 if(tempFrame.data[0] != NULL) 1089 1107 { … … 1106 1124 1107 1125 avcodec_get_frame_defaults(&tempFrame); 1108 err = FFusionDecompress(glob ->avContext, dataPtr, dataProc, myDrp->width, myDrp->height, &tempFrame, dataSize);1126 err = FFusionDecompress(glob, glob->avContext, dataPtr, dataProc, myDrp->width, myDrp->height, &tempFrame, dataSize); 1109 1127 1110 1128 if (glob->packedType == PACKED_QUICKTIME_KNOWS_ORDER) { … … 1126 1144 1127 1145 FFusionDataMarkRead(&(glob->data), frameData); 1146 1147 FFCodecprintf("%p DecodeBand decoded #%d.\n", glob, glob->decode.lastFrame); 1128 1148 1129 1149 return err; … … 1157 1177 FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 1158 1178 int i, j; 1179 1180 FFCodecprintf("%p DrawBand #%d. (%sdecoded)\n", glob, myDrp->frameNumber, not(myDrp->decoded)); 1159 1181 1160 1182 if(!myDrp->decoded) … … 1248 1270 pascal ComponentResult FFusionCodecEndBand(FFusionGlobals glob, ImageSubCodecDecompressRecord *drp, OSErr result, long flags) 1249 1271 { 1272 FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 1273 FFCodecprintf("%p EndBand #%d.\n", glob, myDrp->frameNumber); 1250 1274 return noErr; 1251 1275 } … … 1537 1561 //----------------------------------------------------------------- 1538 1562 1539 OSErr FFusionDecompress( AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length)1563 OSErr FFusionDecompress(FFusionGlobals glob, AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length) 1540 1564 { 1541 1565 OSErr err = noErr; … … 1544 1568 long availableData = dataProc ? codecMinimumDataSize : kInfiniteDataSize; 1545 1569 1570 FFCodecprintf("%p Decompress on frame #%d (%d bytes).\n", glob, glob->decode.lastFrame, length); 1546 1571 picture->data[0] = 0; 1547 1572 trunk/MatroskaCodecIDs.cpp
r812 r816 571 571 } 572 572 573 static void PrintCoreAudioError(const char *msg, OSStatus err)574 {575 OSStatus swap_err = EndianU32_NtoB(err);576 Codecprintf(NULL, "%s '%.4s'\n", msg, &swap_err);577 }578 579 573 ComponentResult ASBDExt_AAC(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd, AudioChannelLayout *acl) 580 574 { … … 599 593 asbd); 600 594 if (err != noErr) 601 PrintCoreAudioError("MatroskaQT: Error creating ASBD from AAC esds", err); 602 //else Codecprintf(NULL, "AAC: profile %d, nch %d\n", asbd->mFormatFlags, asbd->mChannelsPerFrame); 595 FourCCprintf("MatroskaQT: Error creating ASBD from AAC esds", err); 603 596 604 597 err = AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutFromESDS, … … 608 601 acl); 609 602 if (err != noErr) 610 PrintCoreAudioError("MatroskaQT: Error creating ACL from AAC esds", err);603 FourCCprintf("MatroskaQT: Error creating ACL from AAC esds", err); 611 604 612 605 DisposeHandle(esdsExt);
