aboutsummaryrefslogtreecommitdiff
path: root/libavutil/hwcontext_dxva2.c
diff options
context:
space:
mode:
authorHendrik Leppkes2016-11-14 15:15:19 +0100
committerHendrik Leppkes2016-11-14 15:15:19 +0100
commit3dfe97a841fe6985357357ef0b93601bfe531bf8 (patch)
tree08dc449370b924019fe57d6e1059906f88967687 /libavutil/hwcontext_dxva2.c
parentd4509495bfa21e34941e9ee94236c4e71007bf43 (diff)
parent2ef87815fec059504370ae3050cc243a53553915 (diff)
Merge commit '2ef87815fec059504370ae3050cc243a53553915'
* commit '2ef87815fec059504370ae3050cc243a53553915': hwcontext_dxva2: add support for p010 Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
Diffstat (limited to 'libavutil/hwcontext_dxva2.c')
-rw-r--r--libavutil/hwcontext_dxva2.c38
1 files changed, 14 insertions, 24 deletions
diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index 40a4a27ae1..02632b7dae 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -251,19 +251,11 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
D3DLOCKED_RECT LockedRect;
HRESULT hr;
- int download = !!src->hw_frames_ctx;
- int bytes_per_component;
+ uint8_t *surf_data[4] = { NULL };
+ int surf_linesize[4] = { 0 };
+ int i;
- switch (ctx->sw_format) {
- case AV_PIX_FMT_NV12:
- bytes_per_component = 1;
- break;
- case AV_PIX_FMT_P010:
- bytes_per_component = 2;
- break;
- default:
- av_assert0(0);
- }
+ int download = !!src->hw_frames_ctx;
surface = (IDirect3DSurface9*)(download ? src->data[3] : dst->data[3]);
@@ -280,20 +272,18 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
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) {
- av_image_copy_plane(dst->data[0], dst->linesize[0],
- (uint8_t*)LockedRect.pBits, LockedRect.Pitch,
- src->width * bytes_per_component, src->height);
- av_image_copy_plane(dst->data[1], dst->linesize[1],
- (uint8_t*)LockedRect.pBits + LockedRect.Pitch * surfaceDesc.Height,
- LockedRect.Pitch, src->width * bytes_per_component, src->height / 2);
+ av_image_copy(dst->data, dst->linesize, surf_data, surf_linesize,
+ ctx->sw_format, src->width, src->height);
} else {
- av_image_copy_plane((uint8_t*)LockedRect.pBits, LockedRect.Pitch,
- dst->data[0], dst->linesize[0],
- src->width * bytes_per_component, src->height);
- av_image_copy_plane((uint8_t*)LockedRect.pBits + LockedRect.Pitch * surfaceDesc.Height,
- LockedRect.Pitch, dst->data[1], dst->linesize[1],
- src->width * bytes_per_component, src->height / 2);
+ av_image_copy(surf_data, surf_linesize, src->data, src->linesize,
+ ctx->sw_format, src->width, src->height);
}
IDirect3DSurface9_UnlockRect(surface);