Pass hr:min:sec:frame.cent to dev_mmcloc() and remove useless

intermediate conversion to 2400-th of second.
This commit is contained in:
Alexandre Ratchov 2016-05-31 11:24:42 +02:00
parent 0798868306
commit 2ce73a1421
2 changed files with 23 additions and 17 deletions

View File

@ -798,25 +798,35 @@ dev_mmcstop(void)
* relocate all slots simultaneously
*/
static void
dev_mmcloc(unsigned int mmc)
dev_mmcloc(int hr, int min, int sec, int fr, int cent, int fps)
{
long long pos;
pos = mmc * dev_rate / MTC_SEC;
pos = dev_rate * hr * 3600 +
dev_rate * min * 60 +
dev_rate * sec +
dev_rate * fr / fps +
dev_rate * cent / (100 * fps);
if (dev_pos == pos)
return;
dev_pos = pos;
if (log_level >= 2) {
log_puts("relocated to ");
log_putu((mmc / (MTC_SEC * 3600)) % 24);
log_putu(hr);
log_puts(":");
log_putu((mmc / (MTC_SEC * 60)) % 60);
log_putu(min);
log_puts(":");
log_putu((mmc / (MTC_SEC)) % 60);
log_putu(sec);
log_puts(".");
log_putu((mmc / (MTC_SEC / 100)) % 100);
log_putu(fr);
log_puts(".");
log_putu((mmc / (MTC_SEC / 100)) % 100);
log_putu(cent);
log_puts(" at ");
log_putu(fps);
log_puts("fps\n");
log_puts("pos: ");
log_putu(pos);
log_puts("\n");
}
if (dev_pstate == DEV_START) {
@ -880,11 +890,12 @@ dev_imsg(unsigned char *msg, unsigned int len)
dev_mmcstop();
return;
}
dev_mmcloc((x->u.loc.hr & 0x1f) * 3600 * MTC_SEC +
x->u.loc.min * 60 * MTC_SEC +
x->u.loc.sec * MTC_SEC +
x->u.loc.fr * (MTC_SEC / fps) +
x->u.loc.cent * (MTC_SEC / 100 / fps));
dev_mmcloc(x->u.loc.hr & 0x1f,
x->u.loc.min,
x->u.loc.sec,
x->u.loc.fr,
x->u.loc.cent,
fps);
break;
}
}

View File

@ -17,11 +17,6 @@
#ifndef DEFS_H
#define DEFS_H
/*
* units used for MTC clock.
*/
#define MTC_SEC 2400 /* 1 second is 2400 ticks */
/*
* limits
*/