Commit 937dcfbd authored by Angie Chiang's avatar Angie Chiang
Browse files

[Normative lv_map] make 2d rect scan diagonal

1) The scan orders of rect txfm will be diagonal with shorter side
first
2) Neighbor is not updated because lv_map doesn't use the neighbor
3) Write a scan test to protect the scan order.
4) Performance on key frame is neutral. Will report the overall
performance by comment later.

BUG=aomedia:1369

Change-Id: I417392f2d9870e035532a2e1cc7cf71dc20ea219
parent 3a8a25f8
This diff is collapsed.
......@@ -25,6 +25,15 @@ extern "C" {
#define MAX_NEIGHBORS 2
typedef enum SCAN_MODE {
SCAN_MODE_ZIG_ZAG,
SCAN_MODE_COL_DIAG,
SCAN_MODE_ROW_DIAG,
SCAN_MODE_COL_1D,
SCAN_MODE_ROW_1D,
SCAN_MODES
} SCAN_MODE;
extern const SCAN_ORDER av1_default_scan_orders[TX_SIZES];
extern const SCAN_ORDER av1_intra_scan_orders[TX_SIZES_ALL][TX_TYPES];
extern const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES];
......
/*
* Copyright (c) 2018, Alliance for Open Media. All rights reserved
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
#include "av1/common/scan.h"
#include "av1/common/txb_common.h"
#if CONFIG_LV_MAP
static int scan_test(const int16_t *scan, const int16_t *iscan, int si, int r,
int c, int w) {
if (iscan[r * w + c] != si || scan[si] != r * w + c) {
printf("r %d c %d ref_iscan %d iscan %d ref_scan %d scan %d\n", r, c, si,
iscan[r * w + c], r * w + c, scan[si]);
return 1;
} else {
return 0;
}
}
int scan_order_test(const SCAN_ORDER *scan_order, int w, int h,
SCAN_MODE mode) {
const int16_t *scan = scan_order->scan;
const int16_t *iscan = scan_order->iscan;
int dim = w + h - 1;
if (mode == SCAN_MODE_ZIG_ZAG) {
int si = 0;
for (int i = 0; i < dim; ++i) {
if (i % 2 == 0) {
for (int c = 0; c < w; ++c) {
int r = i - c;
if (r >= 0 && r < h) {
if (scan_test(scan, iscan, si, r, c, w)) return 1;
++si;
}
}
} else {
for (int r = 0; r < h; ++r) {
int c = i - r;
if (c >= 0 && c < w) {
if (scan_test(scan, iscan, si, r, c, w)) return 1;
++si;
}
}
}
}
} else if (mode == SCAN_MODE_COL_DIAG) {
int si = 0;
for (int i = 0; i < dim; ++i) {
for (int c = 0; c < w; ++c) {
int r = i - c;
if (r >= 0 && r < h) {
if (scan_test(scan, iscan, si, r, c, w)) return 1;
++si;
}
}
}
} else if (mode == SCAN_MODE_ROW_DIAG) {
int si = 0;
for (int i = 0; i < dim; ++i) {
for (int r = 0; r < h; ++r) {
int c = i - r;
if (c >= 0 && c < w) {
if (scan_test(scan, iscan, si, r, c, w)) return 1;
++si;
}
}
}
} else if (mode == SCAN_MODE_ROW_1D) {
int si = 0;
for (int r = 0; r < h; ++r) {
for (int c = 0; c < w; ++c) {
if (scan_test(scan, iscan, si, r, c, w)) return 1;
++si;
}
}
} else {
assert(mode == SCAN_MODE_COL_1D);
int si = 0;
for (int c = 0; c < w; ++c) {
for (int r = 0; r < h; ++r) {
if (scan_test(scan, iscan, si, r, c, w)) return 1;
++si;
}
}
}
return 0;
}
TEST(Av1ScanTest, Dependency) {
for (int tx_size = TX_4X4; tx_size < TX_SIZES_ALL; ++tx_size) {
const int org_rows = tx_size_high[(TX_SIZE)tx_size];
const int org_cols = tx_size_wide[(TX_SIZE)tx_size];
const int rows = get_txb_high((TX_SIZE)tx_size);
const int cols = get_txb_wide((TX_SIZE)tx_size);
for (int tx_type = 0; tx_type < TX_TYPES; ++tx_type) {
if ((rows >= 32 || cols >= 32) && tx_type != DCT_DCT && tx_type != IDTX &&
tx_type != V_DCT && tx_type != H_DCT) {
// No ADST for large size transforms.
continue;
}
SCAN_MODE scan_mode;
TX_CLASS tx_class = tx_type_to_class[(TX_TYPE)tx_type];
if ((tx_class == TX_CLASS_2D && tx_type != IDTX) || org_rows == 64 ||
org_cols == 64) {
if (rows == cols) {
scan_mode = SCAN_MODE_ZIG_ZAG;
} else if (rows > cols) {
scan_mode = SCAN_MODE_ROW_DIAG;
} else {
scan_mode = SCAN_MODE_COL_DIAG;
}
} else if (tx_type == IDTX) {
scan_mode = SCAN_MODE_ROW_1D;
} else if (tx_class == TX_CLASS_VERT) {
scan_mode = SCAN_MODE_ROW_1D;
} else {
assert(tx_class == TX_CLASS_HORIZ);
scan_mode = SCAN_MODE_COL_1D;
}
int is_inter = 0;
const SCAN_ORDER *scan_order =
get_default_scan((TX_SIZE)tx_size, (TX_TYPE)tx_type, is_inter);
ASSERT_EQ(scan_order_test(scan_order, cols, rows, scan_mode), 0)
<< "scan mismatch tx_class " << tx_class << " tx_type " << tx_type
<< " tx_w " << org_cols << " tx_h " << org_rows << " scan_mode "
<< scan_mode << "\n";
}
}
}
#endif
......@@ -132,6 +132,7 @@ if (NOT BUILD_SHARED_LIBS)
"${AOM_ROOT}/test/av1_convolve_test.cc"
"${AOM_ROOT}/test/intrapred_test.cc"
"${AOM_ROOT}/test/lpf_test.cc"
"${AOM_ROOT}/test/scan_test.cc"
"${AOM_ROOT}/test/simd_cmp_impl.h")
set(AOM_UNIT_TEST_ENCODER_SOURCES
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment