Line data Source code
1 : /*
2 : * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 : *
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.
10 : */
11 :
12 : #ifndef AV1_COMMON_SCAN_H_
13 : #define AV1_COMMON_SCAN_H_
14 :
15 : #include "aom/aom_integer.h"
16 : #include "aom_ports/mem.h"
17 :
18 : #include "av1/common/enums.h"
19 : #include "av1/common/onyxc_int.h"
20 : #include "av1/common/blockd.h"
21 :
22 : #ifdef __cplusplus
23 : extern "C" {
24 : #endif
25 :
26 : #define MAX_NEIGHBORS 2
27 :
28 : extern const SCAN_ORDER av1_default_scan_orders[TX_SIZES];
29 : extern const SCAN_ORDER av1_intra_scan_orders[TX_SIZES_ALL][TX_TYPES];
30 : extern const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES];
31 :
32 : #if CONFIG_ADAPT_SCAN
33 : void av1_update_scan_count_facade(AV1_COMMON *cm, FRAME_COUNTS *counts,
34 : TX_SIZE tx_size, TX_TYPE tx_type,
35 : const tran_low_t *dqcoeffs, int max_scan);
36 :
37 : // embed r + c and coeff_idx info with nonzero probabilities. When sorting the
38 : // nonzero probabilities, if there is a tie, the coefficient with smaller r + c
39 : // will be scanned first
40 : void av1_augment_prob(TX_SIZE tx_size, TX_TYPE tx_type, uint32_t *prob);
41 :
42 : // apply quick sort on nonzero probabilities to obtain a sort order
43 : void av1_update_sort_order(TX_SIZE tx_size, TX_TYPE tx_type,
44 : const uint32_t *non_zero_prob, int16_t *sort_order);
45 :
46 : // apply topological sort on the nonzero probabilities sorting order to
47 : // guarantee each to-be-scanned coefficient's upper and left coefficient will be
48 : // scanned before the to-be-scanned coefficient.
49 : void av1_update_scan_order(TX_SIZE tx_size, int16_t *sort_order, int16_t *scan,
50 : int16_t *iscan);
51 :
52 : // For each coeff_idx in scan[], update its above and left neighbors in
53 : // neighbors[] accordingly.
54 : void av1_update_neighbors(int tx_size, const int16_t *scan,
55 : const int16_t *iscan, int16_t *neighbors);
56 : void av1_init_scan_order(AV1_COMMON *cm);
57 : void av1_adapt_scan_order(AV1_COMMON *cm);
58 : #endif
59 : void av1_deliver_eob_threshold(const AV1_COMMON *cm, MACROBLOCKD *xd);
60 :
61 0 : static INLINE int get_coef_context(const int16_t *neighbors,
62 : const uint8_t *token_cache, int c) {
63 0 : return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +
64 0 : token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >>
65 : 1;
66 : }
67 :
68 0 : static INLINE const SCAN_ORDER *get_default_scan(TX_SIZE tx_size,
69 : TX_TYPE tx_type,
70 : int is_inter) {
71 : #if CONFIG_EXT_TX || CONFIG_VAR_TX
72 0 : return is_inter ? &av1_inter_scan_orders[tx_size][tx_type]
73 0 : : &av1_intra_scan_orders[tx_size][tx_type];
74 : #else
75 : (void)is_inter;
76 : return &av1_intra_scan_orders[tx_size][tx_type];
77 : #endif // CONFIG_EXT_TX
78 : }
79 :
80 0 : static INLINE const SCAN_ORDER *get_scan(const AV1_COMMON *cm, TX_SIZE tx_size,
81 : TX_TYPE tx_type, int is_inter) {
82 : #if CONFIG_ADAPT_SCAN
83 : (void)is_inter;
84 : return &cm->fc->sc[tx_size][tx_type];
85 : #else // CONFIG_ADAPT_SCAN
86 : (void)cm;
87 0 : return get_default_scan(tx_size, tx_type, is_inter);
88 : #endif // CONFIG_ADAPT_SCAN
89 : }
90 :
91 : #ifdef __cplusplus
92 : } // extern "C"
93 : #endif
94 :
95 : #endif // AV1_COMMON_SCAN_H_
|