summaryrefslogtreecommitdiff
path: root/libavcodec/dxva2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/dxva2.c')
-rw-r--r--libavcodec/dxva2.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 8b0e6869ae..f68df860dc 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -3,20 +3,20 @@
*
* copyright (c) 2010 Laurent Aimar
*
- * 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
*/
@@ -58,7 +58,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx,
void *dxva_data;
unsigned dxva_size;
int result;
- HRESULT hr;
+ HRESULT hr = 0;
#if CONFIG_D3D11VA
if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
@@ -137,7 +137,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
#if CONFIG_DXVA2
DXVA2_DecodeBufferDesc buffer2[4];
#endif
- DECODER_BUFFER_DESC *buffer,*buffer_slice;
+ DECODER_BUFFER_DESC *buffer = NULL, *buffer_slice = NULL;
int result, runs = 0;
HRESULT hr;
unsigned type;
@@ -158,9 +158,15 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
ff_dxva2_get_surface(frame),
NULL);
#endif
- if (hr == E_PENDING)
- av_usleep(2000);
- } while (hr == E_PENDING && ++runs < 50);
+ if (hr != E_PENDING || ++runs > 50)
+ break;
+#if CONFIG_D3D11VA
+ if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
+ if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
+ ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
+#endif
+ av_usleep(2000);
+ } while(1);
if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr);