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, 50 mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]); 51 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, 52 lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]); 53 DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, 54 hev_thr[4][SIMD_WIDTH]); 55 uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS]; 56 uint8_t mode_lf_lut[MB_MODE_COUNT]; 57 } loop_filter_info_n; 58 59 /* assorted loopfilter functions which get used elsewhere */ 60 struct VP9Common; 61 struct macroblockd; 62 63 void vp9_loop_filter_init(struct VP9Common *cm); 64 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); 69 70 void vp9_loop_filter_frame(struct VP9Common *cm, 71 struct macroblockd *mbd, 72 int filter_level, 73 int y_only, int partial); 74 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); 79 80 typedef struct LoopFilterWorkerData { 81 const YV12_BUFFER_CONFIG *frame_buffer; 82 struct VP9Common *cm; 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. 86 int start; 87 int stop; 88 int y_only; 89 } LFWorkerData; 90 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_ 94