changeset 11472:258d773b8feb libavcodec

vp3: we only need a temp MV array of size 4
author conrad
date Sat, 13 Mar 2010 05:56:11 +0000
parents 623074220038
children 8b6722b58f15
files vp3.c
diffstat 1 files changed, 6 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/vp3.c	Sat Mar 13 05:56:08 2010 +0000
+++ b/vp3.c	Sat Mar 13 05:56:11 2010 +0000
@@ -608,8 +608,8 @@
 {
     int j, k, sb_x, sb_y;
     int coding_mode;
-    int motion_x[6];
-    int motion_y[6];
+    int motion_x[4];
+    int motion_y[4];
     int last_motion_x = 0;
     int last_motion_y = 0;
     int prior_last_motion_x = 0;
@@ -620,9 +620,6 @@
     if (s->keyframe)
         return 0;
 
-    memset(motion_x, 0, 6 * sizeof(int));
-    memset(motion_y, 0, 6 * sizeof(int));
-
     /* coding mode 0 is the VLC scheme; 1 is the fixed code scheme */
     coding_mode = get_bits1(gb);
 
@@ -670,7 +667,6 @@
 
                 /* fetch 4 vectors from the bitstream, one for each
                  * Y fragment, then average for the C fragment vectors */
-                motion_x[4] = motion_y[4] = 0;
                 for (k = 0; k < 4; k++) {
                     current_fragment = BLOCK_Y*s->fragment_width + BLOCK_X;
                     if (s->all_fragments[current_fragment].coding_method != MODE_COPY) {
@@ -687,14 +683,7 @@
                         motion_x[k] = 0;
                         motion_y[k] = 0;
                     }
-                    motion_x[4] += motion_x[k];
-                    motion_y[4] += motion_y[k];
                 }
-
-                motion_x[5]=
-                motion_x[4]= RSHIFT(motion_x[4], 2);
-                motion_y[5]=
-                motion_y[4]= RSHIFT(motion_y[4], 2);
                 break;
 
             case MODE_INTER_LAST_MV:
@@ -740,16 +729,15 @@
                     s->all_fragments[current_fragment].motion_y = motion_y[0];
                 }
             }
+                if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
+                    motion_x[0] = RSHIFT(motion_x[0] + motion_x[1] + motion_x[2] + motion_x[3], 2);
+                    motion_y[0] = RSHIFT(motion_y[0] + motion_y[1] + motion_y[2] + motion_y[3], 2);
+                }
             for (k = 0; k < 2; k++) {
                 current_fragment = s->fragment_start[k+1] +
                     mb_y*(s->fragment_width>>1) + mb_x;
-                if (s->macroblock_coding[current_macroblock] == MODE_INTER_FOURMV) {
-                    s->all_fragments[current_fragment].motion_x = motion_x[k+4];
-                    s->all_fragments[current_fragment].motion_y = motion_y[k+4];
-                } else {
                     s->all_fragments[current_fragment].motion_x = motion_x[0];
                     s->all_fragments[current_fragment].motion_y = motion_y[0];
-                }
             }
         }
         }