[vlc-devel] [PATCH 4/7] directx_va: return the whole directx_va_mode_t when a GUID is selected
Steve Lhomme
robux4 at ycbcr.xyz
Fri Oct 4 15:15:55 CEST 2019
We get the fancy name and more info about the codec output.
---
modules/codec/avcodec/d3d11va.c | 14 ++++++-------
modules/codec/avcodec/directx_va.c | 33 +++++++++++++++---------------
modules/codec/avcodec/directx_va.h | 6 +++---
modules/codec/avcodec/dxva2.c | 12 +++++------
4 files changed, 32 insertions(+), 33 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 68681b9f115..42b496dd9b8 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -112,7 +112,7 @@ struct vlc_va_sys_t
/* Video decoder */
D3D11_VIDEO_DECODER_CONFIG cfg;
- GUID decoder_guid;
+ const directx_va_mode_t *selected_decoder;
ID3D11VideoDevice *d3ddec;
/* avcodec internals */
@@ -143,7 +143,7 @@ static void SetupAVCodecContext(vlc_va_sys_t *sys, unsigned surfaces)
sys->hw.surface = sys->hw_surface;
sys->hw.context_mutex = sys->d3d_dev.context_mutex;
- if (IsEqualGUID(&sys->decoder_guid, &DXVA_Intel_H264_NoFGT_ClearVideo))
+ if (IsEqualGUID(sys->selected_decoder->guid, &DXVA_Intel_H264_NoFGT_ClearVideo))
sys->hw.workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
}
@@ -255,7 +255,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
HRESULT hr;
D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
ZeroMemory(&viewDesc, sizeof(viewDesc));
- viewDesc.DecodeProfile = sys->decoder_guid;
+ viewDesc.DecodeProfile = *sys->selected_decoder->guid;
viewDesc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
viewDesc.Texture2D.ArraySlice = p_sys->slice_index;
@@ -384,8 +384,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
video_format_t fmt_out;
static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };
- err = directx_va_Setup(va, &dx_sys, ctx, desc, fmt, isXboxHardware(sys->d3d_dev.d3ddevice), &fmt_out, &sys->hw.surface_count, &sys->decoder_guid);
- if (err != VLC_SUCCESS)
+ sys->selected_decoder = directx_va_Setup(va, &dx_sys, ctx, desc, fmt, isXboxHardware(sys->d3d_dev.d3ddevice), &fmt_out, &sys->hw.surface_count);
+ if (sys->selected_decoder == NULL)
goto error;
err = va_pool_SetupDecoder(va, &sys->va_pool, ctx, &fmt_out, sys->hw.surface_count);
@@ -700,7 +700,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
ZeroMemory(&viewDesc, sizeof(viewDesc));
- viewDesc.DecodeProfile = sys->decoder_guid;
+ viewDesc.DecodeProfile = *sys->selected_decoder->guid;
viewDesc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
const d3d_format_t *textureFmt = NULL;
@@ -843,7 +843,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
D3D11_VIDEO_DECODER_DESC decoderDesc;
ZeroMemory(&decoderDesc, sizeof(decoderDesc));
- decoderDesc.Guid = sys->decoder_guid;
+ decoderDesc.Guid = *sys->selected_decoder->guid;
decoderDesc.SampleWidth = fmt->i_width;
decoderDesc.SampleHeight = fmt->i_height;
decoderDesc.OutputFormat = sys->render;
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index 7bd1f636b63..d7862d51e34 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -260,8 +260,8 @@ static const directx_va_mode_t DXVA_MODES[] = {
{ NULL, NULL, 0, 0, NULL }
};
-static int FindVideoServiceConversion(vlc_va_t *, const directx_sys_t *, const es_format_t *, video_format_t *fmt_out,
- const AVCodecContext *, const AVPixFmtDescriptor *, GUID *found_guid);
+static const directx_va_mode_t *FindVideoServiceConversion(vlc_va_t *, const directx_sys_t *, const es_format_t *, video_format_t *fmt_out,
+ const AVCodecContext *, const AVPixFmtDescriptor *);
static char *directx_va_GetDecoderName(const GUID *guid)
{
@@ -277,10 +277,10 @@ static char *directx_va_GetDecoderName(const GUID *guid)
}
/* */
-int directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys,
+const directx_va_mode_t *directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys,
const AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
const es_format_t *fmt, int flag_xbox,
- video_format_t *fmt_out, unsigned *surfaces, GUID *found_guid)
+ video_format_t *fmt_out, unsigned *surfaces)
{
int surface_alignment = 16;
unsigned surface_count = 2;
@@ -318,7 +318,7 @@ int directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys,
surface_count += avctx->thread_count;
if (avctx->coded_width <= 0 || avctx->coded_height <= 0)
- return VLC_EGENERIC;
+ return NULL;
assert((surface_alignment & (surface_alignment - 1)) == 0); /* power of 2 */
#define ALIGN(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
@@ -339,12 +339,13 @@ int directx_va_Setup(vlc_va_t *va, const directx_sys_t *dx_sys,
fmt_out->i_frame_rate_base = avctx->framerate.den;
/* */
- if (FindVideoServiceConversion(va, dx_sys, fmt, fmt_out, avctx, desc, found_guid)) {
+ const directx_va_mode_t *res = FindVideoServiceConversion(va, dx_sys, fmt, fmt_out, avctx, desc);
+ if (res == NULL) {
msg_Err(va, "FindVideoServiceConversion failed");
- return VLC_EGENERIC;
+ return NULL;
}
*surfaces = surface_count;
- return VLC_SUCCESS;
+ return res;
}
static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *fmt,
@@ -384,21 +385,20 @@ static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *
/**
* Find the best suited decoder mode GUID and render format.
*/
-static int FindVideoServiceConversion(vlc_va_t *va, const directx_sys_t *dx_sys,
+static const directx_va_mode_t * FindVideoServiceConversion(vlc_va_t *va, const directx_sys_t *dx_sys,
const es_format_t *fmt, video_format_t *fmt_out,
- const AVCodecContext *avctx, const AVPixFmtDescriptor *desc,
- GUID *found_guid)
+ const AVCodecContext *avctx, const AVPixFmtDescriptor *desc)
{
input_list_t p_list = { 0 };
int err = dx_sys->pf_get_input_list(va, &p_list);
if (err != VLC_SUCCESS)
- return err;
+ return NULL;
if (p_list.count == 0) {
msg_Warn( va, "No input format found for HWAccel" );
- return VLC_EGENERIC;
+ return NULL;
}
- err = VLC_EGENERIC;
+ const directx_va_mode_t *res = NULL;
/* Retreive supported modes from the decoder service */
for (unsigned i = 0; i < p_list.count; i++) {
const GUID *g = &p_list.list[i];
@@ -440,12 +440,11 @@ static int FindVideoServiceConversion(vlc_va_t *va, const directx_sys_t *dx_sys,
msg_Dbg(va, "Trying to use '%s' as input", mode->name);
if (dx_sys->pf_setup_output(va, mode, fmt_out)==VLC_SUCCESS)
{
- *found_guid = *mode->guid;
- err = VLC_SUCCESS;
+ res = mode;
break;
}
}
p_list.pf_release(&p_list);
- return err;
+ return res;
}
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index 9b26b7f8471..eb7de75d39e 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -72,9 +72,9 @@ typedef struct
} directx_sys_t;
-int directx_va_Setup(vlc_va_t *, const directx_sys_t *, const AVCodecContext *, const AVPixFmtDescriptor *,
- const es_format_t *, int flag_xbox,
- video_format_t *fmt_out, unsigned *surface_count, GUID *found_guid);
+const directx_va_mode_t * directx_va_Setup(vlc_va_t *, const directx_sys_t *, const AVCodecContext *, const AVPixFmtDescriptor *,
+ const es_format_t *, int flag_xbox,
+ video_format_t *fmt_out, unsigned *surface_count);
bool directx_va_canUseDecoder(vlc_va_t *, UINT VendorId, UINT DeviceId, const GUID *pCodec, UINT driverBuild);
#endif /* AVCODEC_DIRECTX_VA_H */
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 7f1a40c3216..8f210845509 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -122,7 +122,7 @@ struct vlc_va_sys_t
/* Video decoder */
DXVA2_ConfigPictureDecode cfg;
- GUID decoder_guid;
+ const directx_va_mode_t *selected_decoder;
IDirectXVideoDecoderService *d3ddec;
/* pool */
@@ -151,7 +151,7 @@ static void SetupAVCodecContext(vlc_va_sys_t *sys, unsigned surfaces)
sys->hw.surface_count = surfaces;
sys->hw.surface = sys->hw_surface;
- if (IsEqualGUID(&sys->decoder_guid, &DXVA_Intel_H264_NoFGT_ClearVideo))
+ if (IsEqualGUID(sys->selected_decoder->guid, &DXVA_Intel_H264_NoFGT_ClearVideo))
sys->hw.workaround |= FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;
}
@@ -310,8 +310,8 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, const AVPixFmtDescriptor *des
video_format_t fmt_out;
static const directx_sys_t dx_sys = { DxGetInputList, DxSetupOutput };
- err = directx_va_Setup(va, &dx_sys, ctx, desc, fmt, 0, &fmt_out, &sys->hw.surface_count, &sys->decoder_guid);
- if (err != VLC_SUCCESS)
+ sys->selected_decoder = directx_va_Setup(va, &dx_sys, ctx, desc, fmt, 0, &fmt_out, &sys->hw.surface_count);
+ if (sys->selected_decoder == NULL)
goto error;
err = va_pool_SetupDecoder(va, &sys->va_pool, ctx, &fmt_out, sys->hw.surface_count);
@@ -585,7 +585,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
UINT cfg_count = 0;
DXVA2_ConfigPictureDecode *cfg_list = NULL;
hr = IDirectXVideoDecoderService_GetDecoderConfigurations(sys->d3ddec,
- &sys->decoder_guid,
+ sys->selected_decoder->guid,
&dsc,
NULL,
&cfg_count,
@@ -630,7 +630,7 @@ static int DxCreateVideoDecoder(vlc_va_t *va, int codec_id,
/* Create the decoder */
/* adds a reference on each decoder surface */
if (FAILED(IDirectXVideoDecoderService_CreateVideoDecoder(sys->d3ddec,
- &sys->decoder_guid,
+ sys->selected_decoder->guid,
&dsc,
&sys->cfg,
sys->hw_surface,
--
2.17.1
More information about the vlc-devel
mailing list