[FFmpeg-devel] [PATCH] h264.c: add HW acceleration hooks (take 2)

Benoit Fouet benoit.fouet
Fri Feb 27 11:55:17 CET 2009


On 02/27/2009 11:38 AM, Gwenole Beauchesne wrote:
> On Thu, 26 Feb 2009, Gwenole Beauchesne wrote:
>
>> 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
>
> Forgot to post the revised patch.

> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index 24dc201..160edb0 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -7490,6 +7490,11 @@ static int decode_nal_units(H264Context *h, const
> uint8_t *buf, int buf_size){
>              if((err = decode_slice_header(hx, h)))
>                 break;
>  
> +            if (s->avctx->hwaccel && h->current_slice == 1) {
> +                if (s->avctx->hwaccel->start_frame(s->avctx, NULL, 0) < 0)
> +                    return -1;
> +            }
> +
>   

the if()'s can be merged (not sure this is important though)

>              s->current_picture_ptr->key_frame |=
>                      (hx->nal_unit_type == NAL_IDR_SLICE) ||
>                      (h->sei_recovery_frame_cnt >= 0);
> @@ -7714,6 +7719,11 @@ static int decode_frame(AVCodecContext *avctx,
>          h->prev_frame_num_offset= h->frame_num_offset;
>          h->prev_frame_num= h->frame_num;
>  
> +        if (avctx->hwaccel) {
> +            if (avctx->hwaccel->end_frame(avctx) < 0)
> +                av_log(avctx, AV_LOG_ERROR, "hardware accelerator
> failed to decode picture\n");
> +        }
> +
>   

ditto

>          if (CONFIG_H264_VDPAU_DECODER &&
> s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
>              ff_vdpau_h264_picture_complete(s);
>  
> @@ -8104,7 +8114,7 @@ AVCodec h264_decoder = {
>      /*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY,
>      .flush= flush_dpb,
>      .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC /
> MPEG-4 part 10"),
> -    .pix_fmts= ff_pixfmt_list_420,
> +    .pix_fmts= ff_hwaccel_pixfmt_list_420,
>  };
>  
>  #if CONFIG_H264_VDPAU_DECODER
>
>   

Ben





More information about the ffmpeg-devel mailing list