OSDN Git Service

genX_mfd: fix dmv buffer size calculation
authorcarpalis <jerome.borsboom@carpalis.nl>
Tue, 31 Oct 2017 14:22:14 +0000 (15:22 +0100)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 5 Jan 2018 06:57:31 +0000 (14:57 +0800)
The picture size may vary within a VC-1 stream. We should calculate
the dmv buffer size from the size of the surface instead of the
size of the first picture that uses the surface. Subsequent pictures
may be larger, which could overflow the dmv buffer.

Signed-off-by: Jerome Borsboom <jerome.borsboom@carpalis.nl>
src/gen6_mfd.c
src/gen75_mfd.c
src/gen7_mfd.c
src/gen8_mfd.c

index 43f0efd..4b94d7f 100644 (file)
@@ -1170,7 +1170,7 @@ gen6_mfd_init_vc1_surface(VADriverContextP ctx,
 {
     struct i965_driver_data *i965 = i965_driver_data(ctx);
     struct gen6_vc1_surface *gen6_vc1_surface = obj_surface->private_data;
-    int height_in_mbs = ALIGN(pic_param->coded_height, 16) / 16;
+    int height_in_mbs = ALIGN(obj_surface->orig_height, 16) / 16;
 
     obj_surface->free_private_data = gen6_mfd_free_vc1_surface;
 
index 4d6b1d3..d776d4a 100644 (file)
@@ -1557,7 +1557,7 @@ gen75_mfd_init_vc1_surface(VADriverContextP ctx,
         gen7_vc1_surface->picture_type_top = picture_type;
 
     if (gen7_vc1_surface->dmv_top == NULL) {
-        height_in_mbs = ALIGN(pic_param->coded_height, 16) / 16;
+        height_in_mbs = ALIGN(obj_surface->orig_height, 16) / 16;
         gen7_vc1_surface->dmv_top = dri_bo_alloc(i965->intel.bufmgr,
                                              "direct mv w/r buffer",
                                              128 * height_in_mbs * 64,
@@ -1566,7 +1566,7 @@ gen75_mfd_init_vc1_surface(VADriverContextP ctx,
 
     if (pic_param->sequence_fields.bits.interlace &&
         gen7_vc1_surface->dmv_bottom == NULL) {
-        height_in_mbs = ALIGN(pic_param->coded_height, 32) / 32;
+        height_in_mbs = ALIGN(obj_surface->orig_height, 32) / 32;
         gen7_vc1_surface->dmv_bottom = dri_bo_alloc(i965->intel.bufmgr,
                                              "direct mv w/r buffer",
                                              128 * height_in_mbs * 64,
index 9d3e208..61ad9ee 100644 (file)
@@ -1292,7 +1292,7 @@ gen7_mfd_init_vc1_surface(VADriverContextP ctx,
         gen7_vc1_surface->picture_type_top = picture_type;
 
     if (gen7_vc1_surface->dmv_top == NULL) {
-        height_in_mbs = ALIGN(pic_param->coded_height, 16) / 16;
+        height_in_mbs = ALIGN(obj_surface->orig_height, 16) / 16;
         gen7_vc1_surface->dmv_top = dri_bo_alloc(i965->intel.bufmgr,
                                              "direct mv w/r buffer",
                                              128 * height_in_mbs * 64,
@@ -1301,7 +1301,7 @@ gen7_mfd_init_vc1_surface(VADriverContextP ctx,
 
     if (pic_param->sequence_fields.bits.interlace &&
         gen7_vc1_surface->dmv_bottom == NULL) {
-        height_in_mbs = ALIGN(pic_param->coded_height, 32) / 32;
+        height_in_mbs = ALIGN(obj_surface->orig_height, 32) / 32;
         gen7_vc1_surface->dmv_bottom = dri_bo_alloc(i965->intel.bufmgr,
                                              "direct mv w/r buffer",
                                              128 * height_in_mbs * 64,
index a0a6e59..43331ce 100644 (file)
@@ -1336,7 +1336,7 @@ gen8_mfd_init_vc1_surface(VADriverContextP ctx,
         gen7_vc1_surface->picture_type_top = picture_type;
 
     if (gen7_vc1_surface->dmv_top == NULL) {
-        height_in_mbs = ALIGN(pic_param->coded_height, 16) / 16;
+        height_in_mbs = ALIGN(obj_surface->orig_height, 16) / 16;
         gen7_vc1_surface->dmv_top = dri_bo_alloc(i965->intel.bufmgr,
                                              "direct mv w/r buffer",
                                              128 * height_in_mbs * 64,
@@ -1345,7 +1345,7 @@ gen8_mfd_init_vc1_surface(VADriverContextP ctx,
 
     if (pic_param->sequence_fields.bits.interlace &&
         gen7_vc1_surface->dmv_bottom == NULL) {
-        height_in_mbs = ALIGN(pic_param->coded_height, 32) / 32;
+        height_in_mbs = ALIGN(obj_surface->orig_height, 32) / 32;
         gen7_vc1_surface->dmv_bottom = dri_bo_alloc(i965->intel.bufmgr,
                                              "direct mv w/r buffer",
                                              128 * height_in_mbs * 64,