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.
15 #include "./vpx_config.h"
16 #include "./vpx_scale_rtcd.h"
17 #include "./vp9_rtcd.h"
19 #include "vpx_scale/vpx_scale.h"
20 #include "vpx_scale/yv12config.h"
22 #if CONFIG_VP9_HIGHBITDEPTH
23 #include "vp9/common/vp9_common.h"
25 #include "vp9/common/vp9_onyxc_int.h"
26 #include "vp9/common/vp9_postproc.h"
27 #include "vp9/common/vp9_systemdependent.h"
28 #include "vp9/common/vp9_textblit.h"
30 #if CONFIG_VP9_POSTPROC
31 static const short kernel5[] = {
35 const short vp9_rv[] = {
36 8, 5, 2, 2, 8, 12, 4, 9, 8, 3,
37 0, 3, 9, 0, 0, 0, 8, 3, 14, 4,
38 10, 1, 11, 14, 1, 14, 9, 6, 12, 11,
39 8, 6, 10, 0, 0, 8, 9, 0, 3, 14,
40 8, 11, 13, 4, 2, 9, 0, 3, 9, 6,
41 1, 2, 3, 14, 13, 1, 8, 2, 9, 7,
42 3, 3, 1, 13, 13, 6, 6, 5, 2, 7,
43 11, 9, 11, 8, 7, 3, 2, 0, 13, 13,
44 14, 4, 12, 5, 12, 10, 8, 10, 13, 10,
45 4, 14, 4, 10, 0, 8, 11, 1, 13, 7,
46 7, 14, 6, 14, 13, 2, 13, 5, 4, 4,
47 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
48 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
49 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
50 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
51 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
52 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
53 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
54 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
55 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
56 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
57 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
58 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
59 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
60 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
61 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
62 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
63 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
64 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
65 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
66 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
67 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
68 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
69 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
70 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
71 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
72 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
73 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
74 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
75 3, 8, 3, 7, 8, 5, 11, 4, 12, 3,
76 11, 9, 14, 8, 14, 13, 4, 3, 1, 2,
77 14, 6, 5, 4, 4, 11, 4, 6, 2, 1,
78 5, 8, 8, 12, 13, 5, 14, 10, 12, 13,
79 0, 9, 5, 5, 11, 10, 13, 9, 10, 13,
82 static const uint8_t q_diff_thresh = 20;
83 static const uint8_t last_q_thresh = 170;
85 void vp9_post_proc_down_and_across_c(const uint8_t *src_ptr,
87 int src_pixels_per_line,
88 int dst_pixels_per_line,
98 int pitch = src_pixels_per_line;
100 (void)dst_pixels_per_line;
102 for (row = 0; row < rows; row++) {
103 /* post_proc_down for one row */
107 for (col = 0; col < cols; col++) {
111 for (i = -2; i <= 2; i++) {
112 if (abs(v - p_src[col + i * pitch]) > flimit)
113 goto down_skip_convolve;
115 kernel += kernel5[2 + i] * p_src[col + i * pitch];
123 /* now post_proc_across */
127 for (i = 0; i < 8; i++)
130 for (col = 0; col < cols; col++) {
136 for (i = -2; i <= 2; i++) {
137 if (abs(v - p_src[col + i]) > flimit)
138 goto across_skip_convolve;
140 kernel += kernel5[2 + i] * p_src[col + i];
143 d[col & 7] = (kernel >> 3);
144 across_skip_convolve:
147 p_dst[col - 2] = d[(col - 2) & 7];
150 /* handle the last two pixels */
151 p_dst[col - 2] = d[(col - 2) & 7];
152 p_dst[col - 1] = d[(col - 1) & 7];
161 #if CONFIG_VP9_HIGHBITDEPTH
162 void vp9_highbd_post_proc_down_and_across_c(const uint16_t *src_ptr,
164 int src_pixels_per_line,
165 int dst_pixels_per_line,
169 uint16_t const *p_src;
175 int pitch = src_pixels_per_line;
178 for (row = 0; row < rows; row++) {
179 // post_proc_down for one row.
183 for (col = 0; col < cols; col++) {
187 for (i = -2; i <= 2; i++) {
188 if (abs(v - p_src[col + i * pitch]) > flimit)
189 goto down_skip_convolve;
191 kernel += kernel5[2 + i] * p_src[col + i * pitch];
200 /* now post_proc_across */
204 for (i = 0; i < 8; i++)
207 for (col = 0; col < cols; col++) {
213 for (i = -2; i <= 2; i++) {
214 if (abs(v - p_src[col + i]) > flimit)
215 goto across_skip_convolve;
217 kernel += kernel5[2 + i] * p_src[col + i];
220 d[col & 7] = (kernel >> 3);
222 across_skip_convolve:
224 p_dst[col - 2] = d[(col - 2) & 7];
227 /* handle the last two pixels */
228 p_dst[col - 2] = d[(col - 2) & 7];
229 p_dst[col - 1] = d[(col - 1) & 7];
234 dst_ptr += dst_pixels_per_line;
237 #endif // CONFIG_VP9_HIGHBITDEPTH
239 static int q2mbl(int x) {
242 x = 50 + (x - 50) * 10 / 8;
246 void vp9_mbpost_proc_across_ip_c(uint8_t *src, int pitch,
247 int rows, int cols, int flimit) {
252 for (r = 0; r < rows; r++) {
256 for (i = -8; i <= 6; i++) {
257 sumsq += s[i] * s[i];
262 for (c = 0; c < cols + 8; c++) {
263 int x = s[c + 7] - s[c - 8];
264 int y = s[c + 7] + s[c - 8];
271 if (sumsq * 15 - sum * sum < flimit) {
272 d[c & 15] = (8 + sum + s[c]) >> 4;
275 s[c - 8] = d[(c - 8) & 15];
281 #if CONFIG_VP9_HIGHBITDEPTH
282 void vp9_highbd_mbpost_proc_across_ip_c(uint16_t *src, int pitch,
283 int rows, int cols, int flimit) {
290 for (r = 0; r < rows; r++) {
294 for (i = -8; i <= 6; i++) {
295 sumsq += s[i] * s[i];
300 for (c = 0; c < cols + 8; c++) {
301 int x = s[c + 7] - s[c - 8];
302 int y = s[c + 7] + s[c - 8];
309 if (sumsq * 15 - sum * sum < flimit) {
310 d[c & 15] = (8 + sum + s[c]) >> 4;
313 s[c - 8] = d[(c - 8) & 15];
319 #endif // CONFIG_VP9_HIGHBITDEPTH
321 void vp9_mbpost_proc_down_c(uint8_t *dst, int pitch,
322 int rows, int cols, int flimit) {
324 const short *rv3 = &vp9_rv[63 & rand()]; // NOLINT
326 for (c = 0; c < cols; c++) {
327 uint8_t *s = &dst[c];
331 const short *rv2 = rv3 + ((c * 17) & 127);
333 for (i = -8; i <= 6; i++) {
334 sumsq += s[i * pitch] * s[i * pitch];
338 for (r = 0; r < rows + 8; r++) {
339 sumsq += s[7 * pitch] * s[ 7 * pitch] - s[-8 * pitch] * s[-8 * pitch];
340 sum += s[7 * pitch] - s[-8 * pitch];
343 if (sumsq * 15 - sum * sum < flimit) {
344 d[r & 15] = (rv2[r & 127] + sum + s[0]) >> 4;
347 s[-8 * pitch] = d[(r - 8) & 15];
353 #if CONFIG_VP9_HIGHBITDEPTH
354 void vp9_highbd_mbpost_proc_down_c(uint16_t *dst, int pitch,
355 int rows, int cols, int flimit) {
357 const int16_t *rv3 = &vp9_rv[63 & rand()]; // NOLINT
359 for (c = 0; c < cols; c++) {
360 uint16_t *s = &dst[c];
364 const int16_t *rv2 = rv3 + ((c * 17) & 127);
366 for (i = -8; i <= 6; i++) {
367 sumsq += s[i * pitch] * s[i * pitch];
371 for (r = 0; r < rows + 8; r++) {
372 sumsq += s[7 * pitch] * s[ 7 * pitch] - s[-8 * pitch] * s[-8 * pitch];
373 sum += s[7 * pitch] - s[-8 * pitch];
376 if (sumsq * 15 - sum * sum < flimit) {
377 d[r & 15] = (rv2[r & 127] + sum + s[0]) >> 4;
380 s[-8 * pitch] = d[(r - 8) & 15];
385 #endif // CONFIG_VP9_HIGHBITDEPTH
387 static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
388 YV12_BUFFER_CONFIG *post,
392 double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
393 int ppl = (int)(level + .5);
394 (void) low_var_thresh;
397 #if CONFIG_VP9_HIGHBITDEPTH
398 if (source->flags & YV12_FLAG_HIGHBITDEPTH) {
399 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(source->y_buffer),
400 CONVERT_TO_SHORTPTR(post->y_buffer),
401 source->y_stride, post->y_stride,
402 source->y_height, source->y_width,
405 vp9_highbd_mbpost_proc_across_ip(CONVERT_TO_SHORTPTR(post->y_buffer),
406 post->y_stride, post->y_height,
407 post->y_width, q2mbl(q));
409 vp9_highbd_mbpost_proc_down(CONVERT_TO_SHORTPTR(post->y_buffer),
410 post->y_stride, post->y_height,
411 post->y_width, q2mbl(q));
413 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(source->u_buffer),
414 CONVERT_TO_SHORTPTR(post->u_buffer),
415 source->uv_stride, post->uv_stride,
416 source->uv_height, source->uv_width,
418 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(source->v_buffer),
419 CONVERT_TO_SHORTPTR(post->v_buffer),
420 source->uv_stride, post->uv_stride,
421 source->uv_height, source->uv_width,
424 vp9_post_proc_down_and_across(source->y_buffer, post->y_buffer,
425 source->y_stride, post->y_stride,
426 source->y_height, source->y_width, ppl);
428 vp9_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
429 post->y_width, q2mbl(q));
431 vp9_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
432 post->y_width, q2mbl(q));
434 vp9_post_proc_down_and_across(source->u_buffer, post->u_buffer,
435 source->uv_stride, post->uv_stride,
436 source->uv_height, source->uv_width, ppl);
437 vp9_post_proc_down_and_across(source->v_buffer, post->v_buffer,
438 source->uv_stride, post->uv_stride,
439 source->uv_height, source->uv_width, ppl);
442 vp9_post_proc_down_and_across(source->y_buffer, post->y_buffer,
443 source->y_stride, post->y_stride,
444 source->y_height, source->y_width, ppl);
446 vp9_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
447 post->y_width, q2mbl(q));
449 vp9_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
450 post->y_width, q2mbl(q));
452 vp9_post_proc_down_and_across(source->u_buffer, post->u_buffer,
453 source->uv_stride, post->uv_stride,
454 source->uv_height, source->uv_width, ppl);
455 vp9_post_proc_down_and_across(source->v_buffer, post->v_buffer,
456 source->uv_stride, post->uv_stride,
457 source->uv_height, source->uv_width, ppl);
458 #endif // CONFIG_VP9_HIGHBITDEPTH
461 void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
463 const int ppl = (int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q
467 const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
468 const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
469 const int src_widths[3] = {src->y_width, src->uv_width, src->uv_width};
470 const int src_heights[3] = {src->y_height, src->uv_height, src->uv_height};
472 uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer};
473 const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride};
475 for (i = 0; i < MAX_MB_PLANE; ++i) {
476 #if CONFIG_VP9_HIGHBITDEPTH
477 assert((src->flags & YV12_FLAG_HIGHBITDEPTH) ==
478 (dst->flags & YV12_FLAG_HIGHBITDEPTH));
479 if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
480 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(srcs[i]),
481 CONVERT_TO_SHORTPTR(dsts[i]),
482 src_strides[i], dst_strides[i],
483 src_heights[i], src_widths[i], ppl);
485 vp9_post_proc_down_and_across(srcs[i], dsts[i],
486 src_strides[i], dst_strides[i],
487 src_heights[i], src_widths[i], ppl);
490 vp9_post_proc_down_and_across(srcs[i], dsts[i],
491 src_strides[i], dst_strides[i],
492 src_heights[i], src_widths[i], ppl);
493 #endif // CONFIG_VP9_HIGHBITDEPTH
497 void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
499 const int ppl = (int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q
503 const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
504 const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
505 const int src_widths[3] = {src->y_width, src->uv_width, src->uv_width};
506 const int src_heights[3] = {src->y_height, src->uv_height, src->uv_height};
508 uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer};
509 const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride};
511 for (i = 0; i < MAX_MB_PLANE; ++i) {
512 const int src_stride = src_strides[i];
513 const int src_width = src_widths[i] - 4;
514 const int src_height = src_heights[i] - 4;
515 const int dst_stride = dst_strides[i];
517 #if CONFIG_VP9_HIGHBITDEPTH
518 assert((src->flags & YV12_FLAG_HIGHBITDEPTH) ==
519 (dst->flags & YV12_FLAG_HIGHBITDEPTH));
520 if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
521 const uint16_t *const src = CONVERT_TO_SHORTPTR(srcs[i] + 2 * src_stride
523 uint16_t *const dst = CONVERT_TO_SHORTPTR(dsts[i] + 2 * dst_stride + 2);
524 vp9_highbd_post_proc_down_and_across(src, dst, src_stride, dst_stride,
525 src_height, src_width, ppl);
527 const uint8_t *const src = srcs[i] + 2 * src_stride + 2;
528 uint8_t *const dst = dsts[i] + 2 * dst_stride + 2;
530 vp9_post_proc_down_and_across(src, dst, src_stride, dst_stride,
531 src_height, src_width, ppl);
534 const uint8_t *const src = srcs[i] + 2 * src_stride + 2;
535 uint8_t *const dst = dsts[i] + 2 * dst_stride + 2;
536 vp9_post_proc_down_and_across(src, dst, src_stride, dst_stride,
537 src_height, src_width, ppl);
542 static double gaussian(double sigma, double mu, double x) {
543 return 1 / (sigma * sqrt(2.0 * 3.14159265)) *
544 (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
547 static void fillrd(struct postproc_state *state, int q, int a) {
551 int ai = a, qi = q, i;
553 vp9_clear_system_state();
555 sigma = ai + .5 + .6 * (63 - qi) / 63.0;
557 /* set up a lookup table of 256 entries that matches
558 * a gaussian distribution with sigma determined by q.
566 for (i = -32; i < 32; i++) {
567 int a = (int)(0.5 + 256 * gaussian(sigma, 0, i));
570 for (j = 0; j < a; j++) {
571 char_dist[next + j] = (char) i;
578 for (; next < 256; next++)
582 for (i = 0; i < 3072; i++) {
583 state->noise[i] = char_dist[rand() & 0xff]; // NOLINT
586 for (i = 0; i < 16; i++) {
587 state->blackclamp[i] = -char_dist[0];
588 state->whiteclamp[i] = -char_dist[0];
589 state->bothclamp[i] = -2 * char_dist[0];
593 state->last_noise = a;
596 void vp9_plane_add_noise_c(uint8_t *start, char *noise,
600 unsigned int width, unsigned int height, int pitch) {
603 // TODO(jbb): why does simd code use both but c doesn't, normalize and
606 for (i = 0; i < height; i++) {
607 uint8_t *pos = start + i * pitch;
608 char *ref = (char *)(noise + (rand() & 0xff)); // NOLINT
610 for (j = 0; j < width; j++) {
611 if (pos[j] < blackclamp[0])
612 pos[j] = blackclamp[0];
614 if (pos[j] > 255 + whiteclamp[0])
615 pos[j] = 255 + whiteclamp[0];
622 static void swap_mi_and_prev_mi(VP9_COMMON *cm) {
623 // Current mip will be the prev_mip for the next frame.
624 MODE_INFO *temp = cm->postproc_state.prev_mip;
625 cm->postproc_state.prev_mip = cm->mip;
628 // Update the upper left visible macroblock ptrs.
629 cm->mi = cm->mip + cm->mi_stride + 1;
630 cm->postproc_state.prev_mi = cm->postproc_state.prev_mip + cm->mi_stride + 1;
633 int vp9_post_proc_frame(struct VP9Common *cm,
634 YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *ppflags) {
635 const int q = MIN(63, cm->lf.filter_level * 10 / 6);
636 const int flags = ppflags->post_proc_flag;
637 YV12_BUFFER_CONFIG *const ppbuf = &cm->post_proc_buffer;
638 struct postproc_state *const ppstate = &cm->postproc_state;
640 if (!cm->frame_to_show)
644 *dest = *cm->frame_to_show;
648 vp9_clear_system_state();
650 // Alloc memory for prev_mip in the first frame.
651 if (cm->current_video_frame == 1) {
652 cm->postproc_state.last_base_qindex = cm->base_qindex;
653 cm->postproc_state.last_frame_valid = 1;
654 ppstate->prev_mip = vpx_calloc(cm->mi_alloc_size, sizeof(*cm->mip));
655 if (!ppstate->prev_mip) {
658 ppstate->prev_mi = ppstate->prev_mip + cm->mi_stride + 1;
659 vpx_memset(ppstate->prev_mip, 0,
660 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip));
663 // Allocate post_proc_buffer_int if needed.
664 if ((flags & VP9D_MFQE) && !cm->post_proc_buffer_int.buffer_alloc) {
665 if ((flags & VP9D_DEMACROBLOCK) || (flags & VP9D_DEBLOCK)) {
666 const int width = ALIGN_POWER_OF_TWO(cm->width, 4);
667 const int height = ALIGN_POWER_OF_TWO(cm->height, 4);
669 if (vp9_alloc_frame_buffer(&cm->post_proc_buffer_int, width, height,
670 cm->subsampling_x, cm->subsampling_y,
671 #if CONFIG_VP9_HIGHBITDEPTH
672 cm->use_highbitdepth,
673 #endif // CONFIG_VP9_HIGHBITDEPTH
674 VP9_ENC_BORDER_IN_PIXELS,
675 cm->byte_alignment) < 0) {
676 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
677 "Failed to allocate MFQE framebuffer");
680 // Ensure that postproc is set to all 0s so that post proc
681 // doesn't pull random data in from edge.
682 vpx_memset(cm->post_proc_buffer_int.buffer_alloc, 128,
683 cm->post_proc_buffer.frame_size);
687 if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, cm->width, cm->height,
688 cm->subsampling_x, cm->subsampling_y,
689 #if CONFIG_VP9_HIGHBITDEPTH
690 cm->use_highbitdepth,
692 VP9_DEC_BORDER_IN_PIXELS, cm->byte_alignment,
693 NULL, NULL, NULL) < 0)
694 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
695 "Failed to allocate post-processing buffer");
697 if ((flags & VP9D_MFQE) && cm->current_video_frame >= 2 &&
698 cm->postproc_state.last_frame_valid && cm->bit_depth == 8 &&
699 cm->postproc_state.last_base_qindex <= last_q_thresh &&
700 cm->base_qindex - cm->postproc_state.last_base_qindex >= q_diff_thresh) {
702 // TODO(jackychen): Consider whether enable deblocking by default
703 // if mfqe is enabled. Need to take both the quality and the speed
704 // into consideration.
705 if ((flags & VP9D_DEMACROBLOCK) || (flags & VP9D_DEBLOCK)) {
706 vp8_yv12_copy_frame(ppbuf, &cm->post_proc_buffer_int);
708 if ((flags & VP9D_DEMACROBLOCK) && cm->post_proc_buffer_int.buffer_alloc) {
709 deblock_and_de_macro_block(&cm->post_proc_buffer_int, ppbuf,
710 q + (ppflags->deblocking_level - 5) * 10,
712 } else if (flags & VP9D_DEBLOCK) {
713 vp9_deblock(&cm->post_proc_buffer_int, ppbuf, q);
715 vp8_yv12_copy_frame(&cm->post_proc_buffer_int, ppbuf);
717 } else if (flags & VP9D_DEMACROBLOCK) {
718 deblock_and_de_macro_block(cm->frame_to_show, ppbuf,
719 q + (ppflags->deblocking_level - 5) * 10, 1, 0);
720 } else if (flags & VP9D_DEBLOCK) {
721 vp9_deblock(cm->frame_to_show, ppbuf, q);
723 vp8_yv12_copy_frame(cm->frame_to_show, ppbuf);
726 cm->postproc_state.last_base_qindex = cm->base_qindex;
727 cm->postproc_state.last_frame_valid = 1;
729 if (flags & VP9D_ADDNOISE) {
730 const int noise_level = ppflags->noise_level;
731 if (ppstate->last_q != q ||
732 ppstate->last_noise != noise_level) {
733 fillrd(ppstate, 63 - q, noise_level);
736 vp9_plane_add_noise(ppbuf->y_buffer, ppstate->noise, ppstate->blackclamp,
737 ppstate->whiteclamp, ppstate->bothclamp,
738 ppbuf->y_width, ppbuf->y_height, ppbuf->y_stride);
743 /* handle problem with extending borders */
744 dest->y_width = cm->width;
745 dest->y_height = cm->height;
746 dest->uv_width = dest->y_width >> cm->subsampling_x;
747 dest->uv_height = dest->y_height >> cm->subsampling_y;
749 swap_mi_and_prev_mi(cm);
752 #endif // CONFIG_VP9_POSTPROC