michael@0: /* michael@0: * Copyright (c) 2013 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: #ifndef VP9_COMMON_VP9_SCAN_H_ michael@0: #define VP9_COMMON_VP9_SCAN_H_ michael@0: michael@0: #include "vpx/vpx_integer.h" michael@0: #include "vpx_ports/mem.h" michael@0: michael@0: #include "vp9/common/vp9_enums.h" michael@0: michael@0: #define MAX_NEIGHBORS 2 michael@0: michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_4x4[16]); michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_4x4[16]); michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_4x4[16]); michael@0: michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_8x8[64]); michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_8x8[64]); michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_8x8[64]); michael@0: michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_16x16[256]); michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_col_scan_16x16[256]); michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_row_scan_16x16[256]); michael@0: michael@0: extern DECLARE_ALIGNED(16, const int16_t, vp9_default_scan_32x32[1024]); michael@0: michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_4x4[16]); michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_4x4[16]); michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_4x4[16]); michael@0: michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_8x8[64]); michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_8x8[64]); michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_8x8[64]); michael@0: michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_16x16[256]); michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_col_iscan_16x16[256]); michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_row_iscan_16x16[256]); michael@0: michael@0: extern DECLARE_ALIGNED(16, int16_t, vp9_default_iscan_32x32[1024]); michael@0: michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_default_scan_4x4_neighbors[17 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_col_scan_4x4_neighbors[17 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_row_scan_4x4_neighbors[17 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_col_scan_8x8_neighbors[65 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_row_scan_8x8_neighbors[65 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_default_scan_8x8_neighbors[65 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_col_scan_16x16_neighbors[257 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_row_scan_16x16_neighbors[257 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_default_scan_16x16_neighbors[257 * MAX_NEIGHBORS]); michael@0: extern DECLARE_ALIGNED(16, int16_t, michael@0: vp9_default_scan_32x32_neighbors[1025 * MAX_NEIGHBORS]); michael@0: michael@0: michael@0: void vp9_init_neighbors(); michael@0: michael@0: static INLINE const int16_t* get_scan_4x4(TX_TYPE tx_type) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: return vp9_row_scan_4x4; michael@0: case DCT_ADST: michael@0: return vp9_col_scan_4x4; michael@0: default: michael@0: return vp9_default_scan_4x4; michael@0: } michael@0: } michael@0: michael@0: static INLINE void get_scan_nb_4x4(TX_TYPE tx_type, michael@0: const int16_t **scan, const int16_t **nb) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: *scan = vp9_row_scan_4x4; michael@0: *nb = vp9_row_scan_4x4_neighbors; michael@0: break; michael@0: case DCT_ADST: michael@0: *scan = vp9_col_scan_4x4; michael@0: *nb = vp9_col_scan_4x4_neighbors; michael@0: break; michael@0: default: michael@0: *scan = vp9_default_scan_4x4; michael@0: *nb = vp9_default_scan_4x4_neighbors; michael@0: break; michael@0: } michael@0: } michael@0: michael@0: static INLINE const int16_t* get_iscan_4x4(TX_TYPE tx_type) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: return vp9_row_iscan_4x4; michael@0: case DCT_ADST: michael@0: return vp9_col_iscan_4x4; michael@0: default: michael@0: return vp9_default_iscan_4x4; michael@0: } michael@0: } michael@0: michael@0: static INLINE const int16_t* get_scan_8x8(TX_TYPE tx_type) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: return vp9_row_scan_8x8; michael@0: case DCT_ADST: michael@0: return vp9_col_scan_8x8; michael@0: default: michael@0: return vp9_default_scan_8x8; michael@0: } michael@0: } michael@0: michael@0: static INLINE void get_scan_nb_8x8(TX_TYPE tx_type, michael@0: const int16_t **scan, const int16_t **nb) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: *scan = vp9_row_scan_8x8; michael@0: *nb = vp9_row_scan_8x8_neighbors; michael@0: break; michael@0: case DCT_ADST: michael@0: *scan = vp9_col_scan_8x8; michael@0: *nb = vp9_col_scan_8x8_neighbors; michael@0: break; michael@0: default: michael@0: *scan = vp9_default_scan_8x8; michael@0: *nb = vp9_default_scan_8x8_neighbors; michael@0: break; michael@0: } michael@0: } michael@0: michael@0: static INLINE const int16_t* get_iscan_8x8(TX_TYPE tx_type) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: return vp9_row_iscan_8x8; michael@0: case DCT_ADST: michael@0: return vp9_col_iscan_8x8; michael@0: default: michael@0: return vp9_default_iscan_8x8; michael@0: } michael@0: } michael@0: michael@0: static INLINE const int16_t* get_scan_16x16(TX_TYPE tx_type) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: return vp9_row_scan_16x16; michael@0: case DCT_ADST: michael@0: return vp9_col_scan_16x16; michael@0: default: michael@0: return vp9_default_scan_16x16; michael@0: } michael@0: } michael@0: michael@0: static INLINE void get_scan_nb_16x16(TX_TYPE tx_type, michael@0: const int16_t **scan, const int16_t **nb) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: *scan = vp9_row_scan_16x16; michael@0: *nb = vp9_row_scan_16x16_neighbors; michael@0: break; michael@0: case DCT_ADST: michael@0: *scan = vp9_col_scan_16x16; michael@0: *nb = vp9_col_scan_16x16_neighbors; michael@0: break; michael@0: default: michael@0: *scan = vp9_default_scan_16x16; michael@0: *nb = vp9_default_scan_16x16_neighbors; michael@0: break; michael@0: } michael@0: } michael@0: michael@0: static INLINE const int16_t* get_iscan_16x16(TX_TYPE tx_type) { michael@0: switch (tx_type) { michael@0: case ADST_DCT: michael@0: return vp9_row_iscan_16x16; michael@0: case DCT_ADST: michael@0: return vp9_col_iscan_16x16; michael@0: default: michael@0: return vp9_default_iscan_16x16; michael@0: } michael@0: } michael@0: michael@0: static INLINE int get_coef_context(const int16_t *neighbors, michael@0: const uint8_t *token_cache, int c) { michael@0: return (1 + token_cache[neighbors[MAX_NEIGHBORS * c + 0]] + michael@0: token_cache[neighbors[MAX_NEIGHBORS * c + 1]]) >> 1; michael@0: } michael@0: michael@0: #endif // VP9_COMMON_VP9_SCAN_H_