d3d11va, dxva2: return the format struct directly

Slight simplification, IMHO.
This commit is contained in:
wm4 2016-04-29 23:28:15 +02:00
parent 016eab2209
commit 64f9e48bf1
4 changed files with 13 additions and 16 deletions

View File

@ -137,9 +137,8 @@ struct d3d_decoder_fmt d3d_select_decoder_mode(
const struct d3d_decoded_format *fmt))
{
struct d3d_decoder_fmt fmt = {
.guid = &GUID_NULL,
.mpfmt_decoded = IMGFMT_NONE,
.dxfmt_decoded = 0,
.guid = &GUID_NULL,
.format = NULL,
};
// this has the right bit-depth, but is unfortunately not the native format
@ -168,9 +167,8 @@ struct d3d_decoder_fmt d3d_select_decoder_mode(
MP_VERBOSE(s, "%d\n", (int)format->dxfmt);
}
fmt.guid = mode->guid;
fmt.mpfmt_decoded = format->mpfmt;
fmt.dxfmt_decoded = format->dxfmt;
fmt.guid = mode->guid;
fmt.format = format;
return fmt;
}
}

View File

@ -33,8 +33,7 @@ struct d3d_decoded_format {
struct d3d_decoder_fmt {
const GUID *guid;
int mpfmt_decoded;
DWORD dxfmt_decoded; // D3DFORMAT or DXGI_FORMAT
const struct d3d_decoded_format *format;
};
int d3d_probe_codec(const char *codec);

View File

@ -251,14 +251,14 @@ static int d3d11va_init_decoder(struct lavc_ctx *s, int w, int h)
d3d_select_decoder_mode(s, device_guids, n_guids,
d3d11_formats, MP_ARRAY_SIZE(d3d11_formats),
d3d11_format_supported);
if (fmt.mpfmt_decoded == IMGFMT_NONE) {
if (!fmt.format) {
MP_ERR(p, "Failed to find a suitable decoder\n");
goto done;
}
struct d3d11va_decoder *decoder = talloc_zero(tmp, struct d3d11va_decoder);
talloc_set_destructor(decoder, d3d11va_destroy_decoder);
decoder->mpfmt_decoded = fmt.mpfmt_decoded;
decoder->mpfmt_decoded = fmt.format->mpfmt;
int n_surfaces = hwdec_get_max_refs(s) + ADDITIONAL_SURFACES;
int w_align = w, h_align = h;
@ -269,7 +269,7 @@ static int d3d11va_init_decoder(struct lavc_ctx *s, int w, int h)
.Width = w_align,
.Height = h_align,
.MipLevels = 1,
.Format = fmt.dxfmt_decoded,
.Format = fmt.format->dxfmt,
.SampleDesc.Count = 1,
.MiscFlags = 0,
.ArraySize = n_surfaces,
@ -336,7 +336,7 @@ static int d3d11va_init_decoder(struct lavc_ctx *s, int w, int h)
.Guid = *fmt.guid,
.SampleWidth = w,
.SampleHeight = h,
.OutputFormat = fmt.dxfmt_decoded,
.OutputFormat = fmt.format->dxfmt,
};
UINT n_cfg;
hr = ID3D11VideoDevice_GetVideoDecoderConfigCount(p->video_dev,

View File

@ -197,12 +197,12 @@ static int dxva2_init_decoder(struct lavc_ctx *s, int w, int h)
d3d9_formats, MP_ARRAY_SIZE(d3d9_formats),
dxva2_format_supported);
CoTaskMemFree(device_guids);
if (fmt.mpfmt_decoded == IMGFMT_NONE) {
if (!fmt.format) {
MP_ERR(p, "Failed to find a suitable decoder\n");
goto done;
}
p->mpfmt_decoded = fmt.mpfmt_decoded;
p->mpfmt_decoded = fmt.format->mpfmt;
struct mp_image_pool *decoder_pool =
talloc_steal(tmp, mp_image_pool_new(n_surfaces));
DXVA2_ConfigPictureDecode *decoder_config =
@ -213,7 +213,7 @@ static int dxva2_init_decoder(struct lavc_ctx *s, int w, int h)
DXVA2_VideoDesc video_desc ={
.SampleWidth = w,
.SampleHeight = h,
.Format = fmt.dxfmt_decoded,
.Format = fmt.format->dxfmt,
};
UINT n_configs = 0;
DXVA2_ConfigPictureDecode *configs = NULL;
@ -246,7 +246,7 @@ static int dxva2_init_decoder(struct lavc_ctx *s, int w, int h)
hr = IDirectXVideoDecoderService_CreateSurface(
p->decoder_service,
w_align, h_align,
n_surfaces - 1, fmt.dxfmt_decoded, D3DPOOL_DEFAULT, 0,
n_surfaces - 1, fmt.format->dxfmt, D3DPOOL_DEFAULT, 0,
DXVA2_VideoDecoderRenderTarget, surfaces, NULL);
if (FAILED(hr)) {
MP_ERR(p, "Failed to create %d video surfaces: %s\n",