2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef VP9_COMMON_VP9_LOOPFILTER_H_
12 #define VP9_COMMON_VP9_LOOPFILTER_H_
14 #include "vpx_ports/mem.h"
15 #include "./vpx_config.h"
17 #include "vp10/common/blockd.h"
18 #include "vp10/common/seg_common.h"
24 #define MAX_LOOP_FILTER 63
25 #define MAX_SHARPNESS 7
29 #define MAX_REF_LF_DELTAS 4
30 #define MAX_MODE_LF_DELTAS 2
42 int last_sharpness_level;
44 uint8_t mode_ref_delta_enabled;
45 uint8_t mode_ref_delta_update;
47 // 0 = Intra, Last, GF, ARF
48 signed char ref_deltas[MAX_REF_LF_DELTAS];
49 signed char last_ref_deltas[MAX_REF_LF_DELTAS];
52 signed char mode_deltas[MAX_MODE_LF_DELTAS];
53 signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
56 // Need to align this structure so when it is declared and
57 // passed it can be loaded into vector registers.
59 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, mblim[SIMD_WIDTH]);
60 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, lim[SIMD_WIDTH]);
61 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, hev_thr[SIMD_WIDTH]);
65 loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1];
66 uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS];
69 // This structure holds bit masks for all 8x8 blocks in a 64x64 region.
70 // Each 1 bit represents a position in which we want to apply the loop filter.
71 // Left_ entries refer to whether we apply a filter on the border to the
72 // left of the block. Above_ entries refer to whether or not to apply a
73 // filter on the above border. Int_ entries refer to whether or not to
74 // apply borders on the 4x4 edges within the 8x8 block that each bit
76 // Since each transform is accompanied by a potentially different type of
77 // loop filter there is a different entry in the array for each transform size.
79 uint64_t left_y[TX_SIZES];
80 uint64_t above_y[TX_SIZES];
82 uint16_t left_uv[TX_SIZES];
83 uint16_t above_uv[TX_SIZES];
89 /* assorted loopfilter functions which get used elsewhere */
94 // This function sets up the bit masks for the entire 64x64 region represented
96 void vp10_setup_mask(struct VP9Common *const cm,
97 const int mi_row, const int mi_col,
98 MODE_INFO **mi_8x8, const int mode_info_stride,
99 LOOP_FILTER_MASK *lfm);
101 void vp10_filter_block_plane_ss00(struct VP9Common *const cm,
102 struct macroblockd_plane *const plane,
104 LOOP_FILTER_MASK *lfm);
106 void vp10_filter_block_plane_ss11(struct VP9Common *const cm,
107 struct macroblockd_plane *const plane,
109 LOOP_FILTER_MASK *lfm);
111 void vp10_filter_block_plane_non420(struct VP9Common *cm,
112 struct macroblockd_plane *plane,
114 int mi_row, int mi_col);
116 void vp10_loop_filter_init(struct VP9Common *cm);
118 // Update the loop filter for the current frame.
119 // This should be called before vp10_loop_filter_rows(), vp10_loop_filter_frame()
120 // calls this function directly.
121 void vp10_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl);
123 void vp10_loop_filter_frame(YV12_BUFFER_CONFIG *frame,
124 struct VP9Common *cm,
125 struct macroblockd *mbd,
127 int y_only, int partial_frame);
129 // Apply the loop filter to [start, stop) macro block rows in frame_buffer.
130 void vp10_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer,
131 struct VP9Common *cm,
132 struct macroblockd_plane planes[MAX_MB_PLANE],
133 int start, int stop, int y_only);
135 typedef struct LoopFilterWorkerData {
136 YV12_BUFFER_CONFIG *frame_buffer;
137 struct VP9Common *cm;
138 struct macroblockd_plane planes[MAX_MB_PLANE];
145 void vp10_loop_filter_data_reset(
146 LFWorkerData *lf_data, YV12_BUFFER_CONFIG *frame_buffer,
147 struct VP9Common *cm, const struct macroblockd_plane planes[MAX_MB_PLANE]);
149 // Operates on the rows described by 'lf_data'.
150 int vp10_loop_filter_worker(LFWorkerData *const lf_data, void *unused);
155 #endif // VP9_COMMON_VP9_LOOPFILTER_H_