[FFmpeg-devel] [PATCH] h264.c: add HW acceleration hooks

Gwenole Beauchesne gbeauchesne
Thu Feb 26 13:42:14 CET 2009


On Thu, 26 Feb 2009, Michael Niedermayer wrote:

> On Thu, Feb 26, 2009 at 01:11:28PM +0100, Gwenole Beauchesne wrote:
>> On Thu, 26 Feb 2009, Michael Niedermayer wrote:
>>
>>>>>> Generally, actually all cases, AVHWAccel::end_frame() is sending the
>>>>>> control blocks to the accelerator, and does the actual decoding. We
>>>>>> could ignore errors as the original VDPAU code though.
>>>>>
>>>>> iam not asking to ignore them but rather asking what exactly
>>>>> the return -1 at that point is supposed to achive?
>>>>
>>>> You are right, it's probably just more useful to return the usual
>>>> get_consumed_bytes(). OK to replace the return -1; with an
>>>> av_log(ERROR,..)?
>>>>
>>>> On the other hand, decode_frame() usually returns -1 on errors and let the
>>>> callee manage whatever it wants.
>>>
>>> yes but you are returning it from the middle, this has to be reviewed for
>>> memleaks and such stuff and tested
>>> i suspect you didnt test it ...
>>
>> I indeed did not test the error path. Now, I have (Grey.ts):
>
> good and is the output vissually similar in quality depending on
> return -1 vs. not (there may be some messed up references or such)

My error simulation consisted in:

@@ -527,7 +527,8 @@ static int vaapi_common_end_frame(AVCodecContext *avctx)
              return -1;
          ff_draw_horiz_band(s, 0, s->avctx->height);
      }
-    return vaapi_render_state_fini(rds);
+    vaapi_render_state_fini(rds);
+    return -1;
  }

  /* ====================================================================== */

with the return -1; kept in h264.c, I don't see anything: this causes 
got_picture to remain to 0, thus being interpreted as "Error while 
decoding frame!" in MPlayer.

However, if I get rid of the return -1 but print an error message as in 
mpeg12.c, the video is indeed playing.

Is the second behaviour what you'd expect then? [later]

Indeed, with a (not-that) random failure, I still get video output with 
additional errors printed into the console, as expected:
[h264 @ 0x8726720]hardware accelerator failed to decode picture% 2 0

diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c
index afb6183..cf284d1 100644
--- a/libavcodec/vaapi.c
+++ b/libavcodec/vaapi.c
@@ -527,7 +527,11 @@ static int vaapi_common_end_frame(AVCodecContext *avctx)
              return -1;
          ff_draw_horiz_band(s, 0, s->avctx->height);
      }
-    return vaapi_render_state_fini(rds);
+    vaapi_render_state_fini(rds);
+    static int n = 0;
+    if ((++n % 4) == 0)
+        return -1;
+    return 0;
  }

  /* ====================================================================== */





More information about the ffmpeg-devel mailing list