#include "cl_video.h"
#include "dpvsimpledecode.h"
+// VorteX: JAM video module used by Blood Omnicide
+#define USEJAM
+#ifdef USEJAM
+ #include "cl_video_jamdecode.c"
+#endif
+
// cvars
-cvar_t cl_video_subtitles = {CVAR_SAVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are presented)"};
+cvar_t cl_video_subtitles = {CVAR_SAVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are present)"};
cvar_t cl_video_subtitles_lines = {CVAR_SAVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"};
cvar_t cl_video_subtitles_textsize = {CVAR_SAVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"};
cvar_t cl_video_scale = {CVAR_SAVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."};
-cvar_t cl_video_scale_vpos = {CVAR_SAVE, "cl_video_scale_vpos", "0", "vertial align of scaled video, -1 is top, 1 is bottom"};
+cvar_t cl_video_scale_vpos = {CVAR_SAVE, "cl_video_scale_vpos", "0", "vertical align of scaled video, -1 is top, 1 is bottom"};
cvar_t cl_video_stipple = {CVAR_SAVE, "cl_video_stipple", "0", "draw interlacing-like effect on videos, similar to scr_stipple but static and used only with video playing."};
cvar_t cl_video_brightness = {CVAR_SAVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."};
-cvar_t cl_video_keepaspectratio = {CVAR_SAVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with to & bottom being sliced out"};
+cvar_t cl_video_keepaspectratio = {CVAR_SAVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas, a value of 2 let video to be stretched horizontally with top & bottom being sliced out"};
cvar_t cl_video_fadein = {CVAR_SAVE, "cl_video_fadein", "0", "fading-from-black effect once video is started, in seconds"};
cvar_t cl_video_fadeout = {CVAR_SAVE, "cl_video_fadeout", "0", "fading-to-black effect once video is ended, in seconds"};
static qboolean OpenStream( clvideo_t * video )
{
const char *errorstring;
- video->stream = dpvsimpledecode_open( video->filename, &errorstring);
+ video->stream = dpvsimpledecode_open( video, video->filename, &errorstring);
if (!video->stream )
{
+#ifdef USEJAM
+ video->stream = jam_open( video, video->filename, &errorstring);
+ if (video->stream)
+ return true;
+#endif
Con_Printf("unable to open \"%s\", error: %s\n", video->filename, errorstring);
return false;
}
return true;
}
-static void VideoUpdateCallback(rtexture_t *rt, void *data) {
+static void VideoUpdateCallback(rtexture_t *rt, void *data)
+{
clvideo_t *video = (clvideo_t *) data;
- R_UpdateTexture( video->cpif.tex, (unsigned char *)video->imagedata, 0, 0, video->cpif.width, video->cpif.height );
+ R_UpdateTexture( video->cpif.tex, (unsigned char *)video->imagedata, 0, 0, 0, video->cpif.width, video->cpif.height, 1 );
}
static void LinkVideoTexture( clvideo_t *video )
{
- video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
- video->cpif.width, video->cpif.height, NULL, TEXTYPE_BGRA, TEXF_PERSISTENT | TEXF_CLAMP, -1, NULL );
+ video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name, video->cpif.width, video->cpif.height, NULL, TEXTYPE_BGRA, TEXF_PERSISTENT | TEXF_CLAMP, -1, NULL );
R_MakeTextureDynamic( video->cpif.tex, VideoUpdateCallback, video );
CL_LinkDynTexture( video->cpif.name, video->cpif.tex );
}
-static void UnlinkVideoTexture( clvideo_t *video ) {
+static void UnlinkVideoTexture( clvideo_t *video )
+{
CL_UnlinkDynTexture( video->cpif.name );
// free the texture
R_FreeTexture( video->cpif.tex );
static void SuspendVideo( clvideo_t * video )
{
- if( video->suspended )
+ if (video->suspended)
return;
video->suspended = true;
- UnlinkVideoTexture( video );
+ UnlinkVideoTexture(video);
// if we are in firstframe mode, also close the stream
- if( video->state == CLVIDEO_FIRSTFRAME )
- dpvsimpledecode_close( video->stream );
+ if (video->state == CLVIDEO_FIRSTFRAME)
+ video->close(video->stream);
}
static qboolean WakeVideo( clvideo_t * video )
video->state = CLVIDEO_FIRSTFRAME;
video->framenum = -1;
- video->framerate = dpvsimpledecode_getframerate( video->stream );
+ video->framerate = video->getframerate( video->stream );
video->lasttime = realtime;
video->subtitles = 0;
- video->cpif.width = dpvsimpledecode_getwidth( video->stream );
- video->cpif.height = dpvsimpledecode_getheight( video->stream );
+ video->cpif.width = video->getwidth( video->stream );
+ video->cpif.height = video->getheight( video->stream );
video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
LinkVideoTexture( video );
video->framenum = -1;
// reopen stream
- dpvsimpledecode_close(video->stream);
+ video->close(video->stream);
if (!OpenStream(video))
video->state = CLVIDEO_UNUSED;
}
// close stream
if (!video->suspended || video->state != CLVIDEO_FIRSTFRAME)
- dpvsimpledecode_close(video->stream);
+ video->close(video->stream);
// unlink texture
if (!video->suspended)
UnlinkVideoTexture(video);
{
do {
video->framenum++;
- if (dpvsimpledecode_video(video->stream, video->imagedata, cl_videormask, cl_videogmask, cl_videobmask, cl_videobytesperpixel, cl_videobytesperpixel * video->cpif.width))
+ if (video->decodeframe(video->stream, video->imagedata, cl_videormask, cl_videogmask, cl_videobmask, cl_videobytesperpixel, cl_videobytesperpixel * video->cpif.width))
{
// finished?
CL_RestartVideo(video);
if (cl_video_stipple.integer || px != 0 || py != 0 || sx != vid_conwidth.integer || sy != vid_conheight.integer)
DrawQ_Fill(0, 0, vid_conwidth.integer, vid_conheight.integer, 0, 0, 0, 1, 0);
+#ifndef USE_GLES2
// enable video-only polygon stipple (of global stipple is not active)
if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer)
{
}
qglPolygonStipple(stipple);CHECKGLERROR
}
+#endif
// draw video
DrawQ_SuperPic(px, py, &video->cpif, sx, sy, st[0], st[1], b, b, b, 1, st[2], st[3], b, b, b, 1, st[4], st[5], b, b, b, 1, st[6], st[7], b, b, b, 1, 0);
+#ifndef USE_GLES2
// disable video-only stipple
if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer)
qglDisable(GL_POLYGON_STIPPLE);CHECKGLERROR
+#endif
// VorteX: draw subtitle_text
if (!video->subtitles || !cl_video_subtitles.integer)
static void CL_PlayVideo_f(void)
{
char name[MAX_QPATH], subtitlesfile[MAX_QPATH];
+ const char *extension;
Host_StartVideo();
+ if (COM_CheckParm("-benchmark"))
+ return;
+
if (Cmd_Argc() < 2)
{
Con_Print("usage: playvideo <videoname> [custom_subtitles_file]\nplays video named video/<videoname>.dpv\nif custom subtitles file is not presented\nit tries video/<videoname>.sub");
return;
}
- dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(1));
+ extension = FS_FileExtension(Cmd_Argv(1));
+ if (extension[0])
+ dpsnprintf(name, sizeof(name), "video/%s", Cmd_Argv(1));
+ else
+ dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(1));
if ( Cmd_Argc() > 2)
CL_VideoStart(name, Cmd_Argv(2));
else