Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
specify tiling mode, stride and pixel-format by VASurfaceAttrib
Browse files Browse the repository at this point in the history
Change-Id: I8755874d44ef28bcfad9cbde80e57262cff8607a
  • Loading branch information
Zhao, Halley authored and seanvk committed Mar 14, 2014
1 parent 602e307 commit 2356b85
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions src/wrapper_drv_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#define ALIGN(i, n) (((i) + (n) - 1) & ~((n) - 1))

#define DRIVER_EXTENSION "_drv_video.so"

Expand Down Expand Up @@ -326,14 +327,56 @@ vawr_CreateSurfaces(VADriverContextP ctx,
{
VAStatus vaStatus;
struct vawr_driver_data *vawr = GET_VAWRDATA(ctx);
unsigned int h_stride = 0, v_stride = 0;

/* We will always call i965's vaCreateSurfaces for VA Surface allocation,
* then if the config profile is VP8 we will map the surface into TTM
*/
ctx->pDriverData = vawr->drv_data[0];
vaStatus = vawr->drv_vtable[0]->vaCreateSurfaces(ctx, width, height, format, num_surfaces, surfaces);
RESTORE_VAWRDATA(ctx, vawr);

// XXX, assume we have already got correct profile (vaCreateConfig is called before vaCreateSurface)
if (vawr->profile == VAProfileVP8Version0_3) {
VASurfaceAttrib surface_attrib[2];
VASurfaceAttribExternalBuffers buffer_attrib;
int i=0;

surface_attrib[i].type = VASurfaceAttribMemoryType;
surface_attrib[i].flags = VA_SURFACE_ATTRIB_SETTABLE;
surface_attrib[i].value.type = VAGenericValueTypeInteger;
surface_attrib[i].value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA;
i++;

/* Calculate stride to meet psb requirement */
if (512 >= width)
h_stride = 512;
else if (1024 >= width)
h_stride = 1024;
else if (1280 >= width)
h_stride = 1280;
else if (2048 >= width)
h_stride = 2048;
else if (4096 >= width)
h_stride = 4096;
else
assert(0);
v_stride = ALIGN(height, 32);
buffer_attrib.width = h_stride;
buffer_attrib.height= v_stride;
buffer_attrib.flags = 0; // tiling is diabled by default
buffer_attrib.pixel_format = VA_FOURCC_NV12;

surface_attrib[i].type = VASurfaceAttribExternalBufferDescriptor;
surface_attrib[i].flags = VA_SURFACE_ATTRIB_SETTABLE;
surface_attrib[i].value.type = VAGenericValueTypePointer;
surface_attrib[i].value.value.p = &buffer_attrib;
i++;

vaStatus = vawr->drv_vtable[0]->vaCreateSurfaces2(ctx, format, width, height, surfaces, num_surfaces, &surface_attrib[0], i);
} else {
vaStatus = vawr->drv_vtable[0]->vaCreateSurfaces(ctx, width, height, format, num_surfaces, surfaces);
}

RESTORE_VAWRDATA(ctx, vawr);
return vaStatus;
}

Expand Down

0 comments on commit 2356b85

Please sign in to comment.