X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=lib%2Fh.263%2Fswfvideo.c;h=1d2615224eabafdc69258076f018b771edf88044;hb=7e0ffeacc5c5976d85488d5bc39e512db39936b3;hp=94b3d254d3da8211658226eae960198cb536698f;hpb=6da849f3320df43086c3d3cc01b162ea9c7dc847;p=swftools.git diff --git a/lib/h.263/swfvideo.c b/lib/h.263/swfvideo.c index 94b3d25..1d26152 100644 --- a/lib/h.263/swfvideo.c +++ b/lib/h.263/swfvideo.c @@ -38,10 +38,13 @@ void swf_SetVideoStreamDefine(TAG*tag, VIDEOSTREAM*stream, U16 frames, U16 width swf_SetU8(tag, 0); /* smoothing off */ swf_SetU8(tag, 2); /* codec = h.263 sorenson spark */ +#ifdef MAIN totalframes = frames; - +#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; @@ -250,7 +253,10 @@ static void dct2(int*src, int*dest) innerdct(a,b,cc); } for(t=0;t<64;t++) { - dest[zigzagtable[t]] = (int)(tmp2[t]); + int v = (int)(tmp2[t]); + if(v>127) v=127; + if(v<-127) v=-127; + dest[zigzagtable[t]] = v; } } @@ -935,6 +941,9 @@ static void predictmvd(VIDEOSTREAM*s, int bx, int by, int*px, int*py) } else if((x1 <= x3 && x3 <= x2) || (x2 <= x3 && x3 <= x1)) { x4=x3; + } else { + x4=0; + assert(x4); } if((y1 <= y2 && y2 <= y3) || @@ -946,6 +955,9 @@ static void predictmvd(VIDEOSTREAM*s, int bx, int by, int*px, int*py) } else if((y1 <= y3 && y3 <= y2) || (y2 <= y3 && y3 <= y1)) { y4=y3; + } else { + y4=0; + assert(y4); } *px = x4; @@ -1041,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=-2,endx=2; - int starty=-2,endy=2; + int startx=-31,endx=32; + int starty=-31,endy=32; if(!bx) startx=0; if(!by) starty=0; @@ -1282,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); @@ -1306,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));