[FFmpeg-devel] [PATCH] [dxva2] Handle return value of BeginFrame better for nVidia cards.

Hendrik Leppkes h.leppkes at gmail.com
Wed Apr 17 20:13:18 CEST 2013


On Wed, Apr 17, 2013 at 6:30 PM, Lars Hammarstrand <
lars.hammarstrand at gmail.com> wrote:

>
> 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,
>

Spaces around the = make it look so much better


>                                                 ff_dxva2_get_surface(pic),
> -                                               NULL))) {
> +                                               NULL)) == E_PENDING
> +           && tries < MAX_RETRY_ON_PENDING) {
> +        usleep(1000);
>

av_usleep, replace include of unistd.h with libavutil/time.h instead.


> +        tries++;
> +    }
> +    if (FAILED(hr)) {
>          av_log(avctx, AV_LOG_ERROR, "Failed to begin frame\n");
>          return -1;
>      }
> --
> 1.8.0.1
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list