[FFmpeg-devel] [PATCH] HWAccel infrastructure (take 5)
Gwenole Beauchesne
gbeauchesne
Fri Feb 20 18:06:08 CET 2009
Le 20 f?vr. 09 ? 17:56, Reimar D?ffinger a ?crit :
>>> Application may want to try out the hardware accelerated formats
>>> first
>>> then make second pass for fallback non-accelerated.
>>
>> Then application overrides ::get_format(). We are talking about the
>> default get_format() from lavc, it does not have to handle HW
>> accelerated formats.
>
> I think you misunderstood it, at least the issue I saw is that
> the users supporting hardware acceleration must do two passes:
> one to first search for and try all hardware-accelerated formats and
> if
> that does not work the next (this can be avoided if you enforce that
> hw-accelerated formats must always come first, but that might break
> anyone who make their own get_format and copied the hard-coded fmt[0]
> from the current default_get_format function).
> To try all the hardware-accelerate formats first you must know which
> those are, and with internal ff_is_hwaccel_pix_fmt they might have to
> resort to such ugly hacks as in MPlayer that "uselessly" converts to
> an internal format, or they implement a variant of
> ff_is_hwaccel_pix_fmt() themselves.
You are partially right, because they wouldn't want a means to check
whether pix_fmt is HW accelerated, but if it is of a particular
accelerator "family". I had also suggested an hwaccel_id initially,
but people didn't want it either. I could externalize
av_is_hwaccel_pix_fmt() though.
e.g. here my implementation for MPlayer:
static inline int is_hwaccel_format(int imgfmt)
{
switch (get_video_hwaccel()) {
case HWACCEL_VAAPI: return IMGFMT_IS_VAAPI(imgfmt) != 0;
case HWACCEL_VDPAU: return IMGFMT_IS_VDPAU(imgfmt) != 0;
case HWACCEL_XVMC: return IMGFMT_IS_XVMC(imgfmt) != 0;
}
return 0;
}
static enum PixelFormat get_format(struct AVCodecContext *avctx,
const enum PixelFormat *fmt){
enum PixelFormat selected_format = PIX_FMT_NONE;
int imgfmt;
sh_video_t *sh = avctx->opaque;
int i, try_hwaccel;
for (try_hwaccel = 1; try_hwaccel >= 0; --try_hwaccel) {
for (i = 0; fmt[i] != PIX_FMT_NONE; i++){
imgfmt = pixfmt2imgfmt(fmt[i]);
if ((try_hwaccel ^ is_hwaccel_format(imgfmt)) != 0)
continue;
mp_msg(MSGT_DECVIDEO, MSGL_INFO,
MSGTR_MPCODECS_TryingPixfmt, i);
if (query_format(sh, imgfmt)) {
selected_format = fmt[i];
break;
}
}
if (selected_format != PIX_FMT_NONE)
break;
}
imgfmt = pixfmt2imgfmt(selected_format);
[...]
}
More information about the ffmpeg-devel
mailing list