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_ports/mem.h"
20 #include "vpx_scale/vpx_scale.h"
21 #include "vpx_scale/yv12config.h"
23 #include "vp9/common/vp9_onyxc_int.h"
24 #include "vp9/common/vp9_postproc.h"
25 #include "vp9/common/vp9_systemdependent.h"
26 #include "vp9/common/vp9_textblit.h"
28 #if CONFIG_VP9_POSTPROC
29 static const int16_t kernel5[] = {
33 const int16_t vp9_rv[] = {
34 8, 5, 2, 2, 8, 12, 4, 9, 8, 3,
35 0, 3, 9, 0, 0, 0, 8, 3, 14, 4,
36 10, 1, 11, 14, 1, 14, 9, 6, 12, 11,
37 8, 6, 10, 0, 0, 8, 9, 0, 3, 14,
38 8, 11, 13, 4, 2, 9, 0, 3, 9, 6,
39 1, 2, 3, 14, 13, 1, 8, 2, 9, 7,
40 3, 3, 1, 13, 13, 6, 6, 5, 2, 7,
41 11, 9, 11, 8, 7, 3, 2, 0, 13, 13,
42 14, 4, 12, 5, 12, 10, 8, 10, 13, 10,
43 4, 14, 4, 10, 0, 8, 11, 1, 13, 7,
44 7, 14, 6, 14, 13, 2, 13, 5, 4, 4,
45 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
46 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
47 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
48 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
49 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
50 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
51 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
52 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
53 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
54 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
55 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
56 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
57 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
58 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
59 0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
60 8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
61 3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
62 3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
63 13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
64 5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
65 9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
66 4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
67 3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
68 11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
69 5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
70 0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
71 10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
72 4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
73 3, 8, 3, 7, 8, 5, 11, 4, 12, 3,
74 11, 9, 14, 8, 14, 13, 4, 3, 1, 2,
75 14, 6, 5, 4, 4, 11, 4, 6, 2, 1,
76 5, 8, 8, 12, 13, 5, 14, 10, 12, 13,
77 0, 9, 5, 5, 11, 10, 13, 9, 10, 13,
80 static const uint8_t q_diff_thresh = 20;
81 static const uint8_t last_q_thresh = 170;
83 void vp9_post_proc_down_and_across_c(const uint8_t *src_ptr,
85 int src_pixels_per_line,
86 int dst_pixels_per_line,
92 int row, col, i, v, kernel;
93 int pitch = src_pixels_per_line;
95 (void)dst_pixels_per_line;
97 for (row = 0; row < rows; row++) {
98 /* post_proc_down for one row */
102 for (col = 0; col < cols; col++) {
106 for (i = -2; i <= 2; i++) {
107 if (abs(v - p_src[col + i * pitch]) > flimit)
108 goto down_skip_convolve;
110 kernel += kernel5[2 + i] * p_src[col + i * pitch];
118 /* now post_proc_across */
122 for (i = 0; i < 8; i++)
125 for (col = 0; col < cols; col++) {
131 for (i = -2; i <= 2; i++) {
132 if (abs(v - p_src[col + i]) > flimit)
133 goto across_skip_convolve;
135 kernel += kernel5[2 + i] * p_src[col + i];
138 d[col & 7] = (kernel >> 3);
139 across_skip_convolve:
142 p_dst[col - 2] = d[(col - 2) & 7];
145 /* handle the last two pixels */
146 p_dst[col - 2] = d[(col - 2) & 7];
147 p_dst[col - 1] = d[(col - 1) & 7];
156 #if CONFIG_VP9_HIGHBITDEPTH
157 void vp9_highbd_post_proc_down_and_across_c(const uint16_t *src_ptr,
159 int src_pixels_per_line,
160 int dst_pixels_per_line,
164 uint16_t const *p_src;
166 int row, col, i, v, kernel;
167 int pitch = src_pixels_per_line;
170 for (row = 0; row < rows; row++) {
171 // post_proc_down for one row.
175 for (col = 0; col < cols; col++) {
179 for (i = -2; i <= 2; i++) {
180 if (abs(v - p_src[col + i * pitch]) > flimit)
181 goto down_skip_convolve;
183 kernel += kernel5[2 + i] * p_src[col + i * pitch];
192 /* now post_proc_across */
196 for (i = 0; i < 8; i++)
199 for (col = 0; col < cols; col++) {
205 for (i = -2; i <= 2; i++) {
206 if (abs(v - p_src[col + i]) > flimit)
207 goto across_skip_convolve;
209 kernel += kernel5[2 + i] * p_src[col + i];
212 d[col & 7] = (kernel >> 3);
214 across_skip_convolve:
216 p_dst[col - 2] = d[(col - 2) & 7];
219 /* handle the last two pixels */
220 p_dst[col - 2] = d[(col - 2) & 7];
221 p_dst[col - 1] = d[(col - 1) & 7];
226 dst_ptr += dst_pixels_per_line;
229 #endif // CONFIG_VP9_HIGHBITDEPTH
231 static int q2mbl(int x) {
234 x = 50 + (x - 50) * 10 / 8;
238 void vp9_mbpost_proc_across_ip_c(uint8_t *src, int pitch,
239 int rows, int cols, int flimit) {
244 for (r = 0; r < rows; r++) {
248 for (i = -8; i <= 6; i++) {
249 sumsq += s[i] * s[i];
254 for (c = 0; c < cols + 8; c++) {
255 int x = s[c + 7] - s[c - 8];
256 int y = s[c + 7] + s[c - 8];
263 if (sumsq * 15 - sum * sum < flimit) {
264 d[c & 15] = (8 + sum + s[c]) >> 4;
267 s[c - 8] = d[(c - 8) & 15];
273 #if CONFIG_VP9_HIGHBITDEPTH
274 void vp9_highbd_mbpost_proc_across_ip_c(uint16_t *src, int pitch,
275 int rows, int cols, int flimit) {
282 for (r = 0; r < rows; r++) {
286 for (i = -8; i <= 6; i++) {
287 sumsq += s[i] * s[i];
292 for (c = 0; c < cols + 8; c++) {
293 int x = s[c + 7] - s[c - 8];
294 int y = s[c + 7] + s[c - 8];
301 if (sumsq * 15 - sum * sum < flimit) {
302 d[c & 15] = (8 + sum + s[c]) >> 4;
305 s[c - 8] = d[(c - 8) & 15];
311 #endif // CONFIG_VP9_HIGHBITDEPTH
313 void vp9_mbpost_proc_down_c(uint8_t *dst, int pitch,
314 int rows, int cols, int flimit) {
316 const short *rv3 = &vp9_rv[63 & rand()]; // NOLINT
318 for (c = 0; c < cols; c++) {
319 uint8_t *s = &dst[c];
323 const int16_t *rv2 = rv3 + ((c * 17) & 127);
325 for (i = -8; i <= 6; i++) {
326 sumsq += s[i * pitch] * s[i * pitch];
330 for (r = 0; r < rows + 8; r++) {
331 sumsq += s[7 * pitch] * s[ 7 * pitch] - s[-8 * pitch] * s[-8 * pitch];
332 sum += s[7 * pitch] - s[-8 * pitch];
335 if (sumsq * 15 - sum * sum < flimit) {
336 d[r & 15] = (rv2[r & 127] + sum + s[0]) >> 4;
339 s[-8 * pitch] = d[(r - 8) & 15];
345 #if CONFIG_VP9_HIGHBITDEPTH
346 void vp9_highbd_mbpost_proc_down_c(uint16_t *dst, int pitch,
347 int rows, int cols, int flimit) {
349 const int16_t *rv3 = &vp9_rv[63 & rand()]; // NOLINT
351 for (c = 0; c < cols; c++) {
352 uint16_t *s = &dst[c];
356 const int16_t *rv2 = rv3 + ((c * 17) & 127);
358 for (i = -8; i <= 6; i++) {
359 sumsq += s[i * pitch] * s[i * pitch];
363 for (r = 0; r < rows + 8; r++) {
364 sumsq += s[7 * pitch] * s[ 7 * pitch] - s[-8 * pitch] * s[-8 * pitch];
365 sum += s[7 * pitch] - s[-8 * pitch];
368 if (sumsq * 15 - sum * sum < flimit) {
369 d[r & 15] = (rv2[r & 127] + sum + s[0]) >> 4;
372 s[-8 * pitch] = d[(r - 8) & 15];
377 #endif // CONFIG_VP9_HIGHBITDEPTH
379 static void deblock_and_de_macro_block(YV12_BUFFER_CONFIG *source,
380 YV12_BUFFER_CONFIG *post,
384 double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
385 int ppl = (int)(level + .5);
386 (void) low_var_thresh;
389 #if CONFIG_VP9_HIGHBITDEPTH
390 if (source->flags & YV12_FLAG_HIGHBITDEPTH) {
391 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(source->y_buffer),
392 CONVERT_TO_SHORTPTR(post->y_buffer),
393 source->y_stride, post->y_stride,
394 source->y_height, source->y_width,
397 vp9_highbd_mbpost_proc_across_ip(CONVERT_TO_SHORTPTR(post->y_buffer),
398 post->y_stride, post->y_height,
399 post->y_width, q2mbl(q));
401 vp9_highbd_mbpost_proc_down(CONVERT_TO_SHORTPTR(post->y_buffer),
402 post->y_stride, post->y_height,
403 post->y_width, q2mbl(q));
405 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(source->u_buffer),
406 CONVERT_TO_SHORTPTR(post->u_buffer),
407 source->uv_stride, post->uv_stride,
408 source->uv_height, source->uv_width,
410 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(source->v_buffer),
411 CONVERT_TO_SHORTPTR(post->v_buffer),
412 source->uv_stride, post->uv_stride,
413 source->uv_height, source->uv_width,
416 vp9_post_proc_down_and_across(source->y_buffer, post->y_buffer,
417 source->y_stride, post->y_stride,
418 source->y_height, source->y_width, ppl);
420 vp9_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
421 post->y_width, q2mbl(q));
423 vp9_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
424 post->y_width, q2mbl(q));
426 vp9_post_proc_down_and_across(source->u_buffer, post->u_buffer,
427 source->uv_stride, post->uv_stride,
428 source->uv_height, source->uv_width, ppl);
429 vp9_post_proc_down_and_across(source->v_buffer, post->v_buffer,
430 source->uv_stride, post->uv_stride,
431 source->uv_height, source->uv_width, ppl);
434 vp9_post_proc_down_and_across(source->y_buffer, post->y_buffer,
435 source->y_stride, post->y_stride,
436 source->y_height, source->y_width, ppl);
438 vp9_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
439 post->y_width, q2mbl(q));
441 vp9_mbpost_proc_down(post->y_buffer, post->y_stride, post->y_height,
442 post->y_width, q2mbl(q));
444 vp9_post_proc_down_and_across(source->u_buffer, post->u_buffer,
445 source->uv_stride, post->uv_stride,
446 source->uv_height, source->uv_width, ppl);
447 vp9_post_proc_down_and_across(source->v_buffer, post->v_buffer,
448 source->uv_stride, post->uv_stride,
449 source->uv_height, source->uv_width, ppl);
450 #endif // CONFIG_VP9_HIGHBITDEPTH
453 void vp9_deblock(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
455 const int ppl = (int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q
459 const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
460 const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
461 const int src_widths[3] = {src->y_width, src->uv_width, src->uv_width};
462 const int src_heights[3] = {src->y_height, src->uv_height, src->uv_height};
464 uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer};
465 const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride};
467 for (i = 0; i < MAX_MB_PLANE; ++i) {
468 #if CONFIG_VP9_HIGHBITDEPTH
469 assert((src->flags & YV12_FLAG_HIGHBITDEPTH) ==
470 (dst->flags & YV12_FLAG_HIGHBITDEPTH));
471 if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
472 vp9_highbd_post_proc_down_and_across(CONVERT_TO_SHORTPTR(srcs[i]),
473 CONVERT_TO_SHORTPTR(dsts[i]),
474 src_strides[i], dst_strides[i],
475 src_heights[i], src_widths[i], ppl);
477 vp9_post_proc_down_and_across(srcs[i], dsts[i],
478 src_strides[i], dst_strides[i],
479 src_heights[i], src_widths[i], ppl);
482 vp9_post_proc_down_and_across(srcs[i], dsts[i],
483 src_strides[i], dst_strides[i],
484 src_heights[i], src_widths[i], ppl);
485 #endif // CONFIG_VP9_HIGHBITDEPTH
489 void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst,
491 const int ppl = (int)(6.0e-05 * q * q * q - 0.0067 * q * q + 0.306 * q
495 const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
496 const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
497 const int src_widths[3] = {src->y_width, src->uv_width, src->uv_width};
498 const int src_heights[3] = {src->y_height, src->uv_height, src->uv_height};
500 uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer};
501 const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride};
503 for (i = 0; i < MAX_MB_PLANE; ++i) {
504 const int src_stride = src_strides[i];
505 const int src_width = src_widths[i] - 4;
506 const int src_height = src_heights[i] - 4;
507 const int dst_stride = dst_strides[i];
509 #if CONFIG_VP9_HIGHBITDEPTH
510 assert((src->flags & YV12_FLAG_HIGHBITDEPTH) ==
511 (dst->flags & YV12_FLAG_HIGHBITDEPTH));
512 if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
513 const uint16_t *const src_plane = CONVERT_TO_SHORTPTR(
514 srcs[i] + 2 * src_stride + 2);
515 uint16_t *const dst_plane = CONVERT_TO_SHORTPTR(
516 dsts[i] + 2 * dst_stride + 2);
517 vp9_highbd_post_proc_down_and_across(src_plane, dst_plane, src_stride,
518 dst_stride, src_height, src_width,
521 const uint8_t *const src_plane = srcs[i] + 2 * src_stride + 2;
522 uint8_t *const dst_plane = dsts[i] + 2 * dst_stride + 2;
524 vp9_post_proc_down_and_across(src_plane, dst_plane, src_stride,
525 dst_stride, src_height, src_width, ppl);
528 const uint8_t *const src_plane = srcs[i] + 2 * src_stride + 2;
529 uint8_t *const dst_plane = dsts[i] + 2 * dst_stride + 2;
530 vp9_post_proc_down_and_across(src_plane, dst_plane, src_stride, dst_stride,
531 src_height, src_width, ppl);
536 static double gaussian(double sigma, double mu, double x) {
537 return 1 / (sigma * sqrt(2.0 * 3.14159265)) *
538 (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
541 static void fillrd(struct postproc_state *state, int q, int a) {
545 int ai = a, qi = q, i;
547 vp9_clear_system_state();
549 sigma = ai + .5 + .6 * (63 - qi) / 63.0;
551 /* set up a lookup table of 256 entries that matches
552 * a gaussian distribution with sigma determined by q.
559 for (i = -32; i < 32; i++) {
560 int a_i = (int)(0.5 + 256 * gaussian(sigma, 0, i));
563 for (j = 0; j < a_i; j++) {
564 char_dist[next + j] = (char) i;
571 for (; next < 256; next++)
575 for (i = 0; i < 3072; i++) {
576 state->noise[i] = char_dist[rand() & 0xff]; // NOLINT
579 for (i = 0; i < 16; i++) {
580 state->blackclamp[i] = -char_dist[0];
581 state->whiteclamp[i] = -char_dist[0];
582 state->bothclamp[i] = -2 * char_dist[0];
586 state->last_noise = a;
589 void vp9_plane_add_noise_c(uint8_t *start, char *noise,
593 unsigned int width, unsigned int height, int pitch) {
596 // TODO(jbb): why does simd code use both but c doesn't, normalize and
599 for (i = 0; i < height; i++) {
600 uint8_t *pos = start + i * pitch;
601 char *ref = (char *)(noise + (rand() & 0xff)); // NOLINT
603 for (j = 0; j < width; j++) {
604 if (pos[j] < blackclamp[0])
605 pos[j] = blackclamp[0];
607 if (pos[j] > 255 + whiteclamp[0])
608 pos[j] = 255 + whiteclamp[0];
615 static void swap_mi_and_prev_mi(VP9_COMMON *cm) {
616 // Current mip will be the prev_mip for the next frame.
617 MODE_INFO *temp = cm->postproc_state.prev_mip;
618 cm->postproc_state.prev_mip = cm->mip;
621 // Update the upper left visible macroblock ptrs.
622 cm->mi = cm->mip + cm->mi_stride + 1;
623 cm->postproc_state.prev_mi = cm->postproc_state.prev_mip + cm->mi_stride + 1;
626 int vp9_post_proc_frame(struct VP9Common *cm,
627 YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *ppflags) {
628 const int q = MIN(105, cm->lf.filter_level * 2);
629 const int flags = ppflags->post_proc_flag;
630 YV12_BUFFER_CONFIG *const ppbuf = &cm->post_proc_buffer;
631 struct postproc_state *const ppstate = &cm->postproc_state;
633 if (!cm->frame_to_show)
637 *dest = *cm->frame_to_show;
641 vp9_clear_system_state();
643 // Alloc memory for prev_mip in the first frame.
644 if (cm->current_video_frame == 1) {
645 cm->postproc_state.last_base_qindex = cm->base_qindex;
646 cm->postproc_state.last_frame_valid = 1;
647 ppstate->prev_mip = vpx_calloc(cm->mi_alloc_size, sizeof(*cm->mip));
648 if (!ppstate->prev_mip) {
651 ppstate->prev_mi = ppstate->prev_mip + cm->mi_stride + 1;
652 memset(ppstate->prev_mip, 0,
653 cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip));
656 // Allocate post_proc_buffer_int if needed.
657 if ((flags & VP9D_MFQE) && !cm->post_proc_buffer_int.buffer_alloc) {
658 if ((flags & VP9D_DEMACROBLOCK) || (flags & VP9D_DEBLOCK)) {
659 const int width = ALIGN_POWER_OF_TWO(cm->width, 4);
660 const int height = ALIGN_POWER_OF_TWO(cm->height, 4);
662 if (vp9_alloc_frame_buffer(&cm->post_proc_buffer_int, width, height,
663 cm->subsampling_x, cm->subsampling_y,
664 #if CONFIG_VP9_HIGHBITDEPTH
665 cm->use_highbitdepth,
666 #endif // CONFIG_VP9_HIGHBITDEPTH
667 VP9_ENC_BORDER_IN_PIXELS,
668 cm->byte_alignment) < 0) {
669 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
670 "Failed to allocate MFQE framebuffer");
673 // Ensure that postproc is set to all 0s so that post proc
674 // doesn't pull random data in from edge.
675 memset(cm->post_proc_buffer_int.buffer_alloc, 128,
676 cm->post_proc_buffer.frame_size);
680 if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, cm->width, cm->height,
681 cm->subsampling_x, cm->subsampling_y,
682 #if CONFIG_VP9_HIGHBITDEPTH
683 cm->use_highbitdepth,
685 VP9_DEC_BORDER_IN_PIXELS, cm->byte_alignment,
686 NULL, NULL, NULL) < 0)
687 vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
688 "Failed to allocate post-processing buffer");
690 if ((flags & VP9D_MFQE) && cm->current_video_frame >= 2 &&
691 cm->postproc_state.last_frame_valid && cm->bit_depth == 8 &&
692 cm->postproc_state.last_base_qindex <= last_q_thresh &&
693 cm->base_qindex - cm->postproc_state.last_base_qindex >= q_diff_thresh) {
695 // TODO(jackychen): Consider whether enable deblocking by default
696 // if mfqe is enabled. Need to take both the quality and the speed
697 // into consideration.
698 if ((flags & VP9D_DEMACROBLOCK) || (flags & VP9D_DEBLOCK)) {
699 vp8_yv12_copy_frame(ppbuf, &cm->post_proc_buffer_int);
701 if ((flags & VP9D_DEMACROBLOCK) && cm->post_proc_buffer_int.buffer_alloc) {
702 deblock_and_de_macro_block(&cm->post_proc_buffer_int, ppbuf,
703 q + (ppflags->deblocking_level - 5) * 10,
705 } else if (flags & VP9D_DEBLOCK) {
706 vp9_deblock(&cm->post_proc_buffer_int, ppbuf, q);
708 vp8_yv12_copy_frame(&cm->post_proc_buffer_int, ppbuf);
710 } else if (flags & VP9D_DEMACROBLOCK) {
711 deblock_and_de_macro_block(cm->frame_to_show, ppbuf,
712 q + (ppflags->deblocking_level - 5) * 10, 1, 0);
713 } else if (flags & VP9D_DEBLOCK) {
714 vp9_deblock(cm->frame_to_show, ppbuf, q);
716 vp8_yv12_copy_frame(cm->frame_to_show, ppbuf);
719 cm->postproc_state.last_base_qindex = cm->base_qindex;
720 cm->postproc_state.last_frame_valid = 1;
722 if (flags & VP9D_ADDNOISE) {
723 const int noise_level = ppflags->noise_level;
724 if (ppstate->last_q != q ||
725 ppstate->last_noise != noise_level) {
726 fillrd(ppstate, 63 - q, noise_level);
729 vp9_plane_add_noise(ppbuf->y_buffer, ppstate->noise, ppstate->blackclamp,
730 ppstate->whiteclamp, ppstate->bothclamp,
731 ppbuf->y_width, ppbuf->y_height, ppbuf->y_stride);
736 /* handle problem with extending borders */
737 dest->y_width = cm->width;
738 dest->y_height = cm->height;
739 dest->uv_width = dest->y_width >> cm->subsampling_x;
740 dest->uv_height = dest->y_height >> cm->subsampling_y;
742 swap_mi_and_prev_mi(cm);
745 #endif // CONFIG_VP9_POSTPROC