| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 101, 98, 95, 92, 89, 86, 83, 80, | 43 101, 98, 95, 92, 89, 86, 83, 80, |
| 44 77, 74, 71, 68, 65, 62, 59, 56, | 44 77, 74, 71, 68, 65, 62, 59, 56, |
| 45 53, 50, 47, 44, 41, 38, 35, 32, | 45 53, 50, 47, 44, 41, 38, 35, 32, |
| 46 30, 28, 26, 24, 22, 20, 18, 16, | 46 30, 28, 26, 24, 22, 20, 18, 16, |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 #if defined(SECTIONBITS_OUTPUT) | 49 #if defined(SECTIONBITS_OUTPUT) |
| 50 unsigned __int64 Sectionbits[500]; | 50 unsigned __int64 Sectionbits[500]; |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 #ifdef ENTROPY_STATS | 53 #ifdef VP8_ENTROPY_STATS |
| 54 int intra_mode_stats[10][10][10]; | 54 int intra_mode_stats[10][10][10]; |
| 55 static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTE
XTS] [ENTROPY_NODES] [2]; | 55 static unsigned int tree_update_hist [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTE
XTS] [ENTROPY_NODES] [2]; |
| 56 extern unsigned int active_section; | 56 extern unsigned int active_section; |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 #ifdef MODE_STATS | 59 #ifdef MODE_STATS |
| 60 int count_mb_seg[4] = { 0, 0, 0, 0 }; | 60 int count_mb_seg[4] = { 0, 0, 0, 0 }; |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 | 63 |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 MODE_INFO *m = pc->mi; | 524 MODE_INFO *m = pc->mi; |
| 525 const int mis = pc->mode_info_stride; | 525 const int mis = pc->mode_info_stride; |
| 526 int mb_row = -1; | 526 int mb_row = -1; |
| 527 | 527 |
| 528 int prob_skip_false = 0; | 528 int prob_skip_false = 0; |
| 529 | 529 |
| 530 cpi->mb.partition_info = cpi->mb.pi; | 530 cpi->mb.partition_info = cpi->mb.pi; |
| 531 | 531 |
| 532 vp8_convert_rfct_to_prob(cpi); | 532 vp8_convert_rfct_to_prob(cpi); |
| 533 | 533 |
| 534 #ifdef ENTROPY_STATS | 534 #ifdef VP8_ENTROPY_STATS |
| 535 active_section = 1; | 535 active_section = 1; |
| 536 #endif | 536 #endif |
| 537 | 537 |
| 538 if (pc->mb_no_coeff_skip) | 538 if (pc->mb_no_coeff_skip) |
| 539 { | 539 { |
| 540 int total_mbs = pc->mb_rows * pc->mb_cols; | 540 int total_mbs = pc->mb_rows * pc->mb_cols; |
| 541 | 541 |
| 542 prob_skip_false = (total_mbs - cpi->mb.skip_true_count ) * 256 / total_m
bs; | 542 prob_skip_false = (total_mbs - cpi->mb.skip_true_count ) * 256 / total_m
bs; |
| 543 | 543 |
| 544 if (prob_skip_false <= 1) | 544 if (prob_skip_false <= 1) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 573 | 573 |
| 574 /* Distance of Mb to the various image edges. | 574 /* Distance of Mb to the various image edges. |
| 575 * These specified to 8th pel as they are always compared to MV | 575 * These specified to 8th pel as they are always compared to MV |
| 576 * values that are in 1/8th pel units | 576 * values that are in 1/8th pel units |
| 577 */ | 577 */ |
| 578 xd->mb_to_left_edge = -((mb_col * 16) << 3); | 578 xd->mb_to_left_edge = -((mb_col * 16) << 3); |
| 579 xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3; | 579 xd->mb_to_right_edge = ((pc->mb_cols - 1 - mb_col) * 16) << 3; |
| 580 xd->mb_to_top_edge = -((mb_row * 16)) << 3; | 580 xd->mb_to_top_edge = -((mb_row * 16)) << 3; |
| 581 xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3; | 581 xd->mb_to_bottom_edge = ((pc->mb_rows - 1 - mb_row) * 16) << 3; |
| 582 | 582 |
| 583 #ifdef ENTROPY_STATS | 583 #ifdef VP8_ENTROPY_STATS |
| 584 active_section = 9; | 584 active_section = 9; |
| 585 #endif | 585 #endif |
| 586 | 586 |
| 587 if (cpi->mb.e_mbd.update_mb_segmentation_map) | 587 if (cpi->mb.e_mbd.update_mb_segmentation_map) |
| 588 write_mb_features(w, mi, &cpi->mb.e_mbd); | 588 write_mb_features(w, mi, &cpi->mb.e_mbd); |
| 589 | 589 |
| 590 if (pc->mb_no_coeff_skip) | 590 if (pc->mb_no_coeff_skip) |
| 591 vp8_encode_bool(w, m->mbmi.mb_skip_coeff, prob_skip_false); | 591 vp8_encode_bool(w, m->mbmi.mb_skip_coeff, prob_skip_false); |
| 592 | 592 |
| 593 if (rf == INTRA_FRAME) | 593 if (rf == INTRA_FRAME) |
| 594 { | 594 { |
| 595 vp8_write(w, 0, cpi->prob_intra_coded); | 595 vp8_write(w, 0, cpi->prob_intra_coded); |
| 596 #ifdef ENTROPY_STATS | 596 #ifdef VP8_ENTROPY_STATS |
| 597 active_section = 6; | 597 active_section = 6; |
| 598 #endif | 598 #endif |
| 599 write_ymode(w, mode, pc->fc.ymode_prob); | 599 write_ymode(w, mode, pc->fc.ymode_prob); |
| 600 | 600 |
| 601 if (mode == B_PRED) | 601 if (mode == B_PRED) |
| 602 { | 602 { |
| 603 int j = 0; | 603 int j = 0; |
| 604 | 604 |
| 605 do | 605 do |
| 606 write_bmode(w, m->bmi[j].as_mode, pc->fc.bmode_prob); | 606 write_bmode(w, m->bmi[j].as_mode, pc->fc.bmode_prob); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 626 | 626 |
| 627 { | 627 { |
| 628 int_mv n1, n2; | 628 int_mv n1, n2; |
| 629 int ct[4]; | 629 int ct[4]; |
| 630 | 630 |
| 631 vp8_find_near_mvs(xd, m, &n1, &n2, &best_mv, ct, rf, cpi->co
mmon.ref_frame_sign_bias); | 631 vp8_find_near_mvs(xd, m, &n1, &n2, &best_mv, ct, rf, cpi->co
mmon.ref_frame_sign_bias); |
| 632 vp8_clamp_mv2(&best_mv, xd); | 632 vp8_clamp_mv2(&best_mv, xd); |
| 633 | 633 |
| 634 vp8_mv_ref_probs(mv_ref_p, ct); | 634 vp8_mv_ref_probs(mv_ref_p, ct); |
| 635 | 635 |
| 636 #ifdef ENTROPY_STATS | 636 #ifdef VP8_ENTROPY_STATS |
| 637 accum_mv_refs(mode, ct); | 637 accum_mv_refs(mode, ct); |
| 638 #endif | 638 #endif |
| 639 | 639 |
| 640 } | 640 } |
| 641 | 641 |
| 642 #ifdef ENTROPY_STATS | 642 #ifdef VP8_ENTROPY_STATS |
| 643 active_section = 3; | 643 active_section = 3; |
| 644 #endif | 644 #endif |
| 645 | 645 |
| 646 write_mv_ref(w, mode, mv_ref_p); | 646 write_mv_ref(w, mode, mv_ref_p); |
| 647 | 647 |
| 648 switch (mode) /* new, split require MVs */ | 648 switch (mode) /* new, split require MVs */ |
| 649 { | 649 { |
| 650 case NEWMV: | 650 case NEWMV: |
| 651 | 651 |
| 652 #ifdef ENTROPY_STATS | 652 #ifdef VP8_ENTROPY_STATS |
| 653 active_section = 5; | 653 active_section = 5; |
| 654 #endif | 654 #endif |
| 655 | 655 |
| 656 write_mv(w, &mi->mv.as_mv, &best_mv, mvc); | 656 write_mv(w, &mi->mv.as_mv, &best_mv, mvc); |
| 657 break; | 657 break; |
| 658 | 658 |
| 659 case SPLITMV: | 659 case SPLITMV: |
| 660 { | 660 { |
| 661 int j = 0; | 661 int j = 0; |
| 662 | 662 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 685 while (j != L[++k]); | 685 while (j != L[++k]); |
| 686 #endif | 686 #endif |
| 687 leftmv.as_int = left_block_mv(m, k); | 687 leftmv.as_int = left_block_mv(m, k); |
| 688 abovemv.as_int = above_block_mv(m, k, mis); | 688 abovemv.as_int = above_block_mv(m, k, mis); |
| 689 mv_contz = vp8_mv_cont(&leftmv, &abovemv); | 689 mv_contz = vp8_mv_cont(&leftmv, &abovemv); |
| 690 | 690 |
| 691 write_sub_mv_ref(w, blockmode, vp8_sub_mv_ref_prob2 [mv_
contz]); | 691 write_sub_mv_ref(w, blockmode, vp8_sub_mv_ref_prob2 [mv_
contz]); |
| 692 | 692 |
| 693 if (blockmode == NEW4X4) | 693 if (blockmode == NEW4X4) |
| 694 { | 694 { |
| 695 #ifdef ENTROPY_STATS | 695 #ifdef VP8_ENTROPY_STATS |
| 696 active_section = 11; | 696 active_section = 11; |
| 697 #endif | 697 #endif |
| 698 write_mv(w, &blockmv.as_mv, &best_mv, (const MV_CONT
EXT *) mvc); | 698 write_mv(w, &blockmv.as_mv, &best_mv, (const MV_CONT
EXT *) mvc); |
| 699 } | 699 } |
| 700 } | 700 } |
| 701 while (++j < cpi->mb.partition_info->count); | 701 while (++j < cpi->mb.partition_info->count); |
| 702 } | 702 } |
| 703 break; | 703 break; |
| 704 default: | 704 default: |
| 705 break; | 705 break; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 { | 762 { |
| 763 const int mis = c->mode_info_stride; | 763 const int mis = c->mode_info_stride; |
| 764 int i = 0; | 764 int i = 0; |
| 765 | 765 |
| 766 do | 766 do |
| 767 { | 767 { |
| 768 const B_PREDICTION_MODE A = above_block_mode(m, i, mis); | 768 const B_PREDICTION_MODE A = above_block_mode(m, i, mis); |
| 769 const B_PREDICTION_MODE L = left_block_mode(m, i); | 769 const B_PREDICTION_MODE L = left_block_mode(m, i); |
| 770 const int bm = m->bmi[i].as_mode; | 770 const int bm = m->bmi[i].as_mode; |
| 771 | 771 |
| 772 #ifdef ENTROPY_STATS | 772 #ifdef VP8_ENTROPY_STATS |
| 773 ++intra_mode_stats [A] [L] [bm]; | 773 ++intra_mode_stats [A] [L] [bm]; |
| 774 #endif | 774 #endif |
| 775 | 775 |
| 776 write_bmode(bc, bm, vp8_kf_bmode_prob [A] [L]); | 776 write_bmode(bc, bm, vp8_kf_bmode_prob [A] [L]); |
| 777 } | 777 } |
| 778 while (++i < 16); | 778 while (++i < 16); |
| 779 } | 779 } |
| 780 | 780 |
| 781 write_uv_mode(bc, (m++)->mbmi.uv_mode, vp8_kf_uv_mode_prob); | 781 write_uv_mode(bc, (m++)->mbmi.uv_mode, vp8_kf_uv_mode_prob); |
| 782 } | 782 } |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 cpi->common.frame_type == KEY_FRAME && newp != *Pold) | 1153 cpi->common.frame_type == KEY_FRAME && newp != *Pold) |
| 1154 u = 1; | 1154 u = 1; |
| 1155 | 1155 |
| 1156 #if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING | 1156 #if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING |
| 1157 cpi->update_probs[i][j][k][t] = u; | 1157 cpi->update_probs[i][j][k][t] = u; |
| 1158 #else | 1158 #else |
| 1159 vp8_write(w, u, upd); | 1159 vp8_write(w, u, upd); |
| 1160 #endif | 1160 #endif |
| 1161 | 1161 |
| 1162 | 1162 |
| 1163 #ifdef ENTROPY_STATS | 1163 #ifdef VP8_ENTROPY_STATS |
| 1164 ++ tree_update_hist [i][j][k][t] [u]; | 1164 ++ tree_update_hist [i][j][k][t] [u]; |
| 1165 #endif | 1165 #endif |
| 1166 | 1166 |
| 1167 if (u) | 1167 if (u) |
| 1168 { | 1168 { |
| 1169 /* send/use new probability */ | 1169 /* send/use new probability */ |
| 1170 | 1170 |
| 1171 *Pold = newp; | 1171 *Pold = newp; |
| 1172 #if !(CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) | 1172 #if !(CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING) |
| 1173 vp8_write_literal(w, newp, 8); | 1173 vp8_write_literal(w, newp, 8); |
| 1174 #endif | 1174 #endif |
| 1175 | 1175 |
| 1176 savings += s; | 1176 savings += s; |
| 1177 | 1177 |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 } | 1180 } |
| 1181 while (++t < ENTROPY_NODES); | 1181 while (++t < ENTROPY_NODES); |
| 1182 | 1182 |
| 1183 /* Accum token counts for generation of default statistics */ | 1183 /* Accum token counts for generation of default statistics */ |
| 1184 #ifdef ENTROPY_STATS | 1184 #ifdef VP8_ENTROPY_STATS |
| 1185 t = 0; | 1185 t = 0; |
| 1186 | 1186 |
| 1187 do | 1187 do |
| 1188 { | 1188 { |
| 1189 context_counters [i][j][k][t] += cpi->coef_counts [i][j][k][
t]; | 1189 context_counters [i][j][k][t] += cpi->coef_counts [i][j][k][
t]; |
| 1190 } | 1190 } |
| 1191 while (++t < MAX_ENTROPY_TOKENS); | 1191 while (++t < MAX_ENTROPY_TOKENS); |
| 1192 | 1192 |
| 1193 #endif | 1193 #endif |
| 1194 | 1194 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 else | 1520 else |
| 1521 pc->refresh_entropy_probs = 0; | 1521 pc->refresh_entropy_probs = 0; |
| 1522 } | 1522 } |
| 1523 #endif | 1523 #endif |
| 1524 | 1524 |
| 1525 vp8_write_bit(bc, pc->refresh_entropy_probs); | 1525 vp8_write_bit(bc, pc->refresh_entropy_probs); |
| 1526 | 1526 |
| 1527 if (pc->frame_type != KEY_FRAME) | 1527 if (pc->frame_type != KEY_FRAME) |
| 1528 vp8_write_bit(bc, pc->refresh_last_frame); | 1528 vp8_write_bit(bc, pc->refresh_last_frame); |
| 1529 | 1529 |
| 1530 #ifdef ENTROPY_STATS | 1530 #ifdef VP8_ENTROPY_STATS |
| 1531 | 1531 |
| 1532 if (pc->frame_type == INTER_FRAME) | 1532 if (pc->frame_type == INTER_FRAME) |
| 1533 active_section = 0; | 1533 active_section = 0; |
| 1534 else | 1534 else |
| 1535 active_section = 7; | 1535 active_section = 7; |
| 1536 | 1536 |
| 1537 #endif | 1537 #endif |
| 1538 | 1538 |
| 1539 vp8_clear_system_state(); | 1539 vp8_clear_system_state(); |
| 1540 | 1540 |
| 1541 #if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING | 1541 #if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING |
| 1542 pack_coef_probs(cpi); | 1542 pack_coef_probs(cpi); |
| 1543 #else | 1543 #else |
| 1544 if (pc->refresh_entropy_probs == 0) | 1544 if (pc->refresh_entropy_probs == 0) |
| 1545 { | 1545 { |
| 1546 /* save a copy for later refresh */ | 1546 /* save a copy for later refresh */ |
| 1547 vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc)); | 1547 vpx_memcpy(&cpi->common.lfc, &cpi->common.fc, sizeof(cpi->common.fc)); |
| 1548 } | 1548 } |
| 1549 | 1549 |
| 1550 vp8_update_coef_probs(cpi); | 1550 vp8_update_coef_probs(cpi); |
| 1551 #endif | 1551 #endif |
| 1552 | 1552 |
| 1553 #ifdef ENTROPY_STATS | 1553 #ifdef VP8_ENTROPY_STATS |
| 1554 active_section = 2; | 1554 active_section = 2; |
| 1555 #endif | 1555 #endif |
| 1556 | 1556 |
| 1557 /* Write out the mb_no_coeff_skip flag */ | 1557 /* Write out the mb_no_coeff_skip flag */ |
| 1558 vp8_write_bit(bc, pc->mb_no_coeff_skip); | 1558 vp8_write_bit(bc, pc->mb_no_coeff_skip); |
| 1559 | 1559 |
| 1560 if (pc->frame_type == KEY_FRAME) | 1560 if (pc->frame_type == KEY_FRAME) |
| 1561 { | 1561 { |
| 1562 write_kfmodes(cpi); | 1562 write_kfmodes(cpi); |
| 1563 | 1563 |
| 1564 #ifdef ENTROPY_STATS | 1564 #ifdef VP8_ENTROPY_STATS |
| 1565 active_section = 8; | 1565 active_section = 8; |
| 1566 #endif | 1566 #endif |
| 1567 } | 1567 } |
| 1568 else | 1568 else |
| 1569 { | 1569 { |
| 1570 pack_inter_mode_mvs(cpi); | 1570 pack_inter_mode_mvs(cpi); |
| 1571 | 1571 |
| 1572 #ifdef ENTROPY_STATS | 1572 #ifdef VP8_ENTROPY_STATS |
| 1573 active_section = 1; | 1573 active_section = 1; |
| 1574 #endif | 1574 #endif |
| 1575 } | 1575 } |
| 1576 | 1576 |
| 1577 vp8_stop_encode(bc); | 1577 vp8_stop_encode(bc); |
| 1578 | 1578 |
| 1579 cx_data += bc->pos; | 1579 cx_data += bc->pos; |
| 1580 | 1580 |
| 1581 oh.first_partition_length_in_bytes = cpi->bc->pos; | 1581 oh.first_partition_length_in_bytes = cpi->bc->pos; |
| 1582 | 1582 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 pack_tokens(&cpi->bc[1], cpi->tok, cpi->tok_count); | 1680 pack_tokens(&cpi->bc[1], cpi->tok, cpi->tok_count); |
| 1681 | 1681 |
| 1682 vp8_stop_encode(&cpi->bc[1]); | 1682 vp8_stop_encode(&cpi->bc[1]); |
| 1683 | 1683 |
| 1684 *size += cpi->bc[1].pos; | 1684 *size += cpi->bc[1].pos; |
| 1685 cpi->partition_sz[1] = cpi->bc[1].pos; | 1685 cpi->partition_sz[1] = cpi->bc[1].pos; |
| 1686 } | 1686 } |
| 1687 #endif | 1687 #endif |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 #ifdef ENTROPY_STATS | 1690 #ifdef VP8_ENTROPY_STATS |
| 1691 void print_tree_update_probs() | 1691 void print_tree_update_probs() |
| 1692 { | 1692 { |
| 1693 int i, j, k, l; | 1693 int i, j, k, l; |
| 1694 FILE *f = fopen("context.c", "a"); | 1694 FILE *f = fopen("context.c", "a"); |
| 1695 int Sum; | 1695 int Sum; |
| 1696 fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n"); | 1696 fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n"); |
| 1697 fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV
_COEF_CONTEXTS] [ENTROPY_NODES] = {\n"); | 1697 fprintf(f, "const vp8_prob tree_update_probs[BLOCK_TYPES] [COEF_BANDS] [PREV
_COEF_CONTEXTS] [ENTROPY_NODES] = {\n"); |
| 1698 | 1698 |
| 1699 for (i = 0; i < BLOCK_TYPES; i++) | 1699 for (i = 0; i < BLOCK_TYPES; i++) |
| 1700 { | 1700 { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1729 fprintf(f, " },\n"); | 1729 fprintf(f, " },\n"); |
| 1730 } | 1730 } |
| 1731 | 1731 |
| 1732 fprintf(f, " },\n"); | 1732 fprintf(f, " },\n"); |
| 1733 } | 1733 } |
| 1734 | 1734 |
| 1735 fprintf(f, "};\n"); | 1735 fprintf(f, "};\n"); |
| 1736 fclose(f); | 1736 fclose(f); |
| 1737 } | 1737 } |
| 1738 #endif | 1738 #endif |
| OLD | NEW |