Commit 5a9906ea authored by Steve Lhomme's avatar Steve Lhomme

directx_va: don't store the va_pool in the directx_sys_t

parent e4cc2f84
......@@ -120,6 +120,7 @@ struct vlc_va_sys_t
struct AVD3D11VAContext hw;
/* pool */
va_pool_t va_pool;
ID3D11VideoDecoderOutputView *hw_surface[MAX_SURFACE_COUNT];
ID3D11ShaderResourceView *renderSrc[MAX_SURFACE_COUNT * D3D11_MAX_SHADER_VIEW];
......@@ -244,7 +245,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
vlc_va_sys_t *sys = va->sys;
picture_sys_d3d11_t *p_sys = pic->p_sys;
#if D3D11_DIRECT_DECODE
if (sys->dx_sys.va_pool.can_extern_pool)
if (sys->va_pool.can_extern_pool)
{
/* copy the original picture_sys_d3d11_t in the va_pic_context */
if (!pic->context)
......@@ -280,7 +281,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
else
#endif
{
picture_context_t *pic_ctx = va_pool_Get(&sys->dx_sys.va_pool);
picture_context_t *pic_ctx = va_pool_Get(&sys->va_pool);
if (unlikely(pic_ctx == NULL))
return VLC_ENOITEM;
pic->context = pic_ctx;
......@@ -293,7 +294,7 @@ static void Close(vlc_va_t *va)
{
vlc_va_sys_t *sys = va->sys;
directx_va_Close(va, &sys->dx_sys);
va_pool_Close(va, &sys->va_pool);
D3D11_Destroy( &sys->hd3d );
......@@ -383,7 +384,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
NewSurfacePicContext,
};
err = directx_va_Open(va, &pool_cfg, &sys->dx_sys);
err = va_pool_Open(va, &pool_cfg, &sys->va_pool);
if (err!=VLC_SUCCESS)
goto error;
......@@ -392,7 +393,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
if (err != VLC_SUCCESS)
goto error;
err = va_pool_SetupDecoder(va, &sys->dx_sys.va_pool, ctx, &fmt_out, sys->hw.surface_count);
err = va_pool_SetupDecoder(va, &sys->va_pool, ctx, &fmt_out, sys->hw.surface_count);
if (err != VLC_SUCCESS)
goto error;
......@@ -524,7 +525,6 @@ extern const GUID DXVA_ModeVP9_VLD_10bit_Profile2;
static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *fmt)
{
vlc_va_sys_t *sys = va->sys;
directx_sys_t *dx_sys = &sys->dx_sys;
HRESULT hr;
#ifndef NDEBUG
......@@ -623,7 +623,7 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
if ( sys->render == processorInput[idx] && sys->totalTextureSlices > 4)
{
if (CanUseVoutPool(&sys->d3d_dev, sys->totalTextureSlices))
dx_sys->va_pool.can_extern_pool = true;
sys->va_pool.can_extern_pool = true;
else
msg_Warn( va, "use internal pool" );
}
......@@ -661,7 +661,6 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
const video_format_t *fmt, unsigned surface_count)
{
vlc_va_sys_t *sys = va->sys;
directx_sys_t *dx_sys = &sys->dx_sys;
HRESULT hr;
ID3D10Multithread *pMultithread;
......@@ -685,7 +684,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
{
msg_Dbg(va, "mismatching external pool sizes use the internal one %dx%d vs %dx%d",
sys->textureWidth, sys->textureHeight, fmt->i_width, fmt->i_height);
dx_sys->va_pool.can_extern_pool = false;
sys->va_pool.can_extern_pool = false;
sys->textureWidth = fmt->i_width;
sys->textureHeight = fmt->i_height;
}
......@@ -693,7 +692,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
{
msg_Warn(va, "not enough decoding slices in the texture (%d/%d)",
sys->totalTextureSlices, surface_count);
dx_sys->va_pool.can_extern_pool = false;
sys->va_pool.can_extern_pool = false;
}
#if VLC_WINSTORE_APP
/* On the Xbox 1/S, any decoding of H264 with one dimension over 2304
......@@ -729,7 +728,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
return VLC_EGENERIC;
}
if (dx_sys->va_pool.can_extern_pool)
if (sys->va_pool.can_extern_pool)
{
#if !D3D11_DIRECT_DECODE
size_t surface_idx;
......@@ -740,7 +739,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
if (pic==NULL)
{
msg_Warn(va, "not enough decoder pictures %d out of %d", surface_idx, surface_count);
dx_sys->va_pool.can_extern_pool = false;
sys->va_pool.can_extern_pool = false;
break;
}
......@@ -755,7 +754,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
{
msg_Warn(va, "d3d11va requires decoding slices to be the first in the texture (%d/%d)",
p_sys->slice_index, surface_idx);
dx_sys->va_pool.can_extern_pool = false;
sys->va_pool.can_extern_pool = false;
break;
}
#endif
......@@ -767,7 +766,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
&p_sys->decoder );
if (FAILED(hr)) {
msg_Warn(va, "CreateVideoDecoderOutputView %d failed. (hr=0x%lX)", surface_idx, hr);
dx_sys->va_pool.can_extern_pool = false;
sys->va_pool.can_extern_pool = false;
break;
}
......@@ -776,7 +775,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
sys->hw_surface[surface_idx] = p_sys->decoder;
}
if (!dx_sys->va_pool.can_extern_pool)
if (!sys->va_pool.can_extern_pool)
{
for (size_t i = 0; i < surface_idx; ++i)
{
......@@ -799,7 +798,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
msg_Dbg(va, "using external surface pool");
}
if (!dx_sys->va_pool.can_extern_pool)
if (!sys->va_pool.can_extern_pool)
{
D3D11_TEXTURE2D_DESC texDesc;
ZeroMemory(&texDesc, sizeof(texDesc));
......@@ -922,14 +921,13 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id,
static void DxDestroySurfaces(vlc_va_sys_t *sys)
{
directx_sys_t *dx_sys = &sys->dx_sys;
if (dx_sys->va_pool.surface_count && !dx_sys->va_pool.can_extern_pool) {
if (sys->va_pool.surface_count && !sys->va_pool.can_extern_pool) {
ID3D11Resource *p_texture;
ID3D11VideoDecoderOutputView_GetResource( sys->hw_surface[0], &p_texture );
ID3D11Resource_Release(p_texture);
ID3D11Resource_Release(p_texture);
}
for (unsigned i = 0; i < dx_sys->va_pool.surface_count; i++)
for (unsigned i = 0; i < sys->va_pool.surface_count; i++)
{
ID3D11VideoDecoderOutputView_Release( sys->hw_surface[i] );
for (int j = 0; j < D3D11_MAX_SHADER_VIEW; j++)
......
......@@ -350,16 +350,6 @@ int directx_va_Setup(vlc_va_t *va, directx_sys_t *dx_sys, const AVCodecContext *
return VLC_SUCCESS;
}
void directx_va_Close(vlc_va_t *va, directx_sys_t *dx_sys)
{
va_pool_Close(va, &dx_sys->va_pool);
}
int directx_va_Open(vlc_va_t *va, const struct va_pool_cfg *cbs, directx_sys_t *dx_sys)
{
return va_pool_Open(va, cbs, &dx_sys->va_pool);
}
static bool profile_supported(const directx_va_mode_t *mode, const es_format_t *fmt,
const AVCodecContext *avctx)
{
......
......@@ -52,8 +52,6 @@ typedef struct input_list_t {
#define MAX_SURFACE_COUNT (64)
typedef struct
{
va_pool_t va_pool;
/**
* Read the list of possible input GUIDs
*/
......@@ -66,8 +64,6 @@ typedef struct
} directx_sys_t;
int directx_va_Open(vlc_va_t *, const struct va_pool_cfg *, directx_sys_t *);
void directx_va_Close(vlc_va_t *, directx_sys_t *);
int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *avctx, const es_format_t *, int flag_xbox,
video_format_t *fmt_out, unsigned *surface_count, GUID *found_guid);
char *directx_va_GetDecoderName(const GUID *guid);
......
......@@ -128,6 +128,7 @@ struct vlc_va_sys_t
IDirectXVideoDecoderService *d3ddec;
/* pool */
va_pool_t va_pool;
IDirect3DSurface9 *hw_surface[MAX_SURFACE_COUNT];
/* avcodec internals */
......@@ -221,7 +222,7 @@ static int Get(vlc_va_t *va, picture_t *pic, uint8_t **data)
return VLC_EGENERIC;
}
picture_context_t *pic_ctx = va_pool_Get(&sys->dx_sys.va_pool);
picture_context_t *pic_ctx = va_pool_Get(&sys->va_pool);
if (likely(pic_ctx==NULL))
return VLC_ENOITEM;
......@@ -234,7 +235,7 @@ static void Close(vlc_va_t *va)
{
vlc_va_sys_t *sys = va->sys;
directx_va_Close(va, &sys->dx_sys);
va_pool_Close(va, &sys->va_pool);
if (sys->dxva2_dll)
FreeLibrary(sys->dxva2_dll);
......@@ -310,7 +311,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
va->sys = sys;
err = directx_va_Open(va, &pool_cfg, &sys->dx_sys);
err = va_pool_Open(va, &pool_cfg, &sys->va_pool);
if (err!=VLC_SUCCESS)
goto error;
......@@ -319,7 +320,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
if (err != VLC_SUCCESS)
goto error;
err = va_pool_SetupDecoder(va, &sys->dx_sys.va_pool, ctx, &fmt_out, sys->hw.surface_count);
err = va_pool_SetupDecoder(va, &sys->va_pool, ctx, &fmt_out, sys->hw.surface_count);
if (err != VLC_SUCCESS)
goto error;
......@@ -657,10 +658,9 @@ error:
static void DxDestroyVideoDecoder(vlc_va_sys_t *sys)
{
directx_sys_t *dx_sys = &sys->dx_sys;
/* releases a reference on each decoder surface */
if (sys->hw.decoder)
IDirectXVideoDecoder_Release(sys->hw.decoder);
for (unsigned i = 0; i < dx_sys->va_pool.surface_count; i++)
for (unsigned i = 0; i < sys->va_pool.surface_count; i++)
IDirect3DSurface9_Release(sys->hw_surface[i]);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment