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

Side by Side Diff: source/libvpx/vp9/encoder/vp9_firstpass.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_encodemv.c ('k') | source/libvpx/vp9/encoder/vp9_mbgraph.c » ('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
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.total_stats); 340 output_stats(cpi, cpi->output_pkt_list, &cpi->twopass.total_stats);
341 } 341 }
342 342
343 static void zz_motion_search(VP9_COMP *cpi, MACROBLOCK *x, YV12_BUFFER_CONFIG *r econ_buffer, int *best_motion_err, int recon_yoffset) { 343 static void zz_motion_search(VP9_COMP *cpi, MACROBLOCK *x, YV12_BUFFER_CONFIG *r econ_buffer, int *best_motion_err, int recon_yoffset) {
344 MACROBLOCKD *const xd = &x->e_mbd; 344 MACROBLOCKD *const xd = &x->e_mbd;
345 345
346 // Set up pointers for this macro block recon buffer 346 // Set up pointers for this macro block recon buffer
347 xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset; 347 xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
348 348
349 switch (xd->mode_info_context->mbmi.sb_type) { 349 switch (xd->mode_info_context->mbmi.sb_type) {
350 case BLOCK_SIZE_SB8X8: 350 case BLOCK_8X8:
351 vp9_mse8x8(x->plane[0].src.buf, x->plane[0].src.stride, 351 vp9_mse8x8(x->plane[0].src.buf, x->plane[0].src.stride,
352 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride, 352 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
353 (unsigned int *)(best_motion_err)); 353 (unsigned int *)(best_motion_err));
354 break; 354 break;
355 case BLOCK_SIZE_SB16X8: 355 case BLOCK_16X8:
356 vp9_mse16x8(x->plane[0].src.buf, x->plane[0].src.stride, 356 vp9_mse16x8(x->plane[0].src.buf, x->plane[0].src.stride,
357 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride, 357 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
358 (unsigned int *)(best_motion_err)); 358 (unsigned int *)(best_motion_err));
359 break; 359 break;
360 case BLOCK_SIZE_SB8X16: 360 case BLOCK_8X16:
361 vp9_mse8x16(x->plane[0].src.buf, x->plane[0].src.stride, 361 vp9_mse8x16(x->plane[0].src.buf, x->plane[0].src.stride,
362 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride, 362 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
363 (unsigned int *)(best_motion_err)); 363 (unsigned int *)(best_motion_err));
364 break; 364 break;
365 default: 365 default:
366 vp9_mse16x16(x->plane[0].src.buf, x->plane[0].src.stride, 366 vp9_mse16x16(x->plane[0].src.buf, x->plane[0].src.stride,
367 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride, 367 xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
368 (unsigned int *)(best_motion_err)); 368 (unsigned int *)(best_motion_err));
369 break; 369 break;
370 } 370 }
(...skipping 25 matching lines...) Expand all
396 while ((quart_frm << sr) < MAX_FULL_PEL_VAL) 396 while ((quart_frm << sr) < MAX_FULL_PEL_VAL)
397 sr++; 397 sr++;
398 if (sr) 398 if (sr)
399 sr--; 399 sr--;
400 400
401 step_param += sr; 401 step_param += sr;
402 further_steps -= sr; 402 further_steps -= sr;
403 403
404 // override the default variance function to use MSE 404 // override the default variance function to use MSE
405 switch (xd->mode_info_context->mbmi.sb_type) { 405 switch (xd->mode_info_context->mbmi.sb_type) {
406 case BLOCK_SIZE_SB8X8: 406 case BLOCK_8X8:
407 v_fn_ptr.vf = vp9_mse8x8; 407 v_fn_ptr.vf = vp9_mse8x8;
408 break; 408 break;
409 case BLOCK_SIZE_SB16X8: 409 case BLOCK_16X8:
410 v_fn_ptr.vf = vp9_mse16x8; 410 v_fn_ptr.vf = vp9_mse16x8;
411 break; 411 break;
412 case BLOCK_SIZE_SB8X16: 412 case BLOCK_8X16:
413 v_fn_ptr.vf = vp9_mse8x16; 413 v_fn_ptr.vf = vp9_mse8x16;
414 break; 414 break;
415 default: 415 default:
416 v_fn_ptr.vf = vp9_mse16x16; 416 v_fn_ptr.vf = vp9_mse16x16;
417 break; 417 break;
418 } 418 }
419 419
420 // Set up pointers for this macro block recon buffer 420 // Set up pointers for this macro block recon buffer
421 xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset; 421 xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
422 422
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 int gf_motion_error = INT_MAX; 542 int gf_motion_error = INT_MAX;
543 int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row); 543 int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
544 544
545 xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset; 545 xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset;
546 xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset; 546 xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
547 xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset; 547 xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
548 xd->left_available = (mb_col != 0); 548 xd->left_available = (mb_col != 0);
549 549
550 if (mb_col * 2 + 1 < cm->mi_cols) { 550 if (mb_col * 2 + 1 < cm->mi_cols) {
551 if (mb_row * 2 + 1 < cm->mi_rows) { 551 if (mb_row * 2 + 1 < cm->mi_rows) {
552 xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_MB16X16; 552 xd->mode_info_context->mbmi.sb_type = BLOCK_16X16;
553 } else { 553 } else {
554 xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB16X8; 554 xd->mode_info_context->mbmi.sb_type = BLOCK_16X8;
555 } 555 }
556 } else { 556 } else {
557 if (mb_row * 2 + 1 < cm->mi_rows) { 557 if (mb_row * 2 + 1 < cm->mi_rows) {
558 xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB8X16; 558 xd->mode_info_context->mbmi.sb_type = BLOCK_8X16;
559 } else { 559 } else {
560 xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB8X8; 560 xd->mode_info_context->mbmi.sb_type = BLOCK_8X8;
561 } 561 }
562 } 562 }
563 xd->mode_info_context->mbmi.ref_frame[0] = INTRA_FRAME; 563 xd->mode_info_context->mbmi.ref_frame[0] = INTRA_FRAME;
564 set_mi_row_col(cm, xd, 564 set_mi_row_col(cm, xd,
565 mb_row << 1, 565 mb_row << 1,
566 1 << mi_height_log2(xd->mode_info_context->mbmi.sb_type), 566 1 << mi_height_log2(xd->mode_info_context->mbmi.sb_type),
567 mb_col << 1, 567 mb_col << 1,
568 1 << mi_height_log2(xd->mode_info_context->mbmi.sb_type)); 568 1 << mi_height_log2(xd->mode_info_context->mbmi.sb_type));
569 569
570 // do intra 16x16 prediction 570 // do intra 16x16 prediction
571 this_error = vp9_encode_intra(cpi, x, use_dc_pred); 571 this_error = vp9_encode_intra(x, use_dc_pred);
572 572
573 // "intrapenalty" below deals with situations where the intra and inter er ror scores are very low (eg a plain black frame) 573 // "intrapenalty" below deals with situations where the intra and inter er ror scores are very low (eg a plain black frame)
574 // We do not have special cases in first pass for 0,0 and nearest etc so a ll inter modes carry an overhead cost estimate fot the mv. 574 // We do not have special cases in first pass for 0,0 and nearest etc so a ll inter modes carry an overhead cost estimate fot the mv.
575 // When the error score is very low this causes us to pick all or lots of INTRA modes and throw lots of key frames. 575 // When the error score is very low this causes us to pick all or lots of INTRA modes and throw lots of key frames.
576 // This penalty adds a cost matching that of a 0,0 mv to the intra case. 576 // This penalty adds a cost matching that of a 0,0 mv to the intra case.
577 this_error += intrapenalty; 577 this_error += intrapenalty;
578 578
579 // Cumulative intra error total 579 // Cumulative intra error total
580 intra_error += (int64_t)this_error; 580 intra_error += (int64_t)this_error;
581 581
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 mv.as_mv.row <<= 3; 660 mv.as_mv.row <<= 3;
661 mv.as_mv.col <<= 3; 661 mv.as_mv.col <<= 3;
662 this_error = motion_error; 662 this_error = motion_error;
663 vp9_set_mbmode_and_mvs(x, NEWMV, &mv); 663 vp9_set_mbmode_and_mvs(x, NEWMV, &mv);
664 xd->mode_info_context->mbmi.txfm_size = TX_4X4; 664 xd->mode_info_context->mbmi.txfm_size = TX_4X4;
665 xd->mode_info_context->mbmi.ref_frame[0] = LAST_FRAME; 665 xd->mode_info_context->mbmi.ref_frame[0] = LAST_FRAME;
666 xd->mode_info_context->mbmi.ref_frame[1] = NONE; 666 xd->mode_info_context->mbmi.ref_frame[1] = NONE;
667 vp9_build_inter_predictors_sby(xd, mb_row << 1, 667 vp9_build_inter_predictors_sby(xd, mb_row << 1,
668 mb_col << 1, 668 mb_col << 1,
669 xd->mode_info_context->mbmi.sb_type); 669 xd->mode_info_context->mbmi.sb_type);
670 vp9_encode_sby(cm, x, xd->mode_info_context->mbmi.sb_type); 670 vp9_encode_sby(x, xd->mode_info_context->mbmi.sb_type);
671 sum_mvr += mv.as_mv.row; 671 sum_mvr += mv.as_mv.row;
672 sum_mvr_abs += abs(mv.as_mv.row); 672 sum_mvr_abs += abs(mv.as_mv.row);
673 sum_mvc += mv.as_mv.col; 673 sum_mvc += mv.as_mv.col;
674 sum_mvc_abs += abs(mv.as_mv.col); 674 sum_mvc_abs += abs(mv.as_mv.col);
675 sum_mvrs += mv.as_mv.row * mv.as_mv.row; 675 sum_mvrs += mv.as_mv.row * mv.as_mv.row;
676 sum_mvcs += mv.as_mv.col * mv.as_mv.col; 676 sum_mvcs += mv.as_mv.col * mv.as_mv.col;
677 intercount++; 677 intercount++;
678 678
679 best_ref_mv.as_int = mv.as_int; 679 best_ref_mv.as_int = mv.as_int;
680 680
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 if (next_frame.pcnt_second_ref > next_frame.pcnt_inter && 1275 if (next_frame.pcnt_second_ref > next_frame.pcnt_inter &&
1276 next_frame.pcnt_second_ref >= 0.5) 1276 next_frame.pcnt_second_ref >= 0.5)
1277 flash_detected = 1; 1277 flash_detected = 1;
1278 } 1278 }
1279 1279
1280 return flash_detected; 1280 return flash_detected;
1281 } 1281 }
1282 1282
1283 // Update the motion related elements to the GF arf boost calculation 1283 // Update the motion related elements to the GF arf boost calculation
1284 static void accumulate_frame_motion_stats( 1284 static void accumulate_frame_motion_stats(
1285 VP9_COMP *cpi,
1286 FIRSTPASS_STATS *this_frame, 1285 FIRSTPASS_STATS *this_frame,
1287 double *this_frame_mv_in_out, 1286 double *this_frame_mv_in_out,
1288 double *mv_in_out_accumulator, 1287 double *mv_in_out_accumulator,
1289 double *abs_mv_in_out_accumulator, 1288 double *abs_mv_in_out_accumulator,
1290 double *mv_ratio_accumulator) { 1289 double *mv_ratio_accumulator) {
1291 // double this_frame_mv_in_out; 1290 // double this_frame_mv_in_out;
1292 double this_frame_mvr_ratio; 1291 double this_frame_mvr_ratio;
1293 double this_frame_mvc_ratio; 1292 double this_frame_mvc_ratio;
1294 double motion_pct; 1293 double motion_pct;
1295 1294
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 double abs_mv_in_out_accumulator = 0.0; 1369 double abs_mv_in_out_accumulator = 0.0;
1371 int arf_boost; 1370 int arf_boost;
1372 int flash_detected = 0; 1371 int flash_detected = 0;
1373 1372
1374 // Search forward from the proposed arf/next gf position 1373 // Search forward from the proposed arf/next gf position
1375 for (i = 0; i < f_frames; i++) { 1374 for (i = 0; i < f_frames; i++) {
1376 if (read_frame_stats(cpi, &this_frame, (i + offset)) == EOF) 1375 if (read_frame_stats(cpi, &this_frame, (i + offset)) == EOF)
1377 break; 1376 break;
1378 1377
1379 // Update the motion related elements to the boost calculation 1378 // Update the motion related elements to the boost calculation
1380 accumulate_frame_motion_stats(cpi, &this_frame, 1379 accumulate_frame_motion_stats(&this_frame,
1381 &this_frame_mv_in_out, &mv_in_out_accumulator, 1380 &this_frame_mv_in_out, &mv_in_out_accumulator,
1382 &abs_mv_in_out_accumulator, &mv_ratio_accumula tor); 1381 &abs_mv_in_out_accumulator, &mv_ratio_accumula tor);
1383 1382
1384 // We want to discount the flash frame itself and the recovery 1383 // We want to discount the flash frame itself and the recovery
1385 // frame that follows as both will have poor scores. 1384 // frame that follows as both will have poor scores.
1386 flash_detected = detect_flash(cpi, (i + offset)) || 1385 flash_detected = detect_flash(cpi, (i + offset)) ||
1387 detect_flash(cpi, (i + offset + 1)); 1386 detect_flash(cpi, (i + offset + 1));
1388 1387
1389 // Cumulative effect of prediction quality decay 1388 // Cumulative effect of prediction quality decay
1390 if (!flash_detected) { 1389 if (!flash_detected) {
(...skipping 15 matching lines...) Expand all
1406 this_frame_mv_in_out = 0.0; 1405 this_frame_mv_in_out = 0.0;
1407 mv_in_out_accumulator = 0.0; 1406 mv_in_out_accumulator = 0.0;
1408 abs_mv_in_out_accumulator = 0.0; 1407 abs_mv_in_out_accumulator = 0.0;
1409 1408
1410 // Search backward towards last gf position 1409 // Search backward towards last gf position
1411 for (i = -1; i >= -b_frames; i--) { 1410 for (i = -1; i >= -b_frames; i--) {
1412 if (read_frame_stats(cpi, &this_frame, (i + offset)) == EOF) 1411 if (read_frame_stats(cpi, &this_frame, (i + offset)) == EOF)
1413 break; 1412 break;
1414 1413
1415 // Update the motion related elements to the boost calculation 1414 // Update the motion related elements to the boost calculation
1416 accumulate_frame_motion_stats(cpi, &this_frame, 1415 accumulate_frame_motion_stats(&this_frame,
1417 &this_frame_mv_in_out, &mv_in_out_accumulator, 1416 &this_frame_mv_in_out, &mv_in_out_accumulator,
1418 &abs_mv_in_out_accumulator, &mv_ratio_accumula tor); 1417 &abs_mv_in_out_accumulator, &mv_ratio_accumula tor);
1419 1418
1420 // We want to discount the the flash frame itself and the recovery 1419 // We want to discount the the flash frame itself and the recovery
1421 // frame that follows as both will have poor scores. 1420 // frame that follows as both will have poor scores.
1422 flash_detected = detect_flash(cpi, (i + offset)) || 1421 flash_detected = detect_flash(cpi, (i + offset)) ||
1423 detect_flash(cpi, (i + offset + 1)); 1422 detect_flash(cpi, (i + offset + 1));
1424 1423
1425 // Cumulative effect of prediction quality decay 1424 // Cumulative effect of prediction quality decay
1426 if (!flash_detected) { 1425 if (!flash_detected) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 for (i = 0; i < cpi->new_frame_coding_order_period; ++i) { 1573 for (i = 0; i < cpi->new_frame_coding_order_period; ++i) {
1575 printf("%4d ", cpi->arf_weight[i]); 1574 printf("%4d ", cpi->arf_weight[i]);
1576 } 1575 }
1577 printf("\n"); 1576 printf("\n");
1578 #endif 1577 #endif
1579 } 1578 }
1580 #endif 1579 #endif
1581 1580
1582 // Analyse and define a gf/arf group. 1581 // Analyse and define a gf/arf group.
1583 static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) { 1582 static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
1584 FIRSTPASS_STATS next_frame; 1583 FIRSTPASS_STATS next_frame = { 0 };
1585 FIRSTPASS_STATS *start_pos; 1584 FIRSTPASS_STATS *start_pos;
1586 int i; 1585 int i;
1587 double boost_score = 0.0; 1586 double boost_score = 0.0;
1588 double old_boost_score = 0.0; 1587 double old_boost_score = 0.0;
1589 double gf_group_err = 0.0; 1588 double gf_group_err = 0.0;
1590 double gf_first_frame_err = 0.0; 1589 double gf_first_frame_err = 0.0;
1591 double mod_frame_err = 0.0; 1590 double mod_frame_err = 0.0;
1592 1591
1593 double mv_ratio_accumulator = 0.0; 1592 double mv_ratio_accumulator = 0.0;
1594 double decay_accumulator = 1.0; 1593 double decay_accumulator = 1.0;
(...skipping 15 matching lines...) Expand all
1610 int b_boost = 0; 1609 int b_boost = 0;
1611 int flash_detected; 1610 int flash_detected;
1612 int active_max_gf_interval; 1611 int active_max_gf_interval;
1613 1612
1614 cpi->twopass.gf_group_bits = 0; 1613 cpi->twopass.gf_group_bits = 0;
1615 1614
1616 vp9_clear_system_state(); // __asm emms; 1615 vp9_clear_system_state(); // __asm emms;
1617 1616
1618 start_pos = cpi->twopass.stats_in; 1617 start_pos = cpi->twopass.stats_in;
1619 1618
1620 vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean
1621
1622 // Load stats for the current frame. 1619 // Load stats for the current frame.
1623 mod_frame_err = calculate_modified_err(cpi, this_frame); 1620 mod_frame_err = calculate_modified_err(cpi, this_frame);
1624 1621
1625 // Note the error of the frame at the start of the group (this will be 1622 // Note the error of the frame at the start of the group (this will be
1626 // the GF frame error if we code a normal gf 1623 // the GF frame error if we code a normal gf
1627 gf_first_frame_err = mod_frame_err; 1624 gf_first_frame_err = mod_frame_err;
1628 1625
1629 // Special treatment if the current frame is a key frame (which is also 1626 // Special treatment if the current frame is a key frame (which is also
1630 // a gf). If it is then its error score (and hence bit allocation) need 1627 // a gf). If it is then its error score (and hence bit allocation) need
1631 // to be subtracted out from the calculation for the GF group 1628 // to be subtracted out from the calculation for the GF group
(...skipping 26 matching lines...) Expand all
1658 gf_group_err += mod_frame_err; 1655 gf_group_err += mod_frame_err;
1659 1656
1660 if (EOF == input_stats(cpi, &next_frame)) 1657 if (EOF == input_stats(cpi, &next_frame))
1661 break; 1658 break;
1662 1659
1663 // Test for the case where there is a brief flash but the prediction 1660 // Test for the case where there is a brief flash but the prediction
1664 // quality back to an earlier frame is then restored. 1661 // quality back to an earlier frame is then restored.
1665 flash_detected = detect_flash(cpi, 0); 1662 flash_detected = detect_flash(cpi, 0);
1666 1663
1667 // Update the motion related elements to the boost calculation 1664 // Update the motion related elements to the boost calculation
1668 accumulate_frame_motion_stats(cpi, &next_frame, 1665 accumulate_frame_motion_stats(&next_frame,
1669 &this_frame_mv_in_out, &mv_in_out_accumulator, 1666 &this_frame_mv_in_out, &mv_in_out_accumulator,
1670 &abs_mv_in_out_accumulator, &mv_ratio_accumula tor); 1667 &abs_mv_in_out_accumulator, &mv_ratio_accumula tor);
1671 1668
1672 // Cumulative effect of prediction quality decay 1669 // Cumulative effect of prediction quality decay
1673 if (!flash_detected) { 1670 if (!flash_detected) {
1674 last_loop_decay_rate = loop_decay_rate; 1671 last_loop_decay_rate = loop_decay_rate;
1675 loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame); 1672 loop_decay_rate = get_prediction_decay_rate(cpi, &next_frame);
1676 decay_accumulator = decay_accumulator * loop_decay_rate; 1673 decay_accumulator = decay_accumulator * loop_decay_rate;
1677 1674
1678 // Monitor for static sections. 1675 // Monitor for static sections.
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2132 tmp_q = estimate_max_q( 2129 tmp_q = estimate_max_q(
2133 cpi, 2130 cpi,
2134 &cpi->twopass.total_left_stats, 2131 &cpi->twopass.total_left_stats,
2135 (int)(cpi->twopass.bits_left / frames_left)); 2132 (int)(cpi->twopass.bits_left / frames_left));
2136 2133
2137 // Make a damped adjustment to active max Q 2134 // Make a damped adjustment to active max Q
2138 cpi->active_worst_quality = 2135 cpi->active_worst_quality =
2139 adjust_active_maxq(cpi->active_worst_quality, tmp_q); 2136 adjust_active_maxq(cpi->active_worst_quality, tmp_q);
2140 } 2137 }
2141 #endif 2138 #endif
2142 2139 vp9_zero(this_frame);
2143 vpx_memset(&this_frame, 0, sizeof(FIRSTPASS_STATS));
2144 if (EOF == input_stats(cpi, &this_frame)) 2140 if (EOF == input_stats(cpi, &this_frame))
2145 return; 2141 return;
2146 2142
2147 this_frame_intra_error = this_frame.intra_error; 2143 this_frame_intra_error = this_frame.intra_error;
2148 this_frame_coded_error = this_frame.coded_error; 2144 this_frame_coded_error = this_frame.coded_error;
2149 2145
2150 // keyframe and section processing ! 2146 // keyframe and section processing !
2151 if (cpi->twopass.frames_to_key == 0) { 2147 if (cpi->twopass.frames_to_key == 0) {
2152 // Define next KF group and assign bits to it 2148 // Define next KF group and assign bits to it
2153 this_frame_copy = this_frame; 2149 this_frame_copy = this_frame;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 double zero_motion_accumulator = 1.0; 2307 double zero_motion_accumulator = 1.0;
2312 double boost_score = 0; 2308 double boost_score = 0;
2313 double loop_decay_rate; 2309 double loop_decay_rate;
2314 2310
2315 double kf_mod_err = 0.0; 2311 double kf_mod_err = 0.0;
2316 double kf_group_err = 0.0; 2312 double kf_group_err = 0.0;
2317 double kf_group_intra_err = 0.0; 2313 double kf_group_intra_err = 0.0;
2318 double kf_group_coded_err = 0.0; 2314 double kf_group_coded_err = 0.0;
2319 double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; 2315 double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
2320 2316
2321 vpx_memset(&next_frame, 0, sizeof(next_frame)); // assure clean 2317 vp9_zero(next_frame);
2322 2318
2323 vp9_clear_system_state(); // __asm emms; 2319 vp9_clear_system_state(); // __asm emms;
2324 start_position = cpi->twopass.stats_in; 2320 start_position = cpi->twopass.stats_in;
2325 2321
2326 cpi->common.frame_type = KEY_FRAME; 2322 cpi->common.frame_type = KEY_FRAME;
2327 2323
2328 // is this a forced key frame by interval 2324 // is this a forced key frame by interval
2329 cpi->this_key_frame_forced = cpi->next_key_frame_forced; 2325 cpi->this_key_frame_forced = cpi->next_key_frame_forced;
2330 2326
2331 // Clear the alt ref active flag as this can never be active on a key frame 2327 // Clear the alt ref active flag as this can never be active on a key frame
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 cpi->output_framerate); 2622 cpi->output_framerate);
2627 } 2623 }
2628 2624
2629 // Note the total error score of the kf group minus the key frame itself 2625 // Note the total error score of the kf group minus the key frame itself
2630 cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err); 2626 cpi->twopass.kf_group_error_left = (int)(kf_group_err - kf_mod_err);
2631 2627
2632 // Adjust the count of total modified error left. 2628 // Adjust the count of total modified error left.
2633 // The count of bits left is adjusted elsewhere based on real coded frame size s 2629 // The count of bits left is adjusted elsewhere based on real coded frame size s
2634 cpi->twopass.modified_error_left -= kf_group_err; 2630 cpi->twopass.modified_error_left -= kf_group_err;
2635 } 2631 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodemv.c ('k') | source/libvpx/vp9/encoder/vp9_mbgraph.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698