| 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_config.h" | 
| 12 #include "vp8/common/onyxc_int.h" | 13 #include "vp8/common/onyxc_int.h" | 
| 13 #include "onyx_int.h" | 14 #include "onyx_int.h" | 
| 14 #include "vp8/common/systemdependent.h" | 15 #include "vp8/common/systemdependent.h" | 
| 15 #include "quantize.h" | 16 #include "quantize.h" | 
| 16 #include "vp8/common/alloccommon.h" | 17 #include "vp8/common/alloccommon.h" | 
| 17 #include "mcomp.h" | 18 #include "mcomp.h" | 
| 18 #include "firstpass.h" | 19 #include "firstpass.h" | 
| 19 #include "psnr.h" | 20 #include "psnr.h" | 
| 20 #include "vpx_scale/vpxscale.h" | 21 #include "vpx_scale/vpxscale.h" | 
| 21 #include "vp8/common/extend.h" | 22 #include "vp8/common/extend.h" | 
| 22 #include "ratectrl.h" | 23 #include "ratectrl.h" | 
| 23 #include "vp8/common/quant_common.h" | 24 #include "vp8/common/quant_common.h" | 
| 24 #include "segmentation.h" | 25 #include "segmentation.h" | 
| 25 #include "vp8/common/g_common.h" | 26 #include "vp8/common/g_common.h" | 
| 26 #include "vpx_scale/yv12extend.h" | 27 #include "vpx_scale/yv12extend.h" | 
|  | 28 #if CONFIG_POSTPROC | 
| 27 #include "vp8/common/postproc.h" | 29 #include "vp8/common/postproc.h" | 
|  | 30 #endif | 
| 28 #include "vpx_mem/vpx_mem.h" | 31 #include "vpx_mem/vpx_mem.h" | 
| 29 #include "vp8/common/swapyv12buffer.h" | 32 #include "vp8/common/swapyv12buffer.h" | 
| 30 #include "vp8/common/threading.h" | 33 #include "vp8/common/threading.h" | 
| 31 #include "vpx_ports/vpx_timer.h" | 34 #include "vpx_ports/vpx_timer.h" | 
| 32 #include "temporal_filter.h" | 35 #include "temporal_filter.h" | 
| 33 #if ARCH_ARM | 36 #if ARCH_ARM | 
| 34 #include "vpx_ports/arm.h" | 37 #include "vpx_ports/arm.h" | 
| 35 #endif | 38 #endif | 
| 36 | 39 | 
| 37 #include <math.h> | 40 #include <math.h> | 
| 38 #include <stdio.h> | 41 #include <stdio.h> | 
| 39 #include <limits.h> | 42 #include <limits.h> | 
| 40 | 43 | 
| 41 #if CONFIG_RUNTIME_CPU_DETECT | 44 #if CONFIG_RUNTIME_CPU_DETECT | 
| 42 #define IF_RTCD(x) (x) | 45 #define IF_RTCD(x) (x) | 
| 43 #define RTCD(x) &cpi->common.rtcd.x | 46 #define RTCD(x) &cpi->common.rtcd.x | 
| 44 #else | 47 #else | 
| 45 #define IF_RTCD(x) NULL | 48 #define IF_RTCD(x) NULL | 
| 46 #define RTCD(x) NULL | 49 #define RTCD(x) NULL | 
| 47 #endif | 50 #endif | 
| 48 | 51 | 
| 49 extern void vp8cx_init_mv_bits_sadcost(); |  | 
| 50 extern void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi); | 52 extern void vp8cx_pick_filter_level_fast(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi); | 
| 51 extern void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val); | 53 extern void vp8cx_set_alt_lf_level(VP8_COMP *cpi, int filt_val); | 
| 52 extern void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi); | 54 extern void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi); | 
| 53 | 55 | 
| 54 extern void vp8_init_loop_filter(VP8_COMMON *cm); |  | 
| 55 extern void vp8_loop_filter_frame(VP8_COMMON *cm,    MACROBLOCKD *mbd,  int filt
      _val); |  | 
| 56 extern void vp8_loop_filter_frame_yonly(VP8_COMMON *cm,    MACROBLOCKD *mbd,  in
      t filt_val, int sharpness_lvl); |  | 
| 57 extern void vp8_dmachine_specific_config(VP8_COMP *cpi); | 56 extern void vp8_dmachine_specific_config(VP8_COMP *cpi); | 
| 58 extern void vp8_cmachine_specific_config(VP8_COMP *cpi); | 57 extern void vp8_cmachine_specific_config(VP8_COMP *cpi); | 
| 59 extern void vp8_calc_auto_iframe_target_size(VP8_COMP *cpi); |  | 
| 60 extern void vp8_deblock_frame(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *po
      st, int filt_lvl, int low_var_thresh, int flag); | 58 extern void vp8_deblock_frame(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *po
      st, int filt_lvl, int low_var_thresh, int flag); | 
| 61 extern void print_parms(VP8_CONFIG *ocf, char *filenam); | 59 extern void print_parms(VP8_CONFIG *ocf, char *filenam); | 
| 62 extern unsigned int vp8_get_processor_freq(); | 60 extern unsigned int vp8_get_processor_freq(); | 
| 63 extern void print_tree_update_probs(); | 61 extern void print_tree_update_probs(); | 
| 64 extern void vp8cx_create_encoder_threads(VP8_COMP *cpi); | 62 extern void vp8cx_create_encoder_threads(VP8_COMP *cpi); | 
| 65 extern void vp8cx_remove_encoder_threads(VP8_COMP *cpi); | 63 extern void vp8cx_remove_encoder_threads(VP8_COMP *cpi); | 
| 66 #if HAVE_ARMV7 | 64 #if HAVE_ARMV7 | 
| 67 extern void vp8_yv12_copy_frame_func_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFF
      ER_CONFIG *dst_ybc); | 65 extern void vp8_yv12_copy_frame_func_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_BUFF
      ER_CONFIG *dst_ybc); | 
| 68 extern void vp8_yv12_copy_src_frame_func_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_
      BUFFER_CONFIG *dst_ybc); | 66 extern void vp8_yv12_copy_src_frame_func_neon(YV12_BUFFER_CONFIG *src_ybc, YV12_
      BUFFER_CONFIG *dst_ybc); | 
| 69 #endif | 67 #endif | 
| 70 | 68 | 
| 71 int vp8_estimate_entropy_savings(VP8_COMP *cpi); | 69 int vp8_estimate_entropy_savings(VP8_COMP *cpi); | 
| 72 int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const 
      vp8_variance_rtcd_vtable_t *rtcd); | 70 int vp8_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, const 
      vp8_variance_rtcd_vtable_t *rtcd); | 
| 73 | 71 | 
| 74 extern void vp8_temporal_filter_prepare_c(VP8_COMP *cpi); | 72 extern void vp8_temporal_filter_prepare_c(VP8_COMP *cpi, int distance); | 
| 75 | 73 | 
| 76 static void set_default_lf_deltas(VP8_COMP *cpi); | 74 static void set_default_lf_deltas(VP8_COMP *cpi); | 
| 77 | 75 | 
| 78 extern const int vp8_gf_interval_table[101]; | 76 extern const int vp8_gf_interval_table[101]; | 
| 79 | 77 | 
| 80 #if CONFIG_PSNR | 78 #if CONFIG_INTERNAL_STATS | 
| 81 #include "math.h" | 79 #include "math.h" | 
| 82 | 80 | 
| 83 extern double vp8_calc_ssim | 81 extern double vp8_calc_ssim | 
| 84 ( | 82 ( | 
| 85     YV12_BUFFER_CONFIG *source, | 83     YV12_BUFFER_CONFIG *source, | 
| 86     YV12_BUFFER_CONFIG *dest, | 84     YV12_BUFFER_CONFIG *dest, | 
| 87     int lumamask, | 85     int lumamask, | 
| 88     double *weight, | 86     double *weight, | 
| 89     const vp8_variance_rtcd_vtable_t *rtcd | 87     const vp8_variance_rtcd_vtable_t *rtcd | 
| 90 ); | 88 ); | 
| 91 | 89 | 
| 92 | 90 | 
| 93 extern double vp8_calc_ssimg | 91 extern double vp8_calc_ssimg | 
| 94 ( | 92 ( | 
| 95     YV12_BUFFER_CONFIG *source, | 93     YV12_BUFFER_CONFIG *source, | 
| 96     YV12_BUFFER_CONFIG *dest, | 94     YV12_BUFFER_CONFIG *dest, | 
| 97     double *ssim_y, | 95     double *ssim_y, | 
| 98     double *ssim_u, | 96     double *ssim_u, | 
| 99     double *ssim_v | 97     double *ssim_v, | 
|  | 98     const vp8_variance_rtcd_vtable_t *rtcd | 
| 100 ); | 99 ); | 
| 101 | 100 | 
| 102 | 101 | 
| 103 #endif | 102 #endif | 
| 104 | 103 | 
| 105 | 104 | 
| 106 #ifdef OUTPUT_YUV_SRC | 105 #ifdef OUTPUT_YUV_SRC | 
| 107 FILE *yuv_file; | 106 FILE *yuv_file; | 
| 108 #endif | 107 #endif | 
| 109 | 108 | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 224 { | 223 { | 
| 225     static int init_done = 0; | 224     static int init_done = 0; | 
| 226 | 225 | 
| 227     if (!init_done) | 226     if (!init_done) | 
| 228     { | 227     { | 
| 229         vp8_scale_machine_specific_config(); | 228         vp8_scale_machine_specific_config(); | 
| 230         vp8_initialize_common(); | 229         vp8_initialize_common(); | 
| 231         //vp8_dmachine_specific_config(); | 230         //vp8_dmachine_specific_config(); | 
| 232         vp8_tokenize_initialize(); | 231         vp8_tokenize_initialize(); | 
| 233 | 232 | 
| 234         vp8cx_init_mv_bits_sadcost(); |  | 
| 235         init_done = 1; | 233         init_done = 1; | 
| 236     } | 234     } | 
| 237 } | 235 } | 
| 238 #ifdef PACKET_TESTING | 236 #ifdef PACKET_TESTING | 
| 239 extern FILE *vpxlogc; | 237 extern FILE *vpxlogc; | 
| 240 #endif | 238 #endif | 
| 241 | 239 | 
| 242 static void setup_features(VP8_COMP *cpi) | 240 static void setup_features(VP8_COMP *cpi) | 
| 243 { | 241 { | 
| 244     // Set up default state for MB feature flags | 242     // Set up default state for MB feature flags | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 280     cpi->segmentation_map = 0; | 278     cpi->segmentation_map = 0; | 
| 281 | 279 | 
| 282     vpx_free(cpi->active_map); | 280     vpx_free(cpi->active_map); | 
| 283     cpi->active_map = 0; | 281     cpi->active_map = 0; | 
| 284 | 282 | 
| 285     vp8_de_alloc_frame_buffers(&cpi->common); | 283     vp8_de_alloc_frame_buffers(&cpi->common); | 
| 286 | 284 | 
| 287     vp8_yv12_de_alloc_frame_buffer(&cpi->last_frame_uf); | 285     vp8_yv12_de_alloc_frame_buffer(&cpi->last_frame_uf); | 
| 288     vp8_yv12_de_alloc_frame_buffer(&cpi->scaled_source); | 286     vp8_yv12_de_alloc_frame_buffer(&cpi->scaled_source); | 
| 289 #if VP8_TEMPORAL_ALT_REF | 287 #if VP8_TEMPORAL_ALT_REF | 
| 290     vp8_yv12_de_alloc_frame_buffer(&cpi->alt_ref_buffer.source_buffer); | 288     vp8_yv12_de_alloc_frame_buffer(&cpi->alt_ref_buffer); | 
| 291 #endif | 289 #endif | 
| 292     { | 290     vp8_lookahead_destroy(cpi->lookahead); | 
| 293         int i; |  | 
| 294 |  | 
| 295         for (i = 0; i < MAX_LAG_BUFFERS; i++) |  | 
| 296             vp8_yv12_de_alloc_frame_buffer(&cpi->src_buffer[i].source_buffer); |  | 
| 297 |  | 
| 298         cpi->source_buffer_count = 0; |  | 
| 299     } |  | 
| 300 | 291 | 
| 301     vpx_free(cpi->tok); | 292     vpx_free(cpi->tok); | 
| 302     cpi->tok = 0; | 293     cpi->tok = 0; | 
| 303 | 294 | 
| 304     // Structure used to monitor GF usage | 295     // Structure used to monitor GF usage | 
| 305     vpx_free(cpi->gf_active_flags); | 296     vpx_free(cpi->gf_active_flags); | 
| 306     cpi->gf_active_flags = 0; | 297     cpi->gf_active_flags = 0; | 
| 307 | 298 | 
|  | 299     // Activity mask based per mb zbin adjustments | 
|  | 300     vpx_free(cpi->mb_activity_map); | 
|  | 301     cpi->mb_activity_map = 0; | 
|  | 302     vpx_free(cpi->mb_norm_activity_map); | 
|  | 303     cpi->mb_norm_activity_map = 0; | 
|  | 304 | 
| 308     vpx_free(cpi->mb.pip); | 305     vpx_free(cpi->mb.pip); | 
| 309     cpi->mb.pip = 0; | 306     cpi->mb.pip = 0; | 
| 310 | 307 | 
| 311 #if !(CONFIG_REALTIME_ONLY) | 308 #if !(CONFIG_REALTIME_ONLY) | 
| 312     vpx_free(cpi->total_stats); | 309     vpx_free(cpi->twopass.total_stats); | 
| 313     cpi->total_stats = 0; | 310     cpi->twopass.total_stats = 0; | 
| 314 | 311 | 
| 315     vpx_free(cpi->this_frame_stats); | 312     vpx_free(cpi->twopass.this_frame_stats); | 
| 316     cpi->this_frame_stats = 0; | 313     cpi->twopass.this_frame_stats = 0; | 
| 317 #endif | 314 #endif | 
| 318 } | 315 } | 
| 319 | 316 | 
| 320 static void enable_segmentation(VP8_PTR ptr) | 317 static void enable_segmentation(VP8_PTR ptr) | 
| 321 { | 318 { | 
| 322     VP8_COMP *cpi = (VP8_COMP *)(ptr); | 319     VP8_COMP *cpi = (VP8_COMP *)(ptr); | 
| 323 | 320 | 
| 324     // Set the appropriate feature bit | 321     // Set the appropriate feature bit | 
| 325     cpi->mb.e_mbd.segmentation_enabled = 1; | 322     cpi->mb.e_mbd.segmentation_enabled = 1; | 
| 326     cpi->mb.e_mbd.update_mb_segmentation_map = 1; | 323     cpi->mb.e_mbd.update_mb_segmentation_map = 1; | 
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 557 | 554 | 
| 558     // best quality defaults | 555     // best quality defaults | 
| 559     sf->RD = 1; | 556     sf->RD = 1; | 
| 560     sf->search_method = NSTEP; | 557     sf->search_method = NSTEP; | 
| 561     sf->improved_quant = 1; | 558     sf->improved_quant = 1; | 
| 562     sf->improved_dct = 1; | 559     sf->improved_dct = 1; | 
| 563     sf->auto_filter = 1; | 560     sf->auto_filter = 1; | 
| 564     sf->recode_loop = 1; | 561     sf->recode_loop = 1; | 
| 565     sf->quarter_pixel_search = 1; | 562     sf->quarter_pixel_search = 1; | 
| 566     sf->half_pixel_search = 1; | 563     sf->half_pixel_search = 1; | 
| 567     sf->full_freq[0] = 7; |  | 
| 568     sf->full_freq[1] = 7; |  | 
| 569     sf->min_fs_radius = 8; |  | 
| 570     sf->max_fs_radius = 32; |  | 
| 571     sf->iterative_sub_pixel = 1; | 564     sf->iterative_sub_pixel = 1; | 
| 572     sf->optimize_coefficients = 1; | 565     sf->optimize_coefficients = 1; | 
| 573     sf->use_fastquant_for_pick = 0; | 566     sf->use_fastquant_for_pick = 0; | 
| 574     sf->no_skip_block4x4_search = 1; | 567     sf->no_skip_block4x4_search = 1; | 
| 575 | 568 | 
| 576     sf->first_step = 0; | 569     sf->first_step = 0; | 
| 577     sf->max_step_search_steps = MAX_MVSEARCH_STEPS; | 570     sf->max_step_search_steps = MAX_MVSEARCH_STEPS; | 
| 578     sf->improved_mv_pred = 1; | 571     sf->improved_mv_pred = 1; | 
| 579 | 572 | 
| 580     cpi->do_full[0] = 0; |  | 
| 581     cpi->do_full[1] = 0; |  | 
| 582 |  | 
| 583     // default thresholds to 0 | 573     // default thresholds to 0 | 
| 584     for (i = 0; i < MAX_MODES; i++) | 574     for (i = 0; i < MAX_MODES; i++) | 
| 585         sf->thresh_mult[i] = 0; | 575         sf->thresh_mult[i] = 0; | 
| 586 | 576 | 
| 587     switch (Mode) | 577     switch (Mode) | 
| 588     { | 578     { | 
| 589 #if !(CONFIG_REALTIME_ONLY) | 579 #if !(CONFIG_REALTIME_ONLY) | 
| 590     case 0: // best quality mode | 580     case 0: // best quality mode | 
| 591         sf->thresh_mult[THR_ZEROMV   ] = 0; | 581         sf->thresh_mult[THR_ZEROMV   ] = 0; | 
| 592         sf->thresh_mult[THR_ZEROG    ] = 0; | 582         sf->thresh_mult[THR_ZEROG    ] = 0; | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 606         sf->thresh_mult[THR_TM       ] = 1000; | 596         sf->thresh_mult[THR_TM       ] = 1000; | 
| 607 | 597 | 
| 608         sf->thresh_mult[THR_NEWMV    ] = 1000; | 598         sf->thresh_mult[THR_NEWMV    ] = 1000; | 
| 609         sf->thresh_mult[THR_NEWG     ] = 1000; | 599         sf->thresh_mult[THR_NEWG     ] = 1000; | 
| 610         sf->thresh_mult[THR_NEWA     ] = 1000; | 600         sf->thresh_mult[THR_NEWA     ] = 1000; | 
| 611 | 601 | 
| 612         sf->thresh_mult[THR_SPLITMV  ] = 2500; | 602         sf->thresh_mult[THR_SPLITMV  ] = 2500; | 
| 613         sf->thresh_mult[THR_SPLITG   ] = 5000; | 603         sf->thresh_mult[THR_SPLITG   ] = 5000; | 
| 614         sf->thresh_mult[THR_SPLITA   ] = 5000; | 604         sf->thresh_mult[THR_SPLITA   ] = 5000; | 
| 615 | 605 | 
| 616         sf->full_freq[0] = 7; |  | 
| 617         sf->full_freq[1] = 15; |  | 
| 618 | 606 | 
| 619         sf->first_step = 0; | 607         sf->first_step = 0; | 
| 620         sf->max_step_search_steps = MAX_MVSEARCH_STEPS; | 608         sf->max_step_search_steps = MAX_MVSEARCH_STEPS; | 
| 621         break; | 609         break; | 
| 622     case 1: | 610     case 1: | 
| 623     case 3: | 611     case 3: | 
| 624         sf->thresh_mult[THR_NEARESTMV] = 0; | 612         sf->thresh_mult[THR_NEARESTMV] = 0; | 
| 625         sf->thresh_mult[THR_ZEROMV   ] = 0; | 613         sf->thresh_mult[THR_ZEROMV   ] = 0; | 
| 626         sf->thresh_mult[THR_DC       ] = 0; | 614         sf->thresh_mult[THR_DC       ] = 0; | 
| 627         sf->thresh_mult[THR_NEARMV   ] = 0; | 615         sf->thresh_mult[THR_NEARMV   ] = 0; | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 665         sf->thresh_mult[THR_SPLITA   ] = 4500; | 653         sf->thresh_mult[THR_SPLITA   ] = 4500; | 
| 666 #else | 654 #else | 
| 667         sf->thresh_mult[THR_NEWMV    ] = 1500; | 655         sf->thresh_mult[THR_NEWMV    ] = 1500; | 
| 668         sf->thresh_mult[THR_NEWG     ] = 1500; | 656         sf->thresh_mult[THR_NEWG     ] = 1500; | 
| 669         sf->thresh_mult[THR_NEWA     ] = 1500; | 657         sf->thresh_mult[THR_NEWA     ] = 1500; | 
| 670 | 658 | 
| 671         sf->thresh_mult[THR_SPLITMV  ] = 5000; | 659         sf->thresh_mult[THR_SPLITMV  ] = 5000; | 
| 672         sf->thresh_mult[THR_SPLITG   ] = 10000; | 660         sf->thresh_mult[THR_SPLITG   ] = 10000; | 
| 673         sf->thresh_mult[THR_SPLITA   ] = 10000; | 661         sf->thresh_mult[THR_SPLITA   ] = 10000; | 
| 674 #endif | 662 #endif | 
| 675         sf->full_freq[0] = 15; |  | 
| 676         sf->full_freq[1] = 31; |  | 
| 677 | 663 | 
| 678         if (Speed > 0) | 664         if (Speed > 0) | 
| 679         { | 665         { | 
| 680             /* Disable coefficient optimization above speed 0 */ | 666             /* Disable coefficient optimization above speed 0 */ | 
| 681             sf->optimize_coefficients = 0; | 667             sf->optimize_coefficients = 0; | 
| 682             sf->use_fastquant_for_pick = 1; | 668             sf->use_fastquant_for_pick = 1; | 
| 683             sf->no_skip_block4x4_search = 0; | 669             sf->no_skip_block4x4_search = 0; | 
| 684 | 670 | 
| 685             sf->first_step = 1; | 671             sf->first_step = 1; | 
| 686 | 672 | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 760                 sf->thresh_mult[THR_SPLITA   ] = 50000; | 746                 sf->thresh_mult[THR_SPLITA   ] = 50000; | 
| 761             } | 747             } | 
| 762 | 748 | 
| 763             sf->improved_quant = 0; | 749             sf->improved_quant = 0; | 
| 764             sf->improved_dct = 0; | 750             sf->improved_dct = 0; | 
| 765 | 751 | 
| 766             // Only do recode loop on key frames, golden frames and | 752             // Only do recode loop on key frames, golden frames and | 
| 767             // alt ref frames | 753             // alt ref frames | 
| 768             sf->recode_loop = 2; | 754             sf->recode_loop = 2; | 
| 769 | 755 | 
| 770             sf->full_freq[0] = 31; |  | 
| 771             sf->full_freq[1] = 63; |  | 
| 772         } | 756         } | 
| 773 | 757 | 
| 774         if (Speed > 3) | 758         if (Speed > 3) | 
| 775         { | 759         { | 
| 776             sf->thresh_mult[THR_SPLITA  ] = INT_MAX; | 760             sf->thresh_mult[THR_SPLITA  ] = INT_MAX; | 
| 777             sf->thresh_mult[THR_SPLITG  ] = INT_MAX; | 761             sf->thresh_mult[THR_SPLITG  ] = INT_MAX; | 
| 778             sf->thresh_mult[THR_SPLITMV  ] = INT_MAX; | 762             sf->thresh_mult[THR_SPLITMV  ] = INT_MAX; | 
| 779 | 763 | 
| 780             cpi->mode_check_freq[THR_V_PRED] = 0; | 764             cpi->mode_check_freq[THR_V_PRED] = 0; | 
| 781             cpi->mode_check_freq[THR_H_PRED] = 0; | 765             cpi->mode_check_freq[THR_H_PRED] = 0; | 
| 782             cpi->mode_check_freq[THR_B_PRED] = 0; | 766             cpi->mode_check_freq[THR_B_PRED] = 0; | 
| 783             cpi->mode_check_freq[THR_NEARG] = 0; | 767             cpi->mode_check_freq[THR_NEARG] = 0; | 
| 784             cpi->mode_check_freq[THR_NEWG] = 0; | 768             cpi->mode_check_freq[THR_NEWG] = 0; | 
| 785             cpi->mode_check_freq[THR_NEARA] = 0; | 769             cpi->mode_check_freq[THR_NEARA] = 0; | 
| 786             cpi->mode_check_freq[THR_NEWA] = 0; | 770             cpi->mode_check_freq[THR_NEWA] = 0; | 
| 787 | 771 | 
| 788             sf->auto_filter = 1; | 772             sf->auto_filter = 1; | 
| 789             sf->recode_loop = 0; // recode loop off | 773             sf->recode_loop = 0; // recode loop off | 
| 790             sf->RD = 0;         // Turn rd off | 774             sf->RD = 0;         // Turn rd off | 
| 791 | 775 | 
| 792             sf->full_freq[0] = 63; |  | 
| 793             sf->full_freq[1] = 127; |  | 
| 794         } | 776         } | 
| 795 | 777 | 
| 796         if (Speed > 4) | 778         if (Speed > 4) | 
| 797         { | 779         { | 
| 798             sf->auto_filter = 0;                     // Faster selection of loop
       filter | 780             sf->auto_filter = 0;                     // Faster selection of loop
       filter | 
| 799             sf->full_freq[0] = INT_MAX; |  | 
| 800             sf->full_freq[1] = INT_MAX; |  | 
| 801 | 781 | 
| 802             cpi->mode_check_freq[THR_V_PRED] = 2; | 782             cpi->mode_check_freq[THR_V_PRED] = 2; | 
| 803             cpi->mode_check_freq[THR_H_PRED] = 2; | 783             cpi->mode_check_freq[THR_H_PRED] = 2; | 
| 804             cpi->mode_check_freq[THR_B_PRED] = 2; | 784             cpi->mode_check_freq[THR_B_PRED] = 2; | 
| 805 | 785 | 
| 806             if (cpi->ref_frame_flags & VP8_GOLD_FLAG) | 786             if (cpi->ref_frame_flags & VP8_GOLD_FLAG) | 
| 807             { | 787             { | 
| 808                 cpi->mode_check_freq[THR_NEARG] = 2; | 788                 cpi->mode_check_freq[THR_NEARG] = 2; | 
| 809                 cpi->mode_check_freq[THR_NEWG] = 4; | 789                 cpi->mode_check_freq[THR_NEWG] = 4; | 
| 810             } | 790             } | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 852         sf->thresh_mult[THR_NEARG    ] = 1000; | 832         sf->thresh_mult[THR_NEARG    ] = 1000; | 
| 853         sf->thresh_mult[THR_NEARESTA ] = 1000; | 833         sf->thresh_mult[THR_NEARESTA ] = 1000; | 
| 854         sf->thresh_mult[THR_ZEROA    ] = 1000; | 834         sf->thresh_mult[THR_ZEROA    ] = 1000; | 
| 855         sf->thresh_mult[THR_NEARA    ] = 1000; | 835         sf->thresh_mult[THR_NEARA    ] = 1000; | 
| 856         sf->thresh_mult[THR_NEWMV    ] = 2000; | 836         sf->thresh_mult[THR_NEWMV    ] = 2000; | 
| 857         sf->thresh_mult[THR_NEWG     ] = 2000; | 837         sf->thresh_mult[THR_NEWG     ] = 2000; | 
| 858         sf->thresh_mult[THR_NEWA     ] = 2000; | 838         sf->thresh_mult[THR_NEWA     ] = 2000; | 
| 859         sf->thresh_mult[THR_SPLITMV  ] = 5000; | 839         sf->thresh_mult[THR_SPLITMV  ] = 5000; | 
| 860         sf->thresh_mult[THR_SPLITG   ] = 10000; | 840         sf->thresh_mult[THR_SPLITG   ] = 10000; | 
| 861         sf->thresh_mult[THR_SPLITA   ] = 10000; | 841         sf->thresh_mult[THR_SPLITA   ] = 10000; | 
| 862         sf->full_freq[0] = 15; |  | 
| 863         sf->full_freq[1] = 31; |  | 
| 864         sf->search_method = NSTEP; | 842         sf->search_method = NSTEP; | 
| 865 | 843 | 
| 866         if (Speed > 0) | 844         if (Speed > 0) | 
| 867         { | 845         { | 
| 868             cpi->mode_check_freq[THR_SPLITG] = 4; | 846             cpi->mode_check_freq[THR_SPLITG] = 4; | 
| 869             cpi->mode_check_freq[THR_SPLITA] = 4; | 847             cpi->mode_check_freq[THR_SPLITA] = 4; | 
| 870             cpi->mode_check_freq[THR_SPLITMV] = 2; | 848             cpi->mode_check_freq[THR_SPLITMV] = 2; | 
| 871 | 849 | 
| 872             sf->thresh_mult[THR_DC       ] = 0; | 850             sf->thresh_mult[THR_DC       ] = 0; | 
| 873             sf->thresh_mult[THR_TM       ] = 1000; | 851             sf->thresh_mult[THR_TM       ] = 1000; | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 897             { | 875             { | 
| 898                 sf->thresh_mult[THR_NEARESTA ] = 1000; | 876                 sf->thresh_mult[THR_NEARESTA ] = 1000; | 
| 899                 sf->thresh_mult[THR_ZEROA    ] = 1000; | 877                 sf->thresh_mult[THR_ZEROA    ] = 1000; | 
| 900                 sf->thresh_mult[THR_NEARA    ] = 1000; | 878                 sf->thresh_mult[THR_NEARA    ] = 1000; | 
| 901                 sf->thresh_mult[THR_NEWA     ] = 2000; | 879                 sf->thresh_mult[THR_NEWA     ] = 2000; | 
| 902                 sf->thresh_mult[THR_SPLITA   ] = 20000; | 880                 sf->thresh_mult[THR_SPLITA   ] = 20000; | 
| 903             } | 881             } | 
| 904 | 882 | 
| 905             sf->improved_quant = 0; | 883             sf->improved_quant = 0; | 
| 906             sf->improved_dct = 0; | 884             sf->improved_dct = 0; | 
|  | 885 | 
|  | 886             sf->use_fastquant_for_pick = 1; | 
|  | 887             sf->no_skip_block4x4_search = 0; | 
|  | 888             sf->first_step = 1; | 
| 907         } | 889         } | 
| 908 | 890 | 
| 909         if (Speed > 1) | 891         if (Speed > 1) | 
| 910         { | 892         { | 
| 911             cpi->mode_check_freq[THR_SPLITMV] = 7; | 893             cpi->mode_check_freq[THR_SPLITMV] = 7; | 
| 912             cpi->mode_check_freq[THR_SPLITG] = 15; | 894             cpi->mode_check_freq[THR_SPLITG] = 15; | 
| 913             cpi->mode_check_freq[THR_SPLITA] = 15; | 895             cpi->mode_check_freq[THR_SPLITA] = 15; | 
| 914 | 896 | 
| 915             sf->thresh_mult[THR_TM       ] = 2000; | 897             sf->thresh_mult[THR_TM       ] = 2000; | 
| 916             sf->thresh_mult[THR_V_PRED   ] = 2000; | 898             sf->thresh_mult[THR_V_PRED   ] = 2000; | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 934 | 916 | 
| 935             if (cpi->ref_frame_flags & VP8_ALT_FLAG) | 917             if (cpi->ref_frame_flags & VP8_ALT_FLAG) | 
| 936             { | 918             { | 
| 937                 sf->thresh_mult[THR_NEARESTA ] = 2000; | 919                 sf->thresh_mult[THR_NEARESTA ] = 2000; | 
| 938                 sf->thresh_mult[THR_ZEROA    ] = 2000; | 920                 sf->thresh_mult[THR_ZEROA    ] = 2000; | 
| 939                 sf->thresh_mult[THR_NEARA    ] = 2000; | 921                 sf->thresh_mult[THR_NEARA    ] = 2000; | 
| 940                 sf->thresh_mult[THR_NEWA     ] = 2500; | 922                 sf->thresh_mult[THR_NEWA     ] = 2500; | 
| 941                 sf->thresh_mult[THR_SPLITA   ] = 50000; | 923                 sf->thresh_mult[THR_SPLITA   ] = 50000; | 
| 942             } | 924             } | 
| 943 | 925 | 
| 944             sf->full_freq[0] = 31; |  | 
| 945             sf->full_freq[1] = 63; |  | 
| 946         } | 926         } | 
| 947 | 927 | 
| 948         if (Speed > 2) | 928         if (Speed > 2) | 
| 949         { | 929         { | 
| 950             sf->auto_filter = 0;                     // Faster selection of loop
       filter | 930             sf->auto_filter = 0;                     // Faster selection of loop
       filter | 
| 951 | 931 | 
| 952             cpi->mode_check_freq[THR_V_PRED] = 2; | 932             cpi->mode_check_freq[THR_V_PRED] = 2; | 
| 953             cpi->mode_check_freq[THR_H_PRED] = 2; | 933             cpi->mode_check_freq[THR_H_PRED] = 2; | 
| 954             cpi->mode_check_freq[THR_B_PRED] = 2; | 934             cpi->mode_check_freq[THR_B_PRED] = 2; | 
| 955 | 935 | 
| 956             if (cpi->ref_frame_flags & VP8_GOLD_FLAG) | 936             if (cpi->ref_frame_flags & VP8_GOLD_FLAG) | 
| 957             { | 937             { | 
| 958                 cpi->mode_check_freq[THR_NEARG] = 2; | 938                 cpi->mode_check_freq[THR_NEARG] = 2; | 
| 959                 cpi->mode_check_freq[THR_NEWG] = 4; | 939                 cpi->mode_check_freq[THR_NEWG] = 4; | 
| 960             } | 940             } | 
| 961 | 941 | 
| 962             if (cpi->ref_frame_flags & VP8_ALT_FLAG) | 942             if (cpi->ref_frame_flags & VP8_ALT_FLAG) | 
| 963             { | 943             { | 
| 964                 cpi->mode_check_freq[THR_NEARA] = 2; | 944                 cpi->mode_check_freq[THR_NEARA] = 2; | 
| 965                 cpi->mode_check_freq[THR_NEWA] = 4; | 945                 cpi->mode_check_freq[THR_NEWA] = 4; | 
| 966             } | 946             } | 
| 967 | 947 | 
| 968             sf->thresh_mult[THR_SPLITMV  ] = INT_MAX; | 948             sf->thresh_mult[THR_SPLITMV  ] = INT_MAX; | 
| 969             sf->thresh_mult[THR_SPLITG  ] = INT_MAX; | 949             sf->thresh_mult[THR_SPLITG  ] = INT_MAX; | 
| 970             sf->thresh_mult[THR_SPLITA  ] = INT_MAX; | 950             sf->thresh_mult[THR_SPLITA  ] = INT_MAX; | 
| 971 | 951 | 
| 972             sf->full_freq[0] = 63; |  | 
| 973             sf->full_freq[1] = 127; |  | 
| 974         } | 952         } | 
| 975 | 953 | 
| 976         if (Speed > 3) | 954         if (Speed > 3) | 
| 977         { | 955         { | 
| 978             sf->RD = 0; | 956             sf->RD = 0; | 
| 979             sf->full_freq[0] = INT_MAX; |  | 
| 980             sf->full_freq[1] = INT_MAX; |  | 
| 981 | 957 | 
| 982             sf->auto_filter = 1; | 958             sf->auto_filter = 1; | 
| 983         } | 959         } | 
| 984 | 960 | 
| 985         if (Speed > 4) | 961         if (Speed > 4) | 
| 986         { | 962         { | 
| 987             sf->auto_filter = 0;                     // Faster selection of loop
       filter | 963             sf->auto_filter = 0;                     // Faster selection of loop
       filter | 
| 988 | 964 | 
| 989 #if CONFIG_REALTIME_ONLY |  | 
| 990             sf->search_method = HEX; | 965             sf->search_method = HEX; | 
| 991 #else | 966             //sf->search_method = DIAMOND; | 
| 992             sf->search_method = DIAMOND; | 967 | 
| 993 #endif |  | 
| 994             sf->iterative_sub_pixel = 0; | 968             sf->iterative_sub_pixel = 0; | 
| 995 | 969 | 
| 996             cpi->mode_check_freq[THR_V_PRED] = 4; | 970             cpi->mode_check_freq[THR_V_PRED] = 4; | 
| 997             cpi->mode_check_freq[THR_H_PRED] = 4; | 971             cpi->mode_check_freq[THR_H_PRED] = 4; | 
| 998             cpi->mode_check_freq[THR_B_PRED] = 4; | 972             cpi->mode_check_freq[THR_B_PRED] = 4; | 
| 999 | 973 | 
| 1000             if (cpi->ref_frame_flags & VP8_GOLD_FLAG) | 974             if (cpi->ref_frame_flags & VP8_GOLD_FLAG) | 
| 1001             { | 975             { | 
| 1002                 cpi->mode_check_freq[THR_NEARG] = 2; | 976                 cpi->mode_check_freq[THR_NEARG] = 2; | 
| 1003                 cpi->mode_check_freq[THR_NEWG] = 4; | 977                 cpi->mode_check_freq[THR_NEWG] = 4; | 
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1201     else | 1175     else | 
| 1202     { | 1176     { | 
| 1203         cpi->mb.vp8_short_fdct8x4   = FDCT_INVOKE(&cpi->rtcd.fdct, fast8x4); | 1177         cpi->mb.vp8_short_fdct8x4   = FDCT_INVOKE(&cpi->rtcd.fdct, fast8x4); | 
| 1204         cpi->mb.vp8_short_fdct4x4   = FDCT_INVOKE(&cpi->rtcd.fdct, fast4x4); | 1178         cpi->mb.vp8_short_fdct4x4   = FDCT_INVOKE(&cpi->rtcd.fdct, fast4x4); | 
| 1205     } | 1179     } | 
| 1206 | 1180 | 
| 1207     cpi->mb.short_walsh4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, walsh_short4x4); | 1181     cpi->mb.short_walsh4x4 = FDCT_INVOKE(&cpi->rtcd.fdct, walsh_short4x4); | 
| 1208 | 1182 | 
| 1209     if (cpi->sf.improved_quant) | 1183     if (cpi->sf.improved_quant) | 
| 1210     { | 1184     { | 
| 1211         cpi->mb.quantize_b    = QUANTIZE_INVOKE(&cpi->rtcd.quantize, quantb); | 1185         cpi->mb.quantize_b      = QUANTIZE_INVOKE(&cpi->rtcd.quantize, | 
|  | 1186                                                   quantb); | 
|  | 1187         cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize, | 
|  | 1188                                                   quantb_pair); | 
| 1212     } | 1189     } | 
| 1213     else | 1190     else | 
| 1214     { | 1191     { | 
| 1215         cpi->mb.quantize_b      = QUANTIZE_INVOKE(&cpi->rtcd.quantize, fastquant
      b); | 1192         cpi->mb.quantize_b      = QUANTIZE_INVOKE(&cpi->rtcd.quantize, | 
|  | 1193                                                   fastquantb); | 
|  | 1194         cpi->mb.quantize_b_pair = QUANTIZE_INVOKE(&cpi->rtcd.quantize, | 
|  | 1195                                                   fastquantb_pair); | 
| 1216     } | 1196     } | 
| 1217     if (cpi->sf.improved_quant != last_improved_quant) | 1197     if (cpi->sf.improved_quant != last_improved_quant) | 
| 1218         vp8cx_init_quantizer(cpi); | 1198         vp8cx_init_quantizer(cpi); | 
| 1219 | 1199 | 
| 1220 #if CONFIG_RUNTIME_CPU_DETECT | 1200 #if CONFIG_RUNTIME_CPU_DETECT | 
| 1221     cpi->mb.e_mbd.rtcd = &cpi->common.rtcd; | 1201     cpi->mb.e_mbd.rtcd = &cpi->common.rtcd; | 
| 1222 #endif | 1202 #endif | 
| 1223 | 1203 | 
| 1224     if (cpi->sf.iterative_sub_pixel == 1) | 1204     if (cpi->sf.iterative_sub_pixel == 1) | 
| 1225     { | 1205     { | 
| 1226         cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step_iteratively; | 1206         cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step_iteratively; | 
| 1227     } | 1207     } | 
| 1228     else if (cpi->sf.quarter_pixel_search) | 1208     else if (cpi->sf.quarter_pixel_search) | 
| 1229     { | 1209     { | 
| 1230         cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step; | 1210         cpi->find_fractional_mv_step = vp8_find_best_sub_pixel_step; | 
| 1231     } | 1211     } | 
| 1232     else if (cpi->sf.half_pixel_search) | 1212     else if (cpi->sf.half_pixel_search) | 
| 1233     { | 1213     { | 
| 1234         cpi->find_fractional_mv_step = vp8_find_best_half_pixel_step; | 1214         cpi->find_fractional_mv_step = vp8_find_best_half_pixel_step; | 
| 1235     } | 1215     } | 
| 1236     else | 1216     else | 
| 1237     { | 1217     { | 
| 1238         cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step; | 1218         cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step; | 
| 1239     } | 1219     } | 
| 1240 | 1220 | 
| 1241     if (cpi->sf.optimize_coefficients == 1) | 1221     if (cpi->sf.optimize_coefficients == 1 && cpi->pass!=1) | 
| 1242         cpi->mb.optimize = 1 + cpi->is_next_src_alt_ref; | 1222         cpi->mb.optimize = 1; | 
| 1243     else | 1223     else | 
| 1244         cpi->mb.optimize = 0; | 1224         cpi->mb.optimize = 0; | 
| 1245 | 1225 | 
| 1246     if (cpi->common.full_pixel) | 1226     if (cpi->common.full_pixel) | 
| 1247         cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step; | 1227         cpi->find_fractional_mv_step = vp8_skip_fractional_mv_step; | 
| 1248 | 1228 | 
| 1249 #ifdef SPEEDSTATS | 1229 #ifdef SPEEDSTATS | 
| 1250     frames_at_speed[cpi->Speed]++; | 1230     frames_at_speed[cpi->Speed]++; | 
| 1251 #endif | 1231 #endif | 
| 1252 } | 1232 } | 
| 1253 static void alloc_raw_frame_buffers(VP8_COMP *cpi) | 1233 static void alloc_raw_frame_buffers(VP8_COMP *cpi) | 
| 1254 { | 1234 { | 
| 1255     int i, buffers; |  | 
| 1256     /* allocate source_buffer to be multiples of 16 */ |  | 
| 1257     int width = (cpi->oxcf.Width + 15) & ~15; | 1235     int width = (cpi->oxcf.Width + 15) & ~15; | 
|  | 1236     int height = (cpi->oxcf.Height + 15) & ~15; | 
| 1258 | 1237 | 
| 1259     buffers = cpi->oxcf.lag_in_frames; | 1238     cpi->lookahead = vp8_lookahead_init(cpi->oxcf.Width, cpi->oxcf.Height, | 
| 1260 | 1239                                         cpi->oxcf.lag_in_frames); | 
| 1261     if (buffers > MAX_LAG_BUFFERS) | 1240     if(!cpi->lookahead) | 
| 1262         buffers = MAX_LAG_BUFFERS; | 1241         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 
| 1263 | 1242                            "Failed to allocate lag buffers"); | 
| 1264     if (buffers < 1) |  | 
| 1265         buffers = 1; |  | 
| 1266 |  | 
| 1267     for (i = 0; i < buffers; i++) |  | 
| 1268         if (vp8_yv12_alloc_frame_buffer(&cpi->src_buffer[i].source_buffer, |  | 
| 1269                                         width, cpi->oxcf.Height, |  | 
| 1270                                         16)) |  | 
| 1271             vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, |  | 
| 1272                                "Failed to allocate lag buffer"); |  | 
| 1273 | 1243 | 
| 1274 #if VP8_TEMPORAL_ALT_REF | 1244 #if VP8_TEMPORAL_ALT_REF | 
| 1275 | 1245 | 
| 1276     if (vp8_yv12_alloc_frame_buffer(&cpi->alt_ref_buffer.source_buffer, | 1246     if (vp8_yv12_alloc_frame_buffer(&cpi->alt_ref_buffer, | 
| 1277                                     width, cpi->oxcf.Height, 16)) | 1247                                     width, height, VP8BORDERINPIXELS)) | 
| 1278         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 1248         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 
| 1279                            "Failed to allocate altref buffer"); | 1249                            "Failed to allocate altref buffer"); | 
| 1280 | 1250 | 
| 1281 #endif | 1251 #endif | 
| 1282 |  | 
| 1283     cpi->source_buffer_count = 0; |  | 
| 1284 } | 1252 } | 
| 1285 | 1253 | 
| 1286 static int vp8_alloc_partition_data(VP8_COMP *cpi) | 1254 static int vp8_alloc_partition_data(VP8_COMP *cpi) | 
| 1287 { | 1255 { | 
| 1288         vpx_free(cpi->mb.pip); | 1256         vpx_free(cpi->mb.pip); | 
| 1289 | 1257 | 
| 1290     cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) * | 1258     cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) * | 
| 1291                                 (cpi->common.mb_rows + 1), | 1259                                 (cpi->common.mb_rows + 1), | 
| 1292                                 sizeof(PARTITION_INFO)); | 1260                                 sizeof(PARTITION_INFO)); | 
| 1293     if(!cpi->mb.pip) | 1261     if(!cpi->mb.pip) | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 1319 | 1287 | 
| 1320     if ((height & 0xf) != 0) | 1288     if ((height & 0xf) != 0) | 
| 1321         height += 16 - (height & 0xf); | 1289         height += 16 - (height & 0xf); | 
| 1322 | 1290 | 
| 1323 | 1291 | 
| 1324     if (vp8_yv12_alloc_frame_buffer(&cpi->last_frame_uf, | 1292     if (vp8_yv12_alloc_frame_buffer(&cpi->last_frame_uf, | 
| 1325                                     width, height, VP8BORDERINPIXELS)) | 1293                                     width, height, VP8BORDERINPIXELS)) | 
| 1326         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 1294         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 
| 1327                            "Failed to allocate last frame buffer"); | 1295                            "Failed to allocate last frame buffer"); | 
| 1328 | 1296 | 
| 1329     if (vp8_yv12_alloc_frame_buffer(&cpi->scaled_source, width, height, 16)) | 1297     if (vp8_yv12_alloc_frame_buffer(&cpi->scaled_source, | 
|  | 1298                                     width, height, VP8BORDERINPIXELS)) | 
| 1330         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 1299         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 
| 1331                            "Failed to allocate scaled source buffer"); | 1300                            "Failed to allocate scaled source buffer"); | 
| 1332 | 1301 | 
| 1333 | 1302 | 
| 1334         vpx_free(cpi->tok); | 1303         vpx_free(cpi->tok); | 
| 1335 | 1304 | 
| 1336     { | 1305     { | 
| 1337         unsigned int tokens = cm->mb_rows * cm->mb_cols * 24 * 16; | 1306         unsigned int tokens = cm->mb_rows * cm->mb_cols * 24 * 16; | 
| 1338 | 1307 | 
| 1339         CHECK_MEM_ERROR(cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok))); | 1308         CHECK_MEM_ERROR(cpi->tok, vpx_calloc(tokens, sizeof(*cpi->tok))); | 
| 1340     } | 1309     } | 
| 1341 | 1310 | 
| 1342     // Data used for real time vc mode to see if gf needs refreshing | 1311     // Data used for real time vc mode to see if gf needs refreshing | 
| 1343     cpi->inter_zz_count = 0; | 1312     cpi->inter_zz_count = 0; | 
| 1344     cpi->gf_bad_count = 0; | 1313     cpi->gf_bad_count = 0; | 
| 1345     cpi->gf_update_recommended = 0; | 1314     cpi->gf_update_recommended = 0; | 
| 1346 | 1315 | 
| 1347 | 1316 | 
| 1348     // Structures used to minitor GF usage | 1317     // Structures used to minitor GF usage | 
| 1349         vpx_free(cpi->gf_active_flags); | 1318     vpx_free(cpi->gf_active_flags); | 
| 1350 | 1319     CHECK_MEM_ERROR(cpi->gf_active_flags, | 
| 1351     CHECK_MEM_ERROR(cpi->gf_active_flags, vpx_calloc(1, cm->mb_rows * cm->mb_col
      s)); | 1320                     vpx_calloc(1, cm->mb_rows * cm->mb_cols)); | 
| 1352 |  | 
| 1353     cpi->gf_active_count = cm->mb_rows * cm->mb_cols; | 1321     cpi->gf_active_count = cm->mb_rows * cm->mb_cols; | 
| 1354 | 1322 | 
|  | 1323     vpx_free(cpi->mb_activity_map); | 
|  | 1324     CHECK_MEM_ERROR(cpi->mb_activity_map, | 
|  | 1325                     vpx_calloc(sizeof(unsigned int), | 
|  | 1326                     cm->mb_rows * cm->mb_cols)); | 
|  | 1327 | 
|  | 1328     vpx_free(cpi->mb_norm_activity_map); | 
|  | 1329     CHECK_MEM_ERROR(cpi->mb_norm_activity_map, | 
|  | 1330                     vpx_calloc(sizeof(unsigned int), | 
|  | 1331                     cm->mb_rows * cm->mb_cols)); | 
|  | 1332 | 
| 1355 #if !(CONFIG_REALTIME_ONLY) | 1333 #if !(CONFIG_REALTIME_ONLY) | 
| 1356         vpx_free(cpi->total_stats); | 1334         vpx_free(cpi->twopass.total_stats); | 
| 1357 | 1335 | 
| 1358     cpi->total_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS)); | 1336     cpi->twopass.total_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS)); | 
| 1359 | 1337 | 
| 1360         vpx_free(cpi->this_frame_stats); | 1338         vpx_free(cpi->twopass.this_frame_stats); | 
| 1361 | 1339 | 
| 1362     cpi->this_frame_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS)); | 1340     cpi->twopass.this_frame_stats = vpx_calloc(1, sizeof(FIRSTPASS_STATS)); | 
| 1363 | 1341 | 
| 1364     if(!cpi->total_stats || !cpi->this_frame_stats) | 1342     if(!cpi->twopass.total_stats || !cpi->twopass.this_frame_stats) | 
| 1365         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 1343         vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, | 
| 1366                            "Failed to allocate firstpass stats"); | 1344                            "Failed to allocate firstpass stats"); | 
| 1367 #endif | 1345 #endif | 
| 1368 | 1346 | 
| 1369 #if CONFIG_MULTITHREAD | 1347 #if CONFIG_MULTITHREAD | 
| 1370     if (width < 640) | 1348     if (width < 640) | 
| 1371         cpi->mt_sync_range = 1; | 1349         cpi->mt_sync_range = 1; | 
| 1372     else if (width <= 1280) | 1350     else if (width <= 1280) | 
| 1373         cpi->mt_sync_range = 4; | 1351         cpi->mt_sync_range = 4; | 
| 1374     else if (width <= 2560) | 1352     else if (width <= 2560) | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1417     cpi->av_per_frame_bandwidth        = (int)(cpi->oxcf.target_bandwidth / cpi-
      >output_frame_rate); | 1395     cpi->av_per_frame_bandwidth        = (int)(cpi->oxcf.target_bandwidth / cpi-
      >output_frame_rate); | 
| 1418     cpi->min_frame_bandwidth          = (int)(cpi->av_per_frame_bandwidth * cpi-
      >oxcf.two_pass_vbrmin_section / 100); | 1396     cpi->min_frame_bandwidth          = (int)(cpi->av_per_frame_bandwidth * cpi-
      >oxcf.two_pass_vbrmin_section / 100); | 
| 1419 | 1397 | 
| 1420     // Set Maximum gf/arf interval | 1398     // Set Maximum gf/arf interval | 
| 1421     cpi->max_gf_interval = ((int)(cpi->output_frame_rate / 2.0) + 2); | 1399     cpi->max_gf_interval = ((int)(cpi->output_frame_rate / 2.0) + 2); | 
| 1422 | 1400 | 
| 1423     if(cpi->max_gf_interval < 12) | 1401     if(cpi->max_gf_interval < 12) | 
| 1424         cpi->max_gf_interval = 12; | 1402         cpi->max_gf_interval = 12; | 
| 1425 | 1403 | 
| 1426     // Extended interval for genuinely static scenes | 1404     // Extended interval for genuinely static scenes | 
| 1427     cpi->static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; | 1405     cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; | 
| 1428 | 1406 | 
| 1429      // Special conditions when altr ref frame enabled in lagged compress mode | 1407      // Special conditions when altr ref frame enabled in lagged compress mode | 
| 1430     if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) | 1408     if (cpi->oxcf.play_alternate && cpi->oxcf.lag_in_frames) | 
| 1431     { | 1409     { | 
| 1432         if (cpi->max_gf_interval > cpi->oxcf.lag_in_frames - 1) | 1410         if (cpi->max_gf_interval > cpi->oxcf.lag_in_frames - 1) | 
| 1433             cpi->max_gf_interval = cpi->oxcf.lag_in_frames - 1; | 1411             cpi->max_gf_interval = cpi->oxcf.lag_in_frames - 1; | 
| 1434 | 1412 | 
| 1435         if (cpi->static_scene_max_gf_interval > cpi->oxcf.lag_in_frames - 1) | 1413         if (cpi->twopass.static_scene_max_gf_interval > cpi->oxcf.lag_in_frames 
      - 1) | 
| 1436             cpi->static_scene_max_gf_interval = cpi->oxcf.lag_in_frames - 1; | 1414             cpi->twopass.static_scene_max_gf_interval = cpi->oxcf.lag_in_frames 
      - 1; | 
| 1437     } | 1415     } | 
| 1438 | 1416 | 
| 1439     if ( cpi->max_gf_interval > cpi->static_scene_max_gf_interval ) | 1417     if ( cpi->max_gf_interval > cpi->twopass.static_scene_max_gf_interval ) | 
| 1440         cpi->max_gf_interval = cpi->static_scene_max_gf_interval; | 1418         cpi->max_gf_interval = cpi->twopass.static_scene_max_gf_interval; | 
| 1441 } | 1419 } | 
| 1442 | 1420 | 
| 1443 | 1421 | 
| 1444 static int | 1422 static int | 
| 1445 rescale(int val, int num, int denom) | 1423 rescale(int val, int num, int denom) | 
| 1446 { | 1424 { | 
| 1447     int64_t llnum = num; | 1425     int64_t llnum = num; | 
| 1448     int64_t llden = denom; | 1426     int64_t llden = denom; | 
| 1449     int64_t llval = val; | 1427     int64_t llval = val; | 
| 1450 | 1428 | 
| 1451     return llval * llnum / llden; | 1429     return llval * llnum / llden; | 
| 1452 } | 1430 } | 
| 1453 | 1431 | 
| 1454 | 1432 | 
| 1455 static void init_config(VP8_PTR ptr, VP8_CONFIG *oxcf) | 1433 static void init_config(VP8_PTR ptr, VP8_CONFIG *oxcf) | 
| 1456 { | 1434 { | 
| 1457     VP8_COMP *cpi = (VP8_COMP *)(ptr); | 1435     VP8_COMP *cpi = (VP8_COMP *)(ptr); | 
| 1458     VP8_COMMON *cm = &cpi->common; | 1436     VP8_COMMON *cm = &cpi->common; | 
| 1459 | 1437 | 
| 1460     cpi->oxcf = *oxcf; | 1438     cpi->oxcf = *oxcf; | 
| 1461 | 1439 | 
| 1462     cpi->auto_gold = 1; | 1440     cpi->auto_gold = 1; | 
| 1463     cpi->auto_adjust_gold_quantizer = 1; | 1441     cpi->auto_adjust_gold_quantizer = 1; | 
| 1464     cpi->goldquantizer = 1; |  | 
| 1465     cpi->goldfreq = 7; | 1442     cpi->goldfreq = 7; | 
| 1466     cpi->auto_adjust_key_quantizer = 1; |  | 
| 1467     cpi->keyquantizer = 1; |  | 
| 1468 | 1443 | 
| 1469     cm->version = oxcf->Version; | 1444     cm->version = oxcf->Version; | 
| 1470     vp8_setup_version(cm); | 1445     vp8_setup_version(cm); | 
| 1471 | 1446 | 
| 1472     // change includes all joint functionality | 1447     // change includes all joint functionality | 
| 1473     vp8_change_config(ptr, oxcf); | 1448     vp8_change_config(ptr, oxcf); | 
| 1474 | 1449 | 
| 1475     // Initialize active best and worst q and average q values. | 1450     // Initialize active best and worst q and average q values. | 
| 1476     cpi->active_worst_quality         = cpi->oxcf.worst_allowed_q; | 1451     cpi->active_worst_quality         = cpi->oxcf.worst_allowed_q; | 
| 1477     cpi->active_best_quality          = cpi->oxcf.best_allowed_q; | 1452     cpi->active_best_quality          = cpi->oxcf.best_allowed_q; | 
| 1478     cpi->avg_frame_qindex             = cpi->oxcf.worst_allowed_q; | 1453     cpi->avg_frame_qindex             = cpi->oxcf.worst_allowed_q; | 
| 1479 | 1454 | 
| 1480     // Initialise the starting buffer levels | 1455     // Initialise the starting buffer levels | 
| 1481     cpi->oxcf.starting_buffer_level = |  | 
| 1482         rescale(cpi->oxcf.starting_buffer_level, |  | 
| 1483                 cpi->oxcf.target_bandwidth, 1000); |  | 
| 1484 |  | 
| 1485     cpi->buffer_level                 = cpi->oxcf.starting_buffer_level; | 1456     cpi->buffer_level                 = cpi->oxcf.starting_buffer_level; | 
| 1486     cpi->bits_off_target              = cpi->oxcf.starting_buffer_level; | 1457     cpi->bits_off_target              = cpi->oxcf.starting_buffer_level; | 
| 1487 | 1458 | 
| 1488     cpi->rolling_target_bits          = cpi->av_per_frame_bandwidth; | 1459     cpi->rolling_target_bits          = cpi->av_per_frame_bandwidth; | 
| 1489     cpi->rolling_actual_bits          = cpi->av_per_frame_bandwidth; | 1460     cpi->rolling_actual_bits          = cpi->av_per_frame_bandwidth; | 
| 1490     cpi->long_rolling_target_bits     = cpi->av_per_frame_bandwidth; | 1461     cpi->long_rolling_target_bits     = cpi->av_per_frame_bandwidth; | 
| 1491     cpi->long_rolling_actual_bits     = cpi->av_per_frame_bandwidth; | 1462     cpi->long_rolling_actual_bits     = cpi->av_per_frame_bandwidth; | 
| 1492 | 1463 | 
| 1493     cpi->total_actual_bits            = 0; | 1464     cpi->total_actual_bits            = 0; | 
| 1494     cpi->total_target_vs_actual       = 0; | 1465     cpi->total_target_vs_actual       = 0; | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1535         if (cpi->oxcf.cpu_used < -16) | 1506         if (cpi->oxcf.cpu_used < -16) | 
| 1536         { | 1507         { | 
| 1537             cpi->oxcf.cpu_used = -16; | 1508             cpi->oxcf.cpu_used = -16; | 
| 1538         } | 1509         } | 
| 1539 | 1510 | 
| 1540         if (cpi->oxcf.cpu_used > 16) | 1511         if (cpi->oxcf.cpu_used > 16) | 
| 1541             cpi->oxcf.cpu_used = 16; | 1512             cpi->oxcf.cpu_used = 16; | 
| 1542 | 1513 | 
| 1543         break; | 1514         break; | 
| 1544 | 1515 | 
| 1545 #if !(CONFIG_REALTIME_ONLY) |  | 
| 1546     case MODE_GOODQUALITY: | 1516     case MODE_GOODQUALITY: | 
| 1547         cpi->pass = 0; | 1517         cpi->pass = 0; | 
| 1548         cpi->compressor_speed = 1; | 1518         cpi->compressor_speed = 1; | 
| 1549 | 1519 | 
| 1550         if (cpi->oxcf.cpu_used < -5) | 1520         if (cpi->oxcf.cpu_used < -5) | 
| 1551         { | 1521         { | 
| 1552             cpi->oxcf.cpu_used = -5; | 1522             cpi->oxcf.cpu_used = -5; | 
| 1553         } | 1523         } | 
| 1554 | 1524 | 
| 1555         if (cpi->oxcf.cpu_used > 5) | 1525         if (cpi->oxcf.cpu_used > 5) | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 1576         } | 1546         } | 
| 1577 | 1547 | 
| 1578         if (cpi->oxcf.cpu_used > 5) | 1548         if (cpi->oxcf.cpu_used > 5) | 
| 1579             cpi->oxcf.cpu_used = 5; | 1549             cpi->oxcf.cpu_used = 5; | 
| 1580 | 1550 | 
| 1581         break; | 1551         break; | 
| 1582     case MODE_SECONDPASS_BEST: | 1552     case MODE_SECONDPASS_BEST: | 
| 1583         cpi->pass = 2; | 1553         cpi->pass = 2; | 
| 1584         cpi->compressor_speed = 0; | 1554         cpi->compressor_speed = 0; | 
| 1585         break; | 1555         break; | 
| 1586 #endif |  | 
| 1587     } | 1556     } | 
| 1588 | 1557 | 
| 1589     if (cpi->pass == 0) | 1558     if (cpi->pass == 0) | 
| 1590         cpi->auto_worst_q = 1; | 1559         cpi->auto_worst_q = 1; | 
| 1591 | 1560 | 
| 1592     cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q]; | 1561     cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q]; | 
| 1593     cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q]; | 1562     cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q]; | 
| 1594     cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level]; | 1563     cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level]; | 
| 1595 | 1564 | 
| 1596     if (oxcf->fixed_q >= 0) | 1565     if (oxcf->fixed_q >= 0) | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1649     if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) | 1618     if (cpi->oxcf.end_usage == USAGE_LOCAL_FILE_PLAYBACK) | 
| 1650     { | 1619     { | 
| 1651         cpi->oxcf.starting_buffer_level   = 60000; | 1620         cpi->oxcf.starting_buffer_level   = 60000; | 
| 1652         cpi->oxcf.optimal_buffer_level    = 60000; | 1621         cpi->oxcf.optimal_buffer_level    = 60000; | 
| 1653         cpi->oxcf.maximum_buffer_size     = 240000; | 1622         cpi->oxcf.maximum_buffer_size     = 240000; | 
| 1654     } | 1623     } | 
| 1655 | 1624 | 
| 1656     // Convert target bandwidth from Kbit/s to Bit/s | 1625     // Convert target bandwidth from Kbit/s to Bit/s | 
| 1657     cpi->oxcf.target_bandwidth       *= 1000; | 1626     cpi->oxcf.target_bandwidth       *= 1000; | 
| 1658 | 1627 | 
|  | 1628     cpi->oxcf.starting_buffer_level = | 
|  | 1629         rescale(cpi->oxcf.starting_buffer_level, | 
|  | 1630                 cpi->oxcf.target_bandwidth, 1000); | 
|  | 1631 | 
| 1659     // Set or reset optimal and maximum buffer levels. | 1632     // Set or reset optimal and maximum buffer levels. | 
| 1660     if (cpi->oxcf.optimal_buffer_level == 0) | 1633     if (cpi->oxcf.optimal_buffer_level == 0) | 
| 1661         cpi->oxcf.optimal_buffer_level = cpi->oxcf.target_bandwidth / 8; | 1634         cpi->oxcf.optimal_buffer_level = cpi->oxcf.target_bandwidth / 8; | 
| 1662     else | 1635     else | 
| 1663         cpi->oxcf.optimal_buffer_level = | 1636         cpi->oxcf.optimal_buffer_level = | 
| 1664             rescale(cpi->oxcf.optimal_buffer_level, | 1637             rescale(cpi->oxcf.optimal_buffer_level, | 
| 1665                     cpi->oxcf.target_bandwidth, 1000); | 1638                     cpi->oxcf.target_bandwidth, 1000); | 
| 1666 | 1639 | 
| 1667     if (cpi->oxcf.maximum_buffer_size == 0) | 1640     if (cpi->oxcf.maximum_buffer_size == 0) | 
| 1668         cpi->oxcf.maximum_buffer_size = cpi->oxcf.target_bandwidth / 8; | 1641         cpi->oxcf.maximum_buffer_size = cpi->oxcf.target_bandwidth / 8; | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 1698       cpi->active_best_quality = cpi->oxcf.worst_allowed_q; | 1671       cpi->active_best_quality = cpi->oxcf.worst_allowed_q; | 
| 1699     } | 1672     } | 
| 1700 | 1673 | 
| 1701     cpi->buffered_mode = (cpi->oxcf.optimal_buffer_level > 0) ? TRUE : FALSE; | 1674     cpi->buffered_mode = (cpi->oxcf.optimal_buffer_level > 0) ? TRUE : FALSE; | 
| 1702 | 1675 | 
| 1703     cpi->cq_target_quality = cpi->oxcf.cq_level; | 1676     cpi->cq_target_quality = cpi->oxcf.cq_level; | 
| 1704 | 1677 | 
| 1705     // Only allow dropped frames in buffered mode | 1678     // Only allow dropped frames in buffered mode | 
| 1706     cpi->drop_frames_allowed = cpi->oxcf.allow_df && cpi->buffered_mode; | 1679     cpi->drop_frames_allowed = cpi->oxcf.allow_df && cpi->buffered_mode; | 
| 1707 | 1680 | 
| 1708     cm->filter_type          = (LOOPFILTERTYPE) cpi->filter_type; |  | 
| 1709 |  | 
| 1710     if (!cm->use_bilinear_mc_filter) | 1681     if (!cm->use_bilinear_mc_filter) | 
| 1711         cm->mcomp_filter_type = SIXTAP; | 1682         cm->mcomp_filter_type = SIXTAP; | 
| 1712     else | 1683     else | 
| 1713         cm->mcomp_filter_type = BILINEAR; | 1684         cm->mcomp_filter_type = BILINEAR; | 
| 1714 | 1685 | 
| 1715     cpi->target_bandwidth = cpi->oxcf.target_bandwidth; | 1686     cpi->target_bandwidth = cpi->oxcf.target_bandwidth; | 
| 1716 | 1687 | 
| 1717     cm->Width       = cpi->oxcf.Width     ; | 1688     cm->Width       = cpi->oxcf.Width     ; | 
| 1718     cm->Height      = cpi->oxcf.Height    ; | 1689     cm->Height      = cpi->oxcf.Height    ; | 
| 1719 | 1690 | 
| 1720     cm->horiz_scale  = cpi->horiz_scale; | 1691     cm->horiz_scale  = cpi->horiz_scale; | 
| 1721     cm->vert_scale   = cpi->vert_scale ; | 1692     cm->vert_scale   = cpi->vert_scale ; | 
| 1722 | 1693 | 
| 1723     // As per VP8 |  | 
| 1724     cpi->intra_frame_target = (4 * (cm->Width + cm->Height) / 15) * 1000; |  | 
| 1725 |  | 
| 1726     // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs) | 1694     // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs) | 
| 1727     if (cpi->oxcf.Sharpness > 7) | 1695     if (cpi->oxcf.Sharpness > 7) | 
| 1728         cpi->oxcf.Sharpness = 7; | 1696         cpi->oxcf.Sharpness = 7; | 
| 1729 | 1697 | 
| 1730     cm->sharpness_level = cpi->oxcf.Sharpness; | 1698     cm->sharpness_level = cpi->oxcf.Sharpness; | 
| 1731 | 1699 | 
| 1732     if (cm->horiz_scale != NORMAL || cm->vert_scale != NORMAL) | 1700     if (cm->horiz_scale != NORMAL || cm->vert_scale != NORMAL) | 
| 1733     { | 1701     { | 
| 1734         int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs); | 1702         int UNINITIALIZED_IS_SAFE(hr), UNINITIALIZED_IS_SAFE(hs); | 
| 1735         int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs); | 1703         int UNINITIALIZED_IS_SAFE(vr), UNINITIALIZED_IS_SAFE(vs); | 
| 1736 | 1704 | 
| 1737         Scale2Ratio(cm->horiz_scale, &hr, &hs); | 1705         Scale2Ratio(cm->horiz_scale, &hr, &hs); | 
| 1738         Scale2Ratio(cm->vert_scale, &vr, &vs); | 1706         Scale2Ratio(cm->vert_scale, &vr, &vs); | 
| 1739 | 1707 | 
| 1740         // always go to the next whole number | 1708         // always go to the next whole number | 
| 1741         cm->Width = (hs - 1 + cpi->oxcf.Width * hr) / hs; | 1709         cm->Width = (hs - 1 + cpi->oxcf.Width * hr) / hs; | 
| 1742         cm->Height = (vs - 1 + cpi->oxcf.Height * vr) / vs; | 1710         cm->Height = (vs - 1 + cpi->oxcf.Height * vr) / vs; | 
| 1743     } | 1711     } | 
| 1744 | 1712 | 
| 1745     if (((cm->Width + 15) & 0xfffffff0) != | 1713     if (((cm->Width + 15) & 0xfffffff0) != | 
| 1746           cm->yv12_fb[cm->lst_fb_idx].y_width || | 1714           cm->yv12_fb[cm->lst_fb_idx].y_width || | 
| 1747         ((cm->Height + 15) & 0xfffffff0) != | 1715         ((cm->Height + 15) & 0xfffffff0) != | 
| 1748           cm->yv12_fb[cm->lst_fb_idx].y_height || | 1716           cm->yv12_fb[cm->lst_fb_idx].y_height || | 
| 1749         cm->yv12_fb[cm->lst_fb_idx].y_width == 0) | 1717         cm->yv12_fb[cm->lst_fb_idx].y_width == 0) | 
| 1750     { | 1718     { | 
| 1751         alloc_raw_frame_buffers(cpi); | 1719         alloc_raw_frame_buffers(cpi); | 
| 1752         vp8_alloc_compressor_data(cpi); | 1720         vp8_alloc_compressor_data(cpi); | 
| 1753     } | 1721     } | 
| 1754 | 1722 | 
| 1755     // Clamp KF frame size to quarter of data rate |  | 
| 1756     if (cpi->intra_frame_target > cpi->target_bandwidth >> 2) |  | 
| 1757         cpi->intra_frame_target = cpi->target_bandwidth >> 2; |  | 
| 1758 |  | 
| 1759     if (cpi->oxcf.fixed_q >= 0) | 1723     if (cpi->oxcf.fixed_q >= 0) | 
| 1760     { | 1724     { | 
| 1761         cpi->last_q[0] = cpi->oxcf.fixed_q; | 1725         cpi->last_q[0] = cpi->oxcf.fixed_q; | 
| 1762         cpi->last_q[1] = cpi->oxcf.fixed_q; | 1726         cpi->last_q[1] = cpi->oxcf.fixed_q; | 
| 1763     } | 1727     } | 
| 1764 | 1728 | 
| 1765     cpi->Speed = cpi->oxcf.cpu_used; | 1729     cpi->Speed = cpi->oxcf.cpu_used; | 
| 1766 | 1730 | 
| 1767     // force to allowlag to 0 if lag_in_frames is 0; | 1731     // force to allowlag to 0 if lag_in_frames is 0; | 
| 1768     if (cpi->oxcf.lag_in_frames == 0) | 1732     if (cpi->oxcf.lag_in_frames == 0) | 
| 1769     { | 1733     { | 
| 1770         cpi->oxcf.allow_lag = 0; | 1734         cpi->oxcf.allow_lag = 0; | 
| 1771     } | 1735     } | 
| 1772     // Limit on lag buffers as these are not currently dynamically allocated | 1736     // Limit on lag buffers as these are not currently dynamically allocated | 
| 1773     else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS) | 1737     else if (cpi->oxcf.lag_in_frames > MAX_LAG_BUFFERS) | 
| 1774         cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS; | 1738         cpi->oxcf.lag_in_frames = MAX_LAG_BUFFERS; | 
| 1775 | 1739 | 
| 1776     // YX Temp | 1740     // YX Temp | 
| 1777     cpi->last_alt_ref_sei    = -1; | 1741     cpi->alt_ref_source = NULL; | 
| 1778     cpi->is_src_frame_alt_ref = 0; | 1742     cpi->is_src_frame_alt_ref = 0; | 
| 1779     cpi->is_next_src_alt_ref = 0; | 1743 | 
| 1780 | 1744 | 
| 1781 #if 0 | 1745 #if 0 | 
| 1782     // Experimental RD Code | 1746     // Experimental RD Code | 
| 1783     cpi->frame_distortion = 0; | 1747     cpi->frame_distortion = 0; | 
| 1784     cpi->last_frame_distortion = 0; | 1748     cpi->last_frame_distortion = 0; | 
| 1785 #endif | 1749 #endif | 
| 1786 | 1750 | 
| 1787 } | 1751 } | 
| 1788 | 1752 | 
| 1789 #define M_LOG2_E 0.693147180559945309417 | 1753 #define M_LOG2_E 0.693147180559945309417 | 
| 1790 #define log2f(x) (log (x) / (float) M_LOG2_E) | 1754 #define log2f(x) (log (x) / (float) M_LOG2_E) | 
| 1791 static void cal_mvsadcosts(int *mvsadcost[2]) | 1755 static void cal_mvsadcosts(int *mvsadcost[2]) | 
| 1792 { | 1756 { | 
| 1793     int i = 1; | 1757     int i = 1; | 
| 1794 | 1758 | 
| 1795     mvsadcost [0] [0] = 300; | 1759     mvsadcost [0] [0] = 300; | 
| 1796     mvsadcost [1] [0] = 300; | 1760     mvsadcost [1] [0] = 300; | 
| 1797 | 1761 | 
| 1798     do | 1762     do | 
| 1799     { | 1763     { | 
| 1800         double z = 256 * (2 * (log2f(2 * i) + .6)); | 1764         double z = 256 * (2 * (log2f(8 * i) + .6)); | 
| 1801         mvsadcost [0][i] = (int) z; | 1765         mvsadcost [0][i] = (int) z; | 
| 1802         mvsadcost [1][i] = (int) z; | 1766         mvsadcost [1][i] = (int) z; | 
| 1803         mvsadcost [0][-i] = (int) z; | 1767         mvsadcost [0][-i] = (int) z; | 
| 1804         mvsadcost [1][-i] = (int) z; | 1768         mvsadcost [1][-i] = (int) z; | 
| 1805     } | 1769     } | 
| 1806     while (++i <= mv_max); | 1770     while (++i <= mvfp_max); | 
| 1807 } | 1771 } | 
| 1808 | 1772 | 
| 1809 VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf) | 1773 VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf) | 
| 1810 { | 1774 { | 
| 1811     int i; | 1775     int i; | 
| 1812     volatile union | 1776     volatile union | 
| 1813     { | 1777     { | 
| 1814         VP8_COMP *cpi; | 1778         VP8_COMP *cpi; | 
| 1815         VP8_PTR   ptr; | 1779         VP8_PTR   ptr; | 
| 1816     } ctx; | 1780     } ctx; | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1859     // Prime the recent reference frame useage counters. | 1823     // Prime the recent reference frame useage counters. | 
| 1860     // Hereafter they will be maintained as a sort of moving average | 1824     // Hereafter they will be maintained as a sort of moving average | 
| 1861     cpi->recent_ref_frame_usage[INTRA_FRAME]  = 1; | 1825     cpi->recent_ref_frame_usage[INTRA_FRAME]  = 1; | 
| 1862     cpi->recent_ref_frame_usage[LAST_FRAME]   = 1; | 1826     cpi->recent_ref_frame_usage[LAST_FRAME]   = 1; | 
| 1863     cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1; | 1827     cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1; | 
| 1864     cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1; | 1828     cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1; | 
| 1865 | 1829 | 
| 1866     // Set reference frame sign bias for ALTREF frame to 1 (for now) | 1830     // Set reference frame sign bias for ALTREF frame to 1 (for now) | 
| 1867     cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1; | 1831     cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = 1; | 
| 1868 | 1832 | 
| 1869     cpi->gf_decay_rate = 0; | 1833     cpi->twopass.gf_decay_rate = 0; | 
| 1870     cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL; | 1834     cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL; | 
| 1871 | 1835 | 
| 1872     cpi->gold_is_last = 0 ; | 1836     cpi->gold_is_last = 0 ; | 
| 1873     cpi->alt_is_last  = 0 ; | 1837     cpi->alt_is_last  = 0 ; | 
| 1874     cpi->gold_is_alt  = 0 ; | 1838     cpi->gold_is_alt  = 0 ; | 
| 1875 | 1839 | 
| 1876     // allocate memory for storing last frame's MVs for MV prediction. | 1840     // allocate memory for storing last frame's MVs for MV prediction. | 
| 1877     CHECK_MEM_ERROR(cpi->lfmv, vpx_calloc((cpi->common.mb_rows+2) * (cpi->common
      .mb_cols+2), sizeof(int_mv))); | 1841     CHECK_MEM_ERROR(cpi->lfmv, vpx_calloc((cpi->common.mb_rows+2) * (cpi->common
      .mb_cols+2), sizeof(int_mv))); | 
| 1878     CHECK_MEM_ERROR(cpi->lf_ref_frame_sign_bias, vpx_calloc((cpi->common.mb_rows
      +2) * (cpi->common.mb_cols+2), sizeof(int))); | 1842     CHECK_MEM_ERROR(cpi->lf_ref_frame_sign_bias, vpx_calloc((cpi->common.mb_rows
      +2) * (cpi->common.mb_cols+2), sizeof(int))); | 
| 1879     CHECK_MEM_ERROR(cpi->lf_ref_frame, vpx_calloc((cpi->common.mb_rows+2) * (cpi
      ->common.mb_cols+2), sizeof(int))); | 1843     CHECK_MEM_ERROR(cpi->lf_ref_frame, vpx_calloc((cpi->common.mb_rows+2) * (cpi
      ->common.mb_cols+2), sizeof(int))); | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1933 | 1897 | 
| 1934     cpi->frames_since_key = 8;        // Give a sensible default for the first f
      rame. | 1898     cpi->frames_since_key = 8;        // Give a sensible default for the first f
      rame. | 
| 1935     cpi->key_frame_frequency = cpi->oxcf.key_freq; | 1899     cpi->key_frame_frequency = cpi->oxcf.key_freq; | 
| 1936     cpi->this_key_frame_forced = FALSE; | 1900     cpi->this_key_frame_forced = FALSE; | 
| 1937     cpi->next_key_frame_forced = FALSE; | 1901     cpi->next_key_frame_forced = FALSE; | 
| 1938 | 1902 | 
| 1939     cpi->source_alt_ref_pending = FALSE; | 1903     cpi->source_alt_ref_pending = FALSE; | 
| 1940     cpi->source_alt_ref_active = FALSE; | 1904     cpi->source_alt_ref_active = FALSE; | 
| 1941     cpi->common.refresh_alt_ref_frame = 0; | 1905     cpi->common.refresh_alt_ref_frame = 0; | 
| 1942 | 1906 | 
| 1943     cpi->b_calculate_psnr = CONFIG_PSNR; | 1907     cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; | 
| 1944 #if CONFIG_PSNR | 1908 #if CONFIG_INTERNAL_STATS | 
| 1945     cpi->b_calculate_ssimg = 0; | 1909     cpi->b_calculate_ssimg = 0; | 
| 1946 | 1910 | 
| 1947     cpi->count = 0; | 1911     cpi->count = 0; | 
| 1948     cpi->bytes = 0; | 1912     cpi->bytes = 0; | 
| 1949 | 1913 | 
| 1950     if (cpi->b_calculate_psnr) | 1914     if (cpi->b_calculate_psnr) | 
| 1951     { | 1915     { | 
| 1952         cpi->total_sq_error = 0.0; | 1916         cpi->total_sq_error = 0.0; | 
| 1953         cpi->total_sq_error2 = 0.0; | 1917         cpi->total_sq_error2 = 0.0; | 
| 1954         cpi->total_y = 0.0; | 1918         cpi->total_y = 0.0; | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 1965     } | 1929     } | 
| 1966 | 1930 | 
| 1967     if (cpi->b_calculate_ssimg) | 1931     if (cpi->b_calculate_ssimg) | 
| 1968     { | 1932     { | 
| 1969         cpi->total_ssimg_y = 0; | 1933         cpi->total_ssimg_y = 0; | 
| 1970         cpi->total_ssimg_u = 0; | 1934         cpi->total_ssimg_u = 0; | 
| 1971         cpi->total_ssimg_v = 0; | 1935         cpi->total_ssimg_v = 0; | 
| 1972         cpi->total_ssimg_all = 0; | 1936         cpi->total_ssimg_all = 0; | 
| 1973     } | 1937     } | 
| 1974 | 1938 | 
|  | 1939 #endif | 
|  | 1940 | 
| 1975 #ifndef LLONG_MAX | 1941 #ifndef LLONG_MAX | 
| 1976 #define LLONG_MAX  9223372036854775807LL | 1942 #define LLONG_MAX  9223372036854775807LL | 
| 1977 #endif | 1943 #endif | 
| 1978     cpi->first_time_stamp_ever = LLONG_MAX; | 1944     cpi->first_time_stamp_ever = LLONG_MAX; | 
| 1979 | 1945 | 
| 1980 #endif |  | 
| 1981 |  | 
| 1982     cpi->frames_till_gf_update_due      = 0; | 1946     cpi->frames_till_gf_update_due      = 0; | 
| 1983     cpi->key_frame_count              = 1; | 1947     cpi->key_frame_count              = 1; | 
| 1984     cpi->tot_key_frame_bits            = 0; |  | 
| 1985 | 1948 | 
| 1986     cpi->ni_av_qi                     = cpi->oxcf.worst_allowed_q; | 1949     cpi->ni_av_qi                     = cpi->oxcf.worst_allowed_q; | 
| 1987     cpi->ni_tot_qi                    = 0; | 1950     cpi->ni_tot_qi                    = 0; | 
| 1988     cpi->ni_frames                   = 0; | 1951     cpi->ni_frames                   = 0; | 
| 1989     cpi->total_byte_count             = 0; | 1952     cpi->total_byte_count             = 0; | 
| 1990 | 1953 | 
| 1991     cpi->drop_frame                  = 0; | 1954     cpi->drop_frame                  = 0; | 
| 1992     cpi->drop_count                  = 0; | 1955     cpi->drop_count                  = 0; | 
| 1993     cpi->max_drop_count               = 0; | 1956     cpi->max_drop_count               = 0; | 
| 1994     cpi->max_consec_dropped_frames     = 4; | 1957     cpi->max_consec_dropped_frames     = 4; | 
| 1995 | 1958 | 
| 1996     cpi->rate_correction_factor         = 1.0; | 1959     cpi->rate_correction_factor         = 1.0; | 
| 1997     cpi->key_frame_rate_correction_factor = 1.0; | 1960     cpi->key_frame_rate_correction_factor = 1.0; | 
| 1998     cpi->gf_rate_correction_factor  = 1.0; | 1961     cpi->gf_rate_correction_factor  = 1.0; | 
| 1999     cpi->est_max_qcorrection_factor  = 1.0; | 1962     cpi->twopass.est_max_qcorrection_factor  = 1.0; | 
| 2000 | 1963 | 
| 2001     cpi->mb.mvcost[0] = &cpi->mb.mvcosts[0][mv_max+1]; | 1964     cpi->mb.mvcost[0] = &cpi->mb.mvcosts[0][mv_max+1]; | 
| 2002     cpi->mb.mvcost[1] = &cpi->mb.mvcosts[1][mv_max+1]; | 1965     cpi->mb.mvcost[1] = &cpi->mb.mvcosts[1][mv_max+1]; | 
| 2003     cpi->mb.mvsadcost[0] = &cpi->mb.mvsadcosts[0][mv_max+1]; | 1966     cpi->mb.mvsadcost[0] = &cpi->mb.mvsadcosts[0][mvfp_max+1]; | 
| 2004     cpi->mb.mvsadcost[1] = &cpi->mb.mvsadcosts[1][mv_max+1]; | 1967     cpi->mb.mvsadcost[1] = &cpi->mb.mvsadcosts[1][mvfp_max+1]; | 
| 2005 | 1968 | 
| 2006     cal_mvsadcosts(cpi->mb.mvsadcost); | 1969     cal_mvsadcosts(cpi->mb.mvsadcost); | 
| 2007 | 1970 | 
| 2008     for (i = 0; i < KEY_FRAME_CONTEXT; i++) | 1971     for (i = 0; i < KEY_FRAME_CONTEXT; i++) | 
| 2009     { | 1972     { | 
| 2010         cpi->prior_key_frame_size[i]     = cpi->intra_frame_target; |  | 
| 2011         cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate; | 1973         cpi->prior_key_frame_distance[i] = (int)cpi->output_frame_rate; | 
| 2012     } | 1974     } | 
| 2013 | 1975 | 
| 2014     cpi->check_freq[0] = 15; |  | 
| 2015     cpi->check_freq[1] = 15; |  | 
| 2016 |  | 
| 2017 #ifdef OUTPUT_YUV_SRC | 1976 #ifdef OUTPUT_YUV_SRC | 
| 2018     yuv_file = fopen("bd.yuv", "ab"); | 1977     yuv_file = fopen("bd.yuv", "ab"); | 
| 2019 #endif | 1978 #endif | 
| 2020 | 1979 | 
| 2021 #if 0 | 1980 #if 0 | 
| 2022     framepsnr = fopen("framepsnr.stt", "a"); | 1981     framepsnr = fopen("framepsnr.stt", "a"); | 
| 2023     kf_list = fopen("kf_list.stt", "w"); | 1982     kf_list = fopen("kf_list.stt", "w"); | 
| 2024 #endif | 1983 #endif | 
| 2025 | 1984 | 
| 2026     cpi->output_pkt_list = oxcf->output_pkt_list; | 1985     cpi->output_pkt_list = oxcf->output_pkt_list; | 
| 2027 | 1986 | 
| 2028 #if !(CONFIG_REALTIME_ONLY) | 1987 #if !(CONFIG_REALTIME_ONLY) | 
| 2029 | 1988 | 
| 2030     if (cpi->pass == 1) | 1989     if (cpi->pass == 1) | 
| 2031     { | 1990     { | 
| 2032         vp8_init_first_pass(cpi); | 1991         vp8_init_first_pass(cpi); | 
| 2033     } | 1992     } | 
| 2034     else if (cpi->pass == 2) | 1993     else if (cpi->pass == 2) | 
| 2035     { | 1994     { | 
| 2036         size_t packet_sz = sizeof(FIRSTPASS_STATS); | 1995         size_t packet_sz = sizeof(FIRSTPASS_STATS); | 
| 2037         int packets = oxcf->two_pass_stats_in.sz / packet_sz; | 1996         int packets = oxcf->two_pass_stats_in.sz / packet_sz; | 
| 2038 | 1997 | 
| 2039         cpi->stats_in = oxcf->two_pass_stats_in.buf; | 1998         cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf; | 
| 2040         cpi->stats_in_end = (void*)((char *)cpi->stats_in | 1999         cpi->twopass.stats_in = cpi->twopass.stats_in_start; | 
|  | 2000         cpi->twopass.stats_in_end = (void*)((char *)cpi->twopass.stats_in | 
| 2041                             + (packets - 1) * packet_sz); | 2001                             + (packets - 1) * packet_sz); | 
| 2042         vp8_init_second_pass(cpi); | 2002         vp8_init_second_pass(cpi); | 
| 2043     } | 2003     } | 
| 2044 | 2004 | 
| 2045 #endif | 2005 #endif | 
| 2046 | 2006 | 
| 2047     if (cpi->compressor_speed == 2) | 2007     if (cpi->compressor_speed == 2) | 
| 2048     { | 2008     { | 
| 2049         cpi->cpu_freq            = 0; //vp8_get_processor_freq(); | 2009         cpi->cpu_freq            = 0; //vp8_get_processor_freq(); | 
| 2050         cpi->avg_encode_time      = 0; | 2010         cpi->avg_encode_time      = 0; | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2110     cpi->fn_ptr[BLOCK_4X4].sdf            = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4); | 2070     cpi->fn_ptr[BLOCK_4X4].sdf            = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4); | 
| 2111     cpi->fn_ptr[BLOCK_4X4].vf             = VARIANCE_INVOKE(&cpi->rtcd.variance,
       var4x4); | 2071     cpi->fn_ptr[BLOCK_4X4].vf             = VARIANCE_INVOKE(&cpi->rtcd.variance,
       var4x4); | 
| 2112     cpi->fn_ptr[BLOCK_4X4].svf            = VARIANCE_INVOKE(&cpi->rtcd.variance,
       subpixvar4x4); | 2072     cpi->fn_ptr[BLOCK_4X4].svf            = VARIANCE_INVOKE(&cpi->rtcd.variance,
       subpixvar4x4); | 
| 2113     cpi->fn_ptr[BLOCK_4X4].svf_halfpix_h  = NULL; | 2073     cpi->fn_ptr[BLOCK_4X4].svf_halfpix_h  = NULL; | 
| 2114     cpi->fn_ptr[BLOCK_4X4].svf_halfpix_v  = NULL; | 2074     cpi->fn_ptr[BLOCK_4X4].svf_halfpix_v  = NULL; | 
| 2115     cpi->fn_ptr[BLOCK_4X4].svf_halfpix_hv = NULL; | 2075     cpi->fn_ptr[BLOCK_4X4].svf_halfpix_hv = NULL; | 
| 2116     cpi->fn_ptr[BLOCK_4X4].sdx3f          = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4x3); | 2076     cpi->fn_ptr[BLOCK_4X4].sdx3f          = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4x3); | 
| 2117     cpi->fn_ptr[BLOCK_4X4].sdx8f          = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4x8); | 2077     cpi->fn_ptr[BLOCK_4X4].sdx8f          = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4x8); | 
| 2118     cpi->fn_ptr[BLOCK_4X4].sdx4df         = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4x4d); | 2078     cpi->fn_ptr[BLOCK_4X4].sdx4df         = VARIANCE_INVOKE(&cpi->rtcd.variance,
       sad4x4x4d); | 
| 2119 | 2079 | 
| 2120 #if !(CONFIG_REALTIME_ONLY) | 2080 #if ARCH_X86 || ARCH_X86_64 | 
|  | 2081     cpi->fn_ptr[BLOCK_16X16].copymem        = VARIANCE_INVOKE(&cpi->rtcd.varianc
      e, copy32xn); | 
|  | 2082     cpi->fn_ptr[BLOCK_16X8].copymem        = VARIANCE_INVOKE(&cpi->rtcd.variance
      , copy32xn); | 
|  | 2083     cpi->fn_ptr[BLOCK_8X16].copymem        = VARIANCE_INVOKE(&cpi->rtcd.variance
      , copy32xn); | 
|  | 2084     cpi->fn_ptr[BLOCK_8X8].copymem        = VARIANCE_INVOKE(&cpi->rtcd.variance,
       copy32xn); | 
|  | 2085     cpi->fn_ptr[BLOCK_4X4].copymem        = VARIANCE_INVOKE(&cpi->rtcd.variance,
       copy32xn); | 
|  | 2086 #endif | 
|  | 2087 | 
| 2121     cpi->full_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, full_search); | 2088     cpi->full_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, full_search); | 
| 2122 #endif |  | 
| 2123     cpi->diamond_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, diamond_search); | 2089     cpi->diamond_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, diamond_search); | 
| 2124 | 2090     cpi->refining_search_sad = SEARCH_INVOKE(&cpi->rtcd.search, refining_search)
      ; | 
| 2125     cpi->ready_for_new_frame = 1; |  | 
| 2126 |  | 
| 2127     cpi->source_encode_index = 0; |  | 
| 2128 | 2091 | 
| 2129     // make sure frame 1 is okay | 2092     // make sure frame 1 is okay | 
| 2130     cpi->error_bins[0] = cpi->common.MBs; | 2093     cpi->error_bins[0] = cpi->common.MBs; | 
| 2131 | 2094 | 
| 2132     //vp8cx_init_quantizer() is first called here. Add check in vp8cx_frame_init
      _quantizer() so that vp8cx_init_quantizer is only called later | 2095     //vp8cx_init_quantizer() is first called here. Add check in vp8cx_frame_init
      _quantizer() so that vp8cx_init_quantizer is only called later | 
| 2133     //when needed. This will avoid unnecessary calls of vp8cx_init_quantizer() f
      or every frame. | 2096     //when needed. This will avoid unnecessary calls of vp8cx_init_quantizer() f
      or every frame. | 
| 2134     vp8cx_init_quantizer(cpi); | 2097     vp8cx_init_quantizer(cpi); | 
| 2135     { | 2098 | 
| 2136         vp8_init_loop_filter(cm); | 2099     vp8_loop_filter_init(cm); | 
| 2137         cm->last_frame_type = KEY_FRAME; | 2100 | 
| 2138         cm->last_filter_type = cm->filter_type; |  | 
| 2139         cm->last_sharpness_level = cm->sharpness_level; |  | 
| 2140     } |  | 
| 2141     cpi->common.error.setjmp = 0; | 2101     cpi->common.error.setjmp = 0; | 
| 2142     return (VP8_PTR) cpi; | 2102     return (VP8_PTR) cpi; | 
| 2143 | 2103 | 
| 2144 } | 2104 } | 
| 2145 | 2105 | 
| 2146 | 2106 | 
| 2147 void vp8_remove_compressor(VP8_PTR *ptr) | 2107 void vp8_remove_compressor(VP8_PTR *ptr) | 
| 2148 { | 2108 { | 
| 2149     VP8_COMP *cpi = (VP8_COMP *)(*ptr); | 2109     VP8_COMP *cpi = (VP8_COMP *)(*ptr); | 
| 2150 | 2110 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 2161         } | 2121         } | 
| 2162 | 2122 | 
| 2163 #endif | 2123 #endif | 
| 2164 | 2124 | 
| 2165 #ifdef ENTROPY_STATS | 2125 #ifdef ENTROPY_STATS | 
| 2166         print_context_counters(); | 2126         print_context_counters(); | 
| 2167         print_tree_update_probs(); | 2127         print_tree_update_probs(); | 
| 2168         print_mode_context(); | 2128         print_mode_context(); | 
| 2169 #endif | 2129 #endif | 
| 2170 | 2130 | 
| 2171 #if CONFIG_PSNR | 2131 #if CONFIG_INTERNAL_STATS | 
| 2172 | 2132 | 
| 2173         if (cpi->pass != 1) | 2133         if (cpi->pass != 1) | 
| 2174         { | 2134         { | 
| 2175             FILE *f = fopen("opsnr.stt", "a"); | 2135             FILE *f = fopen("opsnr.stt", "a"); | 
| 2176             double time_encoded = (cpi->source_end_time_stamp - cpi->first_time_
      stamp_ever) / 10000000.000; | 2136             double time_encoded = (cpi->last_end_time_stamp_seen | 
|  | 2137                                    - cpi->first_time_stamp_ever) / 10000000.000; | 
| 2177             double total_encode_time = (cpi->time_receive_data + cpi->time_compr
      ess_data)   / 1000.000; | 2138             double total_encode_time = (cpi->time_receive_data + cpi->time_compr
      ess_data)   / 1000.000; | 
| 2178             double dr = (double)cpi->bytes * (double) 8 / (double)1000  / time_e
      ncoded; | 2139             double dr = (double)cpi->bytes * (double) 8 / (double)1000  / time_e
      ncoded; | 
| 2179 | 2140 | 
| 2180             if (cpi->b_calculate_psnr) | 2141             if (cpi->b_calculate_psnr) | 
| 2181             { | 2142             { | 
| 2182                 YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.
      lst_fb_idx]; | 2143                 YV12_BUFFER_CONFIG *lst_yv12 = &cpi->common.yv12_fb[cpi->common.
      lst_fb_idx]; | 
| 2183                 double samples = 3.0 / 2 * cpi->count * lst_yv12->y_width * lst_
      yv12->y_height; | 2144                 double samples = 3.0 / 2 * cpi->count * lst_yv12->y_width * lst_
      yv12->y_height; | 
| 2184                 double total_psnr = vp8_mse2psnr(samples, 255.0, cpi->total_sq_e
      rror); | 2145                 double total_psnr = vp8_mse2psnr(samples, 255.0, cpi->total_sq_e
      rror); | 
| 2185                 double total_psnr2 = vp8_mse2psnr(samples, 255.0, cpi->total_sq_
      error2); | 2146                 double total_psnr2 = vp8_mse2psnr(samples, 255.0, cpi->total_sq_
      error2); | 
| 2186                 double total_ssim = 100 * pow(cpi->summed_quality / cpi->summed_
      weights, 8.0); | 2147                 double total_ssim = 100 * pow(cpi->summed_quality / cpi->summed_
      weights, 8.0); | 
| 2187 | 2148 | 
| 2188                 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\tVPXSSIM
      \t  Time(us)\n"); | 2149                 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\tVPXSSIM
      \t  Time(us)\n"); | 
| 2189                 fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f %8.0f\n", | 2150                 fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n", | 
| 2190                         dr, cpi->total / cpi->count, total_psnr, cpi->totalp / c
      pi->count, total_psnr2, total_ssim, | 2151                         dr, cpi->total / cpi->count, total_psnr, cpi->totalp / c
      pi->count, total_psnr2, total_ssim, | 
| 2191                         total_encode_time); | 2152                         total_encode_time); | 
| 2192             } | 2153             } | 
| 2193 | 2154 | 
| 2194             if (cpi->b_calculate_ssimg) | 2155             if (cpi->b_calculate_ssimg) | 
| 2195             { | 2156             { | 
| 2196                 fprintf(f, "BitRate\tSSIM_Y\tSSIM_U\tSSIM_V\tSSIM_A\t  Time(us)\
      n"); | 2157                 fprintf(f, "BitRate\tSSIM_Y\tSSIM_U\tSSIM_V\tSSIM_A\t  Time(us)\
      n"); | 
| 2197                 fprintf(f, "%7.3f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f\n", dr, | 2158                 fprintf(f, "%7.3f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f\n", dr, | 
| 2198                         cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cp
      i->count, | 2159                         cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cp
      i->count, | 
| 2199                         cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / 
      cpi->count, total_encode_time); | 2160                         cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / 
      cpi->count, total_encode_time); | 
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2621             tmp_height = 9; | 2582             tmp_height = 9; | 
| 2622         else | 2583         else | 
| 2623             tmp_height = 11; | 2584             tmp_height = 11; | 
| 2624 | 2585 | 
| 2625         Scale2Ratio(cm->horiz_scale, &hr, &hs); | 2586         Scale2Ratio(cm->horiz_scale, &hr, &hs); | 
| 2626         Scale2Ratio(cm->vert_scale, &vr, &vs); | 2587         Scale2Ratio(cm->vert_scale, &vr, &vs); | 
| 2627 | 2588 | 
| 2628         vp8_scale_frame(sd, &cpi->scaled_source, cm->temp_scale_frame.y_buffer, | 2589         vp8_scale_frame(sd, &cpi->scaled_source, cm->temp_scale_frame.y_buffer, | 
| 2629                         tmp_height, hs, hr, vs, vr, 0); | 2590                         tmp_height, hs, hr, vs, vr, 0); | 
| 2630 | 2591 | 
|  | 2592         vp8_yv12_extend_frame_borders(&cpi->scaled_source); | 
| 2631         cpi->Source = &cpi->scaled_source; | 2593         cpi->Source = &cpi->scaled_source; | 
| 2632 #endif | 2594 #endif | 
| 2633     } | 2595     } | 
| 2634     // we may need to copy to a buffer so we can extend the image... | 2596     else | 
| 2635     else if (cm->Width != cm->yv12_fb[cm->lst_fb_idx].y_width || | 2597         cpi->Source = sd; | 
| 2636              cm->Height != cm->yv12_fb[cm->lst_fb_idx].y_height) | 2598 } | 
| 2637     { |  | 
| 2638         //vp8_yv12_copy_frame_ptr(sd, &cpi->scaled_source); |  | 
| 2639 #if HAVE_ARMV7 |  | 
| 2640 #if CONFIG_RUNTIME_CPU_DETECT |  | 
| 2641         if (cm->rtcd.flags & HAS_NEON) |  | 
| 2642 #endif |  | 
| 2643         { |  | 
| 2644             vp8_yv12_copy_src_frame_func_neon(sd, &cpi->scaled_source); |  | 
| 2645         } |  | 
| 2646 #if CONFIG_RUNTIME_CPU_DETECT |  | 
| 2647         else |  | 
| 2648 #endif |  | 
| 2649 #endif |  | 
| 2650 #if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT |  | 
| 2651         { |  | 
| 2652             vp8_yv12_copy_frame_ptr(sd, &cpi->scaled_source); |  | 
| 2653         } |  | 
| 2654 #endif |  | 
| 2655 | 2599 | 
| 2656         cpi->Source = &cpi->scaled_source; |  | 
| 2657     } |  | 
| 2658 | 2600 | 
| 2659     vp8_extend_to_multiple_of16(cpi->Source, cm->Width, cm->Height); |  | 
| 2660 |  | 
| 2661 } |  | 
| 2662 static void resize_key_frame(VP8_COMP *cpi) | 2601 static void resize_key_frame(VP8_COMP *cpi) | 
| 2663 { | 2602 { | 
| 2664 #if CONFIG_SPATIAL_RESAMPLING | 2603 #if CONFIG_SPATIAL_RESAMPLING | 
| 2665     VP8_COMMON *cm = &cpi->common; | 2604     VP8_COMMON *cm = &cpi->common; | 
| 2666 | 2605 | 
| 2667     // Do we need to apply resampling for one pass cbr. | 2606     // Do we need to apply resampling for one pass cbr. | 
| 2668     // In one pass this is more limited than in two pass cbr | 2607     // In one pass this is more limited than in two pass cbr | 
| 2669     // The test and any change is only made one per key frame sequence | 2608     // The test and any change is only made one per key frame sequence | 
| 2670     if (cpi->oxcf.allow_spatial_resampling && (cpi->oxcf.end_usage == USAGE_STRE
      AM_FROM_SERVER)) | 2609     if (cpi->oxcf.allow_spatial_resampling && (cpi->oxcf.end_usage == USAGE_STRE
      AM_FROM_SERVER)) | 
| 2671     { | 2610     { | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 2698         { | 2637         { | 
| 2699             cm->Width = new_width; | 2638             cm->Width = new_width; | 
| 2700             cm->Height = new_height; | 2639             cm->Height = new_height; | 
| 2701             vp8_alloc_compressor_data(cpi); | 2640             vp8_alloc_compressor_data(cpi); | 
| 2702             scale_and_extend_source(cpi->un_scaled_source, cpi); | 2641             scale_and_extend_source(cpi->un_scaled_source, cpi); | 
| 2703         } | 2642         } | 
| 2704     } | 2643     } | 
| 2705 | 2644 | 
| 2706 #endif | 2645 #endif | 
| 2707 } | 2646 } | 
| 2708 // return of 0 means drop frame | 2647 | 
| 2709 static int pick_frame_size(VP8_COMP *cpi) | 2648 | 
|  | 2649 static void update_alt_ref_frame_stats(VP8_COMP *cpi) | 
| 2710 { | 2650 { | 
| 2711     VP8_COMMON *cm = &cpi->common; | 2651     VP8_COMMON *cm = &cpi->common; | 
| 2712 | 2652 | 
| 2713     // First Frame is a special case |  | 
| 2714     if (cm->current_video_frame == 0) |  | 
| 2715     { |  | 
| 2716 #if !(CONFIG_REALTIME_ONLY) |  | 
| 2717 |  | 
| 2718         if (cpi->pass == 2) |  | 
| 2719             vp8_calc_auto_iframe_target_size(cpi); |  | 
| 2720 |  | 
| 2721         // 1 Pass there is no information on which to base size so use bandwidth
       per second * fixed fraction |  | 
| 2722         else |  | 
| 2723 #endif |  | 
| 2724             cpi->this_frame_target = cpi->oxcf.target_bandwidth / 2; |  | 
| 2725 |  | 
| 2726         // in error resilient mode the first frame is bigger since it likely con
      tains |  | 
| 2727         // all the static background |  | 
| 2728         if (cpi->oxcf.error_resilient_mode == 1 || (cpi->compressor_speed == 2)) |  | 
| 2729         { |  | 
| 2730             cpi->this_frame_target *= 3;      // 5; |  | 
| 2731         } |  | 
| 2732 |  | 
| 2733         // Key frame from VFW/auto-keyframe/first frame |  | 
| 2734         cm->frame_type = KEY_FRAME; |  | 
| 2735 |  | 
| 2736     } |  | 
| 2737     // Special case for forced key frames |  | 
| 2738     // The frame sizing here is still far from ideal for 2 pass. |  | 
| 2739     else if (cm->frame_flags & FRAMEFLAGS_KEY) |  | 
| 2740     { |  | 
| 2741         cm->frame_type = KEY_FRAME; |  | 
| 2742         resize_key_frame(cpi); |  | 
| 2743         vp8_calc_iframe_target_size(cpi); |  | 
| 2744     } |  | 
| 2745     else if (cm->frame_type == KEY_FRAME) |  | 
| 2746     { |  | 
| 2747         vp8_calc_auto_iframe_target_size(cpi); |  | 
| 2748     } |  | 
| 2749     else |  | 
| 2750     { |  | 
| 2751         // INTER frame: compute target frame size |  | 
| 2752         cm->frame_type = INTER_FRAME; |  | 
| 2753         vp8_calc_pframe_target_size(cpi); |  | 
| 2754 |  | 
| 2755         // Check if we're dropping the frame: |  | 
| 2756         if (cpi->drop_frame) |  | 
| 2757         { |  | 
| 2758             cpi->drop_frame = FALSE; |  | 
| 2759             cpi->drop_count++; |  | 
| 2760             return 0; |  | 
| 2761         } |  | 
| 2762     } |  | 
| 2763 |  | 
| 2764     return 1; |  | 
| 2765 } |  | 
| 2766 |  | 
| 2767 static void set_quantizer(VP8_COMP *cpi, int Q) |  | 
| 2768 { |  | 
| 2769     VP8_COMMON *cm = &cpi->common; |  | 
| 2770     MACROBLOCKD *mbd = &cpi->mb.e_mbd; |  | 
| 2771     int update = 0; |  | 
| 2772     int new_delta_q; |  | 
| 2773     cm->base_qindex = Q; |  | 
| 2774 |  | 
| 2775     /* if any of the delta_q values are changing update flag has to be set */ |  | 
| 2776     /* currently only y2dc_delta_q may change */ |  | 
| 2777 |  | 
| 2778     cm->y1dc_delta_q = 0; |  | 
| 2779     cm->y2ac_delta_q = 0; |  | 
| 2780     cm->uvdc_delta_q = 0; |  | 
| 2781     cm->uvac_delta_q = 0; |  | 
| 2782 |  | 
| 2783     if (Q < 4) |  | 
| 2784     { |  | 
| 2785         new_delta_q = 4-Q; |  | 
| 2786     } |  | 
| 2787     else |  | 
| 2788         new_delta_q = 0; |  | 
| 2789 |  | 
| 2790     update |= cm->y2dc_delta_q != new_delta_q; |  | 
| 2791     cm->y2dc_delta_q = new_delta_q; |  | 
| 2792 |  | 
| 2793 |  | 
| 2794     // Set Segment specific quatizers |  | 
| 2795     mbd->segment_feature_data[MB_LVL_ALT_Q][0] = cpi->segment_feature_data[MB_LV
      L_ALT_Q][0]; |  | 
| 2796     mbd->segment_feature_data[MB_LVL_ALT_Q][1] = cpi->segment_feature_data[MB_LV
      L_ALT_Q][1]; |  | 
| 2797     mbd->segment_feature_data[MB_LVL_ALT_Q][2] = cpi->segment_feature_data[MB_LV
      L_ALT_Q][2]; |  | 
| 2798     mbd->segment_feature_data[MB_LVL_ALT_Q][3] = cpi->segment_feature_data[MB_LV
      L_ALT_Q][3]; |  | 
| 2799 |  | 
| 2800     /* quantizer has to be reinitialized for any delta_q changes */ |  | 
| 2801     if(update) |  | 
| 2802         vp8cx_init_quantizer(cpi); |  | 
| 2803 |  | 
| 2804 } |  | 
| 2805 |  | 
| 2806 static void update_alt_ref_frame_and_stats(VP8_COMP *cpi) |  | 
| 2807 { |  | 
| 2808     VP8_COMMON *cm = &cpi->common; |  | 
| 2809 |  | 
| 2810     // Update the golden frame buffer |  | 
| 2811     vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cm->yv12_fb[cm->alt_fb_idx]); |  | 
| 2812 |  | 
| 2813     // Select an interval before next GF or altref | 2653     // Select an interval before next GF or altref | 
| 2814     if (!cpi->auto_gold) | 2654     if (!cpi->auto_gold) | 
| 2815         cpi->frames_till_gf_update_due = cpi->goldfreq; | 2655         cpi->frames_till_gf_update_due = cpi->goldfreq; | 
| 2816 | 2656 | 
| 2817     if ((cpi->pass != 2) && cpi->frames_till_gf_update_due) | 2657     if ((cpi->pass != 2) && cpi->frames_till_gf_update_due) | 
| 2818     { | 2658     { | 
| 2819         cpi->current_gf_interval = cpi->frames_till_gf_update_due; | 2659         cpi->current_gf_interval = cpi->frames_till_gf_update_due; | 
| 2820 | 2660 | 
| 2821         // Set the bits per frame that we should try and recover in subsequent i
      nter frames | 2661         // Set the bits per frame that we should try and recover in subsequent i
      nter frames | 
| 2822         // to account for the extra GF spend... note that his does not apply for
       GF updates | 2662         // to account for the extra GF spend... note that his does not apply for
       GF updates | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 2835     cpi->common.frames_since_golden = 0; | 2675     cpi->common.frames_since_golden = 0; | 
| 2836 | 2676 | 
| 2837     // Clear the alternate reference update pending flag. | 2677     // Clear the alternate reference update pending flag. | 
| 2838     cpi->source_alt_ref_pending = FALSE; | 2678     cpi->source_alt_ref_pending = FALSE; | 
| 2839 | 2679 | 
| 2840     // Set the alternate refernce frame active flag | 2680     // Set the alternate refernce frame active flag | 
| 2841     cpi->source_alt_ref_active = TRUE; | 2681     cpi->source_alt_ref_active = TRUE; | 
| 2842 | 2682 | 
| 2843 | 2683 | 
| 2844 } | 2684 } | 
| 2845 static void update_golden_frame_and_stats(VP8_COMP *cpi) | 2685 static void update_golden_frame_stats(VP8_COMP *cpi) | 
| 2846 { | 2686 { | 
| 2847     VP8_COMMON *cm = &cpi->common; | 2687     VP8_COMMON *cm = &cpi->common; | 
| 2848 | 2688 | 
| 2849     // Update the Golden frame reconstruction buffer if signalled and the GF usa
      ge counts. | 2689     // Update the Golden frame usage counts. | 
| 2850     if (cm->refresh_golden_frame) | 2690     if (cm->refresh_golden_frame) | 
| 2851     { | 2691     { | 
| 2852         if (cm->frame_type != KEY_FRAME) |  | 
| 2853         { |  | 
| 2854             // Update the golden frame buffer |  | 
| 2855             vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cm->yv12_fb[cm->gld_fb_i
      dx]); |  | 
| 2856         } |  | 
| 2857 |  | 
| 2858         // Select an interval before next GF | 2692         // Select an interval before next GF | 
| 2859         if (!cpi->auto_gold) | 2693         if (!cpi->auto_gold) | 
| 2860             cpi->frames_till_gf_update_due = cpi->goldfreq; | 2694             cpi->frames_till_gf_update_due = cpi->goldfreq; | 
| 2861 | 2695 | 
| 2862         if ((cpi->pass != 2) && (cpi->frames_till_gf_update_due > 0)) | 2696         if ((cpi->pass != 2) && (cpi->frames_till_gf_update_due > 0)) | 
| 2863         { | 2697         { | 
| 2864             cpi->current_gf_interval = cpi->frames_till_gf_update_due; | 2698             cpi->current_gf_interval = cpi->frames_till_gf_update_due; | 
| 2865 | 2699 | 
| 2866             // Set the bits per frame that we should try and recover in subseque
      nt inter frames | 2700             // Set the bits per frame that we should try and recover in subseque
      nt inter frames | 
| 2867             // to account for the extra GF spend... note that his does not apply
       for GF updates | 2701             // to account for the extra GF spend... note that his does not apply
       for GF updates | 
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3138     return code_key_frame; | 2972     return code_key_frame; | 
| 3139 | 2973 | 
| 3140 } | 2974 } | 
| 3141 | 2975 | 
| 3142 #if !(CONFIG_REALTIME_ONLY) | 2976 #if !(CONFIG_REALTIME_ONLY) | 
| 3143 static void Pass1Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest,
       unsigned int *frame_flags) | 2977 static void Pass1Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest,
       unsigned int *frame_flags) | 
| 3144 { | 2978 { | 
| 3145     (void) size; | 2979     (void) size; | 
| 3146     (void) dest; | 2980     (void) dest; | 
| 3147     (void) frame_flags; | 2981     (void) frame_flags; | 
| 3148     set_quantizer(cpi, 26); | 2982     vp8_set_quantizer(cpi, 26); | 
| 3149 | 2983 | 
| 3150     scale_and_extend_source(cpi->un_scaled_source, cpi); | 2984     scale_and_extend_source(cpi->un_scaled_source, cpi); | 
| 3151     vp8_first_pass(cpi); | 2985     vp8_first_pass(cpi); | 
| 3152 } | 2986 } | 
| 3153 #endif | 2987 #endif | 
| 3154 | 2988 | 
| 3155 #if 0 | 2989 #if 0 | 
| 3156 void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) | 2990 void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) | 
| 3157 { | 2991 { | 
| 3158 | 2992 | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3227             { | 3061             { | 
| 3228                 force_recode = TRUE; | 3062                 force_recode = TRUE; | 
| 3229                 cpi->active_best_quality = cpi->oxcf.cq_level; | 3063                 cpi->active_best_quality = cpi->oxcf.cq_level; | 
| 3230             } | 3064             } | 
| 3231         } | 3065         } | 
| 3232     } | 3066     } | 
| 3233 | 3067 | 
| 3234     return force_recode; | 3068     return force_recode; | 
| 3235 } | 3069 } | 
| 3236 | 3070 | 
|  | 3071 void update_reference_frames(VP8_COMMON *cm) | 
|  | 3072 { | 
|  | 3073     YV12_BUFFER_CONFIG *yv12_fb = cm->yv12_fb; | 
|  | 3074 | 
|  | 3075     // At this point the new frame has been encoded. | 
|  | 3076     // If any buffer copy / swapping is signaled it should be done here. | 
|  | 3077 | 
|  | 3078     if (cm->frame_type == KEY_FRAME) | 
|  | 3079     { | 
|  | 3080         yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG | VP8_ALT_FLAG ; | 
|  | 3081 | 
|  | 3082         yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG; | 
|  | 3083         yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG; | 
|  | 3084 | 
|  | 3085         cm->alt_fb_idx = cm->gld_fb_idx = cm->new_fb_idx; | 
|  | 3086     } | 
|  | 3087     else    /* For non key frames */ | 
|  | 3088     { | 
|  | 3089         if (cm->refresh_alt_ref_frame) | 
|  | 3090         { | 
|  | 3091             assert(!cm->copy_buffer_to_arf); | 
|  | 3092 | 
|  | 3093             cm->yv12_fb[cm->new_fb_idx].flags |= VP8_ALT_FLAG; | 
|  | 3094             cm->yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG; | 
|  | 3095             cm->alt_fb_idx = cm->new_fb_idx; | 
|  | 3096         } | 
|  | 3097         else if (cm->copy_buffer_to_arf) | 
|  | 3098         { | 
|  | 3099             assert(!(cm->copy_buffer_to_arf & ~0x3)); | 
|  | 3100 | 
|  | 3101             if (cm->copy_buffer_to_arf == 1) | 
|  | 3102             { | 
|  | 3103                 if(cm->alt_fb_idx != cm->lst_fb_idx) | 
|  | 3104                 { | 
|  | 3105                     yv12_fb[cm->lst_fb_idx].flags |= VP8_ALT_FLAG; | 
|  | 3106                     yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG; | 
|  | 3107                     cm->alt_fb_idx = cm->lst_fb_idx; | 
|  | 3108                 } | 
|  | 3109             } | 
|  | 3110             else /* if (cm->copy_buffer_to_arf == 2) */ | 
|  | 3111             { | 
|  | 3112                 if(cm->alt_fb_idx != cm->gld_fb_idx) | 
|  | 3113                 { | 
|  | 3114                     yv12_fb[cm->gld_fb_idx].flags |= VP8_ALT_FLAG; | 
|  | 3115                     yv12_fb[cm->alt_fb_idx].flags &= ~VP8_ALT_FLAG; | 
|  | 3116                     cm->alt_fb_idx = cm->gld_fb_idx; | 
|  | 3117                 } | 
|  | 3118             } | 
|  | 3119         } | 
|  | 3120 | 
|  | 3121         if (cm->refresh_golden_frame) | 
|  | 3122         { | 
|  | 3123             assert(!cm->copy_buffer_to_gf); | 
|  | 3124 | 
|  | 3125             cm->yv12_fb[cm->new_fb_idx].flags |= VP8_GOLD_FLAG; | 
|  | 3126             cm->yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG; | 
|  | 3127             cm->gld_fb_idx = cm->new_fb_idx; | 
|  | 3128         } | 
|  | 3129         else if (cm->copy_buffer_to_gf) | 
|  | 3130         { | 
|  | 3131             assert(!(cm->copy_buffer_to_arf & ~0x3)); | 
|  | 3132 | 
|  | 3133             if (cm->copy_buffer_to_gf == 1) | 
|  | 3134             { | 
|  | 3135                 if(cm->gld_fb_idx != cm->lst_fb_idx) | 
|  | 3136                 { | 
|  | 3137                     yv12_fb[cm->lst_fb_idx].flags |= VP8_GOLD_FLAG; | 
|  | 3138                     yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG; | 
|  | 3139                     cm->gld_fb_idx = cm->lst_fb_idx; | 
|  | 3140                 } | 
|  | 3141             } | 
|  | 3142             else /* if (cm->copy_buffer_to_gf == 2) */ | 
|  | 3143             { | 
|  | 3144                 if(cm->alt_fb_idx != cm->gld_fb_idx) | 
|  | 3145                 { | 
|  | 3146                     yv12_fb[cm->alt_fb_idx].flags |= VP8_GOLD_FLAG; | 
|  | 3147                     yv12_fb[cm->gld_fb_idx].flags &= ~VP8_GOLD_FLAG; | 
|  | 3148                     cm->gld_fb_idx = cm->alt_fb_idx; | 
|  | 3149                 } | 
|  | 3150             } | 
|  | 3151         } | 
|  | 3152     } | 
|  | 3153 | 
|  | 3154     if (cm->refresh_last_frame) | 
|  | 3155     { | 
|  | 3156         cm->yv12_fb[cm->new_fb_idx].flags |= VP8_LAST_FLAG; | 
|  | 3157         cm->yv12_fb[cm->lst_fb_idx].flags &= ~VP8_LAST_FLAG; | 
|  | 3158         cm->lst_fb_idx = cm->new_fb_idx; | 
|  | 3159     } | 
|  | 3160 } | 
|  | 3161 | 
| 3237 void loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm) | 3162 void loopfilter_frame(VP8_COMP *cpi, VP8_COMMON *cm) | 
| 3238 { | 3163 { | 
| 3239     if (cm->no_lpf) | 3164     if (cm->no_lpf) | 
| 3240     { | 3165     { | 
| 3241         cm->filter_level = 0; | 3166         cm->filter_level = 0; | 
| 3242     } | 3167     } | 
| 3243     else | 3168     else | 
| 3244     { | 3169     { | 
| 3245         struct vpx_usec_timer timer; | 3170         struct vpx_usec_timer timer; | 
| 3246 | 3171 | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 3258     } | 3183     } | 
| 3259 | 3184 | 
| 3260 #if CONFIG_MULTITHREAD | 3185 #if CONFIG_MULTITHREAD | 
| 3261     if (cpi->b_multi_threaded) | 3186     if (cpi->b_multi_threaded) | 
| 3262         sem_post(&cpi->h_event_end_lpf); /* signal that we have set filter_level
       */ | 3187         sem_post(&cpi->h_event_end_lpf); /* signal that we have set filter_level
       */ | 
| 3263 #endif | 3188 #endif | 
| 3264 | 3189 | 
| 3265     if (cm->filter_level > 0) | 3190     if (cm->filter_level > 0) | 
| 3266     { | 3191     { | 
| 3267         vp8cx_set_alt_lf_level(cpi, cm->filter_level); | 3192         vp8cx_set_alt_lf_level(cpi, cm->filter_level); | 
| 3268         vp8_loop_filter_frame(cm, &cpi->mb.e_mbd, cm->filter_level); | 3193         vp8_loop_filter_frame(cm, &cpi->mb.e_mbd); | 
| 3269         cm->last_filter_type = cm->filter_type; |  | 
| 3270         cm->last_sharpness_level = cm->sharpness_level; |  | 
| 3271     } | 3194     } | 
| 3272 | 3195 | 
| 3273     vp8_yv12_extend_frame_borders_ptr(cm->frame_to_show); | 3196     vp8_yv12_extend_frame_borders_ptr(cm->frame_to_show); | 
| 3274 | 3197 | 
| 3275     { |  | 
| 3276         YV12_BUFFER_CONFIG *lst_yv12 = &cm->yv12_fb[cm->lst_fb_idx]; |  | 
| 3277         YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx]; |  | 
| 3278         YV12_BUFFER_CONFIG *gld_yv12 = &cm->yv12_fb[cm->gld_fb_idx]; |  | 
| 3279         YV12_BUFFER_CONFIG *alt_yv12 = &cm->yv12_fb[cm->alt_fb_idx]; |  | 
| 3280         // At this point the new frame has been encoded. |  | 
| 3281         // If any buffer copy / swapping is signaled it should be done here. |  | 
| 3282         if (cm->frame_type == KEY_FRAME) |  | 
| 3283         { |  | 
| 3284             vp8_yv12_copy_frame_ptr(cm->frame_to_show, gld_yv12); |  | 
| 3285             vp8_yv12_copy_frame_ptr(cm->frame_to_show, alt_yv12); |  | 
| 3286         } |  | 
| 3287         else    // For non key frames |  | 
| 3288         { |  | 
| 3289             // Code to copy between reference buffers |  | 
| 3290             if (cm->copy_buffer_to_arf) |  | 
| 3291             { |  | 
| 3292                 if (cm->copy_buffer_to_arf == 1) |  | 
| 3293                 { |  | 
| 3294                     if (cm->refresh_last_frame) |  | 
| 3295                         // We copy new_frame here because last and new buffers w
      ill already have been swapped if cm->refresh_last_frame is set. |  | 
| 3296                         vp8_yv12_copy_frame_ptr(new_yv12, alt_yv12); |  | 
| 3297                     else |  | 
| 3298                         vp8_yv12_copy_frame_ptr(lst_yv12, alt_yv12); |  | 
| 3299                 } |  | 
| 3300                 else if (cm->copy_buffer_to_arf == 2) |  | 
| 3301                     vp8_yv12_copy_frame_ptr(gld_yv12, alt_yv12); |  | 
| 3302             } |  | 
| 3303 |  | 
| 3304             if (cm->copy_buffer_to_gf) |  | 
| 3305             { |  | 
| 3306                 if (cm->copy_buffer_to_gf == 1) |  | 
| 3307                 { |  | 
| 3308                     if (cm->refresh_last_frame) |  | 
| 3309                         // We copy new_frame here because last and new buffers w
      ill already have been swapped if cm->refresh_last_frame is set. |  | 
| 3310                         vp8_yv12_copy_frame_ptr(new_yv12, gld_yv12); |  | 
| 3311                     else |  | 
| 3312                         vp8_yv12_copy_frame_ptr(lst_yv12, gld_yv12); |  | 
| 3313                 } |  | 
| 3314                 else if (cm->copy_buffer_to_gf == 2) |  | 
| 3315                     vp8_yv12_copy_frame_ptr(alt_yv12, gld_yv12); |  | 
| 3316             } |  | 
| 3317         } |  | 
| 3318     } |  | 
| 3319 } | 3198 } | 
| 3320 | 3199 | 
| 3321 static void encode_frame_to_data_rate | 3200 static void encode_frame_to_data_rate | 
| 3322 ( | 3201 ( | 
| 3323     VP8_COMP *cpi, | 3202     VP8_COMP *cpi, | 
| 3324     unsigned long *size, | 3203     unsigned long *size, | 
| 3325     unsigned char *dest, | 3204     unsigned char *dest, | 
| 3326     unsigned int *frame_flags | 3205     unsigned int *frame_flags | 
| 3327 ) | 3206 ) | 
| 3328 { | 3207 { | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3369     cpi->force_next_frame_intra = 0; | 3248     cpi->force_next_frame_intra = 0; | 
| 3370 #endif | 3249 #endif | 
| 3371 | 3250 | 
| 3372     // For an alt ref frame in 2 pass we skip the call to the second pass functi
      on that sets the target bandwidth | 3251     // For an alt ref frame in 2 pass we skip the call to the second pass functi
      on that sets the target bandwidth | 
| 3373 #if !(CONFIG_REALTIME_ONLY) | 3252 #if !(CONFIG_REALTIME_ONLY) | 
| 3374 | 3253 | 
| 3375     if (cpi->pass == 2) | 3254     if (cpi->pass == 2) | 
| 3376     { | 3255     { | 
| 3377         if (cpi->common.refresh_alt_ref_frame) | 3256         if (cpi->common.refresh_alt_ref_frame) | 
| 3378         { | 3257         { | 
| 3379             cpi->per_frame_bandwidth = cpi->gf_bits;                           /
      / Per frame bit target for the alt ref frame | 3258             cpi->per_frame_bandwidth = cpi->twopass.gf_bits;                    
             // Per frame bit target for the alt ref frame | 
| 3380             cpi->target_bandwidth = cpi->gf_bits * cpi->output_frame_rate;      
      // per second target bitrate | 3259             cpi->target_bandwidth = cpi->twopass.gf_bits * cpi->output_frame_rat
      e;      // per second target bitrate | 
| 3381         } | 3260         } | 
| 3382     } | 3261     } | 
| 3383     else | 3262     else | 
| 3384 #endif | 3263 #endif | 
| 3385         cpi->per_frame_bandwidth  = (int)(cpi->target_bandwidth / cpi->output_fr
      ame_rate); | 3264         cpi->per_frame_bandwidth  = (int)(cpi->target_bandwidth / cpi->output_fr
      ame_rate); | 
| 3386 | 3265 | 
| 3387     // Default turn off buffer to buffer copying | 3266     // Default turn off buffer to buffer copying | 
| 3388     cm->copy_buffer_to_gf = 0; | 3267     cm->copy_buffer_to_gf = 0; | 
| 3389     cm->copy_buffer_to_arf = 0; | 3268     cm->copy_buffer_to_arf = 0; | 
| 3390 | 3269 | 
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3531         { | 3410         { | 
| 3532             cpi->decimation_count = cpi->decimation_factor; | 3411             cpi->decimation_count = cpi->decimation_factor; | 
| 3533         } | 3412         } | 
| 3534         else if (cpi->decimation_count > 0) | 3413         else if (cpi->decimation_count > 0) | 
| 3535         { | 3414         { | 
| 3536             cpi->decimation_count --; | 3415             cpi->decimation_count --; | 
| 3537             cpi->bits_off_target += cpi->av_per_frame_bandwidth; | 3416             cpi->bits_off_target += cpi->av_per_frame_bandwidth; | 
| 3538             cm->current_video_frame++; | 3417             cm->current_video_frame++; | 
| 3539             cpi->frames_since_key++; | 3418             cpi->frames_since_key++; | 
| 3540 | 3419 | 
| 3541 #if CONFIG_PSNR | 3420 #if CONFIG_INTERNAL_STATS | 
| 3542             cpi->count ++; | 3421             cpi->count ++; | 
| 3543 #endif | 3422 #endif | 
| 3544 | 3423 | 
| 3545             cpi->buffer_level = cpi->bits_off_target; | 3424             cpi->buffer_level = cpi->bits_off_target; | 
| 3546 | 3425 | 
| 3547             return; | 3426             return; | 
| 3548         } | 3427         } | 
| 3549         else | 3428         else | 
| 3550             cpi->decimation_count = cpi->decimation_factor; | 3429             cpi->decimation_count = cpi->decimation_factor; | 
| 3551     } | 3430     } | 
| 3552 | 3431 | 
| 3553     // Decide how big to make the frame | 3432     // Decide how big to make the frame | 
| 3554     if (!pick_frame_size(cpi)) | 3433     if (!vp8_pick_frame_size(cpi)) | 
| 3555     { | 3434     { | 
| 3556         cm->current_video_frame++; | 3435         cm->current_video_frame++; | 
| 3557         cpi->frames_since_key++; | 3436         cpi->frames_since_key++; | 
| 3558         return; | 3437         return; | 
| 3559     } | 3438     } | 
| 3560 | 3439 | 
| 3561     // Reduce active_worst_allowed_q for CBR if our buffer is getting too full. | 3440     // Reduce active_worst_allowed_q for CBR if our buffer is getting too full. | 
| 3562     // This has a knock on effect on active best quality as well. | 3441     // This has a knock on effect on active best quality as well. | 
| 3563     // For CBR if the buffer reaches its maximum level then we can no longer | 3442     // For CBR if the buffer reaches its maximum level then we can no longer | 
| 3564     // save up bits for later frames so we might as well use them up | 3443     // save up bits for later frames so we might as well use them up | 
| 3565     // on the current frame. | 3444     // on the current frame. | 
| 3566     if ((cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) && | 3445     if ((cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) && | 
| 3567         (cpi->buffer_level >= cpi->oxcf.optimal_buffer_level) && cpi->buffered_m
      ode) | 3446         (cpi->buffer_level >= cpi->oxcf.optimal_buffer_level) && cpi->buffered_m
      ode) | 
| 3568     { | 3447     { | 
| 3569         int Adjustment = cpi->active_worst_quality / 4;       // Max adjustment 
      is 1/4 | 3448         int Adjustment = cpi->active_worst_quality / 4;       // Max adjustment 
      is 1/4 | 
| 3570 | 3449 | 
| 3571         if (Adjustment) | 3450         if (Adjustment) | 
| 3572         { | 3451         { | 
| 3573             int buff_lvl_step; | 3452             int buff_lvl_step; | 
| 3574             int tmp_lvl = cpi->buffer_level; |  | 
| 3575 | 3453 | 
| 3576             if (cpi->buffer_level < cpi->oxcf.maximum_buffer_size) | 3454             if (cpi->buffer_level < cpi->oxcf.maximum_buffer_size) | 
| 3577             { | 3455             { | 
| 3578                 buff_lvl_step = (cpi->oxcf.maximum_buffer_size - cpi->oxcf.optim
      al_buffer_level) / Adjustment; | 3456                 buff_lvl_step = (cpi->oxcf.maximum_buffer_size - cpi->oxcf.optim
      al_buffer_level) / Adjustment; | 
| 3579 | 3457 | 
| 3580                 if (buff_lvl_step) | 3458                 if (buff_lvl_step) | 
| 3581                 { |  | 
| 3582                     Adjustment = (cpi->buffer_level - cpi->oxcf.optimal_buffer_l
      evel) / buff_lvl_step; | 3459                     Adjustment = (cpi->buffer_level - cpi->oxcf.optimal_buffer_l
      evel) / buff_lvl_step; | 
| 3583                     cpi->active_worst_quality -= Adjustment; | 3460                 else | 
| 3584                 } | 3461                     Adjustment = 0; | 
| 3585             } | 3462             } | 
| 3586             else | 3463 | 
| 3587             { | 3464             cpi->active_worst_quality -= Adjustment; | 
| 3588                 cpi->active_worst_quality -= Adjustment; | 3465 | 
| 3589             } | 3466             if(cpi->active_worst_quality < cpi->active_best_quality) | 
|  | 3467                 cpi->active_worst_quality = cpi->active_best_quality; | 
| 3590         } | 3468         } | 
| 3591     } | 3469     } | 
| 3592 | 3470 | 
| 3593     // Set an active best quality and if necessary active worst quality | 3471     // Set an active best quality and if necessary active worst quality | 
| 3594     // There is some odd behaviour for one pass here that needs attention. | 3472     // There is some odd behaviour for one pass here that needs attention. | 
| 3595     if ( (cpi->pass == 2) || (cpi->ni_frames > 150)) | 3473     if ( (cpi->pass == 2) || (cpi->ni_frames > 150)) | 
| 3596     { | 3474     { | 
| 3597         vp8_clear_system_state(); | 3475         vp8_clear_system_state(); | 
| 3598 | 3476 | 
| 3599         Q = cpi->active_worst_quality; | 3477         Q = cpi->active_worst_quality; | 
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3799 | 3677 | 
| 3800     do | 3678     do | 
| 3801     { | 3679     { | 
| 3802         vp8_clear_system_state();  //__asm emms; | 3680         vp8_clear_system_state();  //__asm emms; | 
| 3803 | 3681 | 
| 3804         /* | 3682         /* | 
| 3805         if(cpi->is_src_frame_alt_ref) | 3683         if(cpi->is_src_frame_alt_ref) | 
| 3806             Q = 127; | 3684             Q = 127; | 
| 3807             */ | 3685             */ | 
| 3808 | 3686 | 
| 3809         set_quantizer(cpi, Q); | 3687         vp8_set_quantizer(cpi, Q); | 
| 3810         this_q = Q; | 3688         this_q = Q; | 
| 3811 | 3689 | 
| 3812         // setup skip prob for costing in mode/mv decision | 3690         // setup skip prob for costing in mode/mv decision | 
| 3813         if (cpi->common.mb_no_coeff_skip) | 3691         if (cpi->common.mb_no_coeff_skip) | 
| 3814         { | 3692         { | 
| 3815             cpi->prob_skip_false = cpi->base_skip_false_prob[Q]; | 3693             cpi->prob_skip_false = cpi->base_skip_false_prob[Q]; | 
| 3816 | 3694 | 
| 3817             if (cm->frame_type != KEY_FRAME) | 3695             if (cm->frame_type != KEY_FRAME) | 
| 3818             { | 3696             { | 
| 3819                 if (cpi->common.refresh_alt_ref_frame) | 3697                 if (cpi->common.refresh_alt_ref_frame) | 
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3873                 FILE *f = fopen("skip.stt", "a"); | 3751                 FILE *f = fopen("skip.stt", "a"); | 
| 3874                 fprintf(f, "%d, %d, %4d ", cpi->common.refresh_golden_frame, cpi
      ->common.refresh_alt_ref_frame, cpi->prob_skip_false); | 3752                 fprintf(f, "%d, %d, %4d ", cpi->common.refresh_golden_frame, cpi
      ->common.refresh_alt_ref_frame, cpi->prob_skip_false); | 
| 3875                 fclose(f); | 3753                 fclose(f); | 
| 3876             } | 3754             } | 
| 3877 | 3755 | 
| 3878 #endif | 3756 #endif | 
| 3879 | 3757 | 
| 3880         } | 3758         } | 
| 3881 | 3759 | 
| 3882         if (cm->frame_type == KEY_FRAME) | 3760         if (cm->frame_type == KEY_FRAME) | 
|  | 3761         { | 
|  | 3762             resize_key_frame(cpi); | 
| 3883             vp8_setup_key_frame(cpi); | 3763             vp8_setup_key_frame(cpi); | 
|  | 3764         } | 
| 3884 | 3765 | 
| 3885         // transform / motion compensation build reconstruction frame | 3766         // transform / motion compensation build reconstruction frame | 
| 3886         vp8_encode_frame(cpi); | 3767         vp8_encode_frame(cpi); | 
| 3887 | 3768 | 
| 3888         cpi->projected_frame_size -= vp8_estimate_entropy_savings(cpi); | 3769         cpi->projected_frame_size -= vp8_estimate_entropy_savings(cpi); | 
| 3889         cpi->projected_frame_size = (cpi->projected_frame_size > 0) ? cpi->proje
      cted_frame_size : 0; | 3770         cpi->projected_frame_size = (cpi->projected_frame_size > 0) ? cpi->proje
      cted_frame_size : 0; | 
| 3890 | 3771 | 
| 3891         vp8_clear_system_state();  //__asm emms; | 3772         vp8_clear_system_state();  //__asm emms; | 
| 3892 | 3773 | 
| 3893         // Test to see if the stats generated for this frame indicate that we sh
      ould have coded a key frame | 3774         // Test to see if the stats generated for this frame indicate that we sh
      ould have coded a key frame | 
| 3894         // (assuming that we didn't)! | 3775         // (assuming that we didn't)! | 
| 3895         if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME) | 3776         if (cpi->pass != 2 && cpi->oxcf.auto_key && cm->frame_type != KEY_FRAME) | 
| 3896         { | 3777         { | 
| 3897 | 3778 | 
| 3898 #if CONFIG_REALTIME_ONLY | 3779 #if CONFIG_REALTIME_ONLY | 
| 3899             { | 3780             { | 
| 3900                 /* we don't do re-encoding in realtime mode | 3781                 /* we don't do re-encoding in realtime mode | 
| 3901                  * if key frame is decided than we force it on next frame */ | 3782                  * if key frame is decided than we force it on next frame */ | 
| 3902                 cpi->force_next_frame_intra = decide_key_frame(cpi); | 3783                 cpi->force_next_frame_intra = decide_key_frame(cpi); | 
| 3903             } | 3784             } | 
| 3904 #else | 3785 #else | 
| 3905             if (decide_key_frame(cpi)) | 3786             if (decide_key_frame(cpi)) | 
| 3906             { | 3787             { | 
| 3907                 vp8_calc_auto_iframe_target_size(cpi); |  | 
| 3908 |  | 
| 3909                 // Reset all our sizing numbers and recode | 3788                 // Reset all our sizing numbers and recode | 
| 3910                 cm->frame_type = KEY_FRAME; | 3789                 cm->frame_type = KEY_FRAME; | 
| 3911 | 3790 | 
|  | 3791                 vp8_pick_frame_size(cpi); | 
|  | 3792 | 
| 3912                 // Clear the Alt reference frame active flag when we have a key 
      frame | 3793                 // Clear the Alt reference frame active flag when we have a key 
      frame | 
| 3913                 cpi->source_alt_ref_active = FALSE; | 3794                 cpi->source_alt_ref_active = FALSE; | 
| 3914 | 3795 | 
| 3915                 // Reset the loop filter deltas and segmentation map | 3796                 // Reset the loop filter deltas and segmentation map | 
| 3916                 setup_features(cpi); | 3797                 setup_features(cpi); | 
| 3917 | 3798 | 
| 3918                 // If segmentation is enabled force a map update for key frames | 3799                 // If segmentation is enabled force a map update for key frames | 
| 3919                 if (cpi->mb.e_mbd.segmentation_enabled) | 3800                 if (cpi->mb.e_mbd.segmentation_enabled) | 
| 3920                 { | 3801                 { | 
| 3921                     cpi->mb.e_mbd.update_mb_segmentation_map = 1; | 3802                     cpi->mb.e_mbd.update_mb_segmentation_map = 1; | 
| 3922                     cpi->mb.e_mbd.update_mb_segmentation_data = 1; | 3803                     cpi->mb.e_mbd.update_mb_segmentation_data = 1; | 
| 3923                 } | 3804                 } | 
| 3924 | 3805 | 
| 3925                 vp8_restore_coding_context(cpi); | 3806                 vp8_restore_coding_context(cpi); | 
| 3926 | 3807 | 
| 3927                 Q = vp8_regulate_q(cpi, cpi->this_frame_target); | 3808                 Q = vp8_regulate_q(cpi, cpi->this_frame_target); | 
| 3928 | 3809 | 
| 3929                 vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &fr
      ame_over_shoot_limit); | 3810                 vp8_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, &fr
      ame_over_shoot_limit); | 
| 3930 | 3811 | 
| 3931                 // Limit Q range for the adaptive loop. | 3812                 // Limit Q range for the adaptive loop. | 
| 3932                 bottom_index = cpi->active_best_quality; | 3813                 bottom_index = cpi->active_best_quality; | 
| 3933                 top_index    = cpi->active_worst_quality; | 3814                 top_index    = cpi->active_worst_quality; | 
| 3934                 q_low  = cpi->active_best_quality; | 3815                 q_low  = cpi->active_best_quality; | 
| 3935                 q_high = cpi->active_worst_quality; | 3816                 q_high = cpi->active_worst_quality; | 
| 3936 | 3817 | 
| 3937                 loop_count++; | 3818                 loop_count++; | 
| 3938                 Loop = TRUE; | 3819                 Loop = TRUE; | 
| 3939 | 3820 | 
| 3940                 resize_key_frame(cpi); |  | 
| 3941                 continue; | 3821                 continue; | 
| 3942             } | 3822             } | 
| 3943 #endif | 3823 #endif | 
| 3944         } | 3824         } | 
| 3945 | 3825 | 
| 3946         vp8_clear_system_state(); | 3826         vp8_clear_system_state(); | 
| 3947 | 3827 | 
| 3948         if (frame_over_shoot_limit == 0) | 3828         if (frame_over_shoot_limit == 0) | 
| 3949             frame_over_shoot_limit = 1; | 3829             frame_over_shoot_limit = 1; | 
| 3950 | 3830 | 
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4131 #endif | 4011 #endif | 
| 4132             Loop = FALSE; | 4012             Loop = FALSE; | 
| 4133 | 4013 | 
| 4134         if (cpi->is_src_frame_alt_ref) | 4014         if (cpi->is_src_frame_alt_ref) | 
| 4135             Loop = FALSE; | 4015             Loop = FALSE; | 
| 4136 | 4016 | 
| 4137         if (Loop == TRUE) | 4017         if (Loop == TRUE) | 
| 4138         { | 4018         { | 
| 4139             vp8_restore_coding_context(cpi); | 4019             vp8_restore_coding_context(cpi); | 
| 4140             loop_count++; | 4020             loop_count++; | 
| 4141 #if CONFIG_PSNR | 4021 #if CONFIG_INTERNAL_STATS | 
| 4142             cpi->tot_recode_hits++; | 4022             cpi->tot_recode_hits++; | 
| 4143 #endif | 4023 #endif | 
| 4144         } | 4024         } | 
| 4145     } | 4025     } | 
| 4146     while (Loop == TRUE); | 4026     while (Loop == TRUE); | 
| 4147 | 4027 | 
| 4148 #if 0 | 4028 #if 0 | 
| 4149     // Experimental code for lagged and one pass | 4029     // Experimental code for lagged and one pass | 
| 4150     // Update stats used for one pass GF selection | 4030     // Update stats used for one pass GF selection | 
| 4151     { | 4031     { | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 4163 | 4043 | 
| 4164         cpi->one_pass_frame_stats[cpi->one_pass_frame_index].frame_coded_error =
       (double)cpi->prediction_error; | 4044         cpi->one_pass_frame_stats[cpi->one_pass_frame_index].frame_coded_error =
       (double)cpi->prediction_error; | 
| 4165         cpi->one_pass_frame_stats[cpi->one_pass_frame_index].frame_intra_error =
       (double)cpi->intra_error; | 4045         cpi->one_pass_frame_stats[cpi->one_pass_frame_index].frame_intra_error =
       (double)cpi->intra_error; | 
| 4166         cpi->one_pass_frame_stats[cpi->one_pass_frame_index].frame_pcnt_inter = 
      (double)(100 - cpi->this_frame_percent_intra) / 100.0; | 4046         cpi->one_pass_frame_stats[cpi->one_pass_frame_index].frame_pcnt_inter = 
      (double)(100 - cpi->this_frame_percent_intra) / 100.0; | 
| 4167     } | 4047     } | 
| 4168 #endif | 4048 #endif | 
| 4169 | 4049 | 
| 4170     // Special case code to reduce pulsing when key frames are forced at a | 4050     // Special case code to reduce pulsing when key frames are forced at a | 
| 4171     // fixed interval. Note the reconstruction error if it is the frame before | 4051     // fixed interval. Note the reconstruction error if it is the frame before | 
| 4172     // the force key frame | 4052     // the force key frame | 
| 4173     if ( cpi->next_key_frame_forced && (cpi->frames_to_key == 0) ) | 4053     if ( cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0) ) | 
| 4174     { | 4054     { | 
| 4175         cpi->ambient_err = vp8_calc_ss_err(cpi->Source, | 4055         cpi->ambient_err = vp8_calc_ss_err(cpi->Source, | 
| 4176                                            &cm->yv12_fb[cm->new_fb_idx], | 4056                                            &cm->yv12_fb[cm->new_fb_idx], | 
| 4177                                            IF_RTCD(&cpi->rtcd.variance)); | 4057                                            IF_RTCD(&cpi->rtcd.variance)); | 
| 4178     } | 4058     } | 
| 4179 | 4059 | 
| 4180     // This frame's MVs are saved and will be used in next frame's MV prediction
      . | 4060     // This frame's MVs are saved and will be used in next frame's MV prediction
      . | 
| 4181     // Last frame has one more line(add to bottom) and one more column(add to ri
      ght) than cm->mip. The edge elements are initialized to 0. | 4061     // Last frame has one more line(add to bottom) and one more column(add to ri
      ght) than cm->mip. The edge elements are initialized to 0. | 
| 4182     if(cm->show_frame)   //do not save for altref frame | 4062     if(cm->show_frame)   //do not save for altref frame | 
| 4183     { | 4063     { | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 4211         cm->refresh_last_frame = 1; | 4091         cm->refresh_last_frame = 1; | 
| 4212 | 4092 | 
| 4213 #if 0 | 4093 #if 0 | 
| 4214     { | 4094     { | 
| 4215         FILE *f = fopen("gfactive.stt", "a"); | 4095         FILE *f = fopen("gfactive.stt", "a"); | 
| 4216         fprintf(f, "%8d %8d %8d %8d %8d\n", cm->current_video_frame, (100 * cpi-
      >gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols), cpi->this_iirat
      io, cpi->next_iiratio, cm->refresh_golden_frame); | 4096         fprintf(f, "%8d %8d %8d %8d %8d\n", cm->current_video_frame, (100 * cpi-
      >gf_active_count) / (cpi->common.mb_rows * cpi->common.mb_cols), cpi->this_iirat
      io, cpi->next_iiratio, cm->refresh_golden_frame); | 
| 4217         fclose(f); | 4097         fclose(f); | 
| 4218     } | 4098     } | 
| 4219 #endif | 4099 #endif | 
| 4220 | 4100 | 
| 4221     // For inter frames the current default behaviour is that when cm->refresh_g
      olden_frame is set we copy the old GF over to the ARF buffer | 4101     // For inter frames the current default behavior is that when | 
| 4222     // This is purely an encoder descision at present. | 4102     // cm->refresh_golden_frame is set we copy the old GF over to the ARF buffer | 
|  | 4103     // This is purely an encoder decision at present. | 
| 4223     if (!cpi->oxcf.error_resilient_mode && cm->refresh_golden_frame) | 4104     if (!cpi->oxcf.error_resilient_mode && cm->refresh_golden_frame) | 
| 4224         cm->copy_buffer_to_arf  = 2; | 4105         cm->copy_buffer_to_arf  = 2; | 
| 4225     else | 4106     else | 
| 4226         cm->copy_buffer_to_arf  = 0; | 4107         cm->copy_buffer_to_arf  = 0; | 
| 4227 | 4108 | 
| 4228     if (cm->refresh_last_frame) | 4109     cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; | 
| 4229     { |  | 
| 4230         vp8_swap_yv12_buffer(&cm->yv12_fb[cm->lst_fb_idx], &cm->yv12_fb[cm->new_
      fb_idx]); |  | 
| 4231         cm->frame_to_show = &cm->yv12_fb[cm->lst_fb_idx]; |  | 
| 4232     } |  | 
| 4233     else |  | 
| 4234         cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; |  | 
| 4235 |  | 
| 4236 | 4110 | 
| 4237 #if CONFIG_MULTITHREAD | 4111 #if CONFIG_MULTITHREAD | 
| 4238     if (cpi->b_multi_threaded) | 4112     if (cpi->b_multi_threaded) | 
| 4239     { | 4113     { | 
| 4240         sem_post(&cpi->h_event_start_lpf); /* start loopfilter in separate threa
      d */ | 4114         sem_post(&cpi->h_event_start_lpf); /* start loopfilter in separate threa
      d */ | 
| 4241     } | 4115     } | 
| 4242     else | 4116     else | 
| 4243 #endif | 4117 #endif | 
| 4244     { | 4118     { | 
| 4245         loopfilter_frame(cpi, cm); | 4119         loopfilter_frame(cpi, cm); | 
| 4246     } | 4120     } | 
| 4247 | 4121 | 
| 4248     if (cpi->oxcf.error_resilient_mode == 1) | 4122     update_reference_frames(cm); | 
|  | 4123 | 
|  | 4124     if (cpi->oxcf.error_resilient_mode) | 
| 4249     { | 4125     { | 
| 4250         cm->refresh_entropy_probs = 0; | 4126         cm->refresh_entropy_probs = 0; | 
| 4251     } | 4127     } | 
| 4252 | 4128 | 
| 4253 #if CONFIG_MULTITHREAD | 4129 #if CONFIG_MULTITHREAD | 
| 4254     /* wait that filter_level is picked so that we can continue with stream pack
      ing */ | 4130     /* wait that filter_level is picked so that we can continue with stream pack
      ing */ | 
| 4255     if (cpi->b_multi_threaded) | 4131     if (cpi->b_multi_threaded) | 
| 4256         sem_wait(&cpi->h_event_end_lpf); | 4132         sem_wait(&cpi->h_event_end_lpf); | 
| 4257 #endif | 4133 #endif | 
| 4258 | 4134 | 
| 4259     // build the bitstream | 4135     // build the bitstream | 
| 4260     vp8_pack_bitstream(cpi, dest, size); | 4136     vp8_pack_bitstream(cpi, dest, size); | 
| 4261 | 4137 | 
| 4262 #if CONFIG_MULTITHREAD | 4138 #if CONFIG_MULTITHREAD | 
| 4263     /* wait for loopfilter thread done */ | 4139     /* wait for loopfilter thread done */ | 
| 4264     if (cpi->b_multi_threaded) | 4140     if (cpi->b_multi_threaded) | 
| 4265     { | 4141     { | 
| 4266         sem_wait(&cpi->h_event_end_lpf); | 4142         sem_wait(&cpi->h_event_end_lpf); | 
| 4267     } | 4143     } | 
| 4268 #endif | 4144 #endif | 
| 4269 | 4145 | 
| 4270     /* Move storing frame_type out of the above loop since it is also | 4146     /* Move storing frame_type out of the above loop since it is also | 
| 4271      * needed in motion search besides loopfilter */ | 4147      * needed in motion search besides loopfilter */ | 
| 4272       cm->last_frame_type = cm->frame_type; | 4148     cm->last_frame_type = cm->frame_type; | 
| 4273 | 4149 | 
| 4274     // Update rate control heuristics | 4150     // Update rate control heuristics | 
| 4275     cpi->total_byte_count += (*size); | 4151     cpi->total_byte_count += (*size); | 
| 4276     cpi->projected_frame_size = (*size) << 3; | 4152     cpi->projected_frame_size = (*size) << 3; | 
| 4277 | 4153 | 
| 4278     if (!active_worst_qchanged) | 4154     if (!active_worst_qchanged) | 
| 4279         vp8_update_rate_correction_factors(cpi, 2); | 4155         vp8_update_rate_correction_factors(cpi, 2); | 
| 4280 | 4156 | 
| 4281     cpi->last_q[cm->frame_type] = cm->base_qindex; | 4157     cpi->last_q[cm->frame_type] = cm->base_qindex; | 
| 4282 | 4158 | 
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4369     cpi->total_actual_bits    += cpi->projected_frame_size; | 4245     cpi->total_actual_bits    += cpi->projected_frame_size; | 
| 4370 | 4246 | 
| 4371     // Debug stats | 4247     // Debug stats | 
| 4372     cpi->total_target_vs_actual += (cpi->this_frame_target - cpi->projected_fram
      e_size); | 4248     cpi->total_target_vs_actual += (cpi->this_frame_target - cpi->projected_fram
      e_size); | 
| 4373 | 4249 | 
| 4374     cpi->buffer_level = cpi->bits_off_target; | 4250     cpi->buffer_level = cpi->bits_off_target; | 
| 4375 | 4251 | 
| 4376     // Update bits left to the kf and gf groups to account for overshoot or unde
      rshoot on these frames | 4252     // Update bits left to the kf and gf groups to account for overshoot or unde
      rshoot on these frames | 
| 4377     if (cm->frame_type == KEY_FRAME) | 4253     if (cm->frame_type == KEY_FRAME) | 
| 4378     { | 4254     { | 
| 4379         cpi->kf_group_bits += cpi->this_frame_target - cpi->projected_frame_size
      ; | 4255         cpi->twopass.kf_group_bits += cpi->this_frame_target - cpi->projected_fr
      ame_size; | 
| 4380 | 4256 | 
| 4381         if (cpi->kf_group_bits < 0) | 4257         if (cpi->twopass.kf_group_bits < 0) | 
| 4382             cpi->kf_group_bits = 0 ; | 4258             cpi->twopass.kf_group_bits = 0 ; | 
| 4383     } | 4259     } | 
| 4384     else if (cm->refresh_golden_frame || cm->refresh_alt_ref_frame) | 4260     else if (cm->refresh_golden_frame || cm->refresh_alt_ref_frame) | 
| 4385     { | 4261     { | 
| 4386         cpi->gf_group_bits += cpi->this_frame_target - cpi->projected_frame_size
      ; | 4262         cpi->twopass.gf_group_bits += cpi->this_frame_target - cpi->projected_fr
      ame_size; | 
| 4387 | 4263 | 
| 4388         if (cpi->gf_group_bits < 0) | 4264         if (cpi->twopass.gf_group_bits < 0) | 
| 4389             cpi->gf_group_bits = 0 ; | 4265             cpi->twopass.gf_group_bits = 0 ; | 
| 4390     } | 4266     } | 
| 4391 | 4267 | 
| 4392     if (cm->frame_type != KEY_FRAME) | 4268     if (cm->frame_type != KEY_FRAME) | 
| 4393     { | 4269     { | 
| 4394         if (cpi->common.refresh_alt_ref_frame) | 4270         if (cpi->common.refresh_alt_ref_frame) | 
| 4395         { | 4271         { | 
| 4396             cpi->last_skip_false_probs[2] = cpi->prob_skip_false; | 4272             cpi->last_skip_false_probs[2] = cpi->prob_skip_false; | 
| 4397             cpi->last_skip_probs_q[2] = cm->base_qindex; | 4273             cpi->last_skip_probs_q[2] = cm->base_qindex; | 
| 4398         } | 4274         } | 
| 4399         else if (cpi->common.refresh_golden_frame) | 4275         else if (cpi->common.refresh_golden_frame) | 
| 4400         { | 4276         { | 
| 4401             cpi->last_skip_false_probs[1] = cpi->prob_skip_false; | 4277             cpi->last_skip_false_probs[1] = cpi->prob_skip_false; | 
| 4402             cpi->last_skip_probs_q[1] = cm->base_qindex; | 4278             cpi->last_skip_probs_q[1] = cm->base_qindex; | 
| 4403         } | 4279         } | 
| 4404         else | 4280         else | 
| 4405         { | 4281         { | 
| 4406             cpi->last_skip_false_probs[0] = cpi->prob_skip_false; | 4282             cpi->last_skip_false_probs[0] = cpi->prob_skip_false; | 
| 4407             cpi->last_skip_probs_q[0] = cm->base_qindex; | 4283             cpi->last_skip_probs_q[0] = cm->base_qindex; | 
| 4408 | 4284 | 
| 4409             //update the baseline | 4285             //update the baseline | 
| 4410             cpi->base_skip_false_prob[cm->base_qindex] = cpi->prob_skip_false; | 4286             cpi->base_skip_false_prob[cm->base_qindex] = cpi->prob_skip_false; | 
| 4411 | 4287 | 
| 4412         } | 4288         } | 
| 4413     } | 4289     } | 
| 4414 | 4290 | 
| 4415 #if 0 && CONFIG_PSNR | 4291 #if 0 && CONFIG_INTERNAL_STATS | 
| 4416     { | 4292     { | 
| 4417         FILE *f = fopen("tmp.stt", "a"); | 4293         FILE *f = fopen("tmp.stt", "a"); | 
| 4418 | 4294 | 
| 4419         vp8_clear_system_state();  //__asm emms; | 4295         vp8_clear_system_state();  //__asm emms; | 
| 4420 | 4296 | 
| 4421         if (cpi->total_coded_error_left != 0.0) | 4297         if (cpi->twopass.total_coded_error_left != 0.0) | 
| 4422             fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6ld %6ld" | 4298             fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d" | 
| 4423                        "%6ld %6ld %6ld %5ld %5ld %5ld %8ld %8.2f %10d %10.3f" | 4299                        "%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f" | 
| 4424                        "%10.3f %8ld\n", | 4300                        "%10.3f %8d\n", | 
| 4425                        cpi->common.current_video_frame, cpi->this_frame_target, | 4301                        cpi->common.current_video_frame, cpi->this_frame_target, | 
| 4426                        cpi->projected_frame_size, | 4302                        cpi->projected_frame_size, | 
| 4427                        (cpi->projected_frame_size - cpi->this_frame_target), | 4303                        (cpi->projected_frame_size - cpi->this_frame_target), | 
| 4428                        (int)cpi->total_target_vs_actual, | 4304                        (int)cpi->total_target_vs_actual, | 
| 4429                        (cpi->oxcf.starting_buffer_level-cpi->bits_off_target), | 4305                        (cpi->oxcf.starting_buffer_level-cpi->bits_off_target), | 
| 4430                        (int)cpi->total_actual_bits, cm->base_qindex, | 4306                        (int)cpi->total_actual_bits, cm->base_qindex, | 
| 4431                        cpi->active_best_quality, cpi->active_worst_quality, | 4307                        cpi->active_best_quality, cpi->active_worst_quality, | 
| 4432                        cpi->ni_av_qi, cpi->cq_target_quality, cpi->zbin_over_qua
      nt, | 4308                        cpi->ni_av_qi, cpi->cq_target_quality, cpi->zbin_over_qua
      nt, | 
| 4433                        //cpi->avg_frame_qindex, cpi->zbin_over_quant, | 4309                        //cpi->avg_frame_qindex, cpi->zbin_over_quant, | 
| 4434                        cm->refresh_golden_frame, cm->refresh_alt_ref_frame, | 4310                        cm->refresh_golden_frame, cm->refresh_alt_ref_frame, | 
| 4435                        cm->frame_type, cpi->gfu_boost, | 4311                        cm->frame_type, cpi->gfu_boost, | 
| 4436                        cpi->est_max_qcorrection_factor, (int)cpi->bits_left, | 4312                        cpi->twopass.est_max_qcorrection_factor, (int)cpi->twopas
      s.bits_left, | 
| 4437                        cpi->total_coded_error_left, | 4313                        cpi->twopass.total_coded_error_left, | 
| 4438                        (double)cpi->bits_left / cpi->total_coded_error_left, | 4314                        (double)cpi->twopass.bits_left / cpi->twopass.total_coded
      _error_left, | 
| 4439                        cpi->tot_recode_hits); | 4315                        cpi->tot_recode_hits); | 
| 4440         else | 4316         else | 
| 4441             fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6ld %6ld" | 4317             fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %6d %6d" | 
| 4442                        "%6ld %6ld %6ld %5ld %5ld %5ld %8ld %8.2f %10d %10.3f" | 4318                        "%6d %6d %6d %5d %5d %5d %8d %8.2f %10d %10.3f" | 
| 4443                        "%8ld\n", | 4319                        "%8d\n", | 
| 4444                        cpi->common.current_video_frame, | 4320                        cpi->common.current_video_frame, | 
| 4445                        cpi->this_frame_target, cpi->projected_frame_size, | 4321                        cpi->this_frame_target, cpi->projected_frame_size, | 
| 4446                        (cpi->projected_frame_size - cpi->this_frame_target), | 4322                        (cpi->projected_frame_size - cpi->this_frame_target), | 
| 4447                        (int)cpi->total_target_vs_actual, | 4323                        (int)cpi->total_target_vs_actual, | 
| 4448                        (cpi->oxcf.starting_buffer_level-cpi->bits_off_target), | 4324                        (cpi->oxcf.starting_buffer_level-cpi->bits_off_target), | 
| 4449                        (int)cpi->total_actual_bits, cm->base_qindex, | 4325                        (int)cpi->total_actual_bits, cm->base_qindex, | 
| 4450                        cpi->active_best_quality, cpi->active_worst_quality, | 4326                        cpi->active_best_quality, cpi->active_worst_quality, | 
| 4451                        cpi->ni_av_qi, cpi->cq_target_quality, cpi->zbin_over_qua
      nt, | 4327                        cpi->ni_av_qi, cpi->cq_target_quality, cpi->zbin_over_qua
      nt, | 
| 4452                        //cpi->avg_frame_qindex, cpi->zbin_over_quant, | 4328                        //cpi->avg_frame_qindex, cpi->zbin_over_quant, | 
| 4453                        cm->refresh_golden_frame, cm->refresh_alt_ref_frame, | 4329                        cm->refresh_golden_frame, cm->refresh_alt_ref_frame, | 
| 4454                        cm->frame_type, cpi->gfu_boost, | 4330                        cm->frame_type, cpi->gfu_boost, | 
| 4455                        cpi->est_max_qcorrection_factor, (int)cpi->bits_left, | 4331                        cpi->twopass.est_max_qcorrection_factor, (int)cpi->twopas
      s.bits_left, | 
| 4456                        cpi->total_coded_error_left, cpi->tot_recode_hits); | 4332                        cpi->twopass.total_coded_error_left, cpi->tot_recode_hits
      ); | 
| 4457 | 4333 | 
| 4458         fclose(f); | 4334         fclose(f); | 
| 4459 | 4335 | 
| 4460         { | 4336         { | 
| 4461             FILE *fmodes = fopen("Modes.stt", "a"); | 4337             FILE *fmodes = fopen("Modes.stt", "a"); | 
| 4462             int i; | 4338             int i; | 
| 4463 | 4339 | 
| 4464             fprintf(fmodes, "%6d:%1d:%1d:%1d ", | 4340             fprintf(fmodes, "%6d:%1d:%1d:%1d ", | 
| 4465                         cpi->common.current_video_frame, | 4341                         cpi->common.current_video_frame, | 
| 4466                         cm->frame_type, cm->refresh_golden_frame, | 4342                         cm->frame_type, cm->refresh_golden_frame, | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4512     if (cpi->gold_is_last) | 4388     if (cpi->gold_is_last) | 
| 4513         cpi->ref_frame_flags &= ~VP8_GOLD_FLAG; | 4389         cpi->ref_frame_flags &= ~VP8_GOLD_FLAG; | 
| 4514 | 4390 | 
| 4515     if (cpi->alt_is_last) | 4391     if (cpi->alt_is_last) | 
| 4516         cpi->ref_frame_flags &= ~VP8_ALT_FLAG; | 4392         cpi->ref_frame_flags &= ~VP8_ALT_FLAG; | 
| 4517 | 4393 | 
| 4518     if (cpi->gold_is_alt) | 4394     if (cpi->gold_is_alt) | 
| 4519         cpi->ref_frame_flags &= ~VP8_ALT_FLAG; | 4395         cpi->ref_frame_flags &= ~VP8_ALT_FLAG; | 
| 4520 | 4396 | 
| 4521 | 4397 | 
| 4522     if (cpi->oxcf.error_resilient_mode) | 4398     if (!cpi->oxcf.error_resilient_mode) | 
| 4523     { |  | 
| 4524         if (cm->frame_type != KEY_FRAME) |  | 
| 4525         { |  | 
| 4526             // Is this an alternate reference update |  | 
| 4527             if (cm->refresh_alt_ref_frame) |  | 
| 4528                 vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cm->yv12_fb[cm->alt_
      fb_idx]); |  | 
| 4529 |  | 
| 4530             if (cm->refresh_golden_frame) |  | 
| 4531                 vp8_yv12_copy_frame_ptr(cm->frame_to_show, &cm->yv12_fb[cm->gld_
      fb_idx]); |  | 
| 4532         } |  | 
| 4533     } |  | 
| 4534     else |  | 
| 4535     { | 4399     { | 
| 4536         if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_
      type != KEY_FRAME)) | 4400         if (cpi->oxcf.play_alternate && cm->refresh_alt_ref_frame && (cm->frame_
      type != KEY_FRAME)) | 
| 4537             // Update the alternate reference frame and stats as appropriate. | 4401             // Update the alternate reference frame stats as appropriate. | 
| 4538             update_alt_ref_frame_and_stats(cpi); | 4402             update_alt_ref_frame_stats(cpi); | 
| 4539         else | 4403         else | 
| 4540             // Update the Golden frame and golden frame and stats as appropriate
      . | 4404             // Update the Golden frame stats as appropriate. | 
| 4541             update_golden_frame_and_stats(cpi); | 4405             update_golden_frame_stats(cpi); | 
| 4542     } | 4406     } | 
| 4543 | 4407 | 
| 4544     if (cm->frame_type == KEY_FRAME) | 4408     if (cm->frame_type == KEY_FRAME) | 
| 4545     { | 4409     { | 
| 4546         // Tell the caller that the frame was coded as a key frame | 4410         // Tell the caller that the frame was coded as a key frame | 
| 4547         *frame_flags = cm->frame_flags | FRAMEFLAGS_KEY; | 4411         *frame_flags = cm->frame_flags | FRAMEFLAGS_KEY; | 
| 4548 | 4412 | 
| 4549         // As this frame is a key frame  the next defaults to an inter frame. | 4413         // As this frame is a key frame  the next defaults to an inter frame. | 
| 4550         cm->frame_type = INTER_FRAME; | 4414         cm->frame_type = INTER_FRAME; | 
| 4551 | 4415 | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4649 } | 4513 } | 
| 4650 | 4514 | 
| 4651 #if !(CONFIG_REALTIME_ONLY) | 4515 #if !(CONFIG_REALTIME_ONLY) | 
| 4652 static void Pass2Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest,
       unsigned int *frame_flags) | 4516 static void Pass2Encode(VP8_COMP *cpi, unsigned long *size, unsigned char *dest,
       unsigned int *frame_flags) | 
| 4653 { | 4517 { | 
| 4654 | 4518 | 
| 4655     if (!cpi->common.refresh_alt_ref_frame) | 4519     if (!cpi->common.refresh_alt_ref_frame) | 
| 4656         vp8_second_pass(cpi); | 4520         vp8_second_pass(cpi); | 
| 4657 | 4521 | 
| 4658     encode_frame_to_data_rate(cpi, size, dest, frame_flags); | 4522     encode_frame_to_data_rate(cpi, size, dest, frame_flags); | 
| 4659     cpi->bits_left -= 8 * *size; | 4523     cpi->twopass.bits_left -= 8 * *size; | 
| 4660 | 4524 | 
| 4661     if (!cpi->common.refresh_alt_ref_frame) | 4525     if (!cpi->common.refresh_alt_ref_frame) | 
| 4662     { | 4526     { | 
| 4663         double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth | 4527         double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth | 
| 4664             *cpi->oxcf.two_pass_vbrmin_section / 100); | 4528             *cpi->oxcf.two_pass_vbrmin_section / 100); | 
| 4665         cpi->bits_left += (long long)(two_pass_min_rate / cpi->oxcf.frame_rate); | 4529         cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->oxcf.frame_
      rate); | 
| 4666     } | 4530     } | 
| 4667 } | 4531 } | 
| 4668 #endif | 4532 #endif | 
| 4669 | 4533 | 
| 4670 //For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us. | 4534 //For ARM NEON, d8-d15 are callee-saved registers, and need to be saved by us. | 
| 4671 #if HAVE_ARMV7 | 4535 #if HAVE_ARMV7 | 
| 4672 extern void vp8_push_neon(INT64 *store); | 4536 extern void vp8_push_neon(int64_t *store); | 
| 4673 extern void vp8_pop_neon(INT64 *store); | 4537 extern void vp8_pop_neon(int64_t *store); | 
| 4674 #endif | 4538 #endif | 
| 4675 int vp8_receive_raw_frame(VP8_PTR ptr, unsigned int frame_flags, YV12_BUFFER_CON
      FIG *sd, INT64 time_stamp, INT64 end_time) | 4539 | 
|  | 4540 | 
|  | 4541 int vp8_receive_raw_frame(VP8_PTR ptr, unsigned int frame_flags, YV12_BUFFER_CON
      FIG *sd, int64_t time_stamp, int64_t end_time) | 
| 4676 { | 4542 { | 
| 4677 #if HAVE_ARMV7 | 4543 #if HAVE_ARMV7 | 
| 4678     INT64 store_reg[8]; | 4544     int64_t store_reg[8]; | 
| 4679 #endif | 4545 #endif | 
| 4680     VP8_COMP *cpi = (VP8_COMP *) ptr; | 4546     VP8_COMP              *cpi = (VP8_COMP *) ptr; | 
| 4681     VP8_COMMON *cm = &cpi->common; | 4547     VP8_COMMON            *cm = &cpi->common; | 
| 4682     struct vpx_usec_timer  timer; | 4548     struct vpx_usec_timer  timer; | 
| 4683 | 4549     int                    res = 0; | 
| 4684     if (!cpi) |  | 
| 4685         return -1; |  | 
| 4686 | 4550 | 
| 4687 #if HAVE_ARMV7 | 4551 #if HAVE_ARMV7 | 
| 4688 #if CONFIG_RUNTIME_CPU_DETECT | 4552 #if CONFIG_RUNTIME_CPU_DETECT | 
| 4689     if (cm->rtcd.flags & HAS_NEON) | 4553     if (cm->rtcd.flags & HAS_NEON) | 
| 4690 #endif | 4554 #endif | 
| 4691     { | 4555     { | 
| 4692         vp8_push_neon(store_reg); | 4556         vp8_push_neon(store_reg); | 
| 4693     } | 4557     } | 
| 4694 #endif | 4558 #endif | 
| 4695 | 4559 | 
| 4696     vpx_usec_timer_start(&timer); | 4560     vpx_usec_timer_start(&timer); | 
| 4697 | 4561     if(vp8_lookahead_push(cpi->lookahead, sd, time_stamp, end_time, | 
| 4698     // no more room for frames; | 4562                           frame_flags)) | 
| 4699     if (cpi->source_buffer_count != 0 && cpi->source_buffer_count >= cpi->oxcf.l
      ag_in_frames) | 4563         res = -1; | 
| 4700     { |  | 
| 4701 #if HAVE_ARMV7 |  | 
| 4702 #if CONFIG_RUNTIME_CPU_DETECT |  | 
| 4703         if (cm->rtcd.flags & HAS_NEON) |  | 
| 4704 #endif |  | 
| 4705         { |  | 
| 4706             vp8_pop_neon(store_reg); |  | 
| 4707         } |  | 
| 4708 #endif |  | 
| 4709         return -1; |  | 
| 4710     } |  | 
| 4711 |  | 
| 4712     //printf("in-cpi->source_buffer_count: %d\n", cpi->source_buffer_count); |  | 
| 4713 |  | 
| 4714     cm->clr_type = sd->clrtype; | 4564     cm->clr_type = sd->clrtype; | 
| 4715 |  | 
| 4716     // make a copy of the frame for use later... |  | 
| 4717 #if !(CONFIG_REALTIME_ONLY) |  | 
| 4718 |  | 
| 4719     if (cpi->oxcf.allow_lag) |  | 
| 4720     { |  | 
| 4721         int which_buffer =  cpi->source_encode_index - 1; |  | 
| 4722         SOURCE_SAMPLE *s; |  | 
| 4723 |  | 
| 4724         if (which_buffer == -1) |  | 
| 4725             which_buffer = cpi->oxcf.lag_in_frames - 1; |  | 
| 4726 |  | 
| 4727         if (cpi->source_buffer_count < cpi->oxcf.lag_in_frames - 1) |  | 
| 4728             which_buffer = cpi->source_buffer_count; |  | 
| 4729 |  | 
| 4730         s = &cpi->src_buffer[which_buffer]; |  | 
| 4731 |  | 
| 4732         s->source_time_stamp = time_stamp; |  | 
| 4733         s->source_end_time_stamp = end_time; |  | 
| 4734         s->source_frame_flags = frame_flags; |  | 
| 4735         vp8_yv12_copy_frame_ptr(sd, &s->source_buffer); |  | 
| 4736 |  | 
| 4737         cpi->source_buffer_count ++; |  | 
| 4738     } |  | 
| 4739     else |  | 
| 4740 #endif |  | 
| 4741     { |  | 
| 4742         SOURCE_SAMPLE *s; |  | 
| 4743         s = &cpi->src_buffer[0]; |  | 
| 4744         s->source_end_time_stamp = end_time; |  | 
| 4745         s->source_time_stamp = time_stamp; |  | 
| 4746         s->source_frame_flags = frame_flags; |  | 
| 4747 #if HAVE_ARMV7 |  | 
| 4748 #if CONFIG_RUNTIME_CPU_DETECT |  | 
| 4749         if (cm->rtcd.flags & HAS_NEON) |  | 
| 4750 #endif |  | 
| 4751         { |  | 
| 4752             vp8_yv12_copy_src_frame_func_neon(sd, &s->source_buffer); |  | 
| 4753         } |  | 
| 4754 #if CONFIG_RUNTIME_CPU_DETECT |  | 
| 4755         else |  | 
| 4756 #endif |  | 
| 4757 #endif |  | 
| 4758 #if !HAVE_ARMV7 || CONFIG_RUNTIME_CPU_DETECT |  | 
| 4759         { |  | 
| 4760             vp8_yv12_copy_frame_ptr(sd, &s->source_buffer); |  | 
| 4761         } |  | 
| 4762 #endif |  | 
| 4763         cpi->source_buffer_count = 1; |  | 
| 4764     } |  | 
| 4765 |  | 
| 4766     vpx_usec_timer_mark(&timer); | 4565     vpx_usec_timer_mark(&timer); | 
| 4767     cpi->time_receive_data += vpx_usec_timer_elapsed(&timer); | 4566     cpi->time_receive_data += vpx_usec_timer_elapsed(&timer); | 
| 4768 | 4567 | 
| 4769 #if HAVE_ARMV7 | 4568 #if HAVE_ARMV7 | 
| 4770 #if CONFIG_RUNTIME_CPU_DETECT | 4569 #if CONFIG_RUNTIME_CPU_DETECT | 
| 4771     if (cm->rtcd.flags & HAS_NEON) | 4570     if (cm->rtcd.flags & HAS_NEON) | 
| 4772 #endif | 4571 #endif | 
| 4773     { | 4572     { | 
| 4774         vp8_pop_neon(store_reg); | 4573         vp8_pop_neon(store_reg); | 
| 4775     } | 4574     } | 
| 4776 #endif | 4575 #endif | 
| 4777 | 4576 | 
| 4778     return 0; | 4577     return res; | 
| 4779 } | 4578 } | 
| 4780 int vp8_get_compressed_data(VP8_PTR ptr, unsigned int *frame_flags, unsigned lon
      g *size, unsigned char *dest, INT64 *time_stamp, INT64 *time_end, int flush) | 4579 | 
|  | 4580 | 
|  | 4581 static int frame_is_reference(const VP8_COMP *cpi) | 
|  | 4582 { | 
|  | 4583     const VP8_COMMON *cm = &cpi->common; | 
|  | 4584     const MACROBLOCKD *xd = &cpi->mb.e_mbd; | 
|  | 4585 | 
|  | 4586     return cm->frame_type == KEY_FRAME || cm->refresh_last_frame | 
|  | 4587            || cm->refresh_golden_frame || cm->refresh_alt_ref_frame | 
|  | 4588            || cm->copy_buffer_to_gf || cm->copy_buffer_to_arf | 
|  | 4589            || cm->refresh_entropy_probs | 
|  | 4590            || xd->mode_ref_lf_delta_update | 
|  | 4591            || xd->update_mb_segmentation_map || xd->update_mb_segmentation_data; | 
|  | 4592 } | 
|  | 4593 | 
|  | 4594 | 
|  | 4595 int vp8_get_compressed_data(VP8_PTR ptr, unsigned int *frame_flags, unsigned lon
      g *size, unsigned char *dest, int64_t *time_stamp, int64_t *time_end, int flush) | 
| 4781 { | 4596 { | 
| 4782 #if HAVE_ARMV7 | 4597 #if HAVE_ARMV7 | 
| 4783     INT64 store_reg[8]; | 4598     int64_t store_reg[8]; | 
| 4784 #endif | 4599 #endif | 
| 4785     VP8_COMP *cpi = (VP8_COMP *) ptr; | 4600     VP8_COMP *cpi = (VP8_COMP *) ptr; | 
| 4786     VP8_COMMON *cm = &cpi->common; | 4601     VP8_COMMON *cm = &cpi->common; | 
| 4787     struct vpx_usec_timer  tsctimer; | 4602     struct vpx_usec_timer  tsctimer; | 
| 4788     struct vpx_usec_timer  ticktimer; | 4603     struct vpx_usec_timer  ticktimer; | 
| 4789     struct vpx_usec_timer  cmptimer; | 4604     struct vpx_usec_timer  cmptimer; | 
|  | 4605     YV12_BUFFER_CONFIG    *force_src_buffer = NULL; | 
| 4790 | 4606 | 
| 4791     if (!cpi) | 4607     if (!cpi) | 
| 4792         return -1; | 4608         return -1; | 
| 4793 | 4609 | 
| 4794 #if HAVE_ARMV7 | 4610 #if HAVE_ARMV7 | 
| 4795 #if CONFIG_RUNTIME_CPU_DETECT | 4611 #if CONFIG_RUNTIME_CPU_DETECT | 
| 4796     if (cm->rtcd.flags & HAS_NEON) | 4612     if (cm->rtcd.flags & HAS_NEON) | 
| 4797 #endif | 4613 #endif | 
| 4798     { | 4614     { | 
| 4799         vp8_push_neon(store_reg); | 4615         vp8_push_neon(store_reg); | 
| 4800     } | 4616     } | 
| 4801 #endif | 4617 #endif | 
| 4802 | 4618 | 
| 4803     vpx_usec_timer_start(&cmptimer); | 4619     vpx_usec_timer_start(&cmptimer); | 
| 4804 | 4620 | 
| 4805 | 4621     cpi->source = NULL; | 
| 4806     // flush variable tells us that even though we have less than 10 frames |  | 
| 4807     // in our buffer we need to start producing compressed frames. |  | 
| 4808     // Probably because we are at the end of a file.... |  | 
| 4809     if ((cpi->source_buffer_count == cpi->oxcf.lag_in_frames && cpi->oxcf.lag_in
      _frames > 0) |  | 
| 4810         || (!cpi->oxcf.allow_lag && cpi->source_buffer_count > 0) |  | 
| 4811         || (flush && cpi->source_buffer_count > 0)) |  | 
| 4812     { |  | 
| 4813 |  | 
| 4814         SOURCE_SAMPLE *s; |  | 
| 4815 |  | 
| 4816         s = &cpi->src_buffer[cpi->source_encode_index]; |  | 
| 4817         cpi->source_time_stamp = s->source_time_stamp; |  | 
| 4818         cpi->source_end_time_stamp = s->source_end_time_stamp; |  | 
| 4819 | 4622 | 
| 4820 #if !(CONFIG_REALTIME_ONLY) | 4623 #if !(CONFIG_REALTIME_ONLY) | 
| 4821 | 4624     // Should we code an alternate reference frame | 
| 4822         // Should we code an alternate reference frame | 4625     if (cpi->oxcf.error_resilient_mode == 0 && | 
| 4823         if (cpi->oxcf.error_resilient_mode == 0 && | 4626         cpi->oxcf.play_alternate && | 
| 4824             cpi->oxcf.play_alternate && | 4627         cpi->source_alt_ref_pending) | 
| 4825             cpi->source_alt_ref_pending  && | 4628     { | 
| 4826             (cpi->frames_till_gf_update_due < cpi->source_buffer_count) && | 4629         if ((cpi->source = vp8_lookahead_peek(cpi->lookahead, | 
| 4827             cpi->oxcf.lag_in_frames != 0) | 4630                                               cpi->frames_till_gf_update_due))) | 
| 4828         { | 4631         { | 
| 4829             cpi->last_alt_ref_sei = (cpi->source_encode_index + cpi->frames_till
      _gf_update_due) % cpi->oxcf.lag_in_frames; | 4632             cpi->alt_ref_source = cpi->source; | 
| 4830 |  | 
| 4831 #if VP8_TEMPORAL_ALT_REF |  | 
| 4832 |  | 
| 4833             if (cpi->oxcf.arnr_max_frames > 0) | 4633             if (cpi->oxcf.arnr_max_frames > 0) | 
| 4834             { | 4634             { | 
| 4835 #if 0 | 4635                 vp8_temporal_filter_prepare_c(cpi, | 
| 4836                 // my attempt at a loop that tests the results of strength filte
      r. | 4636                                               cpi->frames_till_gf_update_due); | 
| 4837                 int start_frame = cpi->last_alt_ref_sei - 3; | 4637                 force_src_buffer = &cpi->alt_ref_buffer; | 
| 4838 |  | 
| 4839                 int i, besti = -1, pastin = cpi->oxcf.arnr_strength; |  | 
| 4840 |  | 
| 4841                 int besterr; |  | 
| 4842 |  | 
| 4843                 if (start_frame < 0) |  | 
| 4844                     start_frame += cpi->oxcf.lag_in_frames; |  | 
| 4845 |  | 
| 4846                 besterr = calc_low_ss_err(&cpi->src_buffer[cpi->last_alt_ref_sei
      ].source_buffer, |  | 
| 4847                                               &cpi->src_buffer[start_frame].sour
      ce_buffer, IF_RTCD(&cpi->rtcd.variance)); |  | 
| 4848 |  | 
| 4849                 for (i = 0; i < 7; i++) |  | 
| 4850                 { |  | 
| 4851                     int thiserr; |  | 
| 4852                     cpi->oxcf.arnr_strength = i; |  | 
| 4853                     vp8_temporal_filter_prepare_c(cpi); |  | 
| 4854 |  | 
| 4855                     thiserr = calc_low_ss_err(&cpi->alt_ref_buffer.source_buffer
      , |  | 
| 4856                                                   &cpi->src_buffer[start_frame].
      source_buffer, IF_RTCD(&cpi->rtcd.variance)); |  | 
| 4857 |  | 
| 4858                     if (10 * thiserr < besterr * 8) |  | 
| 4859                     { |  | 
| 4860                         besterr = thiserr; |  | 
| 4861                         besti = i; |  | 
| 4862                     } |  | 
| 4863                 } |  | 
| 4864 |  | 
| 4865                 if (besti != -1) |  | 
| 4866                 { |  | 
| 4867                     cpi->oxcf.arnr_strength = besti; |  | 
| 4868                     vp8_temporal_filter_prepare_c(cpi); |  | 
| 4869                     s = &cpi->alt_ref_buffer; |  | 
| 4870 |  | 
| 4871                     // FWG not sure if I need to copy this data for the Alt Ref 
      frame |  | 
| 4872                     s->source_time_stamp = cpi->src_buffer[cpi->last_alt_ref_sei
      ].source_time_stamp; |  | 
| 4873                     s->source_end_time_stamp = cpi->src_buffer[cpi->last_alt_ref
      _sei].source_end_time_stamp; |  | 
| 4874                     s->source_frame_flags = cpi->src_buffer[cpi->last_alt_ref_se
      i].source_frame_flags; |  | 
| 4875                 } |  | 
| 4876                 else |  | 
| 4877                     s = &cpi->src_buffer[cpi->last_alt_ref_sei]; |  | 
| 4878 |  | 
| 4879 #else |  | 
| 4880                 vp8_temporal_filter_prepare_c(cpi); |  | 
| 4881                 s = &cpi->alt_ref_buffer; |  | 
| 4882 |  | 
| 4883                 // FWG not sure if I need to copy this data for the Alt Ref fram
      e |  | 
| 4884                 s->source_time_stamp = cpi->src_buffer[cpi->last_alt_ref_sei].so
      urce_time_stamp; |  | 
| 4885                 s->source_end_time_stamp = cpi->src_buffer[cpi->last_alt_ref_sei
      ].source_end_time_stamp; |  | 
| 4886                 s->source_frame_flags = cpi->src_buffer[cpi->last_alt_ref_sei].s
      ource_frame_flags; |  | 
| 4887 |  | 
| 4888 #endif |  | 
| 4889             } | 4638             } | 
| 4890             else |  | 
| 4891 #endif |  | 
| 4892                 s = &cpi->src_buffer[cpi->last_alt_ref_sei]; |  | 
| 4893 |  | 
| 4894             cm->frames_till_alt_ref_frame = cpi->frames_till_gf_update_due; | 4639             cm->frames_till_alt_ref_frame = cpi->frames_till_gf_update_due; | 
| 4895             cm->refresh_alt_ref_frame = 1; | 4640             cm->refresh_alt_ref_frame = 1; | 
| 4896             cm->refresh_golden_frame = 0; | 4641             cm->refresh_golden_frame = 0; | 
| 4897             cm->refresh_last_frame = 0; | 4642             cm->refresh_last_frame = 0; | 
| 4898             cm->show_frame = 0; | 4643             cm->show_frame = 0; | 
| 4899             cpi->source_alt_ref_pending = FALSE;   // Clear Pending altf Ref fla
      g. | 4644             cpi->source_alt_ref_pending = FALSE;   // Clear Pending altf Ref fla
      g. | 
| 4900             cpi->is_src_frame_alt_ref = 0; | 4645             cpi->is_src_frame_alt_ref = 0; | 
| 4901             cpi->is_next_src_alt_ref = 0; |  | 
| 4902         } | 4646         } | 
| 4903         else | 4647     } | 
| 4904 #endif | 4648 #endif | 
|  | 4649 | 
|  | 4650     if (!cpi->source) | 
|  | 4651     { | 
|  | 4652         if ((cpi->source = vp8_lookahead_pop(cpi->lookahead, flush))) | 
| 4905         { | 4653         { | 
| 4906             cm->show_frame = 1; | 4654             cm->show_frame = 1; | 
| 4907 #if !(CONFIG_REALTIME_ONLY) |  | 
| 4908 | 4655 | 
| 4909             if (cpi->oxcf.allow_lag) | 4656             cpi->is_src_frame_alt_ref = cpi->alt_ref_source | 
| 4910             { | 4657                                         && (cpi->source == cpi->alt_ref_source); | 
| 4911                 if (cpi->source_encode_index ==  cpi->last_alt_ref_sei) |  | 
| 4912                 { |  | 
| 4913                     cpi->is_src_frame_alt_ref = 1; |  | 
| 4914                     cpi->last_alt_ref_sei    = -1; |  | 
| 4915                 } |  | 
| 4916                 else |  | 
| 4917                     cpi->is_src_frame_alt_ref = 0; |  | 
| 4918 | 4658 | 
| 4919                 cpi->source_encode_index = (cpi->source_encode_index + 1) % cpi-
      >oxcf.lag_in_frames; | 4659             if(cpi->is_src_frame_alt_ref) | 
|  | 4660                 cpi->alt_ref_source = NULL; | 
|  | 4661         } | 
|  | 4662     } | 
| 4920 | 4663 | 
| 4921                 if(cpi->source_encode_index == cpi->last_alt_ref_sei) | 4664     if (cpi->source) | 
| 4922                     cpi->is_next_src_alt_ref = 1; | 4665     { | 
| 4923                 else | 4666         cpi->un_scaled_source = | 
| 4924                     cpi->is_next_src_alt_ref = 0; | 4667         cpi->Source = force_src_buffer ? force_src_buffer : &cpi->source->img; | 
| 4925             } | 4668         *time_stamp = cpi->source->ts_start; | 
| 4926 | 4669         *time_end = cpi->source->ts_end; | 
| 4927 #endif | 4670         *frame_flags = cpi->source->flags; | 
| 4928             cpi->source_buffer_count--; |  | 
| 4929         } |  | 
| 4930 |  | 
| 4931         cpi->un_scaled_source = &s->source_buffer; |  | 
| 4932         cpi->Source = &s->source_buffer; |  | 
| 4933         cpi->source_frame_flags = s->source_frame_flags; |  | 
| 4934 |  | 
| 4935         *time_stamp = cpi->source_time_stamp; |  | 
| 4936         *time_end = cpi->source_end_time_stamp; |  | 
| 4937     } | 4671     } | 
| 4938     else | 4672     else | 
| 4939     { | 4673     { | 
| 4940         *size = 0; | 4674         *size = 0; | 
| 4941 #if !(CONFIG_REALTIME_ONLY) | 4675 #if !(CONFIG_REALTIME_ONLY) | 
| 4942 | 4676 | 
| 4943         if (flush && cpi->pass == 1 && !cpi->first_pass_done) | 4677         if (flush && cpi->pass == 1 && !cpi->twopass.first_pass_done) | 
| 4944         { | 4678         { | 
| 4945             vp8_end_first_pass(cpi);    /* get last stats packet */ | 4679             vp8_end_first_pass(cpi);    /* get last stats packet */ | 
| 4946             cpi->first_pass_done = 1; | 4680             cpi->twopass.first_pass_done = 1; | 
| 4947         } | 4681         } | 
| 4948 | 4682 | 
| 4949 #endif | 4683 #endif | 
| 4950 | 4684 | 
| 4951 #if HAVE_ARMV7 | 4685 #if HAVE_ARMV7 | 
| 4952 #if CONFIG_RUNTIME_CPU_DETECT | 4686 #if CONFIG_RUNTIME_CPU_DETECT | 
| 4953         if (cm->rtcd.flags & HAS_NEON) | 4687         if (cm->rtcd.flags & HAS_NEON) | 
| 4954 #endif | 4688 #endif | 
| 4955         { | 4689         { | 
| 4956             vp8_pop_neon(store_reg); | 4690             vp8_pop_neon(store_reg); | 
| 4957         } | 4691         } | 
| 4958 #endif | 4692 #endif | 
| 4959         return -1; | 4693         return -1; | 
| 4960     } | 4694     } | 
| 4961 | 4695 | 
| 4962     *frame_flags = cpi->source_frame_flags; | 4696     if (cpi->source->ts_start < cpi->first_time_stamp_ever) | 
| 4963 |  | 
| 4964     if (cpi->source_time_stamp < cpi->first_time_stamp_ever) |  | 
| 4965     { | 4697     { | 
| 4966         cpi->first_time_stamp_ever = cpi->source_time_stamp; | 4698         cpi->first_time_stamp_ever = cpi->source->ts_start; | 
| 4967         cpi->last_end_time_stamp_seen = cpi->source_time_stamp; | 4699         cpi->last_end_time_stamp_seen = cpi->source->ts_start; | 
| 4968     } | 4700     } | 
| 4969 | 4701 | 
| 4970     // adjust frame rates based on timestamps given | 4702     // adjust frame rates based on timestamps given | 
| 4971     if (!cm->refresh_alt_ref_frame) | 4703     if (!cm->refresh_alt_ref_frame) | 
| 4972     { | 4704     { | 
| 4973         if (cpi->source_time_stamp == cpi->first_time_stamp_ever) | 4705         int64_t this_duration; | 
|  | 4706         int step = 0; | 
|  | 4707 | 
|  | 4708         if (cpi->source->ts_start == cpi->first_time_stamp_ever) | 
| 4974         { | 4709         { | 
| 4975             double this_fps = 10000000.000 / (cpi->source_end_time_stamp - cpi->
      source_time_stamp); | 4710             this_duration = cpi->source->ts_end - cpi->source->ts_start; | 
| 4976 | 4711             step = 1; | 
| 4977             vp8_new_frame_rate(cpi, this_fps); |  | 
| 4978         } | 4712         } | 
| 4979         else | 4713         else | 
| 4980         { | 4714         { | 
| 4981             long long nanosecs = cpi->source_end_time_stamp | 4715             int64_t last_duration; | 
| 4982                 - cpi->last_end_time_stamp_seen; |  | 
| 4983 | 4716 | 
| 4984             if (nanosecs > 0) | 4717             this_duration = cpi->source->ts_end - cpi->last_end_time_stamp_seen; | 
| 4985             { | 4718             last_duration = cpi->last_end_time_stamp_seen | 
| 4986               double this_fps = 10000000.000 / nanosecs; | 4719                             - cpi->last_time_stamp_seen; | 
| 4987               vp8_new_frame_rate(cpi, (7 * cpi->oxcf.frame_rate + this_fps) / 8)
      ; | 4720             // do a step update if the duration changes by 10% | 
| 4988             } | 4721             if (last_duration) | 
| 4989 | 4722                 step = ((this_duration - last_duration) * 10 / last_duration); | 
| 4990         } | 4723         } | 
| 4991 | 4724 | 
| 4992         cpi->last_time_stamp_seen = cpi->source_time_stamp; | 4725         if (this_duration) | 
| 4993         cpi->last_end_time_stamp_seen = cpi->source_end_time_stamp; | 4726         { | 
|  | 4727             if (step) | 
|  | 4728                 vp8_new_frame_rate(cpi, 10000000.0 / this_duration); | 
|  | 4729             else | 
|  | 4730             { | 
|  | 4731                 double avg_duration, interval; | 
|  | 4732 | 
|  | 4733                 /* Average this frame's rate into the last second's average | 
|  | 4734                  * frame rate. If we haven't seen 1 second yet, then average | 
|  | 4735                  * over the whole interval seen. | 
|  | 4736                  */ | 
|  | 4737                 interval = cpi->source->ts_end - cpi->first_time_stamp_ever; | 
|  | 4738                 if(interval > 10000000.0) | 
|  | 4739                     interval = 10000000; | 
|  | 4740 | 
|  | 4741                 avg_duration = 10000000.0 / cpi->oxcf.frame_rate; | 
|  | 4742                 avg_duration *= (interval - avg_duration + this_duration); | 
|  | 4743                 avg_duration /= interval; | 
|  | 4744 | 
|  | 4745                 vp8_new_frame_rate(cpi, 10000000.0 / avg_duration); | 
|  | 4746             } | 
|  | 4747         } | 
|  | 4748 | 
|  | 4749         cpi->last_time_stamp_seen = cpi->source->ts_start; | 
|  | 4750         cpi->last_end_time_stamp_seen = cpi->source->ts_end; | 
| 4994     } | 4751     } | 
| 4995 | 4752 | 
| 4996     if (cpi->compressor_speed == 2) | 4753     if (cpi->compressor_speed == 2) | 
| 4997     { | 4754     { | 
| 4998         check_gf_quality(cpi); | 4755         check_gf_quality(cpi); | 
| 4999         vpx_usec_timer_start(&tsctimer); | 4756         vpx_usec_timer_start(&tsctimer); | 
| 5000         vpx_usec_timer_start(&ticktimer); | 4757         vpx_usec_timer_start(&ticktimer); | 
| 5001     } | 4758     } | 
| 5002 | 4759 | 
| 5003     // start with a 0 size frame | 4760     // start with a 0 size frame | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 5017         cm->refresh_golden_frame = 0; | 4774         cm->refresh_golden_frame = 0; | 
| 5018         cm->refresh_last_frame = 0; | 4775         cm->refresh_last_frame = 0; | 
| 5019     } | 4776     } | 
| 5020     else | 4777     else | 
| 5021     { | 4778     { | 
| 5022         cm->refresh_golden_frame = 0; | 4779         cm->refresh_golden_frame = 0; | 
| 5023         cm->refresh_last_frame = 1; | 4780         cm->refresh_last_frame = 1; | 
| 5024     } | 4781     } | 
| 5025 | 4782 | 
| 5026 #endif | 4783 #endif | 
|  | 4784     /* find a free buffer for the new frame */ | 
|  | 4785     { | 
|  | 4786         int i = 0; | 
|  | 4787         for(; i < NUM_YV12_BUFFERS; i++) | 
|  | 4788         { | 
|  | 4789             if(!cm->yv12_fb[i].flags) | 
|  | 4790             { | 
|  | 4791                 cm->new_fb_idx = i; | 
|  | 4792                 break; | 
|  | 4793             } | 
|  | 4794         } | 
| 5027 | 4795 | 
|  | 4796         assert(i < NUM_YV12_BUFFERS ); | 
|  | 4797     } | 
| 5028 #if !(CONFIG_REALTIME_ONLY) | 4798 #if !(CONFIG_REALTIME_ONLY) | 
| 5029 | 4799 | 
| 5030     if (cpi->pass == 1) | 4800     if (cpi->pass == 1) | 
| 5031     { | 4801     { | 
| 5032         Pass1Encode(cpi, size, dest, frame_flags); | 4802         Pass1Encode(cpi, size, dest, frame_flags); | 
| 5033     } | 4803     } | 
| 5034     else if (cpi->pass == 2) | 4804     else if (cpi->pass == 2) | 
| 5035     { | 4805     { | 
| 5036         Pass2Encode(cpi, size, dest, frame_flags); | 4806         Pass2Encode(cpi, size, dest, frame_flags); | 
| 5037     } | 4807     } | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5071     } | 4841     } | 
| 5072 | 4842 | 
| 5073     if (cm->refresh_entropy_probs == 0) | 4843     if (cm->refresh_entropy_probs == 0) | 
| 5074     { | 4844     { | 
| 5075         vpx_memcpy(&cm->fc, &cm->lfc, sizeof(cm->fc)); | 4845         vpx_memcpy(&cm->fc, &cm->lfc, sizeof(cm->fc)); | 
| 5076     } | 4846     } | 
| 5077 | 4847 | 
| 5078     // if its a dropped frame honor the requests on subsequent frames | 4848     // if its a dropped frame honor the requests on subsequent frames | 
| 5079     if (*size > 0) | 4849     if (*size > 0) | 
| 5080     { | 4850     { | 
|  | 4851         cpi->droppable = !frame_is_reference(cpi); | 
| 5081 | 4852 | 
| 5082         // return to normal state | 4853         // return to normal state | 
| 5083         cm->refresh_entropy_probs = 1; | 4854         cm->refresh_entropy_probs = 1; | 
| 5084         cm->refresh_alt_ref_frame = 0; | 4855         cm->refresh_alt_ref_frame = 0; | 
| 5085         cm->refresh_golden_frame = 0; | 4856         cm->refresh_golden_frame = 0; | 
| 5086         cm->refresh_last_frame = 1; | 4857         cm->refresh_last_frame = 1; | 
| 5087         cm->frame_type = INTER_FRAME; | 4858         cm->frame_type = INTER_FRAME; | 
| 5088 | 4859 | 
| 5089     } | 4860     } | 
| 5090 | 4861 | 
| 5091     cpi->ready_for_new_frame = 1; |  | 
| 5092 |  | 
| 5093     vpx_usec_timer_mark(&cmptimer); | 4862     vpx_usec_timer_mark(&cmptimer); | 
| 5094     cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer); | 4863     cpi->time_compress_data += vpx_usec_timer_elapsed(&cmptimer); | 
| 5095 | 4864 | 
| 5096     if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame) | 4865     if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame) | 
| 5097     { | 4866     { | 
| 5098         generate_psnr_packet(cpi); | 4867         generate_psnr_packet(cpi); | 
| 5099     } | 4868     } | 
| 5100 | 4869 | 
| 5101 #if CONFIG_PSNR | 4870 #if CONFIG_INTERNAL_STATS | 
| 5102 | 4871 | 
| 5103     if (cpi->pass != 1) | 4872     if (cpi->pass != 1) | 
| 5104     { | 4873     { | 
| 5105         cpi->bytes += *size; | 4874         cpi->bytes += *size; | 
| 5106 | 4875 | 
| 5107         if (cm->show_frame) | 4876         if (cm->show_frame) | 
| 5108         { | 4877         { | 
| 5109 | 4878 | 
| 5110             cpi->count ++; | 4879             cpi->count ++; | 
| 5111 | 4880 | 
| 5112             if (cpi->b_calculate_psnr) | 4881             if (cpi->b_calculate_psnr) | 
| 5113             { | 4882             { | 
| 5114                 double y, u, v; |  | 
| 5115                 double ye,ue,ve; | 4883                 double ye,ue,ve; | 
| 5116                 double frame_psnr; | 4884                 double frame_psnr; | 
| 5117                 YV12_BUFFER_CONFIG      *orig = cpi->Source; | 4885                 YV12_BUFFER_CONFIG      *orig = cpi->Source; | 
| 5118                 YV12_BUFFER_CONFIG      *recon = cpi->common.frame_to_show; | 4886                 YV12_BUFFER_CONFIG      *recon = cpi->common.frame_to_show; | 
| 5119                 YV12_BUFFER_CONFIG      *pp = &cm->post_proc_buffer; | 4887                 YV12_BUFFER_CONFIG      *pp = &cm->post_proc_buffer; | 
| 5120                 int y_samples = orig->y_height * orig->y_width ; | 4888                 int y_samples = orig->y_height * orig->y_width ; | 
| 5121                 int uv_samples = orig->uv_height * orig->uv_width ; | 4889                 int uv_samples = orig->uv_height * orig->uv_width ; | 
| 5122                 int t_samples = y_samples + 2 * uv_samples; | 4890                 int t_samples = y_samples + 2 * uv_samples; | 
| 5123                 long long sq_error; | 4891                 int64_t sq_error; | 
| 5124 | 4892 | 
| 5125                 ye = calc_plane_error(orig->y_buffer, orig->y_stride, | 4893                 ye = calc_plane_error(orig->y_buffer, orig->y_stride, | 
| 5126                   recon->y_buffer, recon->y_stride, orig->y_width, orig->y_heigh
      t, | 4894                   recon->y_buffer, recon->y_stride, orig->y_width, orig->y_heigh
      t, | 
| 5127                   IF_RTCD(&cpi->rtcd.variance)); | 4895                   IF_RTCD(&cpi->rtcd.variance)); | 
| 5128 | 4896 | 
| 5129                 ue = calc_plane_error(orig->u_buffer, orig->uv_stride, | 4897                 ue = calc_plane_error(orig->u_buffer, orig->uv_stride, | 
| 5130                   recon->u_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
      ight, | 4898                   recon->u_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
      ight, | 
| 5131                   IF_RTCD(&cpi->rtcd.variance)); | 4899                   IF_RTCD(&cpi->rtcd.variance)); | 
| 5132 | 4900 | 
| 5133                 ve = calc_plane_error(orig->v_buffer, orig->uv_stride, | 4901                 ve = calc_plane_error(orig->v_buffer, orig->uv_stride, | 
| 5134                   recon->v_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
      ight, | 4902                   recon->v_buffer, recon->uv_stride, orig->uv_width, orig->uv_he
      ight, | 
| 5135                   IF_RTCD(&cpi->rtcd.variance)); | 4903                   IF_RTCD(&cpi->rtcd.variance)); | 
| 5136 | 4904 | 
| 5137                 sq_error = ye + ue + ve; | 4905                 sq_error = ye + ue + ve; | 
| 5138 | 4906 | 
| 5139                 frame_psnr = vp8_mse2psnr(t_samples, 255.0, sq_error); | 4907                 frame_psnr = vp8_mse2psnr(t_samples, 255.0, sq_error); | 
| 5140 | 4908 | 
| 5141                 cpi->total_y += vp8_mse2psnr(y_samples, 255.0, ye); | 4909                 cpi->total_y += vp8_mse2psnr(y_samples, 255.0, ye); | 
| 5142                 cpi->total_u += vp8_mse2psnr(uv_samples, 255.0, ue); | 4910                 cpi->total_u += vp8_mse2psnr(uv_samples, 255.0, ue); | 
| 5143                 cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, ve); | 4911                 cpi->total_v += vp8_mse2psnr(uv_samples, 255.0, ve); | 
| 5144                 cpi->total_sq_error += sq_error; | 4912                 cpi->total_sq_error += sq_error; | 
| 5145                 cpi->total  += frame_psnr; | 4913                 cpi->total  += frame_psnr; | 
| 5146                 { | 4914                 { | 
| 5147                     double y2, u2, v2, frame_psnr2, frame_ssim2 = 0; | 4915                     double frame_psnr2, frame_ssim2 = 0; | 
| 5148                     double weight = 0; | 4916                     double weight = 0; | 
| 5149 | 4917 | 
| 5150                     vp8_deblock(cm->frame_to_show, &cm->post_proc_buffer, cm->fi
      lter_level * 10 / 6, 1, 0, IF_RTCD(&cm->rtcd.postproc)); | 4918                     vp8_deblock(cm->frame_to_show, &cm->post_proc_buffer, cm->fi
      lter_level * 10 / 6, 1, 0, IF_RTCD(&cm->rtcd.postproc)); | 
| 5151                     vp8_clear_system_state(); | 4919                     vp8_clear_system_state(); | 
| 5152 | 4920 | 
| 5153                     ye = calc_plane_error(orig->y_buffer, orig->y_stride, | 4921                     ye = calc_plane_error(orig->y_buffer, orig->y_stride, | 
| 5154                       pp->y_buffer, pp->y_stride, orig->y_width, orig->y_height, | 4922                       pp->y_buffer, pp->y_stride, orig->y_width, orig->y_height, | 
| 5155                       IF_RTCD(&cpi->rtcd.variance)); | 4923                       IF_RTCD(&cpi->rtcd.variance)); | 
| 5156 | 4924 | 
| 5157                     ue = calc_plane_error(orig->u_buffer, orig->uv_stride, | 4925                     ue = calc_plane_error(orig->u_buffer, orig->uv_stride, | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 5178 | 4946 | 
| 5179                     cpi->summed_quality += frame_ssim2 * weight; | 4947                     cpi->summed_quality += frame_ssim2 * weight; | 
| 5180                     cpi->summed_weights += weight; | 4948                     cpi->summed_weights += weight; | 
| 5181 | 4949 | 
| 5182                 } | 4950                 } | 
| 5183             } | 4951             } | 
| 5184 | 4952 | 
| 5185             if (cpi->b_calculate_ssimg) | 4953             if (cpi->b_calculate_ssimg) | 
| 5186             { | 4954             { | 
| 5187                 double y, u, v, frame_all; | 4955                 double y, u, v, frame_all; | 
| 5188                 frame_all =  vp8_calc_ssimg(cpi->Source, cm->frame_to_show, &y, 
      &u, &v); | 4956                 frame_all =  vp8_calc_ssimg(cpi->Source, cm->frame_to_show, | 
|  | 4957                     &y, &u, &v, IF_RTCD(&cpi->rtcd.variance)); | 
| 5189                 cpi->total_ssimg_y += y; | 4958                 cpi->total_ssimg_y += y; | 
| 5190                 cpi->total_ssimg_u += u; | 4959                 cpi->total_ssimg_u += u; | 
| 5191                 cpi->total_ssimg_v += v; | 4960                 cpi->total_ssimg_v += v; | 
| 5192                 cpi->total_ssimg_all += frame_all; | 4961                 cpi->total_ssimg_all += frame_all; | 
| 5193             } | 4962             } | 
| 5194 | 4963 | 
| 5195         } | 4964         } | 
| 5196     } | 4965     } | 
| 5197 | 4966 | 
| 5198 #if 0 | 4967 #if 0 | 
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5369         } | 5138         } | 
| 5370 | 5139 | 
| 5371         src += 16 * source->y_stride; | 5140         src += 16 * source->y_stride; | 
| 5372         dst += 16 * dest->y_stride; | 5141         dst += 16 * dest->y_stride; | 
| 5373     } | 5142     } | 
| 5374 | 5143 | 
| 5375     return Total; | 5144     return Total; | 
| 5376 } | 5145 } | 
| 5377 | 5146 | 
| 5378 | 5147 | 
| 5379 static int calc_low_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest,
       const vp8_variance_rtcd_vtable_t *rtcd) |  | 
| 5380 { |  | 
| 5381     int i, j; |  | 
| 5382     int Total = 0; |  | 
| 5383 |  | 
| 5384     unsigned char *src = source->y_buffer; |  | 
| 5385     unsigned char *dst = dest->y_buffer; |  | 
| 5386     (void)rtcd; |  | 
| 5387 |  | 
| 5388     // Loop through the Y plane raw and reconstruction data summing (square diff
      erences) |  | 
| 5389     for (i = 0; i < source->y_height; i += 16) |  | 
| 5390     { |  | 
| 5391         for (j = 0; j < source->y_width; j += 16) |  | 
| 5392         { |  | 
| 5393             unsigned int sse; |  | 
| 5394             VARIANCE_INVOKE(rtcd, mse16x16)(src + j, source->y_stride, dst + j, 
      dest->y_stride, &sse); |  | 
| 5395 |  | 
| 5396             if (sse < 8096) |  | 
| 5397                 Total += sse; |  | 
| 5398         } |  | 
| 5399 |  | 
| 5400         src += 16 * source->y_stride; |  | 
| 5401         dst += 16 * dest->y_stride; |  | 
| 5402     } |  | 
| 5403 |  | 
| 5404     return Total; |  | 
| 5405 } |  | 
| 5406 |  | 
| 5407 |  | 
| 5408 int vp8_get_quantizer(VP8_PTR c) | 5148 int vp8_get_quantizer(VP8_PTR c) | 
| 5409 { | 5149 { | 
| 5410     VP8_COMP   *cpi = (VP8_COMP *) c; | 5150     VP8_COMP   *cpi = (VP8_COMP *) c; | 
| 5411     return cpi->common.base_qindex; | 5151     return cpi->common.base_qindex; | 
| 5412 } | 5152 } | 
| OLD | NEW | 
|---|