Changeset 816

Show
Ignore:
Timestamp:
02/27/08 20:47:34 (5 months ago)
Author:
astrange
Message:

Write a lot of debug tracing to /tmp/perian.log if PerianDebugLogging? is set in the environment.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Codecprintf.c

    r332 r816  
    1515#ifdef DEBUG_BUILD 
    1616#define CODEC_HEADER                    "Perian Codec: " 
     17#define FILELOG 
    1718 
    1819static int Codecvprintf(FILE *fileLog, const char *format, va_list va, int print_header) 
     
    2425        { 
    2526                if(print_header) 
    26                         fprintf(glob->fileLog, CODEC_HEADER); 
     27                        fprintf(fileLog, CODEC_HEADER); 
    2728                ret = vfprintf(fileLog, format, va); 
    28                 fflush(glob->fileLog); 
     29                fflush(fileLog); 
    2930        } 
    3031        else 
     
    4748        va_list va; 
    4849        va_start(va, format); 
    49         ret = Codecvprintf(fileLog, format, va, 1); 
     50        ret = Codecvprintf(fileLog, format, va, !fileLog); 
    5051        va_end(va); 
    5152        return ret; 
    5253} 
    5354 
    54 void FourCCprintf (char *string, unsigned long a
     55const char *FourCCString(FourCharCode c
    5556{ 
    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; 
    6863} 
     64 
     65void FourCCprintf (char *string, FourCharCode a) 
     66{ 
     67    Codecprintf(NULL, "%s%s\n", string, FourCCString(a)); 
     68} 
     69 
    6970#else 
    7071#define Codecvprintf(file, fmt, va, print_header) /**/ 
  • trunk/Codecprintf.h

    r214 r816  
    1414#ifdef DEBUG_BUILD 
    1515int Codecprintf(FILE *, const char *format, ...); 
    16 void FourCCprintf(char *string, unsigned long a); 
     16void FourCCprintf(char *string, FourCharCode a); 
     17const char *FourCCString(FourCharCode c); 
    1718#else 
    1819#define Codecprintf(file, fmt, ...) /**/ 
  • trunk/FFusionCodec.c

    r806 r816  
    132132//--------------------------------------------------------------------------- 
    133133 
    134 static OSErr FFusionDecompress(AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length); 
     134static OSErr FFusionDecompress(FFusionGlobals glob, AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length); 
    135135static int FFusionGetBuffer(AVCodecContext *s, AVFrame *pic); 
    136136static void FFusionReleaseBuffer(AVCodecContext *s, AVFrame *pic); 
     
    145145extern void initLib(); 
    146146extern CFMutableStringRef GetHomeDirectory(); 
     147 
     148#define FFCodecprintf(x...) if (glob->fileLog) Codecprintf(glob->fileLog, x); 
     149#define not(x) ((x) ? "" : "not ") 
    147150 
    148151//--------------------------------------------------------------------------- 
     
    241244         
    242245  //  FourCCprintf("Opening component for type ", descout.componentSubType); 
    243          
    244246    // Allocate memory for our globals, set them up and inform the component manager that we've done so 
    245247         
     
    264266                glob->data.frames = NULL; 
    265267                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; 
    271270                 
    272271//        c = FindNextComponent(c, &cd); 
     
    306305    } 
    307306     
     307    FFCodecprintf("%p opened for '%s'\n", glob, FourCCString(glob->componentType)); 
    308308    return err; 
    309309} 
     
    315315pascal ComponentResult FFusionCodecClose(FFusionGlobals glob, ComponentInstance self) 
    316316{ 
     317    FFCodecprintf("%p closed.\n", glob); 
     318 
    317319    // Make sure to close the base component and deallocate our storage 
    318      
    319320    if (glob)  
    320321    { 
     
    417418pascal ComponentResult FFusionCodecInitialize(FFusionGlobals glob, ImageSubCodecDecompressCapabilities *cap) 
    418419{ 
     420        Boolean doExperimentalFlags = getenv("PerianExperimentalQTFlags") != NULL; 
    419421         
    420422    // Secifies the size of the ImageSubCodecDecompressRecord structure 
     
    433435                cap->subCodecSupportsOutOfOrderDisplayTimes = true; 
    434436                cap->baseCodecShouldCallDecodeBandForAllFrames = true; 
    435                 cap->subCodecSupportsScheduledBackwardsPlaybackWithDifferenceFrames = true
     437                cap->subCodecSupportsScheduledBackwardsPlaybackWithDifferenceFrames = !doExperimentalFlags
    436438                 
    437439        //  XXX enabling this seems to cause rare visible artifacts in h.264? 
    438         //     cap->subCodecSupportsDrawInDecodeOrder = true;  
     440               cap->subCodecSupportsDrawInDecodeOrder = doExperimentalFlags;  
    439441                cap->subCodecSupportsDecodeSmoothing = true;  
    440442        } 
     
    468470    // to the fourCC if it has not been done before 
    469471     
     472        FFCodecprintf("%p Preflight called.\n", glob); 
     473         
    470474    if (!glob->avCodec) 
    471475    { 
     
    686690                } 
    687691                 
     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         
    688694                if(glob->avContext->extradata_size != 0 && glob->begin.parser != NULL) 
    689695                        ffusionParseExtraData(glob->begin.parser, glob->avContext->extradata, glob->avContext->extradata_size); 
     
    786792        capabilities->flags |= codecCanAsync | codecCanAsyncWhen; 
    787793         
     794        FFCodecprintf("%p Preflight requesting colorspace '%s'. (error %d)\n", glob, FourCCString(pos[0]), err); 
     795         
    788796    return err; 
    789797} 
     
    822830    FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 
    823831        int redisplayFirstFrame = 0; 
     832        int type = 0; 
     833        int skippable = 0; 
    824834         
    825835    ////// 
     
    847857        myDrp->frameData = NULL; 
    848858        myDrp->buffer = NULL; 
     859         
     860        FFCodecprintf("%p BeginBand #%d. (%sdecoded, packed %d)\n", glob, p->frameNumber, not(myDrp->decoded), glob->packedType); 
    849861         
    850862        if (!glob->avContext) { 
     
    897909        { 
    898910                int parsedBufSize; 
    899                 int type = 0; 
    900                 int skippable = 0; 
    901911                uint8_t *buffer = (uint8_t *)drp->codecData; 
    902912                int bufferSize = p->bufferSize; 
     
    921931                        else 
    922932                        { 
    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); 
    924934                                if(glob->data.unparsedFrames.dataSize != 0) 
    925                                         Codecprintf(NULL, ", parser had extra data\n");                                
     935                                        Codecprintf(glob->fileLog, ", parser had extra data\n");                               
    926936                        } 
    927937                } 
     
    10121022        myDrp->frameNumber = p->frameNumber; 
    10131023        myDrp->GOPStartFrameNumber = glob->begin.lastIFrame; 
     1024         
     1025        FFCodecprintf("%p BeginBand: frame #%d type %d. (%sskippable)\n", glob, myDrp->frameNumber, type, not(skippable)); 
    10141026    return noErr; 
    10151027} 
    10161028 
    1017 static OSErr PrereqDecompress(FrameData *prereq, AVCodecContext *context, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture) 
    1018 
     1029static 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         
    10191033        FrameData *preprereq = FrameDataCheckPrereq(prereq); 
    10201034        if(preprereq) 
    1021                 PrereqDecompress(preprereq, context, dataProc, width, height, picture); 
     1035                PrereqDecompress(glob, preprereq, context, dataProc, width, height, picture); 
    10221036         
    10231037        unsigned char *dataPtr = (unsigned char *)prereq->buffer; 
    10241038        int dataSize = prereq->dataSize; 
    10251039         
    1026         OSErr err = FFusionDecompress(context, dataPtr, dataProc, width, height, picture, dataSize); 
     1040        OSErr err = FFusionDecompress(glob, context, dataPtr, dataProc, width, height, picture, dataSize); 
    10271041         
    10281042        return err; 
     
    10351049 
    10361050    FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 
     1051         
     1052        FFCodecprintf("%p DecodeBand #%d qtType %d. (packed %d)\n", glob, myDrp->frameNumber, drp->frameType, glob->packedType); 
    10371053 
    10381054        avcodec_get_frame_defaults(&tempFrame); 
     
    10431059        { 
    10441060                /* Skipped some frames in here */ 
     1061                FFCodecprintf("%p - frames skipped.\n", glob); 
    10451062                if(drp->frameType == kCodecFrameTypeKey || myDrp->GOPStartFrameNumber > glob->decode.lastFrame || myDrp->frameNumber < glob->decode.lastFrame) 
    10461063                { 
    10471064                        /* 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) * 
    10481065                         * then we are in a whole new GOP */ 
     1066                        FFCodecprintf("%p - in a new GOP.\n", glob); 
    10491067                        avcodec_flush_buffers(glob->avContext); 
    10501068                } 
     
    10591077                if(nextFrame != NULL) 
    10601078                { 
    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); 
    10621080                        if(tempFrame.data[0] != NULL) 
    10631081                        { 
     
    10851103                if(prereq) 
    10861104                { 
    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); 
    10881106                        if(tempFrame.data[0] != NULL) 
    10891107                        { 
     
    11061124                 
    11071125        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); 
    11091127         
    11101128        if (glob->packedType == PACKED_QUICKTIME_KNOWS_ORDER) { 
     
    11261144         
    11271145        FFusionDataMarkRead(&(glob->data), frameData); 
     1146         
     1147        FFCodecprintf("%p DecodeBand decoded #%d.\n", glob, glob->decode.lastFrame); 
    11281148 
    11291149        return err; 
     
    11571177    FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 
    11581178        int i, j; 
     1179         
     1180        FFCodecprintf("%p DrawBand #%d. (%sdecoded)\n", glob, myDrp->frameNumber, not(myDrp->decoded)); 
    11591181         
    11601182        if(!myDrp->decoded) 
     
    12481270pascal ComponentResult FFusionCodecEndBand(FFusionGlobals glob, ImageSubCodecDecompressRecord *drp, OSErr result, long flags) 
    12491271{ 
     1272        FFusionDecompressRecord *myDrp = (FFusionDecompressRecord *)drp->userDecompressRecord; 
     1273        FFCodecprintf("%p EndBand #%d.\n", glob, myDrp->frameNumber); 
    12501274    return noErr; 
    12511275} 
     
    15371561//----------------------------------------------------------------- 
    15381562 
    1539 OSErr FFusionDecompress(AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length) 
     1563OSErr FFusionDecompress(FFusionGlobals glob, AVCodecContext *context, UInt8 *dataPtr, ICMDataProcRecordPtr dataProc, long width, long height, AVFrame *picture, long length) 
    15401564{ 
    15411565    OSErr err = noErr; 
     
    15441568    long availableData = dataProc ? codecMinimumDataSize : kInfiniteDataSize; 
    15451569         
     1570        FFCodecprintf("%p Decompress on frame #%d (%d bytes).\n", glob, glob->decode.lastFrame, length); 
    15461571    picture->data[0] = 0; 
    15471572         
  • trunk/MatroskaCodecIDs.cpp

    r812 r816  
    571571} 
    572572 
    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  
    579573ComponentResult ASBDExt_AAC(KaxTrackEntry *tr_entry, AudioStreamBasicDescription *asbd, AudioChannelLayout *acl) 
    580574{ 
     
    599593                                                                         asbd); 
    600594                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); 
    603596                 
    604597                err = AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutFromESDS, 
     
    608601                                                                         acl); 
    609602                if (err != noErr)  
    610                         PrintCoreAudioError("MatroskaQT: Error creating ACL from AAC esds", err); 
     603                        FourCCprintf("MatroskaQT: Error creating ACL from AAC esds", err); 
    611604                 
    612605                DisposeHandle(esdsExt);