summaryrefslogtreecommitdiff
path: root/libavcodec/dxva2.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-21 15:53:40 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-21 15:56:03 +0100
commit9056d0c94af5c09478acf0e1bc129a9c539070f0 (patch)
tree9acdf2ee29f303a2cf2ff4ccfb75cc1fdaafdcce /libavcodec/dxva2.c
parenta69dd1163b1a91978e596af551c9561d121aeedf (diff)
parent5b2b23f2d69e05c5fcd1c933e383fe60e185574d (diff)
Merge commit '5b2b23f2d69e05c5fcd1c933e383fe60e185574d'
* commit '5b2b23f2d69e05c5fcd1c933e383fe60e185574d': dxva2: Retry IDirectXVideoDecoder_BeginFrame() This also adds a missig #include to prevent breaking building Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dxva2.c')
-rw-r--r--libavcodec/dxva2.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 0997c73677..bc924222b3 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -21,6 +21,7 @@
*/
#include "dxva2_internal.h"
+#include "libavutil/time.h"
void *ff_dxva2_get_surface(const Picture *picture)
{
@@ -87,12 +88,19 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, Picture *pic,
unsigned buffer_count = 0;
DXVA2_DecodeBufferDesc buffer[4];
DXVA2_DecodeExecuteParams exec = { 0 };
- int result;
-
- if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
- ff_dxva2_get_surface(pic),
- NULL))) {
- av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
+ int result, runs = 0;
+ HRESULT hr;
+
+ do {
+ hr = IDirectXVideoDecoder_BeginFrame(ctx->decoder,
+ ff_dxva2_get_surface(pic),
+ NULL);
+ if (hr == E_PENDING)
+ av_usleep(2000);
+ } while (hr == E_PENDING && ++runs < 50);
+
+ if (FAILED(hr)) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr);
return -1;
}