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

Gwenole Beauchesne gbeauchesne
Wed Feb 25 23:01:12 CET 2009


Le 25 f?vr. 09 ? 20:43, Michael Niedermayer a ?crit :

>> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
>> index 344cee5..b1ee0e4 100644
>> --- a/libavcodec/h264.c
>> +++ b/libavcodec/h264.c
>> @@ -4034,6 +4034,11 @@ static int decode_slice_header(H264Context  
>> *h, H264Context *h0){
>>         slice_group_change_cycle= get_bits(&s->gb, ?);
>> #endif
>>
>> +    if (s->avctx->hwaccel && h0->current_slice == 0) {
>> +        if (s->avctx->hwaccel->start_frame(s->avctx, NULL, 0) < 0)
>> +            return -1;
>> +    }
>> +
>>     h0->last_slice_type = slice_type;
>>     h->slice_num = ++h0->current_slice;
>>     if(h->slice_num >= MAX_SLICES){
>
> outside of decode_slice_header() seems a nicer place ...

decode_nal_units()::NAL_SLICE case after the call to  
decode_slice_header()? It cannot really be earlier. Is using  
current_slice==1 ok or the same mpeg12.c machinery desired (s- 
 >first_slice)?

>> @@ -7706,6 +7718,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)
>> +                return -1;
>> +        }
>> +
>>         if (CONFIG_H264_VDPAU_DECODER && s->avctx->codec- 
>> >capabilities&CODEC_CAP_HWACCEL_VDPAU)
>>             ff_vdpau_h264_picture_complete(s);
>>
>
> this seems the only code that does a return -1 there ...
> what is the intent of that? besides what is the meaning of
> end_frame() failing?

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.



More information about the ffmpeg-devel mailing list