[FFmpeg-devel] [PATCH] HWAccel infrastructure (take 4)

Gwenole Beauchesne gbeauchesne
Thu Feb 19 16:46:33 CET 2009


On Thu, 19 Feb 2009, Michael Niedermayer wrote:

>> @@ -612,6 +626,11 @@ retry:
>>      if(MPV_frame_start(s, avctx) < 0)
>>          return -1;
>>
>> +    if (avctx->hwaccel) {
>> +        if (avctx->hwaccel->start_frame(avctx, s->gb.buffer, s->gb.size_in_bits/8) < 0)
>> +            return -1;
>> +    }
>> +
>>  #ifdef DEBUG
>>      av_log(avctx, AV_LOG_DEBUG, "qscale=%d\n", s->qscale);
>>  #endif
>
> could avctx->hwaccel->start_frame() be called from MPV_frame_start() instead?

IIRC, I had two problems with that: (i) I need to call start_frame() for 
each field, this wouldn't work for mpeg1/2 for instance; (ii) your 
buf/buf_size args wouldn't be available there. That's a lame excuse as I 
could extend MPV_frame_start(). ;-) But (i) remains as both accelerators 
needed the fields separately.

>> +    if (avctx->hwaccel) {
>> +        if (avctx->hwaccel->end_frame(avctx) < 0)
>> +            return -1;
>> +    }
>> +
>>      MPV_frame_end(s);
>>
>>  assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type);
>
> could avctx->hwaccel->end_frame() be called from MPV_frame_end() instead?

Similar to (i), end_frame() could represent the end of a field picture 
instead.

>> +AVHWAccel *ff_query_hwaccel_codec(AVCodecContext *avctx, enum CodecID codec_id)
>> +{
>> +    AVHWAccel *hwaccel;
>> +    AVHWAccel *hwaccels[PIX_FMT_NB] = { NULL, };
>> +    enum PixelFormat pix_fmts[PIX_FMT_NB + 1];
>> +    int pix_fmt, n_pix_fmts = 0;
>> +
>
>> +    /* The user shall override ::get_format() with something sensible enough */
>> +    if (!avctx->get_format || avctx->get_format == avcodec_default_get_format)
>> +        return NULL;
>
> avctx->get_format being NULL seems invalid, so no need to check for it
> also i suspect it would be cleaner to make avcodec_default_get_format()
> skip hw-accel formats.

That's what I suggested initially but Reimar had objected IIRC.

Thanks,
Gwenole.




More information about the ffmpeg-devel mailing list