* fixed mvd range.
[swftools.git] / lib / h.263 / swfvideo.c
index e8b420d..4d5e040 100644 (file)
@@ -43,6 +43,8 @@ void swf_SetVideoStreamDefine(TAG*tag, VIDEOSTREAM*stream, U16 frames, U16 width
 #endif
     memset(stream, 0, sizeof(VIDEOSTREAM));
     stream->olinex = width;
+    stream->owidth = width;
+    stream->oheight = height;
     width+=15;width&=~15;
     height+=15;height&=~15;
     stream->linex = width;
@@ -1051,8 +1053,8 @@ static int encode_blockP(TAG*tag, VIDEOSTREAM*s, int bx, int by, int*quant)
        if(s->do_motion) {
            int hx,hy;
            int bestx=0,besty=0,bestbits=65536;
-           int startx=-31,endx=32;
-           int starty=-31,endy=32;
+           int startx=-32,endx=31;
+           int starty=-32,endy=31;
 
            if(!bx) startx=0;
            if(!by) starty=0;
@@ -1292,7 +1294,8 @@ void swf_SetVideoStreamIFrame(TAG*tag, VIDEOSTREAM*s, RGBA*pic, int quant)
 
     writeHeader(tag, s->width, s->height, s->frame, quant, TYPE_IFRAME);
 
-    rgb2yuv(s->current, pic, s->linex, s->olinex, s->width, s->height);
+    memset(s->current, 0, s->linex*s->height*sizeof(YUV));
+    rgb2yuv(s->current, pic, s->linex, s->olinex, s->owidth, s->oheight);
 
     //dostat(s);
 
@@ -1316,7 +1319,8 @@ void swf_SetVideoStreamPFrame(TAG*tag, VIDEOSTREAM*s, RGBA*pic, int quant)
 
     writeHeader(tag, s->width, s->height, s->frame, quant, TYPE_PFRAME);
 
-    rgb2yuv(s->current, pic, s->linex, s->olinex, s->width, s->height);
+    memset(s->current, 0, s->linex*s->height*sizeof(YUV));
+    rgb2yuv(s->current, pic, s->linex, s->olinex, s->owidth, s->oheight);
     memset(s->mvdx, 0, s->bbx*s->bby*sizeof(int));
     memset(s->mvdy, 0, s->bbx*s->bby*sizeof(int));
 
@@ -1379,7 +1383,7 @@ void swf_SetVideoStreamMover(TAG*tag, VIDEOSTREAM*s, int quant)
                int predictmvdx, predictmvdy;
                //int mvx=-1+(2*(s->frame&1));
                //int mvy=-1+((s->frame&2));
-               int mvx=(lrand48()%4)-2;
+               int mvx=0;//(lrand48()%4)-2;
                int mvy=3;
 
                swf_SetBits(tag,0,1); // COD