Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_onyx_if.c

Issue 11974002: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_modecosts.h ('k') | source/libvpx/vp9/encoder/vp9_onyx_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vpx_config.h"
13 #include "vp9/common/vp9_onyxc_int.h" 13 #include "vp9/common/vp9_onyxc_int.h"
14 #include "vp9/encoder/vp9_onyx_int.h" 14 #include "vp9/encoder/vp9_onyx_int.h"
15 #include "vp9/common/vp9_systemdependent.h" 15 #include "vp9/common/vp9_systemdependent.h"
16 #include "vp9/encoder/vp9_quantize.h" 16 #include "vp9/encoder/vp9_quantize.h"
17 #include "vp9/common/vp9_alloccommon.h" 17 #include "vp9/common/vp9_alloccommon.h"
18 #include "vp9/encoder/vp9_mcomp.h" 18 #include "vp9/encoder/vp9_mcomp.h"
19 #include "vp9/encoder/vp9_firstpass.h" 19 #include "vp9/encoder/vp9_firstpass.h"
20 #include "vp9/encoder/vp9_psnr.h" 20 #include "vp9/encoder/vp9_psnr.h"
21 #include "vpx_scale/vpxscale.h" 21 #include "vpx_scale/vpx_scale.h"
22 #include "vp9/common/vp9_extend.h" 22 #include "vp9/common/vp9_extend.h"
23 #include "vp9/encoder/vp9_ratectrl.h" 23 #include "vp9/encoder/vp9_ratectrl.h"
24 #include "vp9/common/vp9_quant_common.h" 24 #include "vp9/common/vp9_quant_common.h"
25 #include "vp9/encoder/vp9_segmentation.h" 25 #include "vp9/encoder/vp9_segmentation.h"
26 #include "./vp9_rtcd.h" 26 #include "./vp9_rtcd.h"
27 #include "./vpx_scale_rtcd.h" 27 #include "./vpx_scale_rtcd.h"
28 #if CONFIG_POSTPROC 28 #if CONFIG_POSTPROC
29 #include "vp9/common/vp9_postproc.h" 29 #include "vp9/common/vp9_postproc.h"
30 #endif 30 #endif
31 #include "vpx_mem/vpx_mem.h" 31 #include "vpx_mem/vpx_mem.h"
(...skipping 10 matching lines...) Expand all
42 #include "vp9/encoder/vp9_temporal_filter.h" 42 #include "vp9/encoder/vp9_temporal_filter.h"
43 43
44 #include <math.h> 44 #include <math.h>
45 #include <stdio.h> 45 #include <stdio.h>
46 #include <limits.h> 46 #include <limits.h>
47 47
48 extern void print_tree_update_probs(); 48 extern void print_tree_update_probs();
49 49
50 static void set_default_lf_deltas(VP9_COMP *cpi); 50 static void set_default_lf_deltas(VP9_COMP *cpi);
51 51
52 #define DEFAULT_INTERP_FILTER EIGHTTAP /* SWITCHABLE for better performance */ 52 #define DEFAULT_INTERP_FILTER SWITCHABLE
53
53 #define SEARCH_BEST_FILTER 0 /* to search exhaustively for 54 #define SEARCH_BEST_FILTER 0 /* to search exhaustively for
54 best filter */ 55 best filter */
55 #define RESET_FOREACH_FILTER 0 /* whether to reset the encoder state 56 #define RESET_FOREACH_FILTER 0 /* whether to reset the encoder state
56 before trying each new filter */ 57 before trying each new filter */
57 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ 58 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */
58 59
59 #define ALTREF_HIGH_PRECISION_MV 1 /* whether to use high precision mv 60 #define ALTREF_HIGH_PRECISION_MV 1 /* whether to use high precision mv
60 for altref computation */ 61 for altref computation */
61 #define HIGH_PRECISION_MV_QTHRESH 200 /* Q threshold for use of high precision 62 #define HIGH_PRECISION_MV_QTHRESH 200 /* Q threshold for use of high precision
62 mv. Choose a very high value for 63 mv. Choose a very high value for
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 #endif 112 #endif
112 113
113 #ifdef SPEEDSTATS 114 #ifdef SPEEDSTATS
114 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 115 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
115 #endif 116 #endif
116 117
117 #if defined(SECTIONBITS_OUTPUT) 118 #if defined(SECTIONBITS_OUTPUT)
118 extern unsigned __int64 Sectionbits[500]; 119 extern unsigned __int64 Sectionbits[500];
119 #endif 120 #endif
120 #ifdef MODE_STATS 121 #ifdef MODE_STATS
121 extern INT64 Sectionbits[500]; 122 extern int64_t Sectionbits[500];
122 extern unsigned int y_modes[VP9_YMODES]; 123 extern unsigned int y_modes[VP9_YMODES];
123 extern unsigned int i8x8_modes[VP9_I8X8_MODES]; 124 extern unsigned int i8x8_modes[VP9_I8X8_MODES];
124 extern unsigned int uv_modes[VP9_UV_MODES]; 125 extern unsigned int uv_modes[VP9_UV_MODES];
125 extern unsigned int uv_modes_y[VP9_YMODES][VP9_UV_MODES]; 126 extern unsigned int uv_modes_y[VP9_YMODES][VP9_UV_MODES];
126 extern unsigned int b_modes[B_MODE_COUNT]; 127 extern unsigned int b_modes[B_MODE_COUNT];
127 extern unsigned int inter_y_modes[MB_MODE_COUNT]; 128 extern unsigned int inter_y_modes[MB_MODE_COUNT];
128 extern unsigned int inter_uv_modes[VP9_UV_MODES]; 129 extern unsigned int inter_uv_modes[VP9_UV_MODES];
129 extern unsigned int inter_b_modes[B_MODE_COUNT]; 130 extern unsigned int inter_b_modes[B_MODE_COUNT];
130 #endif 131 #endif
131 132
132 extern void vp9_init_quantizer(VP9_COMP *cpi); 133 extern void vp9_init_quantizer(VP9_COMP *cpi);
133 134
134 static int base_skip_false_prob[QINDEX_RANGE][3]; 135 static int base_skip_false_prob[QINDEX_RANGE][3];
135 136
136 // Tables relating active max Q to active min Q 137 // Tables relating active max Q to active min Q
137 static int kf_low_motion_minq[QINDEX_RANGE]; 138 static int kf_low_motion_minq[QINDEX_RANGE];
138 static int kf_high_motion_minq[QINDEX_RANGE]; 139 static int kf_high_motion_minq[QINDEX_RANGE];
139 static int gf_low_motion_minq[QINDEX_RANGE]; 140 static int gf_low_motion_minq[QINDEX_RANGE];
140 static int gf_high_motion_minq[QINDEX_RANGE]; 141 static int gf_high_motion_minq[QINDEX_RANGE];
141 static int inter_minq[QINDEX_RANGE]; 142 static int inter_minq[QINDEX_RANGE];
142 143
143 // Functions to compute the active minq lookup table entries based on a 144 // Functions to compute the active minq lookup table entries based on a
144 // formulaic approach to facilitate easier adjustment of the Q tables. 145 // formulaic approach to facilitate easier adjustment of the Q tables.
145 // The formulae were derived from computing a 3rd order polynomial best 146 // The formulae were derived from computing a 3rd order polynomial best
146 // fit to the original data (after plotting real maxq vs minq (not q index)) 147 // fit to the original data (after plotting real maxq vs minq (not q index))
147 static int calculate_minq_index(double maxq, 148 static int calculate_minq_index(double maxq,
148 double x3, double x2, double x, double c) { 149 double x3, double x2, double x, double c) {
149 int i; 150 int i;
150 double minqtarget; 151 double minqtarget;
151 double thisq;
152 152
153 minqtarget = ((x3 * maxq * maxq * maxq) + 153 minqtarget = ((x3 * maxq * maxq * maxq) +
154 (x2 * maxq * maxq) + 154 (x2 * maxq * maxq) +
155 (x * maxq) + 155 (x * maxq) +
156 c); 156 c);
157 157
158 if (minqtarget > maxq) 158 if (minqtarget > maxq)
159 minqtarget = maxq; 159 minqtarget = maxq;
160 160
161 for (i = 0; i < QINDEX_RANGE; i++) { 161 for (i = 0; i < QINDEX_RANGE; i++) {
162 thisq = vp9_convert_qindex_to_q(i);
163 if (minqtarget <= vp9_convert_qindex_to_q(i)) 162 if (minqtarget <= vp9_convert_qindex_to_q(i))
164 return i; 163 return i;
165 } 164 }
166 return QINDEX_RANGE - 1; 165 return QINDEX_RANGE - 1;
167 } 166 }
168 167
169 static void init_minq_luts(void) { 168 static void init_minq_luts(void) {
170 int i; 169 int i;
171 double maxq; 170 double maxq;
172 171
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 mb->mvsadcost = mb->nmvsadcost_hp; 208 mb->mvsadcost = mb->nmvsadcost_hp;
210 209
211 } else { 210 } else {
212 mb->mvcost = mb->nmvcost; 211 mb->mvcost = mb->nmvcost;
213 mb->mvsadcost = mb->nmvsadcost; 212 mb->mvsadcost = mb->nmvsadcost;
214 } 213 }
215 } 214 }
216 static void init_base_skip_probs(void) { 215 static void init_base_skip_probs(void) {
217 int i; 216 int i;
218 double q; 217 double q;
219 int skip_prob, t; 218 int t;
220 219
221 for (i = 0; i < QINDEX_RANGE; i++) { 220 for (i = 0; i < QINDEX_RANGE; i++) {
222 q = vp9_convert_qindex_to_q(i); 221 q = vp9_convert_qindex_to_q(i);
223 222
224 // Exponential decay caluclation of baseline skip prob with clamping 223 // Exponential decay caluclation of baseline skip prob with clamping
225 // Based on crude best fit of old table. 224 // Based on crude best fit of old table.
226 t = (int)(564.25 * pow(2.71828, (-0.012 * q))); 225 t = (int)(564.25 * pow(2.71828, (-0.012 * q)));
227 226
228 skip_prob = t; 227 base_skip_false_prob[i][1] = clip_prob(t);
229 if (skip_prob < 1) 228 base_skip_false_prob[i][2] = clip_prob(t * 3 / 4);
230 skip_prob = 1; 229 base_skip_false_prob[i][0] = clip_prob(t * 5 / 4);
231 else if (skip_prob > 255)
232 skip_prob = 255;
233 base_skip_false_prob[i][1] = skip_prob;
234
235 skip_prob = t * 3 / 4;
236 if (skip_prob < 1)
237 skip_prob = 1;
238 else if (skip_prob > 255)
239 skip_prob = 255;
240 base_skip_false_prob[i][2] = skip_prob;
241
242 skip_prob = t * 5 / 4;
243 if (skip_prob < 1)
244 skip_prob = 1;
245 else if (skip_prob > 255)
246 skip_prob = 255;
247 base_skip_false_prob[i][0] = skip_prob;
248 } 230 }
249 } 231 }
250 232
251 static void update_base_skip_probs(VP9_COMP *cpi) { 233 static void update_base_skip_probs(VP9_COMP *cpi) {
252 VP9_COMMON *cm = &cpi->common; 234 VP9_COMMON *cm = &cpi->common;
253 235
254 if (cm->frame_type != KEY_FRAME) { 236 if (cm->frame_type != KEY_FRAME) {
255 vp9_update_skip_probs(cpi); 237 vp9_update_skip_probs(cpi);
256 238
257 if (cm->refresh_alt_ref_frame) { 239 if (cm->refresh_alt_ref_frame) {
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 map_index++; 548 map_index++;
567 } 549 }
568 fprintf(statsfile, "\n"); 550 fprintf(statsfile, "\n");
569 } 551 }
570 fprintf(statsfile, "\n"); 552 fprintf(statsfile, "\n");
571 553
572 fclose(statsfile); 554 fclose(statsfile);
573 } 555 }
574 556
575 static void update_reference_segmentation_map(VP9_COMP *cpi) { 557 static void update_reference_segmentation_map(VP9_COMP *cpi) {
576 VP9_COMMON *cm = &cpi->common; 558 VP9_COMMON *const cm = &cpi->common;
577 int row, col, sb_rows = (cm->mb_rows + 1) >> 1, sb_cols = (cm->mb_cols + 1) >> 1; 559 int row, col;
578 MODE_INFO *mi = cm->mi; 560 MODE_INFO *mi, *mi_ptr = cm->mi;
579 uint8_t *segmap = cpi->segmentation_map; 561 uint8_t *cache_ptr = cm->last_frame_seg_map, *cache;
580 uint8_t *segcache = cm->last_frame_seg_map;
581 562
582 for (row = 0; row < sb_rows; row++) { 563 for (row = 0; row < cm->mb_rows; row++) {
583 for (col = 0; col < sb_cols; col++) { 564 mi = mi_ptr;
584 MODE_INFO *miptr = mi + col * 2; 565 cache = cache_ptr;
585 uint8_t *cache = segcache + col * 2; 566 for (col = 0; col < cm->mb_cols; col++, mi++, cache++) {
586 #if CONFIG_SUPERBLOCKS 567 cache[0] = mi->mbmi.segment_id;
587 if (miptr->mbmi.encoded_as_sb) {
588 cache[0] = miptr->mbmi.segment_id;
589 if (!(cm->mb_cols & 1) || col < sb_cols - 1)
590 cache[1] = miptr->mbmi.segment_id;
591 if (!(cm->mb_rows & 1) || row < sb_rows - 1) {
592 cache[cm->mb_cols] = miptr->mbmi.segment_id;
593 if (!(cm->mb_cols & 1) || col < sb_cols - 1)
594 cache[cm->mb_cols + 1] = miptr->mbmi.segment_id;
595 }
596 } else
597 #endif
598 {
599 cache[0] = miptr[0].mbmi.segment_id;
600 if (!(cm->mb_cols & 1) || col < sb_cols - 1)
601 cache[1] = miptr[1].mbmi.segment_id;
602 if (!(cm->mb_rows & 1) || row < sb_rows - 1) {
603 cache[cm->mb_cols] = miptr[cm->mode_info_stride].mbmi.segment_id;
604 if (!(cm->mb_cols & 1) || col < sb_cols - 1)
605 cache[1] = miptr[1].mbmi.segment_id;
606 cache[cm->mb_cols + 1] = miptr[cm->mode_info_stride + 1].mbmi.segment_ id;
607 }
608 }
609 } 568 }
610 segmap += 2 * cm->mb_cols; 569 mi_ptr += cm->mode_info_stride;
611 segcache += 2 * cm->mb_cols; 570 cache_ptr += cm->mb_cols;
612 mi += 2 * cm->mode_info_stride;
613 } 571 }
614 } 572 }
615 573
616 static void set_default_lf_deltas(VP9_COMP *cpi) { 574 static void set_default_lf_deltas(VP9_COMP *cpi) {
617 cpi->mb.e_mbd.mode_ref_lf_delta_enabled = 1; 575 cpi->mb.e_mbd.mode_ref_lf_delta_enabled = 1;
618 cpi->mb.e_mbd.mode_ref_lf_delta_update = 1; 576 cpi->mb.e_mbd.mode_ref_lf_delta_update = 1;
619 577
620 vpx_memset(cpi->mb.e_mbd.ref_lf_deltas, 0, sizeof(cpi->mb.e_mbd.ref_lf_deltas) ); 578 vpx_memset(cpi->mb.e_mbd.ref_lf_deltas, 0, sizeof(cpi->mb.e_mbd.ref_lf_deltas) );
621 vpx_memset(cpi->mb.e_mbd.mode_lf_deltas, 0, sizeof(cpi->mb.e_mbd.mode_lf_delta s)); 579 vpx_memset(cpi->mb.e_mbd.mode_lf_deltas, 0, sizeof(cpi->mb.e_mbd.mode_lf_delta s));
622 580
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 sf->iterative_sub_pixel = 1; 619 sf->iterative_sub_pixel = 1;
662 #if CONFIG_LOSSLESS 620 #if CONFIG_LOSSLESS
663 sf->optimize_coefficients = 0; 621 sf->optimize_coefficients = 0;
664 #else 622 #else
665 sf->optimize_coefficients = 1; 623 sf->optimize_coefficients = 1;
666 #endif 624 #endif
667 sf->no_skip_block4x4_search = 1; 625 sf->no_skip_block4x4_search = 1;
668 626
669 sf->first_step = 0; 627 sf->first_step = 0;
670 sf->max_step_search_steps = MAX_MVSEARCH_STEPS; 628 sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
671 sf->improved_mv_pred = 1;
672 629
673 // default thresholds to 0 630 // default thresholds to 0
674 for (i = 0; i < MAX_MODES; i++) 631 for (i = 0; i < MAX_MODES; i++)
675 sf->thresh_mult[i] = 0; 632 sf->thresh_mult[i] = 0;
676 633
677 switch (Mode) { 634 switch (Mode) {
678 case 0: // best quality mode 635 case 0: // best quality mode
679 #if CONFIG_PRED_FILTER
680 sf->thresh_mult[THR_ZEROMV ] = 0;
681 sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
682 sf->thresh_mult[THR_ZEROG ] = 0;
683 sf->thresh_mult[THR_ZEROG_FILT ] = 0;
684 sf->thresh_mult[THR_ZEROA ] = 0;
685 sf->thresh_mult[THR_ZEROA_FILT ] = 0;
686 sf->thresh_mult[THR_NEARESTMV ] = 0;
687 sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
688 sf->thresh_mult[THR_NEARESTG ] = 0;
689 sf->thresh_mult[THR_NEARESTG_FILT ] = 0;
690 sf->thresh_mult[THR_NEARESTA ] = 0;
691 sf->thresh_mult[THR_NEARESTA_FILT ] = 0;
692 sf->thresh_mult[THR_NEARMV ] = 0;
693 sf->thresh_mult[THR_NEARMV_FILT ] = 0;
694 sf->thresh_mult[THR_NEARG ] = 0;
695 sf->thresh_mult[THR_NEARG_FILT ] = 0;
696 sf->thresh_mult[THR_NEARA ] = 0;
697 sf->thresh_mult[THR_NEARA_FILT ] = 0;
698
699 sf->thresh_mult[THR_DC ] = 0;
700
701 sf->thresh_mult[THR_V_PRED ] = 1000;
702 sf->thresh_mult[THR_H_PRED ] = 1000;
703 sf->thresh_mult[THR_D45_PRED ] = 1000;
704 sf->thresh_mult[THR_D135_PRED] = 1000;
705 sf->thresh_mult[THR_D117_PRED] = 1000;
706 sf->thresh_mult[THR_D153_PRED] = 1000;
707 sf->thresh_mult[THR_D27_PRED ] = 1000;
708 sf->thresh_mult[THR_D63_PRED ] = 1000;
709 sf->thresh_mult[THR_B_PRED ] = 2000;
710 sf->thresh_mult[THR_I8X8_PRED] = 2000;
711 sf->thresh_mult[THR_TM ] = 1000;
712
713 sf->thresh_mult[THR_NEWMV ] = 1000;
714 sf->thresh_mult[THR_NEWG ] = 1000;
715 sf->thresh_mult[THR_NEWA ] = 1000;
716 sf->thresh_mult[THR_NEWMV_FILT ] = 1000;
717 sf->thresh_mult[THR_NEWG_FILT ] = 1000;
718 sf->thresh_mult[THR_NEWA_FILT ] = 1000;
719 #else
720 sf->thresh_mult[THR_ZEROMV ] = 0; 636 sf->thresh_mult[THR_ZEROMV ] = 0;
721 sf->thresh_mult[THR_ZEROG ] = 0; 637 sf->thresh_mult[THR_ZEROG ] = 0;
722 sf->thresh_mult[THR_ZEROA ] = 0; 638 sf->thresh_mult[THR_ZEROA ] = 0;
723 sf->thresh_mult[THR_NEARESTMV] = 0; 639 sf->thresh_mult[THR_NEARESTMV] = 0;
724 sf->thresh_mult[THR_NEARESTG ] = 0; 640 sf->thresh_mult[THR_NEARESTG ] = 0;
725 sf->thresh_mult[THR_NEARESTA ] = 0; 641 sf->thresh_mult[THR_NEARESTA ] = 0;
726 sf->thresh_mult[THR_NEARMV ] = 0; 642 sf->thresh_mult[THR_NEARMV ] = 0;
727 sf->thresh_mult[THR_NEARG ] = 0; 643 sf->thresh_mult[THR_NEARG ] = 0;
728 sf->thresh_mult[THR_NEARA ] = 0; 644 sf->thresh_mult[THR_NEARA ] = 0;
729 645
730 sf->thresh_mult[THR_DC ] = 0; 646 sf->thresh_mult[THR_DC ] = 0;
731 647
732 sf->thresh_mult[THR_V_PRED ] = 1000; 648 sf->thresh_mult[THR_V_PRED ] = 1000;
733 sf->thresh_mult[THR_H_PRED ] = 1000; 649 sf->thresh_mult[THR_H_PRED ] = 1000;
734 sf->thresh_mult[THR_D45_PRED ] = 1000; 650 sf->thresh_mult[THR_D45_PRED ] = 1000;
735 sf->thresh_mult[THR_D135_PRED] = 1000; 651 sf->thresh_mult[THR_D135_PRED] = 1000;
736 sf->thresh_mult[THR_D117_PRED] = 1000; 652 sf->thresh_mult[THR_D117_PRED] = 1000;
737 sf->thresh_mult[THR_D153_PRED] = 1000; 653 sf->thresh_mult[THR_D153_PRED] = 1000;
738 sf->thresh_mult[THR_D27_PRED ] = 1000; 654 sf->thresh_mult[THR_D27_PRED ] = 1000;
739 sf->thresh_mult[THR_D63_PRED ] = 1000; 655 sf->thresh_mult[THR_D63_PRED ] = 1000;
740 sf->thresh_mult[THR_B_PRED ] = 2000; 656 sf->thresh_mult[THR_B_PRED ] = 2000;
741 sf->thresh_mult[THR_I8X8_PRED] = 2000; 657 sf->thresh_mult[THR_I8X8_PRED] = 2000;
742 sf->thresh_mult[THR_TM ] = 1000; 658 sf->thresh_mult[THR_TM ] = 1000;
743 659
744 sf->thresh_mult[THR_NEWMV ] = 1000; 660 sf->thresh_mult[THR_NEWMV ] = 1000;
745 sf->thresh_mult[THR_NEWG ] = 1000; 661 sf->thresh_mult[THR_NEWG ] = 1000;
746 sf->thresh_mult[THR_NEWA ] = 1000; 662 sf->thresh_mult[THR_NEWA ] = 1000;
747 #endif 663
748 sf->thresh_mult[THR_SPLITMV ] = 2500; 664 sf->thresh_mult[THR_SPLITMV ] = 2500;
749 sf->thresh_mult[THR_SPLITG ] = 5000; 665 sf->thresh_mult[THR_SPLITG ] = 5000;
750 sf->thresh_mult[THR_SPLITA ] = 5000; 666 sf->thresh_mult[THR_SPLITA ] = 5000;
751 667
752 sf->thresh_mult[THR_COMP_ZEROLG ] = 0; 668 sf->thresh_mult[THR_COMP_ZEROLG ] = 0;
753 sf->thresh_mult[THR_COMP_NEARESTLG] = 0; 669 sf->thresh_mult[THR_COMP_NEARESTLG] = 0;
754 sf->thresh_mult[THR_COMP_NEARLG ] = 0; 670 sf->thresh_mult[THR_COMP_NEARLG ] = 0;
755 sf->thresh_mult[THR_COMP_ZEROLA ] = 0; 671 sf->thresh_mult[THR_COMP_ZEROLA ] = 0;
756 sf->thresh_mult[THR_COMP_NEARESTLA] = 0; 672 sf->thresh_mult[THR_COMP_NEARESTLA] = 0;
757 sf->thresh_mult[THR_COMP_NEARLA ] = 0; 673 sf->thresh_mult[THR_COMP_NEARLA ] = 0;
(...skipping 22 matching lines...) Expand all
780 sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] = 0; 696 sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] = 0;
781 sf->thresh_mult[THR_COMP_INTERINTRA_NEARA ] = 0; 697 sf->thresh_mult[THR_COMP_INTERINTRA_NEARA ] = 0;
782 sf->thresh_mult[THR_COMP_INTERINTRA_NEWA ] = 0; 698 sf->thresh_mult[THR_COMP_INTERINTRA_NEWA ] = 0;
783 #endif 699 #endif
784 700
785 sf->first_step = 0; 701 sf->first_step = 0;
786 sf->max_step_search_steps = MAX_MVSEARCH_STEPS; 702 sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
787 sf->search_best_filter = SEARCH_BEST_FILTER; 703 sf->search_best_filter = SEARCH_BEST_FILTER;
788 break; 704 break;
789 case 1: 705 case 1:
790 #if CONFIG_PRED_FILTER
791 sf->thresh_mult[THR_NEARESTMV] = 0; 706 sf->thresh_mult[THR_NEARESTMV] = 0;
792 sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
793 sf->thresh_mult[THR_ZEROMV ] = 0; 707 sf->thresh_mult[THR_ZEROMV ] = 0;
794 sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
795 sf->thresh_mult[THR_DC ] = 0; 708 sf->thresh_mult[THR_DC ] = 0;
796 sf->thresh_mult[THR_NEARMV ] = 0; 709 sf->thresh_mult[THR_NEARMV ] = 0;
797 sf->thresh_mult[THR_NEARMV_FILT ] = 0;
798 sf->thresh_mult[THR_V_PRED ] = 1000; 710 sf->thresh_mult[THR_V_PRED ] = 1000;
799 sf->thresh_mult[THR_H_PRED ] = 1000; 711 sf->thresh_mult[THR_H_PRED ] = 1000;
800 sf->thresh_mult[THR_D45_PRED ] = 1000; 712 sf->thresh_mult[THR_D45_PRED ] = 1000;
801 sf->thresh_mult[THR_D135_PRED] = 1000; 713 sf->thresh_mult[THR_D135_PRED] = 1000;
802 sf->thresh_mult[THR_D117_PRED] = 1000; 714 sf->thresh_mult[THR_D117_PRED] = 1000;
803 sf->thresh_mult[THR_D153_PRED] = 1000; 715 sf->thresh_mult[THR_D153_PRED] = 1000;
804 sf->thresh_mult[THR_D27_PRED ] = 1000; 716 sf->thresh_mult[THR_D27_PRED ] = 1000;
805 sf->thresh_mult[THR_D63_PRED ] = 1000; 717 sf->thresh_mult[THR_D63_PRED ] = 1000;
806 sf->thresh_mult[THR_B_PRED ] = 2500; 718 sf->thresh_mult[THR_B_PRED ] = 2500;
807 sf->thresh_mult[THR_I8X8_PRED] = 2500; 719 sf->thresh_mult[THR_I8X8_PRED] = 2500;
808 sf->thresh_mult[THR_TM ] = 1000; 720 sf->thresh_mult[THR_TM ] = 1000;
809 721
810 sf->thresh_mult[THR_NEARESTG ] = 1000; 722 sf->thresh_mult[THR_NEARESTG ] = 1000;
811 sf->thresh_mult[THR_NEARESTG_FILT ] = 1000;
812 sf->thresh_mult[THR_NEARESTA ] = 1000; 723 sf->thresh_mult[THR_NEARESTA ] = 1000;
813 sf->thresh_mult[THR_NEARESTA_FILT ] = 1000;
814 724
815 sf->thresh_mult[THR_ZEROG ] = 1000; 725 sf->thresh_mult[THR_ZEROG ] = 1000;
816 sf->thresh_mult[THR_ZEROA ] = 1000; 726 sf->thresh_mult[THR_ZEROA ] = 1000;
817 sf->thresh_mult[THR_NEARG ] = 1000; 727 sf->thresh_mult[THR_NEARG ] = 1000;
818 sf->thresh_mult[THR_NEARA ] = 1000; 728 sf->thresh_mult[THR_NEARA ] = 1000;
819 sf->thresh_mult[THR_ZEROG_FILT ] = 1000;
820 sf->thresh_mult[THR_ZEROA_FILT ] = 1000;
821 sf->thresh_mult[THR_NEARG_FILT ] = 1000;
822 sf->thresh_mult[THR_NEARA_FILT ] = 1000;
823 729
824 sf->thresh_mult[THR_ZEROMV ] = 0; 730 sf->thresh_mult[THR_ZEROMV ] = 0;
825 sf->thresh_mult[THR_ZEROG ] = 0; 731 sf->thresh_mult[THR_ZEROG ] = 0;
826 sf->thresh_mult[THR_ZEROA ] = 0; 732 sf->thresh_mult[THR_ZEROA ] = 0;
827 sf->thresh_mult[THR_NEARESTMV] = 0; 733 sf->thresh_mult[THR_NEARESTMV] = 0;
828 sf->thresh_mult[THR_NEARESTG ] = 0; 734 sf->thresh_mult[THR_NEARESTG ] = 0;
829 sf->thresh_mult[THR_NEARESTA ] = 0; 735 sf->thresh_mult[THR_NEARESTA ] = 0;
830 sf->thresh_mult[THR_NEARMV ] = 0; 736 sf->thresh_mult[THR_NEARMV ] = 0;
831 sf->thresh_mult[THR_NEARG ] = 0; 737 sf->thresh_mult[THR_NEARG ] = 0;
832 sf->thresh_mult[THR_NEARA ] = 0; 738 sf->thresh_mult[THR_NEARA ] = 0;
833 sf->thresh_mult[THR_ZEROMV_FILT ] = 0;
834 sf->thresh_mult[THR_ZEROG_FILT ] = 0;
835 sf->thresh_mult[THR_ZEROA_FILT ] = 0;
836 sf->thresh_mult[THR_NEARESTMV_FILT] = 0;
837 sf->thresh_mult[THR_NEARESTG_FILT ] = 0;
838 sf->thresh_mult[THR_NEARESTA_FILT ] = 0;
839 sf->thresh_mult[THR_NEARMV_FILT ] = 0;
840 sf->thresh_mult[THR_NEARG_FILT ] = 0;
841 sf->thresh_mult[THR_NEARA_FILT ] = 0;
842
843 sf->thresh_mult[THR_NEWMV ] = 1000;
844 sf->thresh_mult[THR_NEWG ] = 1000;
845 sf->thresh_mult[THR_NEWA ] = 1000;
846 sf->thresh_mult[THR_NEWMV_FILT ] = 1000;
847 sf->thresh_mult[THR_NEWG_FILT ] = 1000;
848 sf->thresh_mult[THR_NEWA_FILT ] = 1000;
849 #else
850 sf->thresh_mult[THR_NEARESTMV] = 0;
851 sf->thresh_mult[THR_ZEROMV ] = 0;
852 sf->thresh_mult[THR_DC ] = 0;
853 sf->thresh_mult[THR_NEARMV ] = 0;
854 sf->thresh_mult[THR_V_PRED ] = 1000;
855 sf->thresh_mult[THR_H_PRED ] = 1000;
856 sf->thresh_mult[THR_D45_PRED ] = 1000;
857 sf->thresh_mult[THR_D135_PRED] = 1000;
858 sf->thresh_mult[THR_D117_PRED] = 1000;
859 sf->thresh_mult[THR_D153_PRED] = 1000;
860 sf->thresh_mult[THR_D27_PRED ] = 1000;
861 sf->thresh_mult[THR_D63_PRED ] = 1000;
862 sf->thresh_mult[THR_B_PRED ] = 2500;
863 sf->thresh_mult[THR_I8X8_PRED] = 2500;
864 sf->thresh_mult[THR_TM ] = 1000;
865
866 sf->thresh_mult[THR_NEARESTG ] = 1000;
867 sf->thresh_mult[THR_NEARESTA ] = 1000;
868
869 sf->thresh_mult[THR_ZEROG ] = 1000;
870 sf->thresh_mult[THR_ZEROA ] = 1000;
871 sf->thresh_mult[THR_NEARG ] = 1000;
872 sf->thresh_mult[THR_NEARA ] = 1000;
873
874 sf->thresh_mult[THR_ZEROMV ] = 0;
875 sf->thresh_mult[THR_ZEROG ] = 0;
876 sf->thresh_mult[THR_ZEROA ] = 0;
877 sf->thresh_mult[THR_NEARESTMV] = 0;
878 sf->thresh_mult[THR_NEARESTG ] = 0;
879 sf->thresh_mult[THR_NEARESTA ] = 0;
880 sf->thresh_mult[THR_NEARMV ] = 0;
881 sf->thresh_mult[THR_NEARG ] = 0;
882 sf->thresh_mult[THR_NEARA ] = 0;
883 739
884 sf->thresh_mult[THR_NEWMV ] = 1000; 740 sf->thresh_mult[THR_NEWMV ] = 1000;
885 sf->thresh_mult[THR_NEWG ] = 1000; 741 sf->thresh_mult[THR_NEWG ] = 1000;
886 sf->thresh_mult[THR_NEWA ] = 1000; 742 sf->thresh_mult[THR_NEWA ] = 1000;
887 #endif 743
888 sf->thresh_mult[THR_SPLITMV ] = 1700; 744 sf->thresh_mult[THR_SPLITMV ] = 1700;
889 sf->thresh_mult[THR_SPLITG ] = 4500; 745 sf->thresh_mult[THR_SPLITG ] = 4500;
890 sf->thresh_mult[THR_SPLITA ] = 4500; 746 sf->thresh_mult[THR_SPLITA ] = 4500;
891 747
892 sf->thresh_mult[THR_COMP_ZEROLG ] = 0; 748 sf->thresh_mult[THR_COMP_ZEROLG ] = 0;
893 sf->thresh_mult[THR_COMP_NEARESTLG] = 0; 749 sf->thresh_mult[THR_COMP_NEARESTLG] = 0;
894 sf->thresh_mult[THR_COMP_NEARLG ] = 0; 750 sf->thresh_mult[THR_COMP_NEARLG ] = 0;
895 sf->thresh_mult[THR_COMP_ZEROLA ] = 0; 751 sf->thresh_mult[THR_COMP_ZEROLA ] = 0;
896 sf->thresh_mult[THR_COMP_NEARESTLA] = 0; 752 sf->thresh_mult[THR_COMP_NEARESTLA] = 0;
897 sf->thresh_mult[THR_COMP_NEARLA ] = 0; 753 sf->thresh_mult[THR_COMP_NEARLA ] = 0;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 sf->thresh_mult[THR_D135_PRED] = 1500; 809 sf->thresh_mult[THR_D135_PRED] = 1500;
954 sf->thresh_mult[THR_D117_PRED] = 1500; 810 sf->thresh_mult[THR_D117_PRED] = 1500;
955 sf->thresh_mult[THR_D153_PRED] = 1500; 811 sf->thresh_mult[THR_D153_PRED] = 1500;
956 sf->thresh_mult[THR_D27_PRED ] = 1500; 812 sf->thresh_mult[THR_D27_PRED ] = 1500;
957 sf->thresh_mult[THR_D63_PRED ] = 1500; 813 sf->thresh_mult[THR_D63_PRED ] = 1500;
958 sf->thresh_mult[THR_B_PRED ] = 5000; 814 sf->thresh_mult[THR_B_PRED ] = 5000;
959 sf->thresh_mult[THR_I8X8_PRED] = 5000; 815 sf->thresh_mult[THR_I8X8_PRED] = 5000;
960 816
961 if (cpi->ref_frame_flags & VP9_LAST_FLAG) { 817 if (cpi->ref_frame_flags & VP9_LAST_FLAG) {
962 sf->thresh_mult[THR_NEWMV ] = 2000; 818 sf->thresh_mult[THR_NEWMV ] = 2000;
963 #if CONFIG_PRED_FILTER
964 sf->thresh_mult[THR_NEWMV_FILT ] = 2000;
965 #endif
966 sf->thresh_mult[THR_SPLITMV ] = 10000; 819 sf->thresh_mult[THR_SPLITMV ] = 10000;
967 sf->thresh_mult[THR_COMP_SPLITLG ] = 20000; 820 sf->thresh_mult[THR_COMP_SPLITLG ] = 20000;
968 } 821 }
969 822
970 if (cpi->ref_frame_flags & VP9_GOLD_FLAG) { 823 if (cpi->ref_frame_flags & VP9_GOLD_FLAG) {
971 sf->thresh_mult[THR_NEARESTG ] = 1500; 824 sf->thresh_mult[THR_NEARESTG ] = 1500;
972 sf->thresh_mult[THR_ZEROG ] = 1500; 825 sf->thresh_mult[THR_ZEROG ] = 1500;
973 sf->thresh_mult[THR_NEARG ] = 1500; 826 sf->thresh_mult[THR_NEARG ] = 1500;
974 sf->thresh_mult[THR_NEWG ] = 2000; 827 sf->thresh_mult[THR_NEWG ] = 2000;
975 #if CONFIG_PRED_FILTER
976 sf->thresh_mult[THR_NEARESTG_FILT ] = 1500;
977 sf->thresh_mult[THR_ZEROG_FILT ] = 1500;
978 sf->thresh_mult[THR_NEARG_FILT ] = 1500;
979 sf->thresh_mult[THR_NEWG_FILT ] = 2000;
980 #endif
981 sf->thresh_mult[THR_SPLITG ] = 20000; 828 sf->thresh_mult[THR_SPLITG ] = 20000;
982 sf->thresh_mult[THR_COMP_SPLITGA ] = 20000; 829 sf->thresh_mult[THR_COMP_SPLITGA ] = 20000;
983 } 830 }
984 831
985 if (cpi->ref_frame_flags & VP9_ALT_FLAG) { 832 if (cpi->ref_frame_flags & VP9_ALT_FLAG) {
986 sf->thresh_mult[THR_NEARESTA ] = 1500; 833 sf->thresh_mult[THR_NEARESTA ] = 1500;
987 sf->thresh_mult[THR_ZEROA ] = 1500; 834 sf->thresh_mult[THR_ZEROA ] = 1500;
988 sf->thresh_mult[THR_NEARA ] = 1500; 835 sf->thresh_mult[THR_NEARA ] = 1500;
989 sf->thresh_mult[THR_NEWA ] = 2000; 836 sf->thresh_mult[THR_NEWA ] = 2000;
990 #if CONFIG_PRED_FILTER
991 sf->thresh_mult[THR_NEARESTA_FILT ] = 1500;
992 sf->thresh_mult[THR_ZEROA_FILT ] = 1500;
993 sf->thresh_mult[THR_NEARA_FILT ] = 1500;
994 sf->thresh_mult[THR_NEWA_FILT ] = 2000;
995 #endif
996 sf->thresh_mult[THR_SPLITA ] = 20000; 837 sf->thresh_mult[THR_SPLITA ] = 20000;
997 sf->thresh_mult[THR_COMP_SPLITLA ] = 10000; 838 sf->thresh_mult[THR_COMP_SPLITLA ] = 10000;
998 } 839 }
999 840
1000 sf->thresh_mult[THR_COMP_ZEROLG ] = 1500; 841 sf->thresh_mult[THR_COMP_ZEROLG ] = 1500;
1001 sf->thresh_mult[THR_COMP_NEARESTLG] = 1500; 842 sf->thresh_mult[THR_COMP_NEARESTLG] = 1500;
1002 sf->thresh_mult[THR_COMP_NEARLG ] = 1500; 843 sf->thresh_mult[THR_COMP_NEARLG ] = 1500;
1003 sf->thresh_mult[THR_COMP_ZEROLA ] = 1500; 844 sf->thresh_mult[THR_COMP_ZEROLA ] = 1500;
1004 sf->thresh_mult[THR_COMP_NEARESTLA] = 1500; 845 sf->thresh_mult[THR_COMP_NEARESTLA] = 1500;
1005 sf->thresh_mult[THR_COMP_NEARLA ] = 1500; 846 sf->thresh_mult[THR_COMP_NEARLA ] = 1500;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 sf->thresh_mult[THR_D135_PRED] = 2000; 883 sf->thresh_mult[THR_D135_PRED] = 2000;
1043 sf->thresh_mult[THR_D117_PRED] = 2000; 884 sf->thresh_mult[THR_D117_PRED] = 2000;
1044 sf->thresh_mult[THR_D153_PRED] = 2000; 885 sf->thresh_mult[THR_D153_PRED] = 2000;
1045 sf->thresh_mult[THR_D27_PRED ] = 2000; 886 sf->thresh_mult[THR_D27_PRED ] = 2000;
1046 sf->thresh_mult[THR_D63_PRED ] = 2000; 887 sf->thresh_mult[THR_D63_PRED ] = 2000;
1047 sf->thresh_mult[THR_B_PRED ] = 7500; 888 sf->thresh_mult[THR_B_PRED ] = 7500;
1048 sf->thresh_mult[THR_I8X8_PRED] = 7500; 889 sf->thresh_mult[THR_I8X8_PRED] = 7500;
1049 890
1050 if (cpi->ref_frame_flags & VP9_LAST_FLAG) { 891 if (cpi->ref_frame_flags & VP9_LAST_FLAG) {
1051 sf->thresh_mult[THR_NEWMV ] = 2000; 892 sf->thresh_mult[THR_NEWMV ] = 2000;
1052 #if CONFIG_PRED_FILTER
1053 sf->thresh_mult[THR_NEWMV_FILT ] = 2000;
1054 #endif
1055 sf->thresh_mult[THR_SPLITMV ] = 25000; 893 sf->thresh_mult[THR_SPLITMV ] = 25000;
1056 sf->thresh_mult[THR_COMP_SPLITLG ] = 50000; 894 sf->thresh_mult[THR_COMP_SPLITLG ] = 50000;
1057 } 895 }
1058 896
1059 if (cpi->ref_frame_flags & VP9_GOLD_FLAG) { 897 if (cpi->ref_frame_flags & VP9_GOLD_FLAG) {
1060 sf->thresh_mult[THR_NEARESTG ] = 2000; 898 sf->thresh_mult[THR_NEARESTG ] = 2000;
1061 sf->thresh_mult[THR_ZEROG ] = 2000; 899 sf->thresh_mult[THR_ZEROG ] = 2000;
1062 sf->thresh_mult[THR_NEARG ] = 2000; 900 sf->thresh_mult[THR_NEARG ] = 2000;
1063 sf->thresh_mult[THR_NEWG ] = 2500; 901 sf->thresh_mult[THR_NEWG ] = 2500;
1064 #if CONFIG_PRED_FILTER
1065 sf->thresh_mult[THR_NEARESTG_FILT ] = 2000;
1066 sf->thresh_mult[THR_ZEROG_FILT ] = 2000;
1067 sf->thresh_mult[THR_NEARG_FILT ] = 2000;
1068 sf->thresh_mult[THR_NEWG_FILT ] = 2500;
1069 #endif
1070 sf->thresh_mult[THR_SPLITG ] = 50000; 902 sf->thresh_mult[THR_SPLITG ] = 50000;
1071 sf->thresh_mult[THR_COMP_SPLITGA ] = 50000; 903 sf->thresh_mult[THR_COMP_SPLITGA ] = 50000;
1072 } 904 }
1073 905
1074 if (cpi->ref_frame_flags & VP9_ALT_FLAG) { 906 if (cpi->ref_frame_flags & VP9_ALT_FLAG) {
1075 sf->thresh_mult[THR_NEARESTA ] = 2000; 907 sf->thresh_mult[THR_NEARESTA ] = 2000;
1076 sf->thresh_mult[THR_ZEROA ] = 2000; 908 sf->thresh_mult[THR_ZEROA ] = 2000;
1077 sf->thresh_mult[THR_NEARA ] = 2000; 909 sf->thresh_mult[THR_NEARA ] = 2000;
1078 sf->thresh_mult[THR_NEWA ] = 2500; 910 sf->thresh_mult[THR_NEWA ] = 2500;
1079 #if CONFIG_PRED_FILTER
1080 sf->thresh_mult[THR_NEARESTA_FILT ] = 2000;
1081 sf->thresh_mult[THR_ZEROA_FILT ] = 2000;
1082 sf->thresh_mult[THR_NEARA_FILT ] = 2000;
1083 sf->thresh_mult[THR_NEWA_FILT ] = 2500;
1084 #endif
1085 sf->thresh_mult[THR_SPLITA ] = 50000; 911 sf->thresh_mult[THR_SPLITA ] = 50000;
1086 sf->thresh_mult[THR_COMP_SPLITLA ] = 25000; 912 sf->thresh_mult[THR_COMP_SPLITLA ] = 25000;
1087 } 913 }
1088 914
1089 sf->thresh_mult[THR_COMP_ZEROLG ] = 2000; 915 sf->thresh_mult[THR_COMP_ZEROLG ] = 2000;
1090 sf->thresh_mult[THR_COMP_NEARESTLG] = 2000; 916 sf->thresh_mult[THR_COMP_NEARESTLG] = 2000;
1091 sf->thresh_mult[THR_COMP_NEARLG ] = 2000; 917 sf->thresh_mult[THR_COMP_NEARLG ] = 2000;
1092 sf->thresh_mult[THR_COMP_ZEROLA ] = 2000; 918 sf->thresh_mult[THR_COMP_ZEROLA ] = 2000;
1093 sf->thresh_mult[THR_COMP_NEARESTLA] = 2000; 919 sf->thresh_mult[THR_COMP_NEARESTLA] = 2000;
1094 sf->thresh_mult[THR_COMP_NEARLA ] = 2000; 920 sf->thresh_mult[THR_COMP_NEARLA ] = 2000;
(...skipping 30 matching lines...) Expand all
1125 break; 951 break;
1126 952
1127 }; /* switch */ 953 }; /* switch */
1128 954
1129 /* disable frame modes if flags not set */ 955 /* disable frame modes if flags not set */
1130 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) { 956 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) {
1131 sf->thresh_mult[THR_NEWMV ] = INT_MAX; 957 sf->thresh_mult[THR_NEWMV ] = INT_MAX;
1132 sf->thresh_mult[THR_NEARESTMV] = INT_MAX; 958 sf->thresh_mult[THR_NEARESTMV] = INT_MAX;
1133 sf->thresh_mult[THR_ZEROMV ] = INT_MAX; 959 sf->thresh_mult[THR_ZEROMV ] = INT_MAX;
1134 sf->thresh_mult[THR_NEARMV ] = INT_MAX; 960 sf->thresh_mult[THR_NEARMV ] = INT_MAX;
1135 #if CONFIG_PRED_FILTER
1136 sf->thresh_mult[THR_NEWMV_FILT ] = INT_MAX;
1137 sf->thresh_mult[THR_NEARESTMV_FILT] = INT_MAX;
1138 sf->thresh_mult[THR_ZEROMV_FILT ] = INT_MAX;
1139 sf->thresh_mult[THR_NEARMV_FILT ] = INT_MAX;
1140 #endif
1141 sf->thresh_mult[THR_SPLITMV ] = INT_MAX; 961 sf->thresh_mult[THR_SPLITMV ] = INT_MAX;
1142 } 962 }
1143 963
1144 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) { 964 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) {
1145 sf->thresh_mult[THR_NEARESTG ] = INT_MAX; 965 sf->thresh_mult[THR_NEARESTG ] = INT_MAX;
1146 sf->thresh_mult[THR_ZEROG ] = INT_MAX; 966 sf->thresh_mult[THR_ZEROG ] = INT_MAX;
1147 sf->thresh_mult[THR_NEARG ] = INT_MAX; 967 sf->thresh_mult[THR_NEARG ] = INT_MAX;
1148 sf->thresh_mult[THR_NEWG ] = INT_MAX; 968 sf->thresh_mult[THR_NEWG ] = INT_MAX;
1149 #if CONFIG_PRED_FILTER
1150 sf->thresh_mult[THR_NEARESTG_FILT ] = INT_MAX;
1151 sf->thresh_mult[THR_ZEROG_FILT ] = INT_MAX;
1152 sf->thresh_mult[THR_NEARG_FILT ] = INT_MAX;
1153 sf->thresh_mult[THR_NEWG_FILT ] = INT_MAX;
1154 #endif
1155 #if CONFIG_COMP_INTERINTRA_PRED 969 #if CONFIG_COMP_INTERINTRA_PRED
1156 sf->thresh_mult[THR_COMP_INTERINTRA_ZEROG ] = INT_MAX; 970 sf->thresh_mult[THR_COMP_INTERINTRA_ZEROG ] = INT_MAX;
1157 sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] = INT_MAX; 971 sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTG] = INT_MAX;
1158 sf->thresh_mult[THR_COMP_INTERINTRA_NEARG ] = INT_MAX; 972 sf->thresh_mult[THR_COMP_INTERINTRA_NEARG ] = INT_MAX;
1159 sf->thresh_mult[THR_COMP_INTERINTRA_NEWG ] = INT_MAX; 973 sf->thresh_mult[THR_COMP_INTERINTRA_NEWG ] = INT_MAX;
1160 #endif 974 #endif
1161 sf->thresh_mult[THR_SPLITG ] = INT_MAX; 975 sf->thresh_mult[THR_SPLITG ] = INT_MAX;
1162 } 976 }
1163 977
1164 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) { 978 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) {
1165 sf->thresh_mult[THR_NEARESTA ] = INT_MAX; 979 sf->thresh_mult[THR_NEARESTA ] = INT_MAX;
1166 sf->thresh_mult[THR_ZEROA ] = INT_MAX; 980 sf->thresh_mult[THR_ZEROA ] = INT_MAX;
1167 sf->thresh_mult[THR_NEARA ] = INT_MAX; 981 sf->thresh_mult[THR_NEARA ] = INT_MAX;
1168 sf->thresh_mult[THR_NEWA ] = INT_MAX; 982 sf->thresh_mult[THR_NEWA ] = INT_MAX;
1169 #if CONFIG_PRED_FILTER
1170 sf->thresh_mult[THR_NEARESTA_FILT ] = INT_MAX;
1171 sf->thresh_mult[THR_ZEROA_FILT ] = INT_MAX;
1172 sf->thresh_mult[THR_NEARA_FILT ] = INT_MAX;
1173 sf->thresh_mult[THR_NEWA_FILT ] = INT_MAX;
1174 #endif
1175 #if CONFIG_COMP_INTERINTRA_PRED 983 #if CONFIG_COMP_INTERINTRA_PRED
1176 sf->thresh_mult[THR_COMP_INTERINTRA_ZEROA ] = INT_MAX; 984 sf->thresh_mult[THR_COMP_INTERINTRA_ZEROA ] = INT_MAX;
1177 sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] = INT_MAX; 985 sf->thresh_mult[THR_COMP_INTERINTRA_NEARESTA] = INT_MAX;
1178 sf->thresh_mult[THR_COMP_INTERINTRA_NEARA ] = INT_MAX; 986 sf->thresh_mult[THR_COMP_INTERINTRA_NEARA ] = INT_MAX;
1179 sf->thresh_mult[THR_COMP_INTERINTRA_NEWA ] = INT_MAX; 987 sf->thresh_mult[THR_COMP_INTERINTRA_NEWA ] = INT_MAX;
1180 #endif 988 #endif
1181 sf->thresh_mult[THR_SPLITA ] = INT_MAX; 989 sf->thresh_mult[THR_SPLITA ] = INT_MAX;
1182 } 990 }
1183 991
1184 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_GOLD_FLAG)) != (VP9_LAST_FLAG | VP9_GOLD_FLAG)) { 992 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_GOLD_FLAG)) != (VP9_LAST_FLAG | VP9_GOLD_FLAG)) {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 memcpy(cpi->base_skip_false_prob, base_skip_false_prob, sizeof(base_skip_false _prob)); 1606 memcpy(cpi->base_skip_false_prob, base_skip_false_prob, sizeof(base_skip_false _prob));
1799 cpi->common.current_video_frame = 0; 1607 cpi->common.current_video_frame = 0;
1800 cpi->kf_overspend_bits = 0; 1608 cpi->kf_overspend_bits = 0;
1801 cpi->kf_bitrate_adjustment = 0; 1609 cpi->kf_bitrate_adjustment = 0;
1802 cpi->frames_till_gf_update_due = 0; 1610 cpi->frames_till_gf_update_due = 0;
1803 cpi->gf_overspend_bits = 0; 1611 cpi->gf_overspend_bits = 0;
1804 cpi->non_gf_bitrate_adjustment = 0; 1612 cpi->non_gf_bitrate_adjustment = 0;
1805 cm->prob_last_coded = 128; 1613 cm->prob_last_coded = 128;
1806 cm->prob_gf_coded = 128; 1614 cm->prob_gf_coded = 128;
1807 cm->prob_intra_coded = 63; 1615 cm->prob_intra_coded = 63;
1808 #if CONFIG_SUPERBLOCKS 1616 cm->sb32_coded = 200;
1809 cm->sb_coded = 200; 1617 cm->sb64_coded = 200;
1810 #endif
1811 for (i = 0; i < COMP_PRED_CONTEXTS; i++) 1618 for (i = 0; i < COMP_PRED_CONTEXTS; i++)
1812 cm->prob_comppred[i] = 128; 1619 cm->prob_comppred[i] = 128;
1813 for (i = 0; i < TX_SIZE_MAX - 1; i++) 1620 for (i = 0; i < TX_SIZE_MAX_SB - 1; i++)
1814 cm->prob_tx[i] = 128; 1621 cm->prob_tx[i] = 128;
1815 1622
1816 // Prime the recent reference frame useage counters. 1623 // Prime the recent reference frame useage counters.
1817 // Hereafter they will be maintained as a sort of moving average 1624 // Hereafter they will be maintained as a sort of moving average
1818 cpi->recent_ref_frame_usage[INTRA_FRAME] = 1; 1625 cpi->recent_ref_frame_usage[INTRA_FRAME] = 1;
1819 cpi->recent_ref_frame_usage[LAST_FRAME] = 1; 1626 cpi->recent_ref_frame_usage[LAST_FRAME] = 1;
1820 cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1; 1627 cpi->recent_ref_frame_usage[GOLDEN_FRAME] = 1;
1821 cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1; 1628 cpi->recent_ref_frame_usage[ALTREF_FRAME] = 1;
1822 1629
1823 // Set reference frame sign bias for ALTREF frame to 1 (for now) 1630 // Set reference frame sign bias for ALTREF frame to 1 (for now)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 1720
1914 if (cpi->b_calculate_ssimg) { 1721 if (cpi->b_calculate_ssimg) {
1915 cpi->total_ssimg_y = 0; 1722 cpi->total_ssimg_y = 0;
1916 cpi->total_ssimg_u = 0; 1723 cpi->total_ssimg_u = 0;
1917 cpi->total_ssimg_v = 0; 1724 cpi->total_ssimg_v = 0;
1918 cpi->total_ssimg_all = 0; 1725 cpi->total_ssimg_all = 0;
1919 } 1726 }
1920 1727
1921 #endif 1728 #endif
1922 1729
1923 #ifndef LLONG_MAX 1730 cpi->first_time_stamp_ever = INT64_MAX;
1924 #define LLONG_MAX 9223372036854775807LL
1925 #endif
1926 cpi->first_time_stamp_ever = LLONG_MAX;
1927 1731
1928 cpi->frames_till_gf_update_due = 0; 1732 cpi->frames_till_gf_update_due = 0;
1929 cpi->key_frame_count = 1; 1733 cpi->key_frame_count = 1;
1930 1734
1931 cpi->ni_av_qi = cpi->oxcf.worst_allowed_q; 1735 cpi->ni_av_qi = cpi->oxcf.worst_allowed_q;
1932 cpi->ni_tot_qi = 0; 1736 cpi->ni_tot_qi = 0;
1933 cpi->ni_frames = 0; 1737 cpi->ni_frames = 0;
1934 cpi->tot_q = 0.0; 1738 cpi->tot_q = 0.0;
1935 cpi->avg_q = vp9_convert_qindex_to_q(cpi->oxcf.worst_allowed_q); 1739 cpi->avg_q = vp9_convert_qindex_to_q(cpi->oxcf.worst_allowed_q);
1936 cpi->total_byte_count = 0; 1740 cpi->total_byte_count = 0;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 cpi->fn_ptr[BT].vf = VF; \ 1804 cpi->fn_ptr[BT].vf = VF; \
2001 cpi->fn_ptr[BT].svf = SVF; \ 1805 cpi->fn_ptr[BT].svf = SVF; \
2002 cpi->fn_ptr[BT].svf_halfpix_h = SVFHH; \ 1806 cpi->fn_ptr[BT].svf_halfpix_h = SVFHH; \
2003 cpi->fn_ptr[BT].svf_halfpix_v = SVFHV; \ 1807 cpi->fn_ptr[BT].svf_halfpix_v = SVFHV; \
2004 cpi->fn_ptr[BT].svf_halfpix_hv = SVFHHV; \ 1808 cpi->fn_ptr[BT].svf_halfpix_hv = SVFHHV; \
2005 cpi->fn_ptr[BT].sdx3f = SDX3F; \ 1809 cpi->fn_ptr[BT].sdx3f = SDX3F; \
2006 cpi->fn_ptr[BT].sdx8f = SDX8F; \ 1810 cpi->fn_ptr[BT].sdx8f = SDX8F; \
2007 cpi->fn_ptr[BT].sdx4df = SDX4DF; 1811 cpi->fn_ptr[BT].sdx4df = SDX4DF;
2008 1812
2009 1813
2010 #if CONFIG_SUPERBLOCKS
2011 BFP(BLOCK_32X32, vp9_sad32x32, vp9_variance32x32, vp9_sub_pixel_variance32x32, 1814 BFP(BLOCK_32X32, vp9_sad32x32, vp9_variance32x32, vp9_sub_pixel_variance32x32,
2012 vp9_variance_halfpixvar32x32_h, vp9_variance_halfpixvar32x32_v, 1815 vp9_variance_halfpixvar32x32_h, vp9_variance_halfpixvar32x32_v,
2013 vp9_variance_halfpixvar32x32_hv, vp9_sad32x32x3, vp9_sad32x32x8, 1816 vp9_variance_halfpixvar32x32_hv, vp9_sad32x32x3, vp9_sad32x32x8,
2014 vp9_sad32x32x4d) 1817 vp9_sad32x32x4d)
2015 #endif 1818
1819 BFP(BLOCK_64X64, vp9_sad64x64, vp9_variance64x64, vp9_sub_pixel_variance64x64,
1820 vp9_variance_halfpixvar64x64_h, vp9_variance_halfpixvar64x64_v,
1821 vp9_variance_halfpixvar64x64_hv, vp9_sad64x64x3, vp9_sad64x64x8,
1822 vp9_sad64x64x4d)
2016 1823
2017 BFP(BLOCK_16X16, vp9_sad16x16, vp9_variance16x16, vp9_sub_pixel_variance16x16, 1824 BFP(BLOCK_16X16, vp9_sad16x16, vp9_variance16x16, vp9_sub_pixel_variance16x16,
2018 vp9_variance_halfpixvar16x16_h, vp9_variance_halfpixvar16x16_v, 1825 vp9_variance_halfpixvar16x16_h, vp9_variance_halfpixvar16x16_v,
2019 vp9_variance_halfpixvar16x16_hv, vp9_sad16x16x3, vp9_sad16x16x8, 1826 vp9_variance_halfpixvar16x16_hv, vp9_sad16x16x3, vp9_sad16x16x8,
2020 vp9_sad16x16x4d) 1827 vp9_sad16x16x4d)
2021 1828
2022 BFP(BLOCK_16X8, vp9_sad16x8, vp9_variance16x8, vp9_sub_pixel_variance16x8, 1829 BFP(BLOCK_16X8, vp9_sad16x8, vp9_variance16x8, vp9_sub_pixel_variance16x8,
2023 NULL, NULL, NULL, vp9_sad16x8x3, vp9_sad16x8x8, vp9_sad16x8x4d) 1830 NULL, NULL, NULL, vp9_sad16x8x3, vp9_sad16x8x8, vp9_sad16x8x4d)
2024 1831
2025 BFP(BLOCK_8X16, vp9_sad8x16, vp9_variance8x16, vp9_sub_pixel_variance8x16, 1832 BFP(BLOCK_8X16, vp9_sad8x16, vp9_variance8x16, vp9_sub_pixel_variance8x16,
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 #ifdef ENTROPY_STATS 2023 #ifdef ENTROPY_STATS
2217 { 2024 {
2218 int i, j, k; 2025 int i, j, k;
2219 FILE *fmode = fopen("vp9_modecontext.c", "w"); 2026 FILE *fmode = fopen("vp9_modecontext.c", "w");
2220 2027
2221 fprintf(fmode, "\n#include \"vp9_entropymode.h\"\n\n"); 2028 fprintf(fmode, "\n#include \"vp9_entropymode.h\"\n\n");
2222 fprintf(fmode, "const unsigned int vp9_kf_default_bmode_counts "); 2029 fprintf(fmode, "const unsigned int vp9_kf_default_bmode_counts ");
2223 fprintf(fmode, "[VP9_KF_BINTRAMODES][VP9_KF_BINTRAMODES]" 2030 fprintf(fmode, "[VP9_KF_BINTRAMODES][VP9_KF_BINTRAMODES]"
2224 "[VP9_KF_BINTRAMODES] =\n{\n"); 2031 "[VP9_KF_BINTRAMODES] =\n{\n");
2225 2032
2226 for (i = 0; i < VP8_KF_BINTRAMODES; i++) { 2033 for (i = 0; i < VP9_KF_BINTRAMODES; i++) {
2227 2034
2228 fprintf(fmode, " { // Above Mode : %d\n", i); 2035 fprintf(fmode, " { // Above Mode : %d\n", i);
2229 2036
2230 for (j = 0; j < VP8_KF_BINTRAMODES; j++) { 2037 for (j = 0; j < VP9_KF_BINTRAMODES; j++) {
2231 2038
2232 fprintf(fmode, " {"); 2039 fprintf(fmode, " {");
2233 2040
2234 for (k = 0; k < VP9_KF_BINTRAMODES; k++) { 2041 for (k = 0; k < VP9_KF_BINTRAMODES; k++) {
2235 if (!intra_mode_stats[i][j][k]) 2042 if (!intra_mode_stats[i][j][k])
2236 fprintf(fmode, " %5d, ", 1); 2043 fprintf(fmode, " %5d, ", 1);
2237 else 2044 else
2238 fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]); 2045 fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]);
2239 } 2046 }
2240 2047
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2305 fclose(framepsnr); 2112 fclose(framepsnr);
2306 2113
2307 if (kf_list) 2114 if (kf_list)
2308 fclose(kf_list); 2115 fclose(kf_list);
2309 2116
2310 #endif 2117 #endif
2311 2118
2312 } 2119 }
2313 2120
2314 2121
2315 static uint64_t calc_plane_error(unsigned char *orig, int orig_stride, 2122 static uint64_t calc_plane_error(uint8_t *orig, int orig_stride,
2316 unsigned char *recon, int recon_stride, 2123 uint8_t *recon, int recon_stride,
2317 unsigned int cols, unsigned int rows) { 2124 unsigned int cols, unsigned int rows) {
2318 unsigned int row, col; 2125 unsigned int row, col;
2319 uint64_t total_sse = 0; 2126 uint64_t total_sse = 0;
2320 int diff; 2127 int diff;
2321 2128
2322 for (row = 0; row + 16 <= rows; row += 16) { 2129 for (row = 0; row + 16 <= rows; row += 16) {
2323 for (col = 0; col + 16 <= cols; col += 16) { 2130 for (col = 0; col + 16 <= cols; col += 16) {
2324 unsigned int sse; 2131 unsigned int sse;
2325 2132
2326 vp9_mse16x16(orig + col, orig_stride, recon + col, recon_stride, &sse); 2133 vp9_mse16x16(orig + col, orig_stride, recon + col, recon_stride, &sse);
2327 total_sse += sse; 2134 total_sse += sse;
2328 } 2135 }
2329 2136
2330 /* Handle odd-sized width */ 2137 /* Handle odd-sized width */
2331 if (col < cols) { 2138 if (col < cols) {
2332 unsigned int border_row, border_col; 2139 unsigned int border_row, border_col;
2333 unsigned char *border_orig = orig; 2140 uint8_t *border_orig = orig;
2334 unsigned char *border_recon = recon; 2141 uint8_t *border_recon = recon;
2335 2142
2336 for (border_row = 0; border_row < 16; border_row++) { 2143 for (border_row = 0; border_row < 16; border_row++) {
2337 for (border_col = col; border_col < cols; border_col++) { 2144 for (border_col = col; border_col < cols; border_col++) {
2338 diff = border_orig[border_col] - border_recon[border_col]; 2145 diff = border_orig[border_col] - border_recon[border_col];
2339 total_sse += diff * diff; 2146 total_sse += diff * diff;
2340 } 2147 }
2341 2148
2342 border_orig += orig_stride; 2149 border_orig += orig_stride;
2343 border_recon += recon_stride; 2150 border_recon += recon_stride;
2344 } 2151 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 VP9_COMP *cpi = (VP9_COMP *) comp; 2290 VP9_COMP *cpi = (VP9_COMP *) comp;
2484 VP9_COMMON *cm = &cpi->common; 2291 VP9_COMMON *cm = &cpi->common;
2485 cm->refresh_entropy_probs = update; 2292 cm->refresh_entropy_probs = update;
2486 2293
2487 return 0; 2294 return 0;
2488 } 2295 }
2489 2296
2490 2297
2491 #ifdef OUTPUT_YUV_SRC 2298 #ifdef OUTPUT_YUV_SRC
2492 void vp9_write_yuv_frame(YV12_BUFFER_CONFIG *s) { 2299 void vp9_write_yuv_frame(YV12_BUFFER_CONFIG *s) {
2493 unsigned char *src = s->y_buffer; 2300 uint8_t *src = s->y_buffer;
2494 int h = s->y_height; 2301 int h = s->y_height;
2495 2302
2496 do { 2303 do {
2497 fwrite(src, s->y_width, 1, yuv_file); 2304 fwrite(src, s->y_width, 1, yuv_file);
2498 src += s->y_stride; 2305 src += s->y_stride;
2499 } while (--h); 2306 } while (--h);
2500 2307
2501 src = s->u_buffer; 2308 src = s->u_buffer;
2502 h = s->uv_height; 2309 h = s->uv_height;
2503 2310
2504 do { 2311 do {
2505 fwrite(src, s->uv_width, 1, yuv_file); 2312 fwrite(src, s->uv_width, 1, yuv_file);
2506 src += s->uv_stride; 2313 src += s->uv_stride;
2507 } while (--h); 2314 } while (--h);
2508 2315
2509 src = s->v_buffer; 2316 src = s->v_buffer;
2510 h = s->uv_height; 2317 h = s->uv_height;
2511 2318
2512 do { 2319 do {
2513 fwrite(src, s->uv_width, 1, yuv_file); 2320 fwrite(src, s->uv_width, 1, yuv_file);
2514 src += s->uv_stride; 2321 src += s->uv_stride;
2515 } while (--h); 2322 } while (--h);
2516 } 2323 }
2517 #endif 2324 #endif
2518 2325
2519 #ifdef OUTPUT_YUV_REC 2326 #ifdef OUTPUT_YUV_REC
2520 void vp9_write_yuv_rec_frame(VP9_COMMON *cm) { 2327 void vp9_write_yuv_rec_frame(VP9_COMMON *cm) {
2521 YV12_BUFFER_CONFIG *s = cm->frame_to_show; 2328 YV12_BUFFER_CONFIG *s = cm->frame_to_show;
2522 unsigned char *src = s->y_buffer; 2329 uint8_t *src = s->y_buffer;
2523 int h = cm->Height; 2330 int h = cm->Height;
2524 2331
2525 do { 2332 do {
2526 fwrite(src, s->y_width, 1, yuv_rec_file); 2333 fwrite(src, s->y_width, 1, yuv_rec_file);
2527 src += s->y_stride; 2334 src += s->y_stride;
2528 } while (--h); 2335 } while (--h);
2529 2336
2530 src = s->u_buffer; 2337 src = s->u_buffer;
2531 h = (cm->Height + 1) / 2; 2338 h = (cm->Height + 1) / 2;
2532 2339
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2685 2492
2686 fclose(yframe); 2493 fclose(yframe);
2687 } 2494 }
2688 #endif 2495 #endif
2689 2496
2690 static double compute_edge_pixel_proportion(YV12_BUFFER_CONFIG *frame) { 2497 static double compute_edge_pixel_proportion(YV12_BUFFER_CONFIG *frame) {
2691 #define EDGE_THRESH 128 2498 #define EDGE_THRESH 128
2692 int i, j; 2499 int i, j;
2693 int num_edge_pels = 0; 2500 int num_edge_pels = 0;
2694 int num_pels = (frame->y_height - 2) * (frame->y_width - 2); 2501 int num_pels = (frame->y_height - 2) * (frame->y_width - 2);
2695 unsigned char *prev = frame->y_buffer + 1; 2502 uint8_t *prev = frame->y_buffer + 1;
2696 unsigned char *curr = frame->y_buffer + 1 + frame->y_stride; 2503 uint8_t *curr = frame->y_buffer + 1 + frame->y_stride;
2697 unsigned char *next = frame->y_buffer + 1 + 2 * frame->y_stride; 2504 uint8_t *next = frame->y_buffer + 1 + 2 * frame->y_stride;
2698 for (i = 1; i < frame->y_height - 1; i++) { 2505 for (i = 1; i < frame->y_height - 1; i++) {
2699 for (j = 1; j < frame->y_width - 1; j++) { 2506 for (j = 1; j < frame->y_width - 1; j++) {
2700 /* Sobel hor and ver gradients */ 2507 /* Sobel hor and ver gradients */
2701 int v = 2 * (curr[1] - curr[-1]) + (prev[1] - prev[-1]) + (next[1] - next[ -1]); 2508 int v = 2 * (curr[1] - curr[-1]) + (prev[1] - prev[-1]) + (next[1] - next[ -1]);
2702 int h = 2 * (prev[0] - next[0]) + (prev[1] - next[1]) + (prev[-1] - next[- 1]); 2509 int h = 2 * (prev[0] - next[0]) + (prev[1] - next[1]) + (prev[-1] - next[- 1]);
2703 h = (h < 0 ? -h : h); 2510 h = (h < 0 ? -h : h);
2704 v = (v < 0 ? -v : v); 2511 v = (v < 0 ? -v : v);
2705 if (h > EDGE_THRESH || v > EDGE_THRESH) num_edge_pels++; 2512 if (h > EDGE_THRESH || v > EDGE_THRESH) num_edge_pels++;
2706 curr++; 2513 curr++;
2707 prev++; 2514 prev++;
2708 next++; 2515 next++;
2709 } 2516 }
2710 curr += frame->y_stride - frame->y_width + 2; 2517 curr += frame->y_stride - frame->y_width + 2;
2711 prev += frame->y_stride - frame->y_width + 2; 2518 prev += frame->y_stride - frame->y_width + 2;
2712 next += frame->y_stride - frame->y_width + 2; 2519 next += frame->y_stride - frame->y_width + 2;
2713 } 2520 }
2714 return (double)num_edge_pels / (double)num_pels; 2521 return (double)num_edge_pels / (double)num_pels;
2715 } 2522 }
2716 2523
2717 // Function to test for conditions that indicate we should loop 2524 // Function to test for conditions that indicate we should loop
2718 // back and recode a frame. 2525 // back and recode a frame.
2719 static BOOL recode_loop_test(VP9_COMP *cpi, 2526 static int recode_loop_test(VP9_COMP *cpi,
2720 int high_limit, int low_limit, 2527 int high_limit, int low_limit,
2721 int q, int maxq, int minq) { 2528 int q, int maxq, int minq) {
2722 BOOL force_recode = FALSE; 2529 int force_recode = FALSE;
2723 VP9_COMMON *cm = &cpi->common; 2530 VP9_COMMON *cm = &cpi->common;
2724 2531
2725 // Is frame recode allowed at all 2532 // Is frame recode allowed at all
2726 // Yes if either recode mode 1 is selected or mode two is selcted 2533 // Yes if either recode mode 1 is selected or mode two is selcted
2727 // and the frame is a key frame. golden frame or alt_ref_frame 2534 // and the frame is a key frame. golden frame or alt_ref_frame
2728 if ((cpi->sf.recode_loop == 1) || 2535 if ((cpi->sf.recode_loop == 1) ||
2729 ((cpi->sf.recode_loop == 2) && 2536 ((cpi->sf.recode_loop == 2) &&
2730 ((cm->frame_type == KEY_FRAME) || 2537 ((cm->frame_type == KEY_FRAME) ||
2731 cm->refresh_golden_frame || 2538 cm->refresh_golden_frame ||
2732 cm->refresh_alt_ref_frame))) { 2539 cm->refresh_alt_ref_frame))) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2845 vp9_pick_filter_level_fast(cpi->Source, cpi); 2652 vp9_pick_filter_level_fast(cpi->Source, cpi);
2846 else 2653 else
2847 vp9_pick_filter_level(cpi->Source, cpi); 2654 vp9_pick_filter_level(cpi->Source, cpi);
2848 2655
2849 vpx_usec_timer_mark(&timer); 2656 vpx_usec_timer_mark(&timer);
2850 cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); 2657 cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
2851 } 2658 }
2852 2659
2853 if (cm->filter_level > 0) { 2660 if (cm->filter_level > 0) {
2854 vp9_set_alt_lf_level(cpi, cm->filter_level); 2661 vp9_set_alt_lf_level(cpi, cm->filter_level);
2855 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd); 2662 vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, cm->filter_level, 0);
2856 } 2663 }
2857 2664
2858 vp8_yv12_extend_frame_borders(cm->frame_to_show); 2665 vp8_yv12_extend_frame_borders(cm->frame_to_show);
2859 2666
2860 } 2667 }
2861 2668
2862 #if CONFIG_PRED_FILTER 2669 void select_interp_filter_type(VP9_COMP *cpi) {
2863 void select_pred_filter_mode(VP9_COMP *cpi) { 2670 int i;
2864 VP9_COMMON *cm = &cpi->common; 2671 int high_filter_index = 0;
2672 unsigned int thresh;
2673 unsigned int high_count = 0;
2674 unsigned int count_sum = 0;
2675 unsigned int *hist = cpi->best_switchable_interp_count;
2865 2676
2866 int prob_pred_filter_off = cm->prob_pred_filter_off; 2677 if (DEFAULT_INTERP_FILTER != SWITCHABLE) {
2678 cpi->common.mcomp_filter_type = DEFAULT_INTERP_FILTER;
2679 return;
2680 }
2867 2681
2868 // Force filter on/off if probability is extreme 2682 // TODO(agrange): Look at using RD criteria to select the interpolation
2869 if (prob_pred_filter_off >= 255 * 0.95) 2683 // filter to use for the next frame rather than this simpler counting scheme.
2870 cm->pred_filter_mode = 0; // Off at the frame level 2684
2871 else if (prob_pred_filter_off <= 255 * 0.05) 2685 // Select the interpolation filter mode for the next frame
2872 cm->pred_filter_mode = 1; // On at the frame level 2686 // based on the selection frequency seen in the current frame.
2873 else 2687 for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
2874 cm->pred_filter_mode = 2; // Selectable at the MB level 2688 unsigned int count = hist[i];
2689 count_sum += count;
2690 if (count > high_count) {
2691 high_count = count;
2692 high_filter_index = i;
2693 }
2694 }
2695
2696 thresh = (unsigned int)(0.80 * count_sum);
2697
2698 if (high_count > thresh) {
2699 // One filter accounts for 80+% of cases so force the next
2700 // frame to use this filter exclusively using frame-level flag.
2701 cpi->common.mcomp_filter_type = vp9_switchable_interp[high_filter_index];
2702 } else {
2703 // Use a MB-level switchable filter selection strategy.
2704 cpi->common.mcomp_filter_type = SWITCHABLE;
2705 }
2875 } 2706 }
2876 2707
2877 void update_pred_filt_prob(VP9_COMP *cpi) {
2878 VP9_COMMON *cm = &cpi->common;
2879 int prob_pred_filter_off;
2880
2881 // Based on the selection in the previous frame determine what mode
2882 // to use for the current frame and work out the signaling probability
2883 if (cpi->pred_filter_on_count + cpi->pred_filter_off_count) {
2884 prob_pred_filter_off = cpi->pred_filter_off_count * 256 /
2885 (cpi->pred_filter_on_count + cpi->pred_filter_off_cou nt);
2886
2887 if (prob_pred_filter_off < 1)
2888 prob_pred_filter_off = 1;
2889
2890 if (prob_pred_filter_off > 255)
2891 prob_pred_filter_off = 255;
2892
2893 cm->prob_pred_filter_off = prob_pred_filter_off;
2894 } else
2895 cm->prob_pred_filter_off = 128;
2896 /*
2897 {
2898 FILE *fp = fopen("filt_use.txt", "a");
2899 fprintf (fp, "%d %d prob=%d\n", cpi->pred_filter_off_count,
2900 cpi->pred_filter_on_count, cm->prob_pred_filter_off);
2901 fclose(fp);
2902 }
2903 */
2904 }
2905 #endif
2906 #if CONFIG_COMP_INTERINTRA_PRED 2708 #if CONFIG_COMP_INTERINTRA_PRED
2907 static void select_interintra_mode(VP9_COMP *cpi) { 2709 static void select_interintra_mode(VP9_COMP *cpi) {
2908 static const double threshold = 0.01; 2710 static const double threshold = 0.01;
2909 VP9_COMMON *cm = &cpi->common; 2711 VP9_COMMON *cm = &cpi->common;
2910 // FIXME(debargha): Make this RD based 2712 // FIXME(debargha): Make this RD based
2911 int sum = cpi->interintra_select_count[1] + cpi->interintra_select_count[0]; 2713 int sum = cpi->interintra_select_count[1] + cpi->interintra_select_count[0];
2912 if (sum) { 2714 if (sum) {
2913 double fraction = (double) cpi->interintra_select_count[1] / sum; 2715 double fraction = (double) cpi->interintra_select_count[1] / sum;
2914 // printf("fraction: %f\n", fraction); 2716 // printf("fraction: %f\n", fraction);
2915 cm->use_interintra = (fraction > threshold); 2717 cm->use_interintra = (fraction > threshold);
2916 } 2718 }
2917 } 2719 }
2918 #endif 2720 #endif
2919 2721
2920 static void encode_frame_to_data_rate 2722 static void encode_frame_to_data_rate(VP9_COMP *cpi,
2921 ( 2723 unsigned long *size,
2922 VP9_COMP *cpi, 2724 unsigned char *dest,
2923 unsigned long *size, 2725 unsigned int *frame_flags) {
2924 unsigned char *dest,
2925 unsigned int *frame_flags
2926 ) {
2927 VP9_COMMON *cm = &cpi->common; 2726 VP9_COMMON *cm = &cpi->common;
2928 MACROBLOCKD *xd = &cpi->mb.e_mbd; 2727 MACROBLOCKD *xd = &cpi->mb.e_mbd;
2929 2728
2930 int Q; 2729 int Q;
2931 int frame_over_shoot_limit; 2730 int frame_over_shoot_limit;
2932 int frame_under_shoot_limit; 2731 int frame_under_shoot_limit;
2933 2732
2934 int Loop = FALSE; 2733 int Loop = FALSE;
2935 int loop_count; 2734 int loop_count;
2936 int this_q;
2937 int last_zbin_oq;
2938 2735
2939 int q_low; 2736 int q_low;
2940 int q_high; 2737 int q_high;
2941 int zbin_oq_high; 2738 int zbin_oq_high;
2942 int zbin_oq_low = 0; 2739 int zbin_oq_low = 0;
2943 2740
2944 int top_index; 2741 int top_index;
2945 int bottom_index; 2742 int bottom_index;
2946 int active_worst_qchanged = FALSE; 2743 int active_worst_qchanged = FALSE;
2947 2744
2948 int overshoot_seen = FALSE; 2745 int overshoot_seen = FALSE;
2949 int undershoot_seen = FALSE; 2746 int undershoot_seen = FALSE;
2950 2747
2951 int loop_size_estimate = 0;
2952
2953 SPEED_FEATURES *sf = &cpi->sf; 2748 SPEED_FEATURES *sf = &cpi->sf;
2954 #if RESET_FOREACH_FILTER 2749 #if RESET_FOREACH_FILTER
2955 int q_low0; 2750 int q_low0;
2956 int q_high0; 2751 int q_high0;
2957 int zbin_oq_high0; 2752 int zbin_oq_high0;
2958 int zbin_oq_low0 = 0; 2753 int zbin_oq_low0 = 0;
2959 int Q0; 2754 int Q0;
2755 int last_zbin_oq;
2960 int last_zbin_oq0; 2756 int last_zbin_oq0;
2961 int active_best_quality0; 2757 int active_best_quality0;
2962 int active_worst_quality0; 2758 int active_worst_quality0;
2963 double rate_correction_factor0; 2759 double rate_correction_factor0;
2964 double gf_rate_correction_factor0; 2760 double gf_rate_correction_factor0;
2965 #endif 2761 #endif
2966 2762
2967 /* list of filters to search over */ 2763 /* list of filters to search over */
2968 int mcomp_filters_to_search[] = { 2764 int mcomp_filters_to_search[] = {
2969 EIGHTTAP, EIGHTTAP_SHARP, SIXTAP, SWITCHABLE 2765 #if CONFIG_ENABLE_6TAP
2766 EIGHTTAP, EIGHTTAP_SHARP, SIXTAP, SWITCHABLE
2767 #else
2768 EIGHTTAP, EIGHTTAP_SHARP, EIGHTTAP_SMOOTH, SWITCHABLE
2769 #endif
2970 }; 2770 };
2971 int mcomp_filters = sizeof(mcomp_filters_to_search) / 2771 int mcomp_filters = sizeof(mcomp_filters_to_search) /
2972 sizeof(*mcomp_filters_to_search); 2772 sizeof(*mcomp_filters_to_search);
2973 int mcomp_filter_index = 0; 2773 int mcomp_filter_index = 0;
2974 INT64 mcomp_filter_cost[4]; 2774 int64_t mcomp_filter_cost[4];
2975 2775
2976 // Clear down mmx registers to allow floating point in what follows 2776 // Clear down mmx registers to allow floating point in what follows
2977 vp9_clear_system_state(); 2777 vp9_clear_system_state();
2978 2778
2979 2779
2980 // For an alt ref frame in 2 pass we skip the call to the second 2780 // For an alt ref frame in 2 pass we skip the call to the second
2981 // pass function that sets the target bandwidth so must set it here 2781 // pass function that sets the target bandwidth so must set it here
2982 if (cpi->common.refresh_alt_ref_frame) { 2782 if (cpi->common.refresh_alt_ref_frame) {
2983 cpi->per_frame_bandwidth = cpi->twopass.gf_bits; / / Per frame bit target for the alt ref frame 2783 cpi->per_frame_bandwidth = cpi->twopass.gf_bits; / / Per frame bit target for the alt ref frame
2984 // per second target bitrate 2784 // per second target bitrate
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 if ((cm->current_video_frame == 0) || 2818 if ((cm->current_video_frame == 0) ||
3019 (cm->frame_flags & FRAMEFLAGS_KEY) || 2819 (cm->frame_flags & FRAMEFLAGS_KEY) ||
3020 (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency = = 0))) { 2820 (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency = = 0))) {
3021 // Key frame from VFW/auto-keyframe/first frame 2821 // Key frame from VFW/auto-keyframe/first frame
3022 cm->frame_type = KEY_FRAME; 2822 cm->frame_type = KEY_FRAME;
3023 } 2823 }
3024 2824
3025 // Set default state for segment based loop filter update flags 2825 // Set default state for segment based loop filter update flags
3026 xd->mode_ref_lf_delta_update = 0; 2826 xd->mode_ref_lf_delta_update = 0;
3027 2827
3028 #if CONFIG_NEW_MVREF
3029 // Temp defaults probabilities for ecnoding the MV ref id signal
3030 vpx_memset(xd->mb_mv_ref_id_probs, 192,
3031 sizeof(xd->mb_mv_ref_id_probs));
3032 #endif
3033 2828
3034 // Set various flags etc to special state if it is a key frame 2829 // Set various flags etc to special state if it is a key frame
3035 if (cm->frame_type == KEY_FRAME) { 2830 if (cm->frame_type == KEY_FRAME) {
3036 int i; 2831 int i;
3037 2832
3038 // Reset the loop filter deltas and segmentation map 2833 // Reset the loop filter deltas and segmentation map
3039 setup_features(cpi); 2834 setup_features(cpi);
3040 2835
3041 // If segmentation is enabled force a map update for key frames 2836 // If segmentation is enabled force a map update for key frames
3042 if (xd->segmentation_enabled) { 2837 if (xd->segmentation_enabled) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 2957
3163 if (cpi->active_best_quality < cpi->best_quality) 2958 if (cpi->active_best_quality < cpi->best_quality)
3164 cpi->active_best_quality = cpi->best_quality; 2959 cpi->active_best_quality = cpi->best_quality;
3165 2960
3166 if (cpi->active_best_quality > cpi->worst_quality) 2961 if (cpi->active_best_quality > cpi->worst_quality)
3167 cpi->active_best_quality = cpi->worst_quality; 2962 cpi->active_best_quality = cpi->worst_quality;
3168 2963
3169 if (cpi->active_worst_quality < cpi->active_best_quality) 2964 if (cpi->active_worst_quality < cpi->active_best_quality)
3170 cpi->active_worst_quality = cpi->active_best_quality; 2965 cpi->active_worst_quality = cpi->active_best_quality;
3171 2966
3172 // Specuial case code to try and match quality with forced key frames 2967 // Special case code to try and match quality with forced key frames
3173 if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) { 2968 if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
3174 Q = cpi->last_boosted_qindex; 2969 Q = cpi->last_boosted_qindex;
3175 } else { 2970 } else {
3176 // Determine initial Q to try 2971 // Determine initial Q to try
3177 Q = vp9_regulate_q(cpi, cpi->this_frame_target); 2972 Q = vp9_regulate_q(cpi, cpi->this_frame_target);
3178 } 2973 }
2974 #if RESET_FOREACH_FILTER
3179 last_zbin_oq = cpi->zbin_over_quant; 2975 last_zbin_oq = cpi->zbin_over_quant;
2976 #endif
3180 2977
3181 // Set highest allowed value for Zbin over quant 2978 // Set highest allowed value for Zbin over quant
3182 if (cm->frame_type == KEY_FRAME) 2979 if (cm->frame_type == KEY_FRAME)
3183 zbin_oq_high = 0; // ZBIN_OQ_MAX/16 2980 zbin_oq_high = 0; // ZBIN_OQ_MAX/16
3184 else if (cm->refresh_alt_ref_frame || (cm->refresh_golden_frame && !cpi->sourc e_alt_ref_active)) 2981 else if (cm->refresh_alt_ref_frame || (cm->refresh_golden_frame && !cpi->sourc e_alt_ref_active))
3185 zbin_oq_high = 16; 2982 zbin_oq_high = 16;
3186 else 2983 else
3187 zbin_oq_high = ZBIN_OQ_MAX; 2984 zbin_oq_high = ZBIN_OQ_MAX;
3188 2985
3189 vp9_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, 2986 vp9_compute_frame_size_bounds(cpi, &frame_under_shoot_limit,
(...skipping 22 matching lines...) Expand all
3212 3009
3213 #if CONFIG_COMP_INTERINTRA_PRED 3010 #if CONFIG_COMP_INTERINTRA_PRED
3214 if (cm->current_video_frame == 0) { 3011 if (cm->current_video_frame == 0) {
3215 cm->use_interintra = 1; 3012 cm->use_interintra = 1;
3216 } 3013 }
3217 #endif 3014 #endif
3218 3015
3219 #if CONFIG_POSTPROC 3016 #if CONFIG_POSTPROC
3220 3017
3221 if (cpi->oxcf.noise_sensitivity > 0) { 3018 if (cpi->oxcf.noise_sensitivity > 0) {
3222 unsigned char *src; 3019 uint8_t *src;
3223 int l = 0; 3020 int l = 0;
3224 3021
3225 switch (cpi->oxcf.noise_sensitivity) { 3022 switch (cpi->oxcf.noise_sensitivity) {
3226 case 1: 3023 case 1:
3227 l = 20; 3024 l = 20;
3228 break; 3025 break;
3229 case 2: 3026 case 2:
3230 l = 40; 3027 l = 40;
3231 break; 3028 break;
3232 case 3: 3029 case 3:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3273 rate_correction_factor0 = cpi->rate_correction_factor; 3070 rate_correction_factor0 = cpi->rate_correction_factor;
3274 gf_rate_correction_factor0 = cpi->gf_rate_correction_factor; 3071 gf_rate_correction_factor0 = cpi->gf_rate_correction_factor;
3275 active_best_quality0 = cpi->active_best_quality; 3072 active_best_quality0 = cpi->active_best_quality;
3276 active_worst_quality0 = cpi->active_worst_quality; 3073 active_worst_quality0 = cpi->active_worst_quality;
3277 } 3074 }
3278 #endif 3075 #endif
3279 do { 3076 do {
3280 vp9_clear_system_state(); // __asm emms; 3077 vp9_clear_system_state(); // __asm emms;
3281 3078
3282 vp9_set_quantizer(cpi, Q); 3079 vp9_set_quantizer(cpi, Q);
3283 this_q = Q;
3284 3080
3285 if (loop_count == 0) { 3081 if (loop_count == 0) {
3286 3082
3287 // setup skip prob for costing in mode/mv decision 3083 // setup skip prob for costing in mode/mv decision
3288 if (cpi->common.mb_no_coeff_skip) { 3084 if (cpi->common.mb_no_coeff_skip) {
3289 int k; 3085 int k;
3290 for (k = 0; k < MBSKIP_CONTEXTS; k++) 3086 for (k = 0; k < MBSKIP_CONTEXTS; k++)
3291 cm->mbskip_pred_probs[k] = cpi->base_skip_false_prob[Q][k]; 3087 cm->mbskip_pred_probs[k] = cpi->base_skip_false_prob[Q][k];
3292 3088
3293 if (cm->frame_type != KEY_FRAME) { 3089 if (cm->frame_type != KEY_FRAME) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 // transform / motion compensation build reconstruction frame 3133 // transform / motion compensation build reconstruction frame
3338 3134
3339 vp9_encode_frame(cpi); 3135 vp9_encode_frame(cpi);
3340 3136
3341 // Update the skip mb flag probabilities based on the distribution 3137 // Update the skip mb flag probabilities based on the distribution
3342 // seen in the last encoder iteration. 3138 // seen in the last encoder iteration.
3343 update_base_skip_probs(cpi); 3139 update_base_skip_probs(cpi);
3344 3140
3345 vp9_clear_system_state(); // __asm emms; 3141 vp9_clear_system_state(); // __asm emms;
3346 3142
3347 #if CONFIG_PRED_FILTER
3348 // Update prediction filter on/off probability based on
3349 // selection made for the current frame
3350 if (cm->frame_type != KEY_FRAME)
3351 update_pred_filt_prob(cpi);
3352 #endif
3353
3354 // Dummy pack of the bitstream using up to date stats to get an 3143 // Dummy pack of the bitstream using up to date stats to get an
3355 // accurate estimate of output frame size to determine if we need 3144 // accurate estimate of output frame size to determine if we need
3356 // to recode. 3145 // to recode.
3357 vp9_save_coding_context(cpi); 3146 vp9_save_coding_context(cpi);
3358 cpi->dummy_packing = 1; 3147 cpi->dummy_packing = 1;
3359 vp9_pack_bitstream(cpi, dest, size); 3148 vp9_pack_bitstream(cpi, dest, size);
3360 cpi->projected_frame_size = (*size) << 3; 3149 cpi->projected_frame_size = (*size) << 3;
3361 vp9_restore_coding_context(cpi); 3150 vp9_restore_coding_context(cpi);
3362 3151
3363 if (frame_over_shoot_limit == 0) 3152 if (frame_over_shoot_limit == 0)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
3509 else if (Q < q_low) 3298 else if (Q < q_low)
3510 Q = q_low; 3299 Q = q_low;
3511 3300
3512 // Clamp cpi->zbin_over_quant 3301 // Clamp cpi->zbin_over_quant
3513 cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ? 3302 cpi->zbin_over_quant = (cpi->zbin_over_quant < zbin_oq_low) ?
3514 zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ? 3303 zbin_oq_low : (cpi->zbin_over_quant > zbin_oq_high) ?
3515 zbin_oq_high : cpi->zbin_over_quant; 3304 zbin_oq_high : cpi->zbin_over_quant;
3516 3305
3517 // Loop = ((Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant)) ? TRUE : FALSE; 3306 // Loop = ((Q != last_q) || (last_zbin_oq != cpi->zbin_over_quant)) ? TRUE : FALSE;
3518 Loop = ((Q != last_q)) ? TRUE : FALSE; 3307 Loop = ((Q != last_q)) ? TRUE : FALSE;
3308 #if RESET_FOREACH_FILTER
3519 last_zbin_oq = cpi->zbin_over_quant; 3309 last_zbin_oq = cpi->zbin_over_quant;
3310 #endif
3520 } else 3311 } else
3521 Loop = FALSE; 3312 Loop = FALSE;
3522 3313
3523 if (cpi->is_src_frame_alt_ref) 3314 if (cpi->is_src_frame_alt_ref)
3524 Loop = FALSE; 3315 Loop = FALSE;
3525 3316
3526 if (cm->frame_type != KEY_FRAME &&
3527 !sf->search_best_filter &&
3528 cm->mcomp_filter_type == SWITCHABLE) {
3529 int interp_factor = Q / 3; /* denominator is 256 */
3530 int count[VP9_SWITCHABLE_FILTERS];
3531 int tot_count = 0, c = 0, thr;
3532 int i, j;
3533 for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
3534 count[i] = 0;
3535 for (j = 0; j <= VP9_SWITCHABLE_FILTERS; ++j) {
3536 count[i] += cpi->switchable_interp_count[j][i];
3537 }
3538 tot_count += count[i];
3539 }
3540
3541 thr = ((tot_count * interp_factor + 128) >> 8);
3542 for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
3543 c += (count[i] >= thr);
3544 }
3545 if (c == 1) {
3546 /* Mostly one filter is used. So set the filter at frame level */
3547 for (i = 0; i < VP9_SWITCHABLE_FILTERS; ++i) {
3548 if (count[i]) {
3549 cm->mcomp_filter_type = vp9_switchable_interp[i];
3550 Loop = TRUE; /* Make sure to loop since the filter changed */
3551 break;
3552 }
3553 }
3554 }
3555 }
3556
3557 if (Loop == FALSE && cm->frame_type != KEY_FRAME && sf->search_best_filter) { 3317 if (Loop == FALSE && cm->frame_type != KEY_FRAME && sf->search_best_filter) {
3558 if (mcomp_filter_index < mcomp_filters) { 3318 if (mcomp_filter_index < mcomp_filters) {
3559 INT64 err = vp9_calc_ss_err(cpi->Source, 3319 int64_t err = vp9_calc_ss_err(cpi->Source,
3560 &cm->yv12_fb[cm->new_fb_idx]); 3320 &cm->yv12_fb[cm->new_fb_idx]);
3561 INT64 rate = cpi->projected_frame_size << 8; 3321 int64_t rate = cpi->projected_frame_size << 8;
3562 mcomp_filter_cost[mcomp_filter_index] = 3322 mcomp_filter_cost[mcomp_filter_index] =
3563 (RDCOST(cpi->RDMULT, cpi->RDDIV, rate, err)); 3323 (RDCOST(cpi->RDMULT, cpi->RDDIV, rate, err));
3564 mcomp_filter_index++; 3324 mcomp_filter_index++;
3565 if (mcomp_filter_index < mcomp_filters) { 3325 if (mcomp_filter_index < mcomp_filters) {
3566 cm->mcomp_filter_type = mcomp_filters_to_search[mcomp_filter_index]; 3326 cm->mcomp_filter_type = mcomp_filters_to_search[mcomp_filter_index];
3567 loop_count = -1; 3327 loop_count = -1;
3568 Loop = TRUE; 3328 Loop = TRUE;
3569 } else { 3329 } else {
3570 int f; 3330 int f;
3571 INT64 best_cost = mcomp_filter_cost[0]; 3331 int64_t best_cost = mcomp_filter_cost[0];
3572 int mcomp_best_filter = mcomp_filters_to_search[0]; 3332 int mcomp_best_filter = mcomp_filters_to_search[0];
3573 for (f = 1; f < mcomp_filters; f++) { 3333 for (f = 1; f < mcomp_filters; f++) {
3574 if (mcomp_filter_cost[f] < best_cost) { 3334 if (mcomp_filter_cost[f] < best_cost) {
3575 mcomp_best_filter = mcomp_filters_to_search[f]; 3335 mcomp_best_filter = mcomp_filters_to_search[f];
3576 best_cost = mcomp_filter_cost[f]; 3336 best_cost = mcomp_filter_cost[f];
3577 } 3337 }
3578 } 3338 }
3579 if (mcomp_best_filter != mcomp_filters_to_search[mcomp_filters - 1]) { 3339 if (mcomp_best_filter != mcomp_filters_to_search[mcomp_filters - 1]) {
3580 loop_count = -1; 3340 loop_count = -1;
3581 Loop = TRUE; 3341 Loop = TRUE;
(...skipping 19 matching lines...) Expand all
3601 cpi->gf_rate_correction_factor = gf_rate_correction_factor0; 3361 cpi->gf_rate_correction_factor = gf_rate_correction_factor0;
3602 cpi->active_best_quality = active_best_quality0; 3362 cpi->active_best_quality = active_best_quality0;
3603 cpi->active_worst_quality = active_worst_quality0; 3363 cpi->active_worst_quality = active_worst_quality0;
3604 } 3364 }
3605 #endif 3365 #endif
3606 } 3366 }
3607 } 3367 }
3608 3368
3609 if (Loop == TRUE) { 3369 if (Loop == TRUE) {
3610 loop_count++; 3370 loop_count++;
3371
3611 #if CONFIG_INTERNAL_STATS 3372 #if CONFIG_INTERNAL_STATS
3612 cpi->tot_recode_hits++; 3373 cpi->tot_recode_hits++;
3613 #endif 3374 #endif
3614 } 3375 }
3615 } while (Loop == TRUE); 3376 } while (Loop == TRUE);
3616 3377
3617 // Special case code to reduce pulsing when key frames are forced at a 3378 // Special case code to reduce pulsing when key frames are forced at a
3618 // fixed interval. Note the reconstruction error if it is the frame before 3379 // fixed interval. Note the reconstruction error if it is the frame before
3619 // the force key frame 3380 // the force key frame
3620 if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) { 3381 if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3676 loopfilter_frame(cpi, cm); 3437 loopfilter_frame(cpi, cm);
3677 3438
3678 // build the bitstream 3439 // build the bitstream
3679 cpi->dummy_packing = 0; 3440 cpi->dummy_packing = 0;
3680 vp9_pack_bitstream(cpi, dest, size); 3441 vp9_pack_bitstream(cpi, dest, size);
3681 3442
3682 if (cpi->mb.e_mbd.update_mb_segmentation_map) { 3443 if (cpi->mb.e_mbd.update_mb_segmentation_map) {
3683 update_reference_segmentation_map(cpi); 3444 update_reference_segmentation_map(cpi);
3684 } 3445 }
3685 3446
3686 #if CONFIG_PRED_FILTER
3687 // Select the prediction filtering mode to use for the
3688 // next frame based on the current frame selections
3689 if (cm->frame_type != KEY_FRAME)
3690 select_pred_filter_mode(cpi);
3691 #endif
3692
3693 update_reference_frames(cm); 3447 update_reference_frames(cm);
3694 vp9_copy(cpi->common.fc.coef_counts, cpi->coef_counts); 3448 vp9_copy(cpi->common.fc.coef_counts_4x4, cpi->coef_counts_4x4);
3695 vp9_copy(cpi->common.fc.hybrid_coef_counts, cpi->hybrid_coef_counts); 3449 vp9_copy(cpi->common.fc.hybrid_coef_counts_4x4,
3450 cpi->hybrid_coef_counts_4x4);
3696 vp9_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8); 3451 vp9_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8);
3697 vp9_copy(cpi->common.fc.hybrid_coef_counts_8x8, cpi->hybrid_coef_counts_8x8); 3452 vp9_copy(cpi->common.fc.hybrid_coef_counts_8x8,
3453 cpi->hybrid_coef_counts_8x8);
3698 vp9_copy(cpi->common.fc.coef_counts_16x16, cpi->coef_counts_16x16); 3454 vp9_copy(cpi->common.fc.coef_counts_16x16, cpi->coef_counts_16x16);
3699 vp9_copy(cpi->common.fc.hybrid_coef_counts_16x16, 3455 vp9_copy(cpi->common.fc.hybrid_coef_counts_16x16,
3700 cpi->hybrid_coef_counts_16x16); 3456 cpi->hybrid_coef_counts_16x16);
3457 vp9_copy(cpi->common.fc.coef_counts_32x32, cpi->coef_counts_32x32);
3701 vp9_adapt_coef_probs(&cpi->common); 3458 vp9_adapt_coef_probs(&cpi->common);
3702 if (cpi->common.frame_type != KEY_FRAME) { 3459 if (cpi->common.frame_type != KEY_FRAME) {
3703 #if CONFIG_SUPERBLOCKS
3704 vp9_copy(cpi->common.fc.sb_ymode_counts, cpi->sb_ymode_count); 3460 vp9_copy(cpi->common.fc.sb_ymode_counts, cpi->sb_ymode_count);
3705 #endif
3706 vp9_copy(cpi->common.fc.ymode_counts, cpi->ymode_count); 3461 vp9_copy(cpi->common.fc.ymode_counts, cpi->ymode_count);
3707 vp9_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count); 3462 vp9_copy(cpi->common.fc.uv_mode_counts, cpi->y_uv_mode_count);
3708 vp9_copy(cpi->common.fc.bmode_counts, cpi->bmode_count); 3463 vp9_copy(cpi->common.fc.bmode_counts, cpi->bmode_count);
3709 vp9_copy(cpi->common.fc.i8x8_mode_counts, cpi->i8x8_mode_count); 3464 vp9_copy(cpi->common.fc.i8x8_mode_counts, cpi->i8x8_mode_count);
3710 vp9_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count); 3465 vp9_copy(cpi->common.fc.sub_mv_ref_counts, cpi->sub_mv_ref_count);
3711 vp9_copy(cpi->common.fc.mbsplit_counts, cpi->mbsplit_count); 3466 vp9_copy(cpi->common.fc.mbsplit_counts, cpi->mbsplit_count);
3712 #if CONFIG_COMP_INTERINTRA_PRED 3467 #if CONFIG_COMP_INTERINTRA_PRED
3713 vp9_copy(cpi->common.fc.interintra_counts, cpi->interintra_count); 3468 vp9_copy(cpi->common.fc.interintra_counts, cpi->interintra_count);
3714 #endif 3469 #endif
3715 vp9_adapt_mode_probs(&cpi->common); 3470 vp9_adapt_mode_probs(&cpi->common);
3716 3471
3717 cpi->common.fc.NMVcount = cpi->NMVcount; 3472 cpi->common.fc.NMVcount = cpi->NMVcount;
3718 /* 3473 /*
3719 printf("2: %d %d %d %d\n", cpi->NMVcount.joints[0], cpi->NMVcount.joints[1], 3474 printf("2: %d %d %d %d\n", cpi->NMVcount.joints[0], cpi->NMVcount.joints[1],
3720 cpi->NMVcount.joints[2], cpi->NMVcount.joints[3]); 3475 cpi->NMVcount.joints[2], cpi->NMVcount.joints[3]);
3721 */ 3476 */
3722 vp9_adapt_nmv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv); 3477 vp9_adapt_nmv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv);
3723 } 3478 }
3724 #if CONFIG_COMP_INTERINTRA_PRED 3479 #if CONFIG_COMP_INTERINTRA_PRED
3725 if (cm->frame_type != KEY_FRAME) 3480 if (cm->frame_type != KEY_FRAME)
3726 select_interintra_mode(cpi); 3481 select_interintra_mode(cpi);
3727 #endif 3482 #endif
3728 3483
3729 /* Move storing frame_type out of the above loop since it is also 3484 /* Move storing frame_type out of the above loop since it is also
3730 * needed in motion search besides loopfilter */ 3485 * needed in motion search besides loopfilter */
3731 cm->last_frame_type = cm->frame_type; 3486 cm->last_frame_type = cm->frame_type;
3732 3487
3733 // Keep a copy of the size estimate used in the loop
3734 loop_size_estimate = cpi->projected_frame_size;
3735
3736 // Update rate control heuristics 3488 // Update rate control heuristics
3737 cpi->total_byte_count += (*size); 3489 cpi->total_byte_count += (*size);
3738 cpi->projected_frame_size = (*size) << 3; 3490 cpi->projected_frame_size = (*size) << 3;
3739 3491
3740 if (!active_worst_qchanged) 3492 if (!active_worst_qchanged)
3741 vp9_update_rate_correction_factors(cpi, 2); 3493 vp9_update_rate_correction_factors(cpi, 2);
3742 3494
3743 cpi->last_q[cm->frame_type] = cm->base_qindex; 3495 cpi->last_q[cm->frame_type] = cm->base_qindex;
3744 3496
3745 // Keep record of last boosted (KF/KF/ARF) Q value. 3497 // Keep record of last boosted (KF/KF/ARF) Q value.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3810 cpi->twopass.gf_group_bits += cpi->this_frame_target - cpi->projected_frame_ size; 3562 cpi->twopass.gf_group_bits += cpi->this_frame_target - cpi->projected_frame_ size;
3811 3563
3812 if (cpi->twopass.gf_group_bits < 0) 3564 if (cpi->twopass.gf_group_bits < 0)
3813 cpi->twopass.gf_group_bits = 0; 3565 cpi->twopass.gf_group_bits = 0;
3814 } 3566 }
3815 3567
3816 // Update the skip mb flag probabilities based on the distribution seen 3568 // Update the skip mb flag probabilities based on the distribution seen
3817 // in this frame. 3569 // in this frame.
3818 update_base_skip_probs(cpi); 3570 update_base_skip_probs(cpi);
3819 3571
3820 #if 0 //CONFIG_NEW_MVREF && CONFIG_INTERNAL_STATS
3821 {
3822 FILE *f = fopen("mv_ref_dist.stt", "a");
3823 unsigned int i;
3824 for (i = 0; i < MAX_MV_REFS; ++i) {
3825 fprintf(f, "%10d", cpi->best_ref_index_counts[0][i]);
3826 }
3827 fprintf(f, "\n" );
3828
3829 fclose(f);
3830 }
3831 #endif
3832
3833 #if 0// 1 && CONFIG_INTERNAL_STATS 3572 #if 0// 1 && CONFIG_INTERNAL_STATS
3834 { 3573 {
3835 FILE *f = fopen("tmp.stt", "a"); 3574 FILE *f = fopen("tmp.stt", "a");
3836 int recon_err; 3575 int recon_err;
3837 3576
3838 vp9_clear_system_state(); // __asm emms; 3577 vp9_clear_system_state(); // __asm emms;
3839 3578
3840 recon_err = vp9_calc_ss_err(cpi->Source, 3579 recon_err = vp9_calc_ss_err(cpi->Source,
3841 &cm->yv12_fb[cm->new_fb_idx]); 3580 &cm->yv12_fb[cm->new_fb_idx]);
3842 3581
3843 if (cpi->twopass.total_left_stats->coded_error != 0.0) 3582 if (cpi->twopass.total_left_stats->coded_error != 0.0)
3844 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d" 3583 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
3845 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f" 3584 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
3846 "%6d %5d %5d %5d %8d %8.2f %10d %10.3f" 3585 "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
3847 "%10.3f %8d %10d %10d %10d\n", 3586 "%10.3f %8d %10d %10d %10d\n",
3848 cpi->common.current_video_frame, cpi->this_frame_target, 3587 cpi->common.current_video_frame, cpi->this_frame_target,
3849 cpi->projected_frame_size, loop_size_estimate, 3588 cpi->projected_frame_size, 0, //loop_size_estimate,
3850 (cpi->projected_frame_size - cpi->this_frame_target), 3589 (cpi->projected_frame_size - cpi->this_frame_target),
3851 (int)cpi->total_target_vs_actual, 3590 (int)cpi->total_target_vs_actual,
3852 (cpi->oxcf.starting_buffer_level - cpi->bits_off_target), 3591 (cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
3853 (int)cpi->total_actual_bits, 3592 (int)cpi->total_actual_bits,
3854 vp9_convert_qindex_to_q(cm->base_qindex), 3593 vp9_convert_qindex_to_q(cm->base_qindex),
3855 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0, 3594 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
3856 vp9_convert_qindex_to_q(cpi->active_best_quality), 3595 vp9_convert_qindex_to_q(cpi->active_best_quality),
3857 vp9_convert_qindex_to_q(cpi->active_worst_quality), 3596 vp9_convert_qindex_to_q(cpi->active_worst_quality),
3858 cpi->avg_q, 3597 cpi->avg_q,
3859 vp9_convert_qindex_to_q(cpi->ni_av_qi), 3598 vp9_convert_qindex_to_q(cpi->ni_av_qi),
3860 vp9_convert_qindex_to_q(cpi->cq_target_quality), 3599 vp9_convert_qindex_to_q(cpi->cq_target_quality),
3861 cpi->zbin_over_quant, 3600 cpi->zbin_over_quant,
3862 // cpi->avg_frame_qindex, cpi->zbin_over_quant, 3601 // cpi->avg_frame_qindex, cpi->zbin_over_quant,
3863 cm->refresh_golden_frame, cm->refresh_alt_ref_frame, 3602 cm->refresh_golden_frame, cm->refresh_alt_ref_frame,
3864 cm->frame_type, cpi->gfu_boost, 3603 cm->frame_type, cpi->gfu_boost,
3865 cpi->twopass.est_max_qcorrection_factor, 3604 cpi->twopass.est_max_qcorrection_factor,
3866 (int)cpi->twopass.bits_left, 3605 (int)cpi->twopass.bits_left,
3867 cpi->twopass.total_left_stats->coded_error, 3606 cpi->twopass.total_left_stats->coded_error,
3868 (double)cpi->twopass.bits_left / 3607 (double)cpi->twopass.bits_left /
3869 cpi->twopass.total_left_stats->coded_error, 3608 cpi->twopass.total_left_stats->coded_error,
3870 cpi->tot_recode_hits, recon_err, cpi->kf_boost, 3609 cpi->tot_recode_hits, recon_err, cpi->kf_boost,
3871 cpi->kf_zeromotion_pct); 3610 cpi->kf_zeromotion_pct);
3872 else 3611 else
3873 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d" 3612 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d"
3874 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f" 3613 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
3875 "%6d %5d %5d %5d %8d %8.2f %10d %10.3f" 3614 "%6d %5d %5d %5d %8d %8.2f %10d %10.3f"
3876 "%8d %10d %10d %10d\n", 3615 "%8d %10d %10d %10d\n",
3877 cpi->common.current_video_frame, 3616 cpi->common.current_video_frame,
3878 cpi->this_frame_target, cpi->projected_frame_size, 3617 cpi->this_frame_target, cpi->projected_frame_size,
3879 loop_size_estimate, 3618 0, //loop_size_estimate,
3880 (cpi->projected_frame_size - cpi->this_frame_target), 3619 (cpi->projected_frame_size - cpi->this_frame_target),
3881 (int)cpi->total_target_vs_actual, 3620 (int)cpi->total_target_vs_actual,
3882 (cpi->oxcf.starting_buffer_level - cpi->bits_off_target), 3621 (cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
3883 (int)cpi->total_actual_bits, 3622 (int)cpi->total_actual_bits,
3884 vp9_convert_qindex_to_q(cm->base_qindex), 3623 vp9_convert_qindex_to_q(cm->base_qindex),
3885 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0, 3624 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
3886 vp9_convert_qindex_to_q(cpi->active_best_quality), 3625 vp9_convert_qindex_to_q(cpi->active_best_quality),
3887 vp9_convert_qindex_to_q(cpi->active_worst_quality), 3626 vp9_convert_qindex_to_q(cpi->active_worst_quality),
3888 cpi->avg_q, 3627 cpi->avg_q,
3889 vp9_convert_qindex_to_q(cpi->ni_av_qi), 3628 vp9_convert_qindex_to_q(cpi->ni_av_qi),
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
4491 4230
4492 return 0; 4231 return 0;
4493 } 4232 }
4494 4233
4495 4234
4496 4235
4497 int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest) { 4236 int vp9_calc_ss_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest) {
4498 int i, j; 4237 int i, j;
4499 int Total = 0; 4238 int Total = 0;
4500 4239
4501 unsigned char *src = source->y_buffer; 4240 uint8_t *src = source->y_buffer;
4502 unsigned char *dst = dest->y_buffer; 4241 uint8_t *dst = dest->y_buffer;
4503 4242
4504 // Loop through the Y plane raw and reconstruction data summing (square differ ences) 4243 // Loop through the Y plane raw and reconstruction data summing (square differ ences)
4505 for (i = 0; i < source->y_height; i += 16) { 4244 for (i = 0; i < source->y_height; i += 16) {
4506 for (j = 0; j < source->y_width; j += 16) { 4245 for (j = 0; j < source->y_width; j += 16) {
4507 unsigned int sse; 4246 unsigned int sse;
4508 Total += vp9_mse16x16(src + j, source->y_stride, dst + j, dest->y_stride, 4247 Total += vp9_mse16x16(src + j, source->y_stride, dst + j, dest->y_stride,
4509 &sse); 4248 &sse);
4510 } 4249 }
4511 4250
4512 src += 16 * source->y_stride; 4251 src += 16 * source->y_stride;
4513 dst += 16 * dest->y_stride; 4252 dst += 16 * dest->y_stride;
4514 } 4253 }
4515 4254
4516 return Total; 4255 return Total;
4517 } 4256 }
4518 4257
4519 4258
4520 int vp9_get_quantizer(VP9_PTR c) { 4259 int vp9_get_quantizer(VP9_PTR c) {
4521 VP9_COMP *cpi = (VP9_COMP *) c; 4260 VP9_COMP *cpi = (VP9_COMP *) c;
4522 return cpi->common.base_qindex; 4261 return cpi->common.base_qindex;
4523 } 4262 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_modecosts.h ('k') | source/libvpx/vp9/encoder/vp9_onyx_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698