2 * Copyright (c) 2018, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
13 #include "av1/common/scan.h"
14 #include "av1/common/txb_common.h"
15 #include "test/av1_txfm_test.h"
17 static int scan_test(const int16_t *scan
, const int16_t *iscan
, int si
, int r
,
19 if (iscan
[r
* w
+ c
] != si
|| scan
[si
] != r
* w
+ c
) {
20 printf("r %d c %d ref_iscan %d iscan %d ref_scan %d scan %d\n", r
, c
, si
,
21 iscan
[r
* w
+ c
], r
* w
+ c
, scan
[si
]);
28 int scan_order_test(const SCAN_ORDER
*scan_order
, int w
, int h
,
30 const int16_t *scan
= scan_order
->scan
;
31 const int16_t *iscan
= scan_order
->iscan
;
33 if (mode
== SCAN_MODE_ZIG_ZAG
) {
35 for (int i
= 0; i
< dim
; ++i
) {
37 for (int c
= 0; c
< w
; ++c
) {
39 if (r
>= 0 && r
< h
) {
40 if (scan_test(scan
, iscan
, si
, r
, c
, w
)) return 1;
45 for (int r
= 0; r
< h
; ++r
) {
47 if (c
>= 0 && c
< w
) {
48 if (scan_test(scan
, iscan
, si
, r
, c
, w
)) return 1;
54 } else if (mode
== SCAN_MODE_COL_DIAG
) {
56 for (int i
= 0; i
< dim
; ++i
) {
57 for (int c
= 0; c
< w
; ++c
) {
59 if (r
>= 0 && r
< h
) {
60 if (scan_test(scan
, iscan
, si
, r
, c
, w
)) return 1;
65 } else if (mode
== SCAN_MODE_ROW_DIAG
) {
67 for (int i
= 0; i
< dim
; ++i
) {
68 for (int r
= 0; r
< h
; ++r
) {
70 if (c
>= 0 && c
< w
) {
71 if (scan_test(scan
, iscan
, si
, r
, c
, w
)) return 1;
76 } else if (mode
== SCAN_MODE_ROW_1D
) {
78 for (int r
= 0; r
< h
; ++r
) {
79 for (int c
= 0; c
< w
; ++c
) {
80 if (scan_test(scan
, iscan
, si
, r
, c
, w
)) return 1;
85 assert(mode
== SCAN_MODE_COL_1D
);
87 for (int c
= 0; c
< w
; ++c
) {
88 for (int r
= 0; r
< h
; ++r
) {
89 if (scan_test(scan
, iscan
, si
, r
, c
, w
)) return 1;
97 TEST(Av1ScanTest
, Dependency
) {
98 for (int tx_size
= TX_4X4
; tx_size
< TX_SIZES_ALL
; ++tx_size
) {
99 const int org_rows
= tx_size_high
[(TX_SIZE
)tx_size
];
100 const int org_cols
= tx_size_wide
[(TX_SIZE
)tx_size
];
101 const int rows
= get_txb_high((TX_SIZE
)tx_size
);
102 const int cols
= get_txb_wide((TX_SIZE
)tx_size
);
103 for (int tx_type
= 0; tx_type
< TX_TYPES
; ++tx_type
) {
104 if (libaom_test::IsTxSizeTypeValid(static_cast<TX_SIZE
>(tx_size
),
105 static_cast<TX_TYPE
>(tx_type
)) ==
110 TX_CLASS tx_class
= tx_type_to_class
[(TX_TYPE
)tx_type
];
111 if (tx_class
== TX_CLASS_2D
) {
113 scan_mode
= SCAN_MODE_ZIG_ZAG
;
114 } else if (rows
> cols
) {
115 scan_mode
= SCAN_MODE_ROW_DIAG
;
117 scan_mode
= SCAN_MODE_COL_DIAG
;
119 } else if (tx_class
== TX_CLASS_VERT
) {
120 scan_mode
= SCAN_MODE_ROW_1D
;
122 assert(tx_class
== TX_CLASS_HORIZ
);
123 scan_mode
= SCAN_MODE_COL_1D
;
125 const SCAN_ORDER
*scan_order
=
126 get_default_scan((TX_SIZE
)tx_size
, (TX_TYPE
)tx_type
);
127 ASSERT_EQ(scan_order_test(scan_order
, cols
, rows
, scan_mode
), 0)
128 << "scan mismatch tx_class " << tx_class
<< " tx_type " << tx_type
129 << " tx_w " << org_cols
<< " tx_h " << org_rows
<< " scan_mode "
130 << scan_mode
<< "\n";