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

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

Issue 23600008: libvpx: Pull from upstream (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_modecosts.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 11
12 #include "vpx_config.h" 12 #include "vpx_config.h"
(...skipping 29 matching lines...) Expand all
42 #include "vp9/encoder/vp9_picklpf.h" 42 #include "vp9/encoder/vp9_picklpf.h"
43 #include "vp9/common/vp9_mvref_common.h" 43 #include "vp9/common/vp9_mvref_common.h"
44 #include "vp9/encoder/vp9_temporal_filter.h" 44 #include "vp9/encoder/vp9_temporal_filter.h"
45 45
46 #include <math.h> 46 #include <math.h>
47 #include <stdio.h> 47 #include <stdio.h>
48 #include <limits.h> 48 #include <limits.h>
49 49
50 extern void print_tree_update_probs(); 50 extern void print_tree_update_probs();
51 51
52 static void set_default_lf_deltas(VP9_COMP *cpi); 52 static void set_default_lf_deltas(struct loopfilter *lf);
53 53
54 #define DEFAULT_INTERP_FILTER SWITCHABLE 54 #define DEFAULT_INTERP_FILTER SWITCHABLE
55 55
56 #define SEARCH_BEST_FILTER 0 /* to search exhaustively for 56 #define SEARCH_BEST_FILTER 0 /* to search exhaustively for
57 best filter */ 57 best filter */
58 #define RESET_FOREACH_FILTER 0 /* whether to reset the encoder state 58 #define RESET_FOREACH_FILTER 0 /* whether to reset the encoder state
59 before trying each new filter */ 59 before trying each new filter */
60 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */ 60 #define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */
61 61
62 #define ALTREF_HIGH_PRECISION_MV 1 /* whether to use high precision mv 62 #define ALTREF_HIGH_PRECISION_MV 1 /* whether to use high precision mv
(...skipping 28 matching lines...) Expand all
91 #endif 91 #endif
92 92
93 #if 0 93 #if 0
94 FILE *framepsnr; 94 FILE *framepsnr;
95 FILE *kf_list; 95 FILE *kf_list;
96 FILE *keyfile; 96 FILE *keyfile;
97 #endif 97 #endif
98 98
99 99
100 #ifdef ENTROPY_STATS 100 #ifdef ENTROPY_STATS
101 extern int intra_mode_stats[VP9_INTRA_MODES] 101 extern int intra_mode_stats[INTRA_MODES]
102 [VP9_INTRA_MODES] 102 [INTRA_MODES]
103 [VP9_INTRA_MODES]; 103 [INTRA_MODES];
104 #endif 104 #endif
105 105
106 #ifdef NMV_STATS
107 extern void init_nmvstats();
108 extern void print_nmvstats();
109 #endif
110 #ifdef MODE_STATS 106 #ifdef MODE_STATS
111 extern void init_tx_count_stats(); 107 extern void init_tx_count_stats();
112 extern void write_tx_count_stats(); 108 extern void write_tx_count_stats();
113 extern void init_switchable_interp_stats(); 109 extern void init_switchable_interp_stats();
114 extern void write_switchable_interp_stats(); 110 extern void write_switchable_interp_stats();
115 #endif 111 #endif
116 112
117 #ifdef SPEEDSTATS 113 #ifdef SPEEDSTATS
118 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 114 unsigned int frames_at_speed[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
119 #endif 115 #endif
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 vp9_initialize_common(); 230 vp9_initialize_common();
235 vp9_tokenize_initialize(); 231 vp9_tokenize_initialize();
236 vp9_init_quant_tables(); 232 vp9_init_quant_tables();
237 vp9_init_me_luts(); 233 vp9_init_me_luts();
238 init_minq_luts(); 234 init_minq_luts();
239 // init_base_skip_probs(); 235 // init_base_skip_probs();
240 init_done = 1; 236 init_done = 1;
241 } 237 }
242 } 238 }
243 239
244 static void setup_features(VP9_COMP *cpi) { 240 static void setup_features(VP9_COMMON *cm) {
245 MACROBLOCKD *xd = &cpi->mb.e_mbd; 241 struct loopfilter *const lf = &cm->lf;
246 struct loopfilter *lf = &xd->lf; 242 struct segmentation *const seg = &cm->seg;
247 243
248 // Set up default state for MB feature flags 244 // Set up default state for MB feature flags
249 xd->seg.enabled = 0; 245 seg->enabled = 0;
250 246
251 xd->seg.update_map = 0; 247 seg->update_map = 0;
252 xd->seg.update_data = 0; 248 seg->update_data = 0;
253 vpx_memset(xd->seg.tree_probs, 255, sizeof(xd->seg.tree_probs)); 249 vpx_memset(seg->tree_probs, 255, sizeof(seg->tree_probs));
254 250
255 vp9_clearall_segfeatures(&xd->seg); 251 vp9_clearall_segfeatures(seg);
256 252
257 lf->mode_ref_delta_enabled = 0; 253 lf->mode_ref_delta_enabled = 0;
258 lf->mode_ref_delta_update = 0; 254 lf->mode_ref_delta_update = 0;
259 vp9_zero(lf->ref_deltas); 255 vp9_zero(lf->ref_deltas);
260 vp9_zero(lf->mode_deltas); 256 vp9_zero(lf->mode_deltas);
261 vp9_zero(lf->last_ref_deltas); 257 vp9_zero(lf->last_ref_deltas);
262 vp9_zero(lf->last_mode_deltas); 258 vp9_zero(lf->last_mode_deltas);
263 259
264 set_default_lf_deltas(cpi); 260 set_default_lf_deltas(lf);
265 } 261 }
266 262
267 static void dealloc_compressor_data(VP9_COMP *cpi) { 263 static void dealloc_compressor_data(VP9_COMP *cpi) {
268 // Delete sementation map 264 // Delete sementation map
269 vpx_free(cpi->segmentation_map); 265 vpx_free(cpi->segmentation_map);
270 cpi->segmentation_map = 0; 266 cpi->segmentation_map = 0;
271 vpx_free(cpi->common.last_frame_seg_map); 267 vpx_free(cpi->common.last_frame_seg_map);
272 cpi->common.last_frame_seg_map = 0; 268 cpi->common.last_frame_seg_map = 0;
273 vpx_free(cpi->coding_context.last_frame_seg_map_copy); 269 vpx_free(cpi->coding_context.last_frame_seg_map_copy);
274 cpi->coding_context.last_frame_seg_map_copy = 0; 270 cpi->coding_context.last_frame_seg_map_copy = 0;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 target_index = i; 312 target_index = i;
317 if (vp9_convert_qindex_to_q(i) >= qtarget) 313 if (vp9_convert_qindex_to_q(i) >= qtarget)
318 break; 314 break;
319 } 315 }
320 316
321 return target_index - start_index; 317 return target_index - start_index;
322 } 318 }
323 319
324 static void configure_static_seg_features(VP9_COMP *cpi) { 320 static void configure_static_seg_features(VP9_COMP *cpi) {
325 VP9_COMMON *cm = &cpi->common; 321 VP9_COMMON *cm = &cpi->common;
326 MACROBLOCKD *xd = &cpi->mb.e_mbd; 322 struct segmentation *seg = &cm->seg;
327 323
328 int high_q = (int)(cpi->avg_q > 48.0); 324 int high_q = (int)(cpi->avg_q > 48.0);
329 int qi_delta; 325 int qi_delta;
330 326
331 // Disable and clear down for KF 327 // Disable and clear down for KF
332 if (cm->frame_type == KEY_FRAME) { 328 if (cm->frame_type == KEY_FRAME) {
333 // Clear down the global segmentation map 329 // Clear down the global segmentation map
334 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); 330 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
335 xd->seg.update_map = 0; 331 seg->update_map = 0;
336 xd->seg.update_data = 0; 332 seg->update_data = 0;
337 cpi->static_mb_pct = 0; 333 cpi->static_mb_pct = 0;
338 334
339 // Disable segmentation 335 // Disable segmentation
340 vp9_disable_segmentation((VP9_PTR)cpi); 336 vp9_disable_segmentation((VP9_PTR)cpi);
341 337
342 // Clear down the segment features. 338 // Clear down the segment features.
343 vp9_clearall_segfeatures(&xd->seg); 339 vp9_clearall_segfeatures(seg);
344 } else if (cpi->refresh_alt_ref_frame) { 340 } else if (cpi->refresh_alt_ref_frame) {
345 // If this is an alt ref frame 341 // If this is an alt ref frame
346 // Clear down the global segmentation map 342 // Clear down the global segmentation map
347 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); 343 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
348 xd->seg.update_map = 0; 344 seg->update_map = 0;
349 xd->seg.update_data = 0; 345 seg->update_data = 0;
350 cpi->static_mb_pct = 0; 346 cpi->static_mb_pct = 0;
351 347
352 // Disable segmentation and individual segment features by default 348 // Disable segmentation and individual segment features by default
353 vp9_disable_segmentation((VP9_PTR)cpi); 349 vp9_disable_segmentation((VP9_PTR)cpi);
354 vp9_clearall_segfeatures(&xd->seg); 350 vp9_clearall_segfeatures(seg);
355 351
356 // Scan frames from current to arf frame. 352 // Scan frames from current to arf frame.
357 // This function re-enables segmentation if appropriate. 353 // This function re-enables segmentation if appropriate.
358 vp9_update_mbgraph_stats(cpi); 354 vp9_update_mbgraph_stats(cpi);
359 355
360 // If segmentation was enabled set those features needed for the 356 // If segmentation was enabled set those features needed for the
361 // arf itself. 357 // arf itself.
362 if (xd->seg.enabled) { 358 if (seg->enabled) {
363 xd->seg.update_map = 1; 359 seg->update_map = 1;
364 xd->seg.update_data = 1; 360 seg->update_data = 1;
365 361
366 qi_delta = compute_qdelta(cpi, cpi->avg_q, (cpi->avg_q * 0.875)); 362 qi_delta = compute_qdelta(cpi, cpi->avg_q, (cpi->avg_q * 0.875));
367 vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_Q, (qi_delta - 2)); 363 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta - 2));
368 vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_LF, -2); 364 vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
369 365
370 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_Q); 366 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
371 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_LF); 367 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);
372 368
373 // Where relevant assume segment data is delta data 369 // Where relevant assume segment data is delta data
374 xd->seg.abs_delta = SEGMENT_DELTADATA; 370 seg->abs_delta = SEGMENT_DELTADATA;
375 371
376 } 372 }
377 } else if (xd->seg.enabled) { 373 } else if (seg->enabled) {
378 // All other frames if segmentation has been enabled 374 // All other frames if segmentation has been enabled
379 375
380 // First normal frame in a valid gf or alt ref group 376 // First normal frame in a valid gf or alt ref group
381 if (cpi->frames_since_golden == 0) { 377 if (cpi->frames_since_golden == 0) {
382 // Set up segment features for normal frames in an arf group 378 // Set up segment features for normal frames in an arf group
383 if (cpi->source_alt_ref_active) { 379 if (cpi->source_alt_ref_active) {
384 xd->seg.update_map = 0; 380 seg->update_map = 0;
385 xd->seg.update_data = 1; 381 seg->update_data = 1;
386 xd->seg.abs_delta = SEGMENT_DELTADATA; 382 seg->abs_delta = SEGMENT_DELTADATA;
387 383
388 qi_delta = compute_qdelta(cpi, cpi->avg_q, 384 qi_delta = compute_qdelta(cpi, cpi->avg_q,
389 (cpi->avg_q * 1.125)); 385 (cpi->avg_q * 1.125));
390 vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_Q, (qi_delta + 2)); 386 vp9_set_segdata(seg, 1, SEG_LVL_ALT_Q, (qi_delta + 2));
391 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_Q); 387 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_Q);
392 388
393 vp9_set_segdata(&xd->seg, 1, SEG_LVL_ALT_LF, -2); 389 vp9_set_segdata(seg, 1, SEG_LVL_ALT_LF, -2);
394 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_ALT_LF); 390 vp9_enable_segfeature(seg, 1, SEG_LVL_ALT_LF);
395 391
396 // Segment coding disabled for compred testing 392 // Segment coding disabled for compred testing
397 if (high_q || (cpi->static_mb_pct == 100)) { 393 if (high_q || (cpi->static_mb_pct == 100)) {
398 vp9_set_segdata(&xd->seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME); 394 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
399 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_REF_FRAME); 395 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
400 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_SKIP); 396 vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP);
401 } 397 }
402 } else { 398 } else {
403 // Disable segmentation and clear down features if alt ref 399 // Disable segmentation and clear down features if alt ref
404 // is not active for this group 400 // is not active for this group
405 401
406 vp9_disable_segmentation((VP9_PTR)cpi); 402 vp9_disable_segmentation((VP9_PTR)cpi);
407 403
408 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols); 404 vpx_memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
409 405
410 xd->seg.update_map = 0; 406 seg->update_map = 0;
411 xd->seg.update_data = 0; 407 seg->update_data = 0;
412 408
413 vp9_clearall_segfeatures(&xd->seg); 409 vp9_clearall_segfeatures(seg);
414 } 410 }
415 } else if (cpi->is_src_frame_alt_ref) { 411 } else if (cpi->is_src_frame_alt_ref) {
416 // Special case where we are coding over the top of a previous 412 // Special case where we are coding over the top of a previous
417 // alt ref frame. 413 // alt ref frame.
418 // Segment coding disabled for compred testing 414 // Segment coding disabled for compred testing
419 415
420 // Enable ref frame features for segment 0 as well 416 // Enable ref frame features for segment 0 as well
421 vp9_enable_segfeature(&xd->seg, 0, SEG_LVL_REF_FRAME); 417 vp9_enable_segfeature(seg, 0, SEG_LVL_REF_FRAME);
422 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_REF_FRAME); 418 vp9_enable_segfeature(seg, 1, SEG_LVL_REF_FRAME);
423 419
424 // All mbs should use ALTREF_FRAME 420 // All mbs should use ALTREF_FRAME
425 vp9_clear_segdata(&xd->seg, 0, SEG_LVL_REF_FRAME); 421 vp9_clear_segdata(seg, 0, SEG_LVL_REF_FRAME);
426 vp9_set_segdata(&xd->seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME); 422 vp9_set_segdata(seg, 0, SEG_LVL_REF_FRAME, ALTREF_FRAME);
427 vp9_clear_segdata(&xd->seg, 1, SEG_LVL_REF_FRAME); 423 vp9_clear_segdata(seg, 1, SEG_LVL_REF_FRAME);
428 vp9_set_segdata(&xd->seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME); 424 vp9_set_segdata(seg, 1, SEG_LVL_REF_FRAME, ALTREF_FRAME);
429 425
430 // Skip all MBs if high Q (0,0 mv and skip coeffs) 426 // Skip all MBs if high Q (0,0 mv and skip coeffs)
431 if (high_q) { 427 if (high_q) {
432 vp9_enable_segfeature(&xd->seg, 0, SEG_LVL_SKIP); 428 vp9_enable_segfeature(seg, 0, SEG_LVL_SKIP);
433 vp9_enable_segfeature(&xd->seg, 1, SEG_LVL_SKIP); 429 vp9_enable_segfeature(seg, 1, SEG_LVL_SKIP);
434 } 430 }
435 // Enable data update 431 // Enable data update
436 xd->seg.update_data = 1; 432 seg->update_data = 1;
437 } else { 433 } else {
438 // All other frames. 434 // All other frames.
439 435
440 // No updates.. leave things as they are. 436 // No updates.. leave things as they are.
441 xd->seg.update_map = 0; 437 seg->update_map = 0;
442 xd->seg.update_data = 0; 438 seg->update_data = 0;
443 } 439 }
444 } 440 }
445 } 441 }
446 442
447 #ifdef ENTROPY_STATS 443 #ifdef ENTROPY_STATS
448 void vp9_update_mode_context_stats(VP9_COMP *cpi) { 444 void vp9_update_mode_context_stats(VP9_COMP *cpi) {
449 VP9_COMMON *cm = &cpi->common; 445 VP9_COMMON *cm = &cpi->common;
450 int i, j; 446 int i, j;
451 unsigned int (*inter_mode_counts)[VP9_INTER_MODES - 1][2] = 447 unsigned int (*inter_mode_counts)[INTER_MODES - 1][2] =
452 cm->fc.inter_mode_counts; 448 cm->fc.inter_mode_counts;
453 int64_t (*mv_ref_stats)[VP9_INTER_MODES - 1][2] = cpi->mv_ref_stats; 449 int64_t (*mv_ref_stats)[INTER_MODES - 1][2] = cpi->mv_ref_stats;
454 FILE *f; 450 FILE *f;
455 451
456 // Read the past stats counters 452 // Read the past stats counters
457 f = fopen("mode_context.bin", "rb"); 453 f = fopen("mode_context.bin", "rb");
458 if (!f) { 454 if (!f) {
459 vpx_memset(cpi->mv_ref_stats, 0, sizeof(cpi->mv_ref_stats)); 455 vpx_memset(cpi->mv_ref_stats, 0, sizeof(cpi->mv_ref_stats));
460 } else { 456 } else {
461 fread(cpi->mv_ref_stats, sizeof(cpi->mv_ref_stats), 1, f); 457 fread(cpi->mv_ref_stats, sizeof(cpi->mv_ref_stats), 1, f);
462 fclose(f); 458 fclose(f);
463 } 459 }
464 460
465 // Add in the values for this frame 461 // Add in the values for this frame
466 for (i = 0; i < INTER_MODE_CONTEXTS; i++) { 462 for (i = 0; i < INTER_MODE_CONTEXTS; i++) {
467 for (j = 0; j < VP9_INTER_MODES - 1; j++) { 463 for (j = 0; j < INTER_MODES - 1; j++) {
468 mv_ref_stats[i][j][0] += (int64_t)inter_mode_counts[i][j][0]; 464 mv_ref_stats[i][j][0] += (int64_t)inter_mode_counts[i][j][0];
469 mv_ref_stats[i][j][1] += (int64_t)inter_mode_counts[i][j][1]; 465 mv_ref_stats[i][j][1] += (int64_t)inter_mode_counts[i][j][1];
470 } 466 }
471 } 467 }
472 468
473 // Write back the accumulated stats 469 // Write back the accumulated stats
474 f = fopen("mode_context.bin", "wb"); 470 f = fopen("mode_context.bin", "wb");
475 fwrite(cpi->mv_ref_stats, sizeof(cpi->mv_ref_stats), 1, f); 471 fwrite(cpi->mv_ref_stats, sizeof(cpi->mv_ref_stats), 1, f);
476 fclose(f); 472 fclose(f);
477 } 473 }
478 474
479 void print_mode_context(VP9_COMP *cpi) { 475 void print_mode_context(VP9_COMP *cpi) {
480 FILE *f = fopen("vp9_modecont.c", "a"); 476 FILE *f = fopen("vp9_modecont.c", "a");
481 int i, j; 477 int i, j;
482 478
483 fprintf(f, "#include \"vp9_entropy.h\"\n"); 479 fprintf(f, "#include \"vp9_entropy.h\"\n");
484 fprintf( 480 fprintf(
485 f, 481 f,
486 "const int inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1] ="); 482 "const int inter_mode_probs[INTER_MODE_CONTEXTS][INTER_MODES - 1] =");
487 fprintf(f, "{\n"); 483 fprintf(f, "{\n");
488 for (j = 0; j < INTER_MODE_CONTEXTS; j++) { 484 for (j = 0; j < INTER_MODE_CONTEXTS; j++) {
489 fprintf(f, " {/* %d */ ", j); 485 fprintf(f, " {/* %d */ ", j);
490 fprintf(f, " "); 486 fprintf(f, " ");
491 for (i = 0; i < VP9_INTER_MODES - 1; i++) { 487 for (i = 0; i < INTER_MODES - 1; i++) {
492 int this_prob; 488 int this_prob;
493 int64_t count = cpi->mv_ref_stats[j][i][0] + cpi->mv_ref_stats[j][i][1]; 489 int64_t count = cpi->mv_ref_stats[j][i][0] + cpi->mv_ref_stats[j][i][1];
494 if (count) 490 if (count)
495 this_prob = ((cpi->mv_ref_stats[j][i][0] * 256) + (count >> 1)) / count; 491 this_prob = ((cpi->mv_ref_stats[j][i][0] * 256) + (count >> 1)) / count;
496 else 492 else
497 this_prob = 128; 493 this_prob = 128;
498 494
499 // context probs 495 // context probs
500 fprintf(f, "%5d, ", this_prob); 496 fprintf(f, "%5d, ", this_prob);
501 } 497 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 for (row = 0; row < cm->mi_rows; row++) { 533 for (row = 0; row < cm->mi_rows; row++) {
538 mi = mi_ptr; 534 mi = mi_ptr;
539 cache = cache_ptr; 535 cache = cache_ptr;
540 for (col = 0; col < cm->mi_cols; col++, mi++, cache++) 536 for (col = 0; col < cm->mi_cols; col++, mi++, cache++)
541 cache[0] = mi->mbmi.segment_id; 537 cache[0] = mi->mbmi.segment_id;
542 mi_ptr += cm->mode_info_stride; 538 mi_ptr += cm->mode_info_stride;
543 cache_ptr += cm->mi_cols; 539 cache_ptr += cm->mi_cols;
544 } 540 }
545 } 541 }
546 542
547 static void set_default_lf_deltas(VP9_COMP *cpi) { 543 static void set_default_lf_deltas(struct loopfilter *lf) {
548 struct loopfilter *lf = &cpi->mb.e_mbd.lf;
549
550 lf->mode_ref_delta_enabled = 1; 544 lf->mode_ref_delta_enabled = 1;
551 lf->mode_ref_delta_update = 1; 545 lf->mode_ref_delta_update = 1;
552 546
553 vp9_zero(lf->ref_deltas); 547 vp9_zero(lf->ref_deltas);
554 vp9_zero(lf->mode_deltas); 548 vp9_zero(lf->mode_deltas);
555 549
556 // Test of ref frame deltas 550 // Test of ref frame deltas
557 lf->ref_deltas[INTRA_FRAME] = 2; 551 lf->ref_deltas[INTRA_FRAME] = 2;
558 lf->ref_deltas[LAST_FRAME] = 0; 552 lf->ref_deltas[LAST_FRAME] = 0;
559 lf->ref_deltas[GOLDEN_FRAME] = -2; 553 lf->ref_deltas[GOLDEN_FRAME] = -2;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 sf->thresh_mult[THR_COMP_ZEROLA] += speed_multiplier * 2500; 601 sf->thresh_mult[THR_COMP_ZEROLA] += speed_multiplier * 2500;
608 sf->thresh_mult[THR_COMP_ZEROGA] += speed_multiplier * 2500; 602 sf->thresh_mult[THR_COMP_ZEROGA] += speed_multiplier * 2500;
609 603
610 sf->thresh_mult[THR_B_PRED] += speed_multiplier * 2500; 604 sf->thresh_mult[THR_B_PRED] += speed_multiplier * 2500;
611 sf->thresh_mult[THR_H_PRED] += speed_multiplier * 2000; 605 sf->thresh_mult[THR_H_PRED] += speed_multiplier * 2000;
612 sf->thresh_mult[THR_V_PRED] += speed_multiplier * 2000; 606 sf->thresh_mult[THR_V_PRED] += speed_multiplier * 2000;
613 sf->thresh_mult[THR_D45_PRED ] += speed_multiplier * 2500; 607 sf->thresh_mult[THR_D45_PRED ] += speed_multiplier * 2500;
614 sf->thresh_mult[THR_D135_PRED] += speed_multiplier * 2500; 608 sf->thresh_mult[THR_D135_PRED] += speed_multiplier * 2500;
615 sf->thresh_mult[THR_D117_PRED] += speed_multiplier * 2500; 609 sf->thresh_mult[THR_D117_PRED] += speed_multiplier * 2500;
616 sf->thresh_mult[THR_D153_PRED] += speed_multiplier * 2500; 610 sf->thresh_mult[THR_D153_PRED] += speed_multiplier * 2500;
617 sf->thresh_mult[THR_D27_PRED] += speed_multiplier * 2500; 611 sf->thresh_mult[THR_D207_PRED] += speed_multiplier * 2500;
618 sf->thresh_mult[THR_D63_PRED] += speed_multiplier * 2500; 612 sf->thresh_mult[THR_D63_PRED] += speed_multiplier * 2500;
619 613
620 if (cpi->sf.skip_lots_of_modes) { 614 if (cpi->sf.skip_lots_of_modes) {
621 for (i = 0; i < MAX_MODES; ++i) 615 for (i = 0; i < MAX_MODES; ++i)
622 sf->thresh_mult[i] = INT_MAX; 616 sf->thresh_mult[i] = INT_MAX;
623 617
624 sf->thresh_mult[THR_DC] = 2000; 618 sf->thresh_mult[THR_DC] = 2000;
625 sf->thresh_mult[THR_TM] = 2000; 619 sf->thresh_mult[THR_TM] = 2000;
626 sf->thresh_mult[THR_NEWMV] = 4000; 620 sf->thresh_mult[THR_NEWMV] = 4000;
627 sf->thresh_mult[THR_NEWG] = 4000; 621 sf->thresh_mult[THR_NEWG] = 4000;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 cpi->mode_check_freq[i] = 0; 698 cpi->mode_check_freq[i] = 0;
705 cpi->mode_test_hit_counts[i] = 0; 699 cpi->mode_test_hit_counts[i] = 0;
706 cpi->mode_chosen_counts[i] = 0; 700 cpi->mode_chosen_counts[i] = 0;
707 } 701 }
708 702
709 // best quality defaults 703 // best quality defaults
710 sf->RD = 1; 704 sf->RD = 1;
711 sf->search_method = NSTEP; 705 sf->search_method = NSTEP;
712 sf->auto_filter = 1; 706 sf->auto_filter = 1;
713 sf->recode_loop = 1; 707 sf->recode_loop = 1;
714 sf->quarter_pixel_search = 1; 708 sf->subpel_search_method = SUBPEL_TREE;
715 sf->half_pixel_search = 1; 709 sf->subpel_iters_per_step = 2;
716 sf->iterative_sub_pixel = 1;
717 sf->optimize_coefficients = !cpi->oxcf.lossless; 710 sf->optimize_coefficients = !cpi->oxcf.lossless;
718 sf->reduce_first_step_size = 0; 711 sf->reduce_first_step_size = 0;
719 sf->auto_mv_step_size = 0; 712 sf->auto_mv_step_size = 0;
720 sf->max_step_search_steps = MAX_MVSEARCH_STEPS; 713 sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
721 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_AB4X4; 714 sf->comp_inter_joint_search_thresh = BLOCK_4X4;
722 sf->adaptive_rd_thresh = 0; 715 sf->adaptive_rd_thresh = 0;
723 sf->use_lastframe_partitioning = 0; 716 sf->use_lastframe_partitioning = 0;
724 sf->tx_size_search_method = USE_FULL_RD; 717 sf->tx_size_search_method = USE_FULL_RD;
725 sf->use_8tap_always = 0; 718 sf->use_lp32x32fdct = 0;
726 sf->use_avoid_tested_higherror = 0; 719 sf->use_avoid_tested_higherror = 0;
727 sf->reference_masking = 0; 720 sf->reference_masking = 0;
728 sf->skip_lots_of_modes = 0; 721 sf->skip_lots_of_modes = 0;
729 sf->adjust_thresholds_by_speed = 0; 722 sf->adjust_thresholds_by_speed = 0;
730 sf->partition_by_variance = 0; 723 sf->partition_by_variance = 0;
731 sf->use_one_partition_size_always = 0; 724 sf->use_one_partition_size_always = 0;
732 sf->less_rectangular_check = 0; 725 sf->less_rectangular_check = 0;
733 sf->use_square_partition_only = 0; 726 sf->use_square_partition_only = 0;
734 sf->use_partitions_less_than = 0; 727 sf->auto_min_max_partition_size = 0;
735 sf->less_than_block_size = BLOCK_SIZE_MB16X16; 728 sf->auto_min_max_partition_interval = 0;
736 sf->use_partitions_greater_than = 0; 729 sf->auto_min_max_partition_count = 0;
737 sf->greater_than_block_size = BLOCK_SIZE_SB8X8; 730 sf->max_partition_size = BLOCK_64X64;
731 sf->min_partition_size = BLOCK_4X4;
738 sf->adjust_partitioning_from_last_frame = 0; 732 sf->adjust_partitioning_from_last_frame = 0;
739 sf->last_partitioning_redo_frequency = 4; 733 sf->last_partitioning_redo_frequency = 4;
740 sf->disable_splitmv = 0; 734 sf->disable_splitmv = 0;
741 sf->mode_search_skip_flags = 0; 735 sf->mode_search_skip_flags = 0;
742 sf->last_chroma_intra_mode = TM_PRED; 736 sf->disable_split_var_thresh = 0;
737 sf->disable_filter_search_var_thresh = 0;
738 sf->intra_y_mode_mask = ALL_INTRA_MODES;
739 sf->intra_uv_mode_mask = ALL_INTRA_MODES;
743 sf->use_rd_breakout = 0; 740 sf->use_rd_breakout = 0;
744 sf->skip_encode_sb = 0; 741 sf->skip_encode_sb = 0;
745 sf->use_uv_intra_rd_estimate = 0; 742 sf->use_uv_intra_rd_estimate = 0;
743 sf->use_fast_lpf_pick = 0;
746 sf->using_small_partition_info = 0; 744 sf->using_small_partition_info = 0;
747 // Skip any mode not chosen at size < X for all sizes > X 745 // Skip any mode not chosen at size < X for all sizes > X
748 // Hence BLOCK_SIZE_SB64X64 (skip is off) 746 // Hence BLOCK_64X64 (skip is off)
749 sf->unused_mode_skip_lvl = BLOCK_SIZE_SB64X64; 747 sf->unused_mode_skip_lvl = BLOCK_64X64;
750 748
751 #if CONFIG_MULTIPLE_ARF 749 #if CONFIG_MULTIPLE_ARF
752 // Switch segmentation off. 750 // Switch segmentation off.
753 sf->static_segmentation = 0; 751 sf->static_segmentation = 0;
754 #else 752 #else
755 sf->static_segmentation = 0; 753 sf->static_segmentation = 0;
756 #endif 754 #endif
757 755
758 switch (mode) { 756 switch (mode) {
759 case 0: // best quality mode 757 case 0: // best quality mode
760 sf->search_best_filter = SEARCH_BEST_FILTER; 758 sf->search_best_filter = SEARCH_BEST_FILTER;
761 break; 759 break;
762 760
763 case 1: 761 case 1:
764 #if CONFIG_MULTIPLE_ARF 762 #if CONFIG_MULTIPLE_ARF
765 // Switch segmentation off. 763 // Switch segmentation off.
766 sf->static_segmentation = 0; 764 sf->static_segmentation = 0;
767 #else 765 #else
768 sf->static_segmentation = 0; 766 sf->static_segmentation = 0;
769 #endif 767 #endif
770 sf->use_avoid_tested_higherror = 1; 768 sf->use_avoid_tested_higherror = 1;
771 sf->adaptive_rd_thresh = 1; 769 sf->adaptive_rd_thresh = MIN((speed + 1), 4);
772 sf->last_chroma_intra_mode = TM_PRED;
773 770
774 if (speed == 1) { 771 if (speed == 1) {
775 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES; 772 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
776 sf->less_rectangular_check = 1; 773 sf->less_rectangular_check = 1;
777 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 774 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME ||
778 cpi->common.intra_only || 775 cpi->common.intra_only ||
779 cpi->common.show_frame == 0) ? 776 cpi->common.show_frame == 0) ?
780 USE_FULL_RD : 777 USE_FULL_RD :
781 USE_LARGESTALL); 778 USE_LARGESTALL);
782 sf->use_square_partition_only = !(cpi->common.frame_type == KEY_FRAME || 779 sf->use_square_partition_only = !(cpi->common.frame_type == KEY_FRAME ||
783 cpi->common.intra_only || 780 cpi->common.intra_only ||
784 cpi->common.show_frame == 0); 781 cpi->common.show_frame == 0);
785 sf->disable_splitmv = 782 sf->disable_splitmv =
786 (MIN(cpi->common.width, cpi->common.height) >= 720)? 1 : 0; 783 (MIN(cpi->common.width, cpi->common.height) >= 720)? 1 : 0;
787 sf->unused_mode_skip_lvl = BLOCK_SIZE_SB32X32; 784 sf->unused_mode_skip_lvl = BLOCK_32X32;
788 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 785 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
789 FLAG_SKIP_INTRA_BESTINTER | 786 FLAG_SKIP_INTRA_BESTINTER |
790 FLAG_SKIP_COMP_BESTINTRA; 787 FLAG_SKIP_COMP_BESTINTRA |
791 sf->last_chroma_intra_mode = H_PRED; 788 FLAG_SKIP_INTRA_LOWVAR;
789 sf->use_uv_intra_rd_estimate = 1;
792 sf->use_rd_breakout = 1; 790 sf->use_rd_breakout = 1;
793 sf->skip_encode_sb = 1; 791 sf->skip_encode_sb = 1;
792 sf->use_lp32x32fdct = 1;
794 sf->auto_mv_step_size = 1; 793 sf->auto_mv_step_size = 1;
794
795 sf->auto_min_max_partition_size = 1;
796 sf->auto_min_max_partition_interval = 1;
797 // FIXME(jingning): temporarily turn off disable_split_var_thresh
798 // during refactoring process. will get this back after finishing
799 // the main framework of partition search type.
800 sf->disable_split_var_thresh = 0;
801 sf->disable_filter_search_var_thresh = 16;
802
803 sf->intra_y_mode_mask = INTRA_DC_TM_H_V;
804 sf->intra_uv_mode_mask = INTRA_DC_TM_H_V;
795 } 805 }
796 if (speed == 2) { 806 if (speed == 2) {
797 sf->adjust_thresholds_by_speed = 1; 807 sf->adjust_thresholds_by_speed = 1;
798 sf->less_rectangular_check = 1; 808 sf->less_rectangular_check = 1;
799 sf->use_square_partition_only = 1; 809 sf->use_square_partition_only = 1;
800 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES; 810 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
801 sf->use_lastframe_partitioning = 1; 811 sf->use_lastframe_partitioning = 1;
802 sf->adjust_partitioning_from_last_frame = 1; 812 sf->adjust_partitioning_from_last_frame = 1;
803 sf->last_partitioning_redo_frequency = 3; 813 sf->last_partitioning_redo_frequency = 3;
804 sf->unused_mode_skip_lvl = BLOCK_SIZE_SB32X32; 814 sf->unused_mode_skip_lvl = BLOCK_32X32;
805 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 815 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME ||
806 cpi->common.intra_only || 816 cpi->common.intra_only ||
807 cpi->common.show_frame == 0) ? 817 cpi->common.show_frame == 0) ?
808 USE_FULL_RD : 818 USE_FULL_RD :
809 USE_LARGESTALL); 819 USE_LARGESTALL);
810 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 820 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
811 FLAG_SKIP_INTRA_BESTINTER | 821 FLAG_SKIP_INTRA_BESTINTER |
812 FLAG_SKIP_COMP_BESTINTRA | 822 FLAG_SKIP_COMP_BESTINTRA |
813 FLAG_SKIP_COMP_REFMISMATCH; 823 FLAG_SKIP_COMP_REFMISMATCH |
814 sf->last_chroma_intra_mode = DC_PRED; 824 FLAG_SKIP_INTRA_LOWVAR |
825 FLAG_EARLY_TERMINATE;
826 sf->intra_y_mode_mask = INTRA_DC_TM;
827 sf->intra_uv_mode_mask = INTRA_DC_TM;
828 sf->use_uv_intra_rd_estimate = 1;
815 sf->use_rd_breakout = 1; 829 sf->use_rd_breakout = 1;
816 sf->skip_encode_sb = 1; 830 sf->skip_encode_sb = 1;
817 sf->use_uv_intra_rd_estimate = 1; 831 sf->use_lp32x32fdct = 1;
818 sf->using_small_partition_info = 1; 832 sf->using_small_partition_info = 0;
819 sf->disable_splitmv = 833 sf->disable_splitmv =
820 (MIN(cpi->common.width, cpi->common.height) >= 720)? 1 : 0; 834 (MIN(cpi->common.width, cpi->common.height) >= 720)? 1 : 0;
821 sf->auto_mv_step_size = 1; 835 sf->auto_mv_step_size = 1;
836 sf->search_method = SQUARE;
837 sf->subpel_iters_per_step = 1;
838 sf->use_fast_lpf_pick = 1;
839 sf->auto_min_max_partition_size = 1;
840 sf->auto_min_max_partition_interval = 2;
841 sf->disable_split_var_thresh = 32;
842 sf->disable_filter_search_var_thresh = 32;
822 } 843 }
823 if (speed == 3) { 844 if (speed == 3) {
824 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES; 845 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
825 sf->partition_by_variance = 1; 846 sf->partition_by_variance = 1;
826 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 847 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME ||
827 cpi->common.intra_only || 848 cpi->common.intra_only ||
828 cpi->common.show_frame == 0) ? 849 cpi->common.show_frame == 0) ?
829 USE_FULL_RD : 850 USE_FULL_RD :
830 USE_LARGESTALL); 851 USE_LARGESTALL);
831 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 852 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
832 FLAG_SKIP_INTRA_BESTINTER | 853 FLAG_SKIP_INTRA_BESTINTER |
833 FLAG_SKIP_COMP_BESTINTRA | 854 FLAG_SKIP_COMP_BESTINTRA |
834 FLAG_SKIP_COMP_REFMISMATCH; 855 FLAG_SKIP_COMP_REFMISMATCH |
856 FLAG_SKIP_INTRA_LOWVAR |
857 FLAG_EARLY_TERMINATE;
835 sf->use_rd_breakout = 1; 858 sf->use_rd_breakout = 1;
836 sf->skip_encode_sb = 1; 859 sf->skip_encode_sb = 1;
860 sf->use_lp32x32fdct = 1;
837 sf->disable_splitmv = 1; 861 sf->disable_splitmv = 1;
838 sf->auto_mv_step_size = 1; 862 sf->auto_mv_step_size = 1;
863 sf->search_method = BIGDIA;
864 sf->subpel_iters_per_step = 1;
865 sf->disable_split_var_thresh = 64;
866 sf->disable_filter_search_var_thresh = 64;
867 sf->intra_y_mode_mask = INTRA_DC_ONLY;
868 sf->intra_uv_mode_mask = INTRA_DC_ONLY;
839 } 869 }
840 if (speed == 4) { 870 if (speed == 4) {
841 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES; 871 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
842 sf->use_one_partition_size_always = 1; 872 sf->use_one_partition_size_always = 1;
843 sf->always_this_block_size = BLOCK_SIZE_MB16X16; 873 sf->always_this_block_size = BLOCK_16X16;
844 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME || 874 sf->tx_size_search_method = ((cpi->common.frame_type == KEY_FRAME ||
845 cpi->common.intra_only || 875 cpi->common.intra_only ||
846 cpi->common.show_frame == 0) ? 876 cpi->common.show_frame == 0) ?
847 USE_FULL_RD : 877 USE_FULL_RD :
848 USE_LARGESTALL); 878 USE_LARGESTALL);
849 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | 879 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
850 FLAG_SKIP_INTRA_BESTINTER | 880 FLAG_SKIP_INTRA_BESTINTER |
851 FLAG_SKIP_COMP_BESTINTRA | 881 FLAG_SKIP_COMP_BESTINTRA |
852 FLAG_SKIP_COMP_REFMISMATCH; 882 FLAG_SKIP_COMP_REFMISMATCH |
883 FLAG_SKIP_INTRA_LOWVAR |
884 FLAG_EARLY_TERMINATE;
853 sf->use_rd_breakout = 1; 885 sf->use_rd_breakout = 1;
886 sf->use_lp32x32fdct = 1;
854 sf->optimize_coefficients = 0; 887 sf->optimize_coefficients = 0;
855 sf->auto_mv_step_size = 1; 888 sf->auto_mv_step_size = 1;
856 // sf->reduce_first_step_size = 1; 889 // sf->reduce_first_step_size = 1;
857 // sf->reference_masking = 1; 890 // sf->reference_masking = 1;
858 891
859 sf->disable_splitmv = 1; 892 sf->disable_splitmv = 1;
893 sf->search_method = HEX;
894 sf->subpel_iters_per_step = 1;
895 sf->disable_split_var_thresh = 64;
896 sf->disable_filter_search_var_thresh = 96;
860 } 897 }
861 /* 898 /*
862 if (speed == 2) { 899 if (speed == 2) {
863 sf->first_step = 0; 900 sf->first_step = 0;
864 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; 901 sf->comp_inter_joint_search_thresh = BLOCK_8X8;
865 sf->use_partitions_less_than = 1; 902 sf->max_partition_size = BLOCK_16X16;
866 sf->less_than_block_size = BLOCK_SIZE_MB16X16;
867 } 903 }
868 if (speed == 3) { 904 if (speed == 3) {
869 sf->first_step = 0; 905 sf->first_step = 0;
870 sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; 906 sf->comp_inter_joint_search_thresh = BLOCK_B8X8;
871 sf->use_partitions_greater_than = 1; 907 sf->min_partition_size = BLOCK_8X8;
872 sf->greater_than_block_size = BLOCK_SIZE_SB8X8;
873 } 908 }
874 */ 909 */
875 910
876 break; 911 break;
877 912
878 }; /* switch */ 913 }; /* switch */
879 914
880 // Set rd thresholds based on mode and speed setting 915 // Set rd thresholds based on mode and speed setting
881 if (cpi->sf.adjust_thresholds_by_speed) 916 if (cpi->sf.adjust_thresholds_by_speed)
882 set_rd_speed_thresholds(cpi, mode, speed); 917 set_rd_speed_thresholds(cpi, mode, speed);
(...skipping 10 matching lines...) Expand all
893 cpi->mb.fwd_txm8x8 = vp9_short_fdct8x8; 928 cpi->mb.fwd_txm8x8 = vp9_short_fdct8x8;
894 cpi->mb.fwd_txm8x4 = vp9_short_fdct8x4; 929 cpi->mb.fwd_txm8x4 = vp9_short_fdct8x4;
895 cpi->mb.fwd_txm4x4 = vp9_short_fdct4x4; 930 cpi->mb.fwd_txm4x4 = vp9_short_fdct4x4;
896 if (cpi->oxcf.lossless || cpi->mb.e_mbd.lossless) { 931 if (cpi->oxcf.lossless || cpi->mb.e_mbd.lossless) {
897 cpi->mb.fwd_txm8x4 = vp9_short_walsh8x4; 932 cpi->mb.fwd_txm8x4 = vp9_short_walsh8x4;
898 cpi->mb.fwd_txm4x4 = vp9_short_walsh4x4; 933 cpi->mb.fwd_txm4x4 = vp9_short_walsh4x4;
899 } 934 }
900 935
901 cpi->mb.quantize_b_4x4 = vp9_regular_quantize_b_4x4; 936 cpi->mb.quantize_b_4x4 = vp9_regular_quantize_b_4x4;
902 937
903 if (cpi->sf.iterative_sub_pixel == 1) { 938 if (cpi->sf.subpel_search_method == SUBPEL_ITERATIVE) {
904 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_step_iteratively; 939 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_iterative;
905 } else if (cpi->sf.quarter_pixel_search) { 940 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_iterative;
906 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_step; 941 } else if (cpi->sf.subpel_search_method == SUBPEL_TREE) {
907 } else if (cpi->sf.half_pixel_search) { 942 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree;
908 cpi->find_fractional_mv_step = vp9_find_best_half_pixel_step; 943 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree;
909 } 944 }
910 945
911 cpi->mb.optimize = cpi->sf.optimize_coefficients == 1 && cpi->pass != 1; 946 cpi->mb.optimize = cpi->sf.optimize_coefficients == 1 && cpi->pass != 1;
912 947
913 #ifdef SPEEDSTATS 948 #ifdef SPEEDSTATS
914 frames_at_speed[cpi->speed]++; 949 frames_at_speed[cpi->speed]++;
915 #endif 950 #endif
916 } 951 }
917 952
918 static void alloc_raw_frame_buffers(VP9_COMP *cpi) { 953 static void alloc_raw_frame_buffers(VP9_COMP *cpi) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1240
1206 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG; 1241 cpi->ref_frame_flags = VP9_ALT_FLAG | VP9_GOLD_FLAG | VP9_LAST_FLAG;
1207 1242
1208 // cpi->use_golden_frame_only = 0; 1243 // cpi->use_golden_frame_only = 0;
1209 // cpi->use_last_frame_only = 0; 1244 // cpi->use_last_frame_only = 0;
1210 cpi->refresh_golden_frame = 0; 1245 cpi->refresh_golden_frame = 0;
1211 cpi->refresh_last_frame = 1; 1246 cpi->refresh_last_frame = 1;
1212 cm->refresh_frame_context = 1; 1247 cm->refresh_frame_context = 1;
1213 cm->reset_frame_context = 0; 1248 cm->reset_frame_context = 0;
1214 1249
1215 setup_features(cpi); 1250 setup_features(cm);
1216 cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptatio n 1251 cpi->mb.e_mbd.allow_high_precision_mv = 0; // Default mv precision adaptatio n
1217 set_mvcost(&cpi->mb); 1252 set_mvcost(&cpi->mb);
1218 1253
1219 { 1254 {
1220 int i; 1255 int i;
1221 1256
1222 for (i = 0; i < MAX_SEGMENTS; i++) 1257 for (i = 0; i < MAX_SEGMENTS; i++)
1223 cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout; 1258 cpi->segment_encode_breakout[i] = cpi->oxcf.encode_breakout;
1224 } 1259 }
1225 1260
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 cm->mcomp_filter_type = DEFAULT_INTERP_FILTER; 1310 cm->mcomp_filter_type = DEFAULT_INTERP_FILTER;
1276 1311
1277 cpi->target_bandwidth = cpi->oxcf.target_bandwidth; 1312 cpi->target_bandwidth = cpi->oxcf.target_bandwidth;
1278 1313
1279 cm->display_width = cpi->oxcf.width; 1314 cm->display_width = cpi->oxcf.width;
1280 cm->display_height = cpi->oxcf.height; 1315 cm->display_height = cpi->oxcf.height;
1281 1316
1282 // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs) 1317 // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
1283 cpi->oxcf.Sharpness = MIN(7, cpi->oxcf.Sharpness); 1318 cpi->oxcf.Sharpness = MIN(7, cpi->oxcf.Sharpness);
1284 1319
1285 cpi->mb.e_mbd.lf.sharpness_level = cpi->oxcf.Sharpness; 1320 cpi->common.lf.sharpness_level = cpi->oxcf.Sharpness;
1286 1321
1287 if (cpi->initial_width) { 1322 if (cpi->initial_width) {
1288 // Increasing the size of the frame beyond the first seen frame, or some 1323 // Increasing the size of the frame beyond the first seen frame, or some
1289 // otherwise signalled maximum size, is not supported. 1324 // otherwise signalled maximum size, is not supported.
1290 // TODO(jkoleszar): exit gracefully. 1325 // TODO(jkoleszar): exit gracefully.
1291 assert(cm->width <= cpi->initial_width); 1326 assert(cm->width <= cpi->initial_width);
1292 assert(cm->height <= cpi->initial_height); 1327 assert(cm->height <= cpi->initial_height);
1293 } 1328 }
1294 update_frame_size(cpi); 1329 update_frame_size(cpi);
1295 1330
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 do { 1395 do {
1361 double z = 256 * (2 * (log2f(8 * i) + .6)); 1396 double z = 256 * (2 * (log2f(8 * i) + .6));
1362 mvsadcost[0][i] = (int)z; 1397 mvsadcost[0][i] = (int)z;
1363 mvsadcost[1][i] = (int)z; 1398 mvsadcost[1][i] = (int)z;
1364 mvsadcost[0][-i] = (int)z; 1399 mvsadcost[0][-i] = (int)z;
1365 mvsadcost[1][-i] = (int)z; 1400 mvsadcost[1][-i] = (int)z;
1366 } while (++i <= MV_MAX); 1401 } while (++i <= MV_MAX);
1367 } 1402 }
1368 1403
1369 VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) { 1404 VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
1370 int i; 1405 int i, j;
1371 volatile union { 1406 volatile union {
1372 VP9_COMP *cpi; 1407 VP9_COMP *cpi;
1373 VP9_PTR ptr; 1408 VP9_PTR ptr;
1374 } ctx; 1409 } ctx;
1375 1410
1376 VP9_COMP *cpi; 1411 VP9_COMP *cpi;
1377 VP9_COMMON *cm; 1412 VP9_COMMON *cm;
1378 1413
1379 cpi = ctx.cpi = vpx_memalign(32, sizeof(VP9_COMP)); 1414 cpi = ctx.cpi = vpx_memalign(32, sizeof(VP9_COMP));
1380 // Check that the CPI instance is valid 1415 // Check that the CPI instance is valid
1381 if (!cpi) 1416 if (!cpi)
1382 return 0; 1417 return 0;
1383 1418
1384 cm = &cpi->common; 1419 cm = &cpi->common;
1385 1420
1386 vpx_memset(cpi, 0, sizeof(VP9_COMP)); 1421 vp9_zero(*cpi);
1387 1422
1388 if (setjmp(cm->error.jmp)) { 1423 if (setjmp(cm->error.jmp)) {
1389 VP9_PTR ptr = ctx.ptr; 1424 VP9_PTR ptr = ctx.ptr;
1390 1425
1391 ctx.cpi->common.error.setjmp = 0; 1426 ctx.cpi->common.error.setjmp = 0;
1392 vp9_remove_compressor(&ptr); 1427 vp9_remove_compressor(&ptr);
1393 return 0; 1428 return 0;
1394 } 1429 }
1395 1430
1396 cm->error.setjmp = 1; 1431 cm->error.setjmp = 1;
(...skipping 18 matching lines...) Expand all
1415 cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL; 1450 cpi->baseline_gf_interval = DEFAULT_GF_INTERVAL;
1416 1451
1417 cpi->gold_is_last = 0; 1452 cpi->gold_is_last = 0;
1418 cpi->alt_is_last = 0; 1453 cpi->alt_is_last = 0;
1419 cpi->gold_is_alt = 0; 1454 cpi->gold_is_alt = 0;
1420 1455
1421 // Create the encoder segmentation map and set all entries to 0 1456 // Create the encoder segmentation map and set all entries to 0
1422 CHECK_MEM_ERROR(cm, cpi->segmentation_map, 1457 CHECK_MEM_ERROR(cm, cpi->segmentation_map,
1423 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); 1458 vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
1424 1459
1425 // And a copy in common for temporal coding
1426 CHECK_MEM_ERROR(cm, cm->last_frame_seg_map,
1427 vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
1428
1429 // And a place holder structure is the coding context 1460 // And a place holder structure is the coding context
1430 // for use if we want to save and restore it 1461 // for use if we want to save and restore it
1431 CHECK_MEM_ERROR(cm, cpi->coding_context.last_frame_seg_map_copy, 1462 CHECK_MEM_ERROR(cm, cpi->coding_context.last_frame_seg_map_copy,
1432 vpx_calloc(cm->mi_rows * cm->mi_cols, 1)); 1463 vpx_calloc(cm->mi_rows * cm->mi_cols, 1));
1433 1464
1434 CHECK_MEM_ERROR(cm, cpi->active_map, vpx_calloc(cm->MBs, 1)); 1465 CHECK_MEM_ERROR(cm, cpi->active_map, vpx_calloc(cm->MBs, 1));
1435 vpx_memset(cpi->active_map, 1, cm->MBs); 1466 vpx_memset(cpi->active_map, 1, cm->MBs);
1436 cpi->active_map_enabled = 0; 1467 cpi->active_map_enabled = 0;
1437 1468
1438 for (i = 0; i < (sizeof(cpi->mbgraph_stats) / 1469 for (i = 0; i < (sizeof(cpi->mbgraph_stats) /
1439 sizeof(cpi->mbgraph_stats[0])); i++) { 1470 sizeof(cpi->mbgraph_stats[0])); i++) {
1440 CHECK_MEM_ERROR(cm, cpi->mbgraph_stats[i].mb_stats, 1471 CHECK_MEM_ERROR(cm, cpi->mbgraph_stats[i].mb_stats,
1441 vpx_calloc(cm->MBs * 1472 vpx_calloc(cm->MBs *
1442 sizeof(*cpi->mbgraph_stats[i].mb_stats), 1)); 1473 sizeof(*cpi->mbgraph_stats[i].mb_stats), 1));
1443 } 1474 }
1444 1475
1445 #ifdef ENTROPY_STATS 1476 #ifdef ENTROPY_STATS
1446 if (cpi->pass != 1) 1477 if (cpi->pass != 1)
1447 init_context_counters(); 1478 init_context_counters();
1448 #endif 1479 #endif
1449 1480
1450 #ifdef NMV_STATS
1451 init_nmvstats();
1452 #endif
1453 #ifdef MODE_STATS 1481 #ifdef MODE_STATS
1454 init_tx_count_stats(); 1482 init_tx_count_stats();
1455 init_switchable_interp_stats(); 1483 init_switchable_interp_stats();
1456 #endif 1484 #endif
1457 1485
1458 /*Initialize the feed-forward activity masking.*/ 1486 /*Initialize the feed-forward activity masking.*/
1459 cpi->activity_avg = 90 << 12; 1487 cpi->activity_avg = 90 << 12;
1460 1488
1461 cpi->frames_since_key = 8; // Give a sensible default for the first fra me. 1489 cpi->frames_since_key = 8; // Give a sensible default for the first fra me.
1462 cpi->key_frame_frequency = cpi->oxcf.key_freq; 1490 cpi->key_frame_frequency = cpi->oxcf.key_freq;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 1597
1570 cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf; 1598 cpi->twopass.stats_in_start = oxcf->two_pass_stats_in.buf;
1571 cpi->twopass.stats_in = cpi->twopass.stats_in_start; 1599 cpi->twopass.stats_in = cpi->twopass.stats_in_start;
1572 cpi->twopass.stats_in_end = (void *)((char *)cpi->twopass.stats_in 1600 cpi->twopass.stats_in_end = (void *)((char *)cpi->twopass.stats_in
1573 + (packets - 1) * packet_sz); 1601 + (packets - 1) * packet_sz);
1574 vp9_init_second_pass(cpi); 1602 vp9_init_second_pass(cpi);
1575 } 1603 }
1576 1604
1577 vp9_set_speed_features(cpi); 1605 vp9_set_speed_features(cpi);
1578 1606
1579 // Set starting values of RD threshold multipliers (128 = *1) 1607 // Default rd threshold factors for mode selection
1580 for (i = 0; i < MAX_MODES; i++) 1608 for (i = 0; i < BLOCK_SIZES; ++i)
1581 cpi->rd_thresh_mult[i] = 128; 1609 for (j = 0; j < MAX_MODES; ++j)
1610 cpi->rd_thresh_freq_fact[i][j] = 32;
1582 1611
1583 #define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SVFHH, SVFHV, SVFHHV, \ 1612 #define BFP(BT, SDF, SDAF, VF, SVF, SVAF, SVFHH, SVFHV, SVFHHV, \
1584 SDX3F, SDX8F, SDX4DF)\ 1613 SDX3F, SDX8F, SDX4DF)\
1585 cpi->fn_ptr[BT].sdf = SDF; \ 1614 cpi->fn_ptr[BT].sdf = SDF; \
1586 cpi->fn_ptr[BT].sdaf = SDAF; \ 1615 cpi->fn_ptr[BT].sdaf = SDAF; \
1587 cpi->fn_ptr[BT].vf = VF; \ 1616 cpi->fn_ptr[BT].vf = VF; \
1588 cpi->fn_ptr[BT].svf = SVF; \ 1617 cpi->fn_ptr[BT].svf = SVF; \
1589 cpi->fn_ptr[BT].svaf = SVAF; \ 1618 cpi->fn_ptr[BT].svaf = SVAF; \
1590 cpi->fn_ptr[BT].svf_halfpix_h = SVFHH; \ 1619 cpi->fn_ptr[BT].svf_halfpix_h = SVFHH; \
1591 cpi->fn_ptr[BT].svf_halfpix_v = SVFHV; \ 1620 cpi->fn_ptr[BT].svf_halfpix_v = SVFHV; \
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 // make sure frame 1 is okay 1707 // make sure frame 1 is okay
1679 cpi->error_bins[0] = cpi->common.MBs; 1708 cpi->error_bins[0] = cpi->common.MBs;
1680 1709
1681 /* vp9_init_quantizer() is first called here. Add check in 1710 /* vp9_init_quantizer() is first called here. Add check in
1682 * vp9_frame_init_quantizer() so that vp9_init_quantizer is only 1711 * vp9_frame_init_quantizer() so that vp9_init_quantizer is only
1683 * called later when needed. This will avoid unnecessary calls of 1712 * called later when needed. This will avoid unnecessary calls of
1684 * vp9_init_quantizer() for every frame. 1713 * vp9_init_quantizer() for every frame.
1685 */ 1714 */
1686 vp9_init_quantizer(cpi); 1715 vp9_init_quantizer(cpi);
1687 1716
1688 vp9_loop_filter_init(cm, &cpi->mb.e_mbd.lf); 1717 vp9_loop_filter_init(cm);
1689 1718
1690 cpi->common.error.setjmp = 0; 1719 cpi->common.error.setjmp = 0;
1691 1720
1692 vp9_zero(cpi->y_uv_mode_count) 1721 vp9_zero(cpi->y_uv_mode_count)
1693 1722
1694 return (VP9_PTR) cpi; 1723 return (VP9_PTR) cpi;
1695 } 1724 }
1696 1725
1697 void vp9_remove_compressor(VP9_PTR *ptr) { 1726 void vp9_remove_compressor(VP9_PTR *ptr) {
1698 VP9_COMP *cpi = (VP9_COMP *)(*ptr); 1727 VP9_COMP *cpi = (VP9_COMP *)(*ptr);
1699 int i; 1728 int i;
1700 1729
1701 if (!cpi) 1730 if (!cpi)
1702 return; 1731 return;
1703 1732
1704 if (cpi && (cpi->common.current_video_frame > 0)) { 1733 if (cpi && (cpi->common.current_video_frame > 0)) {
1705 if (cpi->pass == 2) { 1734 if (cpi->pass == 2) {
1706 vp9_end_second_pass(cpi); 1735 vp9_end_second_pass(cpi);
1707 } 1736 }
1708 1737
1709 #ifdef ENTROPY_STATS 1738 #ifdef ENTROPY_STATS
1710 if (cpi->pass != 1) { 1739 if (cpi->pass != 1) {
1711 print_context_counters(); 1740 print_context_counters();
1712 print_tree_update_probs(); 1741 print_tree_update_probs();
1713 print_mode_context(cpi); 1742 print_mode_context(cpi);
1714 } 1743 }
1715 #endif 1744 #endif
1716 #ifdef NMV_STATS 1745
1717 if (cpi->pass != 1)
1718 print_nmvstats();
1719 #endif
1720 #ifdef MODE_STATS 1746 #ifdef MODE_STATS
1721 if (cpi->pass != 1) { 1747 if (cpi->pass != 1) {
1722 write_tx_count_stats(); 1748 write_tx_count_stats();
1723 write_switchable_interp_stats(); 1749 write_switchable_interp_stats();
1724 } 1750 }
1725 #endif 1751 #endif
1726 1752
1727 #if CONFIG_INTERNAL_STATS 1753 #if CONFIG_INTERNAL_STATS
1728 1754
1729 vp9_clear_system_state(); 1755 vp9_clear_system_state();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 1801
1776 #endif 1802 #endif
1777 1803
1778 #ifdef ENTROPY_STATS 1804 #ifdef ENTROPY_STATS
1779 { 1805 {
1780 int i, j, k; 1806 int i, j, k;
1781 FILE *fmode = fopen("vp9_modecontext.c", "w"); 1807 FILE *fmode = fopen("vp9_modecontext.c", "w");
1782 1808
1783 fprintf(fmode, "\n#include \"vp9_entropymode.h\"\n\n"); 1809 fprintf(fmode, "\n#include \"vp9_entropymode.h\"\n\n");
1784 fprintf(fmode, "const unsigned int vp9_kf_default_bmode_counts "); 1810 fprintf(fmode, "const unsigned int vp9_kf_default_bmode_counts ");
1785 fprintf(fmode, "[VP9_INTRA_MODES][VP9_INTRA_MODES]" 1811 fprintf(fmode, "[INTRA_MODES][INTRA_MODES]"
1786 "[VP9_INTRA_MODES] =\n{\n"); 1812 "[INTRA_MODES] =\n{\n");
1787 1813
1788 for (i = 0; i < VP9_INTRA_MODES; i++) { 1814 for (i = 0; i < INTRA_MODES; i++) {
1789 1815
1790 fprintf(fmode, " { // Above Mode : %d\n", i); 1816 fprintf(fmode, " { // Above Mode : %d\n", i);
1791 1817
1792 for (j = 0; j < VP9_INTRA_MODES; j++) { 1818 for (j = 0; j < INTRA_MODES; j++) {
1793 1819
1794 fprintf(fmode, " {"); 1820 fprintf(fmode, " {");
1795 1821
1796 for (k = 0; k < VP9_INTRA_MODES; k++) { 1822 for (k = 0; k < INTRA_MODES; k++) {
1797 if (!intra_mode_stats[i][j][k]) 1823 if (!intra_mode_stats[i][j][k])
1798 fprintf(fmode, " %5d, ", 1); 1824 fprintf(fmode, " %5d, ", 1);
1799 else 1825 else
1800 fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]); 1826 fprintf(fmode, " %5d, ", intra_mode_stats[i][j][k]);
1801 } 1827 }
1802 1828
1803 fprintf(fmode, "}, // left_mode %d\n", j); 1829 fprintf(fmode, "}, // left_mode %d\n", j);
1804 1830
1805 } 1831 }
1806 1832
(...skipping 19 matching lines...) Expand all
1826 fprintf(f, "\n"); 1852 fprintf(f, "\n");
1827 fclose(f); 1853 fclose(f);
1828 } 1854 }
1829 1855
1830 #endif 1856 #endif
1831 1857
1832 #if 0 1858 #if 0
1833 { 1859 {
1834 printf("\n_pick_loop_filter_level:%d\n", cpi->time_pick_lpf / 1000); 1860 printf("\n_pick_loop_filter_level:%d\n", cpi->time_pick_lpf / 1000);
1835 printf("\n_frames recive_data encod_mb_row compress_frame Total\n"); 1861 printf("\n_frames recive_data encod_mb_row compress_frame Total\n");
1836 printf("%6d %10ld %10ld %10ld %10ld\n", cpi->common.current_video_frame, c pi->time_receive_data / 1000, cpi->time_encode_mb_row / 1000, cpi->time_compress _data / 1000, (cpi->time_receive_data + cpi->time_compress_data) / 1000); 1862 printf("%6d %10ld %10ld %10ld %10ld\n", cpi->common.current_video_frame,
1863 cpi->time_receive_data / 1000, cpi->time_encode_sb_row / 1000,
1864 cpi->time_compress_data / 1000,
1865 (cpi->time_receive_data + cpi->time_compress_data) / 1000);
1837 } 1866 }
1838 #endif 1867 #endif
1839 1868
1840 } 1869 }
1841 1870
1842 dealloc_compressor_data(cpi); 1871 dealloc_compressor_data(cpi);
1843 vpx_free(cpi->mb.ss); 1872 vpx_free(cpi->mb.ss);
1844 vpx_free(cpi->tok); 1873 vpx_free(cpi->tok);
1845 1874
1846 for (i = 0; i < sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0]); i+ +) { 1875 for (i = 0; i < sizeof(cpi->mbgraph_stats) / sizeof(cpi->mbgraph_stats[0]); i+ +) {
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2399 } 2428 }
2400 2429
2401 if (cpi->refresh_last_frame) { 2430 if (cpi->refresh_last_frame) {
2402 ref_cnt_fb(cm->fb_idx_ref_cnt, 2431 ref_cnt_fb(cm->fb_idx_ref_cnt,
2403 &cm->ref_frame_map[cpi->lst_fb_idx], cm->new_fb_idx); 2432 &cm->ref_frame_map[cpi->lst_fb_idx], cm->new_fb_idx);
2404 } 2433 }
2405 } 2434 }
2406 2435
2407 static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { 2436 static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
2408 MACROBLOCKD *xd = &cpi->mb.e_mbd; 2437 MACROBLOCKD *xd = &cpi->mb.e_mbd;
2438 struct loopfilter *lf = &cm->lf;
2409 if (xd->lossless) { 2439 if (xd->lossless) {
2410 xd->lf.filter_level = 0; 2440 lf->filter_level = 0;
2411 } else { 2441 } else {
2412 struct vpx_usec_timer timer; 2442 struct vpx_usec_timer timer;
2413 2443
2414 vp9_clear_system_state(); 2444 vp9_clear_system_state();
2415 2445
2416 vpx_usec_timer_start(&timer); 2446 vpx_usec_timer_start(&timer);
2417 2447
2418 vp9_pick_filter_level(cpi->Source, cpi); 2448 vp9_pick_filter_level(cpi->Source, cpi, cpi->sf.use_fast_lpf_pick);
2419 2449
2420 vpx_usec_timer_mark(&timer); 2450 vpx_usec_timer_mark(&timer);
2421 cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); 2451 cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
2422 } 2452 }
2423 2453
2424 if (xd->lf.filter_level > 0) { 2454 if (lf->filter_level > 0) {
2425 vp9_set_alt_lf_level(cpi, xd->lf.filter_level); 2455 vp9_set_alt_lf_level(cpi, lf->filter_level);
2426 vp9_loop_filter_frame(cm, xd, xd->lf.filter_level, 0); 2456 vp9_loop_filter_frame(cm, xd, lf->filter_level, 0, 0);
2427 } 2457 }
2428 2458
2429 vp9_extend_frame_inner_borders(cm->frame_to_show, 2459 vp9_extend_frame_inner_borders(cm->frame_to_show,
2430 cm->subsampling_x, cm->subsampling_y); 2460 cm->subsampling_x, cm->subsampling_y);
2431 } 2461 }
2432 2462
2433 static void scale_references(VP9_COMP *cpi) { 2463 static void scale_references(VP9_COMP *cpi) {
2434 VP9_COMMON *cm = &cpi->common; 2464 VP9_COMMON *cm = &cpi->common;
2435 int i; 2465 int i;
2436 2466
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 2536
2507 int top_index; 2537 int top_index;
2508 int bottom_index; 2538 int bottom_index;
2509 int active_worst_qchanged = 0; 2539 int active_worst_qchanged = 0;
2510 2540
2511 int overshoot_seen = 0; 2541 int overshoot_seen = 0;
2512 int undershoot_seen = 0; 2542 int undershoot_seen = 0;
2513 2543
2514 SPEED_FEATURES *sf = &cpi->sf; 2544 SPEED_FEATURES *sf = &cpi->sf;
2515 unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height); 2545 unsigned int max_mv_def = MIN(cpi->common.width, cpi->common.height);
2546 struct segmentation *seg = &cm->seg;
2516 #if RESET_FOREACH_FILTER 2547 #if RESET_FOREACH_FILTER
2517 int q_low0; 2548 int q_low0;
2518 int q_high0; 2549 int q_high0;
2519 int Q0; 2550 int Q0;
2520 int active_best_quality0; 2551 int active_best_quality0;
2521 int active_worst_quality0; 2552 int active_worst_quality0;
2522 double rate_correction_factor0; 2553 double rate_correction_factor0;
2523 double gf_rate_correction_factor0; 2554 double gf_rate_correction_factor0;
2524 #endif 2555 #endif
2525 2556
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2576 // Check to see if a key frame is signaled 2607 // Check to see if a key frame is signaled
2577 // For two pass with auto key frame enabled cm->frame_type may already be set, but not for one pass. 2608 // For two pass with auto key frame enabled cm->frame_type may already be set, but not for one pass.
2578 if ((cm->current_video_frame == 0) || 2609 if ((cm->current_video_frame == 0) ||
2579 (cm->frame_flags & FRAMEFLAGS_KEY) || 2610 (cm->frame_flags & FRAMEFLAGS_KEY) ||
2580 (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency = = 0))) { 2611 (cpi->oxcf.auto_key && (cpi->frames_since_key % cpi->key_frame_frequency = = 0))) {
2581 // Key frame from VFW/auto-keyframe/first frame 2612 // Key frame from VFW/auto-keyframe/first frame
2582 cm->frame_type = KEY_FRAME; 2613 cm->frame_type = KEY_FRAME;
2583 } 2614 }
2584 2615
2585 // Set default state for segment based loop filter update flags 2616 // Set default state for segment based loop filter update flags
2586 xd->lf.mode_ref_delta_update = 0; 2617 cm->lf.mode_ref_delta_update = 0;
2587 2618
2588 // Initialize cpi->mv_step_param to default based on max resolution 2619 // Initialize cpi->mv_step_param to default based on max resolution
2589 cpi->mv_step_param = vp9_init_search_range(cpi, max_mv_def); 2620 cpi->mv_step_param = vp9_init_search_range(cpi, max_mv_def);
2590 // Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate. 2621 // Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate.
2591 if (sf->auto_mv_step_size) { 2622 if (sf->auto_mv_step_size) {
2592 if ((cpi->common.frame_type == KEY_FRAME) || cpi->common.intra_only) { 2623 if ((cpi->common.frame_type == KEY_FRAME) || cpi->common.intra_only) {
2593 // initialize max_mv_magnitude for use in the first INTER frame 2624 // initialize max_mv_magnitude for use in the first INTER frame
2594 // after a key/intra-only frame 2625 // after a key/intra-only frame
2595 cpi->max_mv_magnitude = max_mv_def; 2626 cpi->max_mv_magnitude = max_mv_def;
2596 } else { 2627 } else {
2597 if (cm->show_frame) 2628 if (cm->show_frame)
2598 // allow mv_steps to correspond to twice the max mv magnitude found 2629 // allow mv_steps to correspond to twice the max mv magnitude found
2599 // in the previous frame, capped by the default max_mv_magnitude based 2630 // in the previous frame, capped by the default max_mv_magnitude based
2600 // on resolution 2631 // on resolution
2601 cpi->mv_step_param = vp9_init_search_range( 2632 cpi->mv_step_param = vp9_init_search_range(
2602 cpi, MIN(max_mv_def, 2 * cpi->max_mv_magnitude)); 2633 cpi, MIN(max_mv_def, 2 * cpi->max_mv_magnitude));
2603 cpi->max_mv_magnitude = 0; 2634 cpi->max_mv_magnitude = 0;
2604 } 2635 }
2605 } 2636 }
2606 2637
2607 // Set various flags etc to special state if it is a key frame 2638 // Set various flags etc to special state if it is a key frame
2608 if (cm->frame_type == KEY_FRAME) { 2639 if (cm->frame_type == KEY_FRAME) {
2609 int i;
2610
2611 // Reset the loop filter deltas and segmentation map 2640 // Reset the loop filter deltas and segmentation map
2612 setup_features(cpi); 2641 setup_features(cm);
2613 2642
2614 // If segmentation is enabled force a map update for key frames 2643 // If segmentation is enabled force a map update for key frames
2615 if (xd->seg.enabled) { 2644 if (seg->enabled) {
2616 xd->seg.update_map = 1; 2645 seg->update_map = 1;
2617 xd->seg.update_data = 1; 2646 seg->update_data = 1;
2618 } 2647 }
2619 2648
2620 // The alternate reference frame cannot be active for a key frame 2649 // The alternate reference frame cannot be active for a key frame
2621 cpi->source_alt_ref_active = 0; 2650 cpi->source_alt_ref_active = 0;
2622 2651
2623 // Reset the RD threshold multipliers to default of * 1 (128)
2624 for (i = 0; i < MAX_MODES; i++)
2625 cpi->rd_thresh_mult[i] = 128;
2626
2627 cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0); 2652 cm->error_resilient_mode = (cpi->oxcf.error_resilient_mode != 0);
2628 cm->frame_parallel_decoding_mode = 2653 cm->frame_parallel_decoding_mode =
2629 (cpi->oxcf.frame_parallel_decoding_mode != 0); 2654 (cpi->oxcf.frame_parallel_decoding_mode != 0);
2630 if (cm->error_resilient_mode) { 2655 if (cm->error_resilient_mode) {
2631 cm->frame_parallel_decoding_mode = 1; 2656 cm->frame_parallel_decoding_mode = 1;
2632 cm->reset_frame_context = 0; 2657 cm->reset_frame_context = 0;
2633 cm->refresh_frame_context = 0; 2658 cm->refresh_frame_context = 0;
2634 } 2659 }
2635 } 2660 }
2636 2661
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 #endif 2836 #endif
2812 // Limit Q range for the adaptive loop. 2837 // Limit Q range for the adaptive loop.
2813 bottom_index = cpi->active_best_quality; 2838 bottom_index = cpi->active_best_quality;
2814 top_index = cpi->active_worst_quality; 2839 top_index = cpi->active_worst_quality;
2815 q_low = cpi->active_best_quality; 2840 q_low = cpi->active_best_quality;
2816 q_high = cpi->active_worst_quality; 2841 q_high = cpi->active_worst_quality;
2817 #if CONFIG_MULTIPLE_ARF 2842 #if CONFIG_MULTIPLE_ARF
2818 } 2843 }
2819 #endif 2844 #endif
2820 loop_count = 0; 2845 loop_count = 0;
2821 vpx_memset(cpi->rd_tx_select_threshes, 0, sizeof(cpi->rd_tx_select_threshes)); 2846 vp9_zero(cpi->rd_tx_select_threshes);
2822 2847
2823 if (cm->frame_type != KEY_FRAME) { 2848 if (cm->frame_type != KEY_FRAME) {
2824 /* TODO: Decide this more intelligently */ 2849 /* TODO: Decide this more intelligently */
2825 if (sf->search_best_filter) { 2850 if (sf->search_best_filter) {
2826 cm->mcomp_filter_type = mcomp_filters_to_search[0]; 2851 cm->mcomp_filter_type = mcomp_filters_to_search[0];
2827 mcomp_filter_index = 0; 2852 mcomp_filter_index = 0;
2828 } else { 2853 } else {
2829 cm->mcomp_filter_type = DEFAULT_INTERP_FILTER; 2854 cm->mcomp_filter_type = DEFAULT_INTERP_FILTER;
2830 } 2855 }
2831 /* TODO: Decide this more intelligently */ 2856 /* TODO: Decide this more intelligently */
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3138 cm->current_video_frame + 2000); 3163 cm->current_video_frame + 2000);
3139 else 3164 else
3140 write_cx_frame_to_file(cm->frame_to_show, 3165 write_cx_frame_to_file(cm->frame_to_show,
3141 cm->current_video_frame + 3000); 3166 cm->current_video_frame + 3000);
3142 #endif 3167 #endif
3143 3168
3144 // build the bitstream 3169 // build the bitstream
3145 cpi->dummy_packing = 0; 3170 cpi->dummy_packing = 0;
3146 vp9_pack_bitstream(cpi, dest, size); 3171 vp9_pack_bitstream(cpi, dest, size);
3147 3172
3148 if (xd->seg.update_map) 3173 if (cm->seg.update_map)
3149 update_reference_segmentation_map(cpi); 3174 update_reference_segmentation_map(cpi);
3150 3175
3151 release_scaled_references(cpi); 3176 release_scaled_references(cpi);
3152 update_reference_frames(cpi); 3177 update_reference_frames(cpi);
3153 3178
3154 for (t = TX_4X4; t <= TX_32X32; t++) 3179 for (t = TX_4X4; t <= TX_32X32; t++)
3155 full_to_model_counts(cpi->common.counts.coef[t], 3180 full_to_model_counts(cpi->common.counts.coef[t],
3156 cpi->coef_counts[t]); 3181 cpi->coef_counts[t]);
3157 if (!cpi->common.error_resilient_mode && 3182 if (!cpi->common.error_resilient_mode &&
3158 !cpi->common.frame_parallel_decoding_mode) { 3183 !cpi->common.frame_parallel_decoding_mode) {
3159 vp9_adapt_coef_probs(&cpi->common); 3184 vp9_adapt_coef_probs(&cpi->common);
3160 } 3185 }
3161 3186
3162 if (cpi->common.frame_type != KEY_FRAME) { 3187 if (cpi->common.frame_type != KEY_FRAME) {
3163 FRAME_COUNTS *counts = &cpi->common.counts; 3188 FRAME_COUNTS *counts = &cpi->common.counts;
3164 3189
3165 vp9_copy(counts->y_mode, cpi->y_mode_count); 3190 vp9_copy(counts->y_mode, cpi->y_mode_count);
3166 vp9_copy(counts->uv_mode, cpi->y_uv_mode_count); 3191 vp9_copy(counts->uv_mode, cpi->y_uv_mode_count);
3167 vp9_copy(counts->partition, cpi->partition_count); 3192 vp9_copy(counts->partition, cpi->partition_count);
3168 vp9_copy(counts->intra_inter, cpi->intra_inter_count); 3193 vp9_copy(counts->intra_inter, cpi->intra_inter_count);
3169 vp9_copy(counts->comp_inter, cpi->comp_inter_count); 3194 vp9_copy(counts->comp_inter, cpi->comp_inter_count);
3170 vp9_copy(counts->single_ref, cpi->single_ref_count); 3195 vp9_copy(counts->single_ref, cpi->single_ref_count);
3171 vp9_copy(counts->comp_ref, cpi->comp_ref_count); 3196 vp9_copy(counts->comp_ref, cpi->comp_ref_count);
3172 counts->mv = cpi->NMVcount; 3197 counts->mv = cpi->NMVcount;
3173 if (!cpi->common.error_resilient_mode && 3198 if (!cpi->common.error_resilient_mode &&
3174 !cpi->common.frame_parallel_decoding_mode) { 3199 !cpi->common.frame_parallel_decoding_mode) {
3175 vp9_adapt_mode_probs(&cpi->common); 3200 vp9_adapt_mode_probs(&cpi->common);
3176 vp9_adapt_mode_context(&cpi->common);
3177 vp9_adapt_mv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv); 3201 vp9_adapt_mv_probs(&cpi->common, cpi->mb.e_mbd.allow_high_precision_mv);
3178 } 3202 }
3179 } 3203 }
3180 3204
3181 #ifdef ENTROPY_STATS 3205 #ifdef ENTROPY_STATS
3182 vp9_update_mode_context_stats(cpi); 3206 vp9_update_mode_context_stats(cpi);
3183 #endif 3207 #endif
3184 3208
3185 /* Move storing frame_type out of the above loop since it is also 3209 /* Move storing frame_type out of the above loop since it is also
3186 * needed in motion search besides loopfilter */ 3210 * needed in motion search besides loopfilter */
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
3447 cpi->frame_coding_order_period = cpi->new_frame_coding_order_period; 3471 cpi->frame_coding_order_period = cpi->new_frame_coding_order_period;
3448 cpi->new_frame_coding_order_period = -1; 3472 cpi->new_frame_coding_order_period = -1;
3449 } 3473 }
3450 cpi->this_frame_weight = cpi->arf_weight[cpi->sequence_number]; 3474 cpi->this_frame_weight = cpi->arf_weight[cpi->sequence_number];
3451 assert(cpi->this_frame_weight >= 0); 3475 assert(cpi->this_frame_weight >= 0);
3452 } 3476 }
3453 #endif 3477 #endif
3454 } 3478 }
3455 3479
3456 // Clear the one shot update flags for segmentation map and mode/ref loop filt er deltas. 3480 // Clear the one shot update flags for segmentation map and mode/ref loop filt er deltas.
3457 xd->seg.update_map = 0; 3481 cm->seg.update_map = 0;
3458 xd->seg.update_data = 0; 3482 cm->seg.update_data = 0;
3459 xd->lf.mode_ref_delta_update = 0; 3483 cm->lf.mode_ref_delta_update = 0;
3460 3484
3461 // keep track of the last coded dimensions 3485 // keep track of the last coded dimensions
3462 cm->last_width = cm->width; 3486 cm->last_width = cm->width;
3463 cm->last_height = cm->height; 3487 cm->last_height = cm->height;
3464 3488
3465 // reset to normal state now that we are done. 3489 // reset to normal state now that we are done.
3466 cm->last_show_frame = cm->show_frame; 3490 cm->last_show_frame = cm->show_frame;
3467 if (cm->show_frame) { 3491 if (cm->show_frame) {
3468 // current mip will be the prev_mip for the next frame 3492 // current mip will be the prev_mip for the next frame
3469 MODE_INFO *temp = cm->prev_mip; 3493 MODE_INFO *temp = cm->prev_mip;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3549 res = -1; 3573 res = -1;
3550 vpx_usec_timer_mark(&timer); 3574 vpx_usec_timer_mark(&timer);
3551 cpi->time_receive_data += vpx_usec_timer_elapsed(&timer); 3575 cpi->time_receive_data += vpx_usec_timer_elapsed(&timer);
3552 3576
3553 return res; 3577 return res;
3554 } 3578 }
3555 3579
3556 3580
3557 static int frame_is_reference(const VP9_COMP *cpi) { 3581 static int frame_is_reference(const VP9_COMP *cpi) {
3558 const VP9_COMMON *cm = &cpi->common; 3582 const VP9_COMMON *cm = &cpi->common;
3559 const MACROBLOCKD *mb = &cpi->mb.e_mbd;
3560 3583
3561 return cm->frame_type == KEY_FRAME || 3584 return cm->frame_type == KEY_FRAME ||
3562 cpi->refresh_last_frame || 3585 cpi->refresh_last_frame ||
3563 cpi->refresh_golden_frame || 3586 cpi->refresh_golden_frame ||
3564 cpi->refresh_alt_ref_frame || 3587 cpi->refresh_alt_ref_frame ||
3565 cm->refresh_frame_context || 3588 cm->refresh_frame_context ||
3566 mb->lf.mode_ref_delta_update || 3589 cm->lf.mode_ref_delta_update ||
3567 mb->seg.update_map || 3590 cm->seg.update_map ||
3568 mb->seg.update_data; 3591 cm->seg.update_data;
3569 } 3592 }
3570 3593
3571 #if CONFIG_MULTIPLE_ARF 3594 #if CONFIG_MULTIPLE_ARF
3572 int is_next_frame_arf(VP9_COMP *cpi) { 3595 int is_next_frame_arf(VP9_COMP *cpi) {
3573 // Negative entry in frame_coding_order indicates an ARF at this position. 3596 // Negative entry in frame_coding_order indicates an ARF at this position.
3574 return cpi->frame_coding_order[cpi->sequence_number + 1] < 0 ? 1 : 0; 3597 return cpi->frame_coding_order[cpi->sequence_number + 1] < 0 ? 1 : 0;
3575 } 3598 }
3576 #endif 3599 #endif
3577 3600
3578 int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, 3601 int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
3618 #else 3641 #else
3619 cpi->alt_ref_source = cpi->source; 3642 cpi->alt_ref_source = cpi->source;
3620 #endif 3643 #endif
3621 3644
3622 if (cpi->oxcf.arnr_max_frames > 0) { 3645 if (cpi->oxcf.arnr_max_frames > 0) {
3623 // Produce the filtered ARF frame. 3646 // Produce the filtered ARF frame.
3624 // TODO(agrange) merge these two functions. 3647 // TODO(agrange) merge these two functions.
3625 configure_arnr_filter(cpi, cm->current_video_frame + frames_to_arf, 3648 configure_arnr_filter(cpi, cm->current_video_frame + frames_to_arf,
3626 cpi->gfu_boost); 3649 cpi->gfu_boost);
3627 vp9_temporal_filter_prepare(cpi, frames_to_arf); 3650 vp9_temporal_filter_prepare(cpi, frames_to_arf);
3651 vp9_extend_frame_borders(&cpi->alt_ref_buffer,
3652 cm->subsampling_x, cm->subsampling_y);
3628 force_src_buffer = &cpi->alt_ref_buffer; 3653 force_src_buffer = &cpi->alt_ref_buffer;
3629 } 3654 }
3630 3655
3631 cm->show_frame = 0; 3656 cm->show_frame = 0;
3632 cm->intra_only = 0; 3657 cm->intra_only = 0;
3633 cpi->refresh_alt_ref_frame = 1; 3658 cpi->refresh_alt_ref_frame = 1;
3634 cpi->refresh_golden_frame = 0; 3659 cpi->refresh_golden_frame = 0;
3635 cpi->refresh_last_frame = 0; 3660 cpi->refresh_last_frame = 0;
3636 cpi->is_src_frame_alt_ref = 0; 3661 cpi->is_src_frame_alt_ref = 0;
3637 3662
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
3887 cpi->total_y += vp9_mse2psnr(y_samples, 255.0, ye); 3912 cpi->total_y += vp9_mse2psnr(y_samples, 255.0, ye);
3888 cpi->total_u += vp9_mse2psnr(uv_samples, 255.0, ue); 3913 cpi->total_u += vp9_mse2psnr(uv_samples, 255.0, ue);
3889 cpi->total_v += vp9_mse2psnr(uv_samples, 255.0, ve); 3914 cpi->total_v += vp9_mse2psnr(uv_samples, 255.0, ve);
3890 cpi->total_sq_error += sq_error; 3915 cpi->total_sq_error += sq_error;
3891 cpi->total += frame_psnr; 3916 cpi->total += frame_psnr;
3892 { 3917 {
3893 double frame_psnr2, frame_ssim2 = 0; 3918 double frame_psnr2, frame_ssim2 = 0;
3894 double weight = 0; 3919 double weight = 0;
3895 #if CONFIG_POSTPROC 3920 #if CONFIG_POSTPROC
3896 vp9_deblock(cm->frame_to_show, &cm->post_proc_buffer, 3921 vp9_deblock(cm->frame_to_show, &cm->post_proc_buffer,
3897 cpi->mb.e_mbd.lf.filter_level * 10 / 6); 3922 cm->lf.filter_level * 10 / 6);
3898 #endif 3923 #endif
3899 vp9_clear_system_state(); 3924 vp9_clear_system_state();
3900 3925
3901 ye = (double)calc_plane_error(orig->y_buffer, orig->y_stride, 3926 ye = (double)calc_plane_error(orig->y_buffer, orig->y_stride,
3902 pp->y_buffer, pp->y_stride, 3927 pp->y_buffer, pp->y_stride,
3903 orig->y_crop_width, orig->y_crop_height); 3928 orig->y_crop_width, orig->y_crop_height);
3904 3929
3905 ue = (double)calc_plane_error(orig->u_buffer, orig->uv_stride, 3930 ue = (double)calc_plane_error(orig->u_buffer, orig->uv_stride,
3906 pp->u_buffer, pp->uv_stride, 3931 pp->u_buffer, pp->uv_stride,
3907 orig->uv_crop_width, orig->uv_crop_height); 3932 orig->uv_crop_width, orig->uv_crop_height);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3962 3987
3963 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest, 3988 int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest,
3964 vp9_ppflags_t *flags) { 3989 vp9_ppflags_t *flags) {
3965 VP9_COMP *cpi = (VP9_COMP *) comp; 3990 VP9_COMP *cpi = (VP9_COMP *) comp;
3966 3991
3967 if (!cpi->common.show_frame) 3992 if (!cpi->common.show_frame)
3968 return -1; 3993 return -1;
3969 else { 3994 else {
3970 int ret; 3995 int ret;
3971 #if CONFIG_POSTPROC 3996 #if CONFIG_POSTPROC
3972 ret = vp9_post_proc_frame(&cpi->common, &cpi->mb.e_mbd.lf, dest, flags); 3997 ret = vp9_post_proc_frame(&cpi->common, dest, flags);
3973 #else 3998 #else
3974 3999
3975 if (cpi->common.frame_to_show) { 4000 if (cpi->common.frame_to_show) {
3976 *dest = *cpi->common.frame_to_show; 4001 *dest = *cpi->common.frame_to_show;
3977 dest->y_width = cpi->common.width; 4002 dest->y_width = cpi->common.width;
3978 dest->y_height = cpi->common.height; 4003 dest->y_height = cpi->common.height;
3979 dest->uv_height = cpi->common.height / 2; 4004 dest->uv_height = cpi->common.height / 2;
3980 ret = 0; 4005 ret = 0;
3981 } else { 4006 } else {
3982 ret = -1; 4007 ret = -1;
3983 } 4008 }
3984 4009
3985 #endif // !CONFIG_POSTPROC 4010 #endif // !CONFIG_POSTPROC
3986 vp9_clear_system_state(); 4011 vp9_clear_system_state();
3987 return ret; 4012 return ret;
3988 } 4013 }
3989 } 4014 }
3990 4015
3991 int vp9_set_roimap(VP9_PTR comp, unsigned char *map, unsigned int rows, 4016 int vp9_set_roimap(VP9_PTR comp, unsigned char *map, unsigned int rows,
3992 unsigned int cols, int delta_q[MAX_SEGMENTS], 4017 unsigned int cols, int delta_q[MAX_SEGMENTS],
3993 int delta_lf[MAX_SEGMENTS], 4018 int delta_lf[MAX_SEGMENTS],
3994 unsigned int threshold[MAX_SEGMENTS]) { 4019 unsigned int threshold[MAX_SEGMENTS]) {
3995 VP9_COMP *cpi = (VP9_COMP *) comp; 4020 VP9_COMP *cpi = (VP9_COMP *) comp;
3996 signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS]; 4021 signed char feature_data[SEG_LVL_MAX][MAX_SEGMENTS];
3997 MACROBLOCKD *xd = &cpi->mb.e_mbd; 4022 struct segmentation *seg = &cpi->common.seg;
3998 int i; 4023 int i;
3999 4024
4000 if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols) 4025 if (cpi->common.mb_rows != rows || cpi->common.mb_cols != cols)
4001 return -1; 4026 return -1;
4002 4027
4003 if (!map) { 4028 if (!map) {
4004 vp9_disable_segmentation((VP9_PTR)cpi); 4029 vp9_disable_segmentation((VP9_PTR)cpi);
4005 return 0; 4030 return 0;
4006 } 4031 }
4007 4032
4008 // Set the segmentation Map 4033 // Set the segmentation Map
4009 vp9_set_segmentation_map((VP9_PTR)cpi, map); 4034 vp9_set_segmentation_map((VP9_PTR)cpi, map);
4010 4035
4011 // Activate segmentation. 4036 // Activate segmentation.
4012 vp9_enable_segmentation((VP9_PTR)cpi); 4037 vp9_enable_segmentation((VP9_PTR)cpi);
4013 4038
4014 // Set up the quan, LF and breakout threshold segment data 4039 // Set up the quant, LF and breakout threshold segment data
4015 for (i = 0; i < MAX_SEGMENTS; i++) { 4040 for (i = 0; i < MAX_SEGMENTS; i++) {
4016 feature_data[SEG_LVL_ALT_Q][i] = delta_q[i]; 4041 feature_data[SEG_LVL_ALT_Q][i] = delta_q[i];
4017 feature_data[SEG_LVL_ALT_LF][i] = delta_lf[i]; 4042 feature_data[SEG_LVL_ALT_LF][i] = delta_lf[i];
4018 cpi->segment_encode_breakout[i] = threshold[i]; 4043 cpi->segment_encode_breakout[i] = threshold[i];
4019 } 4044 }
4020 4045
4021 // Enable the loop and quant changes in the feature mask 4046 // Enable the loop and quant changes in the feature mask
4022 for (i = 0; i < MAX_SEGMENTS; i++) { 4047 for (i = 0; i < MAX_SEGMENTS; i++) {
4023 if (delta_q[i]) 4048 if (delta_q[i])
4024 vp9_enable_segfeature(&xd->seg, i, SEG_LVL_ALT_Q); 4049 vp9_enable_segfeature(seg, i, SEG_LVL_ALT_Q);
4025 else 4050 else
4026 vp9_disable_segfeature(&xd->seg, i, SEG_LVL_ALT_Q); 4051 vp9_disable_segfeature(seg, i, SEG_LVL_ALT_Q);
4027 4052
4028 if (delta_lf[i]) 4053 if (delta_lf[i])
4029 vp9_enable_segfeature(&xd->seg, i, SEG_LVL_ALT_LF); 4054 vp9_enable_segfeature(seg, i, SEG_LVL_ALT_LF);
4030 else 4055 else
4031 vp9_disable_segfeature(&xd->seg, i, SEG_LVL_ALT_LF); 4056 vp9_disable_segfeature(seg, i, SEG_LVL_ALT_LF);
4032 } 4057 }
4033 4058
4034 // Initialise the feature data structure 4059 // Initialize the feature data structure
4035 // SEGMENT_DELTADATA 0, SEGMENT_ABSDATA 1 4060 // SEGMENT_DELTADATA 0, SEGMENT_ABSDATA 1
4036 vp9_set_segment_data((VP9_PTR)cpi, &feature_data[0][0], SEGMENT_DELTADATA); 4061 vp9_set_segment_data((VP9_PTR)cpi, &feature_data[0][0], SEGMENT_DELTADATA);
4037 4062
4038 return 0; 4063 return 0;
4039 } 4064 }
4040 4065
4041 int vp9_set_active_map(VP9_PTR comp, unsigned char *map, 4066 int vp9_set_active_map(VP9_PTR comp, unsigned char *map,
4042 unsigned int rows, unsigned int cols) { 4067 unsigned int rows, unsigned int cols) {
4043 VP9_COMP *cpi = (VP9_COMP *) comp; 4068 VP9_COMP *cpi = (VP9_COMP *) comp;
4044 4069
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
4101 dst += 16 * dest->y_stride; 4126 dst += 16 * dest->y_stride;
4102 } 4127 }
4103 4128
4104 return total; 4129 return total;
4105 } 4130 }
4106 4131
4107 4132
4108 int vp9_get_quantizer(VP9_PTR c) { 4133 int vp9_get_quantizer(VP9_PTR c) {
4109 return ((VP9_COMP *)c)->common.base_qindex; 4134 return ((VP9_COMP *)c)->common.base_qindex;
4110 } 4135 }
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