[FFmpeg-devel] How to enable Hardware Acceleration (VAAPI) with ffmpeg
wade Liang
wadeliangsw at gmail.com
Mon Oct 1 13:46:45 CEST 2012
Dear All,
I am a newbie to ffmpeg. I wonder if I can configure ffmpeg to decode h.264
video with hardware acceleration (VAAPI) . I've saw part of ffmpeg 1.0
source code.
In libavcodec/h264.c (see Figure1), decode_slice_header() will call
get_format() to get pix_fmt, and use it in ff_find_hwaccel.
} else {
s->avctx->pix_fmt = s->avctx->get_format(s->avctx,
s->avctx->codec->pix_fmts ?
s->avctx->codec->pix_fmts :
s->avctx->color_range == AVCOL_RANGE_JPEG ?
hwaccel_pixfmt_list_h264_jpeg_420 :
ff_hwaccel_pixfmt_list_420);
}
break;
default:
av_log(s->avctx, AV_LOG_ERROR,
"Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
return AVERROR_INVALIDDATA;
}
s->avctx->hwaccel = ff_find_hwaccel(s->avctx->codec->id,
s->avctx->pix_fmt);
However, I saw the avformat_new_steram() call avcodec_alloc_context3() by
default.
This function finally call avcodec_get_context_defaults3() and set
s->get_format = avcodec_default_get_format;
The avcodec_default_get_format() will skip all HWACCEL pix_fmt and choose a
non-hardware-accelerated pix_fmt.
So, it means PIX_FMT_VAAPI_VLD won't be selected by ffmpeg and
vaapi_h264.c won't be called by default?
I also get some information from VAAPI wiki. It says below
*ffmpeg*, a command line tool from the
FFmpeg<http://en.wikipedia.org/wiki/FFmpeg> project,
does not support VA-API, but
libavcodec<http://en.wikipedia.org/wiki/Libavcodec> (also
part of the FFmpeg project) does contain code that other applications use
to support hardware accelerated decoding, including VA
API.[12]<http://en.wikipedia.org/wiki/Video_Acceleration_API#cite_note-11>
Does someone can give me some answer and suggestion about that.
I want to know if ffmpeg supports VAAPI by default, or I should follow the
ffmpeg example to write a program to enable it (like
hwdecode-demos<http://gitorious.org/hwdecode-demos>
)
Thanks for your time.
Wade
More information about the ffmpeg-devel
mailing list