+ // calc video proportions
+ px = 0;
+ py = 0;
+ sx = vid_conwidth.integer;
+ sy = vid_conheight.integer;
+ st[0] = 0.0; st[1] = 0.0;
+ st[2] = 1.0; st[3] = 0.0;
+ st[4] = 0.0; st[5] = 1.0;
+ st[6] = 1.0; st[7] = 1.0;
+ if (cl_video_keepaspectratio.integer)
+ {
+ float a = video->getaspectratio(video->stream) / ((float)vid.width / (float)vid.height);
+ if (cl_video_keepaspectratio.integer >= 2)
+ {
+ // clip instead of scale
+ if (a < 1.0) // clip horizontally
+ {
+ st[1] = st[3] = (1 - a)*0.5;
+ st[5] = st[7] = 1 - (1 - a)*0.5;
+ }
+ else if (a > 1.0) // clip vertically
+ {
+ st[0] = st[4] = (1 - 1/a)*0.5;
+ st[2] = st[6] = (1/a)*0.5;
+ }
+ }
+ else if (a < 1.0) // scale horizontally
+ {
+ px += sx * (1 - a) * 0.5;
+ sx *= a;
+ }
+ else if (a > 1.0) // scale vertically
+ {
+ a = 1 / a;
+ py += sy * (1 - a);
+ sy *= a;
+ }
+ }
+
+ if (cl_video_scale.value != 1)
+ {
+ px += sx * (1 - cl_video_scale.value) * 0.5;
+ py += sy * (1 - cl_video_scale.value) * ((bound(-1, cl_video_scale_vpos.value, 1) + 1) / 2);
+ sx *= cl_video_scale.value;
+ sy *= cl_video_scale.value;
+ }
+
+ // calc brightness for fadein and fadeout effects
+ b = cl_video_brightness.value;
+ if (cl_video_fadein.value && (realtime - video->starttime) < cl_video_fadein.value)
+ b = pow((realtime - video->starttime)/cl_video_fadein.value, 2);
+ else if (cl_video_fadeout.value && ((video->starttime + video->framenum * video->framerate) - realtime) < cl_video_fadeout.value)
+ b = pow(((video->starttime + video->framenum * video->framerate) - realtime)/cl_video_fadeout.value, 2);
+