shithub: libvpx

Download patch

ref: 67fe9d17cba8c8ddeeba265bcd6779db5b36e777
parent: 125146034ee8be4e0b4986687db0ce3f80c581b0
author: Dmitry Kovalev <[email protected]>
date: Fri Aug 9 13:24:40 EDT 2013

Removing redundant code and function arguments.

Change-Id: Ia5cdda0f755befcd1e64397452c42cb7031ca574

--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -61,8 +61,9 @@
   }
 }
 
-void vp9_loop_filter_init(VP9_COMMON *cm, struct loopfilter *lf) {
+void vp9_loop_filter_init(VP9_COMMON *cm) {
   loop_filter_info_n *lfi = &cm->lf_info;
+  struct loopfilter *lf = &cm->lf;
   int i;
 
   // init limits for given sharpness
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -60,7 +60,7 @@
 struct VP9Common;
 struct macroblockd;
 
-void vp9_loop_filter_init(struct VP9Common *cm, struct loopfilter *lf);
+void vp9_loop_filter_init(struct VP9Common *cm);
 
 // Update the loop filter for the current frame.
 // This should be called before vp9_loop_filter_rows(), vp9_loop_filter_frame()
--- a/vp9/common/vp9_postproc.c
+++ b/vp9/common/vp9_postproc.c
@@ -631,10 +631,8 @@
 }
 
 int vp9_post_proc_frame(struct VP9Common *oci,
-                        struct loopfilter *lf,
-                        YV12_BUFFER_CONFIG *dest,
-                        vp9_ppflags_t *ppflags) {
-  int q = lf->filter_level * 10 / 6;
+                        YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *ppflags) {
+  int q = oci->lf.filter_level * 10 / 6;
   int flags = ppflags->post_proc_flag;
   int deblock_level = ppflags->deblocking_level;
   int noise_level = ppflags->noise_level;
--- a/vp9/common/vp9_postproc.h
+++ b/vp9/common/vp9_postproc.h
@@ -26,7 +26,7 @@
 #include "vp9/common/vp9_onyxc_int.h"
 #include "vp9/common/vp9_ppflags.h"
 
-int vp9_post_proc_frame(struct VP9Common *oci, struct loopfilter *lf,
+int vp9_post_proc_frame(struct VP9Common *oci,
                         YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *flags);
 
 void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q);
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -110,35 +110,36 @@
 
 VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
   VP9D_COMP *const pbi = vpx_memalign(32, sizeof(VP9D_COMP));
+  VP9_COMMON *const cm = pbi ? &pbi->common : NULL;
 
-  if (!pbi)
+  if (!cm)
     return NULL;
 
   vp9_zero(*pbi);
 
-  if (setjmp(pbi->common.error.jmp)) {
-    pbi->common.error.setjmp = 0;
+  if (setjmp(cm->error.jmp)) {
+    cm->error.setjmp = 0;
     vp9_remove_decompressor(pbi);
     return NULL;
   }
 
-  pbi->common.error.setjmp = 1;
+  cm->error.setjmp = 1;
   vp9_initialize_dec();
 
-  vp9_create_common(&pbi->common);
+  vp9_create_common(cm);
 
   pbi->oxcf = *oxcf;
-  pbi->common.current_video_frame = 0;
   pbi->ready_for_new_data = 1;
+  cm->current_video_frame = 0;
 
   // vp9_init_dequantizer() is first called here. Add check in
   // frame_init_dequantizer() to avoid unnecessary calling of
   // vp9_init_dequantizer() for every frame.
-  vp9_init_dequantizer(&pbi->common);
+  vp9_init_dequantizer(cm);
 
-  vp9_loop_filter_init(&pbi->common, &pbi->common.lf);
+  vp9_loop_filter_init(cm);
 
-  pbi->common.error.setjmp = 0;
+  cm->error.setjmp = 0;
   pbi->decoded_key_frame = 0;
 
   if (pbi->oxcf.max_threads > 1) {
@@ -424,7 +425,7 @@
   *time_end_stamp = 0;
 
 #if CONFIG_POSTPROC
-  ret = vp9_post_proc_frame(&pbi->common, &pbi->common.lf, sd, flags);
+  ret = vp9_post_proc_frame(&pbi->common, sd, flags);
 #else
 
   if (pbi->common.frame_to_show) {
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -49,7 +49,7 @@
 
 extern void print_tree_update_probs();
 
-static void set_default_lf_deltas(VP9_COMP *cpi);
+static void set_default_lf_deltas(struct loopfilter *lf);
 
 #define DEFAULT_INTERP_FILTER SWITCHABLE
 
@@ -258,7 +258,7 @@
   vp9_zero(lf->last_ref_deltas);
   vp9_zero(lf->last_mode_deltas);
 
-  set_default_lf_deltas(cpi);
+  set_default_lf_deltas(lf);
 }
 
 static void dealloc_compressor_data(VP9_COMP *cpi) {
@@ -542,9 +542,7 @@
   }
 }
 
-static void set_default_lf_deltas(VP9_COMP *cpi) {
-  struct loopfilter *lf = &cpi->common.lf;
-
+static void set_default_lf_deltas(struct loopfilter *lf) {
   lf->mode_ref_delta_enabled = 1;
   lf->mode_ref_delta_update = 1;
 
@@ -1705,7 +1703,7 @@
    */
   vp9_init_quantizer(cpi);
 
-  vp9_loop_filter_init(cm, &cpi->common.lf);
+  vp9_loop_filter_init(cm);
 
   cpi->common.error.setjmp = 0;
 
@@ -3990,7 +3988,7 @@
   else {
     int ret;
 #if CONFIG_POSTPROC
-    ret = vp9_post_proc_frame(&cpi->common, &cpi->common.lf, dest, flags);
+    ret = vp9_post_proc_frame(&cpi->common, dest, flags);
 #else
 
     if (cpi->common.frame_to_show) {
--- a/vp9/encoder/vp9_picklpf.c
+++ b/vp9/encoder/vp9_picklpf.c
@@ -21,29 +21,15 @@
 #include "./vpx_scale_rtcd.h"
 
 void vp9_yv12_copy_partial_frame_c(YV12_BUFFER_CONFIG *src_ybc,
-                                   YV12_BUFFER_CONFIG *dst_ybc, int Fraction) {
-  uint8_t *src_y, *dst_y;
-  int yheight;
-  int ystride;
-  int yoffset;
-  int linestocopy;
+                                   YV12_BUFFER_CONFIG *dst_ybc, int fraction) {
+  const int height = src_ybc->y_height;
+  const int stride = src_ybc->y_stride;
+  const int offset = stride * ((height >> 5) * 16 - 8);
+  const int lines_to_copy = MAX(height >> (fraction + 4), 1) << 4;
 
   assert(src_ybc->y_stride == dst_ybc->y_stride);
-  yheight  = src_ybc->y_height;
-  ystride  = src_ybc->y_stride;
-
-  linestocopy = (yheight >> (Fraction + 4));
-
-  if (linestocopy < 1)
-    linestocopy = 1;
-
-  linestocopy <<= 4;
-
-  yoffset  = ystride * ((yheight >> 5) * 16 - 8);
-  src_y = src_ybc->y_buffer + yoffset;
-  dst_y = dst_ybc->y_buffer + yoffset;
-
-  vpx_memcpy(dst_y, src_y, ystride * (linestocopy + 16));
+  vpx_memcpy(dst_ybc->y_buffer + offset, src_ybc->y_buffer + offset,
+             stride * (lines_to_copy + 16));
 }
 
 static int calc_partial_ssl_err(YV12_BUFFER_CONFIG *source,
@@ -126,13 +112,13 @@
 }
 
 void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi, int partial) {
-  VP9_COMMON *cm = &cpi->common;
-  struct loopfilter *lf = &cpi->common.lf;
+  VP9_COMMON *const cm = &cpi->common;
+  struct loopfilter *const lf = &cm->lf;
 
   int best_err = 0;
   int filt_err = 0;
-  int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
-  int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
+  const int min_filter_level = get_min_filter_level(cpi, cm->base_qindex);
+  const int max_filter_level = get_max_filter_level(cpi, cm->base_qindex);
 
   int filter_step;
   int filt_high = 0;
@@ -147,21 +133,14 @@
   //  Make a copy of the unfiltered / processed recon buffer
   vpx_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
 
-  if (cm->frame_type == KEY_FRAME)
-    lf->sharpness_level = 0;
-  else
-    lf->sharpness_level = cpi->oxcf.Sharpness;
+  lf->sharpness_level = cm->frame_type == KEY_FRAME ? 0
+                                                    : cpi->oxcf.Sharpness;
 
   // Start the search at the previous frame filter level unless it is now out of range.
-  filt_mid = lf->filter_level;
+  filt_mid = clamp(lf->filter_level, min_filter_level, max_filter_level);
 
-  if (filt_mid < min_filter_level)
-    filt_mid = min_filter_level;
-  else if (filt_mid > max_filter_level)
-    filt_mid = max_filter_level;
-
   // Define the initial step size
-  filter_step = (filt_mid < 16) ? 4 : filt_mid / 4;
+  filter_step = filt_mid < 16 ? 4 : filt_mid / 4;
 
   // Get baseline error score
   vp9_set_alt_lf_level(cpi, filt_mid);