scan.h 2.05 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4 5 6 7 8 9
 * 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.
Jingning Han's avatar
Jingning Han committed
10 11
 */

Yaowu Xu's avatar
Yaowu Xu committed
12 13
#ifndef AV1_COMMON_SCAN_H_
#define AV1_COMMON_SCAN_H_
Jingning Han's avatar
Jingning Han committed
14

Yaowu Xu's avatar
Yaowu Xu committed
15
#include "aom/aom_integer.h"
16
#include "aom_ports/mem.h"
Jingning Han's avatar
Jingning Han committed
17

18 19
#include "av1/common/enums.h"
#include "av1/common/blockd.h"
Jingning Han's avatar
Jingning Han committed
20 21 22 23 24 25 26

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_NEIGHBORS 2

27 28
extern const SCAN_ORDER av1_default_scan_orders[TX_SIZES];
extern const SCAN_ORDER av1_intra_scan_orders[TX_SIZES][TX_TYPES];
Jingning Han's avatar
Jingning Han committed
29 30 31 32

static INLINE int get_coef_context(const int16_t *neighbors,
                                   const uint8_t *token_cache, int c) {
  return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] +
clang-format's avatar
clang-format committed
33 34
          token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >>
         1;
Jingning Han's avatar
Jingning Han committed
35 36
}

37
static INLINE const SCAN_ORDER *get_intra_scan(TX_SIZE tx_size,
38
                                               TX_TYPE tx_type) {
Yaowu Xu's avatar
Yaowu Xu committed
39
  return &av1_intra_scan_orders[tx_size][tx_type];
40 41 42
}

#if CONFIG_EXT_TX
43
extern const SCAN_ORDER av1_inter_scan_orders[TX_SIZES_ALL][TX_TYPES];
44

45
static INLINE const SCAN_ORDER *get_inter_scan(TX_SIZE tx_size,
46
                                               TX_TYPE tx_type) {
Yaowu Xu's avatar
Yaowu Xu committed
47
  return &av1_inter_scan_orders[tx_size][tx_type];
48 49 50
}
#endif  // CONFIG_EXT_TX

51
static INLINE const SCAN_ORDER *get_scan(TX_SIZE tx_size, TX_TYPE tx_type,
52 53
                                         int is_inter) {
#if CONFIG_EXT_TX
Yaowu Xu's avatar
Yaowu Xu committed
54 55
  return is_inter ? &av1_inter_scan_orders[tx_size][tx_type]
                  : &av1_intra_scan_orders[tx_size][tx_type];
56
#else
clang-format's avatar
clang-format committed
57
  (void)is_inter;
Yaowu Xu's avatar
Yaowu Xu committed
58
  return &av1_intra_scan_orders[tx_size][tx_type];
59
#endif  // CONFIG_EXT_TX
Jingning Han's avatar
Jingning Han committed
60 61 62 63 64 65
}

#ifdef __cplusplus
}  // extern "C"
#endif

Yaowu Xu's avatar
Yaowu Xu committed
66
#endif  // AV1_COMMON_SCAN_H_