[FFmpeg-devel] [PATCH] [dxva2] Handle return value of BeginFrame better for nVidia cards.
Lars Hammarstrand
lars.hammarstrand at gmail.com
Wed Apr 17 18:30:40 CEST 2013
https://github.com/FlyingRat/FFmpeg/commit/1aba762826b074b40f963708ea8780681f436c4b
The nVidia cards sometimes return E_PENDING and need time before they
can start decoding a new frame.
Helps nVidia cards with blocky pictures/pixellation artifacts after skip
or when CPU is busy.
---
libavcodec/dxva2.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index 0997c73..25e5b0b 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -21,6 +21,8 @@
*/
#include "dxva2_internal.h"
+#include <unistd.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) {
+ 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