summaryrefslogtreecommitdiff
path: root/libavutil/hwcontext_dxva2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavutil/hwcontext_dxva2.c')
-rw-r--r--libavutil/hwcontext_dxva2.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index e2c27bf160..e79254bb34 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -1,18 +1,18 @@
/*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -29,6 +29,7 @@
#include <dxva2api.h>
#include <initguid.h>
+#include "avassert.h"
#include "common.h"
#include "hwcontext.h"
#include "hwcontext_dxva2.h"
@@ -65,6 +66,7 @@ static const struct {
enum AVPixelFormat pix_fmt;
} supported_formats[] = {
{ 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);
@@ -249,6 +251,18 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
HRESULT hr;
int download = !!src->hw_frames_ctx;
+ int bytes_per_component;
+
+ 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);
+ }
surface = (IDirect3DSurface9*)(download ? src->data[3] : dst->data[3]);
@@ -268,17 +282,17 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
if (download) {
av_image_copy_plane(dst->data[0], dst->linesize[0],
(uint8_t*)LockedRect.pBits, LockedRect.Pitch,
- src->width, src->height);
+ 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, src->height / 2);
+ LockedRect.Pitch, src->width * bytes_per_component, src->height / 2);
} else {
av_image_copy_plane((uint8_t*)LockedRect.pBits, LockedRect.Pitch,
dst->data[0], dst->linesize[0],
- src->width, src->height);
+ 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, src->height / 2);
+ src->width * bytes_per_component, src->height / 2);
}
IDirect3DSurface9_UnlockRect(surface);
@@ -376,7 +390,7 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, const char *device,
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
- hr = IDirect3D9_CreateDevice(priv->d3d9, adapter, D3DDEVTYPE_HAL, GetShellWindow(),
+ hr = IDirect3D9_CreateDevice(priv->d3d9, adapter, D3DDEVTYPE_HAL, GetDesktopWindow(),
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
&d3dpp, &priv->d3d9device);
if (FAILED(hr)) {