From 3188189cd29f5f3f0c5ba37ba29e5afb39b591ea Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Tue, 7 Jul 2015 01:45:47 +0800 Subject: [PATCH] H264: Use macroblock pair to calculate H264 decoding parameter under MBAFF flag Based on the H264 spec the macroblock pair should be used to calculate the corresponding parameters under MBAFF.(mb-adaptive frame-field). Otherwise the wrong parameter is sent to GPU HW. Fix the GPU hang issue in https://bugs.freedesktop.org/show_bug.cgi?id=91207 Signed-off-by: Zhao Yakui --- src/gen6_mfd.c | 10 ++++++++-- src/gen75_mfd.c | 10 ++++++++-- src/gen7_mfd.c | 10 ++++++++-- src/gen8_mfd.c | 9 +++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/gen6_mfd.c b/src/gen6_mfd.c index 95a8e92..2dd05a1 100755 --- a/src/gen6_mfd.c +++ b/src/gen6_mfd.c @@ -551,14 +551,20 @@ gen6_mfd_avc_slice_state(VADriverContextP ctx, } } - first_mb_in_slice = slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_slice = slice_param->first_mb_in_slice; slice_hor_pos = first_mb_in_slice % width_in_mbs; slice_ver_pos = first_mb_in_slice / width_in_mbs; + if (mbaff_picture) + slice_ver_pos = slice_ver_pos << 1; + if (next_slice_param) { - first_mb_in_next_slice = next_slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_next_slice = next_slice_param->first_mb_in_slice; next_slice_hor_pos = first_mb_in_next_slice % width_in_mbs; next_slice_ver_pos = first_mb_in_next_slice / width_in_mbs; + + if (mbaff_picture) + next_slice_ver_pos = next_slice_ver_pos << 1; } else { next_slice_hor_pos = 0; next_slice_ver_pos = height_in_mbs; diff --git a/src/gen75_mfd.c b/src/gen75_mfd.c index 5171bd9..11cde1f 100644 --- a/src/gen75_mfd.c +++ b/src/gen75_mfd.c @@ -862,14 +862,20 @@ gen75_mfd_avc_slice_state(VADriverContextP ctx, num_ref_idx_l1 = slice_param->num_ref_idx_l1_active_minus1 + 1; } - first_mb_in_slice = slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_slice = slice_param->first_mb_in_slice; slice_hor_pos = first_mb_in_slice % width_in_mbs; slice_ver_pos = first_mb_in_slice / width_in_mbs; + if (mbaff_picture) + slice_ver_pos = slice_ver_pos << 1; + if (next_slice_param) { - first_mb_in_next_slice = next_slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_next_slice = next_slice_param->first_mb_in_slice; next_slice_hor_pos = first_mb_in_next_slice % width_in_mbs; next_slice_ver_pos = first_mb_in_next_slice / width_in_mbs; + + if (mbaff_picture) + next_slice_ver_pos = next_slice_ver_pos << 1; } else { next_slice_hor_pos = 0; next_slice_ver_pos = height_in_mbs / (1 + !!pic_param->pic_fields.bits.field_pic_flag); diff --git a/src/gen7_mfd.c b/src/gen7_mfd.c index 40a6db4..1d04ed4 100755 --- a/src/gen7_mfd.c +++ b/src/gen7_mfd.c @@ -556,14 +556,20 @@ gen7_mfd_avc_slice_state(VADriverContextP ctx, num_ref_idx_l1 = slice_param->num_ref_idx_l1_active_minus1 + 1; } - first_mb_in_slice = slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_slice = slice_param->first_mb_in_slice; slice_hor_pos = first_mb_in_slice % width_in_mbs; slice_ver_pos = first_mb_in_slice / width_in_mbs; + if (mbaff_picture) + slice_ver_pos = slice_ver_pos << 1; + if (next_slice_param) { - first_mb_in_next_slice = next_slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_next_slice = next_slice_param->first_mb_in_slice; next_slice_hor_pos = first_mb_in_next_slice % width_in_mbs; next_slice_ver_pos = first_mb_in_next_slice / width_in_mbs; + + if (mbaff_picture) + next_slice_ver_pos = next_slice_ver_pos << 1; } else { next_slice_hor_pos = 0; next_slice_ver_pos = height_in_mbs / (1 + !!pic_param->pic_fields.bits.field_pic_flag); diff --git a/src/gen8_mfd.c b/src/gen8_mfd.c index c15184d..c55cb4e 100644 --- a/src/gen8_mfd.c +++ b/src/gen8_mfd.c @@ -625,14 +625,19 @@ gen8_mfd_avc_slice_state(VADriverContextP ctx, num_ref_idx_l1 = slice_param->num_ref_idx_l1_active_minus1 + 1; } - first_mb_in_slice = slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_slice = slice_param->first_mb_in_slice; slice_hor_pos = first_mb_in_slice % width_in_mbs; slice_ver_pos = first_mb_in_slice / width_in_mbs; + if (mbaff_picture) + slice_ver_pos = slice_ver_pos << 1; if (next_slice_param) { - first_mb_in_next_slice = next_slice_param->first_mb_in_slice << mbaff_picture; + first_mb_in_next_slice = next_slice_param->first_mb_in_slice; next_slice_hor_pos = first_mb_in_next_slice % width_in_mbs; next_slice_ver_pos = first_mb_in_next_slice / width_in_mbs; + + if (mbaff_picture) + next_slice_ver_pos = next_slice_ver_pos << 1; } else { next_slice_hor_pos = 0; next_slice_ver_pos = height_in_mbs / (1 + !!pic_param->pic_fields.bits.field_pic_flag); -- 1.7.10.1