[Libva] performances question with libva on i5 sandy bridge

Xiang, Haihao haihao.xiang at intel.com
Sun Jan 18 18:34:37 PST 2015


On Mon, 2015-01-19 at 00:20 +0100, Gilles Chanteperdrix wrote:
> Hi,
> 
> I am testing libva with ffmpeg on Linux to decode h264 video. 
> Linux version is 3.4.29 
> FFmpeg version is 2.5.3 
> Mesa version is 10.4.0 
> libdrm version is 2.4.58 
> libva version is 1.5.0
> 
> From what I could gather from the documentation and examples, using
> vaDeriveImage should be preferred if it is available. However, I
> have compared, with top, the CPU consumed, and I observe that the
> following code:
> 
> #ifdef USE_VADERIVEIMAGE
> 	vrc = vaDeriveImage(ctx->display, buf->surface_id, &va_image);
> 	CHECK_VASTATUS(vrc, "vaDeriveImage");
> #else
> 	vrc = vaGetImage(ctx->display, buf->surface_id,
> 			0, 0, cctx->coded_width, cctx->coded_height,
> 			va_image.image_id);
> 	CHECK_VASTATUS(vrc, "vaGetImage");
> #endif
> 
> 	vrc = vaMapBuffer(ctx->display, va_image.buf, &data);
> 	CHECK_VASTATUS(vrc, "vaMapBuffer");
> 
> 	memcpy(f->img[0], data + va_image.offsets[0],
> 		va_image.pitches[0] * cctx->coded_height);
> 	memcpy(f->img[1], data + va_image.offsets[1],
> 		va_image.pitches[1] * cctx->coded_height / 2);
> 
> 	vrc = vaUnmapBuffer(ctx->display, va_image.buf);
> 	CHECK_VASTATUS(vrc, "vaUnmapBuffer");
> 
> #ifdef USE_VADERIVEIMAGE
> 	vrc = vaDestroyImage(ctx->display, va_image.image_id);
> 	CHECK_VASTATUS(vrc, "vaDestroyImage");
> #endif
> 
> Results in a higher cpu consumption if compiled with
> USE_VADERIVEIMAGE. Is this normal, or is there something I am doing
> wrong? I can provide the complete code if needed.

It depends on the the underlying memory format. Most surfaces used in
the driver are tiled, so the derived images are tiled too, the memory
returned is uncached and reading data from it would be slow. If the
image isn't tiled, the returned memory is cached. 

> 
> As a second question, is there a function allowing to copy image
> from a VA surface to custom pointers? I see I can build a buffer
> with some custom pointers, but I do not see how to copy a surface to
> them. I would like something like the inverse operation of
> vaRenderPicture.

Currently you have to do like what you did in your sample code.

> 
> Thanks in advance.
> Regards.
> 




More information about the Libva mailing list