OSDN Git Service

genX_mfd: clean up the use of profile bitstream element
authorcarpalis <jerome.borsboom@carpalis.nl>
Wed, 1 Nov 2017 18:45:42 +0000 (19:45 +0100)
committerXiang, Haihao <haihao.xiang@intel.com>
Fri, 5 Jan 2018 06:57:31 +0000 (14:57 +0800)
Only gen6 needs mapping from input range to the hardware range for
the profile bitstream element. For gen7 and up there is no need for a
mapping as the hardware uses only one bit indicating simple/main profile
or advanced profile. Therefore, we can remove the mapping for gen7 and
clean up the code a bit.

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

index 4b94d7f..2066612 100644 (file)
@@ -1373,7 +1373,6 @@ gen6_mfd_vc1_pic_state(VADriverContextP ctx,
     int fcm = 0;
     int picture_type;
     int ptype;
-    int profile;
     int overlap = 0;
     int loopfilter = 0;
     int bitplane_present;
@@ -1385,7 +1384,6 @@ gen6_mfd_vc1_pic_state(VADriverContextP ctx,
 
     picture_type = pic_param->picture_fields.bits.picture_type;
 
-    profile = va_to_gen6_vc1_profile[pic_param->sequence_fields.bits.profile];
     dquant = pic_param->pic_quantizer_fields.bits.dquant;
     dquantfrm = pic_param->pic_quantizer_fields.bits.dq_frame;
     dqprofile = pic_param->pic_quantizer_fields.bits.dq_profile;
@@ -1528,7 +1526,7 @@ gen6_mfd_vc1_pic_state(VADriverContextP ctx,
     }
 
     if (pic_param->sequence_fields.bits.overlap) {
-        if (profile == GEN6_VC1_ADVANCED_PROFILE) {
+        if (pic_param->sequence_fields.bits.profile == 3) { /* Advanced Profile */
             if (picture_type == GEN6_VC1_P_PICTURE &&
                 pic_param->pic_quantizer_fields.bits.pic_quantizer_scale >= 9) {
                 overlap = 1;
@@ -1732,9 +1730,7 @@ gen6_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
     int slice_header_size = in_slice_data_bit_offset / 8;
     int i, j;
 
-    if (profile != 3)
-        out_slice_data_bit_offset = in_slice_data_bit_offset;
-    else {
+    if (profile == 3) { /* Advanced Profile */
         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) {
                 if (i < slice_header_size - 1)
@@ -1747,7 +1743,8 @@ gen6_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
         }
 
         out_slice_data_bit_offset = 8 * j + in_slice_data_bit_offset % 8;
-    }
+    } else /* Simple or Main Profile */
+        out_slice_data_bit_offset = in_slice_data_bit_offset;
 
     return out_slice_data_bit_offset;
 }
index 640e45c..18e612a 100644 (file)
@@ -1470,13 +1470,6 @@ static const int va_to_gen7_vc1_condover[3] = {
     3
 };
 
-static const int va_to_gen7_vc1_profile[4] = {
-    GEN7_VC1_SIMPLE_PROFILE,
-    GEN7_VC1_MAIN_PROFILE,
-    GEN7_VC1_RESERVED_PROFILE,
-    GEN7_VC1_ADVANCED_PROFILE
-};
-
 static const int fptype_to_picture_type[8][2] = {
     {GEN7_VC1_I_PICTURE, GEN7_VC1_I_PICTURE},
     {GEN7_VC1_I_PICTURE, GEN7_VC1_P_PICTURE},
@@ -1879,7 +1872,6 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
     int fcm = 0;
     int picture_type;
     int ptype;
-    int profile;
     int overlap = 0;
     int interpolation_mode = 0;
     int height_in_mbs;
@@ -1904,7 +1896,6 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
         height_in_mbs = ALIGN(pic_param->coded_height, 32) / 32;
     }
 
-    profile = va_to_gen7_vc1_profile[pic_param->sequence_fields.bits.profile];
     dquant = pic_param->pic_quantizer_fields.bits.dquant;
     dquantfrm = pic_param->pic_quantizer_fields.bits.dq_frame;
     dqprofile = pic_param->pic_quantizer_fields.bits.dq_profile;
@@ -1963,7 +1954,7 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
         }
     }
 
-    if (profile == GEN7_VC1_MAIN_PROFILE &&
+    if (pic_param->sequence_fields.bits.profile == 1 && /* Main Profile */
         pic_param->sequence_fields.bits.rangered) {
         obj_surface = decode_state->reference_objects[0];
 
@@ -2119,7 +2110,7 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
     }
 
     if (pic_param->sequence_fields.bits.overlap) {
-        if (profile == GEN7_VC1_ADVANCED_PROFILE) {
+        if (pic_param->sequence_fields.bits.profile == 3) { /* Advanced Profile */
             if (picture_type == GEN7_VC1_P_PICTURE &&
                 pic_param->pic_quantizer_fields.bits.pic_quantizer_scale >= 9) {
                 overlap = 1;
@@ -2165,7 +2156,7 @@ gen75_mfd_vc1_pic_state(VADriverContextP ctx,
                   loopfilter << 5 |
                   overlap << 4 |
                   !is_first_field << 3 |
-                  (pic_param->sequence_fields.bits.profile == 3) << 0);
+                  (pic_param->sequence_fields.bits.profile == 3) << 0); /* Advanced Profile */
     OUT_BCS_BATCH(batch,
                   va_to_gen7_vc1_condover[pic_param->conditional_overlap_flag] << 29 |
                   ptype << 26 |
@@ -2509,9 +2500,7 @@ gen75_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offs
     int slice_header_size = in_slice_data_bit_offset / 8;
     int i, j;
 
-    if (profile != 3)
-        out_slice_data_bit_offset = in_slice_data_bit_offset;
-    else {
+    if (profile == 3) { /* Advanced Profile */
         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) {
                 if (i < slice_header_size - 1)
@@ -2524,7 +2513,8 @@ gen75_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offs
         }
 
         out_slice_data_bit_offset = 8 * j + in_slice_data_bit_offset % 8;
-    }
+    } else /* Simple or Main Profile */
+        out_slice_data_bit_offset = in_slice_data_bit_offset;
 
     return out_slice_data_bit_offset;
 }
index 0928db3..eceefaf 100644 (file)
@@ -1205,13 +1205,6 @@ static const int va_to_gen7_vc1_condover[3] = {
     3
 };
 
-static const int va_to_gen7_vc1_profile[4] = {
-    GEN7_VC1_SIMPLE_PROFILE,
-    GEN7_VC1_MAIN_PROFILE,
-    GEN7_VC1_RESERVED_PROFILE,
-    GEN7_VC1_ADVANCED_PROFILE
-};
-
 static const int fptype_to_picture_type[8][2] = {
     {GEN7_VC1_I_PICTURE, GEN7_VC1_I_PICTURE},
     {GEN7_VC1_I_PICTURE, GEN7_VC1_P_PICTURE},
@@ -1614,7 +1607,6 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
     int fcm = 0;
     int picture_type;
     int ptype;
-    int profile;
     int overlap = 0;
     int interpolation_mode = 0;
     int height_in_mbs;
@@ -1639,7 +1631,6 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
         height_in_mbs = ALIGN(pic_param->coded_height, 32) / 32;
     }
 
-    profile = va_to_gen7_vc1_profile[pic_param->sequence_fields.bits.profile];
     dquant = pic_param->pic_quantizer_fields.bits.dquant;
     dquantfrm = pic_param->pic_quantizer_fields.bits.dq_frame;
     dqprofile = pic_param->pic_quantizer_fields.bits.dq_profile;
@@ -1698,7 +1689,7 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
         }
     }
 
-    if (profile == GEN7_VC1_MAIN_PROFILE &&
+    if (pic_param->sequence_fields.bits.profile == 1 && /* Main Profile */
         pic_param->sequence_fields.bits.rangered) {
         obj_surface = decode_state->reference_objects[0];
 
@@ -1853,7 +1844,7 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
     }
 
     if (pic_param->sequence_fields.bits.overlap) {
-        if (profile == GEN7_VC1_ADVANCED_PROFILE) {
+        if (pic_param->sequence_fields.bits.profile == 3) { /* Advanced Profile */
             if (picture_type == GEN7_VC1_P_PICTURE &&
                 pic_param->pic_quantizer_fields.bits.pic_quantizer_scale >= 9) {
                 overlap = 1;
@@ -1899,7 +1890,7 @@ gen7_mfd_vc1_pic_state(VADriverContextP ctx,
                   loopfilter << 5 |
                   overlap << 4 |
                   !is_first_field << 3 |
-                  (pic_param->sequence_fields.bits.profile == 3) << 0);
+                  (pic_param->sequence_fields.bits.profile == 3) << 0); /* Advanced Profile */
     OUT_BCS_BATCH(batch,
                   va_to_gen7_vc1_condover[pic_param->conditional_overlap_flag] << 29 |
                   ptype << 26 |
@@ -2164,9 +2155,7 @@ gen7_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
     int slice_header_size = in_slice_data_bit_offset / 8;
     int i, j;
 
-    if (profile != 3)
-        out_slice_data_bit_offset = in_slice_data_bit_offset;
-    else {
+    if (profile == 3) { /* Advanced Profile */
         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) {
                 if (i < slice_header_size - 1)
@@ -2179,7 +2168,8 @@ gen7_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
         }
 
         out_slice_data_bit_offset = 8 * j + in_slice_data_bit_offset % 8;
-    }
+    } else /* Simple or Main Profile */
+        out_slice_data_bit_offset = in_slice_data_bit_offset;
 
     return out_slice_data_bit_offset;
 }
index 37a5d03..37c2b3d 100644 (file)
 #define GEN7_VC1_BI_PICTURE             3
 #define GEN7_VC1_SKIPPED_PICTURE        4
 
-#define GEN7_VC1_SIMPLE_PROFILE         0
-#define GEN7_VC1_MAIN_PROFILE           1
-#define GEN7_VC1_ADVANCED_PROFILE       2
-#define GEN7_VC1_RESERVED_PROFILE       3
-
 #define GEN7_JPEG_ROTATION_0            0
 #define GEN7_JPEG_ROTATION_90           1
 #define GEN7_JPEG_ROTATION_270          2
index 6d4efba..12af5db 100644 (file)
@@ -1246,13 +1246,6 @@ static const int va_to_gen7_vc1_condover[3] = {
     3
 };
 
-static const int va_to_gen7_vc1_profile[4] = {
-    GEN7_VC1_SIMPLE_PROFILE,
-    GEN7_VC1_MAIN_PROFILE,
-    GEN7_VC1_RESERVED_PROFILE,
-    GEN7_VC1_ADVANCED_PROFILE
-};
-
 static const int fptype_to_picture_type[8][2] = {
     {GEN7_VC1_I_PICTURE, GEN7_VC1_I_PICTURE},
     {GEN7_VC1_I_PICTURE, GEN7_VC1_P_PICTURE},
@@ -1658,7 +1651,6 @@ gen8_mfd_vc1_pic_state(VADriverContextP ctx,
     int fcm = 0;
     int picture_type;
     int ptype;
-    int profile;
     int overlap = 0;
     int interpolation_mode = 0;
     int height_in_mbs;
@@ -1683,7 +1675,6 @@ gen8_mfd_vc1_pic_state(VADriverContextP ctx,
         height_in_mbs = ALIGN(pic_param->coded_height, 32) / 32;
     }
 
-    profile = va_to_gen7_vc1_profile[pic_param->sequence_fields.bits.profile];
     dquant = pic_param->pic_quantizer_fields.bits.dquant;
     dquantfrm = pic_param->pic_quantizer_fields.bits.dq_frame;
     dqprofile = pic_param->pic_quantizer_fields.bits.dq_profile;
@@ -1742,7 +1733,7 @@ gen8_mfd_vc1_pic_state(VADriverContextP ctx,
         }
     }
 
-    if (profile == GEN7_VC1_MAIN_PROFILE &&
+    if (pic_param->sequence_fields.bits.profile == 1 && /* Main Profile */
         pic_param->sequence_fields.bits.rangered) {
         obj_surface = decode_state->reference_objects[0];
 
@@ -1898,7 +1889,7 @@ gen8_mfd_vc1_pic_state(VADriverContextP ctx,
     }
 
     if (pic_param->sequence_fields.bits.overlap) {
-        if (profile == GEN7_VC1_ADVANCED_PROFILE) {
+        if (pic_param->sequence_fields.bits.profile == 3) { /* Advanced Profile */
             if (picture_type == GEN7_VC1_P_PICTURE &&
                 pic_param->pic_quantizer_fields.bits.pic_quantizer_scale >= 9) {
                 overlap = 1;
@@ -1944,7 +1935,7 @@ gen8_mfd_vc1_pic_state(VADriverContextP ctx,
                   loopfilter << 5 |
                   overlap << 4 |
                   !is_first_field << 3 |
-                  (pic_param->sequence_fields.bits.profile == 3) << 0);
+                  (pic_param->sequence_fields.bits.profile == 3) << 0); /* Advanced Profile */
     OUT_BCS_BATCH(batch,
                   va_to_gen7_vc1_condover[pic_param->conditional_overlap_flag] << 29 |
                   ptype << 26 |
@@ -2217,9 +2208,7 @@ gen8_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
     int slice_header_size = in_slice_data_bit_offset / 8;
     int i, j;
 
-    if (profile != 3)
-        out_slice_data_bit_offset = in_slice_data_bit_offset;
-    else {
+    if (profile == 3) { /* Advanced Profile */
         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) {
                 if (i < slice_header_size - 1)
@@ -2232,7 +2221,8 @@ gen8_mfd_vc1_get_macroblock_bit_offset(uint8_t *buf, int in_slice_data_bit_offse
         }
 
         out_slice_data_bit_offset = 8 * j + in_slice_data_bit_offset % 8;
-    }
+    } else /* Simple or Main Profile */
+        out_slice_data_bit_offset = in_slice_data_bit_offset;
 
     return out_slice_data_bit_offset;
 }