added missing include.
[swftools.git] / avi2swf / v2swf.c
index 312fcf7..2caed7b 100644 (file)
@@ -168,7 +168,7 @@ static void writeShape(v2swf_internal_t*i, int id, int gfxid, int width, int hei
 static int getSamples(videoreader_t*video, S16*data, int len, double speedup)
 {
     double pos = 0;
-    double ratio = (double) video->rate * speedup / swf_mp3_in_samplerate;
+    double ratio = (double) video->samplerate * speedup / swf_mp3_in_samplerate;
     int rlen = (int)(len * ratio);
     int t;
     S16 tmp[576*32];
@@ -209,7 +209,7 @@ static void writeAudioForOneFrame(v2swf_internal_t* i)
 
     msg("writeAudioForOneFrame()");
 
-    if(i->video->channels<=0 || i->video->rate<=0)
+    if(i->video->channels<=0 || i->video->samplerate<=0)
        return; /* no sound in video */
 
     blocksize = (i->samplerate > 22050) ? 1152 : 576;
@@ -229,7 +229,7 @@ static void writeAudioForOneFrame(v2swf_internal_t* i)
        /* The pre-processing of sound samples in getSamples(..) above
           re-samples the sound to swf_mp3_in_samplerate. It is best to
           simply make it the original samplerate:  */
-       swf_mp3_in_samplerate = i->video->rate;
+       swf_mp3_in_samplerate = i->video->samplerate;
 
        /* first run - initialize */
        swf_mp3_channels = 1;//i->video->channels;
@@ -268,7 +268,7 @@ static void writeAudioForOneFrame(v2swf_internal_t* i)
     /* write num frames, max 1 block */
     for(pos=0;pos<num;pos++) {
         if(!getSamples(i->video, block1, blocksize * (double)swf_mp3_in_samplerate/swf_mp3_out_samplerate, speedup)) {
-           i->video->rate = i->video->channels = 0; //end of soundtrack
+           i->video->samplerate = i->video->channels = 0; //end of soundtrack
            return;
        }
        if(!pos) {
@@ -584,18 +584,16 @@ static int encodeoneframe(v2swf_internal_t*i)
        return 0;
     }
 
-    i->fpspos += i->fpsratio;
-
-    /* skip frames */
-    if(i->fpspos<1.0) {
-       return 0;
-    }
-    
     msg("encoding image for frame %d\n", i->frames);
-
-    if(i->showframe)
+    if(i->showframe) {
+       i->fpspos += i->fpsratio;
+       /* skip frames */
+       if(i->fpspos<1.0) {
+           return 0;
+       }
        writeShowFrame(i);
-
+    }
+    
     msg("scaling\n");
 
     scaleimage(i);
@@ -798,7 +796,7 @@ int v2swf_init(v2swf_t*v2swf, videoreader_t * video)
     i->audio_fix = 1.0;
     i->fixheader = 0;
     i->framerate = video->fps;
-    i->fpsratio = 1.00000000;
+    i->fpsratio = 1.00000000000;
     i->fpspos = 0.0;
     i->bitrate = 32;
     i->version = 6;
@@ -972,29 +970,6 @@ void v2swf_backpatch(v2swf_t*v2swf, char*filename)
     }
 }
 
-float v2swf_getprogress(v2swf_t*v2swf)
-{
-    float* p;
-    v2swf_internal_t* i;
-    msg("v2swf_getprogress()");
-    if(!v2swf || !v2swf->internal) {
-       return 0.0;
-    }
-    i = (v2swf_internal_t*)v2swf->internal;
-
-    p = (float*)videoreader_getinfo(i->video, "position");
-
-    if(p) {
-       return *p;
-    } else {
-       float f = i->frames/1500.0; /*fake*/
-       if(f>1.0)
-           return 1.0;
-       else
-           return f;
-    }
-}
-
 void v2swf_setvideoparameter(videoreader_t*v, char*name, char*value)
 {
     msg("v2swf_setvideoparameter()");