aboutsummaryrefslogtreecommitdiff
path: root/lib/ffmpeg/libavcodec
diff options
context:
space:
mode:
authorCrystalP <CrystalP@xbmc.org>2011-11-11 19:10:54 -0500
committerCrystalP <CrystalP@xbmc.org>2011-11-13 12:00:17 -0500
commit0d36644fb43f0c52d993045cb5be2800e54a8289 (patch)
treeaeddec00f39f41c8da90d8ee28ebe5f50606ee69 /lib/ffmpeg/libavcodec
parent5ad414ddc77a552a91124254381be5cfa4f35f4c (diff)
[DXVA] Handle return value of BeginFrame better.
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.
Diffstat (limited to 'lib/ffmpeg/libavcodec')
-rw-r--r--lib/ffmpeg/libavcodec/dxva2.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/ffmpeg/libavcodec/dxva2.c b/lib/ffmpeg/libavcodec/dxva2.c
index 3f14311c9a..0cf99c3d1b 100644
--- a/lib/ffmpeg/libavcodec/dxva2.c
+++ b/lib/ffmpeg/libavcodec/dxva2.c
@@ -21,6 +21,9 @@
*/
#include "dxva2_internal.h"
+#include <unistd.h>
+
+#define MAX_RETRY_ON_PENDING 50
void *ff_dxva2_get_surface(const Picture *picture)
{
@@ -88,10 +91,17 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, MpegEncContext *s,
DXVA2_DecodeBufferDesc buffer[4];
DXVA2_DecodeExecuteParams exec;
int result;
+ HRESULT hr;
+ int tries = 0;
- if (FAILED(IDirectXVideoDecoder_BeginFrame(ctx->decoder,
+ while ((hr=IDirectXVideoDecoder_BeginFrame(ctx->decoder,
ff_dxva2_get_surface(s->current_picture_ptr),
- 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;
}