[Libav-user] Using h264 dxva2 hwaccel to decrease CPU usage

Jérôme SALAYET jerome.salayet at hymatom.fr
Tue Feb 12 14:48:24 CET 2013

Hello, I have integrated FFMPEG to decode H264 videos streams. It works. Now, I'm trying to use AVHWAccel to decode H264 videos streaming.


I compile FFMPEG 1.1.1 with --enable-dxva2 --enable-decoder=h264_dxva2 --enable-hwaccel=h264_dxva2.

When I initialise my CodecContext, I use the method below to find the AVHWAccel


if(h264_dxva2_hwaccel == NULL)

{ AVHWAccel* hwaccel = NULL;

  while(hwaccel = av_hwaccel_next(hwaccel))

   { if((hwaccel->pix_fmt == AV_PIX_FMT_DXVA2_VLD) && (hwaccel->id == CODEC_ID_H264))

      { h264_dxva2_hwaccel = hwaccel;


        printf("dxva2_hwaccel = %s\r\n",h264_dxva2_hwaccel->name);





And so affect it to my CodecContext

if (h264_dxva2_hwaccel != NULL)

{ m_lpCodecCtx->hwaccel = h264_dxva2_hwaccel;



But it seems I have to set the m_lpCodecCtx->hwaccel_context and I don't find any documentations on this part.

And also, after this, I just have to have the same code than before (using avcodec_decode_video2 and other ffmpeg functions), or the hardware decoding is really different ?


If someone can explain me (or better have a simple sample to do this),


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130212/5a922c87/attachment.html>

More information about the Libav-user mailing list