[x265] [PATCH 2 of 4] modify lambda from int64 to int32 because dynamic range less than 21 bits

Min Chen chenm003 at 163.com
Mon Apr 27 14:32:10 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1430137906 -28800
# Node ID c16efc78718f6fe7210e98393f55ad2e7de871c8
# Parent  c04edc2c3139c9561a08c675738ae976302fc000
modify lambda from int64 to int32 because dynamic range less than 21 bits
---
 source/common/quant.h |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff -r c04edc2c3139 -r c16efc78718f source/common/quant.h
--- a/source/common/quant.h	Mon Apr 27 20:31:42 2015 +0800
+++ b/source/common/quant.h	Mon Apr 27 20:31:46 2015 +0800
@@ -41,7 +41,7 @@
     int per;
     int qp;
     int64_t lambda2; /* FIX8 */
-    int64_t lambda;  /* FIX8 */
+    int32_t lambda;  /* FIX8, dynamic range is 18-bits in 8bpp and 20-bits in 16bpp */
 
     QpParam() : qp(MAX_INT) {}
 
@@ -53,7 +53,8 @@
             per = qpScaled / 6;
             qp  = qpScaled;
             lambda2 = (int64_t)(x265_lambda2_tab[qp - QP_BD_OFFSET] * 256. + 0.5);
-            lambda  = (int64_t)(x265_lambda_tab[qp - QP_BD_OFFSET] * 256. + 0.5);
+            lambda  = (int32_t)(x265_lambda_tab[qp - QP_BD_OFFSET] * 256. + 0.5);
+            X265_CHECK((x265_lambda_tab[qp - QP_BD_OFFSET] * 256. + 0.5) < (double)MAX_INT, "x265_lambda_tab[] value too large\n");
         }
     }
 };



More information about the x265-devel mailing list