| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 | 11 | 
| 12 #include "vpx_ports/config.h" | 12 #include "vpx_config.h" | 
| 13 #include "loopfilter.h" | 13 #include "loopfilter.h" | 
| 14 #include "onyxc_int.h" | 14 #include "onyxc_int.h" | 
|  | 15 #include "vpx_mem/vpx_mem.h" | 
| 15 | 16 | 
| 16 typedef unsigned char uc; | 17 typedef unsigned char uc; | 
| 17 | 18 | 
| 18 |  | 
| 19 prototype_loopfilter(vp8_loop_filter_horizontal_edge_c); | 19 prototype_loopfilter(vp8_loop_filter_horizontal_edge_c); | 
| 20 prototype_loopfilter(vp8_loop_filter_vertical_edge_c); | 20 prototype_loopfilter(vp8_loop_filter_vertical_edge_c); | 
| 21 prototype_loopfilter(vp8_mbloop_filter_horizontal_edge_c); | 21 prototype_loopfilter(vp8_mbloop_filter_horizontal_edge_c); | 
| 22 prototype_loopfilter(vp8_mbloop_filter_vertical_edge_c); | 22 prototype_loopfilter(vp8_mbloop_filter_vertical_edge_c); | 
| 23 prototype_loopfilter(vp8_loop_filter_simple_horizontal_edge_c); | 23 | 
| 24 prototype_loopfilter(vp8_loop_filter_simple_vertical_edge_c); | 24 prototype_simple_loopfilter(vp8_loop_filter_simple_horizontal_edge_c); | 
|  | 25 prototype_simple_loopfilter(vp8_loop_filter_simple_vertical_edge_c); | 
| 25 | 26 | 
| 26 /* Horizontal MB filtering */ | 27 /* Horizontal MB filtering */ | 
| 27 void vp8_loop_filter_mbh_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned 
     char *v_ptr, | 28 void vp8_loop_filter_mbh_c(unsigned char *y_ptr, unsigned char *u_ptr, | 
| 28                            int y_stride, int uv_stride, loop_filter_info *lfi, i
     nt simpler_lpf) | 29                            unsigned char *v_ptr, int y_stride, int uv_stride, | 
|  | 30                            loop_filter_info *lfi) | 
| 29 { | 31 { | 
| 30     (void) simpler_lpf; | 32     vp8_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim, l
     fi->hev_thr, 2); | 
| 31     vp8_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->lim, 
     lfi->thr, 2); |  | 
| 32 | 33 | 
| 33     if (u_ptr) | 34     if (u_ptr) | 
| 34         vp8_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->mbflim, lfi->
     lim, lfi->thr, 1); | 35         vp8_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->l
     im, lfi->hev_thr, 1); | 
| 35 | 36 | 
| 36     if (v_ptr) | 37     if (v_ptr) | 
| 37         vp8_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->mbflim, lfi->
     lim, lfi->thr, 1); | 38         vp8_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->l
     im, lfi->hev_thr, 1); | 
| 38 } |  | 
| 39 |  | 
| 40 void vp8_loop_filter_mbhs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned
      char *v_ptr, |  | 
| 41                             int y_stride, int uv_stride, loop_filter_info *lfi, 
     int simpler_lpf) |  | 
| 42 { |  | 
| 43     (void) u_ptr; |  | 
| 44     (void) v_ptr; |  | 
| 45     (void) uv_stride; |  | 
| 46     (void) simpler_lpf; |  | 
| 47     vp8_loop_filter_simple_horizontal_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->
     lim, lfi->thr, 2); |  | 
| 48 } | 39 } | 
| 49 | 40 | 
| 50 /* Vertical MB Filtering */ | 41 /* Vertical MB Filtering */ | 
| 51 void vp8_loop_filter_mbv_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned 
     char *v_ptr, | 42 void vp8_loop_filter_mbv_c(unsigned char *y_ptr, unsigned char *u_ptr, | 
| 52                            int y_stride, int uv_stride, loop_filter_info *lfi, i
     nt simpler_lpf) | 43                            unsigned char *v_ptr, int y_stride, int uv_stride, | 
|  | 44                            loop_filter_info *lfi) | 
| 53 { | 45 { | 
| 54     (void) simpler_lpf; | 46     vp8_mbloop_filter_vertical_edge_c(y_ptr, y_stride, lfi->mblim, lfi->lim, lfi
     ->hev_thr, 2); | 
| 55     vp8_mbloop_filter_vertical_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->lim, lf
     i->thr, 2); |  | 
| 56 | 47 | 
| 57     if (u_ptr) | 48     if (u_ptr) | 
| 58         vp8_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->mbflim, lfi->li
     m, lfi->thr, 1); | 49         vp8_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->mblim, lfi->lim
     , lfi->hev_thr, 1); | 
| 59 | 50 | 
| 60     if (v_ptr) | 51     if (v_ptr) | 
| 61         vp8_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->mbflim, lfi->li
     m, lfi->thr, 1); | 52         vp8_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->mblim, lfi->lim
     , lfi->hev_thr, 1); | 
| 62 } |  | 
| 63 |  | 
| 64 void vp8_loop_filter_mbvs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned
      char *v_ptr, |  | 
| 65                             int y_stride, int uv_stride, loop_filter_info *lfi, 
     int simpler_lpf) |  | 
| 66 { |  | 
| 67     (void) u_ptr; |  | 
| 68     (void) v_ptr; |  | 
| 69     (void) uv_stride; |  | 
| 70     (void) simpler_lpf; |  | 
| 71     vp8_loop_filter_simple_vertical_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->li
     m, lfi->thr, 2); |  | 
| 72 } | 53 } | 
| 73 | 54 | 
| 74 /* Horizontal B Filtering */ | 55 /* Horizontal B Filtering */ | 
| 75 void vp8_loop_filter_bh_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned c
     har *v_ptr, | 56 void vp8_loop_filter_bh_c(unsigned char *y_ptr, unsigned char *u_ptr, | 
| 76                           int y_stride, int uv_stride, loop_filter_info *lfi, in
     t simpler_lpf) | 57                           unsigned char *v_ptr, int y_stride, int uv_stride, | 
|  | 58                           loop_filter_info *lfi) | 
| 77 { | 59 { | 
| 78     (void) simpler_lpf; | 60     vp8_loop_filter_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi->blim,
      lfi->lim, lfi->hev_thr, 2); | 
| 79     vp8_loop_filter_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi->flim,
      lfi->lim, lfi->thr, 2); | 61     vp8_loop_filter_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi->blim,
      lfi->lim, lfi->hev_thr, 2); | 
| 80     vp8_loop_filter_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi->flim,
      lfi->lim, lfi->thr, 2); | 62     vp8_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->blim
     , lfi->lim, lfi->hev_thr, 2); | 
| 81     vp8_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->flim
     , lfi->lim, lfi->thr, 2); |  | 
| 82 | 63 | 
| 83     if (u_ptr) | 64     if (u_ptr) | 
| 84         vp8_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, lfi-
     >flim, lfi->lim, lfi->thr, 1); | 65         vp8_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, lfi-
     >blim, lfi->lim, lfi->hev_thr, 1); | 
| 85 | 66 | 
| 86     if (v_ptr) | 67     if (v_ptr) | 
| 87         vp8_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, lfi-
     >flim, lfi->lim, lfi->thr, 1); | 68         vp8_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, lfi-
     >blim, lfi->lim, lfi->hev_thr, 1); | 
| 88 } | 69 } | 
| 89 | 70 | 
| 90 void vp8_loop_filter_bhs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned 
     char *v_ptr, | 71 void vp8_loop_filter_bhs_c(unsigned char *y_ptr, int y_stride, | 
| 91                            int y_stride, int uv_stride, loop_filter_info *lfi, i
     nt simpler_lpf) | 72                            const unsigned char *blimit) | 
| 92 { | 73 { | 
| 93     (void) u_ptr; | 74     vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, bli
     mit); | 
| 94     (void) v_ptr; | 75     vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, bli
     mit); | 
| 95     (void) uv_stride; | 76     vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, bl
     imit); | 
| 96     (void) simpler_lpf; |  | 
| 97     vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi
     ->flim, lfi->lim, lfi->thr, 2); |  | 
| 98     vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi
     ->flim, lfi->lim, lfi->thr, 2); |  | 
| 99     vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lf
     i->flim, lfi->lim, lfi->thr, 2); |  | 
| 100 } | 77 } | 
| 101 | 78 | 
| 102 /* Vertical B Filtering */ | 79 /* Vertical B Filtering */ | 
| 103 void vp8_loop_filter_bv_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned c
     har *v_ptr, | 80 void vp8_loop_filter_bv_c(unsigned char *y_ptr, unsigned char *u_ptr, | 
| 104                           int y_stride, int uv_stride, loop_filter_info *lfi, in
     t simpler_lpf) | 81                           unsigned char *v_ptr, int y_stride, int uv_stride, | 
|  | 82                           loop_filter_info *lfi) | 
| 105 { | 83 { | 
| 106     (void) simpler_lpf; | 84     vp8_loop_filter_vertical_edge_c(y_ptr + 4, y_stride, lfi->blim, lfi->lim, lf
     i->hev_thr, 2); | 
| 107     vp8_loop_filter_vertical_edge_c(y_ptr + 4, y_stride, lfi->flim, lfi->lim, lf
     i->thr, 2); | 85     vp8_loop_filter_vertical_edge_c(y_ptr + 8, y_stride, lfi->blim, lfi->lim, lf
     i->hev_thr, 2); | 
| 108     vp8_loop_filter_vertical_edge_c(y_ptr + 8, y_stride, lfi->flim, lfi->lim, lf
     i->thr, 2); | 86     vp8_loop_filter_vertical_edge_c(y_ptr + 12, y_stride, lfi->blim, lfi->lim, l
     fi->hev_thr, 2); | 
| 109     vp8_loop_filter_vertical_edge_c(y_ptr + 12, y_stride, lfi->flim, lfi->lim, l
     fi->thr, 2); |  | 
| 110 | 87 | 
| 111     if (u_ptr) | 88     if (u_ptr) | 
| 112         vp8_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, lfi->flim, lfi->li
     m, lfi->thr, 1); | 89         vp8_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, lfi->blim, lfi->li
     m, lfi->hev_thr, 1); | 
| 113 | 90 | 
| 114     if (v_ptr) | 91     if (v_ptr) | 
| 115         vp8_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, lfi->flim, lfi->li
     m, lfi->thr, 1); | 92         vp8_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, lfi->blim, lfi->li
     m, lfi->hev_thr, 1); | 
| 116 } | 93 } | 
| 117 | 94 | 
| 118 void vp8_loop_filter_bvs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned 
     char *v_ptr, | 95 void vp8_loop_filter_bvs_c(unsigned char *y_ptr, int y_stride, | 
| 119                            int y_stride, int uv_stride, loop_filter_info *lfi, i
     nt simpler_lpf) | 96                            const unsigned char *blimit) | 
| 120 { | 97 { | 
| 121     (void) u_ptr; | 98     vp8_loop_filter_simple_vertical_edge_c(y_ptr + 4, y_stride, blimit); | 
| 122     (void) v_ptr; | 99     vp8_loop_filter_simple_vertical_edge_c(y_ptr + 8, y_stride, blimit); | 
| 123     (void) uv_stride; | 100     vp8_loop_filter_simple_vertical_edge_c(y_ptr + 12, y_stride, blimit); | 
| 124     (void) simpler_lpf; |  | 
| 125     vp8_loop_filter_simple_vertical_edge_c(y_ptr + 4, y_stride, lfi->flim, lfi->
     lim, lfi->thr, 2); |  | 
| 126     vp8_loop_filter_simple_vertical_edge_c(y_ptr + 8, y_stride, lfi->flim, lfi->
     lim, lfi->thr, 2); |  | 
| 127     vp8_loop_filter_simple_vertical_edge_c(y_ptr + 12, y_stride, lfi->flim, lfi-
     >lim, lfi->thr, 2); |  | 
| 128 } | 101 } | 
| 129 | 102 | 
| 130 void vp8_init_loop_filter(VP8_COMMON *cm) | 103 static void lf_init_lut(loop_filter_info_n *lfi) | 
| 131 { | 104 { | 
| 132     loop_filter_info *lfi = cm->lf_info; | 105     int filt_lvl; | 
| 133     LOOPFILTERTYPE lft = cm->filter_type; |  | 
| 134     int sharpness_lvl = cm->sharpness_level; |  | 
| 135     int frame_type = cm->frame_type; |  | 
| 136     int i, j; |  | 
| 137 | 106 | 
| 138     int block_inside_limit = 0; | 107     for (filt_lvl = 0; filt_lvl <= MAX_LOOP_FILTER; filt_lvl++) | 
| 139     int HEVThresh; | 108     { | 
|  | 109         if (filt_lvl >= 40) | 
|  | 110         { | 
|  | 111             lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 2; | 
|  | 112             lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 3; | 
|  | 113         } | 
|  | 114         else if (filt_lvl >= 20) | 
|  | 115         { | 
|  | 116             lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1; | 
|  | 117             lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 2; | 
|  | 118         } | 
|  | 119         else if (filt_lvl >= 15) | 
|  | 120         { | 
|  | 121             lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1; | 
|  | 122             lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 1; | 
|  | 123         } | 
|  | 124         else | 
|  | 125         { | 
|  | 126             lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 0; | 
|  | 127             lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 0; | 
|  | 128         } | 
|  | 129     } | 
| 140 | 130 | 
| 141     /* For each possible value for the loop filter fill out a "loop_filter_info"
      entry. */ | 131     lfi->mode_lf_lut[DC_PRED] = 1; | 
|  | 132     lfi->mode_lf_lut[V_PRED] = 1; | 
|  | 133     lfi->mode_lf_lut[H_PRED] = 1; | 
|  | 134     lfi->mode_lf_lut[TM_PRED] = 1; | 
|  | 135     lfi->mode_lf_lut[B_PRED]  = 0; | 
|  | 136 | 
|  | 137     lfi->mode_lf_lut[ZEROMV]  = 1; | 
|  | 138     lfi->mode_lf_lut[NEARESTMV] = 2; | 
|  | 139     lfi->mode_lf_lut[NEARMV] = 2; | 
|  | 140     lfi->mode_lf_lut[NEWMV] = 2; | 
|  | 141     lfi->mode_lf_lut[SPLITMV] = 3; | 
|  | 142 | 
|  | 143 } | 
|  | 144 | 
|  | 145 void vp8_loop_filter_update_sharpness(loop_filter_info_n *lfi, | 
|  | 146                                       int sharpness_lvl) | 
|  | 147 { | 
|  | 148     int i; | 
|  | 149 | 
|  | 150     /* For each possible value for the loop filter fill out limits */ | 
| 142     for (i = 0; i <= MAX_LOOP_FILTER; i++) | 151     for (i = 0; i <= MAX_LOOP_FILTER; i++) | 
| 143     { | 152     { | 
| 144         int filt_lvl = i; | 153         int filt_lvl = i; | 
| 145 | 154         int block_inside_limit = 0; | 
| 146         if (frame_type == KEY_FRAME) |  | 
| 147         { |  | 
| 148             if (filt_lvl >= 40) |  | 
| 149                 HEVThresh = 2; |  | 
| 150             else if (filt_lvl >= 15) |  | 
| 151                 HEVThresh = 1; |  | 
| 152             else |  | 
| 153                 HEVThresh = 0; |  | 
| 154         } |  | 
| 155         else |  | 
| 156         { |  | 
| 157             if (filt_lvl >= 40) |  | 
| 158                 HEVThresh = 3; |  | 
| 159             else if (filt_lvl >= 20) |  | 
| 160                 HEVThresh = 2; |  | 
| 161             else if (filt_lvl >= 15) |  | 
| 162                 HEVThresh = 1; |  | 
| 163             else |  | 
| 164                 HEVThresh = 0; |  | 
| 165         } |  | 
| 166 | 155 | 
| 167         /* Set loop filter paramaeters that control sharpness. */ | 156         /* Set loop filter paramaeters that control sharpness. */ | 
| 168         block_inside_limit = filt_lvl >> (sharpness_lvl > 0); | 157         block_inside_limit = filt_lvl >> (sharpness_lvl > 0); | 
| 169         block_inside_limit = block_inside_limit >> (sharpness_lvl > 4); | 158         block_inside_limit = block_inside_limit >> (sharpness_lvl > 4); | 
| 170 | 159 | 
| 171         if (sharpness_lvl > 0) | 160         if (sharpness_lvl > 0) | 
| 172         { | 161         { | 
| 173             if (block_inside_limit > (9 - sharpness_lvl)) | 162             if (block_inside_limit > (9 - sharpness_lvl)) | 
| 174                 block_inside_limit = (9 - sharpness_lvl); | 163                 block_inside_limit = (9 - sharpness_lvl); | 
| 175         } | 164         } | 
| 176 | 165 | 
| 177         if (block_inside_limit < 1) | 166         if (block_inside_limit < 1) | 
| 178             block_inside_limit = 1; | 167             block_inside_limit = 1; | 
| 179 | 168 | 
| 180         for (j = 0; j < 16; j++) | 169         vpx_memset(lfi->lim[i], block_inside_limit, SIMD_WIDTH); | 
| 181         { | 170         vpx_memset(lfi->blim[i], (2 * filt_lvl + block_inside_limit), | 
| 182             lfi[i].lim[j] = block_inside_limit; | 171                 SIMD_WIDTH); | 
| 183             lfi[i].mbflim[j] = filt_lvl + 2; | 172         vpx_memset(lfi->mblim[i], (2 * (filt_lvl + 2) + block_inside_limit), | 
| 184             lfi[i].flim[j] = filt_lvl; | 173                 SIMD_WIDTH); | 
| 185             lfi[i].thr[j] = HEVThresh; |  | 
| 186         } |  | 
| 187 |  | 
| 188     } |  | 
| 189 |  | 
| 190     /* Set up the function pointers depending on the type of loop filtering sele
     cted */ |  | 
| 191     if (lft == NORMAL_LOOPFILTER) |  | 
| 192     { |  | 
| 193         cm->lf_mbv = LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v); |  | 
| 194         cm->lf_bv  = LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v); |  | 
| 195         cm->lf_mbh = LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h); |  | 
| 196         cm->lf_bh  = LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h); |  | 
| 197     } |  | 
| 198     else |  | 
| 199     { |  | 
| 200         cm->lf_mbv = LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v); |  | 
| 201         cm->lf_bv  = LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v); |  | 
| 202         cm->lf_mbh = LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h); |  | 
| 203         cm->lf_bh  = LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h); |  | 
| 204     } | 174     } | 
| 205 } | 175 } | 
| 206 | 176 | 
| 207 /* Put vp8_init_loop_filter() in vp8dx_create_decompressor(). Only call vp8_fram
     e_init_loop_filter() while decoding | 177 void vp8_loop_filter_init(VP8_COMMON *cm) | 
| 208  * each frame. Check last_frame_type to skip the function most of times. |  | 
| 209  */ |  | 
| 210 void vp8_frame_init_loop_filter(loop_filter_info *lfi, int frame_type) |  | 
| 211 { | 178 { | 
| 212     int HEVThresh; | 179     loop_filter_info_n *lfi = &cm->lf_info; | 
| 213     int i, j; | 180     int i; | 
| 214 | 181 | 
| 215     /* For each possible value for the loop filter fill out a "loop_filter_info"
      entry. */ | 182     /* init limits for given sharpness*/ | 
| 216     for (i = 0; i <= MAX_LOOP_FILTER; i++) | 183     vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level); | 
|  | 184     cm->last_sharpness_level = cm->sharpness_level; | 
|  | 185 | 
|  | 186     /* init LUT for lvl  and hev thr picking */ | 
|  | 187     lf_init_lut(lfi); | 
|  | 188 | 
|  | 189     /* init hev threshold const vectors */ | 
|  | 190     for(i = 0; i < 4 ; i++) | 
| 217     { | 191     { | 
| 218         int filt_lvl = i; | 192         vpx_memset(lfi->hev_thr[i], i, SIMD_WIDTH); | 
|  | 193     } | 
|  | 194 } | 
| 219 | 195 | 
| 220         if (frame_type == KEY_FRAME) | 196 void vp8_loop_filter_frame_init(VP8_COMMON *cm, | 
|  | 197                                 MACROBLOCKD *mbd, | 
|  | 198                                 int default_filt_lvl) | 
|  | 199 { | 
|  | 200     int seg,  /* segment number */ | 
|  | 201         ref,  /* index in ref_lf_deltas */ | 
|  | 202         mode; /* index in mode_lf_deltas */ | 
|  | 203 | 
|  | 204     loop_filter_info_n *lfi = &cm->lf_info; | 
|  | 205 | 
|  | 206     /* update limits if sharpness has changed */ | 
|  | 207     if(cm->last_sharpness_level != cm->sharpness_level) | 
|  | 208     { | 
|  | 209         vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level); | 
|  | 210         cm->last_sharpness_level = cm->sharpness_level; | 
|  | 211     } | 
|  | 212 | 
|  | 213     for(seg = 0; seg < MAX_MB_SEGMENTS; seg++) | 
|  | 214     { | 
|  | 215         int lvl_seg = default_filt_lvl; | 
|  | 216         int lvl_ref, lvl_mode; | 
|  | 217 | 
|  | 218         /* Note the baseline filter values for each segment */ | 
|  | 219         if (mbd->segmentation_enabled) | 
| 221         { | 220         { | 
| 222             if (filt_lvl >= 40) | 221             /* Abs value */ | 
| 223                 HEVThresh = 2; | 222             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA) | 
| 224             else if (filt_lvl >= 15) | 223             { | 
| 225                 HEVThresh = 1; | 224                 lvl_seg = mbd->segment_feature_data[MB_LVL_ALT_LF][seg]; | 
| 226             else | 225             } | 
| 227                 HEVThresh = 0; | 226             else  /* Delta Value */ | 
| 228         } | 227             { | 
| 229         else | 228                 lvl_seg += mbd->segment_feature_data[MB_LVL_ALT_LF][seg]; | 
| 230         { | 229                 lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0; | 
| 231             if (filt_lvl >= 40) | 230             } | 
| 232                 HEVThresh = 3; |  | 
| 233             else if (filt_lvl >= 20) |  | 
| 234                 HEVThresh = 2; |  | 
| 235             else if (filt_lvl >= 15) |  | 
| 236                 HEVThresh = 1; |  | 
| 237             else |  | 
| 238                 HEVThresh = 0; |  | 
| 239         } | 231         } | 
| 240 | 232 | 
| 241         for (j = 0; j < 16; j++) | 233         if (!mbd->mode_ref_lf_delta_enabled) | 
| 242         { | 234         { | 
| 243             /*lfi[i].lim[j] = block_inside_limit; | 235             /* we could get rid of this if we assume that deltas are set to | 
| 244             lfi[i].mbflim[j] = filt_lvl+2;*/ | 236              * zero when not in use; encoder always uses deltas | 
| 245             /*lfi[i].flim[j] = filt_lvl;*/ | 237              */ | 
| 246             lfi[i].thr[j] = HEVThresh; | 238             vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4 ); | 
|  | 239             continue; | 
|  | 240         } | 
|  | 241 | 
|  | 242         lvl_ref = lvl_seg; | 
|  | 243 | 
|  | 244         /* INTRA_FRAME */ | 
|  | 245         ref = INTRA_FRAME; | 
|  | 246 | 
|  | 247         /* Apply delta for reference frame */ | 
|  | 248         lvl_ref += mbd->ref_lf_deltas[ref]; | 
|  | 249 | 
|  | 250         /* Apply delta for Intra modes */ | 
|  | 251         mode = 0; /* B_PRED */ | 
|  | 252         /* Only the split mode BPRED has a further special case */ | 
|  | 253         lvl_mode = lvl_ref +  mbd->mode_lf_deltas[mode]; | 
|  | 254         lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clam
     p */ | 
|  | 255 | 
|  | 256         lfi->lvl[seg][ref][mode] = lvl_mode; | 
|  | 257 | 
|  | 258         mode = 1; /* all the rest of Intra modes */ | 
|  | 259         lvl_mode = (lvl_ref > 0) ? (lvl_ref > 63 ? 63 : lvl_ref)  : 0; /* clamp 
     */ | 
|  | 260         lfi->lvl[seg][ref][mode] = lvl_mode; | 
|  | 261 | 
|  | 262         /* LAST, GOLDEN, ALT */ | 
|  | 263         for(ref = 1; ref < MAX_REF_FRAMES; ref++) | 
|  | 264         { | 
|  | 265             int lvl_ref = lvl_seg; | 
|  | 266 | 
|  | 267             /* Apply delta for reference frame */ | 
|  | 268             lvl_ref += mbd->ref_lf_deltas[ref]; | 
|  | 269 | 
|  | 270             /* Apply delta for Inter modes */ | 
|  | 271             for (mode = 1; mode < 4; mode++) | 
|  | 272             { | 
|  | 273                 lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode]; | 
|  | 274                 lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0;
      /* clamp */ | 
|  | 275 | 
|  | 276                 lfi->lvl[seg][ref][mode] = lvl_mode; | 
|  | 277             } | 
| 247         } | 278         } | 
| 248     } | 279     } | 
| 249 } | 280 } | 
| 250 | 281 | 
| 251 |  | 
| 252 int vp8_adjust_mb_lf_value(MACROBLOCKD *mbd, int filter_level) |  | 
| 253 { |  | 
| 254     MB_MODE_INFO *mbmi = &mbd->mode_info_context->mbmi; |  | 
| 255 |  | 
| 256     if (mbd->mode_ref_lf_delta_enabled) |  | 
| 257     { |  | 
| 258         /* Apply delta for reference frame */ |  | 
| 259         filter_level += mbd->ref_lf_deltas[mbmi->ref_frame]; |  | 
| 260 |  | 
| 261         /* Apply delta for mode */ |  | 
| 262         if (mbmi->ref_frame == INTRA_FRAME) |  | 
| 263         { |  | 
| 264             /* Only the split mode BPRED has a further special case */ |  | 
| 265             if (mbmi->mode == B_PRED) |  | 
| 266                 filter_level +=  mbd->mode_lf_deltas[0]; |  | 
| 267         } |  | 
| 268         else |  | 
| 269         { |  | 
| 270             /* Zero motion mode */ |  | 
| 271             if (mbmi->mode == ZEROMV) |  | 
| 272                 filter_level +=  mbd->mode_lf_deltas[1]; |  | 
| 273 |  | 
| 274             /* Split MB motion mode */ |  | 
| 275             else if (mbmi->mode == SPLITMV) |  | 
| 276                 filter_level +=  mbd->mode_lf_deltas[3]; |  | 
| 277 |  | 
| 278             /* All other inter motion modes (Nearest, Near, New) */ |  | 
| 279             else |  | 
| 280                 filter_level +=  mbd->mode_lf_deltas[2]; |  | 
| 281         } |  | 
| 282 |  | 
| 283         /* Range check */ |  | 
| 284         if (filter_level > MAX_LOOP_FILTER) |  | 
| 285             filter_level = MAX_LOOP_FILTER; |  | 
| 286         else if (filter_level < 0) |  | 
| 287             filter_level = 0; |  | 
| 288     } |  | 
| 289     return filter_level; |  | 
| 290 } |  | 
| 291 |  | 
| 292 |  | 
| 293 void vp8_loop_filter_frame | 282 void vp8_loop_filter_frame | 
| 294 ( | 283 ( | 
| 295     VP8_COMMON *cm, | 284     VP8_COMMON *cm, | 
| 296     MACROBLOCKD *mbd, | 285     MACROBLOCKD *mbd | 
| 297     int default_filt_lvl |  | 
| 298 ) | 286 ) | 
| 299 { | 287 { | 
| 300     YV12_BUFFER_CONFIG *post = cm->frame_to_show; | 288     YV12_BUFFER_CONFIG *post = cm->frame_to_show; | 
| 301     loop_filter_info *lfi = cm->lf_info; | 289     loop_filter_info_n *lfi_n = &cm->lf_info; | 
|  | 290     loop_filter_info lfi; | 
|  | 291 | 
| 302     FRAME_TYPE frame_type = cm->frame_type; | 292     FRAME_TYPE frame_type = cm->frame_type; | 
| 303 | 293 | 
| 304     int mb_row; | 294     int mb_row; | 
| 305     int mb_col; | 295     int mb_col; | 
| 306 | 296 | 
|  | 297     int filter_level; | 
| 307 | 298 | 
| 308     int baseline_filter_level[MAX_MB_SEGMENTS]; |  | 
| 309     int filter_level; |  | 
| 310     int alt_flt_enabled = mbd->segmentation_enabled; |  | 
| 311 |  | 
| 312     int i; |  | 
| 313     unsigned char *y_ptr, *u_ptr, *v_ptr; | 299     unsigned char *y_ptr, *u_ptr, *v_ptr; | 
| 314 | 300 | 
| 315     mbd->mode_info_context = cm->mi;          /* Point at base of Mb MODE_INFO l
     ist */ | 301     /* Point at base of Mb MODE_INFO list */ | 
| 316 | 302     const MODE_INFO *mode_info_context = cm->mi; | 
| 317     /* Note the baseline filter values for each segment */ |  | 
| 318     if (alt_flt_enabled) |  | 
| 319     { |  | 
| 320         for (i = 0; i < MAX_MB_SEGMENTS; i++) |  | 
| 321         { |  | 
| 322             /* Abs value */ |  | 
| 323             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA) |  | 
| 324                 baseline_filter_level[i] = mbd->segment_feature_data[MB_LVL_ALT_
     LF][i]; |  | 
| 325             /* Delta Value */ |  | 
| 326             else |  | 
| 327             { |  | 
| 328                 baseline_filter_level[i] = default_filt_lvl + mbd->segment_featu
     re_data[MB_LVL_ALT_LF][i]; |  | 
| 329                 baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((b
     aseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOO
     P_FILTER) : 0;  /* Clamp to valid range */ |  | 
| 330             } |  | 
| 331         } |  | 
| 332     } |  | 
| 333     else |  | 
| 334     { |  | 
| 335         for (i = 0; i < MAX_MB_SEGMENTS; i++) |  | 
| 336             baseline_filter_level[i] = default_filt_lvl; |  | 
| 337     } |  | 
| 338 | 303 | 
| 339     /* Initialize the loop filter for this frame. */ | 304     /* Initialize the loop filter for this frame. */ | 
| 340     if ((cm->last_filter_type != cm->filter_type) || (cm->last_sharpness_level !
     = cm->sharpness_level)) | 305     vp8_loop_filter_frame_init(cm, mbd, cm->filter_level); | 
| 341         vp8_init_loop_filter(cm); |  | 
| 342     else if (frame_type != cm->last_frame_type) |  | 
| 343         vp8_frame_init_loop_filter(lfi, frame_type); |  | 
| 344 | 306 | 
| 345     /* Set up the buffer pointers */ | 307     /* Set up the buffer pointers */ | 
| 346     y_ptr = post->y_buffer; | 308     y_ptr = post->y_buffer; | 
| 347     u_ptr = post->u_buffer; | 309     u_ptr = post->u_buffer; | 
| 348     v_ptr = post->v_buffer; | 310     v_ptr = post->v_buffer; | 
| 349 | 311 | 
| 350     /* vp8_filter each macro block */ | 312     /* vp8_filter each macro block */ | 
| 351     for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) | 313     for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) | 
| 352     { | 314     { | 
| 353         for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) | 315         for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) | 
| 354         { | 316         { | 
| 355             int Segment = (alt_flt_enabled) ? mbd->mode_info_context->mbmi.segme
     nt_id : 0; | 317             int skip_lf = (mode_info_context->mbmi.mode != B_PRED && | 
|  | 318                             mode_info_context->mbmi.mode != SPLITMV && | 
|  | 319                             mode_info_context->mbmi.mb_skip_coeff); | 
| 356 | 320 | 
| 357             filter_level = baseline_filter_level[Segment]; | 321             const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mo
     de]; | 
|  | 322             const int seg = mode_info_context->mbmi.segment_id; | 
|  | 323             const int ref_frame = mode_info_context->mbmi.ref_frame; | 
| 358 | 324 | 
| 359             /* Distance of Mb to the various image edges. | 325             filter_level = lfi_n->lvl[seg][ref_frame][mode_index]; | 
| 360              * These specified to 8th pel as they are always compared to values 
     that are in 1/8th pel units |  | 
| 361              * Apply any context driven MB level adjustment |  | 
| 362              */ |  | 
| 363             filter_level = vp8_adjust_mb_lf_value(mbd, filter_level); |  | 
| 364 | 326 | 
| 365             if (filter_level) | 327             if (filter_level) | 
| 366             { | 328             { | 
| 367                 if (mb_col > 0) | 329                 if (cm->filter_type == NORMAL_LOOPFILTER) | 
| 368                     cm->lf_mbv(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_str
     ide, &lfi[filter_level], cm->simpler_lpf); | 330                 { | 
|  | 331                     const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_
     level]; | 
|  | 332                     lfi.mblim = lfi_n->mblim[filter_level]; | 
|  | 333                     lfi.blim = lfi_n->blim[filter_level]; | 
|  | 334                     lfi.lim = lfi_n->lim[filter_level]; | 
|  | 335                     lfi.hev_thr = lfi_n->hev_thr[hev_index]; | 
| 369 | 336 | 
| 370                 if (mbd->mode_info_context->mbmi.dc_diff > 0) | 337                     if (mb_col > 0) | 
| 371                     cm->lf_bv(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stri
     de, &lfi[filter_level], cm->simpler_lpf); | 338                         LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v) | 
|  | 339                         (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &
     lfi); | 
| 372 | 340 | 
| 373                 /* don't apply across umv border */ | 341                     if (!skip_lf) | 
| 374                 if (mb_row > 0) | 342                         LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v) | 
| 375                     cm->lf_mbh(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_str
     ide, &lfi[filter_level], cm->simpler_lpf); | 343                         (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &
     lfi); | 
| 376 | 344 | 
| 377                 if (mbd->mode_info_context->mbmi.dc_diff > 0) | 345                     /* don't apply across umv border */ | 
| 378                     cm->lf_bh(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stri
     de, &lfi[filter_level], cm->simpler_lpf); | 346                     if (mb_row > 0) | 
|  | 347                         LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h) | 
|  | 348                         (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &
     lfi); | 
|  | 349 | 
|  | 350                     if (!skip_lf) | 
|  | 351                         LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h) | 
|  | 352                         (y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &
     lfi); | 
|  | 353                 } | 
|  | 354                 else | 
|  | 355                 { | 
|  | 356                     if (mb_col > 0) | 
|  | 357                         LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v) | 
|  | 358                         (y_ptr, post->y_stride, lfi_n->mblim[filter_level]); | 
|  | 359 | 
|  | 360                     if (!skip_lf) | 
|  | 361                         LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v) | 
|  | 362                         (y_ptr, post->y_stride, lfi_n->blim[filter_level]); | 
|  | 363 | 
|  | 364                     /* don't apply across umv border */ | 
|  | 365                     if (mb_row > 0) | 
|  | 366                         LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h) | 
|  | 367                         (y_ptr, post->y_stride, lfi_n->mblim[filter_level]); | 
|  | 368 | 
|  | 369                     if (!skip_lf) | 
|  | 370                         LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h) | 
|  | 371                         (y_ptr, post->y_stride, lfi_n->blim[filter_level]); | 
|  | 372                 } | 
| 379             } | 373             } | 
| 380 | 374 | 
| 381             y_ptr += 16; | 375             y_ptr += 16; | 
| 382             u_ptr += 8; | 376             u_ptr += 8; | 
| 383             v_ptr += 8; | 377             v_ptr += 8; | 
| 384 | 378 | 
| 385             mbd->mode_info_context++;     /* step to next MB */ | 379             mode_info_context++;     /* step to next MB */ | 
| 386         } | 380         } | 
| 387 | 381 | 
| 388         y_ptr += post->y_stride  * 16 - post->y_width; | 382         y_ptr += post->y_stride  * 16 - post->y_width; | 
| 389         u_ptr += post->uv_stride *  8 - post->uv_width; | 383         u_ptr += post->uv_stride *  8 - post->uv_width; | 
| 390         v_ptr += post->uv_stride *  8 - post->uv_width; | 384         v_ptr += post->uv_stride *  8 - post->uv_width; | 
| 391 | 385 | 
| 392         mbd->mode_info_context++;         /* Skip border mb */ | 386         mode_info_context++;         /* Skip border mb */ | 
| 393     } | 387     } | 
| 394 } | 388 } | 
| 395 | 389 | 
| 396 |  | 
| 397 void vp8_loop_filter_frame_yonly | 390 void vp8_loop_filter_frame_yonly | 
| 398 ( | 391 ( | 
| 399     VP8_COMMON *cm, | 392     VP8_COMMON *cm, | 
| 400     MACROBLOCKD *mbd, | 393     MACROBLOCKD *mbd, | 
| 401     int default_filt_lvl, | 394     int default_filt_lvl | 
| 402     int sharpness_lvl |  | 
| 403 ) | 395 ) | 
| 404 { | 396 { | 
| 405     YV12_BUFFER_CONFIG *post = cm->frame_to_show; | 397     YV12_BUFFER_CONFIG *post = cm->frame_to_show; | 
| 406 | 398 | 
| 407     int i; |  | 
| 408     unsigned char *y_ptr; | 399     unsigned char *y_ptr; | 
| 409     int mb_row; | 400     int mb_row; | 
| 410     int mb_col; | 401     int mb_col; | 
| 411 | 402 | 
| 412     loop_filter_info *lfi = cm->lf_info; | 403     loop_filter_info_n *lfi_n = &cm->lf_info; | 
| 413     int baseline_filter_level[MAX_MB_SEGMENTS]; | 404     loop_filter_info lfi; | 
|  | 405 | 
| 414     int filter_level; | 406     int filter_level; | 
| 415     int alt_flt_enabled = mbd->segmentation_enabled; |  | 
| 416     FRAME_TYPE frame_type = cm->frame_type; | 407     FRAME_TYPE frame_type = cm->frame_type; | 
| 417 | 408 | 
| 418     (void) sharpness_lvl; | 409     /* Point at base of Mb MODE_INFO list */ | 
|  | 410     const MODE_INFO *mode_info_context = cm->mi; | 
| 419 | 411 | 
| 420     /*MODE_INFO * this_mb_mode_info = cm->mi;*/ /* Point at base of Mb MODE_INFO
      list */ | 412 #if 0 | 
| 421     mbd->mode_info_context = cm->mi;          /* Point at base of Mb MODE_INFO l
     ist */ | 413     if(default_filt_lvl == 0) /* no filter applied */ | 
| 422 | 414         return; | 
| 423     /* Note the baseline filter values for each segment */ | 415 #endif | 
| 424     if (alt_flt_enabled) |  | 
| 425     { |  | 
| 426         for (i = 0; i < MAX_MB_SEGMENTS; i++) |  | 
| 427         { |  | 
| 428             /* Abs value */ |  | 
| 429             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA) |  | 
| 430                 baseline_filter_level[i] = mbd->segment_feature_data[MB_LVL_ALT_
     LF][i]; |  | 
| 431             /* Delta Value */ |  | 
| 432             else |  | 
| 433             { |  | 
| 434                 baseline_filter_level[i] = default_filt_lvl + mbd->segment_featu
     re_data[MB_LVL_ALT_LF][i]; |  | 
| 435                 baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((b
     aseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOO
     P_FILTER) : 0;  /* Clamp to valid range */ |  | 
| 436             } |  | 
| 437         } |  | 
| 438     } |  | 
| 439     else |  | 
| 440     { |  | 
| 441         for (i = 0; i < MAX_MB_SEGMENTS; i++) |  | 
| 442             baseline_filter_level[i] = default_filt_lvl; |  | 
| 443     } |  | 
| 444 | 416 | 
| 445     /* Initialize the loop filter for this frame. */ | 417     /* Initialize the loop filter for this frame. */ | 
| 446     if ((cm->last_filter_type != cm->filter_type) || (cm->last_sharpness_level !
     = cm->sharpness_level)) | 418     vp8_loop_filter_frame_init( cm, mbd, default_filt_lvl); | 
| 447         vp8_init_loop_filter(cm); |  | 
| 448     else if (frame_type != cm->last_frame_type) |  | 
| 449         vp8_frame_init_loop_filter(lfi, frame_type); |  | 
| 450 | 419 | 
| 451     /* Set up the buffer pointers */ | 420     /* Set up the buffer pointers */ | 
| 452     y_ptr = post->y_buffer; | 421     y_ptr = post->y_buffer; | 
| 453 | 422 | 
| 454     /* vp8_filter each macro block */ | 423     /* vp8_filter each macro block */ | 
| 455     for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) | 424     for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) | 
| 456     { | 425     { | 
| 457         for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) | 426         for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) | 
| 458         { | 427         { | 
| 459             int Segment = (alt_flt_enabled) ? mbd->mode_info_context->mbmi.segme
     nt_id : 0; | 428             int skip_lf = (mode_info_context->mbmi.mode != B_PRED && | 
| 460             filter_level = baseline_filter_level[Segment]; | 429                             mode_info_context->mbmi.mode != SPLITMV && | 
|  | 430                             mode_info_context->mbmi.mb_skip_coeff); | 
| 461 | 431 | 
| 462             /* Apply any context driven MB level adjustment */ | 432             const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mo
     de]; | 
| 463             filter_level = vp8_adjust_mb_lf_value(mbd, filter_level); | 433             const int seg = mode_info_context->mbmi.segment_id; | 
|  | 434             const int ref_frame = mode_info_context->mbmi.ref_frame; | 
|  | 435 | 
|  | 436             filter_level = lfi_n->lvl[seg][ref_frame][mode_index]; | 
| 464 | 437 | 
| 465             if (filter_level) | 438             if (filter_level) | 
| 466             { | 439             { | 
| 467                 if (mb_col > 0) | 440                 if (cm->filter_type == NORMAL_LOOPFILTER) | 
| 468                     cm->lf_mbv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level
     ], 0); | 441                 { | 
|  | 442                     const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_
     level]; | 
|  | 443                     lfi.mblim = lfi_n->mblim[filter_level]; | 
|  | 444                     lfi.blim = lfi_n->blim[filter_level]; | 
|  | 445                     lfi.lim = lfi_n->lim[filter_level]; | 
|  | 446                     lfi.hev_thr = lfi_n->hev_thr[hev_index]; | 
| 469 | 447 | 
| 470                 if (mbd->mode_info_context->mbmi.dc_diff > 0) | 448                     if (mb_col > 0) | 
| 471                     cm->lf_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level]
     , 0); | 449                         LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v) | 
|  | 450                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
| 472 | 451 | 
| 473                 /* don't apply across umv border */ | 452                     if (!skip_lf) | 
| 474                 if (mb_row > 0) | 453                         LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v) | 
| 475                     cm->lf_mbh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level
     ], 0); | 454                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
| 476 | 455 | 
| 477                 if (mbd->mode_info_context->mbmi.dc_diff > 0) | 456                     /* don't apply across umv border */ | 
| 478                     cm->lf_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level]
     , 0); | 457                     if (mb_row > 0) | 
|  | 458                         LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h) | 
|  | 459                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
|  | 460 | 
|  | 461                     if (!skip_lf) | 
|  | 462                         LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h) | 
|  | 463                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
|  | 464                 } | 
|  | 465                 else | 
|  | 466                 { | 
|  | 467                     if (mb_col > 0) | 
|  | 468                         LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v) | 
|  | 469                         (y_ptr, post->y_stride, lfi_n->mblim[filter_level]); | 
|  | 470 | 
|  | 471                     if (!skip_lf) | 
|  | 472                         LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v) | 
|  | 473                         (y_ptr, post->y_stride, lfi_n->blim[filter_level]); | 
|  | 474 | 
|  | 475                     /* don't apply across umv border */ | 
|  | 476                     if (mb_row > 0) | 
|  | 477                         LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h) | 
|  | 478                         (y_ptr, post->y_stride, lfi_n->mblim[filter_level]); | 
|  | 479 | 
|  | 480                     if (!skip_lf) | 
|  | 481                         LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h) | 
|  | 482                         (y_ptr, post->y_stride, lfi_n->blim[filter_level]); | 
|  | 483                 } | 
| 479             } | 484             } | 
| 480 | 485 | 
| 481             y_ptr += 16; | 486             y_ptr += 16; | 
| 482             mbd->mode_info_context ++;        /* step to next MB */ | 487             mode_info_context ++;        /* step to next MB */ | 
| 483 | 488 | 
| 484         } | 489         } | 
| 485 | 490 | 
| 486         y_ptr += post->y_stride  * 16 - post->y_width; | 491         y_ptr += post->y_stride  * 16 - post->y_width; | 
| 487         mbd->mode_info_context ++;            /* Skip border mb */ | 492         mode_info_context ++;            /* Skip border mb */ | 
| 488     } | 493     } | 
| 489 | 494 | 
| 490 } | 495 } | 
| 491 | 496 | 
| 492 |  | 
| 493 void vp8_loop_filter_partial_frame | 497 void vp8_loop_filter_partial_frame | 
| 494 ( | 498 ( | 
| 495     VP8_COMMON *cm, | 499     VP8_COMMON *cm, | 
| 496     MACROBLOCKD *mbd, | 500     MACROBLOCKD *mbd, | 
| 497     int default_filt_lvl, | 501     int default_filt_lvl | 
| 498     int sharpness_lvl, |  | 
| 499     int Fraction |  | 
| 500 ) | 502 ) | 
| 501 { | 503 { | 
| 502     YV12_BUFFER_CONFIG *post = cm->frame_to_show; | 504     YV12_BUFFER_CONFIG *post = cm->frame_to_show; | 
| 503 | 505 | 
| 504     int i; |  | 
| 505     unsigned char *y_ptr; | 506     unsigned char *y_ptr; | 
| 506     int mb_row; | 507     int mb_row; | 
| 507     int mb_col; | 508     int mb_col; | 
| 508     /*int mb_rows = post->y_height >> 4;*/ |  | 
| 509     int mb_cols = post->y_width  >> 4; | 509     int mb_cols = post->y_width  >> 4; | 
| 510 | 510 | 
| 511     int linestocopy; | 511     int linestocopy, i; | 
| 512 | 512 | 
| 513     loop_filter_info *lfi = cm->lf_info; | 513     loop_filter_info_n *lfi_n = &cm->lf_info; | 
| 514     int baseline_filter_level[MAX_MB_SEGMENTS]; | 514     loop_filter_info lfi; | 
|  | 515 | 
| 515     int filter_level; | 516     int filter_level; | 
| 516     int alt_flt_enabled = mbd->segmentation_enabled; | 517     int alt_flt_enabled = mbd->segmentation_enabled; | 
| 517     FRAME_TYPE frame_type = cm->frame_type; | 518     FRAME_TYPE frame_type = cm->frame_type; | 
| 518 | 519 | 
| 519     (void) sharpness_lvl; | 520     const MODE_INFO *mode_info_context; | 
| 520 | 521 | 
| 521     /*MODE_INFO * this_mb_mode_info = cm->mi + (post->y_height>>5) * (mb_cols + 
     1);*/ /* Point at base of Mb MODE_INFO list */ | 522     int lvl_seg[MAX_MB_SEGMENTS]; | 
| 522     mbd->mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1);    
         /* Point at base of Mb MODE_INFO list */ |  | 
| 523 | 523 | 
| 524     linestocopy = (post->y_height >> (4 + Fraction)); | 524     mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1); | 
|  | 525 | 
|  | 526     /* 3 is a magic number. 4 is probably magic too */ | 
|  | 527     linestocopy = (post->y_height >> (4 + 3)); | 
| 525 | 528 | 
| 526     if (linestocopy < 1) | 529     if (linestocopy < 1) | 
| 527         linestocopy = 1; | 530         linestocopy = 1; | 
| 528 | 531 | 
| 529     linestocopy <<= 4; | 532     linestocopy <<= 4; | 
| 530 | 533 | 
| 531     /* Note the baseline filter values for each segment */ | 534     /* Note the baseline filter values for each segment */ | 
|  | 535     /* See vp8_loop_filter_frame_init. Rather than call that for each change | 
|  | 536      * to default_filt_lvl, copy the relevant calculation here. | 
|  | 537      */ | 
| 532     if (alt_flt_enabled) | 538     if (alt_flt_enabled) | 
| 533     { | 539     { | 
| 534         for (i = 0; i < MAX_MB_SEGMENTS; i++) | 540         for (i = 0; i < MAX_MB_SEGMENTS; i++) | 
| 535         { | 541         {    /* Abs value */ | 
| 536             /* Abs value */ |  | 
| 537             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA) | 542             if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA) | 
| 538                 baseline_filter_level[i] = mbd->segment_feature_data[MB_LVL_ALT_
     LF][i]; | 543             { | 
|  | 544                 lvl_seg[i] = mbd->segment_feature_data[MB_LVL_ALT_LF][i]; | 
|  | 545             } | 
| 539             /* Delta Value */ | 546             /* Delta Value */ | 
| 540             else | 547             else | 
| 541             { | 548             { | 
| 542                 baseline_filter_level[i] = default_filt_lvl + mbd->segment_featu
     re_data[MB_LVL_ALT_LF][i]; | 549                 lvl_seg[i] = default_filt_lvl | 
| 543                 baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((b
     aseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOO
     P_FILTER) : 0;  /* Clamp to valid range */ | 550                         + mbd->segment_feature_data[MB_LVL_ALT_LF][i]; | 
|  | 551                 lvl_seg[i] = (lvl_seg[i] > 0) ? | 
|  | 552                         ((lvl_seg[i] > 63) ? 63: lvl_seg[i]) : 0; | 
| 544             } | 553             } | 
| 545         } | 554         } | 
| 546     } | 555     } | 
| 547     else |  | 
| 548     { |  | 
| 549         for (i = 0; i < MAX_MB_SEGMENTS; i++) |  | 
| 550             baseline_filter_level[i] = default_filt_lvl; |  | 
| 551     } |  | 
| 552 |  | 
| 553     /* Initialize the loop filter for this frame. */ |  | 
| 554     if ((cm->last_filter_type != cm->filter_type) || (cm->last_sharpness_level !
     = cm->sharpness_level)) |  | 
| 555         vp8_init_loop_filter(cm); |  | 
| 556     else if (frame_type != cm->last_frame_type) |  | 
| 557         vp8_frame_init_loop_filter(lfi, frame_type); |  | 
| 558 | 556 | 
| 559     /* Set up the buffer pointers */ | 557     /* Set up the buffer pointers */ | 
| 560     y_ptr = post->y_buffer + (post->y_height >> 5) * 16 * post->y_stride; | 558     y_ptr = post->y_buffer + (post->y_height >> 5) * 16 * post->y_stride; | 
| 561 | 559 | 
| 562     /* vp8_filter each macro block */ | 560     /* vp8_filter each macro block */ | 
| 563     for (mb_row = 0; mb_row<(linestocopy >> 4); mb_row++) | 561     for (mb_row = 0; mb_row<(linestocopy >> 4); mb_row++) | 
| 564     { | 562     { | 
| 565         for (mb_col = 0; mb_col < mb_cols; mb_col++) | 563         for (mb_col = 0; mb_col < mb_cols; mb_col++) | 
| 566         { | 564         { | 
| 567             int Segment = (alt_flt_enabled) ? mbd->mode_info_context->mbmi.segme
     nt_id : 0; | 565             int skip_lf = (mode_info_context->mbmi.mode != B_PRED && | 
| 568             filter_level = baseline_filter_level[Segment]; | 566                            mode_info_context->mbmi.mode != SPLITMV && | 
|  | 567                            mode_info_context->mbmi.mb_skip_coeff); | 
|  | 568 | 
|  | 569             if (alt_flt_enabled) | 
|  | 570                 filter_level = lvl_seg[mode_info_context->mbmi.segment_id]; | 
|  | 571             else | 
|  | 572                 filter_level = default_filt_lvl; | 
| 569 | 573 | 
| 570             if (filter_level) | 574             if (filter_level) | 
| 571             { | 575             { | 
| 572                 if (mb_col > 0) | 576                 if (cm->filter_type == NORMAL_LOOPFILTER) | 
| 573                     cm->lf_mbv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level
     ], 0); | 577                 { | 
|  | 578                     const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_
     level]; | 
|  | 579                     lfi.mblim = lfi_n->mblim[filter_level]; | 
|  | 580                     lfi.blim = lfi_n->blim[filter_level]; | 
|  | 581                     lfi.lim = lfi_n->lim[filter_level]; | 
|  | 582                     lfi.hev_thr = lfi_n->hev_thr[hev_index]; | 
| 574 | 583 | 
| 575                 if (mbd->mode_info_context->mbmi.dc_diff > 0) | 584                     if (mb_col > 0) | 
| 576                     cm->lf_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level]
     , 0); | 585                         LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v) | 
|  | 586                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
| 577 | 587 | 
| 578                 cm->lf_mbh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0
     ); | 588                     if (!skip_lf) | 
|  | 589                         LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v) | 
|  | 590                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
| 579 | 591 | 
| 580                 if (mbd->mode_info_context->mbmi.dc_diff > 0) | 592                     LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h) | 
| 581                     cm->lf_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level]
     , 0); | 593                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
|  | 594 | 
|  | 595                     if (!skip_lf) | 
|  | 596                         LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h) | 
|  | 597                         (y_ptr, 0, 0, post->y_stride, 0, &lfi); | 
|  | 598                 } | 
|  | 599                 else | 
|  | 600                 { | 
|  | 601                     if (mb_col > 0) | 
|  | 602                         LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v) | 
|  | 603                         (y_ptr, post->y_stride, lfi_n->mblim[filter_level]); | 
|  | 604 | 
|  | 605                     if (!skip_lf) | 
|  | 606                         LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v) | 
|  | 607                         (y_ptr, post->y_stride, lfi_n->blim[filter_level]); | 
|  | 608 | 
|  | 609                     LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h) | 
|  | 610                         (y_ptr, post->y_stride, lfi_n->mblim[filter_level]); | 
|  | 611 | 
|  | 612                     if (!skip_lf) | 
|  | 613                         LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h) | 
|  | 614                         (y_ptr, post->y_stride, lfi_n->blim[filter_level]); | 
|  | 615                 } | 
| 582             } | 616             } | 
| 583 | 617 | 
| 584             y_ptr += 16; | 618             y_ptr += 16; | 
| 585             mbd->mode_info_context += 1;      /* step to next MB */ | 619             mode_info_context += 1;      /* step to next MB */ | 
| 586         } | 620         } | 
| 587 | 621 | 
| 588         y_ptr += post->y_stride  * 16 - post->y_width; | 622         y_ptr += post->y_stride  * 16 - post->y_width; | 
| 589         mbd->mode_info_context += 1;          /* Skip border mb */ | 623         mode_info_context += 1;          /* Skip border mb */ | 
| 590     } | 624     } | 
| 591 } | 625 } | 
| OLD | NEW | 
|---|