shithub: libvpx

Download patch

ref: 66ba79f5fb8ec3f729903f8a5edcfef93a663ce6
parent: fd9df44a054260aef0aaf3d8acda61d35e3b001b
author: Deb Mukherjee <debargha@google.com>
date: Thu Mar 22 05:13:18 EDT 2012

Miscellaneous changes in mfqe and postproc modules

Adds logic to disable mfqe for the first frame after a configuration
change such as change in resolution. Also adds some missing
if CONFIG_POSTPROC macro checks.

Change-Id: If29053dad50b676bd29189ab7f9fe250eb5d30b3

--- a/vp8/common/alloccommon.c
+++ b/vp8/common/alloccommon.c
@@ -41,9 +41,11 @@
         vp8_yv12_de_alloc_frame_buffer(&oci->yv12_fb[i]);
 
     vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame);
+#if CONFIG_POSTPROC
     vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer);
     if (oci->post_proc_buffer_int_used)
         vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer_int);
+#endif
 
     vpx_free(oci->above_context);
     vpx_free(oci->mip);
@@ -96,6 +98,7 @@
         return 1;
     }
 
+#if CONFIG_POSTPROC
     if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0)
     {
         vp8_de_alloc_frame_buffers(oci);
@@ -103,6 +106,9 @@
     }
 
     oci->post_proc_buffer_int_used = 0;
+
+    vpx_memset(&oci->postproc_state, 0, sizeof(oci->postproc_state));
+#endif
 
     oci->mb_rows = height >> 4;
     oci->mb_cols = width >> 4;
--- a/vp8/common/onyxc_int.h
+++ b/vp8/common/onyxc_int.h
@@ -92,11 +92,13 @@
     int fb_idx_ref_cnt[NUM_YV12_BUFFERS];
     int new_fb_idx, lst_fb_idx, gld_fb_idx, alt_fb_idx;
 
-    YV12_BUFFER_CONFIG post_proc_buffer;
     YV12_BUFFER_CONFIG temp_scale_frame;
 
+#if CONFIG_POSTPROC
+    YV12_BUFFER_CONFIG post_proc_buffer;
     YV12_BUFFER_CONFIG post_proc_buffer_int;
     int post_proc_buffer_int_used;
+#endif
 
     FRAME_TYPE last_frame_type;  /* Save last frame's frame type for motion search. */
     FRAME_TYPE frame_type;
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -693,7 +693,7 @@
     }
 }
 
-
+#if CONFIG_POSTPROC
 int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t *ppflags)
 {
     int q = oci->filter_level * 10 / 6;
@@ -716,6 +716,7 @@
         dest->y_height = oci->Height;
         dest->uv_height = dest->y_height / 2;
         oci->postproc_state.last_base_qindex = oci->base_qindex;
+        oci->postproc_state.last_frame_valid = 1;
         return 0;
     }
 
@@ -746,6 +747,7 @@
 #endif
 
     if ((flags & VP8D_MFQE) &&
+         oci->postproc_state.last_frame_valid &&
          oci->current_video_frame >= 2 &&
          oci->base_qindex - oci->postproc_state.last_base_qindex >= 10)
     {
@@ -785,6 +787,7 @@
         vp8_yv12_copy_frame_ptr(oci->frame_to_show, &oci->post_proc_buffer);
         oci->postproc_state.last_base_qindex = oci->base_qindex;
     }
+    oci->postproc_state.last_frame_valid = 1;
 
     if (flags & VP8D_ADDNOISE)
     {
@@ -1171,3 +1174,4 @@
     dest->uv_height = dest->y_height / 2;
     return 0;
 }
+#endif
--- a/vp8/common/postproc.h
+++ b/vp8/common/postproc.h
@@ -19,6 +19,7 @@
     int           last_noise;
     char          noise[3072];
     int           last_base_qindex;
+    int           last_frame_valid;
     DECLARE_ALIGNED(16, char, blackclamp[16]);
     DECLARE_ALIGNED(16, char, whiteclamp[16]);
     DECLARE_ALIGNED(16, char, bothclamp[16]);
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -5058,7 +5058,6 @@
                 double frame_psnr;
                 YV12_BUFFER_CONFIG      *orig = cpi->Source;
                 YV12_BUFFER_CONFIG      *recon = cpi->common.frame_to_show;
-                YV12_BUFFER_CONFIG      *pp = &cm->post_proc_buffer;
                 int y_samples = orig->y_height * orig->y_width ;
                 int uv_samples = orig->uv_height * orig->uv_width ;
                 int t_samples = y_samples + 2 * uv_samples;
@@ -5082,7 +5081,9 @@
                 cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, ve);
                 cpi->total_sq_error += sq_error;
                 cpi->total  += frame_psnr;
+#if CONFIG_POSTPROC
                 {
+                    YV12_BUFFER_CONFIG      *pp = &cm->post_proc_buffer;
                     double frame_psnr2, frame_ssim2 = 0;
                     double weight = 0;
 
@@ -5133,6 +5134,7 @@
                          }
                     }
                 }
+#endif
             }
 
             if (cpi->b_calculate_ssimg)
--