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

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

Issue 54923004: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 1 month 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.c ('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
12 #include "vpx_config.h"
13 #include "vp9/common/vp9_filter.h"
14 #include "vp9/common/vp9_onyxc_int.h"
15 #include "vp9/common/vp9_reconinter.h"
16 #include "vp9/encoder/vp9_onyx_int.h"
17 #include "vp9/common/vp9_systemdependent.h"
18 #include "vp9/encoder/vp9_quantize.h"
19 #include "vp9/common/vp9_alloccommon.h"
20 #include "vp9/encoder/vp9_mcomp.h"
21 #include "vp9/encoder/vp9_firstpass.h"
22 #include "vp9/encoder/vp9_psnr.h"
23 #include "vpx_scale/vpx_scale.h"
24 #include "vp9/common/vp9_extend.h"
25 #include "vp9/encoder/vp9_ratectrl.h"
26 #include "vp9/common/vp9_quant_common.h"
27 #include "vp9/common/vp9_tile_common.h"
28 #include "vp9/encoder/vp9_segmentation.h"
29 #include "./vp9_rtcd.h"
30 #include "./vpx_scale_rtcd.h"
31 #if CONFIG_VP9_POSTPROC
32 #include "vp9/common/vp9_postproc.h"
33 #endif
34 #include "vpx_mem/vpx_mem.h"
35 #include "vpx_ports/vpx_timer.h"
36
37 #include "vp9/common/vp9_seg_common.h"
38 #include "vp9/encoder/vp9_mbgraph.h"
39 #include "vp9/common/vp9_pred_common.h"
40 #include "vp9/encoder/vp9_rdopt.h"
41 #include "vp9/encoder/vp9_bitstream.h"
42 #include "vp9/encoder/vp9_picklpf.h"
43 #include "vp9/common/vp9_mvref_common.h"
44 #include "vp9/encoder/vp9_temporal_filter.h"
45
46 #include <math.h> 11 #include <math.h>
47 #include <stdio.h> 12 #include <stdio.h>
48 #include <limits.h> 13 #include <limits.h>
49 14
15 #include "./vpx_config.h"
16 #include "./vpx_scale_rtcd.h"
17
18 #include "vp9/common/vp9_alloccommon.h"
19 #include "vp9/common/vp9_filter.h"
20 #include "vp9/common/vp9_idct.h"
21 #if CONFIG_VP9_POSTPROC
22 #include "vp9/common/vp9_postproc.h"
23 #endif
24 #include "vp9/common/vp9_reconinter.h"
25 #include "vp9/common/vp9_systemdependent.h"
26 #include "vp9/common/vp9_tile_common.h"
27 #include "vp9/encoder/vp9_firstpass.h"
28 #include "vp9/encoder/vp9_mbgraph.h"
29 #include "vp9/encoder/vp9_onyx_int.h"
30 #include "vp9/encoder/vp9_picklpf.h"
31 #include "vp9/encoder/vp9_psnr.h"
32 #include "vp9/encoder/vp9_ratectrl.h"
33 #include "vp9/encoder/vp9_rdopt.h"
34 #include "vp9/encoder/vp9_segmentation.h"
35 #include "vp9/encoder/vp9_temporal_filter.h"
36 #include "vp9/encoder/vp9_vaq.h"
37
38 #include "vpx_ports/vpx_timer.h"
39
40
50 extern void print_tree_update_probs(); 41 extern void print_tree_update_probs();
51 42
52 static void set_default_lf_deltas(struct loopfilter *lf); 43 static void set_default_lf_deltas(struct loopfilter *lf);
53 44
54 #define DEFAULT_INTERP_FILTER SWITCHABLE 45 #define DEFAULT_INTERP_FILTER SWITCHABLE
55 46
56 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ 47 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */
57 48
58 #define ALTREF_HIGH_PRECISION_MV 1 /* whether to use high precision mv 49 #define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv
59 for altref computation */ 50 // for altref computation.
60 #define HIGH_PRECISION_MV_QTHRESH 200 /* Q threshold for use of high precision 51 #define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision
61 mv. Choose a very high value for 52 // mv. Choose a very high value for
62 now so that HIGH_PRECISION is always 53 // now so that HIGH_PRECISION is always
63 chosen */ 54 // chosen.
55
56 // Masks for partially or completely disabling split mode
57 #define DISABLE_ALL_SPLIT 0x3F
58 #define DISABLE_ALL_INTER_SPLIT 0x1F
59 #define DISABLE_COMPOUND_SPLIT 0x18
60 #define LAST_AND_INTRA_SPLIT_ONLY 0x1E
64 61
65 #if CONFIG_INTERNAL_STATS 62 #if CONFIG_INTERNAL_STATS
66 #include "math.h"
67
68 extern double vp9_calc_ssim(YV12_BUFFER_CONFIG *source, 63 extern double vp9_calc_ssim(YV12_BUFFER_CONFIG *source,
69 YV12_BUFFER_CONFIG *dest, int lumamask, 64 YV12_BUFFER_CONFIG *dest, int lumamask,
70 double *weight); 65 double *weight);
71 66
72 67
73 extern double vp9_calc_ssimg(YV12_BUFFER_CONFIG *source, 68 extern double vp9_calc_ssimg(YV12_BUFFER_CONFIG *source,
74 YV12_BUFFER_CONFIG *dest, double *ssim_y, 69 YV12_BUFFER_CONFIG *dest, double *ssim_y,
75 double *ssim_u, double *ssim_v); 70 double *ssim_u, double *ssim_v);
76 71
77 72
(...skipping 22 matching lines...) Expand all
100 #endif 95 #endif
101 96
102 #ifdef MODE_STATS 97 #ifdef MODE_STATS
103 extern void init_tx_count_stats(); 98 extern void init_tx_count_stats();
104 extern void write_tx_count_stats(); 99 extern void write_tx_count_stats();
105 extern void init_switchable_interp_stats(); 100 extern void init_switchable_interp_stats();
106 extern void write_switchable_interp_stats(); 101 extern void write_switchable_interp_stats();
107 #endif 102 #endif
108 103
109 #ifdef SPEEDSTATS 104 #ifdef SPEEDSTATS
110 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 105 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106 0, 0, 0};
111 #endif 107 #endif
112 108
113 #if defined(SECTIONBITS_OUTPUT) 109 #if defined(SECTIONBITS_OUTPUT)
114 extern unsigned __int64 Sectionbits[500]; 110 extern unsigned __int64 Sectionbits[500];
115 #endif 111 #endif
116 112
117 extern void vp9_init_quantizer(VP9_COMP *cpi); 113 extern void vp9_init_quantizer(VP9_COMP *cpi);
118 114
119 // Tables relating active max Q to active min Q 115 // Tables relating active max Q to active min Q
120 static int kf_low_motion_minq[QINDEX_RANGE]; 116 static int kf_low_motion_minq[QINDEX_RANGE];
121 static int kf_high_motion_minq[QINDEX_RANGE]; 117 static int kf_high_motion_minq[QINDEX_RANGE];
122 static int gf_low_motion_minq[QINDEX_RANGE]; 118 static int gf_low_motion_minq[QINDEX_RANGE];
123 static int gf_high_motion_minq[QINDEX_RANGE]; 119 static int gf_high_motion_minq[QINDEX_RANGE];
124 static int inter_minq[QINDEX_RANGE]; 120 static int inter_minq[QINDEX_RANGE];
121 static int afq_low_motion_minq[QINDEX_RANGE];
122 static int afq_high_motion_minq[QINDEX_RANGE];
125 123
126 static INLINE void Scale2Ratio(int mode, int *hr, int *hs) { 124 static INLINE void Scale2Ratio(int mode, int *hr, int *hs) {
127 switch (mode) { 125 switch (mode) {
128 case NORMAL: 126 case NORMAL:
129 *hr = 1; 127 *hr = 1;
130 *hs = 1; 128 *hs = 1;
131 break; 129 break;
132 case FOURFIVE: 130 case FOURFIVE:
133 *hr = 4; 131 *hr = 4;
134 *hs = 5; 132 *hs = 5;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 0.0); 184 0.0);
187 kf_high_motion_minq[i] = calculate_minq_index(maxq, 185 kf_high_motion_minq[i] = calculate_minq_index(maxq,
188 0.000002, 186 0.000002,
189 -0.0012, 187 -0.0012,
190 0.5, 188 0.5,
191 0.0); 189 0.0);
192 190
193 gf_low_motion_minq[i] = calculate_minq_index(maxq, 191 gf_low_motion_minq[i] = calculate_minq_index(maxq,
194 0.0000015, 192 0.0000015,
195 -0.0009, 193 -0.0009,
196 0.33, 194 0.32,
197 0.0); 195 0.0);
198 gf_high_motion_minq[i] = calculate_minq_index(maxq, 196 gf_high_motion_minq[i] = calculate_minq_index(maxq,
199 0.0000021, 197 0.0000021,
200 -0.00125, 198 -0.00125,
201 0.45, 199 0.50,
202 0.0); 200 0.0);
203 inter_minq[i] = calculate_minq_index(maxq, 201 inter_minq[i] = calculate_minq_index(maxq,
204 0.00000271, 202 0.00000271,
205 -0.00113, 203 -0.00113,
206 0.697, 204 0.75,
207 0.0); 205 0.0);
208 206 afq_low_motion_minq[i] = calculate_minq_index(maxq,
207 0.0000015,
208 -0.0009,
209 0.33,
210 0.0);
211 afq_high_motion_minq[i] = calculate_minq_index(maxq,
212 0.0000021,
213 -0.00125,
214 0.55,
215 0.0);
209 } 216 }
210 } 217 }
211 218
212 static void set_mvcost(MACROBLOCK *mb) { 219 static int get_active_quality(int q,
213 if (mb->e_mbd.allow_high_precision_mv) { 220 int gfu_boost,
221 int low,
222 int high,
223 int *low_motion_minq,
224 int *high_motion_minq) {
225 int active_best_quality;
226 if (gfu_boost > high) {
227 active_best_quality = low_motion_minq[q];
228 } else if (gfu_boost < low) {
229 active_best_quality = high_motion_minq[q];
230 } else {
231 const int gap = high - low;
232 const int offset = high - gfu_boost;
233 const int qdiff = high_motion_minq[q] - low_motion_minq[q];
234 const int adjustment = ((offset * qdiff) + (gap >> 1)) / gap;
235 active_best_quality = low_motion_minq[q] + adjustment;
236 }
237 return active_best_quality;
238 }
239
240 static void set_mvcost(VP9_COMP *cpi) {
241 MACROBLOCK *const mb = &cpi->mb;
242 if (cpi->common.allow_high_precision_mv) {
214 mb->mvcost = mb->nmvcost_hp; 243 mb->mvcost = mb->nmvcost_hp;
215 mb->mvsadcost = mb->nmvsadcost_hp; 244 mb->mvsadcost = mb->nmvsadcost_hp;
216 } else { 245 } else {
217 mb->mvcost = mb->nmvcost; 246 mb->mvcost = mb->nmvcost;
218 mb->mvsadcost = mb->nmvsadcost; 247 mb->mvsadcost = mb->nmvsadcost;
219 } 248 }
220 } 249 }
221 250
222 void vp9_initialize_enc() { 251 void vp9_initialize_enc() {
223 static int init_done = 0; 252 static int init_done = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 306
278 vpx_free(cpi->tok); 307 vpx_free(cpi->tok);
279 cpi->tok = 0; 308 cpi->tok = 0;
280 309
281 // Activity mask based per mb zbin adjustments 310 // Activity mask based per mb zbin adjustments
282 vpx_free(cpi->mb_activity_map); 311 vpx_free(cpi->mb_activity_map);
283 cpi->mb_activity_map = 0; 312 cpi->mb_activity_map = 0;
284 vpx_free(cpi->mb_norm_activity_map); 313 vpx_free(cpi->mb_norm_activity_map);
285 cpi->mb_norm_activity_map = 0; 314 cpi->mb_norm_activity_map = 0;
286 315
287 vpx_free(cpi->mb.pip); 316 vpx_free(cpi->above_context[0]);
288 cpi->mb.pip = 0; 317 cpi->above_context[0] = NULL;
318
319 vpx_free(cpi->above_seg_context);
320 cpi->above_seg_context = NULL;
289 } 321 }
290 322
291 // Computes a q delta (in "q index" terms) to get from a starting q value 323 // Computes a q delta (in "q index" terms) to get from a starting q value
292 // to a target value 324 // to a target value
293 // target q value 325 // target q value
294 static int compute_qdelta(VP9_COMP *cpi, double qstart, double qtarget) { 326 int vp9_compute_qdelta(VP9_COMP *cpi, double qstart, double qtarget) {
295 int i; 327 int i;
296 int start_index = cpi->worst_quality; 328 int start_index = cpi->worst_quality;
297 int target_index = cpi->worst_quality; 329 int target_index = cpi->worst_quality;
298 330
299 // Convert the average q value to an index. 331 // Convert the average q value to an index.
300 for (i = cpi->best_quality; i < cpi->worst_quality; i++) { 332 for (i = cpi->best_quality; i < cpi->worst_quality; i++) {
301 start_index = i; 333 start_index = i;
302 if (vp9_convert_qindex_to_q(i) >= qstart) 334 if (vp9_convert_qindex_to_q(i) >= qstart)
303 break; 335 break;
304 } 336 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 // Scan frames from current to arf frame. 380 // Scan frames from current to arf frame.
349 // This function re-enables segmentation if appropriate. 381 // This function re-enables segmentation if appropriate.
350 vp9_update_mbgraph_stats(cpi); 382 vp9_update_mbgraph_stats(cpi);
351 383
352 // If segmentation was enabled set those features needed for the 384 // If segmentation was enabled set those features needed for the
353 // arf itself. 385 // arf itself.
354 if (seg->enabled) { 386 if (seg->enabled) {
355 seg->update_map = 1; 387 seg->update_map = 1;
356 seg->update_data = 1; 388 seg->update_data = 1;
357 389
358 qi_delta = compute_qdelta(cpi, cpi->avg_q, (cpi->avg_q * 0.875)); 390 qi_delta = vp9_compute_qdelta(cpi, cpi->avg_q, (cpi->avg_q * 0.875));
359 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta - 2)); 391 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta - 2));
360 vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2); 392 vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
361 393
362 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q); 394 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
363 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF); 395 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);
364 396
365 // Where relevant assume segment data is delta data 397 // Where relevant assume segment data is delta data
366 seg->abs_delta = SEGMENT_DELTADATA; 398 seg->abs_delta = SEGMENT_DELTADATA;
367
368 } 399 }
369 } else if (seg->enabled) { 400 } else if (seg->enabled) {
370 // All other frames if segmentation has been enabled 401 // All other frames if segmentation has been enabled
371 402
372 // First normal frame in a valid gf or alt ref group 403 // First normal frame in a valid gf or alt ref group
373 if (cpi->frames_since_golden == 0) { 404 if (cpi->frames_since_golden == 0) {
374 // Set up segment features for normal frames in an arf group 405 // Set up segment features for normal frames in an arf group
375 if (cpi->source_alt_ref_active) { 406 if (cpi->source_alt_ref_active) {
376 seg->update_map = 0; 407 seg->update_map = 0;
377 seg->update_data = 1; 408 seg->update_data = 1;
378 seg->abs_delta = SEGMENT_DELTADATA; 409 seg->abs_delta = SEGMENT_DELTADATA;
379 410
380 qi_delta = compute_qdelta(cpi, cpi->avg_q, 411 qi_delta = vp9_compute_qdelta(cpi, cpi->avg_q,
381 (cpi->avg_q * 1.125)); 412 (cpi->avg_q * 1.125));
382 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta + 2)); 413 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta + 2));
383 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q); 414 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
384 415
385 vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2); 416 vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
386 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF); 417 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);
387 418
388 // Segment coding disabled for compred testing 419 // Segment coding disabled for compred testing
389 if (high_q || (cpi->static_mb_pct == 100)) { 420 if (high_q || (cpi->static_mb_pct == 100)) {
390 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME); 421 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
391 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME); 422 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
(...skipping 22 matching lines...) Expand all
414 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME); 445 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
415 446
416 // All mbs should use ALTREF_FRAME 447 // All mbs should use ALTREF_FRAME
417 vp9_clear_segdata(seg, 0, SEG_LVL_REF_FRAME); 448 vp9_clear_segdata(seg, 0, SEG_LVL_REF_FRAME);
418 vp9_set_segdata(seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME); 449 vp9_set_segdata(seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME);
419 vp9_clear_segdata(seg, 1, SEG_LVL_REF_FRAME); 450 vp9_clear_segdata(seg, 1, SEG_LVL_REF_FRAME);
420 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME); 451 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
421 452
422 // Skip all MBs if high Q (0,0 mv and skip coeffs) 453 // Skip all MBs if high Q (0,0 mv and skip coeffs)
423 if (high_q) { 454 if (high_q) {
424 vp9_enable_segfeature(seg, 0, SEG_LVL_SKIP); 455 vp9_enable_segfeature(seg, 0, SEG_LVL_SKIP);
425 vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP); 456 vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP);
426 } 457 }
427 // Enable data update 458 // Enable data update
428 seg->update_data = 1; 459 seg->update_data = 1;
429 } else { 460 } else {
430 // All other frames. 461 // All other frames.
431 462
432 // No updates.. leave things as they are. 463 // No updates.. leave things as they are.
433 seg->update_map = 0; 464 seg->update_map = 0;
434 seg->update_data = 0; 465 seg->update_data = 0;
435 } 466 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 sf->thresh_mult[THR_COMP_NEARESTGA] += 1000; 608 sf->thresh_mult[THR_COMP_NEARESTGA] += 1000;
578 609
579 sf->thresh_mult[THR_TM] += 1000; 610 sf->thresh_mult[THR_TM] += 1000;
580 611
581 sf->thresh_mult[THR_COMP_NEARLA] += 1500; 612 sf->thresh_mult[THR_COMP_NEARLA] += 1500;
582 sf->thresh_mult[THR_COMP_NEWLA] += 2000; 613 sf->thresh_mult[THR_COMP_NEWLA] += 2000;
583 sf->thresh_mult[THR_NEARG] += 1000; 614 sf->thresh_mult[THR_NEARG] += 1000;
584 sf->thresh_mult[THR_COMP_NEARGA] += 1500; 615 sf->thresh_mult[THR_COMP_NEARGA] += 1500;
585 sf->thresh_mult[THR_COMP_NEWGA] += 2000; 616 sf->thresh_mult[THR_COMP_NEWGA] += 2000;
586 617
587 sf->thresh_mult[THR_SPLITMV] += 2500;
588 sf->thresh_mult[THR_SPLITG] += 2500;
589 sf->thresh_mult[THR_SPLITA] += 2500;
590 sf->thresh_mult[THR_COMP_SPLITLA] += 4500;
591 sf->thresh_mult[THR_COMP_SPLITGA] += 4500;
592
593 sf->thresh_mult[THR_ZEROMV] += 2000; 618 sf->thresh_mult[THR_ZEROMV] += 2000;
594 sf->thresh_mult[THR_ZEROG] += 2000; 619 sf->thresh_mult[THR_ZEROG] += 2000;
595 sf->thresh_mult[THR_ZEROA] += 2000; 620 sf->thresh_mult[THR_ZEROA] += 2000;
596 sf->thresh_mult[THR_COMP_ZEROLA] += 2500; 621 sf->thresh_mult[THR_COMP_ZEROLA] += 2500;
597 sf->thresh_mult[THR_COMP_ZEROGA] += 2500; 622 sf->thresh_mult[THR_COMP_ZEROGA] += 2500;
598 623
599 sf->thresh_mult[THR_B_PRED] += 2500;
600 sf->thresh_mult[THR_H_PRED] += 2000; 624 sf->thresh_mult[THR_H_PRED] += 2000;
601 sf->thresh_mult[THR_V_PRED] += 2000; 625 sf->thresh_mult[THR_V_PRED] += 2000;
602 sf->thresh_mult[THR_D45_PRED ] += 2500; 626 sf->thresh_mult[THR_D45_PRED ] += 2500;
603 sf->thresh_mult[THR_D135_PRED] += 2500; 627 sf->thresh_mult[THR_D135_PRED] += 2500;
604 sf->thresh_mult[THR_D117_PRED] += 2500; 628 sf->thresh_mult[THR_D117_PRED] += 2500;
605 sf->thresh_mult[THR_D153_PRED] += 2500; 629 sf->thresh_mult[THR_D153_PRED] += 2500;
606 sf->thresh_mult[THR_D207_PRED] += 2500; 630 sf->thresh_mult[THR_D207_PRED] += 2500;
607 sf->thresh_mult[THR_D63_PRED] += 2500; 631 sf->thresh_mult[THR_D63_PRED] += 2500;
608 632
609 /* disable frame modes if flags not set */ 633 /* disable frame modes if flags not set */
610 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) { 634 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG)) {
611 sf->thresh_mult[THR_NEWMV ] = INT_MAX; 635 sf->thresh_mult[THR_NEWMV ] = INT_MAX;
612 sf->thresh_mult[THR_NEARESTMV] = INT_MAX; 636 sf->thresh_mult[THR_NEARESTMV] = INT_MAX;
613 sf->thresh_mult[THR_ZEROMV ] = INT_MAX; 637 sf->thresh_mult[THR_ZEROMV ] = INT_MAX;
614 sf->thresh_mult[THR_NEARMV ] = INT_MAX; 638 sf->thresh_mult[THR_NEARMV ] = INT_MAX;
615 sf->thresh_mult[THR_SPLITMV ] = INT_MAX;
616 } 639 }
617 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) { 640 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG)) {
618 sf->thresh_mult[THR_NEARESTG ] = INT_MAX; 641 sf->thresh_mult[THR_NEARESTG ] = INT_MAX;
619 sf->thresh_mult[THR_ZEROG ] = INT_MAX; 642 sf->thresh_mult[THR_ZEROG ] = INT_MAX;
620 sf->thresh_mult[THR_NEARG ] = INT_MAX; 643 sf->thresh_mult[THR_NEARG ] = INT_MAX;
621 sf->thresh_mult[THR_NEWG ] = INT_MAX; 644 sf->thresh_mult[THR_NEWG ] = INT_MAX;
622 sf->thresh_mult[THR_SPLITG ] = INT_MAX;
623 } 645 }
624 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) { 646 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG)) {
625 sf->thresh_mult[THR_NEARESTA ] = INT_MAX; 647 sf->thresh_mult[THR_NEARESTA ] = INT_MAX;
626 sf->thresh_mult[THR_ZEROA ] = INT_MAX; 648 sf->thresh_mult[THR_ZEROA ] = INT_MAX;
627 sf->thresh_mult[THR_NEARA ] = INT_MAX; 649 sf->thresh_mult[THR_NEARA ] = INT_MAX;
628 sf->thresh_mult[THR_NEWA ] = INT_MAX; 650 sf->thresh_mult[THR_NEWA ] = INT_MAX;
629 sf->thresh_mult[THR_SPLITA ] = INT_MAX;
630 } 651 }
631 652
632 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) != 653 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) !=
633 (VP9_LAST_FLAG | VP9_ALT_FLAG)) { 654 (VP9_LAST_FLAG | VP9_ALT_FLAG)) {
634 sf->thresh_mult[THR_COMP_ZEROLA ] = INT_MAX; 655 sf->thresh_mult[THR_COMP_ZEROLA ] = INT_MAX;
635 sf->thresh_mult[THR_COMP_NEARESTLA] = INT_MAX; 656 sf->thresh_mult[THR_COMP_NEARESTLA] = INT_MAX;
636 sf->thresh_mult[THR_COMP_NEARLA ] = INT_MAX; 657 sf->thresh_mult[THR_COMP_NEARLA ] = INT_MAX;
637 sf->thresh_mult[THR_COMP_NEWLA ] = INT_MAX; 658 sf->thresh_mult[THR_COMP_NEWLA ] = INT_MAX;
638 sf->thresh_mult[THR_COMP_SPLITLA ] = INT_MAX;
639 } 659 }
640 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) != 660 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) !=
641 (VP9_GOLD_FLAG | VP9_ALT_FLAG)) { 661 (VP9_GOLD_FLAG | VP9_ALT_FLAG)) {
642 sf->thresh_mult[THR_COMP_ZEROGA ] = INT_MAX; 662 sf->thresh_mult[THR_COMP_ZEROGA ] = INT_MAX;
643 sf->thresh_mult[THR_COMP_NEARESTGA] = INT_MAX; 663 sf->thresh_mult[THR_COMP_NEARESTGA] = INT_MAX;
644 sf->thresh_mult[THR_COMP_NEARGA ] = INT_MAX; 664 sf->thresh_mult[THR_COMP_NEARGA ] = INT_MAX;
645 sf->thresh_mult[THR_COMP_NEWGA ] = INT_MAX; 665 sf->thresh_mult[THR_COMP_NEWGA ] = INT_MAX;
646 sf->thresh_mult[THR_COMP_SPLITGA ] = INT_MAX;
647 }
648
649 if (sf->disable_splitmv == 1) {
650 sf->thresh_mult[THR_SPLITMV ] = INT_MAX;
651 sf->thresh_mult[THR_SPLITG ] = INT_MAX;
652 sf->thresh_mult[THR_SPLITA ] = INT_MAX;
653
654 sf->thresh_mult[THR_COMP_SPLITLA ] = INT_MAX;
655 sf->thresh_mult[THR_COMP_SPLITGA ] = INT_MAX;
656 } 666 }
657 } 667 }
658 668
669 static void set_rd_speed_thresholds_sub8x8(VP9_COMP *cpi, int mode) {
670 SPEED_FEATURES *sf = &cpi->sf;
671 int i;
672
673 for (i = 0; i < MAX_REFS; ++i)
674 sf->thresh_mult_sub8x8[i] = mode == 0 ? -500 : 0;
675
676 sf->thresh_mult_sub8x8[THR_LAST] += 2500;
677 sf->thresh_mult_sub8x8[THR_GOLD] += 2500;
678 sf->thresh_mult_sub8x8[THR_ALTR] += 2500;
679 sf->thresh_mult_sub8x8[THR_INTRA] += 2500;
680 sf->thresh_mult_sub8x8[THR_COMP_LA] += 4500;
681 sf->thresh_mult_sub8x8[THR_COMP_GA] += 4500;
682
683 // Check for masked out split cases.
684 for (i = 0; i < MAX_REFS; i++) {
685 if (sf->disable_split_mask & (1 << i))
686 sf->thresh_mult_sub8x8[i] = INT_MAX;
687 }
688
689 // disable mode test if frame flag is not set
690 if (!(cpi->ref_frame_flags & VP9_LAST_FLAG))
691 sf->thresh_mult_sub8x8[THR_LAST] = INT_MAX;
692 if (!(cpi->ref_frame_flags & VP9_GOLD_FLAG))
693 sf->thresh_mult_sub8x8[THR_GOLD] = INT_MAX;
694 if (!(cpi->ref_frame_flags & VP9_ALT_FLAG))
695 sf->thresh_mult_sub8x8[THR_ALTR] = INT_MAX;
696 if ((cpi->ref_frame_flags & (VP9_LAST_FLAG | VP9_ALT_FLAG)) !=
697 (VP9_LAST_FLAG | VP9_ALT_FLAG))
698 sf->thresh_mult_sub8x8[THR_COMP_LA] = INT_MAX;
699 if ((cpi->ref_frame_flags & (VP9_GOLD_FLAG | VP9_ALT_FLAG)) !=
700 (VP9_GOLD_FLAG | VP9_ALT_FLAG))
701 sf->thresh_mult_sub8x8[THR_COMP_GA] = INT_MAX;
702 }
703
659 void vp9_set_speed_features(VP9_COMP *cpi) { 704 void vp9_set_speed_features(VP9_COMP *cpi) {
660 SPEED_FEATURES *sf = &cpi->sf; 705 SPEED_FEATURES *sf = &cpi->sf;
661 int mode = cpi->compressor_speed; 706 int mode = cpi->compressor_speed;
662 int speed = cpi->speed; 707 int speed = cpi->speed;
663 int i; 708 int i;
664 709
665 // Only modes 0 and 1 supported for now in experimental code basae 710 // Only modes 0 and 1 supported for now in experimental code basae
666 if (mode > 1) 711 if (mode > 1)
667 mode = 1; 712 mode = 1;
668 713
669 // Initialise default mode frequency sampling variables 714 for (i = 0; i < MAX_MODES; ++i)
670 for (i = 0; i < MAX_MODES; i ++) {
671 cpi->mode_check_freq[i] = 0;
672 cpi->mode_test_hit_counts[i] = 0;
673 cpi->mode_chosen_counts[i] = 0; 715 cpi->mode_chosen_counts[i] = 0;
674 }
675 716
676 // best quality defaults 717 // best quality defaults
677 sf->RD = 1; 718 sf->RD = 1;
678 sf->search_method = NSTEP; 719 sf->search_method = NSTEP;
679 sf->auto_filter = 1; 720 sf->auto_filter = 1;
680 sf->recode_loop = 1; 721 sf->recode_loop = 1;
681 sf->subpel_search_method = SUBPEL_TREE; 722 sf->subpel_search_method = SUBPEL_TREE;
682 sf->subpel_iters_per_step = 2; 723 sf->subpel_iters_per_step = 2;
683 sf->optimize_coefficients = !cpi->oxcf.lossless; 724 sf->optimize_coefficients = !cpi->oxcf.lossless;
684 sf->reduce_first_step_size = 0; 725 sf->reduce_first_step_size = 0;
685 sf->auto_mv_step_size = 0; 726 sf->auto_mv_step_size = 0;
686 sf->max_step_search_steps = MAX_MVSEARCH_STEPS; 727 sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
687 sf->comp_inter_joint_search_thresh = BLOCK_4X4; 728 sf->comp_inter_joint_search_thresh = BLOCK_4X4;
688 sf->adaptive_rd_thresh = 0; 729 sf->adaptive_rd_thresh = 0;
689 sf->use_lastframe_partitioning = 0; 730 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_OFF;
690 sf->tx_size_search_method = USE_FULL_RD; 731 sf->tx_size_search_method = USE_FULL_RD;
691 sf->use_lp32x32fdct = 0; 732 sf->use_lp32x32fdct = 0;
692 sf->adaptive_motion_search = 0; 733 sf->adaptive_motion_search = 0;
693 sf->use_avoid_tested_higherror = 0; 734 sf->use_avoid_tested_higherror = 0;
694 sf->reference_masking = 0; 735 sf->reference_masking = 0;
695 sf->partition_by_variance = 0;
696 sf->use_one_partition_size_always = 0; 736 sf->use_one_partition_size_always = 0;
697 sf->less_rectangular_check = 0; 737 sf->less_rectangular_check = 0;
698 sf->use_square_partition_only = 0; 738 sf->use_square_partition_only = 0;
699 sf->auto_min_max_partition_size = 0; 739 sf->auto_min_max_partition_size = 0;
700 sf->auto_min_max_partition_interval = 0;
701 sf->auto_min_max_partition_count = 0;
702 sf->max_partition_size = BLOCK_64X64; 740 sf->max_partition_size = BLOCK_64X64;
703 sf->min_partition_size = BLOCK_4X4; 741 sf->min_partition_size = BLOCK_4X4;
704 sf->adjust_partitioning_from_last_frame = 0; 742 sf->adjust_partitioning_from_last_frame = 0;
705 sf->last_partitioning_redo_frequency = 4; 743 sf->last_partitioning_redo_frequency = 4;
706 sf->disable_splitmv = 0; 744 sf->disable_split_mask = 0;
707 sf->mode_search_skip_flags = 0; 745 sf->mode_search_skip_flags = 0;
708 sf->disable_split_var_thresh = 0; 746 sf->disable_split_var_thresh = 0;
709 sf->disable_filter_search_var_thresh = 0; 747 sf->disable_filter_search_var_thresh = 0;
710 sf->intra_y_mode_mask = ALL_INTRA_MODES; 748 for (i = 0; i < TX_SIZES; i++) {
711 sf->intra_uv_mode_mask = ALL_INTRA_MODES; 749 sf->intra_y_mode_mask[i] = ALL_INTRA_MODES;
750 sf->intra_uv_mode_mask[i] = ALL_INTRA_MODES;
751 }
712 sf->use_rd_breakout = 0; 752 sf->use_rd_breakout = 0;
713 sf->skip_encode_sb = 0; 753 sf->skip_encode_sb = 0;
714 sf->use_uv_intra_rd_estimate = 0; 754 sf->use_uv_intra_rd_estimate = 0;
715 sf->use_fast_lpf_pick = 0; 755 sf->use_fast_lpf_pick = 0;
716 sf->use_fast_coef_updates = 0; 756 sf->use_fast_coef_updates = 0;
717 sf->using_small_partition_info = 0; 757 sf->using_small_partition_info = 0;
718 sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set 758 sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set
719 759
720 #if CONFIG_MULTIPLE_ARF 760 #if CONFIG_MULTIPLE_ARF
721 // Switch segmentation off. 761 // Switch segmentation off.
722 sf->static_segmentation = 0; 762 sf->static_segmentation = 0;
723 #else 763 #else
724 sf->static_segmentation = 0; 764 sf->static_segmentation = 0;
725 #endif 765 #endif
726 766
767 sf->variance_adaptive_quantization = 0;
768
727 switch (mode) { 769 switch (mode) {
728 case 0: // best quality mode 770 case 0: // This is the best quality mode.
729 break; 771 break;
730 772
731 case 1: 773 case 1:
732 #if CONFIG_MULTIPLE_ARF 774 #if CONFIG_MULTIPLE_ARF
733 // Switch segmentation off. 775 // Switch segmentation off.
734 sf->static_segmentation = 0; 776 sf->static_segmentation = 0;
735 #else 777 #else
736 sf->static_segmentation = 0; 778 sf->static_segmentation = 0;
737 #endif 779 #endif
738 sf->use_avoid_tested_higherror = 1; 780 sf->use_avoid_tested_higherror = 1;
739 sf->adaptive_rd_thresh = MIN((speed + 1), 4); 781 sf->adaptive_rd_thresh = 1;
782 sf->recode_loop = (speed < 1);
740 783
741 if (speed == 1) { 784 if (speed == 1) {
742 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; 785 sf->use_square_partition_only = !frame_is_intra_only(&cpi->common);
743 sf->less_rectangular_check = 1; 786 sf->less_rectangular_check = 1;
744 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 787 sf->tx_size_search_method = frame_is_intra_only(&cpi->common)
745 cpi->common.intra_only || 788 ? USE_FULL_RD : USE_LARGESTALL;
746 cpi->common.show_frame == 0) ? 789
747 USE_FULL_RD : 790 if (MIN(cpi->common.width, cpi->common.height) >= 720)
748 USE_LARGESTALL); 791 sf->disable_split_mask = cpi->common.show_frame ?
749 sf->use_square_partition_only = !(cpi->common.frame_type == KEY_FRAME || 792 DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT;
750 cpi->common.intra_only || 793 else
751 cpi->common.show_frame == 0); 794 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
752 sf->disable_splitmv = 795
753 (MIN(cpi->common.width, cpi->common.height) >= 720)? 1 : 0; 796 sf->use_rd_breakout = 1;
797 sf->adaptive_motion_search = 1;
798 sf->auto_mv_step_size = 1;
799 sf->adaptive_rd_thresh = 2;
800 sf->recode_loop = 2;
801 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
802 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
803 sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
804 }
805 if (speed == 2) {
806 sf->use_square_partition_only = !frame_is_intra_only(&cpi->common);
807 sf->less_rectangular_check = 1;
808 sf->tx_size_search_method = frame_is_intra_only(&cpi->common)
809 ? USE_FULL_RD : USE_LARGESTALL;
810
811 if (MIN(cpi->common.width, cpi->common.height) >= 720)
812 sf->disable_split_mask = cpi->common.show_frame ?
813 DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT;
814 else
815 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
816
817
754 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 818 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
755 FLAG_SKIP_INTRA_BESTINTER | 819 FLAG_SKIP_INTRA_BESTINTER |
756 FLAG_SKIP_COMP_BESTINTRA | 820 FLAG_SKIP_COMP_BESTINTRA |
757 FLAG_SKIP_INTRA_LOWVAR; 821 FLAG_SKIP_INTRA_LOWVAR;
758 sf->use_uv_intra_rd_estimate = 1; 822
759 sf->use_rd_breakout = 1; 823 sf->use_rd_breakout = 1;
760 sf->skip_encode_sb = 1;
761 sf->use_lp32x32fdct = 1;
762 sf->adaptive_motion_search = 1; 824 sf->adaptive_motion_search = 1;
763 sf->auto_mv_step_size = 1; 825 sf->auto_mv_step_size = 1;
764 826
827 sf->disable_filter_search_var_thresh = 16;
828 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
829
765 sf->auto_min_max_partition_size = 1; 830 sf->auto_min_max_partition_size = 1;
766 sf->auto_min_max_partition_interval = 1; 831 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_LOW_MOTION;
767 // FIXME(jingning): temporarily turn off disable_split_var_thresh
768 // during refactoring process. will get this back after finishing
769 // the main framework of partition search type.
770 sf->disable_split_var_thresh = 0;
771 sf->disable_filter_search_var_thresh = 16;
772
773 sf->intra_y_mode_mask = INTRA_DC_TM_H_V;
774 sf->intra_uv_mode_mask = INTRA_DC_TM_H_V;
775 sf->use_fast_coef_updates = 1;
776 sf->mode_skip_start = 11;
777 }
778 if (speed == 2) {
779 sf->less_rectangular_check = 1;
780 sf->use_square_partition_only = 1;
781 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
782 sf->use_lastframe_partitioning = 1;
783 sf->adjust_partitioning_from_last_frame = 1; 832 sf->adjust_partitioning_from_last_frame = 1;
784 sf->last_partitioning_redo_frequency = 3; 833 sf->last_partitioning_redo_frequency = 3;
785 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 834
786 cpi->common.intra_only || 835 sf->adaptive_rd_thresh = 2;
787 cpi->common.show_frame == 0) ? 836 sf->recode_loop = 2;
788 USE_FULL_RD : 837 sf->mode_skip_start = 11;
789 USE_LARGESTALL); 838 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
839 sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
840 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
841 sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
842 }
843 if (speed == 3) {
844 sf->use_square_partition_only = 1;
845 sf->tx_size_search_method = USE_LARGESTALL;
846
847 if (MIN(cpi->common.width, cpi->common.height) >= 720)
848 sf->disable_split_mask = DISABLE_ALL_SPLIT;
849 else
850 sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
851
852 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
853 FLAG_SKIP_INTRA_BESTINTER |
854 FLAG_SKIP_COMP_BESTINTRA |
855 FLAG_SKIP_INTRA_LOWVAR;
856
857 sf->use_rd_breakout = 1;
858 sf->adaptive_motion_search = 1;
859 sf->auto_mv_step_size = 1;
860
861 sf->disable_filter_search_var_thresh = 16;
862 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
863
864 sf->auto_min_max_partition_size = 1;
865 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL;
866 sf->adjust_partitioning_from_last_frame = 1;
867 sf->last_partitioning_redo_frequency = 3;
868
869 sf->use_uv_intra_rd_estimate = 1;
870 sf->skip_encode_sb = 1;
871 sf->use_lp32x32fdct = 1;
872 sf->subpel_iters_per_step = 1;
873 sf->use_fast_coef_updates = 2;
874
875 sf->adaptive_rd_thresh = 4;
876 sf->mode_skip_start = 6;
877 }
878 if (speed == 4) {
879 sf->use_square_partition_only = 1;
880 sf->tx_size_search_method = USE_LARGESTALL;
881 sf->disable_split_mask = DISABLE_ALL_SPLIT;
882
790 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 883 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
791 FLAG_SKIP_INTRA_BESTINTER | 884 FLAG_SKIP_INTRA_BESTINTER |
792 FLAG_SKIP_COMP_BESTINTRA | 885 FLAG_SKIP_COMP_BESTINTRA |
793 FLAG_SKIP_COMP_REFMISMATCH | 886 FLAG_SKIP_COMP_REFMISMATCH |
794 FLAG_SKIP_INTRA_LOWVAR | 887 FLAG_SKIP_INTRA_LOWVAR |
795 FLAG_EARLY_TERMINATE; 888 FLAG_EARLY_TERMINATE;
796 sf->intra_y_mode_mask = INTRA_DC_TM; 889
797 sf->intra_uv_mode_mask = INTRA_DC_TM; 890 sf->use_rd_breakout = 1;
891 sf->adaptive_motion_search = 1;
892 sf->auto_mv_step_size = 1;
893
894 sf->disable_filter_search_var_thresh = 16;
895 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
896
897 sf->auto_min_max_partition_size = 1;
898 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL;
899 sf->adjust_partitioning_from_last_frame = 1;
900 sf->last_partitioning_redo_frequency = 3;
901
798 sf->use_uv_intra_rd_estimate = 1; 902 sf->use_uv_intra_rd_estimate = 1;
799 sf->use_rd_breakout = 1;
800 sf->skip_encode_sb = 1; 903 sf->skip_encode_sb = 1;
801 sf->use_lp32x32fdct = 1; 904 sf->use_lp32x32fdct = 1;
802 sf->adaptive_motion_search = 1;
803 sf->using_small_partition_info = 0;
804 sf->disable_splitmv =
805 (MIN(cpi->common.width, cpi->common.height) >= 720)? 1 : 0;
806 sf->auto_mv_step_size = 1;
807 sf->search_method = SQUARE;
808 sf->subpel_iters_per_step = 1; 905 sf->subpel_iters_per_step = 1;
809 sf->use_fast_lpf_pick = 1;
810 sf->auto_min_max_partition_size = 1;
811 sf->auto_min_max_partition_interval = 2;
812 sf->disable_split_var_thresh = 32;
813 sf->disable_filter_search_var_thresh = 32;
814 sf->use_fast_coef_updates = 2; 906 sf->use_fast_coef_updates = 2;
907
908 sf->adaptive_rd_thresh = 4;
815 sf->mode_skip_start = 6; 909 sf->mode_skip_start = 6;
910
911 /* sf->intra_y_mode_mask = INTRA_DC_ONLY;
912 sf->intra_uv_mode_mask = INTRA_DC_ONLY;
913 sf->search_method = BIGDIA;
914 sf->disable_split_var_thresh = 64;
915 sf->disable_filter_search_var_thresh = 64; */
816 } 916 }
817 if (speed == 3) { 917 if (speed == 5) {
818 sf->comp_inter_joint_search_thresh = BLOCK_SIZES; 918 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
819 sf->partition_by_variance = 1; 919 sf->use_one_partition_size_always = 1;
820 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 920 sf->always_this_block_size = BLOCK_16X16;
821 cpi->common.intra_only || 921 sf->tx_size_search_method = frame_is_intra_only(&cpi->common) ?
822 cpi->common.show_frame == 0) ? 922 USE_FULL_RD : USE_LARGESTALL;
823 USE_FULL_RD :
824 USE_LARGESTALL);
825 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 923 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
826 FLAG_SKIP_INTRA_BESTINTER | 924 FLAG_SKIP_INTRA_BESTINTER |
827 FLAG_SKIP_COMP_BESTINTRA | 925 FLAG_SKIP_COMP_BESTINTRA |
828 FLAG_SKIP_COMP_REFMISMATCH |
829 FLAG_SKIP_INTRA_LOWVAR |
830 FLAG_EARLY_TERMINATE;
831 sf->use_rd_breakout = 1;
832 sf->skip_encode_sb = 1;
833 sf->use_lp32x32fdct = 1;
834 sf->disable_splitmv = 1;
835 sf->auto_mv_step_size = 1;
836 sf->search_method = BIGDIA;
837 sf->subpel_iters_per_step = 1;
838 sf->disable_split_var_thresh = 64;
839 sf->disable_filter_search_var_thresh = 64;
840 sf->intra_y_mode_mask = INTRA_DC_ONLY;
841 sf->intra_uv_mode_mask = INTRA_DC_ONLY;
842 sf->use_fast_coef_updates = 2;
843 sf->mode_skip_start = 6;
844 }
845 if (speed == 4) {
846 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
847 sf->use_one_partition_size_always = 1;
848 sf->always_this_block_size = BLOCK_16X16;
849 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME ||
850 cpi->common.intra_only ||
851 cpi->common.show_frame == 0) ?
852 USE_FULL_RD :
853 USE_LARGESTALL);
854 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
855 FLAG_SKIP_INTRA_BESTINTER |
856 FLAG_SKIP_COMP_BESTINTRA |
857 FLAG_SKIP_COMP_REFMISMATCH | 926 FLAG_SKIP_COMP_REFMISMATCH |
858 FLAG_SKIP_INTRA_LOWVAR | 927 FLAG_SKIP_INTRA_LOWVAR |
859 FLAG_EARLY_TERMINATE; 928 FLAG_EARLY_TERMINATE;
860 sf->use_rd_breakout = 1; 929 sf->use_rd_breakout = 1;
861 sf->use_lp32x32fdct = 1; 930 sf->use_lp32x32fdct = 1;
862 sf->optimize_coefficients = 0; 931 sf->optimize_coefficients = 0;
863 sf->auto_mv_step_size = 1; 932 sf->auto_mv_step_size = 1;
864 // sf->reduce_first_step_size = 1; 933 // sf->reduce_first_step_size = 1;
865 // sf->reference_masking = 1; 934 // sf->reference_masking = 1;
866 935
867 sf->disable_splitmv = 1; 936 sf->disable_split_mask = DISABLE_ALL_SPLIT;
868 sf->search_method = HEX; 937 sf->search_method = HEX;
869 sf->subpel_iters_per_step = 1; 938 sf->subpel_iters_per_step = 1;
870 sf->disable_split_var_thresh = 64; 939 sf->disable_split_var_thresh = 64;
871 sf->disable_filter_search_var_thresh = 96; 940 sf->disable_filter_search_var_thresh = 96;
872 sf->intra_y_mode_mask = INTRA_DC_ONLY; 941 for (i = 0; i < TX_SIZES; i++) {
873 sf->intra_uv_mode_mask = INTRA_DC_ONLY; 942 sf->intra_y_mode_mask[i] = INTRA_DC_ONLY;
943 sf->intra_uv_mode_mask[i] = INTRA_DC_ONLY;
944 }
874 sf->use_fast_coef_updates = 2; 945 sf->use_fast_coef_updates = 2;
946 sf->adaptive_rd_thresh = 4;
875 sf->mode_skip_start = 6; 947 sf->mode_skip_start = 6;
876 } 948 }
877 break; 949 break;
878
879 }; /* switch */ 950 }; /* switch */
880 951
881 // Set rd thresholds based on mode and speed setting 952 // Set rd thresholds based on mode and speed setting
882 set_rd_speed_thresholds(cpi, mode); 953 set_rd_speed_thresholds(cpi, mode);
954 set_rd_speed_thresholds_sub8x8(cpi, mode);
883 955
884 // Slow quant, dct and trellis not worthwhile for first pass 956 // Slow quant, dct and trellis not worthwhile for first pass
885 // so make sure they are always turned off. 957 // so make sure they are always turned off.
886 if (cpi->pass == 1) { 958 if (cpi->pass == 1) {
887 sf->optimize_coefficients = 0; 959 sf->optimize_coefficients = 0;
888 } 960 }
889 961
890 cpi->mb.fwd_txm16x16 = vp9_short_fdct16x16; 962 // No recode for 1 pass.
891 cpi->mb.fwd_txm8x8 = vp9_short_fdct8x8; 963 if (cpi->pass == 0) {
892 cpi->mb.fwd_txm8x4 = vp9_short_fdct8x4; 964 sf->recode_loop = 0;
893 cpi->mb.fwd_txm4x4 = vp9_short_fdct4x4; 965 sf->optimize_coefficients = 0;
894 if (cpi->oxcf.lossless || cpi->mb.e_mbd.lossless) {
895 cpi->mb.fwd_txm8x4 = vp9_short_walsh8x4;
896 cpi->mb.fwd_txm4x4 = vp9_short_walsh4x4;
897 } 966 }
898 967
899 cpi->mb.quantize_b_4x4 = vp9_regular_quantize_b_4x4; 968 cpi->mb.fwd_txm4x4 = vp9_fdct4x4;
969 if (cpi->oxcf.lossless || cpi->mb.e_mbd.lossless) {
970 cpi->mb.fwd_txm4x4 = vp9_fwht4x4;
971 }
900 972
901 if (cpi->sf.subpel_search_method == SUBPEL_ITERATIVE) { 973 if (cpi->sf.subpel_search_method == SUBPEL_ITERATIVE) {
902 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_iterative; 974 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_iterative;
903 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_iterative; 975 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_iterative;
904 } else if (cpi->sf.subpel_search_method == SUBPEL_TREE) { 976 } else if (cpi->sf.subpel_search_method == SUBPEL_TREE) {
905 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree; 977 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree;
906 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree; 978 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree;
907 } 979 }
908 980
909 cpi->mb.optimize = cpi->sf.optimize_coefficients == 1 && cpi->pass != 1; 981 cpi->mb.optimize = cpi->sf.optimize_coefficients == 1 && cpi->pass != 1;
(...skipping 14 matching lines...) Expand all
924 "Failed to allocate lag buffers"); 996 "Failed to allocate lag buffers");
925 997
926 if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer, 998 if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer,
927 cpi->oxcf.width, cpi->oxcf.height, 999 cpi->oxcf.width, cpi->oxcf.height,
928 cm->subsampling_x, cm->subsampling_y, 1000 cm->subsampling_x, cm->subsampling_y,
929 VP9BORDERINPIXELS)) 1001 VP9BORDERINPIXELS))
930 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, 1002 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
931 "Failed to allocate altref buffer"); 1003 "Failed to allocate altref buffer");
932 } 1004 }
933 1005
934 static int alloc_partition_data(VP9_COMP *cpi) {
935 vpx_free(cpi->mb.pip);
936
937 cpi->mb.pip = vpx_calloc(cpi->common.mode_info_stride *
938 (cpi->common.mi_rows + MI_BLOCK_SIZE),
939 sizeof(PARTITION_INFO));
940 if (!cpi->mb.pip)
941 return 1;
942
943 cpi->mb.pi = cpi->mb.pip + cpi->common.mode_info_stride + 1;
944
945 return 0;
946 }
947
948 void vp9_alloc_compressor_data(VP9_COMP *cpi) { 1006 void vp9_alloc_compressor_data(VP9_COMP *cpi) {
949 VP9_COMMON *cm = &cpi->common; 1007 VP9_COMMON *cm = &cpi->common;
950 1008
951 if (vp9_alloc_frame_buffers(cm, cm->width, cm->height)) 1009 if (vp9_alloc_frame_buffers(cm, cm->width, cm->height))
952 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, 1010 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
953 "Failed to allocate frame buffers"); 1011 "Failed to allocate frame buffers");
954 1012
955 if (alloc_partition_data(cpi))
956 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
957 "Failed to allocate partition data");
958
959 if (vp9_alloc_frame_buffer(&cpi->last_frame_uf, 1013 if (vp9_alloc_frame_buffer(&cpi->last_frame_uf,
960 cm->width, cm->height, 1014 cm->width, cm->height,
961 cm->subsampling_x, cm->subsampling_y, 1015 cm->subsampling_x, cm->subsampling_y,
962 VP9BORDERINPIXELS)) 1016 VP9BORDERINPIXELS))
963 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR, 1017 vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
964 "Failed to allocate last frame buffer"); 1018 "Failed to allocate last frame buffer");
965 1019
966 if (vp9_alloc_frame_buffer(&cpi->scaled_source, 1020 if (vp9_alloc_frame_buffer(&cpi->scaled_source,
967 cm->width, cm->height, 1021 cm->width, cm->height,
968 cm->subsampling_x, cm->subsampling_y, 1022 cm->subsampling_x, cm->subsampling_y,
(...skipping 16 matching lines...) Expand all
985 1039
986 vpx_free(cpi->mb_activity_map); 1040 vpx_free(cpi->mb_activity_map);
987 CHECK_MEM_ERROR(cm, cpi->mb_activity_map, 1041 CHECK_MEM_ERROR(cm, cpi->mb_activity_map,
988 vpx_calloc(sizeof(unsigned int), 1042 vpx_calloc(sizeof(unsigned int),
989 cm->mb_rows * cm->mb_cols)); 1043 cm->mb_rows * cm->mb_cols));
990 1044
991 vpx_free(cpi->mb_norm_activity_map); 1045 vpx_free(cpi->mb_norm_activity_map);
992 CHECK_MEM_ERROR(cm, cpi->mb_norm_activity_map, 1046 CHECK_MEM_ERROR(cm, cpi->mb_norm_activity_map,
993 vpx_calloc(sizeof(unsigned int), 1047 vpx_calloc(sizeof(unsigned int),
994 cm->mb_rows * cm->mb_cols)); 1048 cm->mb_rows * cm->mb_cols));
1049
1050 // 2 contexts per 'mi unit', so that we have one context per 4x4 txfm
1051 // block where mi unit size is 8x8.
1052 vpx_free(cpi->above_context[0]);
1053 CHECK_MEM_ERROR(cm, cpi->above_context[0],
1054 vpx_calloc(2 * mi_cols_aligned_to_sb(cm->mi_cols) *
1055 MAX_MB_PLANE,
1056 sizeof(*cpi->above_context[0])));
1057
1058 vpx_free(cpi->above_seg_context);
1059 CHECK_MEM_ERROR(cm, cpi->above_seg_context,
1060 vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols),
1061 sizeof(*cpi->above_seg_context)));
995 } 1062 }
996 1063
997 1064
998 static void update_frame_size(VP9_COMP *cpi) { 1065 static void update_frame_size(VP9_COMP *cpi) {
999 VP9_COMMON *cm = &cpi->common; 1066 VP9_COMMON *cm = &cpi->common;
1000 1067
1001 vp9_update_frame_size(cm); 1068 vp9_update_frame_size(cm);
1002 1069
1003 // Update size of buffers local to this frame 1070 // Update size of buffers local to this frame
1004 if (vp9_realloc_frame_buffer(&cpi->last_frame_uf, 1071 if (vp9_realloc_frame_buffer(&cpi->last_frame_uf,
(...skipping 12 matching lines...) Expand all
1017 1084
1018 { 1085 {
1019 int y_stride = cpi->scaled_source.y_stride; 1086 int y_stride = cpi->scaled_source.y_stride;
1020 1087
1021 if (cpi->sf.search_method == NSTEP) { 1088 if (cpi->sf.search_method == NSTEP) {
1022 vp9_init3smotion_compensation(&cpi->mb, y_stride); 1089 vp9_init3smotion_compensation(&cpi->mb, y_stride);
1023 } else if (cpi->sf.search_method == DIAMOND) { 1090 } else if (cpi->sf.search_method == DIAMOND) {
1024 vp9_init_dsmotion_compensation(&cpi->mb, y_stride); 1091 vp9_init_dsmotion_compensation(&cpi->mb, y_stride);
1025 } 1092 }
1026 } 1093 }
1094
1095 {
1096 int i;
1097 for (i = 1; i < MAX_MB_PLANE; ++i) {
1098 cpi->above_context[i] = cpi->above_context[0] +
1099 i * sizeof(*cpi->above_context[0]) * 2 *
1100 mi_cols_aligned_to_sb(cm->mi_cols);
1101 }
1102 }
1027 } 1103 }
1028 1104
1029 1105
1030 // TODO perhaps change number of steps expose to outside world when setting
1031 // max and min limits. Also this will likely want refining for the extended Q
1032 // range.
1033 //
1034 // Table that converts 0-63 Q range values passed in outside to the Qindex 1106 // Table that converts 0-63 Q range values passed in outside to the Qindex
1035 // range used internally. 1107 // range used internally.
1036 static const int q_trans[] = { 1108 static const int q_trans[] = {
1037 0, 4, 8, 12, 16, 20, 24, 28, 1109 0, 4, 8, 12, 16, 20, 24, 28,
1038 32, 36, 40, 44, 48, 52, 56, 60, 1110 32, 36, 40, 44, 48, 52, 56, 60,
1039 64, 68, 72, 76, 80, 84, 88, 92, 1111 64, 68, 72, 76, 80, 84, 88, 92,
1040 96, 100, 104, 108, 112, 116, 120, 124, 1112 96, 100, 104, 108, 112, 116, 120, 124,
1041 128, 132, 136, 140, 144, 148, 152, 156, 1113 128, 132, 136, 140, 144, 148, 152, 156,
1042 160, 164, 168, 172, 176, 180, 184, 188, 1114 160, 164, 168, 172, 176, 180, 184, 188,
1043 192, 196, 200, 204, 208, 212, 216, 220, 1115 192, 196, 200, 204, 208, 212, 216, 220,
1044 224, 228, 232, 236, 240, 244, 249, 255, 1116 224, 228, 232, 236, 240, 244, 249, 255,
1045 }; 1117 };
1046 1118
1047 int vp9_reverse_trans(int x) { 1119 int vp9_reverse_trans(int x) {
1048 int i; 1120 int i;
1049 1121
1050 for (i = 0; i < 64; i++) 1122 for (i = 0; i < 64; i++)
1051 if (q_trans[i] >= x) 1123 if (q_trans[i] >= x)
1052 return i; 1124 return i;
1053 1125
1054 return 63; 1126 return 63;
1055 }; 1127 };
1056 void vp9_new_framerate(VP9_COMP *cpi, double framerate) { 1128 void vp9_new_framerate(VP9_COMP *cpi, double framerate) {
1057 if (framerate < 0.1) 1129 if (framerate < 0.1)
1058 framerate = 30; 1130 framerate = 30;
1059 1131
1060 cpi->oxcf.framerate = framerate; 1132 cpi->oxcf.framerate = framerate;
1061 cpi->output_framerate = cpi->oxcf.framerate; 1133 cpi->output_framerate = cpi->oxcf.framerate;
1062 cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->ou tput_framerate); 1134 cpi->per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth
1063 cpi->av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth / cpi->o utput_framerate); 1135 / cpi->output_framerate);
1064 cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth * cpi->o xcf.two_pass_vbrmin_section / 100); 1136 cpi->av_per_frame_bandwidth = (int)(cpi->oxcf.target_bandwidth
1137 / cpi->output_framerate);
1138 cpi->min_frame_bandwidth = (int)(cpi->av_per_frame_bandwidth *
1139 cpi->oxcf.two_pass_vbrmin_section / 100);
1065 1140
1066 1141
1067 cpi->min_frame_bandwidth = MAX(cpi->min_frame_bandwidth, FRAME_OVERHEAD_BITS); 1142 cpi->min_frame_bandwidth = MAX(cpi->min_frame_bandwidth, FRAME_OVERHEAD_BITS);
1068 1143
1069 // Set Maximum gf/arf interval 1144 // Set Maximum gf/arf interval
1070 cpi->max_gf_interval = 16; 1145 cpi->max_gf_interval = 16;
1071 1146
1072 // Extended interval for genuinely static scenes 1147 // Extended interval for genuinely static scenes
1073 cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1; 1148 cpi->twopass.static_scene_max_gf_interval = cpi->key_frame_frequency >> 1;
1074 1149
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 return; 1240 return;
1166 1241
1167 if (cm->version != oxcf->version) { 1242 if (cm->version != oxcf->version) {
1168 cm->version = oxcf->version; 1243 cm->version = oxcf->version;
1169 } 1244 }
1170 1245
1171 cpi->oxcf = *oxcf; 1246 cpi->oxcf = *oxcf;
1172 1247
1173 switch (cpi->oxcf.Mode) { 1248 switch (cpi->oxcf.Mode) {
1174 // Real time and one pass deprecated in test code base 1249 // Real time and one pass deprecated in test code base
1250 case MODE_GOODQUALITY:
1251 cpi->pass = 0;
1252 cpi->compressor_speed = 2;
1253 cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5);
1254 break;
1255
1175 case MODE_FIRSTPASS: 1256 case MODE_FIRSTPASS:
1176 cpi->pass = 1; 1257 cpi->pass = 1;
1177 cpi->compressor_speed = 1; 1258 cpi->compressor_speed = 1;
1178 break; 1259 break;
1179 1260
1180 case MODE_SECONDPASS: 1261 case MODE_SECONDPASS:
1181 cpi->pass = 2; 1262 cpi->pass = 2;
1182 cpi->compressor_speed = 1; 1263 cpi->compressor_speed = 1;
1183 cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5); 1264 cpi->oxcf.cpu_used = clamp(cpi->oxcf.cpu_used, -5, 5);
1184 break; 1265 break;
1185 1266
1186 case MODE_SECONDPASS_BEST: 1267 case MODE_SECONDPASS_BEST:
1187 cpi->pass = 2; 1268 cpi->pass = 2;
1188 cpi->compressor_speed = 0; 1269 cpi->compressor_speed = 0;
1189 break; 1270 break;
1190 } 1271 }
1191 1272
1192 cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q]; 1273 cpi->oxcf.worst_allowed_q = q_trans[oxcf->worst_allowed_q];
1193 cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q]; 1274 cpi->oxcf.best_allowed_q = q_trans[oxcf->best_allowed_q];
1194 cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level]; 1275 cpi->oxcf.cq_level = q_trans[cpi->oxcf.cq_level];
1195 1276
1196 cpi->oxcf.lossless = oxcf->lossless; 1277 cpi->oxcf.lossless = oxcf->lossless;
1197 if (cpi->oxcf.lossless) { 1278 cpi->mb.e_mbd.itxm_add = cpi->oxcf.lossless ? vp9_iwht4x4_add
1198 cpi->mb.e_mbd.inv_txm4x4_1_add = vp9_short_iwalsh4x4_1_add; 1279 : vp9_idct4x4_add;
1199 cpi->mb.e_mbd.inv_txm4x4_add = vp9_short_iwalsh4x4_add;
1200 } else {
1201 cpi->mb.e_mbd.inv_txm4x4_1_add = vp9_short_idct4x4_1_add;
1202 cpi->mb.e_mbd.inv_txm4x4_add = vp9_short_idct4x4_add;
1203 }
1204
1205 cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL; 1280 cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
1206 1281
1207 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; 1282 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG;
1208 1283
1209 // cpi->use_golden_frame_only = 0; 1284 // cpi->use_golden_frame_only = 0;
1210 // cpi->use_last_frame_only = 0; 1285 // cpi->use_last_frame_only = 0;
1211 cpi->refresh_golden_frame = 0; 1286 cpi->refresh_golden_frame = 0;
1212 cpi->refresh_last_frame = 1; 1287 cpi->refresh_last_frame = 1;
1213 cm->refresh_frame_context = 1; 1288 cm->refresh_frame_context = 1;
1214 cm->reset_frame_context = 0; 1289 cm->reset_frame_context = 0;
1215 1290
1216 setup_features(cm); 1291 setup_features(cm);
1217 cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptatio n 1292 cpi->common.allow_high_precision_mv = 0; // Default mv precision
1218 set_mvcost(&cpi->mb); 1293 set_mvcost(cpi);
1219 1294
1220 { 1295 {
1221 int i; 1296 int i;
1222 1297
1223 for (i = 0; i < MAX_SEGMENTS; i++) 1298 for (i = 0; i < MAX_SEGMENTS; i++)
1224 cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout; 1299 cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout;
1225 } 1300 }
1226 1301
1227 // At the moment the first order values may not be > MAXQ 1302 // At the moment the first order values may not be > MAXQ
1228 cpi->oxcf.fixed_q = MIN(cpi->oxcf.fixed_q, MAXQ); 1303 cpi->oxcf.fixed_q = MIN(cpi->oxcf.fixed_q, MAXQ);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 1435
1361 do { 1436 do {
1362 double z = 256 * (2 * (log2f(8 * i) + .6)); 1437 double z = 256 * (2 * (log2f(8 * i) + .6));
1363 mvsadcost[0][i] = (int)z; 1438 mvsadcost[0][i] = (int)z;
1364 mvsadcost[1][i] = (int)z; 1439 mvsadcost[1][i] = (int)z;
1365 mvsadcost[0][-i] = (int)z; 1440 mvsadcost[0][-i] = (int)z;
1366 mvsadcost[1][-i] = (int)z; 1441 mvsadcost[1][-i] = (int)z;
1367 } while (++i <= MV_MAX); 1442 } while (++i <= MV_MAX);
1368 } 1443 }
1369 1444
1445 static void init_pick_mode_context(VP9_COMP *cpi) {
1446 int i;
1447 MACROBLOCK *x = &cpi->mb;
1448 MACROBLOCKD *xd = &x->e_mbd;
1449 VP9_COMMON *cm = &cpi->common;
1450
1451 for (i = 0; i < BLOCK_SIZES; ++i) {
1452 const int num_4x4_w = num_4x4_blocks_wide_lookup[i];
1453 const int num_4x4_h = num_4x4_blocks_high_lookup[i];
1454 const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h);
1455 if (i < BLOCK_16X16) {
1456 for (xd->sb_index = 0; xd->sb_index < 4; ++xd->sb_index) {
1457 for (xd->mb_index = 0; xd->mb_index < 4; ++xd->mb_index) {
1458 for (xd->b_index = 0; xd->b_index < 16 / num_4x4_blk; ++xd->b_index) {
1459 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1460 ctx->num_4x4_blk = num_4x4_blk;
1461 CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
1462 vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
1463 }
1464 }
1465 }
1466 } else if (i < BLOCK_32X32) {
1467 for (xd->sb_index = 0; xd->sb_index < 4; ++xd->sb_index) {
1468 for (xd->mb_index = 0; xd->mb_index < 64 / num_4x4_blk;
1469 ++xd->mb_index) {
1470 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1471 ctx->num_4x4_blk = num_4x4_blk;
1472 CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
1473 vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
1474 }
1475 }
1476 } else if (i < BLOCK_64X64) {
1477 for (xd->sb_index = 0; xd->sb_index < 256 / num_4x4_blk; ++xd->sb_index) {
1478 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1479 ctx->num_4x4_blk = num_4x4_blk;
1480 CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
1481 vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
1482 }
1483 } else {
1484 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1485 ctx->num_4x4_blk = num_4x4_blk;
1486 CHECK_MEM_ERROR(cm, ctx->zcoeff_blk,
1487 vpx_calloc(num_4x4_blk, sizeof(uint8_t)));
1488 }
1489 }
1490 }
1491
1492 static void free_pick_mode_context(MACROBLOCK *x) {
1493 int i;
1494 MACROBLOCKD *xd = &x->e_mbd;
1495
1496 for (i = 0; i < BLOCK_SIZES; ++i) {
1497 const int num_4x4_w = num_4x4_blocks_wide_lookup[i];
1498 const int num_4x4_h = num_4x4_blocks_high_lookup[i];
1499 const int num_4x4_blk = MAX(4, num_4x4_w * num_4x4_h);
1500 if (i < BLOCK_16X16) {
1501 for (xd->sb_index = 0; xd->sb_index < 4; ++xd->sb_index) {
1502 for (xd->mb_index = 0; xd->mb_index < 4; ++xd->mb_index) {
1503 for (xd->b_index = 0; xd->b_index < 16 / num_4x4_blk; ++xd->b_index) {
1504 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1505 vpx_free(ctx->zcoeff_blk);
1506 ctx->zcoeff_blk = 0;
1507 }
1508 }
1509 }
1510 } else if (i < BLOCK_32X32) {
1511 for (xd->sb_index = 0; xd->sb_index < 4; ++xd->sb_index) {
1512 for (xd->mb_index = 0; xd->mb_index < 64 / num_4x4_blk;
1513 ++xd->mb_index) {
1514 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1515 vpx_free(ctx->zcoeff_blk);
1516 ctx->zcoeff_blk = 0;
1517 }
1518 }
1519 } else if (i < BLOCK_64X64) {
1520 for (xd->sb_index = 0; xd->sb_index < 256 / num_4x4_blk; ++xd->sb_index) {
1521 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1522 vpx_free(ctx->zcoeff_blk);
1523 ctx->zcoeff_blk = 0;
1524 }
1525 } else {
1526 PICK_MODE_CONTEXT *ctx = get_block_context(x, i);
1527 vpx_free(ctx->zcoeff_blk);
1528 ctx->zcoeff_blk = 0;
1529 }
1530 }
1531 }
1532
1370 VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) { 1533 VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
1371 int i, j; 1534 int i, j;
1372 volatile union { 1535 volatile union {
1373 VP9_COMP *cpi; 1536 VP9_COMP *cpi;
1374 VP9_PTR ptr; 1537 VP9_PTR ptr;
1375 } ctx; 1538 } ctx;
1376 1539
1377 VP9_COMP *cpi; 1540 VP9_COMP *cpi;
1378 VP9_COMMON *cm; 1541 VP9_COMMON *cm;
1379 1542
(...skipping 16 matching lines...) Expand all
1396 1559
1397 cm->error.setjmp = 1; 1560 cm->error.setjmp = 1;
1398 1561
1399 CHECK_MEM_ERROR(cm, cpi->mb.ss, vpx_calloc(sizeof(search_site), 1562 CHECK_MEM_ERROR(cm, cpi->mb.ss, vpx_calloc(sizeof(search_site),
1400 (MAX_MVSEARCH_STEPS * 8) + 1)); 1563 (MAX_MVSEARCH_STEPS * 8) + 1));
1401 1564
1402 vp9_create_common(cm); 1565 vp9_create_common(cm);
1403 1566
1404 init_config((VP9_PTR)cpi, oxcf); 1567 init_config((VP9_PTR)cpi, oxcf);
1405 1568
1569 init_pick_mode_context(cpi);
1570
1406 cm->current_video_frame = 0; 1571 cm->current_video_frame = 0;
1407 cpi->kf_overspend_bits = 0; 1572 cpi->kf_overspend_bits = 0;
1408 cpi->kf_bitrate_adjustment = 0; 1573 cpi->kf_bitrate_adjustment = 0;
1409 cpi->frames_till_gf_update_due = 0; 1574 cpi->frames_till_gf_update_due = 0;
1410 cpi->gf_overspend_bits = 0; 1575 cpi->gf_overspend_bits = 0;
1411 cpi->non_gf_bitrate_adjustment = 0; 1576 cpi->non_gf_bitrate_adjustment = 0;
1412 1577
1413 // Set reference frame sign bias for ALTREF frame to 1 (for now) 1578 // Set reference frame sign bias for ALTREF frame to 1 (for now)
1414 cm->ref_frame_sign_bias[ALTREF_FRAME] = 1; 1579 cm->ref_frame_sign_bias[ALTREF_FRAME] = 1;
1415 1580
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1448 #endif 1613 #endif
1449 1614
1450 #ifdef MODE_STATS 1615 #ifdef MODE_STATS
1451 init_tx_count_stats(); 1616 init_tx_count_stats();
1452 init_switchable_interp_stats(); 1617 init_switchable_interp_stats();
1453 #endif 1618 #endif
1454 1619
1455 /*Initialize the feed-forward activity masking.*/ 1620 /*Initialize the feed-forward activity masking.*/
1456 cpi->activity_avg = 90 << 12; 1621 cpi->activity_avg = 90 << 12;
1457 1622
1458 cpi->frames_since_key = 8; // Give a sensible default for the first fra me. 1623 cpi->frames_since_key = 8; // Sensible default for first frame.
1459 cpi->key_frame_frequency = cpi->oxcf.key_freq; 1624 cpi->key_frame_frequency = cpi->oxcf.key_freq;
1460 cpi->this_key_frame_forced = 0; 1625 cpi->this_key_frame_forced = 0;
1461 cpi->next_key_frame_forced = 0; 1626 cpi->next_key_frame_forced = 0;
1462 1627
1463 cpi->source_alt_ref_pending = 0; 1628 cpi->source_alt_ref_pending = 0;
1464 cpi->source_alt_ref_active = 0; 1629 cpi->source_alt_ref_active = 0;
1465 cpi->refresh_alt_ref_frame = 0; 1630 cpi->refresh_alt_ref_frame = 0;
1466 1631
1467 #if CONFIG_MULTIPLE_ARF 1632 #if CONFIG_MULTIPLE_ARF
1468 // Turn multiple ARF usage on/off. This is a quick hack for the initial test 1633 // Turn multiple ARF usage on/off. This is a quick hack for the initial test
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf; 1734 cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf;
1570 cpi->twopass.stats_in = cpi->twopass.stats_in_start; 1735 cpi->twopass.stats_in = cpi->twopass.stats_in_start;
1571 cpi->twopass.stats_in_end = (void *)((char *)cpi->twopass.stats_in 1736 cpi->twopass.stats_in_end = (void *)((char *)cpi->twopass.stats_in
1572 + (packets - 1) * packet_sz); 1737 + (packets - 1) * packet_sz);
1573 vp9_init_second_pass(cpi); 1738 vp9_init_second_pass(cpi);
1574 } 1739 }
1575 1740
1576 vp9_set_speed_features(cpi); 1741 vp9_set_speed_features(cpi);
1577 1742
1578 // Default rd threshold factors for mode selection 1743 // Default rd threshold factors for mode selection
1579 for (i = 0; i < BLOCK_SIZES; ++i) 1744 for (i = 0; i < BLOCK_SIZES; ++i) {
1580 for (j = 0; j < MAX_MODES; ++j) 1745 for (j = 0; j < MAX_MODES; ++j)
1581 cpi->rd_thresh_freq_fact[i][j] = 32; 1746 cpi->rd_thresh_freq_fact[i][j] = 32;
1747 for (j = 0; j < MAX_REFS; ++j)
1748 cpi->rd_thresh_freq_sub8x8[i][j] = 32;
1749 }
1582 1750
1583 #define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SVFHH, SVFHV, SVFHHV, \ 1751 #define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SVFHH, SVFHV, SVFHHV, \
1584 SDX3F, SDX8F, SDX4DF)\ 1752 SDX3F, SDX8F, SDX4DF)\
1585 cpi->fn_ptr[BT].sdf = SDF; \ 1753 cpi->fn_ptr[BT].sdf = SDF; \
1586 cpi->fn_ptr[BT].sdaf = SDAF; \ 1754 cpi->fn_ptr[BT].sdaf = SDAF; \
1587 cpi->fn_ptr[BT].vf = VF; \ 1755 cpi->fn_ptr[BT].vf = VF; \
1588 cpi->fn_ptr[BT].svf = SVF; \ 1756 cpi->fn_ptr[BT].svf = SVF; \
1589 cpi->fn_ptr[BT].svaf = SVAF; \ 1757 cpi->fn_ptr[BT].svaf = SVAF; \
1590 cpi->fn_ptr[BT].svf_halfpix_h = SVFHH; \ 1758 cpi->fn_ptr[BT].svf_halfpix_h = SVFHH; \
1591 cpi->fn_ptr[BT].svf_halfpix_v = SVFHV; \ 1759 cpi->fn_ptr[BT].svf_halfpix_v = SVFHV; \
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 * vp9_frame_init_quantizer() so that vp9_init_quantizer is only 1850 * vp9_frame_init_quantizer() so that vp9_init_quantizer is only
1683 * called later when needed. This will avoid unnecessary calls of 1851 * called later when needed. This will avoid unnecessary calls of
1684 * vp9_init_quantizer() for every frame. 1852 * vp9_init_quantizer() for every frame.
1685 */ 1853 */
1686 vp9_init_quantizer(cpi); 1854 vp9_init_quantizer(cpi);
1687 1855
1688 vp9_loop_filter_init(cm); 1856 vp9_loop_filter_init(cm);
1689 1857
1690 cpi->common.error.setjmp = 0; 1858 cpi->common.error.setjmp = 0;
1691 1859
1692 vp9_zero(cpi->y_uv_mode_count) 1860 vp9_zero(cpi->y_uv_mode_count);
1693 1861
1694 #ifdef MODE_TEST_HIT_STATS 1862 #ifdef MODE_TEST_HIT_STATS
1695 vp9_zero(cpi->mode_test_hits) 1863 vp9_zero(cpi->mode_test_hits);
1696 #endif 1864 #endif
1697 1865
1698 return (VP9_PTR) cpi; 1866 return (VP9_PTR) cpi;
1699 } 1867 }
1700 1868
1701 void vp9_remove_compressor(VP9_PTR *ptr) { 1869 void vp9_remove_compressor(VP9_PTR *ptr) {
1702 VP9_COMP *cpi = (VP9_COMP *)(*ptr); 1870 VP9_COMP *cpi = (VP9_COMP *)(*ptr);
1703 int i; 1871 int i;
1704 1872
1705 if (!cpi) 1873 if (!cpi)
(...skipping 21 matching lines...) Expand all
1727 1895
1728 #if CONFIG_INTERNAL_STATS 1896 #if CONFIG_INTERNAL_STATS
1729 1897
1730 vp9_clear_system_state(); 1898 vp9_clear_system_state();
1731 1899
1732 // printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count); 1900 // printf("\n8x8-4x4:%d-%d\n", cpi->t8x8_count, cpi->t4x4_count);
1733 if (cpi->pass != 1) { 1901 if (cpi->pass != 1) {
1734 FILE *f = fopen("opsnr.stt", "a"); 1902 FILE *f = fopen("opsnr.stt", "a");
1735 double time_encoded = (cpi->last_end_time_stamp_seen 1903 double time_encoded = (cpi->last_end_time_stamp_seen
1736 - cpi->first_time_stamp_ever) / 10000000.000; 1904 - cpi->first_time_stamp_ever) / 10000000.000;
1737 double total_encode_time = (cpi->time_receive_data + cpi->time_compress_da ta) / 1000.000; 1905 double total_encode_time = (cpi->time_receive_data +
1738 double dr = (double)cpi->bytes * (double) 8 / (double)1000 / time_encoded ; 1906 cpi->time_compress_data) / 1000.000;
1907 double dr = (double)cpi->bytes * (double) 8 / (double)1000
1908 / time_encoded;
1739 1909
1740 if (cpi->b_calculate_psnr) { 1910 if (cpi->b_calculate_psnr) {
1741 YV12_BUFFER_CONFIG *lst_yv12 = 1911 YV12_BUFFER_CONFIG *lst_yv12 =
1742 &cpi->common.yv12_fb[cpi->common.ref_frame_map[cpi->lst_fb_idx]]; 1912 &cpi->common.yv12_fb[cpi->common.ref_frame_map[cpi->lst_fb_idx]];
1743 double samples = 3.0 / 2 * cpi->count * 1913 double samples = 3.0 / 2 * cpi->count *
1744 lst_yv12->y_width * lst_yv12->y_height; 1914 lst_yv12->y_width * lst_yv12->y_height;
1745 double total_psnr = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error); 1915 double total_psnr = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error);
1746 double total_psnr2 = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error2); 1916 double total_psnr2 = vp9_mse2psnr(samples, 255.0, cpi->total_sq_error2);
1747 double total_ssim = 100 * pow(cpi->summed_quality / 1917 double total_ssim = 100 * pow(cpi->summed_quality /
1748 cpi->summed_weights, 8.0); 1918 cpi->summed_weights, 8.0);
1749 double total_ssimp = 100 * pow(cpi->summedp_quality / 1919 double total_ssimp = 100 * pow(cpi->summedp_quality /
1750 cpi->summedp_weights, 8.0); 1920 cpi->summedp_weights, 8.0);
1751 1921
1752 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\t" 1922 fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\tGLPsnrP\t"
1753 "VPXSSIM\tVPSSIMP\t Time(ms)\n"); 1923 "VPXSSIM\tVPSSIMP\t Time(ms)\n");
1754 fprintf(f, "%7.2f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n", 1924 fprintf(f, "%7.2f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f\n",
1755 dr, cpi->total / cpi->count, total_psnr, 1925 dr, cpi->total / cpi->count, total_psnr,
1756 cpi->totalp / cpi->count, total_psnr2, total_ssim, total_ssimp, 1926 cpi->totalp / cpi->count, total_psnr2, total_ssim, total_ssimp,
1757 total_encode_time); 1927 total_encode_time);
1758 // fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t%8.0f %10ld\n",
1759 // dr, cpi->total / cpi->count, total_psnr,
1760 // cpi->totalp / cpi->count, total_psnr2, total_ssim,
1761 // total_encode_time, cpi->tot_recode_hits);
1762 } 1928 }
1763 1929
1764 if (cpi->b_calculate_ssimg) { 1930 if (cpi->b_calculate_ssimg) {
1765 fprintf(f, "BitRate\tSSIM_Y\tSSIM_U\tSSIM_V\tSSIM_A\t Time(ms)\n"); 1931 fprintf(f, "BitRate\tSSIM_Y\tSSIM_U\tSSIM_V\tSSIM_A\t Time(ms)\n");
1766 fprintf(f, "%7.2f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f\n", dr, 1932 fprintf(f, "%7.2f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f\n", dr,
1767 cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cpi->count , 1933 cpi->total_ssimg_y / cpi->count,
1768 cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / cpi->cou nt, total_encode_time); 1934 cpi->total_ssimg_u / cpi->count,
1769 // fprintf(f, "%7.3f\t%6.4f\t%6.4f\t%6.4f\t%6.4f\t%8.0f %10ld\n" , dr, 1935 cpi->total_ssimg_v / cpi->count,
1770 // cpi->total_ssimg_y / cpi->count, cpi->total_ssimg_u / cpi->count, 1936 cpi->total_ssimg_all / cpi->count, total_encode_time);
1771 // cpi->total_ssimg_v / cpi->count, cpi->total_ssimg_all / cpi->count, total_encode_time, cpi->tot_recode_hits);
1772 } 1937 }
1773 1938
1774 fclose(f); 1939 fclose(f);
1775 } 1940 }
1776 1941
1777 #endif 1942 #endif
1778 1943
1779 #ifdef MODE_TEST_HIT_STATS 1944 #ifdef MODE_TEST_HIT_STATS
1780 if (cpi->pass != 1) { 1945 if (cpi->pass != 1) {
1781 double norm_per_pixel_mode_tests = 0; 1946 double norm_per_pixel_mode_tests = 0;
(...skipping 26 matching lines...) Expand all
1808 { 1973 {
1809 int i, j, k; 1974 int i, j, k;
1810 FILE *fmode = fopen("vp9_modecontext.c", "w"); 1975 FILE *fmode = fopen("vp9_modecontext.c", "w");
1811 1976
1812 fprintf(fmode, "\n#include \"vp9_entropymode.h\"\n\n"); 1977 fprintf(fmode, "\n#include \"vp9_entropymode.h\"\n\n");
1813 fprintf(fmode, "const unsigned int vp9_kf_default_bmode_counts "); 1978 fprintf(fmode, "const unsigned int vp9_kf_default_bmode_counts ");
1814 fprintf(fmode, "[INTRA_MODES][INTRA_MODES]" 1979 fprintf(fmode, "[INTRA_MODES][INTRA_MODES]"
1815 "[INTRA_MODES] =\n{\n"); 1980 "[INTRA_MODES] =\n{\n");
1816 1981
1817 for (i = 0; i < INTRA_MODES; i++) { 1982 for (i = 0; i < INTRA_MODES; i++) {
1818
1819 fprintf(fmode, " { // Above Mode : %d\n", i); 1983 fprintf(fmode, " { // Above Mode : %d\n", i);
1820 1984
1821 for (j = 0; j < INTRA_MODES; j++) { 1985 for (j = 0; j < INTRA_MODES; j++) {
1822
1823 fprintf(fmode, " {"); 1986 fprintf(fmode, " {");
1824 1987
1825 for (k = 0; k < INTRA_MODES; k++) { 1988 for (k = 0; k < INTRA_MODES; k++) {
1826 if (!intra_mode_stats[i][j][k]) 1989 if (!intra_mode_stats[i][j][k])
1827 fprintf(fmode, " %5d, ", 1); 1990 fprintf(fmode, " %5d, ", 1);
1828 else 1991 else
1829 fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]); 1992 fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]);
1830 } 1993 }
1831 1994
1832 fprintf(fmode, "}, // left_mode %d\n", j); 1995 fprintf(fmode, "}, // left_mode %d\n", j);
1833
1834 } 1996 }
1835 1997
1836 fprintf(fmode, " },\n"); 1998 fprintf(fmode, " },\n");
1837
1838 } 1999 }
1839 2000
1840 fprintf(fmode, "};\n"); 2001 fprintf(fmode, "};\n");
1841 fclose(fmode); 2002 fclose(fmode);
1842 } 2003 }
1843 #endif 2004 #endif
1844 2005
1845 2006
1846 #if defined(SECTIONBITS_OUTPUT) 2007 #if defined(SECTIONBITS_OUTPUT)
1847 2008
(...skipping 13 matching lines...) Expand all
1861 #if 0 2022 #if 0
1862 { 2023 {
1863 printf("\n_pick_loop_filter_level:%d\n", cpi->time_pick_lpf / 1000); 2024 printf("\n_pick_loop_filter_level:%d\n", cpi->time_pick_lpf / 1000);
1864 printf("\n_frames recive_data encod_mb_row compress_frame Total\n"); 2025 printf("\n_frames recive_data encod_mb_row compress_frame Total\n");
1865 printf("%6d %10ld %10ld %10ld %10ld\n", cpi->common.current_video_frame, 2026 printf("%6d %10ld %10ld %10ld %10ld\n", cpi->common.current_video_frame,
1866 cpi->time_receive_data / 1000, cpi->time_encode_sb_row / 1000, 2027 cpi->time_receive_data / 1000, cpi->time_encode_sb_row / 1000,
1867 cpi->time_compress_data / 1000, 2028 cpi->time_compress_data / 1000,
1868 (cpi->time_receive_data + cpi->time_compress_data) / 1000); 2029 (cpi->time_receive_data + cpi->time_compress_data) / 1000);
1869 } 2030 }
1870 #endif 2031 #endif
1871
1872 } 2032 }
1873 2033
2034 free_pick_mode_context(&cpi->mb);
1874 dealloc_compressor_data(cpi); 2035 dealloc_compressor_data(cpi);
1875 vpx_free(cpi->mb.ss); 2036 vpx_free(cpi->mb.ss);
1876 vpx_free(cpi->tok); 2037 vpx_free(cpi->tok);
1877 2038
1878 for (i = 0; i < sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0]); i+ +) { 2039 for (i = 0; i < sizeof(cpi->mbgraph_stats) /
2040 sizeof(cpi->mbgraph_stats[0]); ++i) {
1879 vpx_free(cpi->mbgraph_stats[i].mb_stats); 2041 vpx_free(cpi->mbgraph_stats[i].mb_stats);
1880 } 2042 }
1881 2043
1882 vp9_remove_common(&cpi->common); 2044 vp9_remove_common(&cpi->common);
1883 vpx_free(cpi); 2045 vpx_free(cpi);
1884 *ptr = 0; 2046 *ptr = 0;
1885 2047
1886 #ifdef OUTPUT_YUV_SRC 2048 #ifdef OUTPUT_YUV_SRC
1887 fclose(yuv_file); 2049 fclose(yuv_file);
1888 #endif 2050 #endif
1889 #ifdef OUTPUT_YUV_REC 2051 #ifdef OUTPUT_YUV_REC
1890 fclose(yuv_rec_file); 2052 fclose(yuv_rec_file);
1891 #endif 2053 #endif
1892 2054
1893 #if 0 2055 #if 0
1894 2056
1895 if (keyfile) 2057 if (keyfile)
1896 fclose(keyfile); 2058 fclose(keyfile);
1897 2059
1898 if (framepsnr) 2060 if (framepsnr)
1899 fclose(framepsnr); 2061 fclose(framepsnr);
1900 2062
1901 if (kf_list) 2063 if (kf_list)
1902 fclose(kf_list); 2064 fclose(kf_list);
1903 2065
1904 #endif 2066 #endif
1905
1906 } 2067 }
1907 2068
1908 2069
1909 static uint64_t calc_plane_error(uint8_t *orig, int orig_stride, 2070 static uint64_t calc_plane_error(uint8_t *orig, int orig_stride,
1910 uint8_t *recon, int recon_stride, 2071 uint8_t *recon, int recon_stride,
1911 unsigned int cols, unsigned int rows) { 2072 unsigned int cols, unsigned int rows) {
1912 unsigned int row, col; 2073 unsigned int row, col;
1913 uint64_t total_sse = 0; 2074 uint64_t total_sse = 0;
1914 int diff; 2075 int diff;
1915 2076
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 cpi->source_alt_ref_active = 1; 2377 cpi->source_alt_ref_active = 1;
2217 } 2378 }
2218 static void update_golden_frame_stats(VP9_COMP *cpi) { 2379 static void update_golden_frame_stats(VP9_COMP *cpi) {
2219 // Update the Golden frame usage counts. 2380 // Update the Golden frame usage counts.
2220 if (cpi->refresh_golden_frame) { 2381 if (cpi->refresh_golden_frame) {
2221 // this frame refreshes means next frames don't unless specified by user 2382 // this frame refreshes means next frames don't unless specified by user
2222 cpi->refresh_golden_frame = 0; 2383 cpi->refresh_golden_frame = 0;
2223 cpi->frames_since_golden = 0; 2384 cpi->frames_since_golden = 0;
2224 2385
2225 // ******** Fixed Q test code only ************ 2386 // ******** Fixed Q test code only ************
2226 // If we are going to use the ALT reference for the next group of frames set a flag to say so. 2387 // If we are going to use the ALT reference for the next group of frames
2388 // set a flag to say so.
2227 if (cpi->oxcf.fixed_q >= 0 && 2389 if (cpi->oxcf.fixed_q >= 0 &&
2228 cpi->oxcf.play_alternate && !cpi->refresh_alt_ref_frame) { 2390 cpi->oxcf.play_alternate && !cpi->refresh_alt_ref_frame) {
2229 cpi->source_alt_ref_pending = 1; 2391 cpi->source_alt_ref_pending = 1;
2230 cpi->frames_till_gf_update_due = cpi->baseline_gf_interval; 2392 cpi->frames_till_gf_update_due = cpi->baseline_gf_interval;
2231 2393
2232 // TODO(ivan): for SVC encoder, GF automatic update is disabled by using a 2394 // TODO(ivan): For SVC encoder, GF automatic update is disabled by using
2233 // large GF_interval 2395 // a large GF_interval.
2234 if (cpi->use_svc) { 2396 if (cpi->use_svc) {
2235 cpi->frames_till_gf_update_due = INT_MAX; 2397 cpi->frames_till_gf_update_due = INT_MAX;
2236 } 2398 }
2237 } 2399 }
2238 2400
2239 if (!cpi->source_alt_ref_pending) 2401 if (!cpi->source_alt_ref_pending)
2240 cpi->source_alt_ref_active = 0; 2402 cpi->source_alt_ref_active = 0;
2241 2403
2242 // Decrement count down till next gf 2404 // Decrement count down till next gf
2243 if (cpi->frames_till_gf_update_due > 0) 2405 if (cpi->frames_till_gf_update_due > 0)
(...skipping 19 matching lines...) Expand all
2263 break; 2425 break;
2264 } 2426 }
2265 } 2427 }
2266 2428
2267 if (i == QINDEX_RANGE) 2429 if (i == QINDEX_RANGE)
2268 i--; 2430 i--;
2269 2431
2270 return i; 2432 return i;
2271 } 2433 }
2272 2434
2273 static void Pass1Encode(VP9_COMP *cpi, unsigned long *size, unsigned char *dest, unsigned int *frame_flags) { 2435 static void Pass1Encode(VP9_COMP *cpi, unsigned long *size, unsigned char *dest,
2436 unsigned int *frame_flags) {
2274 (void) size; 2437 (void) size;
2275 (void) dest; 2438 (void) dest;
2276 (void) frame_flags; 2439 (void) frame_flags;
2277 2440
2278
2279 vp9_set_quantizer(cpi, find_fp_qindex()); 2441 vp9_set_quantizer(cpi, find_fp_qindex());
2280 vp9_first_pass(cpi); 2442 vp9_first_pass(cpi);
2281 } 2443 }
2282 2444
2283 #define WRITE_RECON_BUFFER 0 2445 #define WRITE_RECON_BUFFER 0
2284 #if WRITE_RECON_BUFFER 2446 #if WRITE_RECON_BUFFER
2285 void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) { 2447 void write_cx_frame_to_file(YV12_BUFFER_CONFIG *frame, int this_frame) {
2286
2287 // write the frame
2288 FILE *yframe; 2448 FILE *yframe;
2289 int i; 2449 int i;
2290 char filename[255]; 2450 char filename[255];
2291 2451
2292 sprintf(filename, "cx\\y%04d.raw", this_frame); 2452 snprintf(filename, sizeof(filename), "cx\\y%04d.raw", this_frame);
2293 yframe = fopen(filename, "wb"); 2453 yframe = fopen(filename, "wb");
2294 2454
2295 for (i = 0; i < frame->y_height; i++) 2455 for (i = 0; i < frame->y_height; i++)
2296 fwrite(frame->y_buffer + i * frame->y_stride, 2456 fwrite(frame->y_buffer + i * frame->y_stride,
2297 frame->y_width, 1, yframe); 2457 frame->y_width, 1, yframe);
2298 2458
2299 fclose(yframe); 2459 fclose(yframe);
2300 sprintf(filename, "cx\\u%04d.raw", this_frame); 2460 snprintf(filename, sizeof(filename), "cx\\u%04d.raw", this_frame);
2301 yframe = fopen(filename, "wb"); 2461 yframe = fopen(filename, "wb");
2302 2462
2303 for (i = 0; i < frame->uv_height; i++) 2463 for (i = 0; i < frame->uv_height; i++)
2304 fwrite(frame->u_buffer + i * frame->uv_stride, 2464 fwrite(frame->u_buffer + i * frame->uv_stride,
2305 frame->uv_width, 1, yframe); 2465 frame->uv_width, 1, yframe);
2306 2466
2307 fclose(yframe); 2467 fclose(yframe);
2308 sprintf(filename, "cx\\v%04d.raw", this_frame); 2468 snprintf(filename, sizeof(filename), "cx\\v%04d.raw", this_frame);
2309 yframe = fopen(filename, "wb"); 2469 yframe = fopen(filename, "wb");
2310 2470
2311 for (i = 0; i < frame->uv_height; i++) 2471 for (i = 0; i < frame->uv_height; i++)
2312 fwrite(frame->v_buffer + i * frame->uv_stride, 2472 fwrite(frame->v_buffer + i * frame->uv_stride,
2313 frame->uv_width, 1, yframe); 2473 frame->uv_width, 1, yframe);
2314 2474
2315 fclose(yframe); 2475 fclose(yframe);
2316 } 2476 }
2317 #endif 2477 #endif
2318 2478
2319 static double compute_edge_pixel_proportion(YV12_BUFFER_CONFIG *frame) { 2479 static double compute_edge_pixel_proportion(YV12_BUFFER_CONFIG *frame) {
2320 #define EDGE_THRESH 128 2480 #define EDGE_THRESH 128
2321 int i, j; 2481 int i, j;
2322 int num_edge_pels = 0; 2482 int num_edge_pels = 0;
2323 int num_pels = (frame->y_height - 2) * (frame->y_width - 2); 2483 int num_pels = (frame->y_height - 2) * (frame->y_width - 2);
2324 uint8_t *prev = frame->y_buffer + 1; 2484 uint8_t *prev = frame->y_buffer + 1;
2325 uint8_t *curr = frame->y_buffer + 1 + frame->y_stride; 2485 uint8_t *curr = frame->y_buffer + 1 + frame->y_stride;
2326 uint8_t *next = frame->y_buffer + 1 + 2 * frame->y_stride; 2486 uint8_t *next = frame->y_buffer + 1 + 2 * frame->y_stride;
2327 for (i = 1; i < frame->y_height - 1; i++) { 2487 for (i = 1; i < frame->y_height - 1; i++) {
2328 for (j = 1; j < frame->y_width - 1; j++) { 2488 for (j = 1; j < frame->y_width - 1; j++) {
2329 /* Sobel hor and ver gradients */ 2489 /* Sobel hor and ver gradients */
2330 int v = 2 * (curr[1] - curr[-1]) + (prev[1] - prev[-1]) + (next[1] - next[ -1]); 2490 int v = 2 * (curr[1] - curr[-1]) + (prev[1] - prev[-1]) +
2331 int h = 2 * (prev[0] - next[0]) + (prev[1] - next[1]) + (prev[-1] - next[- 1]); 2491 (next[1] - next[-1]);
2492 int h = 2 * (prev[0] - next[0]) + (prev[1] - next[1]) +
2493 (prev[-1] - next[-1]);
2332 h = (h < 0 ? -h : h); 2494 h = (h < 0 ? -h : h);
2333 v = (v < 0 ? -v : v); 2495 v = (v < 0 ? -v : v);
2334 if (h > EDGE_THRESH || v > EDGE_THRESH) 2496 if (h > EDGE_THRESH || v > EDGE_THRESH)
2335 num_edge_pels++; 2497 num_edge_pels++;
2336 curr++; 2498 curr++;
2337 prev++; 2499 prev++;
2338 next++; 2500 next++;
2339 } 2501 }
2340 curr += frame->y_stride - frame->y_width + 2; 2502 curr += frame->y_stride - frame->y_width + 2;
2341 prev += frame->y_stride - frame->y_width + 2; 2503 prev += frame->y_stride - frame->y_width + 2;
(...skipping 15 matching lines...) Expand all
2357 // and the frame is a key frame. golden frame or alt_ref_frame 2519 // and the frame is a key frame. golden frame or alt_ref_frame
2358 if ((cpi->sf.recode_loop == 1) || 2520 if ((cpi->sf.recode_loop == 1) ||
2359 ((cpi->sf.recode_loop == 2) && 2521 ((cpi->sf.recode_loop == 2) &&
2360 ((cm->frame_type == KEY_FRAME) || 2522 ((cm->frame_type == KEY_FRAME) ||
2361 cpi->refresh_golden_frame || 2523 cpi->refresh_golden_frame ||
2362 cpi->refresh_alt_ref_frame))) { 2524 cpi->refresh_alt_ref_frame))) {
2363 // General over and under shoot tests 2525 // General over and under shoot tests
2364 if (((cpi->projected_frame_size > high_limit) && (q < maxq)) || 2526 if (((cpi->projected_frame_size > high_limit) && (q < maxq)) ||
2365 ((cpi->projected_frame_size < low_limit) && (q > minq))) { 2527 ((cpi->projected_frame_size < low_limit) && (q > minq))) {
2366 force_recode = 1; 2528 force_recode = 1;
2367 } 2529 } else if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
2368 // Special Constrained quality tests 2530 // Deal with frame undershoot and whether or not we are
2369 else if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) { 2531 // below the automatically set cq level.
2370 // Undershoot and below auto cq level
2371 if (q > cpi->cq_target_quality && 2532 if (q > cpi->cq_target_quality &&
2372 cpi->projected_frame_size < ((cpi->this_frame_target * 7) >> 3)) { 2533 cpi->projected_frame_size < ((cpi->this_frame_target * 7) >> 3)) {
2373 force_recode = 1; 2534 force_recode = 1;
2374 } else if (q > cpi->oxcf.cq_level && 2535 } else if (q > cpi->oxcf.cq_level &&
2375 cpi->projected_frame_size < cpi->min_frame_bandwidth && 2536 cpi->projected_frame_size < cpi->min_frame_bandwidth &&
2376 cpi->active_best_quality > cpi->oxcf.cq_level) { 2537 cpi->active_best_quality > cpi->oxcf.cq_level) {
2377 // Severe undershoot and between auto and user cq level 2538 // Severe undershoot and between auto and user cq level
2378 force_recode = 1; 2539 force_recode = 1;
2379 cpi->active_best_quality = cpi->oxcf.cq_level; 2540 cpi->active_best_quality = cpi->oxcf.cq_level;
2380 } 2541 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 for (i = 0; i < BLOCK_TYPES; ++i) 2682 for (i = 0; i < BLOCK_TYPES; ++i)
2522 for (j = 0; j < REF_TYPES; ++j) 2683 for (j = 0; j < REF_TYPES; ++j)
2523 for (k = 0; k < COEF_BANDS; ++k) 2684 for (k = 0; k < COEF_BANDS; ++k)
2524 for (l = 0; l < PREV_COEF_CONTEXTS; ++l) { 2685 for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
2525 if (l >= 3 && k == 0) 2686 if (l >= 3 && k == 0)
2526 continue; 2687 continue;
2527 full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]); 2688 full_to_model_count(model_count[i][j][k][l], full_count[i][j][k][l]);
2528 } 2689 }
2529 } 2690 }
2530 2691
2692 #if 0 && CONFIG_INTERNAL_STATS
2693 static void output_frame_level_debug_stats(VP9_COMP *cpi) {
2694 VP9_COMMON *const cm = &cpi->common;
2695 FILE *const f = fopen("tmp.stt", cm->current_video_frame ? "a" : "w");
2696 int recon_err;
2531 2697
2532 static void encode_frame_to_data_rate(VP9_COMP *cpi, 2698 vp9_clear_system_state(); // __asm emms;
2533 unsigned long *size,
2534 unsigned char *dest,
2535 unsigned int *frame_flags) {
2536 VP9_COMMON *cm = &cpi->common;
2537 MACROBLOCKD *xd = &cpi->mb.e_mbd;
2538 TX_SIZE t;
2539 int q;
2540 int frame_over_shoot_limit;
2541 int frame_under_shoot_limit;
2542 2699
2543 int loop = 0; 2700 recon_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm));
2544 int loop_count;
2545 2701
2546 int q_low; 2702 if (cpi->twopass.total_left_stats.coded_error != 0.0)
2547 int q_high; 2703 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d"
2704 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
2705 "%6d %6d %5d %5d %5d %8.2f %10d %10.3f"
2706 "%10.3f %8d %10d %10d %10d\n",
2707 cpi->common.current_video_frame, cpi->this_frame_target,
2708 cpi->projected_frame_size, 0,
2709 (cpi->projected_frame_size - cpi->this_frame_target),
2710 (int)cpi->total_target_vs_actual,
2711 (int)(cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
2712 (int)cpi->total_actual_bits, cm->base_qindex,
2713 vp9_convert_qindex_to_q(cm->base_qindex),
2714 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
2715 vp9_convert_qindex_to_q(cpi->active_best_quality),
2716 vp9_convert_qindex_to_q(cpi->active_worst_quality), cpi->avg_q,
2717 vp9_convert_qindex_to_q(cpi->ni_av_qi),
2718 vp9_convert_qindex_to_q(cpi->cq_target_quality),
2719 cpi->refresh_last_frame, cpi->refresh_golden_frame,
2720 cpi->refresh_alt_ref_frame, cm->frame_type, cpi->gfu_boost,
2721 cpi->twopass.est_max_qcorrection_factor, (int)cpi->twopass.bits_left,
2722 cpi->twopass.total_left_stats.coded_error,
2723 (double)cpi->twopass.bits_left /
2724 (1 + cpi->twopass.total_left_stats.coded_error),
2725 cpi->tot_recode_hits, recon_err, cpi->kf_boost, cpi->kf_zeromotion_pct);
2548 2726
2549 int top_index; 2727 fclose(f);
2550 int bottom_index;
2551 int active_worst_qchanged = 0;
2552 2728
2553 int overshoot_seen = 0; 2729 if (0) {
2554 int undershoot_seen = 0; 2730 FILE *const fmodes = fopen("Modes.stt", "a");
2731 int i;
2555 2732
2556 SPEED_FEATURES *sf = &cpi->sf; 2733 fprintf(fmodes, "%6d:%1d:%1d:%1d ", cpi->common.current_video_frame,
2557 unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height); 2734 cm->frame_type, cpi->refresh_golden_frame,
2558 struct segmentation *seg = &cm->seg; 2735 cpi->refresh_alt_ref_frame);
2559 2736
2560 /* Scale the source buffer, if required */ 2737 for (i = 0; i < MAX_MODES; ++i)
2561 if (cm->mi_cols * 8 != cpi->un_scaled_source->y_width || 2738 fprintf(fmodes, "%5d ", cpi->mode_chosen_counts[i]);
2562 cm->mi_rows * 8 != cpi->un_scaled_source->y_height) { 2739 for (i = 0; i < MAX_REFS; ++i)
2563 scale_and_extend_frame(cpi->un_scaled_source, &cpi->scaled_source); 2740 fprintf(fmodes, "%5d ", cpi->sub8x8_mode_chosen_counts[i]);
2564 cpi->Source = &cpi->scaled_source; 2741
2565 } else { 2742 fprintf(fmodes, "\n");
2566 cpi->Source = cpi->un_scaled_source; 2743
2744 fclose(fmodes);
2567 } 2745 }
2746 }
2747 #endif
2568 2748
2569 scale_references(cpi); 2749 static int pick_q_and_adjust_q_bounds(VP9_COMP *cpi,
2750 int * bottom_index, int * top_index) {
2751 // Set an active best quality and if necessary active worst quality
2752 int q = cpi->active_worst_quality;
2753 VP9_COMMON *const cm = &cpi->common;
2570 2754
2571 // Clear down mmx registers to allow floating point in what follows 2755 if (frame_is_intra_only(cm)) {
2572 vp9_clear_system_state();
2573
2574
2575 // For an alt ref frame in 2 pass we skip the call to the second
2576 // pass function that sets the target bandwidth so must set it here
2577 if (cpi->refresh_alt_ref_frame) {
2578 // Per frame bit target for the alt ref frame
2579 cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
2580 // per second target bitrate
2581 cpi->target_bandwidth = (int)(cpi->twopass.gf_bits *
2582 cpi->output_framerate);
2583 }
2584
2585 // Clear zbin over-quant value and mode boost values.
2586 cpi->zbin_mode_boost = 0;
2587
2588 // Enable or disable mode based tweaking of the zbin
2589 // For 2 Pass Only used where GF/ARF prediction quality
2590 // is above a threshold
2591 cpi->zbin_mode_boost = 0;
2592
2593 // if (cpi->oxcf.lossless)
2594 cpi->zbin_mode_boost_enabled = 0;
2595 // else
2596 // cpi->zbin_mode_boost_enabled = 1;
2597
2598 // Current default encoder behaviour for the altref sign bias
2599 cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = cpi->source_alt_ref_active;
2600
2601 // Check to see if a key frame is signaled
2602 // For two pass with auto key frame enabled cm->frame_type may already be set, but not for one pass.
2603 if ((cm->current_video_frame == 0) ||
2604 (cm->frame_flags & FRAMEFLAGS_KEY) ||
2605 (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency = = 0))) {
2606 // Key frame from VFW/auto-keyframe/first frame
2607 cm->frame_type = KEY_FRAME;
2608 }
2609
2610 // Set default state for segment based loop filter update flags
2611 cm->lf.mode_ref_delta_update = 0;
2612
2613 // Initialize cpi->mv_step_param to default based on max resolution
2614 cpi->mv_step_param = vp9_init_search_range(cpi, max_mv_def);
2615 // Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate.
2616 if (sf->auto_mv_step_size) {
2617 if ((cpi->common.frame_type == KEY_FRAME) || cpi->common.intra_only) {
2618 // initialize max_mv_magnitude for use in the first INTER frame
2619 // after a key/intra-only frame
2620 cpi->max_mv_magnitude = max_mv_def;
2621 } else {
2622 if (cm->show_frame)
2623 // allow mv_steps to correspond to twice the max mv magnitude found
2624 // in the previous frame, capped by the default max_mv_magnitude based
2625 // on resolution
2626 cpi->mv_step_param = vp9_init_search_range(
2627 cpi, MIN(max_mv_def, 2 * cpi->max_mv_magnitude));
2628 cpi->max_mv_magnitude = 0;
2629 }
2630 }
2631
2632 // Set various flags etc to special state if it is a key frame
2633 if (cm->frame_type == KEY_FRAME) {
2634 // Reset the loop filter deltas and segmentation map
2635 setup_features(cm);
2636
2637 // If segmentation is enabled force a map update for key frames
2638 if (seg->enabled) {
2639 seg->update_map = 1;
2640 seg->update_data = 1;
2641 }
2642
2643 // The alternate reference frame cannot be active for a key frame
2644 cpi->source_alt_ref_active = 0;
2645
2646 cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0);
2647 cm->frame_parallel_decoding_mode =
2648 (cpi->oxcf.frame_parallel_decoding_mode != 0);
2649 if (cm->error_resilient_mode) {
2650 cm->frame_parallel_decoding_mode = 1;
2651 cm->reset_frame_context = 0;
2652 cm->refresh_frame_context = 0;
2653 }
2654 }
2655
2656 // Configure experimental use of segmentation for enhanced coding of
2657 // static regions if indicated.
2658 // Only allowed for now in second pass of two pass (as requires lagged coding)
2659 // and if the relevant speed feature flag is set.
2660 if ((cpi->pass == 2) && (cpi->sf.static_segmentation)) {
2661 configure_static_seg_features(cpi);
2662 }
2663
2664 // Decide how big to make the frame
2665 vp9_pick_frame_size(cpi);
2666
2667 vp9_clear_system_state();
2668
2669 // Set an active best quality and if necessary active worst quality
2670 q = cpi->active_worst_quality;
2671
2672 if (cm->frame_type == KEY_FRAME) {
2673 #if !CONFIG_MULTIPLE_ARF 2756 #if !CONFIG_MULTIPLE_ARF
2674 // Special case for key frames forced because we have reached 2757 // Handle the special case for key frames forced when we have75 reached
2675 // the maximum key frame interval. Here force the Q to a range 2758 // the maximum key frame interval. Here force the Q to a range
2676 // based on the ambient Q to reduce the risk of popping 2759 // based on the ambient Q to reduce the risk of popping.
2677 if (cpi->this_key_frame_forced) { 2760 if (cpi->this_key_frame_forced) {
2678 int delta_qindex; 2761 int delta_qindex;
2679 int qindex = cpi->last_boosted_qindex; 2762 int qindex = cpi->last_boosted_qindex;
2680 double last_boosted_q = vp9_convert_qindex_to_q(qindex); 2763 double last_boosted_q = vp9_convert_qindex_to_q(qindex);
2681 2764
2682 delta_qindex = compute_qdelta(cpi, last_boosted_q, 2765 delta_qindex = vp9_compute_qdelta(cpi, last_boosted_q,
2683 (last_boosted_q * 0.75)); 2766 (last_boosted_q * 0.75));
2684 2767
2685 cpi->active_best_quality = MAX(qindex + delta_qindex, 2768 cpi->active_best_quality = MAX(qindex + delta_qindex,
2686 cpi->best_quality); 2769 cpi->best_quality);
2687 } else { 2770 } else {
2688 int high = 5000; 2771 int high = 5000;
2689 int low = 400; 2772 int low = 400;
2690 double q_adj_factor = 1.0; 2773 double q_adj_factor = 1.0;
2691 double q_val; 2774 double q_val;
2692 2775
2693 // Baseline value derived from cpi->active_worst_quality and kf boost 2776 // Baseline value derived from cpi->active_worst_quality and kf boost
2694 if (cpi->kf_boost > high) { 2777 cpi->active_best_quality = get_active_quality(q, cpi->kf_boost,
2695 cpi->active_best_quality = kf_low_motion_minq[q]; 2778 low, high,
2696 } else if (cpi->kf_boost < low) { 2779 kf_low_motion_minq,
2697 cpi->active_best_quality = kf_high_motion_minq[q]; 2780 kf_high_motion_minq);
2698 } else {
2699 const int gap = high - low;
2700 const int offset = high - cpi->kf_boost;
2701 const int qdiff = kf_high_motion_minq[q] - kf_low_motion_minq[q];
2702 const int adjustment = ((offset * qdiff) + (gap >> 1)) / gap;
2703
2704 cpi->active_best_quality = kf_low_motion_minq[q] + adjustment;
2705 }
2706 2781
2707 // Allow somewhat lower kf minq with small image formats. 2782 // Allow somewhat lower kf minq with small image formats.
2708 if ((cm->width * cm->height) <= (352 * 288)) { 2783 if ((cm->width * cm->height) <= (352 * 288)) {
2709 q_adj_factor -= 0.25; 2784 q_adj_factor -= 0.25;
2710 } 2785 }
2711 2786
2712 // Make a further adjustment based on the kf zero motion measure. 2787 // Make a further adjustment based on the kf zero motion measure.
2713 q_adj_factor += 0.05 - (0.001 * (double)cpi->kf_zeromotion_pct); 2788 q_adj_factor += 0.05 - (0.001 * (double)cpi->kf_zeromotion_pct);
2714 2789
2715 // Convert the adjustment factor to a qindex delta 2790 // Convert the adjustment factor to a qindex delta
2716 // on active_best_quality. 2791 // on active_best_quality.
2717 q_val = vp9_convert_qindex_to_q(cpi->active_best_quality); 2792 q_val = vp9_convert_qindex_to_q(cpi->active_best_quality);
2718 cpi->active_best_quality += 2793 cpi->active_best_quality +=
2719 compute_qdelta(cpi, q_val, (q_val * q_adj_factor)); 2794 vp9_compute_qdelta(cpi, q_val, (q_val * q_adj_factor));
2720 } 2795 }
2721 #else 2796 #else
2722 double current_q; 2797 double current_q;
2723 // Force the KF quantizer to be 30% of the active_worst_quality. 2798 // Force the KF quantizer to be 30% of the active_worst_quality.
2724 current_q = vp9_convert_qindex_to_q(cpi->active_worst_quality); 2799 current_q = vp9_convert_qindex_to_q(cpi->active_worst_quality);
2725 cpi->active_best_quality = cpi->active_worst_quality 2800 cpi->active_best_quality = cpi->active_worst_quality
2726 + compute_qdelta(cpi, current_q, current_q * 0.3); 2801 + vp9_compute_qdelta(cpi, current_q, current_q * 0.3);
2727 #endif 2802 #endif
2728 } else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) { 2803 } else if (!cpi->is_src_frame_alt_ref &&
2804 (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
2729 int high = 2000; 2805 int high = 2000;
2730 int low = 400; 2806 int low = 400;
2731 2807
2732 // Use the lower of cpi->active_worst_quality and recent 2808 // Use the lower of cpi->active_worst_quality and recent
2733 // average Q as basis for GF/ARF Q limit unless last frame was 2809 // average Q as basis for GF/ARF best Q limit unless last frame was
2734 // a key frame. 2810 // a key frame.
2735 if (cpi->frames_since_key > 1 && 2811 if (cpi->frames_since_key > 1 &&
2736 cpi->avg_frame_qindex < cpi->active_worst_quality) { 2812 cpi->avg_frame_qindex < cpi->active_worst_quality) {
2737 q = cpi->avg_frame_qindex; 2813 q = cpi->avg_frame_qindex;
2738 } 2814 }
2739 // For constrained quality dont allow Q less than the cq level 2815 // For constrained quality dont allow Q less than the cq level
2740 if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY && 2816 if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
2741 q < cpi->cq_target_quality) { 2817 if (q < cpi->cq_target_quality)
2742 q = cpi->cq_target_quality; 2818 q = cpi->cq_target_quality;
2743 } 2819 if (cpi->frames_since_key > 1) {
2744 if (cpi->gfu_boost > high) { 2820 cpi->active_best_quality = get_active_quality(q, cpi->gfu_boost,
2745 cpi->active_best_quality = gf_low_motion_minq[q]; 2821 low, high,
2746 } else if (cpi->gfu_boost < low) { 2822 afq_low_motion_minq,
2747 cpi->active_best_quality = gf_high_motion_minq[q]; 2823 afq_high_motion_minq);
2748 } else { 2824 } else {
2749 const int gap = high - low; 2825 cpi->active_best_quality = get_active_quality(q, cpi->gfu_boost,
2750 const int offset = high - cpi->gfu_boost; 2826 low, high,
2751 const int qdiff = gf_high_motion_minq[q] - gf_low_motion_minq[q]; 2827 gf_low_motion_minq,
2752 const int adjustment = ((offset * qdiff) + (gap >> 1)) / gap; 2828 gf_high_motion_minq);
2753 2829 }
2754 cpi->active_best_quality = gf_low_motion_minq[q] + adjustment; 2830 // Constrained quality use slightly lower active best.
2755 }
2756
2757 // Constrained quality use slightly lower active best.
2758 if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY)
2759 cpi->active_best_quality = cpi->active_best_quality * 15 / 16; 2831 cpi->active_best_quality = cpi->active_best_quality * 15 / 16;
2760 2832
2761 // TODO(debargha): Refine the logic below 2833 } else if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
2762 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
2763 if (!cpi->refresh_alt_ref_frame) { 2834 if (!cpi->refresh_alt_ref_frame) {
2764 cpi->active_best_quality = cpi->cq_target_quality; 2835 cpi->active_best_quality = cpi->cq_target_quality;
2765 } else { 2836 } else {
2766 if (cpi->frames_since_key > 1) { 2837 if (cpi->frames_since_key > 1) {
2767 if (cpi->gfu_boost > high) { 2838 cpi->active_best_quality = get_active_quality(q, cpi->gfu_boost,
2768 cpi->active_best_quality = cpi->cq_target_quality * 6 / 16; 2839 low, high,
2769 } else if (cpi->gfu_boost < low) { 2840 afq_low_motion_minq,
2770 cpi->active_best_quality = cpi->cq_target_quality * 11 / 16; 2841 afq_high_motion_minq);
2771 } else { 2842 } else {
2772 const int gap = high - low; 2843 cpi->active_best_quality = get_active_quality(q, cpi->gfu_boost,
2773 const int offset = high - cpi->gfu_boost; 2844 low, high,
2774 const int qdiff = cpi->cq_target_quality * 5 / 16; 2845 gf_low_motion_minq,
2775 const int adjustment = ((offset * qdiff) + (gap >> 1)) / gap; 2846 gf_high_motion_minq);
2776 cpi->active_best_quality = cpi->cq_target_quality * 6 / 16
2777 + adjustment;
2778 }
2779 } 2847 }
2780 } 2848 }
2849 } else {
2850 cpi->active_best_quality = get_active_quality(q, cpi->gfu_boost,
2851 low, high,
2852 gf_low_motion_minq,
2853 gf_high_motion_minq);
2781 } 2854 }
2782 } else { 2855 } else {
2783 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { 2856 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
2784 cpi->active_best_quality = cpi->cq_target_quality; 2857 cpi->active_best_quality = cpi->cq_target_quality;
2785 } else { 2858 } else {
2786 #ifdef ONE_SHOT_Q_ESTIMATE 2859 #ifdef ONE_SHOT_Q_ESTIMATE
2787 #ifdef STRICT_ONE_SHOT_Q 2860 #ifdef STRICT_ONE_SHOT_Q
2788 cpi->active_best_quality = q; 2861 cpi->active_best_quality = q;
2789 #else 2862 #else
2790 cpi->active_best_quality = inter_minq[q]; 2863 cpi->active_best_quality = inter_minq[q];
2791 #endif 2864 #endif
2792 #else 2865 #else
2793 cpi->active_best_quality = inter_minq[q]; 2866 cpi->active_best_quality = inter_minq[q];
2867 // 1-pass: for now, use the average Q for the active_best, if its lower
2868 // than active_worst.
2869 if (cpi->pass == 0 && (cpi->avg_frame_qindex < q))
2870 cpi->active_best_quality = inter_minq[cpi->avg_frame_qindex];
2794 #endif 2871 #endif
2795 2872
2796 // For the constant/constrained quality mode we don't want 2873 // For the constrained quality mode we don't want
2797 // q to fall below the cq level. 2874 // q to fall below the cq level.
2798 if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) && 2875 if ((cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) &&
2799 (cpi->active_best_quality < cpi->cq_target_quality)) { 2876 (cpi->active_best_quality < cpi->cq_target_quality)) {
2800 // If we are strongly undershooting the target rate in the last 2877 // If we are strongly undershooting the target rate in the last
2801 // frames then use the user passed in cq value not the auto 2878 // frames then use the user passed in cq value not the auto
2802 // cq value. 2879 // cq value.
2803 if (cpi->rolling_actual_bits < cpi->min_frame_bandwidth) 2880 if (cpi->rolling_actual_bits < cpi->min_frame_bandwidth)
2804 cpi->active_best_quality = cpi->oxcf.cq_level; 2881 cpi->active_best_quality = cpi->oxcf.cq_level;
2805 else 2882 else
2806 cpi->active_best_quality = cpi->cq_target_quality; 2883 cpi->active_best_quality = cpi->cq_target_quality;
2807 } 2884 }
2808 } 2885 }
2809 } 2886 }
2810 2887
2811 // Clip the active best and worst quality values to limits 2888 // Clip the active best and worst quality values to limits
2812 if (cpi->active_worst_quality > cpi->worst_quality) 2889 if (cpi->active_worst_quality > cpi->worst_quality)
2813 cpi->active_worst_quality = cpi->worst_quality; 2890 cpi->active_worst_quality = cpi->worst_quality;
2814 2891
2815 if (cpi->active_best_quality < cpi->best_quality) 2892 if (cpi->active_best_quality < cpi->best_quality)
2816 cpi->active_best_quality = cpi->best_quality; 2893 cpi->active_best_quality = cpi->best_quality;
2817 2894
2818 if (cpi->active_best_quality > cpi->worst_quality) 2895 if (cpi->active_best_quality > cpi->worst_quality)
2819 cpi->active_best_quality = cpi->worst_quality; 2896 cpi->active_best_quality = cpi->worst_quality;
2820 2897
2821 if (cpi->active_worst_quality < cpi->active_best_quality) 2898 if (cpi->active_worst_quality < cpi->active_best_quality)
2822 cpi->active_worst_quality = cpi->active_best_quality; 2899 cpi->active_worst_quality = cpi->active_best_quality;
2823 2900
2824 // Special case code to try and match quality with forced key frames 2901 // Limit Q range for the adaptive loop.
2902 if (cm->frame_type == KEY_FRAME && !cpi->this_key_frame_forced) {
2903 *top_index =
2904 (cpi->active_worst_quality + cpi->active_best_quality * 3) / 4;
2905 // If this is the first (key) frame in 1-pass, active best is the user
2906 // best-allowed, and leave the top_index to active_worst.
2907 if (cpi->pass == 0 && cpi->common.current_video_frame == 0) {
2908 cpi->active_best_quality = cpi->oxcf.best_allowed_q;
2909 *top_index = cpi->oxcf.worst_allowed_q;
2910 }
2911 } else if (!cpi->is_src_frame_alt_ref &&
2912 (cpi->oxcf.end_usage != USAGE_STREAM_FROM_SERVER) &&
2913 (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)) {
2914 *top_index =
2915 (cpi->active_worst_quality + cpi->active_best_quality) / 2;
2916 } else {
2917 *top_index = cpi->active_worst_quality;
2918 }
2919 *bottom_index = cpi->active_best_quality;
2920
2825 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { 2921 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
2826 q = cpi->active_best_quality; 2922 q = cpi->active_best_quality;
2923 // Special case code to try and match quality with forced key frames
2827 } else if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) { 2924 } else if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
2828 q = cpi->last_boosted_qindex; 2925 q = cpi->last_boosted_qindex;
2829 } else { 2926 } else {
2830 // Determine initial Q to try 2927 // Determine initial Q to try.
2831 q = vp9_regulate_q(cpi, cpi->this_frame_target); 2928 if (cpi->pass == 0) {
2929 // 1-pass: for now, use per-frame-bw for target size of frame, scaled
2930 // by |x| for key frame.
2931 int scale = (cm->frame_type == KEY_FRAME) ? 5 : 1;
2932 q = vp9_regulate_q(cpi, scale * cpi->av_per_frame_bandwidth);
2933 } else {
2934 q = vp9_regulate_q(cpi, cpi->this_frame_target);
2935 }
2936 if (q > *top_index)
2937 q = *top_index;
2832 } 2938 }
2833 2939
2940 return q;
2941 }
2942 static void encode_frame_to_data_rate(VP9_COMP *cpi,
2943 unsigned long *size,
2944 unsigned char *dest,
2945 unsigned int *frame_flags) {
2946 VP9_COMMON *const cm = &cpi->common;
2947 TX_SIZE t;
2948 int q;
2949 int frame_over_shoot_limit;
2950 int frame_under_shoot_limit;
2951
2952 int loop = 0;
2953 int loop_count;
2954
2955 int q_low;
2956 int q_high;
2957
2958 int top_index;
2959 int bottom_index;
2960 int active_worst_qchanged = 0;
2961
2962 int overshoot_seen = 0;
2963 int undershoot_seen = 0;
2964
2965 SPEED_FEATURES *const sf = &cpi->sf;
2966 unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height);
2967 struct segmentation *const seg = &cm->seg;
2968
2969 /* Scale the source buffer, if required. */
2970 if (cm->mi_cols * 8 != cpi->un_scaled_source->y_width ||
2971 cm->mi_rows * 8 != cpi->un_scaled_source->y_height) {
2972 scale_and_extend_frame(cpi->un_scaled_source, &cpi->scaled_source);
2973 cpi->Source = &cpi->scaled_source;
2974 } else {
2975 cpi->Source = cpi->un_scaled_source;
2976 }
2977 scale_references(cpi);
2978
2979 // Clear down mmx registers to allow floating point in what follows.
2980 vp9_clear_system_state();
2981
2982 // For an alt ref frame in 2 pass we skip the call to the second
2983 // pass function that sets the target bandwidth so we must set it here.
2984 if (cpi->refresh_alt_ref_frame) {
2985 // Set a per frame bit target for the alt ref frame.
2986 cpi->per_frame_bandwidth = cpi->twopass.gf_bits;
2987 // Set a per second target bitrate.
2988 cpi->target_bandwidth = (int)(cpi->twopass.gf_bits * cpi->output_framerate);
2989 }
2990
2991 // Clear zbin over-quant value and mode boost values.
2992 cpi->zbin_mode_boost = 0;
2993
2994 // Enable or disable mode based tweaking of the zbin.
2995 // For 2 pass only used where GF/ARF prediction quality
2996 // is above a threshold.
2997 cpi->zbin_mode_boost = 0;
2998 cpi->zbin_mode_boost_enabled = 0;
2999
3000 // Current default encoder behavior for the altref sign bias.
3001 cpi->common.ref_frame_sign_bias[ALTREF_FRAME] = cpi->source_alt_ref_active;
3002
3003 // Check to see if a key frame is signaled.
3004 // For two pass with auto key frame enabled cm->frame_type may already be
3005 // set, but not for one pass.
3006 if ((cm->current_video_frame == 0) ||
3007 (cm->frame_flags & FRAMEFLAGS_KEY) ||
3008 (cpi->oxcf.auto_key && (cpi->frames_since_key %
3009 cpi->key_frame_frequency == 0))) {
3010 // Set frame type to key frame for the force key frame, if we exceed the
3011 // maximum distance in an automatic keyframe selection or for the first
3012 // frame.
3013 cm->frame_type = KEY_FRAME;
3014 }
3015
3016 // Set default state for segment based loop filter update flags.
3017 cm->lf.mode_ref_delta_update = 0;
3018
3019 // Initialize cpi->mv_step_param to default based on max resolution.
3020 cpi->mv_step_param = vp9_init_search_range(cpi, max_mv_def);
3021 // Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate.
3022 if (sf->auto_mv_step_size) {
3023 if (frame_is_intra_only(&cpi->common)) {
3024 // Initialize max_mv_magnitude for use in the first INTER frame
3025 // after a key/intra-only frame.
3026 cpi->max_mv_magnitude = max_mv_def;
3027 } else {
3028 if (cm->show_frame)
3029 // Allow mv_steps to correspond to twice the max mv magnitude found
3030 // in the previous frame, capped by the default max_mv_magnitude based
3031 // on resolution.
3032 cpi->mv_step_param = vp9_init_search_range(
3033 cpi, MIN(max_mv_def, 2 * cpi->max_mv_magnitude));
3034 cpi->max_mv_magnitude = 0;
3035 }
3036 }
3037
3038 // Set various flags etc to special state if it is a key frame.
3039 if (frame_is_intra_only(cm)) {
3040 vp9_setup_key_frame(cpi);
3041 // Reset the loop filter deltas and segmentation map.
3042 setup_features(cm);
3043
3044 // If segmentation is enabled force a map update for key frames.
3045 if (seg->enabled) {
3046 seg->update_map = 1;
3047 seg->update_data = 1;
3048 }
3049
3050 // The alternate reference frame cannot be active for a key frame.
3051 cpi->source_alt_ref_active = 0;
3052
3053 cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0);
3054 cm->frame_parallel_decoding_mode =
3055 (cpi->oxcf.frame_parallel_decoding_mode != 0);
3056 if (cm->error_resilient_mode) {
3057 cm->frame_parallel_decoding_mode = 1;
3058 cm->reset_frame_context = 0;
3059 cm->refresh_frame_context = 0;
3060 } else if (cm->intra_only) {
3061 // Only reset the current context.
3062 cm->reset_frame_context = 2;
3063 }
3064 }
3065
3066 // Configure experimental use of segmentation for enhanced coding of
3067 // static regions if indicated.
3068 // Only allowed in second pass of two pass (as requires lagged coding)
3069 // and if the relevant speed feature flag is set.
3070 if ((cpi->pass == 2) && (cpi->sf.static_segmentation)) {
3071 configure_static_seg_features(cpi);
3072 }
3073
3074 // Decide how big to make the frame.
3075 vp9_pick_frame_size(cpi);
3076
3077 vp9_clear_system_state();
3078
3079 q = pick_q_and_adjust_q_bounds(cpi, &bottom_index, &top_index);
3080
3081 q_high = top_index;
3082 q_low = bottom_index;
3083
2834 vp9_compute_frame_size_bounds(cpi, &frame_under_shoot_limit, 3084 vp9_compute_frame_size_bounds(cpi, &frame_under_shoot_limit,
2835 &frame_over_shoot_limit); 3085 &frame_over_shoot_limit);
2836 3086
2837 #if CONFIG_MULTIPLE_ARF 3087 #if CONFIG_MULTIPLE_ARF
2838 // Force the quantizer determined by the coding order pattern. 3088 // Force the quantizer determined by the coding order pattern.
2839 if (cpi->multi_arf_enabled && (cm->frame_type != KEY_FRAME) && 3089 if (cpi->multi_arf_enabled && (cm->frame_type != KEY_FRAME) &&
2840 cpi->oxcf.end_usage != USAGE_CONSTANT_QUALITY) { 3090 cpi->oxcf.end_usage != USAGE_CONSTANT_QUALITY) {
2841 double new_q; 3091 double new_q;
2842 double current_q = vp9_convert_qindex_to_q(cpi->active_worst_quality); 3092 double current_q = vp9_convert_qindex_to_q(cpi->active_worst_quality);
2843 int level = cpi->this_frame_weight; 3093 int level = cpi->this_frame_weight;
2844 assert(level >= 0); 3094 assert(level >= 0);
2845 3095
2846 // Set quantizer steps at 10% increments. 3096 // Set quantizer steps at 10% increments.
2847 new_q = current_q * (1.0 - (0.2 * (cpi->max_arf_level - level))); 3097 new_q = current_q * (1.0 - (0.2 * (cpi->max_arf_level - level)));
2848 q = cpi->active_worst_quality + compute_qdelta(cpi, current_q, new_q); 3098 q = cpi->active_worst_quality + vp9_compute_qdelta(cpi, current_q, new_q);
2849 3099
2850 bottom_index = q; 3100 bottom_index = q;
2851 top_index = q; 3101 top_index = q;
2852 q_low = q; 3102 q_low = q;
2853 q_high = q; 3103 q_high = q;
2854 3104
2855 printf("frame:%d q:%d\n", cm->current_video_frame, q); 3105 printf("frame:%d q:%d\n", cm->current_video_frame, q);
2856 } else {
2857 #endif
2858 // Limit Q range for the adaptive loop.
2859 bottom_index = cpi->active_best_quality;
2860 top_index = cpi->active_worst_quality;
2861 q_low = cpi->active_best_quality;
2862 q_high = cpi->active_worst_quality;
2863 #if CONFIG_MULTIPLE_ARF
2864 } 3106 }
2865 #endif 3107 #endif
3108
2866 loop_count = 0; 3109 loop_count = 0;
2867 vp9_zero(cpi->rd_tx_select_threshes); 3110 vp9_zero(cpi->rd_tx_select_threshes);
2868 3111
2869 if (cm->frame_type != KEY_FRAME) { 3112 if (!frame_is_intra_only(cm)) {
2870 cm->mcomp_filter_type = DEFAULT_INTERP_FILTER; 3113 cm->mcomp_filter_type = DEFAULT_INTERP_FILTER;
2871 /* TODO: Decide this more intelligently */ 3114 /* TODO: Decide this more intelligently */
2872 xd->allow_high_precision_mv = q < HIGH_PRECISION_MV_QTHRESH; 3115 cm->allow_high_precision_mv = q < HIGH_PRECISION_MV_QTHRESH;
2873 set_mvcost(&cpi->mb); 3116 set_mvcost(cpi);
2874 } 3117 }
2875 3118
2876 #if CONFIG_VP9_POSTPROC 3119 #if CONFIG_VP9_POSTPROC
2877 3120
2878 if (cpi->oxcf.noise_sensitivity > 0) { 3121 if (cpi->oxcf.noise_sensitivity > 0) {
2879 int l = 0; 3122 int l = 0;
2880 3123
2881 switch (cpi->oxcf.noise_sensitivity) { 3124 switch (cpi->oxcf.noise_sensitivity) {
2882 case 1: 3125 case 1:
2883 l = 20; 3126 l = 20;
(...skipping 21 matching lines...) Expand all
2905 #ifdef OUTPUT_YUV_SRC 3148 #ifdef OUTPUT_YUV_SRC
2906 vp9_write_yuv_frame(cpi->Source); 3149 vp9_write_yuv_frame(cpi->Source);
2907 #endif 3150 #endif
2908 3151
2909 do { 3152 do {
2910 vp9_clear_system_state(); // __asm emms; 3153 vp9_clear_system_state(); // __asm emms;
2911 3154
2912 vp9_set_quantizer(cpi, q); 3155 vp9_set_quantizer(cpi, q);
2913 3156
2914 if (loop_count == 0) { 3157 if (loop_count == 0) {
2915 3158 // Set up entropy context depending on frame type. The decoder mandates
2916 // Set up entropy depending on frame type. 3159 // the use of the default context, index 0, for keyframes and inter
3160 // frames where the error_resilient_mode or intra_only flag is set. For
3161 // other inter-frames the encoder currently uses only two contexts;
3162 // context 1 for ALTREF frames and context 0 for the others.
2917 if (cm->frame_type == KEY_FRAME) { 3163 if (cm->frame_type == KEY_FRAME) {
2918 /* Choose which entropy context to use. When using a forward reference
2919 * frame, it immediately follows the keyframe, and thus benefits from
2920 * using the same entropy context established by the keyframe.
2921 * Otherwise, use the default context 0.
2922 */
2923 cm->frame_context_idx = cpi->oxcf.play_alternate;
2924 vp9_setup_key_frame(cpi); 3164 vp9_setup_key_frame(cpi);
2925 } else { 3165 } else {
2926 /* Choose which entropy context to use. Currently there are only two 3166 if (!cm->intra_only && !cm->error_resilient_mode) {
2927 * contexts used, one for normal frames and one for alt ref frames. 3167 cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame;
2928 */ 3168 }
2929 cpi->common.frame_context_idx = cpi->refresh_alt_ref_frame;
2930 vp9_setup_inter_frame(cpi); 3169 vp9_setup_inter_frame(cpi);
2931 } 3170 }
2932 } 3171 }
2933 3172
3173 if (cpi->sf.variance_adaptive_quantization) {
3174 vp9_vaq_frame_setup(cpi);
3175 }
3176
2934 // transform / motion compensation build reconstruction frame 3177 // transform / motion compensation build reconstruction frame
2935 3178
2936 vp9_encode_frame(cpi); 3179 vp9_encode_frame(cpi);
2937 3180
2938 // Update the skip mb flag probabilities based on the distribution 3181 // Update the skip mb flag probabilities based on the distribution
2939 // seen in the last encoder iteration. 3182 // seen in the last encoder iteration.
2940 // update_base_skip_probs(cpi); 3183 // update_base_skip_probs(cpi);
2941 3184
2942 vp9_clear_system_state(); // __asm emms; 3185 vp9_clear_system_state(); // __asm emms;
2943 3186
2944 // Dummy pack of the bitstream using up to date stats to get an 3187 // Dummy pack of the bitstream using up to date stats to get an
2945 // accurate estimate of output frame size to determine if we need 3188 // accurate estimate of output frame size to determine if we need
2946 // to recode. 3189 // to recode.
2947 vp9_save_coding_context(cpi); 3190 vp9_save_coding_context(cpi);
2948 cpi->dummy_packing = 1; 3191 cpi->dummy_packing = 1;
2949 vp9_pack_bitstream(cpi, dest, size); 3192 vp9_pack_bitstream(cpi, dest, size);
2950 cpi->projected_frame_size = (*size) << 3; 3193 cpi->projected_frame_size = (*size) << 3;
2951 vp9_restore_coding_context(cpi); 3194 vp9_restore_coding_context(cpi);
2952 3195
2953 if (frame_over_shoot_limit == 0) 3196 if (frame_over_shoot_limit == 0)
2954 frame_over_shoot_limit = 1; 3197 frame_over_shoot_limit = 1;
2955 active_worst_qchanged = 0; 3198 active_worst_qchanged = 0;
2956 3199
2957 // Special case handling for forced key frames
2958 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) { 3200 if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
2959 loop = 0; 3201 loop = 0;
2960 } else { 3202 } else {
3203 // Special case handling for forced key frames
2961 if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) { 3204 if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
2962 int last_q = q; 3205 int last_q = q;
2963 int kf_err = vp9_calc_ss_err(cpi->Source, 3206 int kf_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm));
2964 &cm->yv12_fb[cm->new_fb_idx]);
2965 3207
2966 int high_err_target = cpi->ambient_err; 3208 int high_err_target = cpi->ambient_err;
2967 int low_err_target = cpi->ambient_err >> 1; 3209 int low_err_target = cpi->ambient_err >> 1;
2968 3210
2969 // Prevent possible divide by zero error below for perfect KF 3211 // Prevent possible divide by zero error below for perfect KF
2970 kf_err += !kf_err; 3212 kf_err += !kf_err;
2971 3213
2972 // The key frame is not good enough or we can afford 3214 // The key frame is not good enough or we can afford
2973 // to make it better without undue risk of popping. 3215 // to make it better without undue risk of popping.
2974 if ((kf_err > high_err_target && 3216 if ((kf_err > high_err_target &&
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 #if CONFIG_INTERNAL_STATS 3332 #if CONFIG_INTERNAL_STATS
3091 cpi->tot_recode_hits++; 3333 cpi->tot_recode_hits++;
3092 #endif 3334 #endif
3093 } 3335 }
3094 } while (loop); 3336 } while (loop);
3095 3337
3096 // Special case code to reduce pulsing when key frames are forced at a 3338 // Special case code to reduce pulsing when key frames are forced at a
3097 // fixed interval. Note the reconstruction error if it is the frame before 3339 // fixed interval. Note the reconstruction error if it is the frame before
3098 // the force key frame 3340 // the force key frame
3099 if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) { 3341 if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) {
3100 cpi->ambient_err = vp9_calc_ss_err(cpi->Source, 3342 cpi->ambient_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm));
3101 &cm->yv12_fb[cm->new_fb_idx]);
3102 } 3343 }
3103 3344
3104 if (cm->frame_type == KEY_FRAME) 3345 if (cm->frame_type == KEY_FRAME)
3105 cpi->refresh_last_frame = 1; 3346 cpi->refresh_last_frame = 1;
3106 3347
3107 cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; 3348 cm->frame_to_show = get_frame_new_buffer(cm);
3108 3349
3109 #if WRITE_RECON_BUFFER 3350 #if WRITE_RECON_BUFFER
3110 if (cm->show_frame) 3351 if (cm->show_frame)
3111 write_cx_frame_to_file(cm->frame_to_show, 3352 write_cx_frame_to_file(cm->frame_to_show,
3112 cm->current_video_frame); 3353 cm->current_video_frame);
3113 else 3354 else
3114 write_cx_frame_to_file(cm->frame_to_show, 3355 write_cx_frame_to_file(cm->frame_to_show,
3115 cm->current_video_frame + 1000); 3356 cm->current_video_frame + 1000);
3116 #endif 3357 #endif
3117 3358
(...skipping 20 matching lines...) Expand all
3138 update_reference_frames(cpi); 3379 update_reference_frames(cpi);
3139 3380
3140 for (t = TX_4X4; t <= TX_32X32; t++) 3381 for (t = TX_4X4; t <= TX_32X32; t++)
3141 full_to_model_counts(cpi->common.counts.coef[t], 3382 full_to_model_counts(cpi->common.counts.coef[t],
3142 cpi->coef_counts[t]); 3383 cpi->coef_counts[t]);
3143 if (!cpi->common.error_resilient_mode && 3384 if (!cpi->common.error_resilient_mode &&
3144 !cpi->common.frame_parallel_decoding_mode) { 3385 !cpi->common.frame_parallel_decoding_mode) {
3145 vp9_adapt_coef_probs(&cpi->common); 3386 vp9_adapt_coef_probs(&cpi->common);
3146 } 3387 }
3147 3388
3148 if (cpi->common.frame_type != KEY_FRAME) { 3389 if (!frame_is_intra_only(&cpi->common)) {
3149 FRAME_COUNTS *counts = &cpi->common.counts; 3390 FRAME_COUNTS *counts = &cpi->common.counts;
3150 3391
3151 vp9_copy(counts->y_mode, cpi->y_mode_count); 3392 vp9_copy(counts->y_mode, cpi->y_mode_count);
3152 vp9_copy(counts->uv_mode, cpi->y_uv_mode_count); 3393 vp9_copy(counts->uv_mode, cpi->y_uv_mode_count);
3153 vp9_copy(counts->partition, cpi->partition_count); 3394 vp9_copy(counts->partition, cpi->partition_count);
3154 vp9_copy(counts->intra_inter, cpi->intra_inter_count); 3395 vp9_copy(counts->intra_inter, cpi->intra_inter_count);
3155 vp9_copy(counts->comp_inter, cpi->comp_inter_count); 3396 vp9_copy(counts->comp_inter, cpi->comp_inter_count);
3156 vp9_copy(counts->single_ref, cpi->single_ref_count); 3397 vp9_copy(counts->single_ref, cpi->single_ref_count);
3157 vp9_copy(counts->comp_ref, cpi->comp_ref_count); 3398 vp9_copy(counts->comp_ref, cpi->comp_ref_count);
3158 counts->mv = cpi->NMVcount; 3399 counts->mv = cpi->NMVcount;
3159 if (!cpi->common.error_resilient_mode && 3400 if (!cpi->common.error_resilient_mode &&
3160 !cpi->common.frame_parallel_decoding_mode) { 3401 !cpi->common.frame_parallel_decoding_mode) {
3161 vp9_adapt_mode_probs(&cpi->common); 3402 vp9_adapt_mode_probs(&cpi->common);
3162 vp9_adapt_mv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv); 3403 vp9_adapt_mv_probs(&cpi->common, cpi->common.allow_high_precision_mv);
3163 } 3404 }
3164 } 3405 }
3165 3406
3166 #ifdef ENTROPY_STATS 3407 #ifdef ENTROPY_STATS
3167 vp9_update_mode_context_stats(cpi); 3408 vp9_update_mode_context_stats(cpi);
3168 #endif 3409 #endif
3169 3410
3170 /* Move storing frame_type out of the above loop since it is also 3411 /* Move storing frame_type out of the above loop since it is also
3171 * needed in motion search besides loopfilter */ 3412 * needed in motion search besides loopfilter */
3172 cm->last_frame_type = cm->frame_type; 3413 cm->last_frame_type = cm->frame_type;
3173 3414
3174 // Update rate control heuristics 3415 // Update rate control heuristics
3175 cpi->total_byte_count += (*size); 3416 cpi->total_byte_count += (*size);
3176 cpi->projected_frame_size = (*size) << 3; 3417 cpi->projected_frame_size = (*size) << 3;
3177 3418
3419 // Post encode loop adjustment of Q prediction.
3178 if (!active_worst_qchanged) 3420 if (!active_worst_qchanged)
3179 vp9_update_rate_correction_factors(cpi, 2); 3421 vp9_update_rate_correction_factors(cpi, (cpi->sf.recode_loop) ? 2 : 0);
3180 3422
3181 cpi->last_q[cm->frame_type] = cm->base_qindex; 3423 cpi->last_q[cm->frame_type] = cm->base_qindex;
3182 3424
3183 // Keep record of last boosted (KF/KF/ARF) Q value. 3425 // Keep record of last boosted (KF/KF/ARF) Q value.
3184 // If the current frame is coded at a lower Q then we also update it. 3426 // If the current frame is coded at a lower Q then we also update it.
3185 // If all mbs in this group are skipped only update if the Q value is 3427 // If all mbs in this group are skipped only update if the Q value is
3186 // better than that already stored. 3428 // better than that already stored.
3187 // This is used to help set quality in forced key frames to reduce popping 3429 // This is used to help set quality in forced key frames to reduce popping
3188 if ((cm->base_qindex < cpi->last_boosted_qindex) || 3430 if ((cm->base_qindex < cpi->last_boosted_qindex) ||
3189 ((cpi->static_mb_pct < 100) && 3431 ((cpi->static_mb_pct < 100) &&
3190 ((cm->frame_type == KEY_FRAME) || 3432 ((cm->frame_type == KEY_FRAME) ||
3191 cpi->refresh_alt_ref_frame || 3433 cpi->refresh_alt_ref_frame ||
3192 (cpi->refresh_golden_frame && !cpi->is_src_frame_alt_ref)))) { 3434 (cpi->refresh_golden_frame && !cpi->is_src_frame_alt_ref)))) {
3193 cpi->last_boosted_qindex = cm->base_qindex; 3435 cpi->last_boosted_qindex = cm->base_qindex;
3194 } 3436 }
3195 3437
3196 if (cm->frame_type == KEY_FRAME) { 3438 if (cm->frame_type == KEY_FRAME) {
3197 vp9_adjust_key_frame_context(cpi); 3439 vp9_adjust_key_frame_context(cpi);
3198 } 3440 }
3199 3441
3200 // Keep a record of ambient average Q. 3442 // Keep a record of ambient average Q.
3201 if (cm->frame_type != KEY_FRAME) 3443 if (cm->frame_type != KEY_FRAME)
3202 cpi->avg_frame_qindex = (2 + 3 * cpi->avg_frame_qindex + cm->base_qindex) >> 2; 3444 cpi->avg_frame_qindex = (2 + 3 * cpi->avg_frame_qindex +
3445 cm->base_qindex) >> 2;
3203 3446
3204 // Keep a record from which we can calculate the average Q excluding GF update s and key frames 3447 // Keep a record from which we can calculate the average Q excluding GF
3448 // updates and key frames.
3205 if (cm->frame_type != KEY_FRAME && 3449 if (cm->frame_type != KEY_FRAME &&
3206 !cpi->refresh_golden_frame && 3450 !cpi->refresh_golden_frame &&
3207 !cpi->refresh_alt_ref_frame) { 3451 !cpi->refresh_alt_ref_frame) {
3208 cpi->ni_frames++; 3452 cpi->ni_frames++;
3209 cpi->tot_q += vp9_convert_qindex_to_q(q); 3453 cpi->tot_q += vp9_convert_qindex_to_q(q);
3210 cpi->avg_q = cpi->tot_q / (double)cpi->ni_frames; 3454 cpi->avg_q = cpi->tot_q / (double)cpi->ni_frames;
3211 3455
3212 // Calculate the average Q for normal inter frames (not key or GFU frames). 3456 // Calculate the average Q for normal inter frames (not key or GFU frames).
3213 cpi->ni_tot_qi += q; 3457 cpi->ni_tot_qi += q;
3214 cpi->ni_av_qi = cpi->ni_tot_qi / cpi->ni_frames; 3458 cpi->ni_av_qi = cpi->ni_tot_qi / cpi->ni_frames;
3215 } 3459 }
3216 3460
3217 // Update the buffer level variable. 3461 // Update the buffer level variable.
3218 // Non-viewable frames are a special case and are treated as pure overhead. 3462 // Non-viewable frames are a special case and are treated as pure overhead.
3219 if (!cm->show_frame) 3463 if (!cm->show_frame)
3220 cpi->bits_off_target -= cpi->projected_frame_size; 3464 cpi->bits_off_target -= cpi->projected_frame_size;
3221 else 3465 else
3222 cpi->bits_off_target += cpi->av_per_frame_bandwidth - cpi->projected_frame_s ize; 3466 cpi->bits_off_target += cpi->av_per_frame_bandwidth -
3467 cpi->projected_frame_size;
3223 3468
3224 // Clip the buffer level at the maximum buffer size 3469 // Clip the buffer level at the maximum buffer size
3225 if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size) 3470 if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
3226 cpi->bits_off_target = cpi->oxcf.maximum_buffer_size; 3471 cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
3227 3472
3228 // Rolling monitors of whether we are over or underspending used to help 3473 // Rolling monitors of whether we are over or underspending used to help
3229 // regulate min and Max Q in two pass. 3474 // regulate min and Max Q in two pass.
3230 if (cm->frame_type != KEY_FRAME) { 3475 if (cm->frame_type != KEY_FRAME) {
3231 cpi->rolling_target_bits = 3476 cpi->rolling_target_bits =
3232 ((cpi->rolling_target_bits * 3) + cpi->this_frame_target + 2) / 4; 3477 ((cpi->rolling_target_bits * 3) + cpi->this_frame_target + 2) / 4;
3233 cpi->rolling_actual_bits = 3478 cpi->rolling_actual_bits =
3234 ((cpi->rolling_actual_bits * 3) + cpi->projected_frame_size + 2) / 4; 3479 ((cpi->rolling_actual_bits * 3) + cpi->projected_frame_size + 2) / 4;
3235 cpi->long_rolling_target_bits = 3480 cpi->long_rolling_target_bits =
3236 ((cpi->long_rolling_target_bits * 31) + cpi->this_frame_target + 16) / 32; 3481 ((cpi->long_rolling_target_bits * 31) + cpi->this_frame_target + 16) / 32;
3237 cpi->long_rolling_actual_bits = 3482 cpi->long_rolling_actual_bits =
3238 ((cpi->long_rolling_actual_bits * 31) + 3483 ((cpi->long_rolling_actual_bits * 31) +
3239 cpi->projected_frame_size + 16) / 32; 3484 cpi->projected_frame_size + 16) / 32;
3240 } 3485 }
3241 3486
3242 // Actual bits spent 3487 // Actual bits spent
3243 cpi->total_actual_bits += cpi->projected_frame_size; 3488 cpi->total_actual_bits += cpi->projected_frame_size;
3244 3489
3245 // Debug stats 3490 // Debug stats
3246 cpi->total_target_vs_actual += (cpi->this_frame_target - cpi->projected_frame_ size); 3491 cpi->total_target_vs_actual += (cpi->this_frame_target -
3492 cpi->projected_frame_size);
3247 3493
3248 cpi->buffer_level = cpi->bits_off_target; 3494 cpi->buffer_level = cpi->bits_off_target;
3249 3495
3250 // Update bits left to the kf and gf groups to account for overshoot or unders hoot on these frames 3496 #ifndef DISABLE_RC_LONG_TERM_MEM
3497 // Update bits left to the kf and gf groups to account for overshoot or
3498 // undershoot on these frames
3251 if (cm->frame_type == KEY_FRAME) { 3499 if (cm->frame_type == KEY_FRAME) {
3252 cpi->twopass.kf_group_bits += cpi->this_frame_target - cpi->projected_frame_ size; 3500 cpi->twopass.kf_group_bits += cpi->this_frame_target -
3501 cpi->projected_frame_size;
3253 3502
3254 cpi->twopass.kf_group_bits = MAX(cpi->twopass.kf_group_bits, 0); 3503 cpi->twopass.kf_group_bits = MAX(cpi->twopass.kf_group_bits, 0);
3255 } else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) { 3504 } else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) {
3256 cpi->twopass.gf_group_bits += cpi->this_frame_target - cpi->projected_frame_ size; 3505 cpi->twopass.gf_group_bits += cpi->this_frame_target -
3506 cpi->projected_frame_size;
3257 3507
3258 cpi->twopass.gf_group_bits = MAX(cpi->twopass.gf_group_bits, 0); 3508 cpi->twopass.gf_group_bits = MAX(cpi->twopass.gf_group_bits, 0);
3259 } 3509 }
3260
3261 // Update the skip mb flag probabilities based on the distribution seen
3262 // in this frame.
3263 // update_base_skip_probs(cpi);
3264
3265 #if CONFIG_INTERNAL_STATS
3266 {
3267 FILE *f = fopen("tmp.stt", cm->current_video_frame ? "a" : "w");
3268 int recon_err;
3269
3270 vp9_clear_system_state(); // __asm emms;
3271
3272 recon_err = vp9_calc_ss_err(cpi->Source,
3273 &cm->yv12_fb[cm->new_fb_idx]);
3274
3275 if (cpi->twopass.total_left_stats.coded_error != 0.0)
3276 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d"
3277 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
3278 "%6d %6d %5d %5d %5d %8.2f %10d %10.3f"
3279 "%10.3f %8d %10d %10d %10d\n",
3280 cpi->common.current_video_frame, cpi->this_frame_target,
3281 cpi->projected_frame_size, 0, //loop_size_estimate,
3282 (cpi->projected_frame_size - cpi->this_frame_target),
3283 (int)cpi->total_target_vs_actual,
3284 (int)(cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
3285 (int)cpi->total_actual_bits,
3286 cm->base_qindex,
3287 vp9_convert_qindex_to_q(cm->base_qindex),
3288 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
3289 vp9_convert_qindex_to_q(cpi->active_best_quality),
3290 vp9_convert_qindex_to_q(cpi->active_worst_quality),
3291 cpi->avg_q,
3292 vp9_convert_qindex_to_q(cpi->ni_av_qi),
3293 vp9_convert_qindex_to_q(cpi->cq_target_quality),
3294 cpi->refresh_last_frame,
3295 cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
3296 cm->frame_type, cpi->gfu_boost,
3297 cpi->twopass.est_max_qcorrection_factor,
3298 (int)cpi->twopass.bits_left,
3299 cpi->twopass.total_left_stats.coded_error,
3300 (double)cpi->twopass.bits_left /
3301 cpi->twopass.total_left_stats.coded_error,
3302 cpi->tot_recode_hits, recon_err, cpi->kf_boost,
3303 cpi->kf_zeromotion_pct);
3304 else
3305 fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d"
3306 "%7.2f %7.2f %7.2f %7.2f %7.2f %7.2f %7.2f"
3307 "%5d %5d %5d %8d %8d %8.2f %10d %10.3f"
3308 "%8d %10d %10d %10d\n",
3309 cpi->common.current_video_frame,
3310 cpi->this_frame_target, cpi->projected_frame_size,
3311 0, //loop_size_estimate,
3312 (cpi->projected_frame_size - cpi->this_frame_target),
3313 (int)cpi->total_target_vs_actual,
3314 (int)(cpi->oxcf.starting_buffer_level - cpi->bits_off_target),
3315 (int)cpi->total_actual_bits,
3316 cm->base_qindex,
3317 vp9_convert_qindex_to_q(cm->base_qindex),
3318 (double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
3319 vp9_convert_qindex_to_q(cpi->active_best_quality),
3320 vp9_convert_qindex_to_q(cpi->active_worst_quality),
3321 cpi->avg_q,
3322 vp9_convert_qindex_to_q(cpi->ni_av_qi),
3323 vp9_convert_qindex_to_q(cpi->cq_target_quality),
3324 cpi->refresh_last_frame,
3325 cpi->refresh_golden_frame, cpi->refresh_alt_ref_frame,
3326 cm->frame_type, cpi->gfu_boost,
3327 cpi->twopass.est_max_qcorrection_factor,
3328 (int)cpi->twopass.bits_left,
3329 cpi->twopass.total_left_stats.coded_error,
3330 cpi->tot_recode_hits, recon_err, cpi->kf_boost,
3331 cpi->kf_zeromotion_pct);
3332
3333 fclose(f);
3334
3335 if (0) {
3336 FILE *fmodes = fopen("Modes.stt", "a");
3337 int i;
3338
3339 fprintf(fmodes, "%6d:%1d:%1d:%1d ",
3340 cpi->common.current_video_frame,
3341 cm->frame_type, cpi->refresh_golden_frame,
3342 cpi->refresh_alt_ref_frame);
3343
3344 for (i = 0; i < MAX_MODES; i++)
3345 fprintf(fmodes, "%5d ", cpi->mode_chosen_counts[i]);
3346
3347 fprintf(fmodes, "\n");
3348
3349 fclose(fmodes);
3350 }
3351 }
3352
3353 #endif 3510 #endif
3354 3511
3355 #if 0 3512 #if 0
3356 // Debug stats for segment feature experiments. 3513 output_frame_level_debug_stats(cpi);
3357 print_seg_map(cpi);
3358 #endif 3514 #endif
3359
3360 // If this was a kf or Gf note the Q
3361 if ((cm->frame_type == KEY_FRAME)
3362 || cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)
3363 cm->last_kf_gf_q = cm->base_qindex;
3364
3365 if (cpi->refresh_golden_frame == 1) 3515 if (cpi->refresh_golden_frame == 1)
3366 cm->frame_flags = cm->frame_flags | FRAMEFLAGS_GOLDEN; 3516 cm->frame_flags = cm->frame_flags | FRAMEFLAGS_GOLDEN;
3367 else 3517 else
3368 cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_GOLDEN; 3518 cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_GOLDEN;
3369 3519
3370 if (cpi->refresh_alt_ref_frame == 1) 3520 if (cpi->refresh_alt_ref_frame == 1)
3371 cm->frame_flags = cm->frame_flags | FRAMEFLAGS_ALTREF; 3521 cm->frame_flags = cm->frame_flags | FRAMEFLAGS_ALTREF;
3372 else 3522 else
3373 cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_ALTREF; 3523 cm->frame_flags = cm->frame_flags&~FRAMEFLAGS_ALTREF;
3374 3524
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3433 cpi->sequence_number = 0; 3583 cpi->sequence_number = 0;
3434 cpi->frame_coding_order_period = cpi->new_frame_coding_order_period; 3584 cpi->frame_coding_order_period = cpi->new_frame_coding_order_period;
3435 cpi->new_frame_coding_order_period = -1; 3585 cpi->new_frame_coding_order_period = -1;
3436 } 3586 }
3437 cpi->this_frame_weight = cpi->arf_weight[cpi->sequence_number]; 3587 cpi->this_frame_weight = cpi->arf_weight[cpi->sequence_number];
3438 assert(cpi->this_frame_weight >= 0); 3588 assert(cpi->this_frame_weight >= 0);
3439 } 3589 }
3440 #endif 3590 #endif
3441 } 3591 }
3442 3592
3443 // Clear the one shot update flags for segmentation map and mode/ref loop filt er deltas. 3593 // Clear the one shot update flags for segmentation map and mode/ref loop
3594 // filter deltas.
3444 cm->seg.update_map = 0; 3595 cm->seg.update_map = 0;
3445 cm->seg.update_data = 0; 3596 cm->seg.update_data = 0;
3446 cm->lf.mode_ref_delta_update = 0; 3597 cm->lf.mode_ref_delta_update = 0;
3447 3598
3448 // keep track of the last coded dimensions 3599 // keep track of the last coded dimensions
3449 cm->last_width = cm->width; 3600 cm->last_width = cm->width;
3450 cm->last_height = cm->height; 3601 cm->last_height = cm->height;
3451 3602
3452 // reset to normal state now that we are done. 3603 // reset to normal state now that we are done.
3453 cm->last_show_frame = cm->show_frame; 3604 cm->last_show_frame = cm->show_frame;
3454 if (cm->show_frame) { 3605 if (cm->show_frame) {
3455 // current mip will be the prev_mip for the next frame 3606 // current mip will be the prev_mip for the next frame
3456 MODE_INFO *temp = cm->prev_mip; 3607 MODE_INFO *temp = cm->prev_mip;
3457 MODE_INFO **temp2 = cm->prev_mi_grid_base; 3608 MODE_INFO **temp2 = cm->prev_mi_grid_base;
3458 cm->prev_mip = cm->mip; 3609 cm->prev_mip = cm->mip;
3459 cm->mip = temp; 3610 cm->mip = temp;
3460 cm->prev_mi_grid_base = cm->mi_grid_base; 3611 cm->prev_mi_grid_base = cm->mi_grid_base;
3461 cm->mi_grid_base = temp2; 3612 cm->mi_grid_base = temp2;
3462 3613
3463 // update the upper left visible macroblock ptrs 3614 // update the upper left visible macroblock ptrs
3464 cm->mi = cm->mip + cm->mode_info_stride + 1; 3615 cm->mi = cm->mip + cm->mode_info_stride + 1;
3465 cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1; 3616 cm->mi_grid_visible = cm->mi_grid_base + cm->mode_info_stride + 1;
3466 3617
3618 cpi->mb.e_mbd.mi_8x8 = cm->mi_grid_visible;
3619 cpi->mb.e_mbd.mi_8x8[0] = cm->mi;
3620
3467 // Don't increment frame counters if this was an altref buffer 3621 // Don't increment frame counters if this was an altref buffer
3468 // update not a real frame 3622 // update not a real frame
3469 ++cm->current_video_frame; 3623 ++cm->current_video_frame;
3470 ++cpi->frames_since_key; 3624 ++cpi->frames_since_key;
3471 } 3625 }
3472 // restore prev_mi 3626 // restore prev_mi
3473 cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; 3627 cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
3474 cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1; 3628 cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1;
3475
3476 #if 0
3477 {
3478 char filename[512];
3479 FILE *recon_file;
3480 sprintf(filename, "enc%04d.yuv", (int) cm->current_video_frame);
3481 recon_file = fopen(filename, "wb");
3482 fwrite(cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]].buffer_alloc,
3483 cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]].frame_size,
3484 1, recon_file);
3485 fclose(recon_file);
3486 }
3487 #endif
3488 #ifdef OUTPUT_YUV_REC
3489 vp9_write_yuv_rec_frame(cm);
3490 #endif
3491
3492 } 3629 }
3493 3630
3494 static void Pass2Encode(VP9_COMP *cpi, unsigned long *size, 3631 static void Pass2Encode(VP9_COMP *cpi, unsigned long *size,
3495 unsigned char *dest, unsigned int *frame_flags) { 3632 unsigned char *dest, unsigned int *frame_flags) {
3496
3497 cpi->enable_encode_breakout = 1; 3633 cpi->enable_encode_breakout = 1;
3498 3634
3499 if (!cpi->refresh_alt_ref_frame) 3635 if (!cpi->refresh_alt_ref_frame)
3500 vp9_second_pass(cpi); 3636 vp9_second_pass(cpi);
3501 3637
3502 encode_frame_to_data_rate(cpi, size, dest, frame_flags); 3638 encode_frame_to_data_rate(cpi, size, dest, frame_flags);
3503 // vp9_print_modes_and_motion_vectors(&cpi->common, "encode.stt"); 3639 // vp9_print_modes_and_motion_vectors(&cpi->common, "encode.stt");
3504 #ifdef DISABLE_RC_LONG_TERM_MEM 3640 #ifdef DISABLE_RC_LONG_TERM_MEM
3505 cpi->twopass.bits_left -= cpi->this_frame_target; 3641 cpi->twopass.bits_left -= cpi->this_frame_target;
3506 #else 3642 #else
3507 cpi->twopass.bits_left -= 8 * *size; 3643 cpi->twopass.bits_left -= 8 * *size;
3508 #endif 3644 #endif
3509 3645
3510 if (!cpi->refresh_alt_ref_frame) { 3646 if (!cpi->refresh_alt_ref_frame) {
3511 double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.framerate; 3647 double lower_bounds_min_rate = FRAME_OVERHEAD_BITS * cpi->oxcf.framerate;
3512 double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth 3648 double two_pass_min_rate = (double)(cpi->oxcf.target_bandwidth
3513 * cpi->oxcf.two_pass_vbrmin_section / 10 0); 3649 * cpi->oxcf.two_pass_vbrmin_section
3650 / 100);
3514 3651
3515 if (two_pass_min_rate < lower_bounds_min_rate) 3652 if (two_pass_min_rate < lower_bounds_min_rate)
3516 two_pass_min_rate = lower_bounds_min_rate; 3653 two_pass_min_rate = lower_bounds_min_rate;
3517 3654
3518 cpi->twopass.bits_left += (int64_t)(two_pass_min_rate / cpi->oxcf.framerate) ; 3655 cpi->twopass.bits_left += (int64_t)(two_pass_min_rate
3656 / cpi->oxcf.framerate);
3519 } 3657 }
3520 } 3658 }
3521 3659
3522 static void check_initial_width(VP9_COMP *cpi, YV12_BUFFER_CONFIG *sd) { 3660 static void check_initial_width(VP9_COMP *cpi, YV12_BUFFER_CONFIG *sd) {
3523 VP9_COMMON *cm = &cpi->common; 3661 VP9_COMMON *cm = &cpi->common;
3524 if (!cpi->initial_width) { 3662 if (!cpi->initial_width) {
3525 // TODO(jkoleszar): Support 1/4 subsampling? 3663 // TODO(jkoleszar): Support 1/4 subsampling?
3526 cm->subsampling_x = (sd != NULL) && sd->uv_width < sd->y_width; 3664 cm->subsampling_x = (sd != NULL) && sd->uv_width < sd->y_width;
3527 cm->subsampling_y = (sd != NULL) && sd->uv_height < sd->y_height; 3665 cm->subsampling_y = (sd != NULL) && sd->uv_height < sd->y_height;
3528 alloc_raw_frame_buffers(cpi); 3666 alloc_raw_frame_buffers(cpi);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3582 int i; 3720 int i;
3583 // FILE *fp_out = fopen("enc_frame_type.txt", "a"); 3721 // FILE *fp_out = fopen("enc_frame_type.txt", "a");
3584 3722
3585 if (!cpi) 3723 if (!cpi)
3586 return -1; 3724 return -1;
3587 3725
3588 vpx_usec_timer_start(&cmptimer); 3726 vpx_usec_timer_start(&cmptimer);
3589 3727
3590 cpi->source = NULL; 3728 cpi->source = NULL;
3591 3729
3592 cpi->mb.e_mbd.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV; 3730 cpi->common.allow_high_precision_mv = ALTREF_HIGH_PRECISION_MV;
3593 set_mvcost(&cpi->mb); 3731 set_mvcost(cpi);
3594 3732
3595 // Should we code an alternate reference frame. 3733 // Should we code an alternate reference frame.
3596 if (cpi->oxcf.play_alternate && cpi->source_alt_ref_pending) { 3734 if (cpi->oxcf.play_alternate && cpi->source_alt_ref_pending) {
3597 int frames_to_arf; 3735 int frames_to_arf;
3598 3736
3599 #if CONFIG_MULTIPLE_ARF 3737 #if CONFIG_MULTIPLE_ARF
3600 assert(!cpi->multi_arf_enabled || 3738 assert(!cpi->multi_arf_enabled ||
3601 cpi->frame_coding_order[cpi->sequence_number] < 0); 3739 cpi->frame_coding_order[cpi->sequence_number] < 0);
3602 3740
3603 if (cpi->multi_arf_enabled && (cpi->pass == 2)) 3741 if (cpi->multi_arf_enabled && (cpi->pass == 2))
(...skipping 17 matching lines...) Expand all
3621 // TODO(agrange) merge these two functions. 3759 // TODO(agrange) merge these two functions.
3622 configure_arnr_filter(cpi, cm->current_video_frame + frames_to_arf, 3760 configure_arnr_filter(cpi, cm->current_video_frame + frames_to_arf,
3623 cpi->gfu_boost); 3761 cpi->gfu_boost);
3624 vp9_temporal_filter_prepare(cpi, frames_to_arf); 3762 vp9_temporal_filter_prepare(cpi, frames_to_arf);
3625 vp9_extend_frame_borders(&cpi->alt_ref_buffer, 3763 vp9_extend_frame_borders(&cpi->alt_ref_buffer,
3626 cm->subsampling_x, cm->subsampling_y); 3764 cm->subsampling_x, cm->subsampling_y);
3627 force_src_buffer = &cpi->alt_ref_buffer; 3765 force_src_buffer = &cpi->alt_ref_buffer;
3628 } 3766 }
3629 3767
3630 cm->show_frame = 0; 3768 cm->show_frame = 0;
3631 cm->intra_only = 0;
3632 cpi->refresh_alt_ref_frame = 1; 3769 cpi->refresh_alt_ref_frame = 1;
3633 cpi->refresh_golden_frame = 0; 3770 cpi->refresh_golden_frame = 0;
3634 cpi->refresh_last_frame = 0; 3771 cpi->refresh_last_frame = 0;
3635 cpi->is_src_frame_alt_ref = 0; 3772 cpi->is_src_frame_alt_ref = 0;
3636 3773
3637 // TODO(agrange) This needs to vary depending on where the next ARF is. 3774 // TODO(agrange) This needs to vary depending on where the next ARF is.
3638 cpi->frames_till_alt_ref_frame = frames_to_arf; 3775 cpi->frames_till_alt_ref_frame = frames_to_arf;
3639 3776
3640 #if CONFIG_MULTIPLE_ARF 3777 #if CONFIG_MULTIPLE_ARF
3641 if (!cpi->multi_arf_enabled) 3778 if (!cpi->multi_arf_enabled)
3642 #endif 3779 #endif
3643 cpi->source_alt_ref_pending = 0; // Clear Pending altf Ref flag. 3780 cpi->source_alt_ref_pending = 0; // Clear Pending altf Ref flag.
3644 } 3781 }
3645 } 3782 }
3646 3783
3647 if (!cpi->source) { 3784 if (!cpi->source) {
3648 #if CONFIG_MULTIPLE_ARF 3785 #if CONFIG_MULTIPLE_ARF
3649 int i; 3786 int i;
3650 #endif 3787 #endif
3651 if ((cpi->source = vp9_lookahead_pop(cpi->lookahead, flush))) { 3788 if ((cpi->source = vp9_lookahead_pop(cpi->lookahead, flush))) {
3652 cm->show_frame = 1; 3789 cm->show_frame = 1;
3790 cm->intra_only = 0;
3653 3791
3654 #if CONFIG_MULTIPLE_ARF 3792 #if CONFIG_MULTIPLE_ARF
3655 // Is this frame the ARF overlay. 3793 // Is this frame the ARF overlay.
3656 cpi->is_src_frame_alt_ref = 0; 3794 cpi->is_src_frame_alt_ref = 0;
3657 for (i = 0; i < cpi->arf_buffered; ++i) { 3795 for (i = 0; i < cpi->arf_buffered; ++i) {
3658 if (cpi->source == cpi->alt_ref_source[i]) { 3796 if (cpi->source == cpi->alt_ref_source[i]) {
3659 cpi->is_src_frame_alt_ref = 1; 3797 cpi->is_src_frame_alt_ref = 1;
3660 cpi->refresh_golden_frame = 1; 3798 cpi->refresh_golden_frame = 1;
3661 break; 3799 break;
3662 } 3800 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3799 if (cpi->is_src_frame_alt_ref) 3937 if (cpi->is_src_frame_alt_ref)
3800 fprintf(fp_out, " type:OVERLAY[%d]", cpi->alt_fb_idx); 3938 fprintf(fp_out, " type:OVERLAY[%d]", cpi->alt_fb_idx);
3801 fprintf(fp_out, "\n"); 3939 fprintf(fp_out, "\n");
3802 } 3940 }
3803 #endif 3941 #endif
3804 3942
3805 cm->frame_type = INTER_FRAME; 3943 cm->frame_type = INTER_FRAME;
3806 cm->frame_flags = *frame_flags; 3944 cm->frame_flags = *frame_flags;
3807 3945
3808 // Reset the frame pointers to the current frame size 3946 // Reset the frame pointers to the current frame size
3809 vp9_realloc_frame_buffer(&cm->yv12_fb[cm->new_fb_idx], 3947 vp9_realloc_frame_buffer(get_frame_new_buffer(cm),
3810 cm->width, cm->height, 3948 cm->width, cm->height,
3811 cm->subsampling_x, cm->subsampling_y, 3949 cm->subsampling_x, cm->subsampling_y,
3812 VP9BORDERINPIXELS); 3950 VP9BORDERINPIXELS);
3813 3951
3814 // Calculate scaling factors for each of the 3 available references 3952 // Calculate scaling factors for each of the 3 available references
3815 for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) 3953 for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i)
3816 vp9_setup_scale_factors(cm, i); 3954 vp9_setup_scale_factors(cm, i);
3817 3955
3818 vp9_setup_interp_filters(&cpi->mb.e_mbd, DEFAULT_INTERP_FILTER, cm); 3956 vp9_setup_interp_filters(&cpi->mb.e_mbd, DEFAULT_INTERP_FILTER, cm);
3819 3957
3958 if (cpi->sf.variance_adaptive_quantization) {
3959 vp9_vaq_init();
3960 }
3961
3820 if (cpi->pass == 1) { 3962 if (cpi->pass == 1) {
3821 Pass1Encode(cpi, size, dest, frame_flags); 3963 Pass1Encode(cpi, size, dest, frame_flags);
3822 } else if (cpi->pass == 2) { 3964 } else if (cpi->pass == 2) {
3823 Pass2Encode(cpi, size, dest, frame_flags); 3965 Pass2Encode(cpi, size, dest, frame_flags);
3824 } else { 3966 } else {
3825 encode_frame_to_data_rate(cpi, size, dest, frame_flags); 3967 encode_frame_to_data_rate(cpi, size, dest, frame_flags);
3826 } 3968 }
3827 3969
3828 if (cm->refresh_frame_context) 3970 if (cm->refresh_frame_context)
3829 cm->frame_contexts[cm->frame_context_idx] = cm->fc; 3971 cm->frame_contexts[cm->frame_context_idx] = cm->fc;
(...skipping 16 matching lines...) Expand all
3846 3988
3847 if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame) 3989 if (cpi->b_calculate_psnr && cpi->pass != 1 && cm->show_frame)
3848 generate_psnr_packet(cpi); 3990 generate_psnr_packet(cpi);
3849 3991
3850 #if CONFIG_INTERNAL_STATS 3992 #if CONFIG_INTERNAL_STATS
3851 3993
3852 if (cpi->pass != 1) { 3994 if (cpi->pass != 1) {
3853 cpi->bytes += *size; 3995 cpi->bytes += *size;
3854 3996
3855 if (cm->show_frame) { 3997 if (cm->show_frame) {
3856
3857 cpi->count++; 3998 cpi->count++;
3858 3999
3859 if (cpi->b_calculate_psnr) { 4000 if (cpi->b_calculate_psnr) {
3860 double ye, ue, ve; 4001 double ye, ue, ve;
3861 double frame_psnr; 4002 double frame_psnr;
3862 YV12_BUFFER_CONFIG *orig = cpi->Source; 4003 YV12_BUFFER_CONFIG *orig = cpi->Source;
3863 YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show; 4004 YV12_BUFFER_CONFIG *recon = cpi->common.frame_to_show;
3864 YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer; 4005 YV12_BUFFER_CONFIG *pp = &cm->post_proc_buffer;
3865 int y_samples = orig->y_height * orig->y_width; 4006 int y_samples = orig->y_height * orig->y_width;
3866 int uv_samples = orig->uv_height * orig->uv_width; 4007 int uv_samples = orig->uv_height * orig->uv_width;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3956 4097
3957 #endif 4098 #endif
3958 // fclose(fp_out); 4099 // fclose(fp_out);
3959 return 0; 4100 return 0;
3960 } 4101 }
3961 4102
3962 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest, 4103 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest,
3963 vp9_ppflags_t *flags) { 4104 vp9_ppflags_t *flags) {
3964 VP9_COMP *cpi = (VP9_COMP *) comp; 4105 VP9_COMP *cpi = (VP9_COMP *) comp;
3965 4106
3966 if (!cpi->common.show_frame) 4107 if (!cpi->common.show_frame) {
3967 return -1; 4108 return -1;
3968 else { 4109 } else {
3969 int ret; 4110 int ret;
3970 #if CONFIG_VP9_POSTPROC 4111 #if CONFIG_VP9_POSTPROC
3971 ret = vp9_post_proc_frame(&cpi->common, dest, flags); 4112 ret = vp9_post_proc_frame(&cpi->common, dest, flags);
3972 #else 4113 #else
3973 4114
3974 if (cpi->common.frame_to_show) { 4115 if (cpi->common.frame_to_show) {
3975 *dest = *cpi->common.frame_to_show; 4116 *dest = *cpi->common.frame_to_show;
3976 dest->y_width = cpi->common.width; 4117 dest->y_width = cpi->common.width;
3977 dest->y_height = cpi->common.height; 4118 dest->y_height = cpi->common.height;
3978 dest->uv_height = cpi->common.height / 2; 4119 dest->uv_height = cpi->common.height / 2;
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 dst += 16 * dest->y_stride; 4310 dst += 16 * dest->y_stride;
4170 } 4311 }
4171 4312
4172 return total; 4313 return total;
4173 } 4314 }
4174 4315
4175 4316
4176 int vp9_get_quantizer(VP9_PTR c) { 4317 int vp9_get_quantizer(VP9_PTR c) {
4177 return ((VP9_COMP *)c)->common.base_qindex; 4318 return ((VP9_COMP *)c)->common.base_qindex;
4178 } 4319 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_modecosts.c ('k') | source/libvpx/vp9/encoder/vp9_onyx_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698