0

我正在尝试使用 h264 解码器配置文件获取 ID3D11VideoDecoder 解码器,但在 Windows Phone 8 上捕获异常。使用此代码:

DX::ThrowIfFailed(device.Get()->QueryInterface(__uuidof(ID3D11VideoDevice), (void**)&videoDevice));
GUID guid = {0x1b81be68, 0xa0c7,0x11d3,{0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5}};

D3D11_VIDEO_DECODER_DESC *desc = new D3D11_VIDEO_DECODER_DESC();
desc->Guid = guid;
desc->OutputFormat = DXGI_FORMAT_420_OPAQUE;
desc->SampleHeight = 480;
desc->SampleWidth = 800;

D3D11_VIDEO_DECODER_CONFIG *conf = new D3D11_VIDEO_DECODER_CONFIG();
ID3D11VideoDecoder *decoder;
DX::ThrowIfFailed(videoDevice.Get()->CreateVideoDecoder(desc, conf, &decoder));

PS。我为此尝试了 SharpDX 并遇到了同样的问题。

4

2 回答 2

0

看来您没有传入有效的 D3D11_VIDEO_DECODER_CONFIG 变量。您只是定义了一个结构 D3D11_VIDEO_DECODER_CONFIG 的指针,并且在调用函数 CreateVideoDecoder 之前没有设置它的值。

D3D11_VIDEO_DECODER_CONFIG *conf = new D3D11_VIDEO_DECODER_CONFIG();
DX::ThrowIfFailed(videoDevice.Get()->CreateVideoDecoder(desc, conf, &decoder));

您可以尝试如下。

D3D11_VIDEO_DECODER_CONFIG conf
ZeroMemory(&conf, sizeof(conf));
conf.guidConfigBitstreamEncryption = xxx;
...
conf.ConfigDecoderSpecific = xxx;
DX::ThrowIfFailed(videoDevice.Get()->CreateVideoDecoder(desc, conf, &decoder));
于 2013-08-06T01:30:08.517 回答
0

所以,我找到了解决方案。

对于 H264 解码器,ConfigBitstreamRaw 字段必须为“2”。不是“1”,也不是“0”。只有“2”。像这样

    VideoDecoderDescription decoderDescription = new VideoDecoderDescription();
    decoderDescription.OutputFormat = Format.Opaque420;
    decoderDescription.SampleHeight = 480;
    decoderDescription.SampleWidth = 800;
    decoderDescription.Guid = _formatGuid;

    VideoDecoderConfig config = new VideoDecoderConfig();
    config.ConfigMinRenderTargetBuffCount = 1;
    config.ConfigBitstreamRaw = 2;
于 2013-08-08T16:43:49.713 回答