Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: source/libvpx/test/fdct4x4_test.cc

Issue 11555023: libvpx: Add VP9 decoder. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: source/libvpx/test/fdct4x4_test.cc
===================================================================
--- source/libvpx/test/fdct4x4_test.cc (revision 172621)
+++ source/libvpx/test/fdct4x4_test.cc (working copy)
@@ -1,79 +1,31 @@
/*
-* Copyright (c) 2012 The WebM project authors. All Rights Reserved.
-*
-* Use of this source code is governed by a BSD-style license
-* that can be found in the LICENSE file in the root of the source
-* tree. An additional intellectual property rights grant can be found
-* in the file PATENTS. All contributing project authors may
-* be found in the AUTHORS file in the root of the source tree.
-*/
+ * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
-
#include <math.h>
-#include <stddef.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
+#include "third_party/googletest/src/include/gtest/gtest.h"
extern "C" {
-#include "vpx_rtcd.h"
+#include "vp9_rtcd.h"
}
-#include "test/acm_random.h"
-#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "acm_random.h"
#include "vpx/vpx_integer.h"
+using libvpx_test::ACMRandom;
namespace {
-const int cospi8sqrt2minus1 = 20091;
-const int sinpi8sqrt2 = 35468;
-
-void reference_idct4x4(const int16_t *input, int16_t *output) {
- const int16_t *ip = input;
- int16_t *op = output;
-
- for (int i = 0; i < 4; ++i) {
- const int a1 = ip[0] + ip[8];
- const int b1 = ip[0] - ip[8];
- const int temp1 = (ip[4] * sinpi8sqrt2) >> 16;
- const int temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1) >> 16);
- const int c1 = temp1 - temp2;
- const int temp3 = ip[4] + ((ip[4] * cospi8sqrt2minus1) >> 16);
- const int temp4 = (ip[12] * sinpi8sqrt2) >> 16;
- const int d1 = temp3 + temp4;
- op[0] = a1 + d1;
- op[12] = a1 - d1;
- op[4] = b1 + c1;
- op[8] = b1 - c1;
- ++ip;
- ++op;
- }
- ip = output;
- op = output;
- for (int i = 0; i < 4; ++i) {
- const int a1 = ip[0] + ip[2];
- const int b1 = ip[0] - ip[2];
- const int temp1 = (ip[1] * sinpi8sqrt2) >> 16;
- const int temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1) >> 16);
- const int c1 = temp1 - temp2;
- const int temp3 = ip[1] + ((ip[1] * cospi8sqrt2minus1) >> 16);
- const int temp4 = (ip[3] * sinpi8sqrt2) >> 16;
- const int d1 = temp3 + temp4;
- op[0] = (a1 + d1 + 4) >> 3;
- op[3] = (a1 - d1 + 4) >> 3;
- op[1] = (b1 + c1 + 4) >> 3;
- op[2] = (b1 - c1 + 4) >> 3;
- ip += 4;
- op += 4;
- }
-}
-
-using libvpx_test::ACMRandom;
-
-TEST(Vp8FdctTest, SignBiasCheck) {
+TEST(Vp9FdctTest, SignBiasCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
int16_t test_input_block[16];
int16_t test_output_block[16];
@@ -88,7 +40,9 @@
for (int j = 0; j < 16; ++j)
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
- vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch);
+ // TODO(Yaowu): this should be converted to a parameterized test
+ // to test optimized versions of this function.
+ vp9_short_fdct4x4_c(test_input_block, test_output_block, pitch);
for (int j = 0; j < 16; ++j) {
if (test_output_block[j] < 0)
@@ -98,14 +52,14 @@
}
}
- bool bias_acceptable = true;
- for (int j = 0; j < 16; ++j)
- bias_acceptable = bias_acceptable &&
- (abs(count_sign_block[j][0] - count_sign_block[j][1]) < 10000);
+ for (int j = 0; j < 16; ++j) {
+ const bool bias_acceptable = (abs(count_sign_block[j][0] -
+ count_sign_block[j][1]) < 10000);
+ EXPECT_TRUE(bias_acceptable)
+ << "Error: 4x4 FDCT has a sign bias > 1%"
+ << " for input range [-255, 255] at index " << j;
+ }
- EXPECT_EQ(true, bias_acceptable)
- << "Error: 4x4 FDCT has a sign bias > 1% for input range [-255, 255]";
-
memset(count_sign_block, 0, sizeof(count_sign_block));
for (int i = 0; i < count_test_block; ++i) {
@@ -113,7 +67,9 @@
for (int j = 0; j < 16; ++j)
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4);
- vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch);
+ // TODO(Yaowu): this should be converted to a parameterized test
+ // to test optimized versions of this function.
+ vp9_short_fdct4x4_c(test_input_block, test_output_block, pitch);
for (int j = 0; j < 16; ++j) {
if (test_output_block[j] < 0)
@@ -123,16 +79,16 @@
}
}
- bias_acceptable = true;
- for (int j = 0; j < 16; ++j)
- bias_acceptable = bias_acceptable &&
- (abs(count_sign_block[j][0] - count_sign_block[j][1]) < 100000);
-
- EXPECT_EQ(true, bias_acceptable)
- << "Error: 4x4 FDCT has a sign bias > 10% for input range [-15, 15]";
+ for (int j = 0; j < 16; ++j) {
+ const bool bias_acceptable = (abs(count_sign_block[j][0] -
+ count_sign_block[j][1]) < 100000);
+ EXPECT_TRUE(bias_acceptable)
+ << "Error: 4x4 FDCT has a sign bias > 10%"
+ << " for input range [-15, 15] at index " << j;
+ }
};
-TEST(Vp8FdctTest, RoundTripErrorCheck) {
+TEST(Vp9FdctTest, RoundTripErrorCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
int max_error = 0;
double total_error = 0;
@@ -146,11 +102,27 @@
for (int j = 0; j < 16; ++j)
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
+ // TODO(Yaowu): this should be converted to a parameterized test
+ // to test optimized versions of this function.
const int pitch = 8;
- vp8_short_fdct4x4_c(test_input_block, test_temp_block, pitch);
- reference_idct4x4(test_temp_block, test_output_block);
+ vp9_short_fdct4x4_c(test_input_block, test_temp_block, pitch);
for (int j = 0; j < 16; ++j) {
+ if(test_temp_block[j] > 0) {
+ test_temp_block[j] += 2;
+ test_temp_block[j] /= 4;
+ test_temp_block[j] *= 4;
+ } else {
+ test_temp_block[j] -= 2;
+ test_temp_block[j] /= 4;
+ test_temp_block[j] *= 4;
+ }
+ }
+
+ // Because the bitstream is not frozen yet, use the idct in the codebase.
+ vp9_short_idct4x4llm_c(test_temp_block, test_output_block, pitch);
+
+ for (int j = 0; j < 16; ++j) {
const int diff = test_input_block[j] - test_output_block[j];
const int error = diff * diff;
if (max_error < error)
@@ -158,12 +130,11 @@
total_error += error;
}
}
+ EXPECT_GE(1, max_error)
+ << "Error: FDCT/IDCT has an individual roundtrip error > 1";
- EXPECT_GE(1, max_error )
- << "Error: FDCT/IDCT has an individual roundtrip error > 1";
-
EXPECT_GE(count_test_block, total_error)
- << "Error: FDCT/IDCT has average roundtrip error > 1 per block";
+ << "Error: FDCT/IDCT has average roundtrip error > 1 per block";
};
} // namespace

Powered by Google App Engine
This is Rietveld 408576698