X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=avi2swf%2Fv2swf.c;h=a8244b4ba42eb321e20a30240392309cae0a9aa8;hb=c98051785717925e8afb55626f88211b8e7a691d;hp=a536c088ff29ac54fb272850450664a390ad2acd;hpb=6e6c53e5b76e2d8e213cf84bb3acd412767cd1e2;p=swftools.git diff --git a/avi2swf/v2swf.c b/avi2swf/v2swf.c index a536c08..a8244b4 100644 --- a/avi2swf/v2swf.c +++ b/avi2swf/v2swf.c @@ -39,6 +39,7 @@ typedef struct _v2swf_internal_t ringbuffer_t r; videoreader_t* video; + double video_fps; int width; int height; @@ -81,6 +82,8 @@ typedef struct _v2swf_internal_t int prescale; int scale; + + int add_cut; int domotion; @@ -413,8 +416,22 @@ static void finish(v2swf_internal_t*i) if(!i->finished) { msg("write endtag\n", i->finished); + if(i->add_cut) { + swf_ResetTag(i->tag, ST_SHOWFRAME); + i->filesize += swf_WriteTag2(&i->out, i->tag); + + swf_ResetTag(i->tag, ST_REMOVEOBJECT2); + swf_SetU16(i->tag, 1); //depth + i->filesize += swf_WriteTag2(&i->out, i->tag); + + swf_ResetTag(i->tag, ST_DOACTION); + swf_SetU16(i->tag, 0x0007); + i->filesize += swf_WriteTag2(&i->out, i->tag); + } + swf_ResetTag(i->tag, ST_END); i->filesize += swf_WriteTag2(&i->out, i->tag); + i->out.finish(&i->out); if(i->version>=6) { @@ -571,6 +588,11 @@ static void scaleimage(v2swf_internal_t*i) int xv,yv; int xm = (i->video->width*65536)/i->width; int ym = (i->video->height*65536)/i->height; + msg("scaling from %dx%d to %dx%d\n", + i->video->width, i->video->height, + i->width, i->height + ); + memset(i->buffer, 255, i->width*i->height*4); for(y=0,yv=0;yheight;y++,yv+=ym) { int*src = &((int*)i->vrbuffer)[(yv>>16)*i->video->width]; @@ -635,8 +657,6 @@ static int encodeoneframe(v2swf_internal_t*i) writeShowFrame(i); } - msg("scaling\n"); - scaleimage(i); msg("version is %d\n", i->version); @@ -826,17 +846,19 @@ int v2swf_init(v2swf_t*v2swf, videoreader_t * video) msg("video: %dx%d, fps %f\n", video->width, video->height, video->fps); i->video = video; + i->video_fps = ((int)(video->fps*256))/256.0; i->blockdiff = 64; i->keyframe_interval = 8; i->quality = 20; i->scale = 65536; + i->add_cut = 1; i->samplerate = 11025; i->prescale = 0; i->head_done = 0; i->diffmode = DIFFMODE_QMEAN; i->audio_fix = 1.0; i->fixheader = 0; - i->framerate = video->fps; + i->framerate = i->video_fps; i->fpsratio = 1.00000000000; i->fpspos = 0.0; i->bitrate = 32; @@ -911,6 +933,8 @@ void v2swf_setparameter(v2swf_t*v2swf, char*name, char*value) i->version = atoi(value); } else if(!strcmp(name, "audiosync")) { i->audio_fix = (int)(atof(value)); + } else if(!strcmp(name, "addcut")) { + i->add_cut = atoi(value); } else if(!strcmp(name, "scale")) { i->scale = (int)(atof(value)*65536); } else if(!strcmp(name, "scale65536")) { @@ -929,7 +953,7 @@ void v2swf_setparameter(v2swf_t*v2swf, char*name, char*value) i->samplerate = atoi(value); } else if(!strcmp(name, "framerate")) { i->framerate = atof(value); - i->fpsratio = i->framerate / i->video->fps; + i->fpsratio = i->framerate / i->video_fps; } else if(!strcmp(name, "mp3_bitrate")) { int t=0,o;