[FFmpeg-devel] [PATCH] [dxva2] Handle return value of BeginFrame better for nVidia cards.
Lars Hammarstrand
lars.hammarstrand at gmail.com
Wed Apr 17 23:03:24 CEST 2013
2013/4/17 Hendrik Leppkes <h.leppkes at gmail.com>
>
> Spaces around the = make it look so much better & av_usleep, replace
> include of unistd.h with libavutil/time.h instead.
>
>
Done.
https://github.com/FlyingRat/FFmpeg/commit/877bc4b0401e81a9ac1482818568fd988def7a6a
---
libavcodec/dxva2.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 0997c73..691bba0 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -21,6 +21,8 @@
*/
#include "dxva2_internal.h"
+#include "libavutil/time.h"
+#define MAX_RETRY_ON_PENDING 50
void *ff_dxva2_get_surface(const Picture *picture)
{
@@ -88,10 +90,17 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx,
Picture *pic,
DXVA2_DecodeBufferDesc buffer[4];
DXVA2_DecodeExecuteParams exec = { 0 };
int result;
+ HRESULT hr;
+ int tries = 0;
- if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
+ while ((hr = IDirectXVideoDecoder_BeginFrame(ctx->decoder,
ff_dxva2_get_surface(pic),
- NULL))) {
+ NULL)) == E_PENDING
+ && tries < MAX_RETRY_ON_PENDING) {
+ av_usleep(1000);
+ tries++;
+ }
+ if (FAILED(hr)) {
av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
return -1;
}
--
1.8.0.1
More information about the ffmpeg-devel
mailing list