[Libav-user] HW Accelerator in Windows: DXVA2 with new API

wm4 nfxjfg at googlemail.com
Mon Aug 25 17:53:54 CEST 2014


On Mon, 25 Aug 2014 15:23:20 +0200
Hector Alonso <hector.alonso.aparicio at gmail.com> wrote:

> Hi,
> I've rebuilt ffmpeg using these instructions
> https://trac.ffmpeg.org/wiki/CompilationGuide/MSVC from the Visual Studio
> Console, installing MinGW directly from the link with the flags --enable-dxva2
> and --enable-hwaccel=h264_dxva2 and is almost working but I get a lot
> of errors:
> -1094995529 "Invalid data found when processing input"
> from avcodec_decode_video2 a lot of artifacts and a very poor and
> inconsistent image quality.
> This is my dxva initialization code:
> 
> _pCodecCtx->flags|= CODEC_CAP_DR1;
> _pCodecCtx->flags|= CODEC_CAP_HWACCEL;
> 
> InputStream *ist = new InputStream ();
> ist->hwaccel_id = HWACCEL_AUTO;
> ist->hwaccel_device = "dxva2";
> ist->dec = _pCodec;
> ist->dec_ctx = _pCodecCtx;
> _pCodecCtx->coded_width  = 1280;
> _pCodecCtx->coded_height = 720;
> _pCodecCtx->opaque = ist;
> dxva2_init(_pCodecCtx);
> _pCodecCtx->opaque  = ist;
> _pCodecCtx->get_buffer2 = ist->hwaccel_get_buffer;
> _pCodecCtx->get_format = get_format;
> _pCodecCtx->thread_safe_callbacks = 0;
> 
> before  calling
> 
>  if (avcodec_open2(_pCodecCtx , _pCodec, 0) < 0)  ...
> 
> Where get_format is:
> 
> static enum AVPixelFormat get_format(AVCodecContext *s, const enum
> AVPixelFormat *pix_fmts)
> {
> InputStream* ist = (InputStream*)s->opaque;
> ist->active_hwaccel_id = HWACCEL_DXVA2;
> ist->hwaccel_pix_fmt   = AV_PIX_FMT_DXVA2_VLD;
> return ist->hwaccel_pix_fmt;
> }
> 
> Find attached my modified ffmpeg_dxva2.cpp and ffmpeg_dxva2.h files from
> the original ffmpeg_dxva2.c and the InputStream declaration from ffmpeg.h
> 
> For getting the decoded frame I call: dxva2_retrieve_data_call, and then I
> convert it to YUV420p (I make the final conversion via pixel shader with
> OpenGL texture).
> 
> Also, with my old CPU decoder I had 3-6% CPU usage and 5-10% GPU usage (as
> I said, I'm converting and painting with OpenGL) and now with the "GPU
> Accelerated" one I have 5-13% CPU and 6-12% GPU.

PS: nevcairiel mentioned:
http://developer.download.nvidia.com/opengl/specs/WGL_NV_DX_interop.txt

Unfortunately, it's marked as experimental, and other drivers probably
don't provide it.

> Any thoughts?
> 
> Thank you!
> 


More information about the Libav-user mailing list