[Libav-user] (Bug?) Questions about error processing during hardware assisted decoding of H264

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Libav-user] (Bug?) Questions about error processing during hardware assisted decoding of H264

wl2776
Administrator
Hi all.
I was trying to ak this question in libav-api mailing list, but with no answer.

I'd like to draw your attention to the function field_end(), located in the file libavcodec/h264.c

http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/h264.c;h=66174778df67f1f946b1f217c1bbcb2a64748691;hb=HEAD#l2503

Lines 2528 - 2531 contain call to the end_frame function, processing its return code and writing diagnostic message.

However, the function return code, stored in the variable err, doesn't depend on this error code.

So, for me, it's obvious bug here.
Beacuse of it, in my application, I'm often getting error messages about "hardware accelerator failed to decode", and positive result of the call to avcodec_decode_video2() (got_picture flag is positive).
As a result, my application draws green rectangles instead of dropping invalid frames.

Is such behavior by design?

I tried patching this by assigning err to the return code of the end_frame(), but it didn't help since return code of the field_end() function is entirely ignored.

My patch is this:
if (avctx->hwaccel) {
   int end_frame_result;
   if ((end_frame_result = avctx->hwaccel->end_frame(avctx)) < 0) {
       av_log(avctx, AV_LOG_ERROR, "hardware accelerator failed to decode picture\n");
       err = end_frame_result;
   }
}

Could anyone advise me a solution on the best way to signal these errors to the application?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: [Libav-user] (Bug?) Questions about error processing during hardware assisted decoding of H264

wl2776
Administrator
Looks like my initial diagnostics was wrong.
I've added some debugging output, and got_picture was 0 after all hardware errors.

However, I was observing green frames accompanied with the following messages:

 [h264 @ 0E86DC60]=== avcodec_decode_video2 start ===
 [h264 @ 0E86DC60]Frame num gap 2 13
 [h264 @ 0E86DC60]Frame num gap 2 14
 [h264 @ 0E86DC60]Frame num gap 2 15
 [h264 @ 0E86DC60]Frame num gap 2 0
 [h264 @ 0E86DC60]no picture ooo
 [h264 @ 0E86DC60]illegal short term buffer state detected
 [h264 @ 0E86DC60]=== avcodec_decode_video2 end === bytes_used 59245 got 1 (360)

 The first and last line were produced by my application and lines in the middle were generated by the decoder.