X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=cap_avi.c;h=e7cf88d675f9cf363a5876d7c0b4f2fec8fcf8b5;hb=8c5f851b4148a19dff450267a93f6f37912df00a;hp=e9b0d286147b9768db67aa06cd4fef3b35b9840f;hpb=b2bc40de23857c762b317d4b02230246e142ff48;p=xonotic%2Fdarkplaces.git diff --git a/cap_avi.c b/cap_avi.c index e9b0d286..e7cf88d6 100644 --- a/cap_avi.c +++ b/cap_avi.c @@ -52,6 +52,18 @@ static void SCR_CaptureVideo_RIFF_Flush(void) } } +static void SCR_CaptureVideo_RIFF_FlushNoIncrease(void) +{ + LOAD_FORMATSPECIFIC_AVI(); + if (format->riffbuffer.cursize > 0) + { + if (!FS_Write(cls.capturevideo.videofile, format->riffbuffer.data, format->riffbuffer.cursize)) + cls.capturevideo.error = true; + format->riffbuffer.cursize = 0; + format->riffbuffer.overflowed = false; + } +} + static void SCR_CaptureVideo_RIFF_WriteBytes(const unsigned char *data, size_t size) { LOAD_FORMATSPECIFIC_AVI(); @@ -245,13 +257,13 @@ static void SCR_CaptureVideo_RIFF_MakeIxChunk(const char *fcc, const char *dwChu SCR_CaptureVideo_RIFF_Write32(((fs_offset_t) ix) >> 32); SCR_CaptureVideo_RIFF_Write32(pos - ix); SCR_CaptureVideo_RIFF_Write32(nMatching); - SCR_CaptureVideo_RIFF_Flush(); + SCR_CaptureVideo_RIFF_FlushNoIncrease(); } if(FS_Seek(cls.capturevideo.videofile, masteridx_counter, SEEK_SET) >= 0) { SCR_CaptureVideo_RIFF_Write32(++*masteridx_count); - SCR_CaptureVideo_RIFF_Flush(); + SCR_CaptureVideo_RIFF_FlushNoIncrease(); } FS_Seek(cls.capturevideo.videofile, 0, SEEK_END); // return value doesn't matter here @@ -285,7 +297,7 @@ static void SCR_CaptureVideo_RIFF_Finish(qboolean final) if(FS_Seek(cls.capturevideo.videofile, format->videofile_firstchunkframes_offset, SEEK_SET) >= 0) { SCR_CaptureVideo_RIFF_Write32(cls.capturevideo.frame); - SCR_CaptureVideo_RIFF_Flush(); + SCR_CaptureVideo_RIFF_FlushNoIncrease(); } FS_Seek(cls.capturevideo.videofile, 0, SEEK_END); format->videofile_firstchunkframes_offset = 0; @@ -297,7 +309,8 @@ static void SCR_CaptureVideo_RIFF_Finish(qboolean final) static void SCR_CaptureVideo_RIFF_OverflowCheck(int framesize) { LOAD_FORMATSPECIFIC_AVI(); - fs_offset_t cursize, curfilesize; + fs_offset_t cursize; + //fs_offset_t curfilesize; if (format->riffstacklevel != 2) Sys_Error("SCR_CaptureVideo_RIFF_OverflowCheck: chunk stack leakage!\n"); @@ -307,7 +320,7 @@ static void SCR_CaptureVideo_RIFF_OverflowCheck(int framesize) // check where we are in the file SCR_CaptureVideo_RIFF_Flush(); cursize = SCR_CaptureVideo_RIFF_GetPosition() - format->riffstackstartoffset[0]; - curfilesize = SCR_CaptureVideo_RIFF_GetPosition(); + //curfilesize = SCR_CaptureVideo_RIFF_GetPosition(); // if this would overflow the windows limit of 1GB per RIFF chunk, we need // to close the current RIFF chunk and open another for future frames @@ -391,7 +404,7 @@ static void SCR_CaptureVideo_Avi_VideoFrames(int num) } } -void SCR_CaptureVideo_Avi_EndVideo() +void SCR_CaptureVideo_Avi_EndVideo(void) { LOAD_FORMATSPECIFIC_AVI(); @@ -405,13 +418,13 @@ void SCR_CaptureVideo_Avi_EndVideo() if(FS_Seek(cls.capturevideo.videofile, format->videofile_totalframes_offset1, SEEK_SET) >= 0) { SCR_CaptureVideo_RIFF_Write32(cls.capturevideo.frame); - SCR_CaptureVideo_RIFF_Flush(); + SCR_CaptureVideo_RIFF_FlushNoIncrease(); } if(format->videofile_totalframes_offset2) if(FS_Seek(cls.capturevideo.videofile, format->videofile_totalframes_offset2, SEEK_SET) >= 0) { SCR_CaptureVideo_RIFF_Write32(cls.capturevideo.frame); - SCR_CaptureVideo_RIFF_Flush(); + SCR_CaptureVideo_RIFF_FlushNoIncrease(); } if (cls.capturevideo.soundrate) { @@ -419,7 +432,7 @@ void SCR_CaptureVideo_Avi_EndVideo() if(FS_Seek(cls.capturevideo.videofile, format->videofile_totalsampleframes_offset, SEEK_SET) >= 0) { SCR_CaptureVideo_RIFF_Write32(cls.capturevideo.soundsampleframe); - SCR_CaptureVideo_RIFF_Flush(); + SCR_CaptureVideo_RIFF_FlushNoIncrease(); } } } @@ -482,7 +495,7 @@ void SCR_CaptureVideo_Avi_SoundFrame(const portable_sampleframe_t *paintbuffer, } } -void SCR_CaptureVideo_Avi_BeginVideo() +void SCR_CaptureVideo_Avi_BeginVideo(void) { int width = cls.capturevideo.width; int height = cls.capturevideo.height; @@ -508,7 +521,7 @@ void SCR_CaptureVideo_Avi_BeginVideo() // AVI main header SCR_CaptureVideo_RIFF_Push("LIST", "hdrl", format->canseek ? -1 : 8+56+12+(12+52+8+40+8+68)+(cls.capturevideo.soundrate?(12+12+52+8+18):0)+12+(8+4)); SCR_CaptureVideo_RIFF_Push("avih", NULL, 56); - SCR_CaptureVideo_RIFF_Write32((int)(1000000.0 / cls.capturevideo.framerate)); // microseconds per frame + SCR_CaptureVideo_RIFF_Write32((int)(1000000.0 / (cls.capturevideo.framerate / cls.capturevideo.framestep))); // microseconds per frame SCR_CaptureVideo_RIFF_Write32(0); // max bytes per second SCR_CaptureVideo_RIFF_Write32(0); // padding granularity SCR_CaptureVideo_RIFF_Write32(0x910); // flags (AVIF_HASINDEX | AVIF_ISINTERLEAVED | AVIF_TRUSTCKTYPE) @@ -536,7 +549,7 @@ void SCR_CaptureVideo_Avi_BeginVideo() SCR_CaptureVideo_RIFF_Write16(0); // language SCR_CaptureVideo_RIFF_Write32(0); // initial frames // find an ideal divisor for the framerate - FindFraction(cls.capturevideo.framerate, &n, &d, 1000); + FindFraction(cls.capturevideo.framerate / cls.capturevideo.framestep, &n, &d, 1000); SCR_CaptureVideo_RIFF_Write32(d); // samples/second divisor SCR_CaptureVideo_RIFF_Write32(n); // samples/second multiplied by divisor SCR_CaptureVideo_RIFF_Write32(0); // start @@ -585,7 +598,7 @@ void SCR_CaptureVideo_Avi_BeginVideo() SCR_CaptureVideo_RIFF_Push("vprp", NULL, 68); SCR_CaptureVideo_RIFF_Write32(0); // VideoFormatToken SCR_CaptureVideo_RIFF_Write32(0); // VideoStandard - SCR_CaptureVideo_RIFF_Write32((int)cls.capturevideo.framerate); // dwVerticalRefreshRate (bogus) + SCR_CaptureVideo_RIFF_Write32((int)(cls.capturevideo.framerate / cls.capturevideo.framestep)); // dwVerticalRefreshRate (bogus) SCR_CaptureVideo_RIFF_Write32(width); // dwHTotalInT SCR_CaptureVideo_RIFF_Write32(height); // dwVTotalInLines FindFraction(aspect, &n, &d, 1000);