|
|
@ -40,6 +40,10 @@ |
|
|
|
typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT); |
|
|
|
typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT); |
|
|
|
typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **); |
|
|
|
typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct DXVA2Mapping { |
|
|
|
|
|
|
|
uint32_t palette_dummy[256]; |
|
|
|
|
|
|
|
} DXVA2Mapping; |
|
|
|
|
|
|
|
|
|
|
|
typedef struct DXVA2FramesContext { |
|
|
|
typedef struct DXVA2FramesContext { |
|
|
|
IDirect3DSurface9 **surfaces_internal; |
|
|
|
IDirect3DSurface9 **surfaces_internal; |
|
|
|
int nb_surfaces_used; |
|
|
|
int nb_surfaces_used; |
|
|
@ -66,6 +70,7 @@ static const struct { |
|
|
|
} supported_formats[] = { |
|
|
|
} supported_formats[] = { |
|
|
|
{ MKTAG('N', 'V', '1', '2'), AV_PIX_FMT_NV12 }, |
|
|
|
{ MKTAG('N', 'V', '1', '2'), AV_PIX_FMT_NV12 }, |
|
|
|
{ MKTAG('P', '0', '1', '0'), AV_PIX_FMT_P010 }, |
|
|
|
{ MKTAG('P', '0', '1', '0'), AV_PIX_FMT_P010 }, |
|
|
|
|
|
|
|
{ D3DFMT_P8, AV_PIX_FMT_PAL8 }, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
DEFINE_GUID(video_decoder_service, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02); |
|
|
|
DEFINE_GUID(video_decoder_service, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02); |
|
|
@ -245,12 +250,14 @@ static void dxva2_unmap_frame(AVHWFramesContext *ctx, HWMapDescriptor *hwmap) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IDirect3DSurface9 *surface = (IDirect3DSurface9*)hwmap->source->data[3]; |
|
|
|
IDirect3DSurface9 *surface = (IDirect3DSurface9*)hwmap->source->data[3]; |
|
|
|
IDirect3DSurface9_UnlockRect(surface); |
|
|
|
IDirect3DSurface9_UnlockRect(surface); |
|
|
|
|
|
|
|
av_freep(&hwmap->priv); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, |
|
|
|
static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *src, |
|
|
|
int flags) |
|
|
|
int flags) |
|
|
|
{ |
|
|
|
{ |
|
|
|
IDirect3DSurface9 *surface = (IDirect3DSurface9*)src->data[3]; |
|
|
|
IDirect3DSurface9 *surface = (IDirect3DSurface9*)src->data[3]; |
|
|
|
|
|
|
|
DXVA2Mapping *map; |
|
|
|
D3DSURFACE_DESC surfaceDesc; |
|
|
|
D3DSURFACE_DESC surfaceDesc; |
|
|
|
D3DLOCKED_RECT LockedRect; |
|
|
|
D3DLOCKED_RECT LockedRect; |
|
|
|
HRESULT hr; |
|
|
|
HRESULT hr; |
|
|
@ -271,10 +278,16 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame * |
|
|
|
return AVERROR_UNKNOWN; |
|
|
|
return AVERROR_UNKNOWN; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map = av_mallocz(sizeof(*map)); |
|
|
|
|
|
|
|
if (!map) |
|
|
|
|
|
|
|
goto fail; |
|
|
|
|
|
|
|
|
|
|
|
err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, |
|
|
|
err = ff_hwframe_map_create(src->hw_frames_ctx, dst, src, |
|
|
|
dxva2_unmap_frame, NULL); |
|
|
|
dxva2_unmap_frame, map); |
|
|
|
if (err < 0) |
|
|
|
if (err < 0) { |
|
|
|
|
|
|
|
av_freep(&map); |
|
|
|
goto fail; |
|
|
|
goto fail; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < nb_planes; i++) |
|
|
|
for (i = 0; i < nb_planes; i++) |
|
|
|
dst->linesize[i] = LockedRect.Pitch; |
|
|
|
dst->linesize[i] = LockedRect.Pitch; |
|
|
@ -282,6 +295,9 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame * |
|
|
|
av_image_fill_pointers(dst->data, dst->format, surfaceDesc.Height, |
|
|
|
av_image_fill_pointers(dst->data, dst->format, surfaceDesc.Height, |
|
|
|
(uint8_t*)LockedRect.pBits, dst->linesize); |
|
|
|
(uint8_t*)LockedRect.pBits, dst->linesize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dst->format == AV_PIX_FMT_PAL8) |
|
|
|
|
|
|
|
dst->data[1] = (uint8_t*)map->palette_dummy; |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
fail: |
|
|
|
fail: |
|
|
|
IDirect3DSurface9_UnlockRect(surface); |
|
|
|
IDirect3DSurface9_UnlockRect(surface); |
|
|
|