shithub: libvpx

Download patch

ref: 816d6c989ce2773a79b51d92a2c9d0e7644e4fa1
parent: ace93a175de219fa0b9a643ef8c217dea4217564
author: Dmitry Kovalev <[email protected]>
date: Fri Aug 9 10:41:51 EDT 2013

Moving loopfilter struct to VP9_COMMON.

Loop filter configuration doesn't belong to macroblock, so moving it from
MACROBLOCKD to VP9_COMMON. Also moving the declaration of loopfilter struct
from vp9_blockd.h to vp9_loopfilter.h.

Change-Id: I4b3e34be9623b47cda35f9b1f9951f8c5b1d5d28

--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -217,27 +217,6 @@
 
 #define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n))
 
-#define MAX_REF_LF_DELTAS       4
-#define MAX_MODE_LF_DELTAS      2
-
-struct loopfilter {
-  int filter_level;
-
-  int sharpness_level;
-  int last_sharpness_level;
-
-  uint8_t mode_ref_delta_enabled;
-  uint8_t mode_ref_delta_update;
-
-  // 0 = Intra, Last, GF, ARF
-  signed char ref_deltas[MAX_REF_LF_DELTAS];
-  signed char last_ref_deltas[MAX_REF_LF_DELTAS];
-
-  // 0 = ZERO_MV, MV
-  signed char mode_deltas[MAX_MODE_LF_DELTAS];
-  signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
-};
-
 typedef struct macroblockd {
   struct macroblockd_plane plane[MAX_MB_PLANE];
 
@@ -252,7 +231,6 @@
   int right_available;
 
   struct segmentation seg;
-  struct loopfilter lf;
 
   // partition contexts
   PARTITION_CONTEXT *above_seg_context;
--- a/vp9/common/vp9_entropymode.c
+++ b/vp9/common/vp9_entropymode.c
@@ -473,7 +473,7 @@
 void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
   // Reset the segment feature data to the default stats:
   // Features disabled, 0, with delta coding (Default state).
-  struct loopfilter *const lf = &xd->lf;
+  struct loopfilter *const lf = &cm->lf;
 
   int i;
   vp9_clearall_segfeatures(&xd->seg);
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -85,7 +85,7 @@
   // 2 when filter_lvl is between 32 and 63
   const int n_shift = default_filt_lvl >> 5;
   loop_filter_info_n *const lfi = &cm->lf_info;
-  struct loopfilter *const lf = &xd->lf;
+  struct loopfilter *const lf = &cm->lf;
   struct segmentation *const seg = &xd->seg;
 
   // update limits if sharpness has changed
--- a/vp9/common/vp9_loopfilter.h
+++ b/vp9/common/vp9_loopfilter.h
@@ -22,6 +22,27 @@
 
 #define SIMD_WIDTH 16
 
+#define MAX_REF_LF_DELTAS       4
+#define MAX_MODE_LF_DELTAS      2
+
+struct loopfilter {
+  int filter_level;
+
+  int sharpness_level;
+  int last_sharpness_level;
+
+  uint8_t mode_ref_delta_enabled;
+  uint8_t mode_ref_delta_update;
+
+  // 0 = Intra, Last, GF, ARF
+  signed char ref_deltas[MAX_REF_LF_DELTAS];
+  signed char last_ref_deltas[MAX_REF_LF_DELTAS];
+
+  // 0 = ZERO_MV, MV
+  signed char mode_deltas[MAX_MODE_LF_DELTAS];
+  signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
+};
+
 // Need to align this structure so when it is declared and
 // passed it can be loaded into vector registers.
 typedef struct {
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -176,6 +176,8 @@
 
   int ref_frame_sign_bias[MAX_REF_FRAMES];    /* Two state 0, 1 */
 
+  struct loopfilter lf;
+
   /* Y,U,V */
   ENTROPY_CONTEXT *above_context[MAX_MB_PLANE];
   ENTROPY_CONTEXT left_context[MAX_MB_PLANE][16];
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -599,7 +599,7 @@
       lf_data->xd = pbi->mb;
       lf_data->y_only = 0;
     }
-    vp9_loop_filter_frame_init(pc, &pbi->mb, pbi->mb.lf.filter_level);
+    vp9_loop_filter_frame_init(pc, &pbi->mb, pc->lf.filter_level);
   }
 
   for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end;
@@ -813,7 +813,7 @@
     int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)];
     ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show);
     pbi->refresh_frame_flags = 0;
-    xd->lf.filter_level = 0;
+    cm->lf.filter_level = 0;
     return 0;
   }
 
@@ -897,7 +897,7 @@
   if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only)
     vp9_setup_past_independence(cm, xd);
 
-  setup_loopfilter(&xd->lf, rb);
+  setup_loopfilter(&cm->lf, rb);
   setup_quantization(pbi, rb);
   setup_segmentation(&xd->seg, rb);
 
@@ -961,7 +961,7 @@
   xd->corrupted = 0;
   new_fb->corrupted = 0;
   pbi->do_loopfilter_inline =
-      (pc->log2_tile_rows | pc->log2_tile_cols) == 0 && pbi->mb.lf.filter_level;
+      (pc->log2_tile_rows | pc->log2_tile_cols) == 0 && pc->lf.filter_level;
 
   if (!pbi->decoded_key_frame && !keyframe)
     return -1;
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -136,7 +136,7 @@
   // vp9_init_dequantizer() for every frame.
   vp9_init_dequantizer(&pbi->common);
 
-  vp9_loop_filter_init(&pbi->common, &pbi->mb.lf);
+  vp9_loop_filter_init(&pbi->common, &pbi->common.lf);
 
   pbi->common.error.setjmp = 0;
   pbi->decoded_key_frame = 0;
@@ -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, 0);
+      vp9_loop_filter_frame(cm, &pbi->mb, pbi->common.lf.filter_level, 0, 0);
     }
 
 #if WRITE_RECON_BUFFER == 2
@@ -424,7 +424,7 @@
   *time_end_stamp = 0;
 
 #if CONFIG_POSTPROC
-  ret = vp9_post_proc_frame(&pbi->common, &pbi->mb.lf, sd, flags);
+  ret = vp9_post_proc_frame(&pbi->common, &pbi->common.lf, sd, flags);
 #else
 
   if (pbi->common.frame_to_show) {
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -1342,7 +1342,7 @@
 
   vp9_wb_write_literal(wb, cm->frame_context_idx, NUM_FRAME_CONTEXTS_LOG2);
 
-  encode_loopfilter(&xd->lf, wb);
+  encode_loopfilter(&cm->lf, wb);
   encode_quantization(cm, wb);
   encode_segmentation(cpi, wb);
 
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -2023,7 +2023,7 @@
     cpi->mb.e_mbd.inv_txm4x4_1_add = vp9_short_iwalsh4x4_1_add;
     cpi->mb.e_mbd.inv_txm4x4_add = vp9_short_iwalsh4x4_add;
     cpi->mb.optimize = 0;
-    cpi->mb.e_mbd.lf.filter_level = 0;
+    cpi->common.lf.filter_level = 0;
     cpi->zbin_mode_boost_enabled = 0;
     cpi->common.tx_mode = ONLY_4X4;
   } else {
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -239,7 +239,7 @@
 
 static void setup_features(VP9_COMP *cpi) {
   MACROBLOCKD *xd = &cpi->mb.e_mbd;
-  struct loopfilter *const lf = &xd->lf;
+  struct loopfilter *const lf = &cpi->common.lf;
   struct segmentation *const seg = &xd->seg;
 
   // Set up default state for MB feature flags
@@ -543,7 +543,7 @@
 }
 
 static void set_default_lf_deltas(VP9_COMP *cpi) {
-  struct loopfilter *lf = &cpi->mb.e_mbd.lf;
+  struct loopfilter *lf = &cpi->common.lf;
 
   lf->mode_ref_delta_enabled = 1;
   lf->mode_ref_delta_update = 1;
@@ -1305,7 +1305,7 @@
   // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
   cpi->oxcf.Sharpness = MIN(7, cpi->oxcf.Sharpness);
 
-  cpi->mb.e_mbd.lf.sharpness_level = cpi->oxcf.Sharpness;
+  cpi->common.lf.sharpness_level = cpi->oxcf.Sharpness;
 
   if (cpi->initial_width) {
     // Increasing the size of the frame beyond the first seen frame, or some
@@ -1705,7 +1705,7 @@
    */
   vp9_init_quantizer(cpi);
 
-  vp9_loop_filter_init(cm, &cpi->mb.e_mbd.lf);
+  vp9_loop_filter_init(cm, &cpi->common.lf);
 
   cpi->common.error.setjmp = 0;
 
@@ -2426,7 +2426,7 @@
 
 static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
   MACROBLOCKD *xd = &cpi->mb.e_mbd;
-  struct loopfilter *lf = &xd->lf;
+  struct loopfilter *lf = &cm->lf;
   if (xd->lossless) {
       lf->filter_level = 0;
   } else {
@@ -2605,7 +2605,7 @@
   }
 
   // Set default state for segment based loop filter update flags
-  xd->lf.mode_ref_delta_update = 0;
+  cm->lf.mode_ref_delta_update = 0;
 
   // Initialize cpi->mv_step_param to default based on max resolution
   cpi->mv_step_param = vp9_init_search_range(cpi, max_mv_def);
@@ -3477,7 +3477,7 @@
   // Clear the one shot update flags for segmentation map and mode/ref loop filter deltas.
   xd->seg.update_map = 0;
   xd->seg.update_data = 0;
-  xd->lf.mode_ref_delta_update = 0;
+  cm->lf.mode_ref_delta_update = 0;
 
   // keep track of the last coded dimensions
   cm->last_width = cm->width;
@@ -3584,7 +3584,7 @@
          cpi->refresh_golden_frame ||
          cpi->refresh_alt_ref_frame ||
          cm->refresh_frame_context ||
-         mb->lf.mode_ref_delta_update ||
+         cm->lf.mode_ref_delta_update ||
          mb->seg.update_map ||
          mb->seg.update_data;
 }
@@ -3990,7 +3990,7 @@
   else {
     int ret;
 #if CONFIG_POSTPROC
-    ret = vp9_post_proc_frame(&cpi->common, &cpi->mb.e_mbd.lf, dest, flags);
+    ret = vp9_post_proc_frame(&cpi->common, &cpi->common.lf, dest, flags);
 #else
 
     if (cpi->common.frame_to_show) {
--- a/vp9/encoder/vp9_picklpf.c
+++ b/vp9/encoder/vp9_picklpf.c
@@ -127,7 +127,7 @@
 
 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;
+  struct loopfilter *lf = &cpi->common.lf;
 
   int best_err = 0;
   int filt_err = 0;
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -99,8 +99,8 @@
   vpx_memcpy(cpi->coding_context.last_frame_seg_map_copy,
              cm->last_frame_seg_map, (cm->mi_rows * cm->mi_cols));
 
-  vp9_copy(cc->last_ref_lf_deltas, xd->lf.last_ref_deltas);
-  vp9_copy(cc->last_mode_lf_deltas, xd->lf.last_mode_deltas);
+  vp9_copy(cc->last_ref_lf_deltas, cm->lf.last_ref_deltas);
+  vp9_copy(cc->last_mode_lf_deltas, cm->lf.last_mode_deltas);
 
   vp9_copy(cc->coef_probs, cm->fc.coef_probs);
   vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob);
@@ -138,8 +138,8 @@
              cpi->coding_context.last_frame_seg_map_copy,
              (cm->mi_rows * cm->mi_cols));
 
-  vp9_copy(xd->lf.last_ref_deltas, cc->last_ref_lf_deltas);
-  vp9_copy(xd->lf.last_mode_deltas, cc->last_mode_lf_deltas);
+  vp9_copy(cm->lf.last_ref_deltas, cc->last_ref_lf_deltas);
+  vp9_copy(cm->lf.last_mode_deltas, cc->last_mode_lf_deltas);
 
   vp9_copy(cm->fc.coef_probs, cc->coef_probs);
   vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob);