[Libva] [Libva-intel-driver][PATCH 1/5] svct: Usa an array to store QP rounding accumulator

Xiang, Haihao haihao.xiang at intel.com
Mon Oct 24 04:49:38 UTC 2016


We can do QP compensation per layer.

Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/gen6_mfc.h        |  2 +-
 src/gen6_mfc_common.c | 10 +++++-----
 src/gen8_mfc.c        | 10 +++++-----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/gen6_mfc.h b/src/gen6_mfc.h
index 02591a3..e0972bb 100644
--- a/src/gen6_mfc.h
+++ b/src/gen6_mfc.h
@@ -232,7 +232,7 @@ struct gen6_mfc_context
         int target_frame_size[MAX_TEMPORAL_LAYERS][3]; // I,P,B
         int qp_prime_y[MAX_TEMPORAL_LAYERS][3];
         double bits_per_frame[MAX_TEMPORAL_LAYERS];
-        double qpf_rounding_accumulator;
+        double qpf_rounding_accumulator[MAX_TEMPORAL_LAYERS];
 
         double saved_bps;
         double saved_fps;
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
index 33226a5..fbce493 100644
--- a/src/gen6_mfc_common.c
+++ b/src/gen6_mfc_common.c
@@ -254,13 +254,13 @@ int intel_mfc_brc_postpack(struct encode_state *encode_state,
 
     if (qpn == qp) {
         /* setting qpn we round qpf making mistakes: now we are trying to compensate this */
-        mfc_context->brc.qpf_rounding_accumulator += qpf - qpn;
-        if (mfc_context->brc.qpf_rounding_accumulator > 1.0) {
+        mfc_context->brc.qpf_rounding_accumulator[next_frame_layer_id] += qpf - qpn;
+        if (mfc_context->brc.qpf_rounding_accumulator[next_frame_layer_id] > 1.0) {
             qpn++;
-            mfc_context->brc.qpf_rounding_accumulator = 0.;
-        } else if (mfc_context->brc.qpf_rounding_accumulator < -1.0) {
+            mfc_context->brc.qpf_rounding_accumulator[next_frame_layer_id] = 0.;
+        } else if (mfc_context->brc.qpf_rounding_accumulator[next_frame_layer_id] < -1.0) {
             qpn--;
-            mfc_context->brc.qpf_rounding_accumulator = 0.;
+            mfc_context->brc.qpf_rounding_accumulator[next_frame_layer_id] = 0.;
         }
     }
     /* making sure that QP is not changing too fast */
diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c
index e4506b6..6576950 100644
--- a/src/gen8_mfc.c
+++ b/src/gen8_mfc.c
@@ -3412,13 +3412,13 @@ static int gen8_mfc_vp8_brc_postpack(struct encode_state *encode_state,
 
     if (qpn == qp) {
         /* setting qpn we round qpf making mistakes: now we are trying to compensate this */
-        mfc_context->brc.qpf_rounding_accumulator += qpf - qpn;
-        if (mfc_context->brc.qpf_rounding_accumulator > 1.0) {
+        mfc_context->brc.qpf_rounding_accumulator[0] += qpf - qpn;
+        if (mfc_context->brc.qpf_rounding_accumulator[0] > 1.0) {
             qpn++;
-            mfc_context->brc.qpf_rounding_accumulator = 0.;
-        } else if (mfc_context->brc.qpf_rounding_accumulator < -1.0) {
+            mfc_context->brc.qpf_rounding_accumulator[0] = 0.;
+        } else if (mfc_context->brc.qpf_rounding_accumulator[0] < -1.0) {
             qpn--;
-            mfc_context->brc.qpf_rounding_accumulator = 0.;
+            mfc_context->brc.qpf_rounding_accumulator[0] = 0.;
         }
     }
 
-- 
1.9.1



More information about the Libva mailing list