summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Isorce <julien.isorce@gmail.com>2015-10-13 09:10:46 +0100
committerXiang, Haihao <haihao.xiang@intel.com>2015-10-14 13:57:35 +0800
commit4640d06a8ccb0a12e91bbd00cc3e2423d17ee243 (patch)
tree7eeba6be3288995de9bcd5fbe0dc7eddda76b527
parent4977b0d9df37bec130931f039be4ac434a6ba0be (diff)
vaDeriveImage: properly set VAImage format
This is required to allow gstvaapipostproc outputing RGBx va surfaces. https://bugs.freedesktop.org/show_bug.cgi?id=92088 Signed-off-by: Julien Isorce <j.isorce@samsung.com>
-rw-r--r--src/i965_drv_video.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index f16fb57..54c7030 100644
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -227,6 +227,22 @@ get_fourcc_info(unsigned int fourcc)
return NULL;
}
+static int
+get_bpp_from_fourcc(unsigned int fourcc)
+{
+ const i965_fourcc_info *info = get_fourcc_info(fourcc);
+ unsigned int i = 0;
+ unsigned int bpp = 0;
+
+ if (!info)
+ return 0;
+
+ for (i = 0; i < info->num_planes; i++)
+ bpp += info->bpp[i];
+
+ return bpp;
+}
+
enum {
I965_SURFACETYPE_RGBA = 1,
I965_SURFACETYPE_YUV,
@@ -4060,7 +4076,10 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
image->format.fourcc = obj_surface->fourcc;
image->format.byte_order = VA_LSB_FIRST;
- image->format.bits_per_pixel = 12;
+ image->format.bits_per_pixel = get_bpp_from_fourcc(obj_surface->fourcc);
+
+ if (!image->format.bits_per_pixel)
+ goto error;
switch (image->format.fourcc) {
case VA_FOURCC_YV12:
@@ -4119,6 +4138,39 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
case VA_FOURCC_BGRX:
image->num_planes = 1;
image->pitches[0] = obj_surface->width;
+
+ switch (image->format.fourcc) {
+ case VA_FOURCC_RGBA:
+ case VA_FOURCC_RGBX:
+ image->format.red_mask = 0x000000ff;
+ image->format.green_mask = 0x0000ff00;
+ image->format.blue_mask = 0x00ff0000;
+ image->format.alpha_mask = 0x00000000;
+ break;
+ case VA_FOURCC_BGRA:
+ case VA_FOURCC_BGRX:
+ image->format.red_mask = 0x00ff0000;
+ image->format.green_mask = 0x0000ff00;
+ image->format.blue_mask = 0x000000ff;
+ image->format.alpha_mask = 0x00000000;
+ break;
+ default:
+ goto error;
+ }
+
+ switch (image->format.fourcc) {
+ case VA_FOURCC_RGBA:
+ case VA_FOURCC_BGRA:
+ image->format.depth = 32;
+ break;
+ case VA_FOURCC_RGBX:
+ case VA_FOURCC_BGRX:
+ image->format.depth = 24;
+ break;
+ default:
+ goto error;
+ }
+
break;
default:
goto error;