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 "vp9/common/vp9_blockd.h"
18 #include "vp9/common/vp9_seg_common.h"
20 #define MAX_LOOP_FILTER 63
21 #define MAX_SHARPNESS 7
25 #define MAX_REF_LF_DELTAS 4
26 #define MAX_MODE_LF_DELTAS 2
32 int last_sharpness_level;
34 uint8_t mode_ref_delta_enabled;
35 uint8_t mode_ref_delta_update;
37 // 0 = Intra, Last, GF, ARF
38 signed char ref_deltas[MAX_REF_LF_DELTAS];
39 signed char last_ref_deltas[MAX_REF_LF_DELTAS];
42 signed char mode_deltas[MAX_MODE_LF_DELTAS];
43 signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
46 // Need to align this structure so when it is declared and
47 // passed it can be loaded into vector registers.
49 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, mblim[SIMD_WIDTH]);
50 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, lim[SIMD_WIDTH]);
51 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, hev_thr[SIMD_WIDTH]);
55 loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1];
56 uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS];
59 /* assorted loopfilter functions which get used elsewhere */
63 void vp9_loop_filter_init(struct VP9Common *cm);
65 // Update the loop filter for the current frame.
66 // This should be called before vp9_loop_filter_rows(), vp9_loop_filter_frame()
67 // calls this function directly.
68 void vp9_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl);
70 void vp9_loop_filter_frame(struct VP9Common *cm,
71 struct macroblockd *mbd,
73 int y_only, int partial);
75 // Apply the loop filter to [start, stop) macro block rows in frame_buffer.
76 void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
77 struct VP9Common *cm, struct macroblockd *xd,
78 int start, int stop, int y_only);
80 typedef struct LoopFilterWorkerData {
81 const YV12_BUFFER_CONFIG *frame_buffer;
83 struct macroblockd xd; // TODO(jzern): most of this is unnecessary to the
84 // loopfilter. the planes are necessary as their state
85 // is changed during decode.
91 // Operates on the rows described by LFWorkerData passed as 'arg1'.
92 int vp9_loop_filter_worker(void *arg1, void *arg2);
93 #endif // VP9_COMMON_VP9_LOOPFILTER_H_