Mercurial > libavcodec.hg
comparison vp8.c @ 11990:3c51d7ac41c9 libavcodec
Simplify MV parsing, removes laying out 2 or 4 (16x8/8x8/8x16) MVs over all
16 subblocks (since we no longer need that), which should also lead to a
minor speedup.
author | rbultje |
---|---|
date | Mon, 28 Jun 2010 16:04:14 +0000 |
parents | 176c5deb6756 |
children | 372f7fed2806 |
comparison
equal
deleted
inserted
replaced
11989:176c5deb6756 | 11990:3c51d7ac41c9 |
---|---|
597 return l_is_zero ? vp8_submv_prob[1] : vp8_submv_prob[0]; | 597 return l_is_zero ? vp8_submv_prob[1] : vp8_submv_prob[0]; |
598 } | 598 } |
599 | 599 |
600 /** | 600 /** |
601 * Split motion vector prediction, 16.4. | 601 * Split motion vector prediction, 16.4. |
602 * @returns the number of motion vectors parsed (2, 4 or 16) | |
602 */ | 603 */ |
603 static void decode_splitmvs(VP8Context *s, VP56RangeCoder *c, | 604 static int decode_splitmvs(VP8Context *s, VP56RangeCoder *c, |
604 VP8Macroblock *mb, VP56mv *base_mv) | 605 VP8Macroblock *mb, VP56mv *base_mv) |
605 { | 606 { |
606 int part_idx = mb->partitioning = | 607 int part_idx = mb->partitioning = |
607 vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob); | 608 vp8_rac_get_tree(c, vp8_mbsplit_tree, vp8_mbsplit_prob); |
608 int n, num = vp8_mbsplit_count[part_idx]; | 609 int n, num = vp8_mbsplit_count[part_idx]; |
609 VP56mv part_mv[16]; | 610 const uint8_t *mbsplits = vp8_mbsplits[part_idx], |
611 *firstidx = vp8_mbfirstidx[part_idx]; | |
610 | 612 |
611 for (n = 0; n < num; n++) { | 613 for (n = 0; n < num; n++) { |
612 int k = vp8_mbfirstidx[part_idx][n]; | 614 int k = firstidx[n]; |
613 const VP56mv *left = (k & 3) ? &mb->bmv[k - 1] : &mb[-1].bmv[k + 3], | 615 const VP56mv *left, *above; |
614 *above = (k > 3) ? &mb->bmv[k - 4] : &mb[-s->mb_stride].bmv[k + 12]; | 616 const uint8_t *submv_prob; |
615 const uint8_t *submv_prob = get_submv_prob(left, above); | 617 |
618 if (!(k & 3)) { | |
619 VP8Macroblock *left_mb = &mb[-1]; | |
620 left = &left_mb->bmv[vp8_mbsplits[left_mb->partitioning][k + 3]]; | |
621 } else | |
622 left = &mb->bmv[mbsplits[k - 1]]; | |
623 if (k <= 3) { | |
624 VP8Macroblock *above_mb = &mb[-s->mb_stride]; | |
625 above = &above_mb->bmv[vp8_mbsplits[above_mb->partitioning][k + 12]]; | |
626 } else | |
627 above = &mb->bmv[mbsplits[k - 4]]; | |
628 | |
629 submv_prob = get_submv_prob(left, above); | |
616 | 630 |
617 switch (vp8_rac_get_tree(c, vp8_submv_ref_tree, submv_prob)) { | 631 switch (vp8_rac_get_tree(c, vp8_submv_ref_tree, submv_prob)) { |
618 case VP8_SUBMVMODE_NEW4X4: | 632 case VP8_SUBMVMODE_NEW4X4: |
619 part_mv[n].y = base_mv->y + read_mv_component(c, s->prob->mvc[0]); | 633 mb->bmv[n].y = base_mv->y + read_mv_component(c, s->prob->mvc[0]); |
620 part_mv[n].x = base_mv->x + read_mv_component(c, s->prob->mvc[1]); | 634 mb->bmv[n].x = base_mv->x + read_mv_component(c, s->prob->mvc[1]); |
621 break; | 635 break; |
622 case VP8_SUBMVMODE_ZERO4X4: | 636 case VP8_SUBMVMODE_ZERO4X4: |
623 part_mv[n].x = 0; | 637 mb->bmv[n].x = 0; |
624 part_mv[n].y = 0; | 638 mb->bmv[n].y = 0; |
625 break; | 639 break; |
626 case VP8_SUBMVMODE_LEFT4X4: | 640 case VP8_SUBMVMODE_LEFT4X4: |
627 part_mv[n] = *left; | 641 mb->bmv[n] = *left; |
628 break; | 642 break; |
629 case VP8_SUBMVMODE_TOP4X4: | 643 case VP8_SUBMVMODE_TOP4X4: |
630 part_mv[n] = *above; | 644 mb->bmv[n] = *above; |
631 break; | 645 break; |
632 } | 646 } |
633 | 647 } |
634 /* fill out over the 4x4 blocks in MB */ | 648 |
635 for (k = 0; k < 16; k++) | 649 return num; |
636 if (vp8_mbsplits[part_idx][k] == n) { | |
637 mb->bmv[k] = part_mv[n]; | |
638 } | |
639 } | |
640 } | 650 } |
641 | 651 |
642 static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4, | 652 static inline void decode_intra4x4_modes(VP56RangeCoder *c, uint8_t *intra4x4, |
643 int stride, int keyframe) | 653 int stride, int keyframe) |
644 { | 654 { |
696 for (n = 0; n < 4; n++) | 706 for (n = 0; n < 4; n++) |
697 p[n] = vp8_mode_contexts[cnt[n]][n]; | 707 p[n] = vp8_mode_contexts[cnt[n]][n]; |
698 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_mvinter, p); | 708 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_mvinter, p); |
699 switch (mb->mode) { | 709 switch (mb->mode) { |
700 case VP8_MVMODE_SPLIT: | 710 case VP8_MVMODE_SPLIT: |
701 decode_splitmvs(s, c, mb, &best); | 711 mb->mv = mb->bmv[decode_splitmvs(s, c, mb, &best) - 1]; |
702 mb->mv = mb->bmv[15]; | |
703 break; | 712 break; |
704 case VP8_MVMODE_ZERO: | 713 case VP8_MVMODE_ZERO: |
705 mb->mv.x = 0; | 714 mb->mv.x = 0; |
706 mb->mv.y = 0; | 715 mb->mv.y = 0; |
707 break; | 716 break; |
715 mb->mv.y = best.y + read_mv_component(c, s->prob->mvc[0]); | 724 mb->mv.y = best.y + read_mv_component(c, s->prob->mvc[0]); |
716 mb->mv.x = best.x + read_mv_component(c, s->prob->mvc[1]); | 725 mb->mv.x = best.x + read_mv_component(c, s->prob->mvc[1]); |
717 break; | 726 break; |
718 } | 727 } |
719 if (mb->mode != VP8_MVMODE_SPLIT) { | 728 if (mb->mode != VP8_MVMODE_SPLIT) { |
720 for (n = 0; n < 16; n++) | 729 mb->partitioning = VP8_SPLITMVMODE_NONE; |
721 mb->bmv[n] = mb->mv; | 730 mb->bmv[0] = mb->mv; |
722 } | 731 } |
723 } else { | 732 } else { |
724 // intra MB, 16.1 | 733 // intra MB, 16.1 |
725 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16); | 734 mb->mode = vp8_rac_get_tree(c, vp8_pred16x16_tree_inter, s->prob->pred16x16); |
726 | 735 |
1038 } | 1047 } |
1039 case VP8_SPLITMVMODE_16x8: | 1048 case VP8_SPLITMVMODE_16x8: |
1040 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1049 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1041 0, 0, 16, 8, width, height, &mb->bmv[0]); | 1050 0, 0, 16, 8, width, height, &mb->bmv[0]); |
1042 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1051 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1043 0, 8, 16, 8, width, height, &mb->bmv[8]); | 1052 0, 8, 16, 8, width, height, &mb->bmv[1]); |
1044 break; | 1053 break; |
1045 case VP8_SPLITMVMODE_8x16: | 1054 case VP8_SPLITMVMODE_8x16: |
1046 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1055 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1047 0, 0, 8, 16, width, height, &mb->bmv[0]); | 1056 0, 0, 8, 16, width, height, &mb->bmv[0]); |
1048 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1057 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1049 8, 0, 8, 16, width, height, &mb->bmv[2]); | 1058 8, 0, 8, 16, width, height, &mb->bmv[1]); |
1050 break; | 1059 break; |
1051 case VP8_SPLITMVMODE_8x8: | 1060 case VP8_SPLITMVMODE_8x8: |
1052 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1061 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1053 0, 0, 8, 8, width, height, &mb->bmv[0]); | 1062 0, 0, 8, 8, width, height, &mb->bmv[0]); |
1054 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1063 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1055 8, 0, 8, 8, width, height, &mb->bmv[2]); | 1064 8, 0, 8, 8, width, height, &mb->bmv[1]); |
1056 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1065 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1057 0, 8, 8, 8, width, height, &mb->bmv[8]); | 1066 0, 8, 8, 8, width, height, &mb->bmv[2]); |
1058 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, | 1067 vp8_mc_part(s, dst, s->framep[mb->ref_frame], x_off, y_off, |
1059 8, 8, 8, 8, width, height, &mb->bmv[10]); | 1068 8, 8, 8, 8, width, height, &mb->bmv[3]); |
1060 break; | 1069 break; |
1061 } | 1070 } |
1062 } | 1071 } |
1063 | 1072 |
1064 static void idct_mb(VP8Context *s, uint8_t *y_dst, uint8_t *u_dst, uint8_t *v_dst, | 1073 static void idct_mb(VP8Context *s, uint8_t *y_dst, uint8_t *u_dst, uint8_t *v_dst, |