1 /* 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3 * 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. 9 */ 10 11 #ifndef VP9_COMMON_VP9_LOOPFILTER_H_ 12 #define VP9_COMMON_VP9_LOOPFILTER_H_ 13 14 #include "vpx_ports/mem.h" 15 #include "./vpx_config.h" 16 17 #include "vp9/common/vp9_blockd.h" 18 #include "vp9/common/vp9_seg_common.h" 19 20 #define MAX_LOOP_FILTER 63 21 #define MAX_SHARPNESS 7 22 23 #define SIMD_WIDTH 16 24 25 #define MAX_REF_LF_DELTAS 4 26 #define MAX_MODE_LF_DELTAS 2 27 28 struct loopfilter { 29 int filter_level; 30 31 int sharpness_level; 32 int last_sharpness_level; 33 34 uint8_t mode_ref_delta_enabled; 35 uint8_t mode_ref_delta_update; 36 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]; 40 41 // 0 = ZERO_MV, MV 42 signed char mode_deltas[MAX_MODE_LF_DELTAS]; 43 signed char last_mode_deltas[MAX_MODE_LF_DELTAS]; 44 }; 45 46 // Need to align this structure so when it is declared and 47 // passed it can be loaded into vector registers. 48 typedef struct { 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]); 52 } loop_filter_thresh; 53 54 typedef struct { 55 loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1]; 56 uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS]; 57 uint8_t mode_lf_lut[MB_MODE_COUNT]; 58 } loop_filter_info_n; 59 60 /* assorted loopfilter functions which get used elsewhere */ 61 struct VP9Common; 62 struct macroblockd; 63 64 void vp9_loop_filter_init(struct VP9Common *cm); 65 66 // Update the loop filter for the current frame. 67 // This should be called before vp9_loop_filter_rows(), vp9_loop_filter_frame() 68 // calls this function directly. 69 void vp9_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl); 70 71 void vp9_loop_filter_frame(struct VP9Common *cm, 72 struct macroblockd *mbd, 73 int filter_level, 74 int y_only, int partial); 75 76 // Apply the loop filter to [start, stop) macro block rows in frame_buffer. 77 void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer, 78 struct VP9Common *cm, struct macroblockd *xd, 79 int start, int stop, int y_only); 80 81 typedef struct LoopFilterWorkerData { 82 const YV12_BUFFER_CONFIG *frame_buffer; 83 struct VP9Common *cm; 84 struct macroblockd xd; // TODO(jzern): most of this is unnecessary to the 85 // loopfilter. the planes are necessary as their state 86 // is changed during decode. 87 int start; 88 int stop; 89 int y_only; 90 } LFWorkerData; 91 92 // Operates on the rows described by LFWorkerData passed as 'arg1'. 93 int vp9_loop_filter_worker(void *arg1, void *arg2); 94 #endif // VP9_COMMON_VP9_LOOPFILTER_H_ 95