objective-ccocoaavfoundationencodevideo-toolbox

VideoToolBox Decoding image display is flickring in Yosemite OSX


I have used videoToolBox for encoding and decoding data, so once we got data for decode directly we are passing to AVSampleBufferDisplayLayer

here is the code snippet

 -(CVPixelBufferRef)decode:(AVPacket*)vp {

    CVPixelBufferRef outputPixelBuffer = NULL;

    CMBlockBufferRef blockBuffer = NULL;
    OSStatus status  = CMBlockBufferCreateWithMemoryBlock(kCFAllocatorDefault,
                                                          (void*)vp->data, vp->size,
                                                          kCFAllocatorNull,
                                                          NULL, 0, vp->size,
                                                          0, &blockBuffer);


    //NSLog(@"status is for CMBlockBufferCreateWithMemoryBlock is %d",(int)status);
    if(status == kCMBlockBufferNoErr) {
        CMSampleBufferRef sampleBuffer = NULL;
        const size_t sampleSizeArray[] = {vp->size};
        status = CMSampleBufferCreateReady(kCFAllocatorDefault,
                                           blockBuffer,
                                           formatDesc ,
                                           1, 0, NULL, 1, sampleSizeArray,
                                           &sampleBuffer);
       // NSLog(@"status is for formatdesc is %d",(int)status);
        if (status == kCMBlockBufferNoErr && sampleBuffer) {
            CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, YES);
            CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachments, 0);
            CFDictionarySetValue(dict, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
            [displayLayer flush];
            if([displayLayer isReadyForMoreMediaData])
            {
                [displayLayer enqueueSampleBuffer:sampleBuffer];
            }

            [displayLayer setNeedsDisplay];

            [self performSelectorOnMainThread:@selector(setView:) withObject:[[RPCViewerAppInitializer sharedRPCViewerAppInitializer] rpcView] waitUntilDone:NO];
            CFRelease(blockBuffer);
            CFRelease(sampleBuffer);

        }
    }
    return outputPixelBuffer;
}

above code is working fine in 10.10 osx but in 10.10 i am getting flicker on screen.

any help will be appreciable.


Solution

  • This question have solved:

    I was setting controlTimebase property of AVSampleBufferDisplayLayer to nil, this was reason,now am not setting this property at all