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_FILTER_H_ 13 : #define AV1_COMMON_FILTER_H_ 14 : 15 : #include <assert.h> 16 : 17 : #ifdef __cplusplus 18 : extern "C" { 19 : #endif 20 : 21 : //---aom_filter.h 22 : #define FILTER_BITS 7 23 : 24 : #define SUBPEL_BITS 4 25 : #define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1) 26 : #define SUBPEL_SHIFTS (1 << SUBPEL_BITS) 27 : #define SUBPEL_TAPS 8 28 : 29 : #define SCALE_SUBPEL_BITS 10 30 : #define SCALE_SUBPEL_SHIFTS (1 << SCALE_SUBPEL_BITS) 31 : #define SCALE_SUBPEL_MASK (SCALE_SUBPEL_SHIFTS - 1) 32 : #define SCALE_EXTRA_BITS (SCALE_SUBPEL_BITS - SUBPEL_BITS) 33 : #define SCALE_EXTRA_OFF ((1 << SCALE_EXTRA_BITS) / 2) 34 : 35 : #define BIL_SUBPEL_BITS 3 36 : #define BIL_SUBPEL_SHIFTS (1 << BIL_SUBPEL_BITS) 37 : 38 : // 2 tap bilinear filters 39 : static const uint8_t bilinear_filters_2t[BIL_SUBPEL_SHIFTS][2] = { 40 : { 128, 0 }, { 112, 16 }, { 96, 32 }, { 80, 48 }, 41 : { 64, 64 }, { 48, 80 }, { 32, 96 }, { 16, 112 }, 42 : }; 43 : //---- 44 : #define MAX_FILTER_TAP 8 45 : 46 : // With CONFIG_DUAL_FILTER, pack two InterpFilter's into a uint32_t: since 47 : // there are at most 10 filters, we can use 16 bits for each and have more than 48 : // enough space. This reduces argument passing and unifies the operation of 49 : // setting a (pair of) filters. 50 : // 51 : // Without CONFIG_DUAL_FILTER, 52 : typedef uint32_t InterpFilters; 53 1186043960 : static INLINE InterpFilter av1_extract_interp_filter(InterpFilters filters, 54 : int32_t x_filter) { 55 1186043960 : return (InterpFilter)((filters >> (x_filter ? 16 : 0)) & 0xffff); 56 : } 57 : 58 66271252 : static INLINE InterpFilters av1_make_interp_filters(InterpFilter y_filter, 59 : InterpFilter x_filter) { 60 66271252 : uint16_t y16 = y_filter & 0xffff; 61 66271252 : uint16_t x16 = x_filter & 0xffff; 62 66271252 : return y16 | ((uint32_t)x16 << 16); 63 : } 64 : 65 22358684 : static INLINE InterpFilters av1_broadcast_interp_filter(InterpFilter filter) { 66 22358684 : return av1_make_interp_filters(filter, filter); 67 : } 68 : 69 22357784 : static INLINE InterpFilter av1_unswitchable_filter(InterpFilter filter) { 70 22357784 : return filter == SWITCHABLE ? EIGHTTAP_REGULAR : filter; 71 : } 72 : 73 : #define LOG_SWITCHABLE_FILTERS \ 74 : 2 /* (1 << LOG_SWITCHABLE_FILTERS) > SWITCHABLE_FILTERS */ 75 : 76 : #define MAX_SUBPEL_TAPS 12 77 : #define SWITCHABLE_FILTER_CONTEXTS ((SWITCHABLE_FILTERS + 1) * 4) 78 : #define INTER_FILTER_COMP_OFFSET (SWITCHABLE_FILTERS + 1) 79 : #define INTER_FILTER_DIR_OFFSET ((SWITCHABLE_FILTERS + 1) * 2) 80 : // 81 : //typedef struct InterpFilterParams { 82 : // const int16_t *filter_ptr; 83 : // uint16_t taps; 84 : // uint16_t subpel_shifts; 85 : // InterpFilter interp_filter; 86 : //} InterpFilterParams; 87 : 88 : InterpFilterParams av1_get_interp_filter_params_with_block_size( 89 : const InterpFilter interp_filter, const int32_t w); 90 : 91 752264500 : static INLINE const int16_t *av1_get_interp_filter_subpel_kernel( 92 : const InterpFilterParams filter_params, const int32_t subpel) { 93 752264500 : return filter_params.filter_ptr + filter_params.taps * subpel; 94 : } 95 : 96 : #ifdef __cplusplus 97 : } // extern "C" 98 : #endif 99 : 100 : #endif // AV1_COMMON_FILTER_H_