forked from bartvdbraak/blender
code cleanup: video playback move frame step into the PlayState struct.
This commit is contained in:
parent
3d9812c5d1
commit
d4ed5ab92a
@ -89,6 +89,8 @@ typedef struct PlayState {
|
||||
short stopped;
|
||||
short go;
|
||||
|
||||
int fstep;
|
||||
|
||||
/* current picture */
|
||||
struct PlayAnimPict *picture;
|
||||
|
||||
@ -213,7 +215,6 @@ typedef struct PlayAnimPict {
|
||||
|
||||
static struct ListBase picsbase = {NULL, NULL};
|
||||
static int fromdisk = FALSE;
|
||||
static int fstep = 1;
|
||||
static float zoomx = 1.0, zoomy = 1.0;
|
||||
static double ptottime = 0.0, swaptime = 0.04;
|
||||
|
||||
@ -229,7 +230,7 @@ static int pupdate_time(void)
|
||||
return (ptottime < 0);
|
||||
}
|
||||
|
||||
static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid)
|
||||
static void playanim_toscreen(PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep)
|
||||
{
|
||||
|
||||
if (ibuf == NULL) {
|
||||
@ -287,7 +288,7 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
|
||||
int pic;
|
||||
ibuf = IMB_anim_absolute(anim, 0, IMB_TC_NONE, IMB_PROXY_NONE);
|
||||
if (ibuf) {
|
||||
playanim_toscreen(NULL, ibuf, fontid);
|
||||
playanim_toscreen(NULL, ibuf, fontid, fstep);
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
|
||||
@ -390,7 +391,7 @@ static void build_pict_list(char *first, int totframes, int fstep, int fontid)
|
||||
ibuf = IMB_loadiffname(picture->name, picture->IB_flags, NULL);
|
||||
}
|
||||
if (ibuf) {
|
||||
playanim_toscreen(picture, ibuf, fontid);
|
||||
playanim_toscreen(picture, ibuf, fontid, fstep);
|
||||
IMB_freeImBuf(ibuf);
|
||||
}
|
||||
pupdate_time();
|
||||
@ -446,34 +447,34 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
if (val) ps->pingpong = !ps->pingpong;
|
||||
break;
|
||||
case GHOST_kKeyNumpad1:
|
||||
if (val) swaptime = fstep / 60.0;
|
||||
if (val) swaptime = ps->fstep / 60.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad2:
|
||||
if (val) swaptime = fstep / 50.0;
|
||||
if (val) swaptime = ps->fstep / 50.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad3:
|
||||
if (val) swaptime = fstep / 30.0;
|
||||
if (val) swaptime = ps->fstep / 30.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad4:
|
||||
if (g_WS.qual & WS_QUAL_SHIFT)
|
||||
swaptime = fstep / 24.0;
|
||||
swaptime = ps->fstep / 24.0;
|
||||
else
|
||||
swaptime = fstep / 25.0;
|
||||
swaptime = ps->fstep / 25.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad5:
|
||||
if (val) swaptime = fstep / 20.0;
|
||||
if (val) swaptime = ps->fstep / 20.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad6:
|
||||
if (val) swaptime = fstep / 15.0;
|
||||
if (val) swaptime = ps->fstep / 15.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad7:
|
||||
if (val) swaptime = fstep / 12.0;
|
||||
if (val) swaptime = ps->fstep / 12.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad8:
|
||||
if (val) swaptime = fstep / 10.0;
|
||||
if (val) swaptime = ps->fstep / 10.0;
|
||||
break;
|
||||
case GHOST_kKeyNumpad9:
|
||||
if (val) swaptime = fstep / 6.0;
|
||||
if (val) swaptime = ps->fstep / 6.0;
|
||||
break;
|
||||
case GHOST_kKeyLeftArrow:
|
||||
if (val) {
|
||||
@ -531,10 +532,10 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
if (val) {
|
||||
if (g_WS.qual & WS_QUAL_SHIFT) {
|
||||
if (ps->curframe_ibuf)
|
||||
printf(" Name: %s | Speed: %.2f frames/s\n", ps->curframe_ibuf->name, fstep / swaptime);
|
||||
printf(" Name: %s | Speed: %.2f frames/s\n", ps->curframe_ibuf->name, ps->fstep / swaptime);
|
||||
}
|
||||
else {
|
||||
swaptime = fstep / 5.0;
|
||||
swaptime = ps->fstep / 5.0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -675,7 +676,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
|
||||
glPixelZoom(zoomx, zoomy);
|
||||
glEnable(GL_DITHER);
|
||||
ptottime = 0.0;
|
||||
playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid);
|
||||
playanim_toscreen(ps->picture, ps->curframe_ibuf, ps->fontid, ps->fstep);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -747,6 +748,8 @@ void WM_main_playanim(int argc, const char **argv)
|
||||
ps.picture = NULL;
|
||||
/* resetmap = FALSE */
|
||||
|
||||
ps.fstep = 1;
|
||||
|
||||
ps.fontid = -1;
|
||||
|
||||
while (argc > 1) {
|
||||
@ -794,8 +797,8 @@ void WM_main_playanim(int argc, const char **argv)
|
||||
argv++;
|
||||
break;
|
||||
case 'j':
|
||||
fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
|
||||
swaptime *= fstep;
|
||||
ps.fstep = MIN2(MAXFRAME, MAX2(1, atoi(argv[2])));
|
||||
swaptime *= ps.fstep;
|
||||
argc--;
|
||||
argv++;
|
||||
break;
|
||||
@ -894,11 +897,11 @@ void WM_main_playanim(int argc, const char **argv)
|
||||
efra = MAXFRAME;
|
||||
}
|
||||
|
||||
build_pict_list(filepath, (efra - sfra) + 1, fstep, ps.fontid);
|
||||
build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
|
||||
|
||||
for (i = 2; i < argc; i++) {
|
||||
BLI_strncpy(filepath, argv[i], sizeof(filepath));
|
||||
build_pict_list(filepath, (efra - sfra) + 1, fstep, ps.fontid);
|
||||
build_pict_list(filepath, (efra - sfra) + 1, ps.fstep, ps.fontid);
|
||||
}
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
@ -970,7 +973,7 @@ void WM_main_playanim(int argc, const char **argv)
|
||||
|
||||
while (pupdate_time()) PIL_sleep_ms(1);
|
||||
ptottime -= swaptime;
|
||||
playanim_toscreen(ps.picture, ibuf, ps.fontid);
|
||||
playanim_toscreen(ps.picture, ibuf, ps.fontid, ps.fstep);
|
||||
} /* else deleten */
|
||||
else {
|
||||
printf("error: can't play this image type\n");
|
||||
|
Loading…
Reference in New Issue
Block a user