示例#1
0
int main(int argc, char **argv) {
    grpc_test_init(argc, argv);
    test_encoding();
    test_decoding();
    test_decoding_fails();
    return 0;
}
static void test_decoder_resolution(IDirectXVideoDecoderService *service, REFGUID const guid, D3DFORMAT format,
                                    UINT width, UINT height, UINT surface_count)
{
    HRESULT hr;
    DXVA2_VideoDesc desc;
    UINT count;
    DXVA2_ConfigPictureDecode *configs;
    DXVA2_ConfigPictureDecode config;
    IDirect3DSurface9 **surfaces;
    IDirectXVideoDecoder *decoder;
    UINT i;

    trace("Analysing buffer sizes for: %s (%u x %u)\n", convert_decoderguid_to_str(guid), width, height);

    memset(&desc, 0, sizeof(desc));

    desc.SampleWidth = width;
    desc.SampleHeight = height;
    desc.Format = format;
    desc.InputSampleFreq.Numerator = 25;
    desc.InputSampleFreq.Denominator = 1;
    desc.OutputFrameFreq.Numerator = 25;
    desc.OutputFrameFreq.Denominator = 1;

    if (0) /* crashes on windows */
    {
        hr = IDirectXVideoDecoderService_GetDecoderConfigurations(service, guid, &desc, NULL, NULL, NULL);
        ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);

        hr = IDirectXVideoDecoderService_GetDecoderConfigurations(service, guid, &desc, NULL, &count, NULL);
        ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);

        hr = IDirectXVideoDecoderService_GetDecoderConfigurations(service, guid, &desc, NULL, NULL, &configs);
        ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %x\n", hr);
    }

    hr = IDirectXVideoDecoderService_GetDecoderConfigurations(service, &GUID_NULL, &desc, NULL, &count, &configs);
    ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);

    hr = IDirectXVideoDecoderService_GetDecoderConfigurations(service, guid, &desc, NULL, &count, &configs);
    ok(!hr, "Failed to get decoder congiruation for: %s\n", convert_decoderguid_to_str(guid));
    if (hr) return;

    if (!count)
    {
        skip("Decoder for %s does not support a single decoder configuration? Skipping test\n",
             convert_decoderguid_to_str(guid));
        return;
    }

    memcpy(&config, &configs[0], sizeof(config));
    CoTaskMemFree(configs);

    surfaces = (void*)HeapAlloc(GetProcessHeap(), 0, surface_count * sizeof(IDirect3DSurface9));
    if (!surfaces)
    {
        skip("Failed to allocate memory for surfaces\n");
        return;
    }

    hr = IDirectXVideoDecoderService_CreateSurface(service, width, height, surface_count-1, format, D3DPOOL_DEFAULT, 0,
                                                        DXVA2_VideoDecoderRenderTarget, surfaces, NULL);
    ok(!hr, "Failed to create surfaces: %x\n", hr);
    if (hr)
    {
        HeapFree(GetProcessHeap(), 0, surfaces);
        return;
    }

    hr = IDirectXVideoDecoderService_CreateVideoDecoder(service, guid, &desc, &configs[0], surfaces, surface_count, &decoder);
    ok(!hr, "Failed to create decoder for %s: %x\n", convert_decoderguid_to_str(guid), hr);
    if (!hr)
    {
        test_decoding(decoder, guid, surfaces);
        IDirectXVideoDecoder_Release(decoder);
    }

    for (i = 0; i < surface_count; i++)
        IDirect3DSurface9_Release(surfaces[i]);

    HeapFree(GetProcessHeap(), 0, surfaces);
}