Beispiel #1
0
static HRESULT WINAPI QTVDecoder_Receive(TransformFilter *tf, IMediaSample *pSample)
{
    QTVDecoderImpl* This = impl_from_TransformFilter(tf);
    HRESULT hr;
    DWORD cbSrcStream;
    LPBYTE pbSrcStream;

    ICMFrameTimeRecord frameTime = {{0}};
    TimeValue time = 1;
    TimeScale timeScale = 1;
    OSStatus err = noErr;
    LONGLONG tStart, tStop;

    hr = IMediaSample_GetPointer(pSample, &pbSrcStream);
    if (FAILED(hr))
    {
        ERR("Cannot get pointer to sample data (%x)\n", hr);
        goto error;
    }

    cbSrcStream = IMediaSample_GetActualDataLength(pSample);

    if (IMediaSample_GetTime(pSample, &tStart, &tStop) != S_OK)
        tStart = tStop = 0;

    time = tStart;

    frameTime.recordSize = sizeof(ICMFrameTimeRecord);
    *(TimeValue64 *)&frameTime.value = tStart;
    frameTime.scale = 1;
    frameTime.rate = fixed1;
    frameTime.duration = tStop - tStart;
    frameTime.frameNumber = 0;
    frameTime.flags = icmFrameTimeIsNonScheduledDisplayTime;

    err = ICMDecompressionSessionDecodeFrame(This->decompressionSession,
            (UInt8 *)pbSrcStream, cbSrcStream, NULL, &frameTime, pSample);

    if (err != noErr)
    {
        ERR("Error with ICMDecompressionSessionDecodeFrame\n");
        hr = E_FAIL;
        goto error;
    }

    ICMDecompressionSessionSetNonScheduledDisplayTime(This->decompressionSession, time, timeScale, 0);
    ICMDecompressionSessionFlush(This->decompressionSession);
    hr = This->decodeHR;

error:
    return hr;
}
Beispiel #2
0
static ComponentResult
_setup_ds(StreamInfoPtr si, ImageDescriptionHandle imgDesc)
{
    ComponentResult err = noErr;
    CFNumberRef number = NULL;
    CFMutableDictionaryRef pba = NULL;
    ICMDecompressionTrackingCallbackRecord dtcr;
    SInt32 w, h;
    OSType pbf = k422YpCbCr8PixelFormat;

    dbg_printf("[ vOE]  >> [%08lx] :: _setup_ds()\n", (UInt32) -1);

    if (si->si_v.ds) {
        ICMDecompressionSessionFlush(si->si_v.ds);
        ICMDecompressionSessionRelease(si->si_v.ds);
        si->si_v.ds = NULL;
    }

    pba = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks,
                                    &kCFTypeDictionaryValueCallBacks);

    w = si->si_v.width >> 16;
    h = si->si_v.height >> 16;

    number = CFNumberCreate(NULL, kCFNumberSInt32Type, &w);
    CFDictionaryAddValue(pba, kCVPixelBufferWidthKey, number);
    CFRelease(number);

    number = CFNumberCreate(NULL, kCFNumberSInt32Type, &h);
    CFDictionaryAddValue(pba, kCVPixelBufferHeightKey, number);
    CFRelease(number);

    number = CFNumberCreate(NULL, kCFNumberSInt32Type, &pbf);
    CFDictionaryAddValue(pba, kCVPixelBufferPixelFormatTypeKey, number);
    CFRelease(number);

    dtcr.decompressionTrackingCallback = _frame_decompressed;
    dtcr.decompressionTrackingRefCon = (void *) si;

    err = ICMDecompressionSessionCreate(NULL, imgDesc,
                                        /* sessionOptions */ NULL,
                                        pba,
                                        &dtcr,
                                        &si->si_v.ds);

    CFRelease(pba);

    dbg_printf("[ vOE] <   [%08lx] :: _setup_ds() = %ld\n", (UInt32) -1, err);
    return err;
}