aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-11-07 13:42:50 +0100
committerAnton Khirnov <anton@khirnov.net>2016-11-18 10:31:53 +0100
commit9d7026574bbbe67d004a1c32911da75375692967 (patch)
treea1f059a2509274e0c274dd599766cd7ef34e3f93
parent0d3176e32f351d18d6174d8b05796829a75a4c6b (diff)
downloadffmpeg-9d7026574bbbe67d004a1c32911da75375692967.tar.gz
hwcontext_dxva2: fix handling of the mapping flags
D3DLOCK_READONLY properly corresponds to the absence of the write flag, not to the presence of the read flag, while D3DLOCK_DISCARD is equivalent to the overwrite flag.
-rw-r--r--libavutil/hwcontext_dxva2.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c
index 8a050719b7..1dc351a356 100644
--- a/libavutil/hwcontext_dxva2.c
+++ b/libavutil/hwcontext_dxva2.c
@@ -262,6 +262,7 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *
D3DLOCKED_RECT LockedRect;
HRESULT hr;
int i, err, nb_planes;
+ int lock_flags = 0;
nb_planes = av_pix_fmt_count_planes(dst->format);
@@ -271,8 +272,12 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *
return AVERROR_UNKNOWN;
}
- hr = IDirect3DSurface9_LockRect(surface, &LockedRect, NULL,
- flags & AV_HWFRAME_MAP_READ ? D3DLOCK_READONLY : D3DLOCK_DISCARD);
+ if (!(flags & AV_HWFRAME_MAP_WRITE))
+ lock_flags |= D3DLOCK_READONLY;
+ if (flags & AV_HWFRAME_MAP_OVERWRITE)
+ lock_flags |= D3DLOCK_DISCARD;
+
+ hr = IDirect3DSurface9_LockRect(surface, &LockedRect, NULL, lock_flags);
if (FAILED(hr)) {
av_log(ctx, AV_LOG_ERROR, "Unable to lock DXVA2 surface\n");
return AVERROR_UNKNOWN;
@@ -318,7 +323,8 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
map->format = dst->format;
ret = dxva2_map_frame(ctx, map, download ? src : dst,
- download ? AV_HWFRAME_MAP_READ : AV_HWFRAME_MAP_WRITE);
+ download ? AV_HWFRAME_MAP_READ :
+ AV_HWFRAME_MAP_WRITE | AV_HWFRAME_MAP_OVERWRITE);
if (ret < 0)
goto fail;