hwcontext_dxva2: add support for p010

This commit is contained in:
Anton Khirnov 2016-06-22 13:00:49 +02:00
parent e78e5b735f
commit 2ef87815fe
1 changed files with 15 additions and 12 deletions

View File

@ -65,6 +65,7 @@ static const struct {
enum AVPixelFormat pix_fmt; enum AVPixelFormat pix_fmt;
} 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 },
}; };
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);
@ -248,6 +249,10 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
D3DLOCKED_RECT LockedRect; D3DLOCKED_RECT LockedRect;
HRESULT hr; HRESULT hr;
uint8_t *surf_data[4] = { NULL };
int surf_linesize[4] = { 0 };
int i;
int download = !!src->hw_frames_ctx; int download = !!src->hw_frames_ctx;
surface = (IDirect3DSurface9*)(download ? src->data[3] : dst->data[3]); surface = (IDirect3DSurface9*)(download ? src->data[3] : dst->data[3]);
@ -265,20 +270,18 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
return AVERROR_UNKNOWN; return AVERROR_UNKNOWN;
} }
for (i = 0; download ? dst->data[i] : src->data[i]; i++)
surf_linesize[i] = LockedRect.Pitch;
av_image_fill_pointers(surf_data, ctx->sw_format, surfaceDesc.Height,
(uint8_t*)LockedRect.pBits, surf_linesize);
if (download) { if (download) {
av_image_copy_plane(dst->data[0], dst->linesize[0], av_image_copy(dst->data, dst->linesize, surf_data, surf_linesize,
(uint8_t*)LockedRect.pBits, LockedRect.Pitch, ctx->sw_format, src->width, src->height);
src->width, src->height);
av_image_copy_plane(dst->data[1], dst->linesize[1],
(uint8_t*)LockedRect.pBits + LockedRect.Pitch * surfaceDesc.Height,
LockedRect.Pitch, src->width, src->height / 2);
} else { } else {
av_image_copy_plane((uint8_t*)LockedRect.pBits, LockedRect.Pitch, av_image_copy(surf_data, surf_linesize, src->data, src->linesize,
dst->data[0], dst->linesize[0], ctx->sw_format, src->width, src->height);
src->width, src->height);
av_image_copy_plane((uint8_t*)LockedRect.pBits + LockedRect.Pitch * surfaceDesc.Height,
LockedRect.Pitch, dst->data[1], dst->linesize[1],
src->width, src->height / 2);
} }
IDirect3DSurface9_UnlockRect(surface); IDirect3DSurface9_UnlockRect(surface);