]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dxva2.c
lavc: mark the old audio/video encoding API as deprecated
[ffmpeg] / libavcodec / dxva2.c
index 76a9d54a27a8e38952dbc1bedecc9a58cca049dd..8b0e6869ae8a167741bb8dc820e5bb0825bda9a6 100644 (file)
@@ -27,7 +27,6 @@
 #include "libavutil/time.h"
 
 #include "avcodec.h"
-#include "mpegvideo.h"
 #include "dxva2_internal.h"
 
 void *ff_dxva2_get_surface(const AVFrame *frame)
@@ -132,8 +131,12 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
 {
     AVDXVAContext *ctx = avctx->hwaccel_context;
     unsigned               buffer_count = 0;
+#if CONFIG_D3D11VA
     D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4];
+#endif
+#if CONFIG_DXVA2
     DXVA2_DecodeBufferDesc          buffer2[4];
+#endif
     DECODER_BUFFER_DESC             *buffer,*buffer_slice;
     int result, runs = 0;
     HRESULT hr;
@@ -141,10 +144,13 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
 
     do {
 #if CONFIG_D3D11VA
-        if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
+        if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
+            if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
+                WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE);
             hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder,
                                                       ff_dxva2_get_surface(frame),
                                                       0, NULL);
+        }
 #endif
 #if CONFIG_DXVA2
         if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
@@ -158,6 +164,11 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
 
     if (FAILED(hr)) {
         av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%lx\n", hr);
+#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
         return -1;
     }
 
@@ -257,8 +268,11 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
 
 end:
 #if CONFIG_D3D11VA
-    if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
+    if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
         hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder);
+        if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE)
+            ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex);
+    }
 #endif
 #if CONFIG_DXVA2
     if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)