]> granicus.if.org Git - libvpx/commitdiff
quantize test: restrict and correct input
authorJohann <johannkoenig@google.com>
Tue, 18 Jul 2017 16:40:45 +0000 (09:40 -0700)
committerJohann <johannkoenig@google.com>
Tue, 18 Jul 2017 16:40:45 +0000 (09:40 -0700)
Use only valid values for quantize inputs. These were determined by
looping over vp9_init_quantizer and looking for max and min values.

This allows extending the test to the low bit depth functions which were
not designed to handle all possible inputs but only valid inputs.

Change-Id: I94e1d8863a49ac227845b65c6b50130e10e6319e

test/vp9_quantize_test.cc

index 948b01fb066de00ece288ff6189d8f8d534da63d..125c39b797b26a7f4bd83acd0a33dedc536bffdc 100644 (file)
@@ -111,11 +111,19 @@ TEST_P(VP9QuantizeTest, OperationCheck) {
     ref_eob = eob;
     coeff.Set(&rnd, 0, max_value_);
     for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(max_value_);
-      round_ptr[j] = rnd.Rand16();
-      quant_ptr[j] = rnd.Rand16();
-      quant_shift_ptr[j] = rnd.Rand16();
-      dequant_ptr[j] = rnd.Rand16();
+      // Values determined by deconstructing vp9_init_quantizer().
+      // zbin may be up to 1143 for 8 and 10 bit Y values, or 1200 for 12 bit Y
+      // values or U/V values of any bit depth. This is because y_delta is not
+      // factored into the vp9_ac_quant() call.
+      zbin_ptr[j] = rnd.RandRange(1200);
+      // round may be up to 685 for Y values or 914 for U/V.
+      round_ptr[j] = rnd.RandRange(914);
+      // quant ranges from 1 to -32703
+      quant_ptr[j] = rnd.RandRange(32704) - 32703;
+      // quant_shift goes up to 1 << 16.
+      quant_shift_ptr[j] = rnd.RandRange(16384);
+      // dequant maxes out at 1828 for all cases.
+      dequant_ptr[j] = rnd.RandRange(1828);
     }
     ref_quantize_op_(
         coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
@@ -169,11 +177,11 @@ TEST_P(VP9Quantize32Test, OperationCheck) {
     ref_eob = eob;
     coeff.Set(&rnd, 0, max_value_);
     for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(max_value_);
-      round_ptr[j] = rnd.Rand16();
-      quant_ptr[j] = rnd.Rand16();
-      quant_shift_ptr[j] = rnd.Rand16();
-      dequant_ptr[j] = rnd.Rand16();
+      zbin_ptr[j] = rnd.RandRange(1200);
+      round_ptr[j] = rnd.RandRange(914);
+      quant_ptr[j] = rnd.RandRange(32704) - 32703;
+      quant_shift_ptr[j] = rnd.RandRange(16384);
+      dequant_ptr[j] = rnd.RandRange(1828);
     }
     ref_quantize_op_(
         coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
@@ -230,11 +238,11 @@ TEST_P(VP9QuantizeTest, EOBCheck) {
     coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
     coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
     for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(max_value_);
-      round_ptr[j] = rnd.Rand16();
-      quant_ptr[j] = rnd.Rand16();
-      quant_shift_ptr[j] = rnd.Rand16();
-      dequant_ptr[j] = rnd.Rand16();
+      zbin_ptr[j] = rnd.RandRange(1200);
+      round_ptr[j] = rnd.RandRange(914);
+      quant_ptr[j] = rnd.RandRange(32704) - 32703;
+      quant_shift_ptr[j] = rnd.RandRange(16384);
+      dequant_ptr[j] = rnd.RandRange(1828);
     }
 
     ref_quantize_op_(
@@ -292,11 +300,11 @@ TEST_P(VP9Quantize32Test, EOBCheck) {
     coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
     coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
     for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(max_value_);
-      round_ptr[j] = rnd.Rand16();
-      quant_ptr[j] = rnd.Rand16();
-      quant_shift_ptr[j] = rnd.Rand16();
-      dequant_ptr[j] = rnd.Rand16();
+      zbin_ptr[j] = rnd.RandRange(1200);
+      round_ptr[j] = rnd.RandRange(914);
+      quant_ptr[j] = rnd.RandRange(32704) - 32703;
+      quant_shift_ptr[j] = rnd.RandRange(16384);
+      dequant_ptr[j] = rnd.RandRange(1828);
     }
 
     ref_quantize_op_(