Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <assert.h> |
| 13 | #include <limits.h> |
| 14 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | #include "./aom_scale_rtcd.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 16 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 17 | #include "aom_dsp/aom_dsp_common.h" |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 18 | #include "aom_dsp/psnr.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | #include "aom_mem/aom_mem.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 20 | #include "aom_ports/mem.h" |
| 21 | |
Tom Finegan | 17ce8b1 | 2017-02-08 12:46:31 -0800 | [diff] [blame] | 22 | #include "av1/common/av1_loopfilter.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | #include "av1/common/onyxc_int.h" |
| 24 | #include "av1/common/quant_common.h" |
| 25 | |
Tom Finegan | 17ce8b1 | 2017-02-08 12:46:31 -0800 | [diff] [blame] | 26 | #include "av1/encoder/av1_quantize.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 27 | #include "av1/encoder/encoder.h" |
| 28 | #include "av1/encoder/picklpf.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 29 | |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 30 | #if CONFIG_LPF_SB && !CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 31 | #if CONFIG_HIGHBITDEPTH |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 32 | static int compute_sb_y_sse_highbd(const YV12_BUFFER_CONFIG *src, |
| 33 | const YV12_BUFFER_CONFIG *frame, |
| 34 | AV1_COMMON *const cm, int mi_row, |
| 35 | int mi_col) { |
| 36 | int sse = 0; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 37 | const int mi_row_start = AOMMAX(0, mi_row - FILT_BOUNDARY_MI_OFFSET); |
| 38 | const int mi_col_start = AOMMAX(0, mi_col - FILT_BOUNDARY_MI_OFFSET); |
| 39 | const int mi_row_range = mi_row - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE; |
| 40 | const int mi_col_range = mi_col - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE; |
| 41 | const int mi_row_end = AOMMIN(mi_row_range, cm->mi_rows); |
| 42 | const int mi_col_end = AOMMIN(mi_col_range, cm->mi_cols); |
| 43 | |
| 44 | const int row = mi_row_start * MI_SIZE; |
| 45 | const int col = mi_col_start * MI_SIZE; |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 46 | const uint16_t *src_y = |
| 47 | CONVERT_TO_SHORTPTR(src->y_buffer) + row * src->y_stride + col; |
| 48 | const uint16_t *frame_y = |
| 49 | CONVERT_TO_SHORTPTR(frame->y_buffer) + row * frame->y_stride + col; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 50 | const int row_end = (mi_row_end - mi_row_start) * MI_SIZE; |
| 51 | const int col_end = (mi_col_end - mi_col_start) * MI_SIZE; |
| 52 | |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 53 | int x, y; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 54 | for (y = 0; y < row_end; ++y) { |
| 55 | for (x = 0; x < col_end; ++x) { |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 56 | const int diff = src_y[x] - frame_y[x]; |
| 57 | sse += diff * diff; |
| 58 | } |
| 59 | src_y += src->y_stride; |
| 60 | frame_y += frame->y_stride; |
| 61 | } |
| 62 | return sse; |
| 63 | } |
| 64 | #endif |
| 65 | |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 66 | static int compute_sb_y_sse(const YV12_BUFFER_CONFIG *src, |
| 67 | const YV12_BUFFER_CONFIG *frame, |
| 68 | AV1_COMMON *const cm, int mi_row, int mi_col) { |
| 69 | int sse = 0; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 70 | const int mi_row_start = AOMMAX(0, mi_row - FILT_BOUNDARY_MI_OFFSET); |
| 71 | const int mi_col_start = AOMMAX(0, mi_col - FILT_BOUNDARY_MI_OFFSET); |
| 72 | const int mi_row_range = mi_row - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE; |
| 73 | const int mi_col_range = mi_col - FILT_BOUNDARY_MI_OFFSET + MAX_MIB_SIZE; |
| 74 | const int mi_row_end = AOMMIN(mi_row_range, cm->mi_rows); |
| 75 | const int mi_col_end = AOMMIN(mi_col_range, cm->mi_cols); |
| 76 | |
| 77 | const int row = mi_row_start * MI_SIZE; |
| 78 | const int col = mi_col_start * MI_SIZE; |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 79 | const uint8_t *src_y = src->y_buffer + row * src->y_stride + col; |
| 80 | const uint8_t *frame_y = frame->y_buffer + row * frame->y_stride + col; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 81 | const int row_end = (mi_row_end - mi_row_start) * MI_SIZE; |
| 82 | const int col_end = (mi_col_end - mi_col_start) * MI_SIZE; |
| 83 | |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 84 | int x, y; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 85 | for (y = 0; y < row_end; ++y) { |
| 86 | for (x = 0; x < col_end; ++x) { |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 87 | const int diff = src_y[x] - frame_y[x]; |
| 88 | sse += diff * diff; |
| 89 | } |
| 90 | src_y += src->y_stride; |
| 91 | frame_y += frame->y_stride; |
| 92 | } |
| 93 | return sse; |
| 94 | } |
| 95 | #endif // CONFIG_LPF_SB |
| 96 | |
| 97 | #if !CONFIG_LPF_SB |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 98 | static void yv12_copy_plane(const YV12_BUFFER_CONFIG *src_bc, |
| 99 | YV12_BUFFER_CONFIG *dst_bc, int plane) { |
| 100 | switch (plane) { |
| 101 | case 0: aom_yv12_copy_y(src_bc, dst_bc); break; |
| 102 | case 1: aom_yv12_copy_u(src_bc, dst_bc); break; |
| 103 | case 2: aom_yv12_copy_v(src_bc, dst_bc); break; |
| 104 | default: assert(plane >= 0 && plane <= 2); break; |
| 105 | } |
| 106 | } |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 107 | #endif // CONFIG_LPF_SB |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 108 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 109 | int av1_get_max_filter_level(const AV1_COMP *cpi) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 110 | if (cpi->oxcf.pass == 2) { |
| 111 | return cpi->twopass.section_intra_rating > 8 ? MAX_LOOP_FILTER * 3 / 4 |
| 112 | : MAX_LOOP_FILTER; |
| 113 | } else { |
| 114 | return MAX_LOOP_FILTER; |
| 115 | } |
| 116 | } |
| 117 | |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 118 | #if CONFIG_LPF_SB && !CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 119 | // TODO(chengchen): reduce memory usage by copy superblock instead of frame |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 120 | static int try_filter_superblock(const YV12_BUFFER_CONFIG *sd, |
| 121 | AV1_COMP *const cpi, int filt_level, |
| 122 | int partial_frame, int mi_row, int mi_col) { |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 123 | AV1_COMMON *const cm = &cpi->common; |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 124 | int filt_err; |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 125 | |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 126 | av1_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, filt_level, 1, |
| 127 | partial_frame, mi_row, mi_col); |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 128 | |
| 129 | #if CONFIG_HIGHBITDEPTH |
| 130 | if (cm->use_highbitdepth) { |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 131 | filt_err = |
| 132 | compute_sb_y_sse_highbd(sd, cm->frame_to_show, cm, mi_row, mi_col); |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 133 | } else { |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 134 | filt_err = compute_sb_y_sse(sd, cm->frame_to_show, cm, mi_row, mi_col); |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 135 | } |
| 136 | #else |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 137 | filt_err = compute_sb_y_sse(sd, cm->frame_to_show, cm, mi_row, mi_col); |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 138 | #endif // CONFIG_HIGHBITDEPTH |
| 139 | |
Cheng Chen | c7855b1 | 2017-09-05 10:49:08 -0700 | [diff] [blame] | 140 | // TODO(chengchen): Copy the superblock only |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 141 | // Re-instate the unfiltered frame |
| 142 | aom_yv12_copy_y(&cpi->last_frame_uf, cm->frame_to_show); |
| 143 | |
| 144 | return filt_err; |
| 145 | } |
| 146 | |
Cheng Chen | ebcee0b | 2017-12-05 12:36:01 -0800 | [diff] [blame] | 147 | int av1_search_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi, |
| 148 | int partial_frame, double *best_cost_ret, |
| 149 | int mi_row, int mi_col, int last_lvl) { |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 150 | assert(partial_frame == 1); |
| 151 | assert(last_lvl >= 0); |
| 152 | |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 153 | const AV1_COMMON *const cm = &cpi->common; |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 154 | MACROBLOCK *x = &cpi->td.mb; |
| 155 | |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 156 | int min_filter_level = AOMMAX(0, last_lvl - MAX_LPF_OFFSET); |
| 157 | int max_filter_level = |
| 158 | AOMMIN(av1_get_max_filter_level(cpi), last_lvl + MAX_LPF_OFFSET); |
| 159 | |
| 160 | // search a larger range for the start superblock |
| 161 | if (mi_row == 0 && mi_col == 0) { |
| 162 | min_filter_level = 0; |
| 163 | max_filter_level = av1_get_max_filter_level(cpi); |
| 164 | } |
| 165 | |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 166 | // TODO(chengchen): Copy for superblock only |
Cheng Chen | c7855b1 | 2017-09-05 10:49:08 -0700 | [diff] [blame] | 167 | // Make a copy of the unfiltered / processed recon buffer |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 168 | aom_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf); |
| 169 | |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 170 | int estimate_err = |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 171 | try_filter_superblock(sd, cpi, last_lvl, partial_frame, mi_row, mi_col); |
Cheng Chen | c7855b1 | 2017-09-05 10:49:08 -0700 | [diff] [blame] | 172 | |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 173 | int best_err = estimate_err; |
| 174 | int filt_best = last_lvl; |
| 175 | |
Cheng Chen | a4b27de | 2017-08-31 16:05:19 -0700 | [diff] [blame] | 176 | int i; |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 177 | for (i = min_filter_level; i <= max_filter_level; i += LPF_STEP) { |
Cheng Chen | c7855b1 | 2017-09-05 10:49:08 -0700 | [diff] [blame] | 178 | if (i == last_lvl) continue; |
| 179 | |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 180 | int filt_err = |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 181 | try_filter_superblock(sd, cpi, i, partial_frame, mi_row, mi_col); |
| 182 | |
Cheng Chen | a4b27de | 2017-08-31 16:05:19 -0700 | [diff] [blame] | 183 | if (filt_err < best_err) { |
| 184 | best_err = filt_err; |
| 185 | filt_best = i; |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 186 | } |
| 187 | } |
| 188 | |
Cheng Chen | c7855b1 | 2017-09-05 10:49:08 -0700 | [diff] [blame] | 189 | // If previous sb filter level has similar filtering performance as current |
| 190 | // best filter level, use previous level such that we can only send one bit |
| 191 | // to indicate current filter level is the same as the previous. |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 192 | int threshold = 400; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 193 | |
| 194 | // ratio = the filtering area / a superblock size |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 195 | int ratio = 1; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 196 | if (mi_row + MAX_MIB_SIZE > cm->mi_rows) { |
| 197 | ratio *= (cm->mi_rows - mi_row); |
| 198 | } else { |
| 199 | if (mi_row == 0) { |
| 200 | ratio *= (MAX_MIB_SIZE - FILT_BOUNDARY_MI_OFFSET); |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 201 | } else { |
| 202 | ratio *= MAX_MIB_SIZE; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 203 | } |
| 204 | } |
| 205 | if (mi_col + MAX_MIB_SIZE > cm->mi_cols) { |
| 206 | ratio *= (cm->mi_cols - mi_col); |
| 207 | } else { |
| 208 | if (mi_col == 0) { |
| 209 | ratio *= (MAX_MIB_SIZE - FILT_BOUNDARY_MI_OFFSET); |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 210 | } else { |
| 211 | ratio *= MAX_MIB_SIZE; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | threshold = threshold * ratio / (MAX_MIB_SIZE * MAX_MIB_SIZE); |
| 215 | |
Cheng Chen | f89ca3e | 2017-09-07 14:47:47 -0700 | [diff] [blame] | 216 | const int diff = abs(estimate_err - best_err); |
| 217 | |
| 218 | const int percent_thresh = (int)((double)estimate_err * 0.01); |
| 219 | threshold = AOMMAX(threshold, percent_thresh); |
| 220 | if (diff < threshold) { |
Cheng Chen | c7855b1 | 2017-09-05 10:49:08 -0700 | [diff] [blame] | 221 | best_err = estimate_err; |
| 222 | filt_best = last_lvl; |
| 223 | } |
| 224 | |
Cheng Chen | 15f6b86 | 2017-09-08 16:56:07 -0700 | [diff] [blame] | 225 | // Compute rdcost to determine whether to reuse previous filter lvl |
| 226 | if (filt_best != last_lvl) { |
| 227 | } |
| 228 | |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 229 | if (best_cost_ret) *best_cost_ret = RDCOST_DBL(x->rdmult, 0, best_err); |
| 230 | return filt_best; |
| 231 | } |
| 232 | |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 233 | #elif !CONFIG_LPF_SB // CONFIG_LPF_SB |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 234 | static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 235 | AV1_COMP *const cpi, int filt_level, |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 236 | int partial_frame |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 237 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 238 | , |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 239 | int plane, int dir |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 240 | #endif |
| 241 | ) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 242 | AV1_COMMON *const cm = &cpi->common; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 243 | int64_t filt_err; |
| 244 | |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 245 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 246 | assert(plane >= 0 && plane <= 2); |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 247 | int filter_level[2] = { filt_level, filt_level }; |
| 248 | if (plane == 0 && dir == 0) filter_level[1] = cm->lf.filter_level[1]; |
| 249 | if (plane == 0 && dir == 1) filter_level[0] = cm->lf.filter_level[0]; |
| 250 | |
| 251 | av1_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, |
| 252 | filter_level[0], filter_level[1], plane, partial_frame); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 253 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 254 | av1_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, filt_level, 1, |
| 255 | partial_frame); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 256 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 257 | |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 258 | int highbd = 0; |
| 259 | #if CONFIG_HIGHBITDEPTH |
| 260 | highbd = cm->use_highbitdepth; |
| 261 | #endif // CONFIG_HIGHBITDEPTH |
| 262 | |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 263 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 264 | filt_err = aom_get_sse_plane(sd, cm->frame_to_show, plane, highbd); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 265 | |
| 266 | // Re-instate the unfiltered frame |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 267 | yv12_copy_plane(&cpi->last_frame_uf, cm->frame_to_show, plane); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 268 | #else |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 269 | filt_err = aom_get_sse_plane(sd, cm->frame_to_show, 0, highbd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 270 | |
| 271 | // Re-instate the unfiltered frame |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 272 | yv12_copy_plane(&cpi->last_frame_uf, cm->frame_to_show, 0); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 273 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 274 | |
| 275 | return filt_err; |
| 276 | } |
| 277 | |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 278 | static int search_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi, |
| 279 | int partial_frame, double *best_cost_ret |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 280 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 281 | , |
| 282 | int plane, int dir |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 283 | #endif |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 284 | ) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 285 | const AV1_COMMON *const cm = &cpi->common; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 286 | const struct loopfilter *const lf = &cm->lf; |
| 287 | const int min_filter_level = 0; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 288 | const int max_filter_level = av1_get_max_filter_level(cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 289 | int filt_direction = 0; |
| 290 | int64_t best_err; |
| 291 | int filt_best; |
| 292 | MACROBLOCK *x = &cpi->td.mb; |
| 293 | |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 294 | // Start the search at the previous frame filter level unless it is now out of |
| 295 | // range. |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 296 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 297 | int lvl; |
| 298 | switch (plane) { |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 299 | case 0: lvl = (dir == 1) ? lf->filter_level[1] : lf->filter_level[0]; break; |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 300 | case 1: lvl = lf->filter_level_u; break; |
| 301 | case 2: lvl = lf->filter_level_v; break; |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 302 | default: assert(plane >= 0 && plane <= 2); return 0; |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 303 | } |
| 304 | int filt_mid = clamp(lvl, min_filter_level, max_filter_level); |
| 305 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 306 | int filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 307 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 308 | int filter_step = filt_mid < 16 ? 4 : filt_mid / 4; |
| 309 | // Sum squared error at each filter level |
| 310 | int64_t ss_err[MAX_LOOP_FILTER + 1]; |
| 311 | |
| 312 | // Set each entry to -1 |
| 313 | memset(ss_err, 0xFF, sizeof(ss_err)); |
| 314 | |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 315 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 9efbaf9 | 2017-07-27 14:09:59 -0700 | [diff] [blame] | 316 | yv12_copy_plane(cm->frame_to_show, &cpi->last_frame_uf, plane); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 317 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 318 | // Make a copy of the unfiltered / processed recon buffer |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 319 | aom_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 320 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 321 | |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 322 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 323 | best_err = try_filter_frame(sd, cpi, filt_mid, partial_frame, plane, dir); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 324 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 325 | best_err = try_filter_frame(sd, cpi, filt_mid, partial_frame); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 326 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 327 | filt_best = filt_mid; |
| 328 | ss_err[filt_mid] = best_err; |
| 329 | |
| 330 | while (filter_step > 0) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 331 | const int filt_high = AOMMIN(filt_mid + filter_step, max_filter_level); |
| 332 | const int filt_low = AOMMAX(filt_mid - filter_step, min_filter_level); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 333 | |
| 334 | // Bias against raising loop filter in favor of lowering it. |
| 335 | int64_t bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; |
| 336 | |
| 337 | if ((cpi->oxcf.pass == 2) && (cpi->twopass.section_intra_rating < 20)) |
| 338 | bias = (bias * cpi->twopass.section_intra_rating) / 20; |
| 339 | |
| 340 | // yx, bias less for large block size |
| 341 | if (cm->tx_mode != ONLY_4X4) bias >>= 1; |
| 342 | |
| 343 | if (filt_direction <= 0 && filt_low != filt_mid) { |
| 344 | // Get Low filter error score |
| 345 | if (ss_err[filt_low] < 0) { |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 346 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 347 | ss_err[filt_low] = |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 348 | try_filter_frame(sd, cpi, filt_low, partial_frame, plane, dir); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 349 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 350 | ss_err[filt_low] = try_filter_frame(sd, cpi, filt_low, partial_frame); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 351 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 352 | } |
| 353 | // If value is close to the best so far then bias towards a lower loop |
| 354 | // filter value. |
| 355 | if (ss_err[filt_low] < (best_err + bias)) { |
| 356 | // Was it actually better than the previous best? |
| 357 | if (ss_err[filt_low] < best_err) { |
| 358 | best_err = ss_err[filt_low]; |
| 359 | } |
| 360 | filt_best = filt_low; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | // Now look at filt_high |
| 365 | if (filt_direction >= 0 && filt_high != filt_mid) { |
| 366 | if (ss_err[filt_high] < 0) { |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 367 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 368 | ss_err[filt_high] = |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 369 | try_filter_frame(sd, cpi, filt_high, partial_frame, plane, dir); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 370 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 371 | ss_err[filt_high] = try_filter_frame(sd, cpi, filt_high, partial_frame); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 372 | #endif // CONFIG_LOOPFILTER_LEVEL |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 373 | } |
| 374 | // If value is significantly better than previous best, bias added against |
| 375 | // raising filter value |
| 376 | if (ss_err[filt_high] < (best_err - bias)) { |
| 377 | best_err = ss_err[filt_high]; |
| 378 | filt_best = filt_high; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | // Half the step distance if the best filter value was the same as last time |
| 383 | if (filt_best == filt_mid) { |
| 384 | filter_step /= 2; |
| 385 | filt_direction = 0; |
| 386 | } else { |
| 387 | filt_direction = (filt_best < filt_mid) ? -1 : 1; |
| 388 | filt_mid = filt_best; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // Update best error |
| 393 | best_err = ss_err[filt_best]; |
| 394 | |
Urvang Joshi | 70006e4 | 2017-06-14 16:08:55 -0700 | [diff] [blame] | 395 | if (best_cost_ret) *best_cost_ret = RDCOST_DBL(x->rdmult, 0, best_err); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 396 | return filt_best; |
| 397 | } |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 398 | #endif // CONFIG_LPF_SB |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 399 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 400 | void av1_pick_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi, |
| 401 | LPF_PICK_METHOD method) { |
| 402 | AV1_COMMON *const cm = &cpi->common; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 403 | struct loopfilter *const lf = &cm->lf; |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 404 | (void)sd; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 405 | |
| 406 | lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0 : cpi->oxcf.sharpness; |
| 407 | |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 408 | if (method == LPF_PICK_MINIMAL_LPF) { |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 409 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 410 | lf->filter_level[0] = 0; |
| 411 | lf->filter_level[1] = 0; |
| 412 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 413 | lf->filter_level = 0; |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 414 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 415 | } else if (method >= LPF_PICK_FROM_Q) { |
| 416 | const int min_filter_level = 0; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 417 | const int max_filter_level = av1_get_max_filter_level(cpi); |
Monty Montgomery | 60f2a22 | 2017-11-01 19:48:38 -0400 | [diff] [blame] | 418 | const int q = av1_ac_quant_Q3(cm->base_qindex, 0, cm->bit_depth); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 419 | // These values were determined by linear fitting the result of the |
Alexander Bokov | ac504f7 | 2017-10-10 13:15:13 -0700 | [diff] [blame] | 420 | // searched level for 8 bit depth: |
| 421 | // Keyframes: filt_guess = q * 0.06699 - 1.60817 |
| 422 | // Other frames: filt_guess = q * 0.02295 + 2.48225 |
| 423 | // |
| 424 | // And high bit depth separately: |
| 425 | // filt_guess = q * 0.316206 + 3.87252 |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 426 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 427 | int filt_guess; |
| 428 | switch (cm->bit_depth) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 429 | case AOM_BITS_8: |
Alexander Bokov | ac504f7 | 2017-10-10 13:15:13 -0700 | [diff] [blame] | 430 | filt_guess = (cm->frame_type == KEY_FRAME) |
| 431 | ? ROUND_POWER_OF_TWO(q * 17563 - 421574, 18) |
| 432 | : ROUND_POWER_OF_TWO(q * 6017 + 650707, 18); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 433 | break; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 434 | case AOM_BITS_10: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 435 | filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 4060632, 20); |
| 436 | break; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 437 | case AOM_BITS_12: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 438 | filt_guess = ROUND_POWER_OF_TWO(q * 20723 + 16242526, 22); |
| 439 | break; |
| 440 | default: |
| 441 | assert(0 && |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 442 | "bit_depth should be AOM_BITS_8, AOM_BITS_10 " |
| 443 | "or AOM_BITS_12"); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 444 | return; |
| 445 | } |
| 446 | #else |
Alexander Bokov | ac504f7 | 2017-10-10 13:15:13 -0700 | [diff] [blame] | 447 | int filt_guess = (cm->frame_type == KEY_FRAME) |
| 448 | ? ROUND_POWER_OF_TWO(q * 17563 - 421574, 18) |
| 449 | : ROUND_POWER_OF_TWO(q * 6017 + 650707, 18); |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 450 | #endif // CONFIG_HIGHBITDEPTH |
Alexander Bokov | ac504f7 | 2017-10-10 13:15:13 -0700 | [diff] [blame] | 451 | if (cm->bit_depth != AOM_BITS_8 && cm->frame_type == KEY_FRAME) |
| 452 | filt_guess -= 4; |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 453 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 454 | // TODO(chengchen): retrain the model for Y, U, V filter levels |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 455 | lf->filter_level[0] = clamp(filt_guess, min_filter_level, max_filter_level); |
| 456 | lf->filter_level[1] = clamp(filt_guess, min_filter_level, max_filter_level); |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 457 | lf->filter_level_u = clamp(filt_guess, min_filter_level, max_filter_level); |
| 458 | lf->filter_level_v = clamp(filt_guess, min_filter_level, max_filter_level); |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 459 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 460 | lf->filter_level = clamp(filt_guess, min_filter_level, max_filter_level); |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 461 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 462 | } else { |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 463 | #if CONFIG_LPF_SB && !CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 464 | int mi_row, mi_col; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 465 | // TODO(chengchen): init last_lvl using previous frame's info? |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 466 | int last_lvl = 0; |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 467 | // TODO(chengchen): if the frame size makes the last superblock very small, |
| 468 | // consider merge it to the previous superblock to save bits. |
| 469 | // Example, if frame size 1080x720, then in the last row of superblock, |
| 470 | // there're (FILT_BOUNDAR_OFFSET + 16) pixels. |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 471 | for (mi_row = 0; mi_row < cm->mi_rows; mi_row += MAX_MIB_SIZE) { |
| 472 | for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MAX_MIB_SIZE) { |
Cheng Chen | ebcee0b | 2017-12-05 12:36:01 -0800 | [diff] [blame] | 473 | #if CONFIG_LPF_SB |
| 474 | int lvl = |
| 475 | av1_search_filter_level(sd, cpi, 1, NULL, mi_row, mi_col, last_lvl); |
| 476 | #else |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 477 | int lvl = |
| 478 | search_filter_level(sd, cpi, 1, NULL, mi_row, mi_col, last_lvl); |
Cheng Chen | ebcee0b | 2017-12-05 12:36:01 -0800 | [diff] [blame] | 479 | #endif |
Cheng Chen | 5589d71 | 2017-09-05 12:03:25 -0700 | [diff] [blame] | 480 | |
| 481 | av1_loop_filter_sb_level_init(cm, mi_row, mi_col, lvl); |
Cheng Chen | a4b27de | 2017-08-31 16:05:19 -0700 | [diff] [blame] | 482 | |
| 483 | // For the superblock at row start, its previous filter level should be |
| 484 | // the one above it, not the one at the end of last row |
| 485 | if (mi_col + MAX_MIB_SIZE >= cm->mi_cols) { |
| 486 | last_lvl = cm->mi_grid_visible[mi_row * cm->mi_stride]->mbmi.filt_lvl; |
| 487 | } else { |
| 488 | last_lvl = lvl; |
| 489 | } |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 490 | } |
| 491 | } |
Cheng Chen | 765e34e | 2017-12-11 11:43:35 -0800 | [diff] [blame^] | 492 | #elif !CONFIG_LPF_SB // !CONFIG_LPF_SB |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 493 | #if CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 494 | lf->filter_level[0] = lf->filter_level[1] = search_filter_level( |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 495 | sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL, 0, 2); |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 496 | lf->filter_level[0] = search_filter_level( |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 497 | sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL, 0, 0); |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 498 | lf->filter_level[1] = search_filter_level( |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 499 | sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL, 0, 1); |
| 500 | |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 501 | lf->filter_level_u = search_filter_level( |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 502 | sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL, 1, 0); |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 503 | lf->filter_level_v = search_filter_level( |
Cheng Chen | 179479f | 2017-08-04 10:56:39 -0700 | [diff] [blame] | 504 | sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL, 2, 0); |
Cheng Chen | e94df5c | 2017-07-19 17:25:33 -0700 | [diff] [blame] | 505 | #else |
Cheng Chen | 1545bdb | 2017-09-05 16:32:12 -0700 | [diff] [blame] | 506 | lf->filter_level = |
| 507 | search_filter_level(sd, cpi, method == LPF_PICK_FROM_SUBIMAGE, NULL); |
Cheng Chen | 13fc819 | 2017-08-19 11:49:28 -0700 | [diff] [blame] | 508 | #endif // CONFIG_LOOPFILTER_LEVEL |
Cheng Chen | f572cd3 | 2017-08-25 18:34:51 -0700 | [diff] [blame] | 509 | #endif // CONFIG_LPF_SB |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 510 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 511 | } |