mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-09-08 00:45:34 +02:00
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.
This commit is contained in:
parent
0d3176e32f
commit
9d7026574b
@ -262,6 +262,7 @@ static int dxva2_map_frame(AVHWFramesContext *ctx, AVFrame *dst, const AVFrame *
|
|||||||
D3DLOCKED_RECT LockedRect;
|
D3DLOCKED_RECT LockedRect;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
int i, err, nb_planes;
|
int i, err, nb_planes;
|
||||||
|
int lock_flags = 0;
|
||||||
|
|
||||||
nb_planes = av_pix_fmt_count_planes(dst->format);
|
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;
|
return AVERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IDirect3DSurface9_LockRect(surface, &LockedRect, NULL,
|
if (!(flags & AV_HWFRAME_MAP_WRITE))
|
||||||
flags & AV_HWFRAME_MAP_READ ? D3DLOCK_READONLY : D3DLOCK_DISCARD);
|
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)) {
|
if (FAILED(hr)) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "Unable to lock DXVA2 surface\n");
|
av_log(ctx, AV_LOG_ERROR, "Unable to lock DXVA2 surface\n");
|
||||||
return AVERROR_UNKNOWN;
|
return AVERROR_UNKNOWN;
|
||||||
@ -318,7 +323,8 @@ static int dxva2_transfer_data(AVHWFramesContext *ctx, AVFrame *dst,
|
|||||||
map->format = dst->format;
|
map->format = dst->format;
|
||||||
|
|
||||||
ret = dxva2_map_frame(ctx, map, download ? src : dst,
|
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)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user