summaryrefslogtreecommitdiff
path: root/libavcodec/vp3.c
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2009-12-19 07:33:10 +0000
committerMike Melanson <mike@multimedia.cx>2009-12-19 07:33:10 +0000
commite6e32bdc5f3c4b221d330cc9c58cb7ca3d1fd396 (patch)
tree7ac351cbfd3f8ef56847e2468f160b9497be6055 /libavcodec/vp3.c
parentb2cc8111d65c3377ed9f2e1216023c91f7ca45a9 (diff)
Optimize unpack_vectors() by not shuffling around redundant vectors.
Inspired by guidance from Dark Shikari. On a Core 2 Duo 2.0 GHz, this change decodes the 10-minute Big Buck Bunny 1080p short about 2 seconds faster. Originally committed as revision 20895 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/vp3.c')
-rw-r--r--libavcodec/vp3.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 0593d4ec24..d67f91ec2d 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -891,11 +891,6 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
motion_y[0] = fixed_motion_vector_table[get_bits(gb, 6)];
}
- for (k = 1; k < 6; k++) {
- motion_x[k] = motion_x[0];
- motion_y[k] = motion_y[0];
- }
-
/* vector maintenance, only on MODE_INTER_PLUS_MV */
if (s->macroblock_coding[current_macroblock] ==
MODE_INTER_PLUS_MV) {
@@ -946,10 +941,6 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
/* all 6 fragments use the last motion vector */
motion_x[0] = last_motion_x;
motion_y[0] = last_motion_y;
- for (k = 1; k < 6; k++) {
- motion_x[k] = motion_x[0];
- motion_y[k] = motion_y[0];
- }
/* no vector maintenance (last vector remains the
* last vector) */
@@ -960,10 +951,6 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
* last motion vector */
motion_x[0] = prior_last_motion_x;
motion_y[0] = prior_last_motion_y;
- for (k = 1; k < 6; k++) {
- motion_x[k] = motion_x[0];
- motion_y[k] = motion_y[0];
- }
/* vector maintenance */
prior_last_motion_x = last_motion_x;
@@ -974,8 +961,8 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
default:
/* covers intra, inter without MV, golden without MV */
- memset(motion_x, 0, 6 * sizeof(int));
- memset(motion_y, 0, 6 * sizeof(int));
+ motion_x[0] = 0;
+ motion_y[0] = 0;
/* no vector maintenance */
break;
@@ -992,8 +979,13 @@ static int unpack_vectors(Vp3DecodeContext *s, GetBitContext *gb)
current_fragment, s->fragment_count);
return 1;
}
+ if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
s->all_fragments[current_fragment].motion_x = motion_x[k];
s->all_fragments[current_fragment].motion_y = motion_y[k];
+ } else {
+ s->all_fragments[current_fragment].motion_x = motion_x[0];
+ s->all_fragments[current_fragment].motion_y = motion_y[0];
+ }
}
}
}