| 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 "vp8/common/onyxc_int.h" | 12 #include "vp8/common/onyxc_int.h" | 
| 13 #include "onyx_int.h" | 13 #include "onyx_int.h" | 
| 14 #include "quantize.h" | 14 #include "quantize.h" | 
| 15 #include "vpx_mem/vpx_mem.h" | 15 #include "vpx_mem/vpx_mem.h" | 
| 16 #include "vpx_scale/yv12extend.h" | 16 #include "vpx_scale/yv12extend.h" | 
| 17 #include "vpx_scale/vpxscale.h" | 17 #include "vpx_scale/vpxscale.h" | 
| 18 #include "vp8/common/alloccommon.h" | 18 #include "vp8/common/alloccommon.h" | 
|  | 19 #include "vp8/common/loopfilter.h" | 
| 19 #if ARCH_ARM | 20 #if ARCH_ARM | 
| 20 #include "vpx_ports/arm.h" | 21 #include "vpx_ports/arm.h" | 
| 21 #endif | 22 #endif | 
| 22 | 23 | 
| 23 extern void vp8_loop_filter_frame(VP8_COMMON *cm,    MACROBLOCKD *mbd,  int filt
     _val); |  | 
| 24 extern void vp8_loop_filter_frame_yonly(VP8_COMMON *cm,    MACROBLOCKD *mbd,  in
     t filt_val, int sharpness_lvl); |  | 
| 25 extern int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
      const vp8_variance_rtcd_vtable_t *rtcd); | 24 extern int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
      const vp8_variance_rtcd_vtable_t *rtcd); | 
| 26 #if HAVE_ARMV7 | 25 #if HAVE_ARMV7 | 
| 27 extern void vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(YV12_BUFFER_C
     ONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc); | 26 extern void vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(YV12_BUFFER_C
     ONFIG *src_ybc, YV12_BUFFER_CONFIG *dst_ybc); | 
| 28 #endif | 27 #endif | 
| 29 | 28 | 
| 30 #if CONFIG_RUNTIME_CPU_DETECT | 29 #if CONFIG_RUNTIME_CPU_DETECT | 
| 31 #define IF_RTCD(x) (x) | 30 #define IF_RTCD(x) (x) | 
| 32 #else | 31 #else | 
| 33 #define IF_RTCD(x) NULL | 32 #define IF_RTCD(x) NULL | 
| 34 #endif | 33 #endif | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 97             Total += VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, 
     dst + j, dest->y_stride, &sse); | 96             Total += VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, 
     dst + j, dest->y_stride, &sse); | 
| 98         } | 97         } | 
| 99 | 98 | 
| 100         src += 16 * source->y_stride; | 99         src += 16 * source->y_stride; | 
| 101         dst += 16 * dest->y_stride; | 100         dst += 16 * dest->y_stride; | 
| 102     } | 101     } | 
| 103 | 102 | 
| 104     return Total; | 103     return Total; | 
| 105 } | 104 } | 
| 106 | 105 | 
| 107 extern void vp8_loop_filter_partial_frame |  | 
| 108 ( |  | 
| 109     VP8_COMMON *cm, |  | 
| 110     MACROBLOCKD *mbd, |  | 
| 111     int default_filt_lvl, |  | 
| 112     int sharpness_lvl, |  | 
| 113     int Fraction |  | 
| 114 ); |  | 
| 115 |  | 
| 116 // Enforce a minimum filter level based upon baseline Q | 106 // Enforce a minimum filter level based upon baseline Q | 
| 117 static int get_min_filter_level(VP8_COMP *cpi, int base_qindex) | 107 static int get_min_filter_level(VP8_COMP *cpi, int base_qindex) | 
| 118 { | 108 { | 
| 119     int min_filter_level; | 109     int min_filter_level; | 
| 120 | 110 | 
| 121     if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame && !cpi->
     common.refresh_alt_ref_frame) | 111     if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame && !cpi->
     common.refresh_alt_ref_frame) | 
| 122         min_filter_level = 0; | 112         min_filter_level = 0; | 
| 123     else | 113     else | 
| 124     { | 114     { | 
| 125         if (base_qindex <= 6) | 115         if (base_qindex <= 6) | 
| 126             min_filter_level = 0; | 116             min_filter_level = 0; | 
| 127         else if (base_qindex <= 16) | 117         else if (base_qindex <= 16) | 
| 128             min_filter_level = 1; | 118             min_filter_level = 1; | 
| 129         else | 119         else | 
| 130             min_filter_level = (base_qindex / 8); | 120             min_filter_level = (base_qindex / 8); | 
| 131     } | 121     } | 
| 132 | 122 | 
| 133     return min_filter_level; | 123     return min_filter_level; | 
| 134 } | 124 } | 
| 135 | 125 | 
| 136 // Enforce a maximum filter level based upon baseline Q | 126 // Enforce a maximum filter level based upon baseline Q | 
| 137 static int get_max_filter_level(VP8_COMP *cpi, int base_qindex) | 127 static int get_max_filter_level(VP8_COMP *cpi, int base_qindex) | 
| 138 { | 128 { | 
| 139     // PGW August 2006: Highest filter values almost always a bad idea | 129     // PGW August 2006: Highest filter values almost always a bad idea | 
| 140 | 130 | 
| 141     // jbb chg: 20100118 - not so any more with this overquant stuff allow high 
     values | 131     // jbb chg: 20100118 - not so any more with this overquant stuff allow high 
     values | 
| 142     // with lots of intra coming in. | 132     // with lots of intra coming in. | 
| 143     int max_filter_level = MAX_LOOP_FILTER ;//* 3 / 4; | 133     int max_filter_level = MAX_LOOP_FILTER ;//* 3 / 4; | 
|  | 134     (void)base_qindex; | 
| 144 | 135 | 
| 145     if (cpi->section_intra_rating > 8) | 136     if (cpi->twopass.section_intra_rating > 8) | 
| 146         max_filter_level = MAX_LOOP_FILTER * 3 / 4; | 137         max_filter_level = MAX_LOOP_FILTER * 3 / 4; | 
| 147 | 138 | 
| 148     (void) cpi; |  | 
| 149     (void) base_qindex; |  | 
| 150 |  | 
| 151     return max_filter_level; | 139     return max_filter_level; | 
| 152 } | 140 } | 
| 153 | 141 | 
| 154 void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) | 142 void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) | 
| 155 { | 143 { | 
| 156     VP8_COMMON *cm = &cpi->common; | 144     VP8_COMMON *cm = &cpi->common; | 
| 157 | 145 | 
| 158     int best_err = 0; | 146     int best_err = 0; | 
| 159     int filt_err = 0; | 147     int filt_err = 0; | 
| 160     int min_filter_level = 0; | 148     int min_filter_level = get_min_filter_level(cpi, cm->base_qindex); | 
| 161     int max_filter_level = MAX_LOOP_FILTER * 3 / 4;   // PGW August 2006: Highes
     t filter values almost always a bad idea | 149     int max_filter_level = get_max_filter_level(cpi, cm->base_qindex); | 
| 162     int filt_val; | 150     int filt_val; | 
| 163     int best_filt_val = cm->filter_level; | 151     int best_filt_val = cm->filter_level; | 
| 164 | 152 | 
| 165     //  Make a copy of the unfiltered / processed recon buffer | 153     //  Make a copy of the unfiltered / processed recon buffer | 
| 166     //vp8_yv12_copy_frame_ptr( cm->frame_to_show, &cpi->last_frame_uf  ); |  | 
| 167     vp8_yv12_copy_partial_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf, 3); | 154     vp8_yv12_copy_partial_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf, 3); | 
| 168 | 155 | 
| 169     if (cm->frame_type == KEY_FRAME) | 156     if (cm->frame_type == KEY_FRAME) | 
| 170         cm->sharpness_level = 0; | 157         cm->sharpness_level = 0; | 
| 171     else | 158     else | 
| 172         cm->sharpness_level = cpi->oxcf.Sharpness; | 159         cm->sharpness_level = cpi->oxcf.Sharpness; | 
| 173 | 160 | 
| 174     // Enforce a minimum filter level based upon Q | 161     if (cm->sharpness_level != cm->last_sharpness_level) | 
| 175     min_filter_level = get_min_filter_level(cpi, cm->base_qindex); | 162     { | 
| 176     max_filter_level = get_max_filter_level(cpi, cm->base_qindex); | 163         vp8_loop_filter_update_sharpness(&cm->lf_info, cm->sharpness_level); | 
|  | 164         cm->last_sharpness_level = cm->sharpness_level; | 
|  | 165     } | 
| 177 | 166 | 
| 178     // Start the search at the previous frame filter level unless it is now out 
     of range. | 167     // Start the search at the previous frame filter level unless it is now out 
     of range. | 
| 179     if (cm->filter_level < min_filter_level) | 168     if (cm->filter_level < min_filter_level) | 
| 180         cm->filter_level = min_filter_level; | 169         cm->filter_level = min_filter_level; | 
| 181     else if (cm->filter_level > max_filter_level) | 170     else if (cm->filter_level > max_filter_level) | 
| 182         cm->filter_level = max_filter_level; | 171         cm->filter_level = max_filter_level; | 
| 183 | 172 | 
| 184     filt_val = cm->filter_level; | 173     filt_val = cm->filter_level; | 
| 185     best_filt_val = filt_val; | 174     best_filt_val = filt_val; | 
| 186 | 175 | 
| 187     // Set up alternate filter values |  | 
| 188 |  | 
| 189     // Get the err using the previous frame's filter value. | 176     // Get the err using the previous frame's filter value. | 
| 190     vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val, 0  , 3); | 177     vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 
| 191     cm->last_frame_type = cm->frame_type; |  | 
| 192     cm->last_filter_type = cm->filter_type; |  | 
| 193     cm->last_sharpness_level = cm->sharpness_level; |  | 
| 194 | 178 | 
| 195     best_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->
     rtcd.variance)); | 179     best_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&cpi->
     rtcd.variance)); | 
| 196 | 180 | 
| 197     //  Re-instate the unfiltered frame | 181     //  Re-instate the unfiltered frame | 
| 198     vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3); | 182     vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 3); | 
| 199 | 183 | 
| 200     filt_val -= (1 + ((filt_val > 10) ? 1 : 0)); | 184     filt_val -= (1 + ((filt_val > 10) ? 1 : 0)); | 
| 201 | 185 | 
| 202     // Search lower filter levels | 186     // Search lower filter levels | 
| 203     while (filt_val >= min_filter_level) | 187     while (filt_val >= min_filter_level) | 
| 204     { | 188     { | 
| 205         // Apply the loop filter | 189         // Apply the loop filter | 
| 206         vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val, 0, 3); | 190         vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 
| 207         cm->last_frame_type = cm->frame_type; |  | 
| 208         cm->last_filter_type = cm->filter_type; |  | 
| 209         cm->last_sharpness_level = cm->sharpness_level; |  | 
| 210 | 191 | 
| 211         // Get the err for filtered frame | 192         // Get the err for filtered frame | 
| 212         filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&c
     pi->rtcd.variance)); | 193         filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTCD(&c
     pi->rtcd.variance)); | 
| 213 | 194 | 
| 214 |  | 
| 215         //  Re-instate the unfiltered frame | 195         //  Re-instate the unfiltered frame | 
| 216         vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 
     3); | 196         vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_show, 
     3); | 
| 217 | 197 | 
| 218 | 198 | 
| 219         // Update the best case record or exit loop. | 199         // Update the best case record or exit loop. | 
| 220         if (filt_err < best_err) | 200         if (filt_err < best_err) | 
| 221         { | 201         { | 
| 222             best_err = filt_err; | 202             best_err = filt_err; | 
| 223             best_filt_val = filt_val; | 203             best_filt_val = filt_val; | 
| 224         } | 204         } | 
| 225         else | 205         else | 
| 226             break; | 206             break; | 
| 227 | 207 | 
| 228         // Adjust filter level | 208         // Adjust filter level | 
| 229         filt_val -= (1 + ((filt_val > 10) ? 1 : 0)); | 209         filt_val -= (1 + ((filt_val > 10) ? 1 : 0)); | 
| 230     } | 210     } | 
| 231 | 211 | 
| 232     // Search up (note that we have already done filt_val = cm->filter_level) | 212     // Search up (note that we have already done filt_val = cm->filter_level) | 
| 233     filt_val = cm->filter_level + (1 + ((filt_val > 10) ? 1 : 0)); | 213     filt_val = cm->filter_level + (1 + ((filt_val > 10) ? 1 : 0)); | 
| 234 | 214 | 
| 235     if (best_filt_val == cm->filter_level) | 215     if (best_filt_val == cm->filter_level) | 
| 236     { | 216     { | 
| 237         // Resist raising filter level for very small gains | 217         // Resist raising filter level for very small gains | 
| 238         best_err -= (best_err >> 10); | 218         best_err -= (best_err >> 10); | 
| 239 | 219 | 
| 240         while (filt_val < max_filter_level) | 220         while (filt_val < max_filter_level) | 
| 241         { | 221         { | 
| 242             // Apply the loop filter | 222             // Apply the loop filter | 
| 243             vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val, 0, 3); | 223             vp8_loop_filter_partial_frame(cm, &cpi->mb.e_mbd, filt_val); | 
| 244             cm->last_frame_type = cm->frame_type; |  | 
| 245             cm->last_filter_type = cm->filter_type; |  | 
| 246             cm->last_sharpness_level = cm->sharpness_level; |  | 
| 247 | 224 | 
| 248             // Get the err for filtered frame | 225             // Get the err for filtered frame | 
| 249             filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTC
     D(&cpi->rtcd.variance)); | 226             filt_err = vp8_calc_partial_ssl_err(sd, cm->frame_to_show, 3, IF_RTC
     D(&cpi->rtcd.variance)); | 
| 250 | 227 | 
| 251             //  Re-instate the unfiltered frame | 228             //  Re-instate the unfiltered frame | 
| 252             vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_sh
     ow, 3); | 229             vp8_yv12_copy_partial_frame_ptr(&cpi->last_frame_uf, cm->frame_to_sh
     ow, 3); | 
| 253 | 230 | 
| 254             // Update the best case record or exit loop. | 231             // Update the best case record or exit loop. | 
| 255             if (filt_err < best_err) | 232             if (filt_err < best_err) | 
| 256             { | 233             { | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 287     mbd->segment_feature_data[MB_LVL_ALT_LF][2] = cpi->segment_feature_data[MB_L
     VL_ALT_LF][2]; | 264     mbd->segment_feature_data[MB_LVL_ALT_LF][2] = cpi->segment_feature_data[MB_L
     VL_ALT_LF][2]; | 
| 288     mbd->segment_feature_data[MB_LVL_ALT_LF][3] = cpi->segment_feature_data[MB_L
     VL_ALT_LF][3]; | 265     mbd->segment_feature_data[MB_LVL_ALT_LF][3] = cpi->segment_feature_data[MB_L
     VL_ALT_LF][3]; | 
| 289 } | 266 } | 
| 290 | 267 | 
| 291 void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) | 268 void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi) | 
| 292 { | 269 { | 
| 293     VP8_COMMON *cm = &cpi->common; | 270     VP8_COMMON *cm = &cpi->common; | 
| 294 | 271 | 
| 295     int best_err = 0; | 272     int best_err = 0; | 
| 296     int filt_err = 0; | 273     int filt_err = 0; | 
| 297     int min_filter_level; | 274     int min_filter_level = get_min_filter_level(cpi, cm->base_qindex); | 
| 298     int max_filter_level; | 275     int max_filter_level = get_max_filter_level(cpi, cm->base_qindex); | 
| 299 | 276 | 
| 300     int filter_step; | 277     int filter_step; | 
| 301     int filt_high = 0; | 278     int filt_high = 0; | 
| 302     int filt_mid = cm->filter_level;      // Start search at previous frame filt
     er level | 279     int filt_mid = cm->filter_level;      // Start search at previous frame filt
     er level | 
| 303     int filt_low = 0; | 280     int filt_low = 0; | 
| 304     int filt_best; | 281     int filt_best; | 
| 305     int filt_direction = 0; | 282     int filt_direction = 0; | 
| 306 | 283 | 
| 307     int Bias = 0;                       // Bias against raising loop filter and 
     in favour of lowering it | 284     int Bias = 0;                       // Bias against raising loop filter and 
     in favour of lowering it | 
| 308 | 285 | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 322     { | 299     { | 
| 323         vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf); | 300         vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cpi->last_frame_uf); | 
| 324     } | 301     } | 
| 325 #endif | 302 #endif | 
| 326 | 303 | 
| 327     if (cm->frame_type == KEY_FRAME) | 304     if (cm->frame_type == KEY_FRAME) | 
| 328         cm->sharpness_level = 0; | 305         cm->sharpness_level = 0; | 
| 329     else | 306     else | 
| 330         cm->sharpness_level = cpi->oxcf.Sharpness; | 307         cm->sharpness_level = cpi->oxcf.Sharpness; | 
| 331 | 308 | 
| 332     // Enforce a minimum filter level based upon Q |  | 
| 333     min_filter_level = get_min_filter_level(cpi, cm->base_qindex); |  | 
| 334     max_filter_level = get_max_filter_level(cpi, cm->base_qindex); |  | 
| 335 |  | 
| 336     // Start the search at the previous frame filter level unless it is now out 
     of range. | 309     // Start the search at the previous frame filter level unless it is now out 
     of range. | 
| 337     filt_mid = cm->filter_level; | 310     filt_mid = cm->filter_level; | 
| 338 | 311 | 
| 339     if (filt_mid < min_filter_level) | 312     if (filt_mid < min_filter_level) | 
| 340         filt_mid = min_filter_level; | 313         filt_mid = min_filter_level; | 
| 341     else if (filt_mid > max_filter_level) | 314     else if (filt_mid > max_filter_level) | 
| 342         filt_mid = max_filter_level; | 315         filt_mid = max_filter_level; | 
| 343 | 316 | 
| 344     // Define the initial step size | 317     // Define the initial step size | 
| 345     filter_step = (filt_mid < 16) ? 4 : filt_mid / 4; | 318     filter_step = (filt_mid < 16) ? 4 : filt_mid / 4; | 
| 346 | 319 | 
| 347     // Get baseline error score | 320     // Get baseline error score | 
| 348     vp8cx_set_alt_lf_level(cpi, filt_mid); | 321     vp8cx_set_alt_lf_level(cpi, filt_mid); | 
| 349     vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid, 0); | 322     vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_mid); | 
| 350     cm->last_frame_type = cm->frame_type; |  | 
| 351     cm->last_filter_type = cm->filter_type; |  | 
| 352     cm->last_sharpness_level = cm->sharpness_level; |  | 
| 353 | 323 | 
| 354     best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.varianc
     e)); | 324     best_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd.varianc
     e)); | 
| 355     filt_best = filt_mid; | 325     filt_best = filt_mid; | 
| 356 | 326 | 
| 357     //  Re-instate the unfiltered frame | 327     //  Re-instate the unfiltered frame | 
| 358 #if HAVE_ARMV7 | 328 #if HAVE_ARMV7 | 
| 359 #if CONFIG_RUNTIME_CPU_DETECT | 329 #if CONFIG_RUNTIME_CPU_DETECT | 
| 360     if (cm->rtcd.flags & HAS_NEON) | 330     if (cm->rtcd.flags & HAS_NEON) | 
| 361 #endif | 331 #endif | 
| 362     { | 332     { | 
| 363         vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_
     uf, cm->frame_to_show); | 333         vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->last_frame_
     uf, cm->frame_to_show); | 
| 364     } | 334     } | 
| 365 #if CONFIG_RUNTIME_CPU_DETECT | 335 #if CONFIG_RUNTIME_CPU_DETECT | 
| 366     else | 336     else | 
| 367 #endif | 337 #endif | 
| 368 #endif | 338 #endif | 
| 369 #if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT | 339 #if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT | 
| 370     { | 340     { | 
| 371         vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show); | 341         vp8_yv12_copy_frame_yonly_ptr(&cpi->last_frame_uf, cm->frame_to_show); | 
| 372     } | 342     } | 
| 373 #endif | 343 #endif | 
| 374 | 344 | 
| 375     while (filter_step > 0) | 345     while (filter_step > 0) | 
| 376     { | 346     { | 
| 377         Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; //PGW change 1
     2/12/06 for small images | 347         Bias = (best_err >> (15 - (filt_mid / 8))) * filter_step; //PGW change 1
     2/12/06 for small images | 
| 378 | 348 | 
| 379         // jbb chg: 20100118 - in sections with lots of new material coming in d
     on't bias as much to a low filter value | 349         // jbb chg: 20100118 - in sections with lots of new material coming in d
     on't bias as much to a low filter value | 
| 380         if (cpi->section_intra_rating < 20) | 350         if (cpi->twopass.section_intra_rating < 20) | 
| 381             Bias = Bias * cpi->section_intra_rating / 20; | 351             Bias = Bias * cpi->twopass.section_intra_rating / 20; | 
| 382 | 352 | 
| 383         filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_l
     evel : (filt_mid + filter_step); | 353         filt_high = ((filt_mid + filter_step) > max_filter_level) ? max_filter_l
     evel : (filt_mid + filter_step); | 
| 384         filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_le
     vel : (filt_mid - filter_step); | 354         filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_le
     vel : (filt_mid - filter_step); | 
| 385 | 355 | 
| 386         if ((filt_direction <= 0) && (filt_low != filt_mid)) | 356         if ((filt_direction <= 0) && (filt_low != filt_mid)) | 
| 387         { | 357         { | 
| 388             // Get Low filter error score | 358             // Get Low filter error score | 
| 389             vp8cx_set_alt_lf_level(cpi, filt_low); | 359             vp8cx_set_alt_lf_level(cpi, filt_low); | 
| 390             vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low, 0); | 360             vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_low); | 
| 391             cm->last_frame_type = cm->frame_type; |  | 
| 392             cm->last_filter_type = cm->filter_type; |  | 
| 393             cm->last_sharpness_level = cm->sharpness_level; |  | 
| 394 | 361 | 
| 395             filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd
     .variance)); | 362             filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd
     .variance)); | 
| 396 | 363 | 
| 397             //  Re-instate the unfiltered frame | 364             //  Re-instate the unfiltered frame | 
| 398 #if HAVE_ARMV7 | 365 #if HAVE_ARMV7 | 
| 399 #if CONFIG_RUNTIME_CPU_DETECT | 366 #if CONFIG_RUNTIME_CPU_DETECT | 
| 400             if (cm->rtcd.flags & HAS_NEON) | 367             if (cm->rtcd.flags & HAS_NEON) | 
| 401 #endif | 368 #endif | 
| 402             { | 369             { | 
| 403                 vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->las
     t_frame_uf, cm->frame_to_show); | 370                 vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->las
     t_frame_uf, cm->frame_to_show); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 420                     best_err = filt_err; | 387                     best_err = filt_err; | 
| 421 | 388 | 
| 422                 filt_best = filt_low; | 389                 filt_best = filt_low; | 
| 423             } | 390             } | 
| 424         } | 391         } | 
| 425 | 392 | 
| 426         // Now look at filt_high | 393         // Now look at filt_high | 
| 427         if ((filt_direction >= 0) && (filt_high != filt_mid)) | 394         if ((filt_direction >= 0) && (filt_high != filt_mid)) | 
| 428         { | 395         { | 
| 429             vp8cx_set_alt_lf_level(cpi, filt_high); | 396             vp8cx_set_alt_lf_level(cpi, filt_high); | 
| 430             vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high, 0); | 397             vp8_loop_filter_frame_yonly(cm, &cpi->mb.e_mbd, filt_high); | 
| 431             cm->last_frame_type = cm->frame_type; |  | 
| 432             cm->last_filter_type = cm->filter_type; |  | 
| 433             cm->last_sharpness_level = cm->sharpness_level; |  | 
| 434 | 398 | 
| 435             filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd
     .variance)); | 399             filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, IF_RTCD(&cpi->rtcd
     .variance)); | 
| 436 | 400 | 
| 437             //  Re-instate the unfiltered frame | 401             //  Re-instate the unfiltered frame | 
| 438 #if HAVE_ARMV7 | 402 #if HAVE_ARMV7 | 
| 439 #if CONFIG_RUNTIME_CPU_DETECT | 403 #if CONFIG_RUNTIME_CPU_DETECT | 
| 440             if (cm->rtcd.flags & HAS_NEON) | 404             if (cm->rtcd.flags & HAS_NEON) | 
| 441 #endif | 405 #endif | 
| 442             { | 406             { | 
| 443                 vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->las
     t_frame_uf, cm->frame_to_show); | 407                 vp8_yv12_copy_frame_yonly_no_extend_frame_borders_neon(&cpi->las
     t_frame_uf, cm->frame_to_show); | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 467             filt_direction = 0; | 431             filt_direction = 0; | 
| 468         } | 432         } | 
| 469         else | 433         else | 
| 470         { | 434         { | 
| 471             filt_direction = (filt_best < filt_mid) ? -1 : 1; | 435             filt_direction = (filt_best < filt_mid) ? -1 : 1; | 
| 472             filt_mid = filt_best; | 436             filt_mid = filt_best; | 
| 473         } | 437         } | 
| 474     } | 438     } | 
| 475 | 439 | 
| 476     cm->filter_level = filt_best; | 440     cm->filter_level = filt_best; | 
| 477     cpi->last_auto_filt_val = filt_best; |  | 
| 478     cpi->last_auto_filt_q  = cm->base_qindex; |  | 
| 479 |  | 
| 480     cpi->frames_since_auto_filter = 0; |  | 
| 481 } | 441 } | 
| OLD | NEW | 
|---|