Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_denoiser.c

Issue 390713002: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: libvpx: Pull from upstream Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_thread.c ('k') | source/libvpx/vp9/encoder/vp9_encodeframe.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 BLOCK_SIZE bs, 183 BLOCK_SIZE bs,
184 int increase_denoising, 184 int increase_denoising,
185 int mi_row, 185 int mi_row,
186 int mi_col) { 186 int mi_col) {
187 int mv_col, mv_row; 187 int mv_col, mv_row;
188 int sse_diff = denoiser->zero_mv_sse - denoiser->best_sse; 188 int sse_diff = denoiser->zero_mv_sse - denoiser->best_sse;
189 MV_REFERENCE_FRAME frame; 189 MV_REFERENCE_FRAME frame;
190 MACROBLOCKD *filter_mbd = &mb->e_mbd; 190 MACROBLOCKD *filter_mbd = &mb->e_mbd;
191 MB_MODE_INFO *mbmi = &filter_mbd->mi[0]->mbmi; 191 MB_MODE_INFO *mbmi = &filter_mbd->mi[0]->mbmi;
192 192
193 MB_MODE_INFO saved_mbmi;
194 int i, j;
195 struct buf_2d saved_dst[MAX_MB_PLANE];
196 struct buf_2d saved_pre[MAX_MB_PLANE][2]; // 2 pre buffers
197
193 // We will restore these after motion compensation. 198 // We will restore these after motion compensation.
194 MB_MODE_INFO saved_mbmi = *mbmi; 199 saved_mbmi = *mbmi;
195 struct buf_2d saved_dst = filter_mbd->plane[0].dst; 200 for (i = 0; i < MAX_MB_PLANE; ++i) {
196 struct buf_2d saved_pre[2]; 201 for (j = 0; j < 2; ++j) {
197 saved_pre[0] = filter_mbd->plane[0].pre[0]; 202 saved_pre[i][j] = filter_mbd->plane[i].pre[j];
198 saved_pre[1] = filter_mbd->plane[0].pre[1]; 203 }
204 saved_dst[i] = filter_mbd->plane[i].dst;
205 }
199 206
200 mv_col = denoiser->best_sse_mv.as_mv.col; 207 mv_col = denoiser->best_sse_mv.as_mv.col;
201 mv_row = denoiser->best_sse_mv.as_mv.row; 208 mv_row = denoiser->best_sse_mv.as_mv.row;
202 209
203 frame = denoiser->best_reference_frame; 210 frame = denoiser->best_reference_frame;
204 211
205 // If the best reference frame uses inter-prediction and there is enough of a 212 // If the best reference frame uses inter-prediction and there is enough of a
206 // difference in sum-squared-error, use it. 213 // difference in sum-squared-error, use it.
207 if (frame != INTRA_FRAME && 214 if (frame != INTRA_FRAME &&
208 sse_diff > sse_diff_thresh(bs, increase_denoising, mv_row, mv_col)) { 215 sse_diff > sse_diff_thresh(bs, increase_denoising, mv_row, mv_col)) {
209 mbmi->ref_frame[0] = denoiser->best_reference_frame; 216 mbmi->ref_frame[0] = denoiser->best_reference_frame;
210 mbmi->mode = denoiser->best_sse_inter_mode; 217 mbmi->mode = denoiser->best_sse_inter_mode;
211 mbmi->mv[0] = denoiser->best_sse_mv; 218 mbmi->mv[0] = denoiser->best_sse_mv;
212 } else { 219 } else {
213 // Otherwise, use the zero reference frame. 220 // Otherwise, use the zero reference frame.
214 frame = denoiser->best_zeromv_reference_frame; 221 frame = denoiser->best_zeromv_reference_frame;
215 222
216 mbmi->ref_frame[0] = denoiser->best_zeromv_reference_frame; 223 mbmi->ref_frame[0] = denoiser->best_zeromv_reference_frame;
217 mbmi->mode = ZEROMV; 224 mbmi->mode = ZEROMV;
218 mbmi->mv[0].as_int = 0; 225 mbmi->mv[0].as_int = 0;
219 226
220 denoiser->best_sse_inter_mode = ZEROMV; 227 denoiser->best_sse_inter_mode = ZEROMV;
221 denoiser->best_sse_mv.as_int = 0; 228 denoiser->best_sse_mv.as_int = 0;
222 denoiser->best_sse = denoiser->zero_mv_sse; 229 denoiser->best_sse = denoiser->zero_mv_sse;
223 } 230 }
224 231
225 // Set the pointers in the MACROBLOCKD to point to the buffers in the denoiser 232 // Set the pointers in the MACROBLOCKD to point to the buffers in the denoiser
226 // struct. 233 // struct.
227 filter_mbd->plane[0].pre[0].buf = 234 for (j = 0; j < 2; ++j) {
228 block_start(denoiser->running_avg_y[frame].y_buffer, 235 filter_mbd->plane[0].pre[j].buf =
229 denoiser->running_avg_y[frame].y_stride, 236 block_start(denoiser->running_avg_y[frame].y_buffer,
230 mi_row, mi_col); 237 denoiser->running_avg_y[frame].y_stride,
231 filter_mbd->plane[0].pre[0].stride = denoiser->running_avg_y[frame].y_stride; 238 mi_row, mi_col);
232 239 filter_mbd->plane[0].pre[j].stride =
233 filter_mbd->plane[1].pre[0].buf = 240 denoiser->running_avg_y[frame].y_stride;
234 block_start(denoiser->running_avg_y[frame].u_buffer, 241 filter_mbd->plane[1].pre[j].buf =
235 denoiser->running_avg_y[frame].uv_stride, 242 block_start(denoiser->running_avg_y[frame].u_buffer,
236 mi_row, mi_col); 243 denoiser->running_avg_y[frame].uv_stride,
237 filter_mbd->plane[1].pre[0].stride = denoiser->running_avg_y[frame].uv_stride; 244 mi_row, mi_col);
238 245 filter_mbd->plane[1].pre[j].stride =
239 filter_mbd->plane[2].pre[0].buf = 246 denoiser->running_avg_y[frame].uv_stride;
240 block_start(denoiser->running_avg_y[frame].v_buffer, 247 filter_mbd->plane[2].pre[j].buf =
241 denoiser->running_avg_y[frame].uv_stride, 248 block_start(denoiser->running_avg_y[frame].v_buffer,
242 mi_row, mi_col); 249 denoiser->running_avg_y[frame].uv_stride,
243 filter_mbd->plane[2].pre[0].stride = denoiser->running_avg_y[frame].uv_stride; 250 mi_row, mi_col);
244 251 filter_mbd->plane[2].pre[j].stride =
245 filter_mbd->plane[0].pre[1].buf = 252 denoiser->running_avg_y[frame].uv_stride;
246 block_start(denoiser->running_avg_y[frame].y_buffer, 253 }
247 denoiser->running_avg_y[frame].y_stride,
248 mi_row, mi_col);
249 filter_mbd->plane[0].pre[1].stride = denoiser->running_avg_y[frame].y_stride;
250
251 filter_mbd->plane[1].pre[1].buf =
252 block_start(denoiser->running_avg_y[frame].u_buffer,
253 denoiser->running_avg_y[frame].uv_stride,
254 mi_row, mi_col);
255 filter_mbd->plane[1].pre[1].stride = denoiser->running_avg_y[frame].uv_stride;
256
257 filter_mbd->plane[2].pre[1].buf =
258 block_start(denoiser->running_avg_y[frame].v_buffer,
259 denoiser->running_avg_y[frame].uv_stride,
260 mi_row, mi_col);
261 filter_mbd->plane[2].pre[1].stride = denoiser->running_avg_y[frame].uv_stride;
262
263 filter_mbd->plane[0].dst.buf = 254 filter_mbd->plane[0].dst.buf =
264 block_start(denoiser->mc_running_avg_y.y_buffer, 255 block_start(denoiser->mc_running_avg_y.y_buffer,
265 denoiser->mc_running_avg_y.y_stride, 256 denoiser->mc_running_avg_y.y_stride,
266 mi_row, mi_col); 257 mi_row, mi_col);
267 filter_mbd->plane[0].dst.stride = denoiser->mc_running_avg_y.y_stride; 258 filter_mbd->plane[0].dst.stride = denoiser->mc_running_avg_y.y_stride;
268
269 filter_mbd->plane[1].dst.buf = 259 filter_mbd->plane[1].dst.buf =
270 block_start(denoiser->mc_running_avg_y.u_buffer, 260 block_start(denoiser->mc_running_avg_y.u_buffer,
271 denoiser->mc_running_avg_y.uv_stride, 261 denoiser->mc_running_avg_y.uv_stride,
272 mi_row, mi_col); 262 mi_row, mi_col);
273 filter_mbd->plane[1].dst.stride = denoiser->mc_running_avg_y.y_stride; 263 filter_mbd->plane[1].dst.stride = denoiser->mc_running_avg_y.uv_stride;
274
275 filter_mbd->plane[2].dst.buf = 264 filter_mbd->plane[2].dst.buf =
276 block_start(denoiser->mc_running_avg_y.v_buffer, 265 block_start(denoiser->mc_running_avg_y.v_buffer,
277 denoiser->mc_running_avg_y.uv_stride, 266 denoiser->mc_running_avg_y.uv_stride,
278 mi_row, mi_col); 267 mi_row, mi_col);
279 filter_mbd->plane[2].dst.stride = denoiser->mc_running_avg_y.y_stride; 268 filter_mbd->plane[2].dst.stride = denoiser->mc_running_avg_y.uv_stride;
280 269
281 vp9_build_inter_predictors_sby(filter_mbd, mv_row, mv_col, bs); 270 vp9_build_inter_predictors_sby(filter_mbd, mv_row, mv_col, bs);
282 271
283 // Restore everything to its original state 272 // Restore everything to its original state
284 filter_mbd->plane[0].pre[0] = saved_pre[0];
285 filter_mbd->plane[0].pre[1] = saved_pre[1];
286 filter_mbd->plane[0].dst = saved_dst;
287 *mbmi = saved_mbmi; 273 *mbmi = saved_mbmi;
274 for (i = 0; i < MAX_MB_PLANE; ++i) {
275 for (j = 0; j < 2; ++j) {
276 filter_mbd->plane[i].pre[j] = saved_pre[i][j];
277 }
278 filter_mbd->plane[i].dst = saved_dst[i];
279 }
288 280
289 mv_row = denoiser->best_sse_mv.as_mv.row; 281 mv_row = denoiser->best_sse_mv.as_mv.row;
290 mv_col = denoiser->best_sse_mv.as_mv.col; 282 mv_col = denoiser->best_sse_mv.as_mv.col;
291 283
292 if (denoiser->best_sse > sse_thresh(bs, increase_denoising)) { 284 if (denoiser->best_sse > sse_thresh(bs, increase_denoising)) {
293 return COPY_BLOCK; 285 return COPY_BLOCK;
294 } 286 }
295 if (mv_row * mv_row + mv_col * mv_col > 287 if (mv_row * mv_row + mv_col * mv_col >
296 8 * noise_motion_thresh(bs, increase_denoising)) { 288 8 * noise_motion_thresh(bs, increase_denoising)) {
297 return COPY_BLOCK; 289 return COPY_BLOCK;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 for (r = 0; r < yuv->uv_height / 2; ++r) { 440 for (r = 0; r < yuv->uv_height / 2; ++r) {
449 for (c = 0; c < yuv->uv_width / 2; ++c) { 441 for (c = 0; c < yuv->uv_width / 2; ++c) {
450 u[c] = UINT8_MAX / 2; 442 u[c] = UINT8_MAX / 2;
451 v[c] = UINT8_MAX / 2; 443 v[c] = UINT8_MAX / 2;
452 } 444 }
453 u += yuv->uv_stride + yuv->uv_width / 2; 445 u += yuv->uv_stride + yuv->uv_width / 2;
454 v += yuv->uv_stride + yuv->uv_width / 2; 446 v += yuv->uv_stride + yuv->uv_width / 2;
455 } 447 }
456 } 448 }
457 #endif 449 #endif
OLDNEW
« no previous file with comments | « source/libvpx/vp9/decoder/vp9_thread.c ('k') | source/libvpx/vp9/encoder/vp9_encodeframe.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698