]> granicus.if.org Git - libvpx/commitdiff
vp9 postproc: Bug fix and code clean.
authorjackychen <jackychen@google.com>
Tue, 28 Jun 2016 22:38:18 +0000 (15:38 -0700)
committerjackychen <jackychen@google.com>
Tue, 28 Jun 2016 23:13:44 +0000 (16:13 -0700)
Bug fix: The crash is caused by not allocating buffer for prev_mip in
postproc_state and prev_mip in postproc_state is only used for MFQE,
ohter postproc modules, deblocking and etc., should not use it.

BUG=webm:1251

Change-Id: I3120d2f50603b4a2d400e92d583960a513953a28

vp9/common/vp9_postproc.c

index c04cc8f05c054acfd8998c66d4adfcf452bf2722..5dad81d64dffb29d7ab3d9761a85ea3fd2bcd24b 100644 (file)
@@ -618,15 +618,16 @@ int vp9_post_proc_frame(struct VP9Common *cm,
 
   // Alloc memory for prev_mip in the first frame.
   if (cm->current_video_frame == 1) {
-    cm->postproc_state.last_base_qindex = cm->base_qindex;
-    cm->postproc_state.last_frame_valid = 1;
+    ppstate->last_base_qindex = cm->base_qindex;
+    ppstate->last_frame_valid = 1;
+  }
+
+  if ((flags & VP9D_MFQE) && ppstate->prev_mip == NULL) {
     ppstate->prev_mip = vpx_calloc(cm->mi_alloc_size, sizeof(*cm->mip));
     if (!ppstate->prev_mip) {
       return 1;
     }
     ppstate->prev_mi = ppstate->prev_mip + cm->mi_stride + 1;
-    memset(ppstate->prev_mip, 0,
-           cm->mi_stride * (cm->mi_rows + 1) * sizeof(*cm->mip));
   }
 
   // Allocate post_proc_buffer_int if needed.
@@ -664,9 +665,9 @@ int vp9_post_proc_frame(struct VP9Common *cm,
                        "Failed to allocate post-processing buffer");
 
   if ((flags & VP9D_MFQE) && cm->current_video_frame >= 2 &&
-      cm->postproc_state.last_frame_valid && cm->bit_depth == 8 &&
-      cm->postproc_state.last_base_qindex <= last_q_thresh &&
-      cm->base_qindex - cm->postproc_state.last_base_qindex >= q_diff_thresh) {
+      ppstate->last_frame_valid && cm->bit_depth == 8 &&
+      ppstate->last_base_qindex <= last_q_thresh &&
+      cm->base_qindex - ppstate->last_base_qindex >= q_diff_thresh) {
     vp9_mfqe(cm);
     // TODO(jackychen): Consider whether enable deblocking by default
     // if mfqe is enabled. Need to take both the quality and the speed
@@ -692,8 +693,8 @@ int vp9_post_proc_frame(struct VP9Common *cm,
     vp8_yv12_copy_frame(cm->frame_to_show, ppbuf);
   }
 
-  cm->postproc_state.last_base_qindex = cm->base_qindex;
-  cm->postproc_state.last_frame_valid = 1;
+  ppstate->last_base_qindex = cm->base_qindex;
+  ppstate->last_frame_valid = 1;
 
   if (flags & VP9D_ADDNOISE) {
     const int noise_level = ppflags->noise_level;
@@ -714,7 +715,8 @@ int vp9_post_proc_frame(struct VP9Common *cm,
   dest->uv_width = dest->y_width >> cm->subsampling_x;
   dest->uv_height = dest->y_height >> cm->subsampling_y;
 
-  swap_mi_and_prev_mi(cm);
+  if (flags & VP9D_MFQE)
+    swap_mi_and_prev_mi(cm);
   return 0;
 }
 #endif  // CONFIG_VP9_POSTPROC