X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=dpvsimpledecode.c;h=2cf5e82f6aa45a0d3c0576aed4a87e9677b94c78;hb=cf74e01c006d2937bf1e3a522efc7b2dd0f40ba2;hp=d17ced77d5f4ddbb3601e29810ab606c8e54f08b;hpb=8682421639582094eea9dec3b5b8118335475be1;p=xonotic%2Fdarkplaces.git diff --git a/dpvsimpledecode.c b/dpvsimpledecode.c index d17ced77..2cf5e82f 100644 --- a/dpvsimpledecode.c +++ b/dpvsimpledecode.c @@ -1,4 +1,3 @@ - #include "quakedef.h" #include "dpvsimpledecode.h" @@ -38,7 +37,7 @@ hz_bitstream_read_t *hz_bitstream_read_open(char *filename) { qfile_t *file; hz_bitstream_read_t *stream; - if ((file = FS_Open (filename, "rb", false, false))) + if ((file = FS_OpenVirtualFile(filename, false))) { stream = (hz_bitstream_read_t *)Z_Malloc(sizeof(hz_bitstream_read_t)); memset(stream, 0, sizeof(*stream)); @@ -279,7 +278,6 @@ static int dpvsimpledecode_setpixelformat(dpvsimpledecodestream_t *s, unsigned i default: s->error = DPVSIMPLEDECODEERROR_UNSUPPORTEDBPP; return s->error; - break; } for (Rshift = 0;!(Rmask & 1);Rshift++, Rmask >>= 1); for (Gshift = 0;!(Gmask & 1);Gshift++, Gmask >>= 1); @@ -333,32 +331,8 @@ static int dpvsimpledecode_setpixelformat(dpvsimpledecodestream_t *s, unsigned i // opening and closing streams -static void StripExtension(char *in, char *out) -{ - char *dot, *c; - dot = NULL; - for (c = in;*c;c++) - { - if (*c == ':' || *c == '\\' || *c == '/') - dot = NULL; - if (*c == '.') - dot = c; - } - if (dot == NULL) - { - // nothing to remove - strcpy(out, in); - return; - } - else - { - memcpy(out, in, dot - in); - out[dot - in] = 0; - } -} - // opens a stream -void *dpvsimpledecode_open(char *filename, char **errorstring) +void *dpvsimpledecode_open(clvideo_t *video, char *filename, const char **errorstring) { dpvsimpledecodestream_t *s; char t[8], *wavename; @@ -392,13 +366,16 @@ void *dpvsimpledecode_open(char *filename, char **errorstring) s->videopixels = (unsigned int *)Z_Malloc(s->info_imagewidth * s->info_imageheight * sizeof(*s->videopixels)); if (s->videopixels != NULL) { - wavename = (char *)Z_Malloc(strlen(filename) + 10); + size_t namelen; + + namelen = strlen(filename) + 10; + wavename = (char *)Z_Malloc(namelen); if (wavename) { sfx_t* sfx; - StripExtension(filename, wavename); - strcat(wavename, ".wav"); + FS_StripExtension(filename, wavename, namelen); + strlcat(wavename, ".wav", namelen); sfx = S_PrecacheSound (wavename, false, false); if (sfx != NULL) s->sndchan = S_StartSound (-1, 0, sfx, vec3_origin, 1.0f, 0); @@ -407,7 +384,14 @@ void *dpvsimpledecode_open(char *filename, char **errorstring) Z_Free(wavename); } // all is well... + // set the module functions s->videoframenum = -10000; + video->close = dpvsimpledecode_close; + video->getwidth = dpvsimpledecode_getwidth; + video->getheight = dpvsimpledecode_getheight; + video->getframerate = dpvsimpledecode_getframerate; + video->decodeframe = dpvsimpledecode_video; + return s; } else if (errorstring != NULL) @@ -445,7 +429,7 @@ void dpvsimpledecode_close(void *stream) if (s->videopixels) Z_Free(s->videopixels); if (s->sndchan != -1) - S_StopChannel (s->sndchan); + S_StopChannel (s->sndchan, true, true); if (s->framedatablocks) hz_bitstream_read_blocks_free(s->framedatablocks); if (s->bitstream) @@ -459,7 +443,7 @@ void dpvsimpledecode_close(void *stream) // number to DPVSIMPLEDECODEERROR_NONE // if the supplied string pointer variable is not NULL, it will be set to the // error message -int dpvsimpledecode_error(void *stream, char **errorstring) +int dpvsimpledecode_error(void *stream, const char **errorstring) { dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; int e; @@ -528,10 +512,6 @@ double dpvsimpledecode_getframerate(void *stream) return s->info_framerate; } - - - - static int dpvsimpledecode_convertpixels(dpvsimpledecodestream_t *s, void *imagedata, int imagebytesperrow) { unsigned int a, x, y, width, height;