shithub: libvpx

Download patch

ref: 6ec2b85badc7b5e9e19e9da623b05cbdba197f1b
parent: 6a7a4ba75346a22d9f1f92b731498055788e0f5a
author: Yaowu Xu <[email protected]>
date: Wed Aug 7 08:29:45 EDT 2013

Added lpf level picking using partial frame

Change-Id: I599ab1bd22b5f3f10d5962c609952abdef8ff67a

--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -377,11 +377,23 @@
 }
 
 void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd,
-                           int frame_filter_level, int y_only) {
+                           int frame_filter_level,
+                           int y_only, int partial) {
+  int start_mi_row, end_mi_row, mi_rows_to_filter;
   if (!frame_filter_level) return;
+
+  start_mi_row = 0;
+  mi_rows_to_filter = cm->mi_rows;
+  if (partial && cm->mi_rows > 8) {
+    start_mi_row = cm->mi_rows >> 1;
+    start_mi_row &= 0xfffffff8;
+    mi_rows_to_filter = MAX(cm->mi_rows / 8, 8);
+  }
+  end_mi_row = start_mi_row + mi_rows_to_filter;
   vp9_loop_filter_frame_init(cm, xd, frame_filter_level);
   vp9_loop_filter_rows(cm->frame_to_show, cm, xd,
-                       0, cm->mi_rows, y_only);
+                       start_mi_row, end_mi_row,
+                       y_only);
 }
 
 int vp9_loop_filter_worker(void *arg1, void *arg2) {
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -51,7 +51,7 @@
 void vp9_loop_filter_frame(struct VP9Common *cm,
                            struct macroblockd *mbd,
                            int filter_level,
-                           int y_only);
+                           int y_only, int partial);
 
 // Apply the loop filter to [start, stop) macro block rows in frame_buffer.
 void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -359,7 +359,7 @@
 
     if (!pbi->do_loopfilter_inline) {
       /* Apply the loop filter if appropriate. */
-      vp9_loop_filter_frame(cm, &pbi->mb, pbi->mb.lf.filter_level, 0);
+      vp9_loop_filter_frame(cm, &pbi->mb, pbi->mb.lf.filter_level, 0, 0);
     }
 
 #if WRITE_RECON_BUFFER == 2
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -2436,10 +2436,7 @@
 
     vpx_usec_timer_start(&timer);
 
-    if (cpi->sf.use_fast_lpf_pick == 0)
-      vp9_pick_filter_level(cpi->Source, cpi);
-    else
-      vp9_pick_filter_level_fast(cpi->Source, cpi);
+    vp9_pick_filter_level(cpi->Source, cpi, cpi->sf.use_fast_lpf_pick);
 
     vpx_usec_timer_mark(&timer);
     cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
@@ -2447,7 +2444,7 @@
 
   if (lf->filter_level > 0) {
     vp9_set_alt_lf_level(cpi, lf->filter_level);
-    vp9_loop_filter_frame(cm, xd, lf->filter_level, 0);
+    vp9_loop_filter_frame(cm, xd, lf->filter_level, 0, 0);
   }
 
   vp9_extend_frame_inner_borders(cm->frame_to_show,
--- a/vp9/encoder/vp9_picklpf.c
+++ b/vp9/encoder/vp9_picklpf.c
@@ -125,11 +125,7 @@
 void vp9_set_alt_lf_level(VP9_COMP *cpi, int filt_val) {
 }
 
-void vp9_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
-  struct loopfilter *lf = &cpi->mb.e_mbd.lf;
-  lf->filter_level = 0;
-}
-void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
+void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int partial) {
   VP9_COMMON *cm = &cpi->common;
   struct loopfilter *lf = &cpi->mb.e_mbd.lf;
 
@@ -169,7 +165,7 @@
 
   // Get baseline error score
   vp9_set_alt_lf_level(cpi, filt_mid);
-  vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1);
+  vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_mid, 1, partial);
 
   best_err = vp9_calc_ss_err(sd, cm->frame_to_show);
   filt_best = filt_mid;
@@ -194,7 +190,7 @@
     if ((filt_direction <= 0) && (filt_low != filt_mid)) {
       // Get Low filter error score
       vp9_set_alt_lf_level(cpi, filt_low);
-      vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1);
+      vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_low, 1, partial);
 
       filt_err = vp9_calc_ss_err(sd, cm->frame_to_show);
 
@@ -214,7 +210,7 @@
     // Now look at filt_high
     if ((filt_direction >= 0) && (filt_high != filt_mid)) {
       vp9_set_alt_lf_level(cpi, filt_high);
-      vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1);
+      vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, filt_high, 1, partial);
 
       filt_err = vp9_calc_ss_err(sd, cm->frame_to_show);
 
@@ -240,3 +236,4 @@
 
   lf->filter_level = filt_best;
 }
+
--- a/vp9/encoder/vp9_picklpf.h
+++ b/vp9/encoder/vp9_picklpf.h
@@ -18,8 +18,5 @@
 void vp9_set_alt_lf_level(struct VP9_COMP *cpi, int filt_val);
 
 void vp9_pick_filter_level(struct yv12_buffer_config *sd,
-                           struct VP9_COMP *cpi);
-
-void vp9_pick_filter_level_fast(struct yv12_buffer_config *sd,
-                                struct VP9_COMP *cpi);
+                           struct VP9_COMP *cpi, int partial);
 #endif  // VP9_ENCODER_VP9_PICKLPF_H_