[Libva] vaDeriveImage returns wrong image size, data size and strange fourcc NV11.

kwisp kwispost at gmail.com
Wed Apr 17 09:40:25 PDT 2013


On 17 April 2013 08:44, ykzhao <yakui.zhao at intel.com> wrote:

> On Tue, 2013-04-16 at 12:26 -0600, kwisp wrote:
> > I use standart libva example
> > http://cgit.freedesktop.org/libva/tree/test/decode/mpeg2vldemo.c
> >
> >
> > I try retrive image by calling vaDeriveImage after decoding and
> > recieve stange VAImage.
> >
> > image.width = 512 image.height = 32 image.data_size=16384
> > image.numplanes=2
> >
> > image.format.fourcc = NV11 image.offsets[0] = 0, image.offsets[1] =
> > 16384, image.pitches[0] = image.pitches[1] = 512.
> >
> >
> > If I convert this VAImage data to normaly FOURCC format I see correct
> > picture.
> >
>
> Will you please describe how you call the vaDeriveImage in your test?
>
> BTW: Which platform is used?
>
>

In mpeg2vldemo.c
.....
    if (putsurface) {
        VARectangle src_rect, dst_rect;
        .....
        va_status = va_put_surface(va_dpy, surface_id, &src_rect,
&dst_rect);
        CHECK_VASTATUS(va_status, "vaPutSurface");
    } else {

        VAImage image;
        VAImageFormat fList[10];
        int num_formats = 0;
        va_status= vaQueryImageFormats(va_dpy, fList, &num_formats);
        CHECK_VASTATUS(va_status, "vaQueryImageFormats");
        printf("%d image formats\n", num_formats);
        for (int index = 0; index < num_formats; index++ ) {
            printf("%d - imageFormat: fourcc(%x), byteOrger(%u),
bitsPerPixel(%u), depth(%u)"
                   ", redM(%u), greenM(%u), alphaM(%u)\n",index,
fList[index].fourcc, fList[index].byte_order
                   , fList[index].bits_per_pixel, fList[index].depth,
fList[index].red_mask
                   , fList[index].green_mask, fList[index].alpha_mask);
        }

        char comporder[5];
        memset(comporder, '\0', 5);
        memcpy(comporder, image.component_order, 4);

        printf("imageinfo: w:%u, h:%u, data_size:%u, planes:%u,
palettes:%u, bytes:%d, comp_order%s, fourcc:%x \n"
               ,image.width, image.height, image.data_size,
image.num_planes, image.num_palette_entries
               , image.entry_bytes, comporder, image.format.fourcc);
        for(int i=0; i < 3; i++){
            printf("pitch[%d]=%u, offset[%d]=%u\n", i, image.pitches[i], i,
image.offsets[i]);
        }

        VASurfaceStatus status;

        va_status = vaQuerySurfaceStatus(va_dpy, surface_id, &status);
        CHECK_VASTATUS(va_status, "vaQuerySurfaceStatus");

        printf("surface status: %d\n", status);

        va_status = vaDeriveImage ( va_dpy, surface_id, &image);
        CHECK_VASTATUS(va_status, "vaDeriveImage");

        printf("vaDeriveImage\n");

        char* img = NULL;

        va_status = vaMapBuffer(va_dpy, image.buf, (void**)&img);
        CHECK_VASTATUS(va_status, "vaMapBuffer");

        memset(comporder, '\0', 5);
        memcpy(comporder, image.component_order, 4);

        printf("imageinfo: w:%u, h:%u, data_size:%u, planes:%u,
palettes:%u, bytes:%d, comp_order%s, fourcc:%x \n"
               ,image.width, image.height, image.data_size,
image.num_planes, image.num_palette_entries
               , image.entry_bytes, comporder, image.format.fourcc);
        for(int i=0; i < 3; i++){
            printf("pitch[%d]=%u, offset[%d]=%u\n", i, image.pitches[i], i,
image.offsets[i]);
        }

        int fd = open("/tmp/dump", O_RDWR | O_TRUNC | O_CREAT, S_IRWXU);
        if(fd == -1) {
            printf("error to open file \'/tmp/dump\'\n");
            return -1;
        }

        printf("img:%p, size:%u\n", img, image.data_size);
        ssize_t s = write(fd, img, image.data_size*1.5);
        printf("%d bytes written\n", s);

        va_status = vaUnmapBuffer(va_dpy, image.buf);
        CHECK_VASTATUS(va_status, "vaUnMapBuffer");
}

realy WxH of image is 16x16 but vaDeriveImage return 512x32.

out is:
libva: libva version 0.32.0
libva: va_getDriverName() returns 0
libva: Trying to open /usr/lib/dri/emgd_drv_video.so
Intel(R) Embedded Media and Graphics Driver 1.10 Build 2209
libva: va_openDriver() returns 0
3 image formats
0 - imageFormat: fourcc(41424752), byteOrger(1), bitsPerPixel(32),
depth(32), redM(16711680), greenM(65280), alphaM(4278190080)
1 - imageFormat: fourcc(32595559), byteOrger(1), bitsPerPixel(16),
depth(0), redM(0), greenM(0), alphaM(0)
2 - imageFormat: fourcc(32315659), byteOrger(1), bitsPerPixel(12),
depth(0), redM(0), greenM(0), alphaM(0)
imageinfo: w:14, h:0, data_size:3075098360, planes:3073595636,
palettes:2195, bytes:-1221371576, comp_order┬q╥, fourcc:bfa809f0
pitch[0]=4131212846, offset[0]=0
pitch[1]=3075553328, offset[1]=0
pitch[2]=18, offset[2]=1
surface status: 4
vaDeriveImage
imageinfo: w:512, h:32, data_size:16384, planes:2, palettes:0, bytes:0,
comp_orderYUV, fourcc:3231564e
pitch[0]=512, offset[0]=0
pitch[1]=512, offset[1]=16384
pitch[2]=0, offset[2]=0
img:0xb6bf9000, size:16384
24576 bytes written
press any key to exit

OS: Linux Debian Squeeze
Driver: EMGD 1.10
Xorg: 1.10
What do you whant to know about platform?

-- 
-----------------------------------------
С Уважением, Клочков В.В.
mailto: kwispost at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libva/attachments/20130417/be5e9907/attachment.html>


More information about the Libva mailing list