OSDN Git Service

genX_mfd: remove emulation byte on MB layer boundary
authorcarpalis <jerome.borsboom@carpalis.nl>
Sat, 21 Oct 2017 10:22:19 +0000 (12:22 +0200)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 5 Jan 2018 06:57:31 +0000 (14:57 +0800)
As stated in the PRM, VC-1 decoder hardware cannot handle the case
where the second 0x00 byte in the emulation prevention pattern
0x00 0x00 0x03 (0x00-0x03) coincides with the start of the
MB layer. Fixed by overwriting the 0x03 byte with the previous 0x00
byte and adjusting the MB layer byte offset accordingly.

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 bcc455b..44c9717 100644 (file)
@@ -1705,7 +1705,12 @@ gen6_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
     else {
         for (i = 0, j = 0; i < slice_header_size; i++, j++) {
             if (!buf[j] && !buf[j + 1] && buf[j + 2] == 3 && buf[j + 3] < 4) {
-                i++, j += 2;
+                if (i < slice_header_size - 1)
+                    i++, j += 2;
+                else {
+                    buf[j + 2] = buf[j + 1];
+                    j++;
+                }
             }
         }
 
@@ -1728,7 +1733,7 @@ gen6_mfd_vc1_bsd_object(VADriverContextP ctx,
     int macroblock_offset;
     uint8_t *slice_data = NULL;
 
-    dri_bo_map(slice_data_bo, 0);
+    dri_bo_map(slice_data_bo, True);
     slice_data = (uint8_t *)(slice_data_bo->virtual + slice_param->slice_data_offset);
     macroblock_offset = gen6_mfd_vc1_get_macroblock_bit_offset(slice_data,
                                                                slice_param->macroblock_offset,
index 08855a0..44e5a12 100644 (file)
@@ -2076,7 +2076,12 @@ gen75_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offs
     else {
         for (i = 0, j = 0; i < slice_header_size; i++, j++) {
             if (!buf[j] && !buf[j + 1] && buf[j + 2] == 3 && buf[j + 3] < 4) {
-                i++, j += 2;
+                if (i < slice_header_size - 1)
+                    i++, j += 2;
+                else {
+                    buf[j + 2] = buf[j + 1];
+                    j++;
+                }
             }
         }
 
@@ -2099,7 +2104,7 @@ gen75_mfd_vc1_bsd_object(VADriverContextP ctx,
     int macroblock_offset;
     uint8_t *slice_data = NULL;
 
-    dri_bo_map(slice_data_bo, 0);
+    dri_bo_map(slice_data_bo, True);
     slice_data = (uint8_t *)(slice_data_bo->virtual + slice_param->slice_data_offset);
     macroblock_offset = gen75_mfd_vc1_get_macroblock_bit_offset(slice_data,
                                                                 slice_param->macroblock_offset,
index 1e6911e..1bf6500 100644 (file)
@@ -1761,7 +1761,12 @@ gen7_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
     else {
         for (i = 0, j = 0; i < slice_header_size; i++, j++) {
             if (!buf[j] && !buf[j + 1] && buf[j + 2] == 3 && buf[j + 3] < 4) {
-                i++, j += 2;
+                if (i < slice_header_size - 1)
+                    i++, j += 2;
+                else {
+                    buf[j + 2] = buf[j + 1];
+                    j++;
+                }
             }
         }
 
@@ -1784,7 +1789,7 @@ gen7_mfd_vc1_bsd_object(VADriverContextP ctx,
     int macroblock_offset;
     uint8_t *slice_data = NULL;
 
-    dri_bo_map(slice_data_bo, 0);
+    dri_bo_map(slice_data_bo, True);
     slice_data = (uint8_t *)(slice_data_bo->virtual + slice_param->slice_data_offset);
     macroblock_offset = gen7_mfd_vc1_get_macroblock_bit_offset(slice_data,
                                                                slice_param->macroblock_offset,
index 78719b2..124f72e 100644 (file)
@@ -1813,7 +1813,12 @@ gen8_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
     else {
         for (i = 0, j = 0; i < slice_header_size; i++, j++) {
             if (!buf[j] && !buf[j + 1] && buf[j + 2] == 3 && buf[j + 3] < 4) {
-                i++, j += 2;
+                if (i < slice_header_size - 1)
+                    i++, j += 2;
+                else {
+                    buf[j + 2] = buf[j + 1];
+                    j++;
+                }
             }
         }
 
@@ -1836,7 +1841,7 @@ gen8_mfd_vc1_bsd_object(VADriverContextP ctx,
     int macroblock_offset;
     uint8_t *slice_data = NULL;
 
-    dri_bo_map(slice_data_bo, 0);
+    dri_bo_map(slice_data_bo, True);
     slice_data = (uint8_t *)(slice_data_bo->virtual + slice_param->slice_data_offset);
     macroblock_offset = gen8_mfd_vc1_get_macroblock_bit_offset(slice_data,
                                                                slice_param->macroblock_offset,