Correct the usage of width/height in struct object_surface
authorXiang, Haihao <haihao.xiang@intel.com>
Wed, 13 Nov 2013 05:19:16 +0000 (13:19 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Wed, 13 Nov 2013 07:36:29 +0000 (15:36 +0800)
Add comments for width/height, orig_width/orig_height as well

Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
(cherry picked from commit f886f24eaaacba9544fa5f6405b7382c686f3a1f)

src/i965_drv_video.c
src/i965_drv_video.h
src/i965_post_processing.c

index eec7762..b6522db 100755 (executable)
@@ -2874,12 +2874,13 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
         case VA_FOURCC('Y', 'U', 'Y', '2'):
         case VA_FOURCC('U', 'Y', 'V', 'Y'):
             assert(subsampling == SUBSAMPLE_YUV422H);
-            obj_surface->cb_cr_pitch = obj_surface->width * 2;
+            obj_surface->width = ALIGN(obj_surface->orig_width * 2, 128);
+            obj_surface->cb_cr_pitch = obj_surface->width;
             obj_surface->y_cb_offset = 0; 
             obj_surface->y_cr_offset = 0; 
             obj_surface->cb_cr_width = obj_surface->orig_width / 2;
             obj_surface->cb_cr_height = obj_surface->orig_height / 2;
-            region_width = obj_surface->width * 2;
+            region_width = obj_surface->width;
             region_height = obj_surface->height;
             
             break;
@@ -2890,7 +2891,8 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
         case VA_FOURCC('B', 'G', 'R', 'X'):
             assert(subsampling == SUBSAMPLE_RGBX);
 
-            region_width = obj_surface->width * 4;
+            obj_surface->width = ALIGN(obj_surface->orig_width * 4, 128);
+            region_width = obj_surface->width;
             region_height = obj_surface->height;
             break;
 
@@ -2936,19 +2938,21 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
 
         case VA_FOURCC('Y', 'U', 'Y', '2'):
         case VA_FOURCC('U', 'Y', 'V', 'Y'):
+            obj_surface->width = ALIGN(obj_surface->orig_width * 2, 16);
             obj_surface->y_cb_offset = 0;
             obj_surface->y_cr_offset = 0;
             obj_surface->cb_cr_width = obj_surface->orig_width / 2;
             obj_surface->cb_cr_height = obj_surface->orig_height;
-            obj_surface->cb_cr_pitch = obj_surface->width * 2;
-            region_width = obj_surface->width * 2;
+            obj_surface->cb_cr_pitch = obj_surface->width;
+            region_width = obj_surface->width;
             region_height = obj_surface->height;
             break;
         case VA_FOURCC('R', 'G', 'B', 'A'):
         case VA_FOURCC('R', 'G', 'B', 'X'):
         case VA_FOURCC('B', 'G', 'R', 'A'):
         case VA_FOURCC('B', 'G', 'R', 'X'):
-            region_width = obj_surface->width * 4;
+            obj_surface->width = ALIGN(obj_surface->orig_width * 4, 16);
+            region_width = obj_surface->width;
             region_height = obj_surface->height;
             break;
 
@@ -2974,9 +2978,7 @@ i965_check_alloc_surface_bo(VADriverContextP ctx,
                                                    &pitch,
                                                    0);
         assert(tiling_mode == I915_TILING_Y);
-        assert(pitch == obj_surface->width     || 
-               pitch == obj_surface->width * 2 ||
-               pitch == obj_surface->width * 4) ;
+        assert(pitch == obj_surface->width);
     } else {
         obj_surface->bo = dri_bo_alloc(i965->intel.bufmgr,
                                        "vaapi surface",
@@ -3078,7 +3080,7 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
     case VA_FOURCC('Y', 'U', 'Y', '2'):
     case VA_FOURCC('U', 'Y', 'V', 'Y'):
         image->num_planes = 1;
-        image->pitches[0] = obj_surface->width * 2; /* Y, width is aligned already */
+        image->pitches[0] = obj_surface->width; /* Y, width is aligned already */
         image->offsets[0] = 0;
         break;
     case VA_FOURCC('R', 'G', 'B', 'A'):
@@ -3086,7 +3088,7 @@ VAStatus i965_DeriveImage(VADriverContextP ctx,
     case VA_FOURCC('B', 'G', 'R', 'A'):
     case VA_FOURCC('B', 'G', 'R', 'X'):
         image->num_planes = 1;
-        image->pitches[0] = obj_surface->width * 4;
+        image->pitches[0] = obj_surface->width;
         break;
     default:
         goto error;
index 3b06ac0..f51f39f 100644 (file)
@@ -207,11 +207,11 @@ struct object_surface
     struct object_subpic *obj_subpic[I965_MAX_SUBPIC_SUM];
     unsigned int subpic_render_idx;
 
-    int width;
-    int height;
+    int width;          /* the pitch of plane 0 in bytes in horizontal direction */
+    int height;         /* the pitch of plane 0 in bytes in vertical direction */
     int size;
-    int orig_width;
-    int orig_height;
+    int orig_width;     /* the width of plane 0 in pixels */
+    int orig_height;    /* the height of plane 0 in pixels */
     int flags;
     unsigned int fourcc;    
     dri_bo *bo;
index d5847ea..eeff289 100755 (executable)
@@ -1738,11 +1738,9 @@ pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_processin
 
         if (full_packed_format) {
             scale_factor_of_1st_plane_width_in_byte = 4; 
-            pitch[0] = obj_surface->width * 4;
         }
         else if (packed_yuv ) {
             scale_factor_of_1st_plane_width_in_byte =  2; 
-            pitch[0] = obj_surface->width * 2;
         }
         else if (interleaved_uv) {
             width[1] = obj_surface->orig_width;
@@ -1853,12 +1851,9 @@ gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_proc
                 width[0] = obj_surface->orig_width * 2; /* surface format is R8, so double the width */
             else
                 width[0] = obj_surface->orig_width;     /* surface foramt is YCBCR, width is specified in units of pixels */
-
-            pitch[0] = obj_surface->width * 2;
         } else if (rgbx_format) {
            if (is_target)
                 width[0] = obj_surface->orig_width * 4; /* surface format is R8, so quad the width */
-            pitch[0] = obj_surface->width * 4;
        }
 
         width[1] = obj_surface->cb_cr_width;