]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - cl_video.c
cvar "cl_video_keepaspectratio" which scales fullscreen video to keep original aspect...
[xonotic/darkplaces.git] / cl_video.c
1
2 #include "quakedef.h"
3 #include "cl_dyntexture.h"
4 #include "cl_video.h"
5 #include "dpvsimpledecode.h"
6
7 // cvars
8 cvar_t cl_video_subtitles = {CVAR_SAVE, "cl_video_subtitles", "0", "show subtitles for videos (if they are presented)"};
9 cvar_t cl_video_subtitles_lines = {CVAR_SAVE, "cl_video_subtitles_lines", "4", "how many lines to occupy for subtitles"};
10 cvar_t cl_video_subtitles_textsize = {CVAR_SAVE, "cl_video_subtitles_textsize", "16", "textsize for subtitles"};
11 cvar_t cl_video_scale = {CVAR_SAVE, "cl_video_scale", "1", "scale of video, 1 = fullscreen, 0.75 - 3/4 of screen etc."};
12 cvar_t cl_video_scale_vpos = {CVAR_SAVE, "cl_video_scale_vpos", "0", "vertial align of scaled video, -1 is top, 1 is bottom"};
13 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."};
14 cvar_t cl_video_brightness = {CVAR_SAVE, "cl_video_brightness", "1", "brightness of video, 1 = fullbright, 0.75 - 3/4 etc."};
15 cvar_t cl_video_keepaspectratio = {CVAR_SAVE, "cl_video_keepaspectratio", "0", "keeps aspect ratio of fullscreen videos, leaving black color on unfilled areas"};
16
17 // constants (and semi-constants)
18 static int  cl_videormask;
19 static int  cl_videobmask;
20 static int  cl_videogmask;
21 static int      cl_videobytesperpixel;
22
23 static int cl_num_videos;
24 static clvideo_t cl_videos[ MAXCLVIDEOS ];
25 static rtexturepool_t *cl_videotexturepool;
26
27 static clvideo_t *FindUnusedVid( void )
28 {
29         int i;
30         for( i = 1 ; i < MAXCLVIDEOS ; i++ )
31                 if( cl_videos[ i ].state == CLVIDEO_UNUSED )
32                         return &cl_videos[ i ];
33         return NULL;
34 }
35
36 static qboolean OpenStream( clvideo_t * video )
37 {
38         const char *errorstring;
39         video->stream = dpvsimpledecode_open( video->filename, &errorstring);
40         if (!video->stream )
41         {
42                 Con_Printf("unable to open \"%s\", error: %s\n", video->filename, errorstring);
43                 return false;
44         }
45         return true;
46 }
47
48 static void VideoUpdateCallback(rtexture_t *rt, void *data) {
49         clvideo_t *video = (clvideo_t *) data;
50         R_UpdateTexture( video->cpif.tex, (unsigned char *)video->imagedata, 0, 0, video->cpif.width, video->cpif.height );
51 }
52
53 static void LinkVideoTexture( clvideo_t *video )
54 {
55         video->cpif.tex = R_LoadTexture2D( cl_videotexturepool, video->cpif.name,
56                 video->cpif.width, video->cpif.height, NULL, TEXTYPE_BGRA, TEXF_PERSISTENT | TEXF_CLAMP, -1, NULL );
57         R_MakeTextureDynamic( video->cpif.tex, VideoUpdateCallback, video );
58         CL_LinkDynTexture( video->cpif.name, video->cpif.tex );
59 }
60
61 static void UnlinkVideoTexture( clvideo_t *video ) {
62         CL_UnlinkDynTexture( video->cpif.name );
63         // free the texture
64         R_FreeTexture( video->cpif.tex );
65         // free the image data
66         Mem_Free( video->imagedata );
67 }
68
69 static void SuspendVideo( clvideo_t * video )
70 {
71         if( video->suspended )
72                 return;
73         video->suspended = true;
74         UnlinkVideoTexture( video );
75         // if we are in firstframe mode, also close the stream
76         if( video->state == CLVIDEO_FIRSTFRAME )
77                 dpvsimpledecode_close( video->stream );
78 }
79
80 static qboolean WakeVideo( clvideo_t * video )
81 {
82         if( !video->suspended )
83                 return true;
84         video->suspended = false;
85
86         if( video->state == CLVIDEO_FIRSTFRAME )
87                 if( !OpenStream( video ) ) {
88                         video->state = CLVIDEO_UNUSED;
89                         return false;
90                 }
91
92         video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
93         LinkVideoTexture( video );
94
95         // update starttime
96         video->starttime += realtime - video->lasttime;
97
98         return true;
99 }
100
101 static void LoadSubtitles( clvideo_t *video, const char *subtitlesfile )
102 {
103         char *subtitle_text;
104         const char *data;
105         float subtime, sublen;
106         int numsubs = 0;
107
108         if (gamemode == GAME_BLOODOMNICIDE)
109         {
110                 char overridename[MAX_QPATH];
111                 cvar_t *langcvar;
112
113                 langcvar = Cvar_FindVar("language");
114                 subtitle_text = NULL;
115                 if (langcvar)
116                 {
117                         dpsnprintf(overridename, sizeof(overridename), "script/locale/%s/%s", langcvar->string, subtitlesfile);
118                         subtitle_text = (char *)FS_LoadFile(overridename, cls.permanentmempool, false, NULL);
119                 }
120                 if (!subtitle_text)
121                         subtitle_text = (char *)FS_LoadFile(subtitlesfile, cls.permanentmempool, false, NULL);
122         }
123         else
124         {
125                 subtitle_text = (char *)FS_LoadFile(subtitlesfile, cls.permanentmempool, false, NULL);
126         }
127         if (!subtitle_text)
128         {
129                 Con_DPrintf( "LoadSubtitles: can't open subtitle file '%s'!\n", subtitlesfile );
130                 return;
131         }
132
133         // parse subtitle_text
134         // line is: x y "text" where
135         //    x - start time
136         //    y - seconds last (if 0 - last thru next sub, if negative - last to next sub - this amount of seconds)
137
138         data = subtitle_text;
139         for (;;)
140         {
141                 if (!COM_ParseToken_QuakeC(&data, false))
142                         break;
143                 subtime = atof( com_token );
144                 if (!COM_ParseToken_QuakeC(&data, false))
145                         break;
146                 sublen = atof( com_token );
147                 if (!COM_ParseToken_QuakeC(&data, false))
148                         break;
149                 if (!com_token[0])
150                         continue;
151                 // check limits
152                 if (video->subtitles == CLVIDEO_MAX_SUBTITLES)
153                 {
154                         Con_Printf("WARNING: CLVIDEO_MAX_SUBTITLES = %i reached when reading subtitles from '%s'\n", CLVIDEO_MAX_SUBTITLES, subtitlesfile);
155                         break;  
156                 }
157                 // add a sub
158                 video->subtitle_text[numsubs] = (char *) Mem_Alloc(cls.permanentmempool, strlen(com_token) + 1);
159                 memcpy(video->subtitle_text[numsubs], com_token, strlen(com_token) + 1);
160                 video->subtitle_start[numsubs] = subtime;
161                 video->subtitle_end[numsubs] = sublen;
162                 if (numsubs > 0) // make true len for prev sub, autofix overlapping subtitles
163                 {
164                         if (video->subtitle_end[numsubs-1] <= 0)
165                                 video->subtitle_end[numsubs-1] = max(video->subtitle_start[numsubs-1], video->subtitle_start[numsubs] + video->subtitle_end[numsubs-1]);
166                         else
167                                 video->subtitle_end[numsubs-1] = min(video->subtitle_start[numsubs-1] + video->subtitle_end[numsubs-1], video->subtitle_start[numsubs]);
168                 }
169                 numsubs++;
170                 // todo: check timing for consistency?
171         }
172         if (numsubs > 0) // make true len for prev sub, autofix overlapping subtitles
173         {
174                 if (video->subtitle_end[numsubs-1] <= 0)
175                         video->subtitle_end[numsubs-1] = 99999999; // fixme: make it end when video ends?
176                 else
177                         video->subtitle_end[numsubs-1] = video->subtitle_start[numsubs-1] + video->subtitle_end[numsubs-1];
178         }
179         Z_Free( subtitle_text );
180         video->subtitles = numsubs;
181 /*
182         Con_Printf( "video->subtitles: %i\n", video->subtitles );
183         for (numsubs = 0; numsubs < video->subtitles; numsubs++)
184                 Con_Printf( "  %03.2f %03.2f : %s\n", video->subtitle_start[numsubs], video->subtitle_end[numsubs], video->subtitle_text[numsubs] );
185 */
186 }
187
188 static clvideo_t* OpenVideo( clvideo_t *video, const char *filename, const char *name, int owner, const char *subtitlesfile )
189 {
190         strlcpy( video->filename, filename, sizeof(video->filename) );
191         video->ownertag = owner;
192         if( strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) )
193                 return NULL;
194         strlcpy( video->cpif.name, name, sizeof(video->cpif.name) );
195
196         if( !OpenStream( video ) )
197                 return NULL;
198
199         video->state = CLVIDEO_FIRSTFRAME;
200         video->framenum = -1;
201         video->framerate = dpvsimpledecode_getframerate( video->stream );
202         video->lasttime = realtime;
203         video->subtitles = 0;
204
205         video->cpif.width = dpvsimpledecode_getwidth( video->stream );
206         video->cpif.height = dpvsimpledecode_getheight( video->stream );
207         video->imagedata = Mem_Alloc( cls.permanentmempool, video->cpif.width * video->cpif.height * cl_videobytesperpixel );
208         LinkVideoTexture( video );
209
210         // VorteX: load simple subtitle_text file
211         if (subtitlesfile[0])
212                 LoadSubtitles( video, subtitlesfile );
213
214         return video;
215 }
216
217 clvideo_t* CL_OpenVideo( const char *filename, const char *name, int owner, const char *subtitlesfile )
218 {
219         clvideo_t *video;
220         // sanity check
221         if( !name || !*name || strncmp( name, CLVIDEOPREFIX, sizeof( CLVIDEOPREFIX ) - 1 ) != 0 ) {
222                 Con_DPrintf( "CL_OpenVideo: Bad video texture name '%s'!\n", name );
223                 return NULL;
224         }
225
226         video = FindUnusedVid();
227         if( !video ) {
228                 Con_Printf( "CL_OpenVideo: unable to open video \"%s\" - video limit reached\n", filename );
229                 return NULL;
230         }
231         video = OpenVideo( video, filename, name, owner, subtitlesfile );
232         // expand the active range to include the new entry
233         if (video) {
234                 cl_num_videos = max(cl_num_videos, (int)(video - cl_videos) + 1);
235         }
236         return video;
237 }
238
239 static clvideo_t* CL_GetVideoBySlot( int slot )
240 {
241         clvideo_t *video = &cl_videos[ slot ];
242
243         if( video->suspended )
244         {
245                 if( !WakeVideo( video ) )
246                         return NULL;
247                 else if( video->state == CLVIDEO_RESETONWAKEUP )
248                         video->framenum = -1;
249         }
250
251         video->lasttime = realtime;
252
253         return video;
254 }
255
256 clvideo_t *CL_GetVideoByName( const char *name )
257 {
258         int i;
259
260         for( i = 0 ; i < cl_num_videos ; i++ )
261                 if( cl_videos[ i ].state != CLVIDEO_UNUSED
262                         &&      !strcmp( cl_videos[ i ].cpif.name , name ) )
263                         break;
264         if( i != cl_num_videos )
265                 return CL_GetVideoBySlot( i );
266         else
267                 return NULL;
268 }
269
270 void CL_SetVideoState( clvideo_t *video, clvideostate_t state )
271 {
272         if( !video )
273                 return;
274
275         video->lasttime = realtime;
276         video->state = state;
277         if( state == CLVIDEO_FIRSTFRAME )
278                 CL_RestartVideo( video );
279 }
280
281 void CL_RestartVideo( clvideo_t *video )
282 {
283         if( !video )
284                 return;
285
286         video->starttime = video->lasttime = realtime;
287         video->framenum = -1;
288
289         dpvsimpledecode_close( video->stream );
290         if( !OpenStream( video ) )
291                 video->state = CLVIDEO_UNUSED;
292 }
293
294 void CL_CloseVideo( clvideo_t * video )
295 {
296         int i;
297
298         if( !video || video->state == CLVIDEO_UNUSED )
299                 return;
300
301         if( !video->suspended || video->state != CLVIDEO_FIRSTFRAME )
302                 dpvsimpledecode_close( video->stream );
303         if( !video->suspended )
304                 UnlinkVideoTexture( video );
305         if (video->subtitles)
306         {
307                 for (i = 0; i < video->subtitles; i++)
308                         Z_Free( video->subtitle_text[i] );
309                 video->subtitles = 0;
310         }
311
312         video->state = CLVIDEO_UNUSED;
313 }
314
315 static void VideoFrame( clvideo_t *video )
316 {
317         int destframe;
318
319         if( video->state == CLVIDEO_FIRSTFRAME )
320                 destframe = 0;
321         else
322                 destframe = (int)((realtime - video->starttime) * video->framerate);
323         if( destframe < 0 )
324                 destframe = 0;
325         if( video->framenum < destframe ) {
326                 do {
327                         video->framenum++;
328                         if( dpvsimpledecode_video( video->stream, video->imagedata, cl_videormask,
329                                 cl_videogmask, cl_videobmask, cl_videobytesperpixel,
330                                 cl_videobytesperpixel * video->cpif.width )
331                                 ) { // finished?
332                                 CL_RestartVideo( video );
333                                 if( video->state == CLVIDEO_PLAY )
334                                                 video->state = CLVIDEO_FIRSTFRAME;
335                                 return;
336                         }
337                 } while( video->framenum < destframe );
338                 R_MarkDirtyTexture( video->cpif.tex );
339         }
340 }
341
342 void CL_Video_Frame( void ) // update all videos
343 {
344         int i;
345         clvideo_t *video;
346
347         if (!cl_num_videos)
348                 return;
349
350         for( video = cl_videos, i = 0 ; i < cl_num_videos ; video++, i++ )
351                 if( video->state != CLVIDEO_UNUSED && !video->suspended )
352                 {
353                         if( realtime - video->lasttime > CLTHRESHOLD )
354                                 SuspendVideo( video );
355                         else if( video->state == CLVIDEO_PAUSE )
356                                 video->starttime = realtime - video->framenum * video->framerate;
357                         else
358                                 VideoFrame( video );
359                 }
360
361         if( cl_videos->state == CLVIDEO_FIRSTFRAME )
362                 CL_VideoStop();
363
364         // reduce range to exclude unnecessary entries
365         while (cl_num_videos > 0 && cl_videos[cl_num_videos-1].state == CLVIDEO_UNUSED)
366                 cl_num_videos--;
367 }
368
369 void CL_Video_Shutdown( void )
370 {
371         int i;
372         for( i = 0 ; i < cl_num_videos ; i++ )
373                 CL_CloseVideo( &cl_videos[ i ] );
374 }
375
376 void CL_PurgeOwner( int owner )
377 {
378         int i;
379         for( i = 0 ; i < cl_num_videos ; i++ )
380                 if( cl_videos[ i ].ownertag == owner )
381                         CL_CloseVideo( &cl_videos[ i ] );
382 }
383
384 typedef struct
385 {
386         dp_font_t *font;
387         float x;
388         float y;
389         float width;
390         float height;
391         float alignment; // 0 = left, 0.5 = center, 1 = right
392         float fontsize;
393         float textalpha;
394 }
395 cl_video_subtitle_info_t;
396
397 float CL_DrawVideo_WordWidthFunc(void *passthrough, const char *w, size_t *length, float maxWidth)
398 {
399         cl_video_subtitle_info_t *si = (cl_video_subtitle_info_t *) passthrough;
400
401         if(w == NULL)
402                 return si->fontsize * si->font->maxwidth;
403         if(maxWidth >= 0)
404                 return DrawQ_TextWidth_UntilWidth(w, length, si->fontsize, si->fontsize, false, si->font, -maxWidth); // -maxWidth: we want at least one char
405         else if(maxWidth == -1)
406                 return DrawQ_TextWidth(w, *length, si->fontsize, si->fontsize, false, si->font);
407         else
408                 return 0;
409 }
410
411 int CL_DrawVideo_DisplaySubtitleLine(void *passthrough, const char *line, size_t length, float width, qboolean isContinuation)
412 {
413         cl_video_subtitle_info_t *si = (cl_video_subtitle_info_t *) passthrough;
414
415         int x = (int) (si->x + (si->width - width) * si->alignment);
416         if (length > 0)
417                 DrawQ_String(x, si->y, line, length, si->fontsize, si->fontsize, 1.0, 1.0, 1.0, si->textalpha, 0, NULL, false, si->font);
418         si->y += si->fontsize;
419         return 1;
420 }
421
422 int cl_videoplaying = false; // old, but still supported
423
424 void CL_DrawVideo(void)
425 {
426         clvideo_t *video;
427         float videotime, px, py, sx, sy;
428         cl_video_subtitle_info_t si;
429         int i;
430
431         if (!cl_videoplaying)
432                 return;
433
434         video = CL_GetVideoBySlot( 0 );
435
436         // fix cvars
437         if (cl_video_scale.value <= 0 || cl_video_scale.value > 1)
438                 Cvar_SetValueQuick( &cl_video_scale, 1);
439         if (cl_video_brightness.value <= 0 || cl_video_brightness.value > 10)
440                 Cvar_SetValueQuick( &cl_video_brightness, 1);
441
442         // calc video proportions
443         px = 0;
444         py = 0;
445         sx = vid_conwidth.integer;
446         sy = vid_conheight.integer;
447         if (cl_video_keepaspectratio.integer)
448         {
449                 float a = ((float)video->cpif.width / (float)video->cpif.height) / ((float)vid.width / (float)vid.height);
450                 Con_Printf("%f\n", a);
451                 if (a < 1.0) // scale horizontally
452                 {
453                         px += sx * (1 - a) * 0.5;
454                         sx *= a;
455                 }
456                 else if (a > 1.0) // scale vertically
457                 {
458                         a = 1 / a;
459                         py += sy * (1 - a);
460                         sy *= a;
461                 }
462         }
463         if (cl_video_scale.value != 1)
464         {
465                 px += sx * (1 - cl_video_scale.value) * 0.5;
466                 py += sy * (1 - cl_video_scale.value) * ((bound(-1, cl_video_scale_vpos.value, 1) + 1) / 2);
467                 sx *= cl_video_scale.value;
468                 sy *= cl_video_scale.value;
469         }
470
471         // draw black bg in case stipple is active or video is scaled
472         if (cl_video_stipple.integer || px != 0 || py != 0 || sx != vid_conwidth.integer || sy != vid_conheight.integer)
473                 DrawQ_Fill(0, 0, vid_conwidth.integer, vid_conheight.integer, 0, 0, 0, 1, 0);
474
475         // enable video-only polygon stipple (of global stipple is not active)
476         if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer)
477         {
478                 GLubyte stipple[128];
479                 int i, s, width, parts;
480         
481                 s = cl_video_stipple.integer;
482                 parts = (s & 007);
483                 width = (s & 070) >> 3;
484                 qglEnable(GL_POLYGON_STIPPLE);CHECKGLERROR // 0x0B42
485                 for(i = 0; i < 128; ++i)
486                 {
487                         int line = i/4;
488                         stipple[i] = ((line >> width) & ((1 << parts) - 1)) ? 0x00 : 0xFF;
489                 }
490                 qglPolygonStipple(stipple);CHECKGLERROR
491         }
492
493         // draw video
494         DrawQ_Pic(px, py, &video->cpif, sx, sy, cl_video_brightness.value, cl_video_brightness.value, cl_video_brightness.value, 1, 0);
495
496         // disable video-only stipple
497         if (qglPolygonStipple && !scr_stipple.integer && cl_video_stipple.integer)
498                 qglDisable(GL_POLYGON_STIPPLE);CHECKGLERROR
499
500         // VorteX: draw subtitle_text
501         if (!video->subtitles || !cl_video_subtitles.integer)
502                 return;
503
504         // find current subtitle
505         videotime = realtime - video->starttime;
506         for (i = 0; i < video->subtitles; i++)
507         {
508                 if (videotime >= video->subtitle_start[i] && videotime <= video->subtitle_end[i])
509                 {
510                         // found, draw it
511                         si.font = FONT_NOTIFY;
512                         si.x = vid_conwidth.integer * 0.1;
513                         si.y = vid_conheight.integer - (max(1, cl_video_subtitles_lines.value) * cl_video_subtitles_textsize.value);
514                         si.width = vid_conwidth.integer * 0.8;
515                         si.height = max(1, cl_video_subtitles_lines.integer) * cl_video_subtitles_textsize.value;
516                         si.alignment = 0.5;
517                         si.fontsize = cl_video_subtitles_textsize.value;
518                         si.textalpha = min(1, (videotime - video->subtitle_start[i])/0.5) * min(1, ((video->subtitle_end[i] - videotime)/0.3)); // fade in and fade out
519                         COM_Wordwrap(video->subtitle_text[i], strlen(video->subtitle_text[i]), 0, si.width, CL_DrawVideo_WordWidthFunc, &si, CL_DrawVideo_DisplaySubtitleLine, &si);
520                         break;
521                 }
522         }
523 }
524
525 void CL_VideoStart(char *filename, const char *subtitlesfile)
526 {
527         Host_StartVideo();
528
529         if( cl_videos->state != CLVIDEO_UNUSED )
530                 CL_CloseVideo( cl_videos );
531         // already contains video/
532         if( !OpenVideo( cl_videos, filename, va( CLDYNTEXTUREPREFIX "%s", filename ), 0, subtitlesfile ) )
533                 return;
534         // expand the active range to include the new entry
535         cl_num_videos = max(cl_num_videos, 1);
536
537         cl_videoplaying = true;
538
539         CL_SetVideoState( cl_videos, CLVIDEO_PLAY );
540         CL_RestartVideo( cl_videos );
541 }
542
543 void CL_Video_KeyEvent( int key, int ascii, qboolean down ) 
544 {
545         // only react to up events, to allow the user to delay the abortion point if it suddenly becomes interesting..
546         if( !down ) {
547                 if( key == K_ESCAPE || key == K_ENTER || key == K_SPACE ) {
548                         CL_VideoStop();
549                 }
550         }
551 }
552
553 void CL_VideoStop(void)
554 {
555         cl_videoplaying = false;
556
557         CL_CloseVideo( cl_videos );
558 }
559
560 static void CL_PlayVideo_f(void)
561 {
562         char name[MAX_QPATH], subtitlesfile[MAX_QPATH];
563
564         Host_StartVideo();
565
566         if (Cmd_Argc() < 2)
567         {
568                 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");
569                 return;
570         }
571
572         dpsnprintf(name, sizeof(name), "video/%s.dpv", Cmd_Argv(1));
573         if ( Cmd_Argc() > 2)
574                 CL_VideoStart(name, Cmd_Argv(2));
575         else
576         {
577                 dpsnprintf(subtitlesfile, sizeof(subtitlesfile), "video/%s.dpsubs", Cmd_Argv(1));
578                 CL_VideoStart(name, subtitlesfile);
579         }
580 }
581
582 static void CL_StopVideo_f(void)
583 {
584         CL_VideoStop();
585 }
586
587 static void cl_video_start( void )
588 {
589         int i;
590         clvideo_t *video;
591
592         cl_videotexturepool = R_AllocTexturePool();
593
594         for( video = cl_videos, i = 0 ; i < cl_num_videos ; i++, video++ )
595                 if( video->state != CLVIDEO_UNUSED && !video->suspended )
596                         LinkVideoTexture( video );
597 }
598
599 static void cl_video_shutdown( void )
600 {
601         // TODO: unlink video textures?
602         R_FreeTexturePool( &cl_videotexturepool );
603 }
604
605 static void cl_video_newmap( void )
606 {
607 }
608
609 void CL_Video_Init( void )
610 {
611         union
612         {
613                 unsigned char b[4];
614                 unsigned int i;
615         }
616         bgra;
617
618         cl_num_videos = 0;
619         cl_videobytesperpixel = 4;
620
621         // set masks in an endian-independent way (as they really represent bytes)
622         bgra.i = 0;bgra.b[0] = 0xFF;cl_videobmask = bgra.i;
623         bgra.i = 0;bgra.b[1] = 0xFF;cl_videogmask = bgra.i;
624         bgra.i = 0;bgra.b[2] = 0xFF;cl_videormask = bgra.i;
625
626         Cmd_AddCommand( "playvideo", CL_PlayVideo_f, "play a .dpv video file" );
627         Cmd_AddCommand( "stopvideo", CL_StopVideo_f, "stop playing a .dpv video file" );
628
629         Cvar_RegisterVariable(&cl_video_subtitles);
630         Cvar_RegisterVariable(&cl_video_subtitles_lines);
631         Cvar_RegisterVariable(&cl_video_subtitles_textsize);
632         Cvar_RegisterVariable(&cl_video_scale);
633         Cvar_RegisterVariable(&cl_video_scale_vpos);
634         Cvar_RegisterVariable(&cl_video_brightness);
635         Cvar_RegisterVariable(&cl_video_stipple);
636         Cvar_RegisterVariable(&cl_video_keepaspectratio);
637
638         R_RegisterModule( "CL_Video", cl_video_start, cl_video_shutdown, cl_video_newmap, NULL, NULL );
639 }