Unbreak SMPTE ruler at non-30fps rates. Display 60fps properly. Use the same data types for SMPTE::Time.rate and dropframe as are used in Config.
git-svn-id: svn://localhost/ardour2/trunk@1198 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
3039691723
commit
6146d6aa6f
@ -281,6 +281,9 @@ Session::sample_to_smpte( nframes_t sample, SMPTE::Time& smpte, bool use_offset,
|
||||
if (!use_subframes) {
|
||||
smpte.subframes = 0;
|
||||
}
|
||||
/* set frame rate and drop frame */
|
||||
smpte.rate = Config->get_smpte_frames_per_second ();
|
||||
smpte.drop = Config->get_smpte_drop_frames();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -31,28 +31,18 @@ enum Wrap {
|
||||
HOURS
|
||||
};
|
||||
|
||||
/** SMPTE frame rate (in frames per second).
|
||||
*
|
||||
* This should be eliminated in favour of a float to support arbitrary rates.
|
||||
*/
|
||||
enum FPS {
|
||||
MTC_24_FPS = 0,
|
||||
MTC_25_FPS = 1,
|
||||
MTC_30_FPS_DROP = 2,
|
||||
MTC_30_FPS = 3
|
||||
};
|
||||
|
||||
struct Time {
|
||||
bool negative;
|
||||
uint32_t hours;
|
||||
uint32_t minutes;
|
||||
uint32_t seconds;
|
||||
uint32_t frames; ///< SMPTE frames (not audio samples)
|
||||
uint32_t subframes; ///< Typically unused
|
||||
FPS rate; ///< Frame rate of this Time
|
||||
static FPS default_rate; ///< Rate to use for default constructor
|
||||
uint32_t frames; ///< SMPTE frames (not audio samples)
|
||||
uint32_t subframes; ///< Typically unused
|
||||
float rate; ///< Frame rate of this Time
|
||||
static float default_rate;///< Rate to use for default constructor
|
||||
bool drop; ///< Whether this Time uses dropframe SMPTE
|
||||
|
||||
Time(FPS a_rate = default_rate) {
|
||||
Time(float a_rate = default_rate) {
|
||||
negative = false;
|
||||
hours = 0;
|
||||
minutes = 0;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
namespace SMPTE {
|
||||
|
||||
FPS Time::default_rate = MTC_30_FPS;
|
||||
float Time::default_rate = 30.0;
|
||||
|
||||
|
||||
/** Increment @a smpte by exactly one frame (keep subframes value).
|
||||
@ -51,34 +51,42 @@ increment( Time& smpte )
|
||||
}
|
||||
return wrap;
|
||||
}
|
||||
|
||||
switch (smpte.rate) {
|
||||
case MTC_24_FPS:
|
||||
|
||||
switch ((int)ceil(smpte.rate)) {
|
||||
case 24:
|
||||
if (smpte.frames == 23) {
|
||||
smpte.frames = 0;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
case MTC_25_FPS:
|
||||
case 25:
|
||||
if (smpte.frames == 24) {
|
||||
smpte.frames = 0;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
case MTC_30_FPS_DROP:
|
||||
if (smpte.frames == 29) {
|
||||
if ( ((smpte.minutes + 1) % 10) && (smpte.seconds == 59) ) {
|
||||
smpte.frames = 2;
|
||||
}
|
||||
else {
|
||||
smpte.frames = 0;
|
||||
}
|
||||
wrap = SECONDS;
|
||||
case 30:
|
||||
if (smpte.drop) {
|
||||
if (smpte.frames == 29) {
|
||||
if ( ((smpte.minutes + 1) % 10) && (smpte.seconds == 59) ) {
|
||||
smpte.frames = 2;
|
||||
}
|
||||
else {
|
||||
smpte.frames = 0;
|
||||
}
|
||||
wrap = SECONDS;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (smpte.frames == 29) {
|
||||
smpte.frames = 0;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MTC_30_FPS:
|
||||
if (smpte.frames == 29) {
|
||||
smpte.frames = 0;
|
||||
case 60:
|
||||
if (smpte.frames == 59) {
|
||||
smpte.frames = 0;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
@ -127,33 +135,41 @@ decrement( Time& smpte )
|
||||
return SECONDS;
|
||||
}
|
||||
|
||||
switch (smpte.rate) {
|
||||
case MTC_24_FPS:
|
||||
switch ((int)ceil(smpte.rate)) {
|
||||
case 24:
|
||||
if (smpte.frames == 0) {
|
||||
smpte.frames = 23;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
case MTC_25_FPS:
|
||||
case 25:
|
||||
if (smpte.frames == 0) {
|
||||
smpte.frames = 24;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
case MTC_30_FPS_DROP:
|
||||
if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
|
||||
if (smpte.frames <= 2) {
|
||||
smpte.frames = 29;
|
||||
case 30:
|
||||
if (smpte.drop) {
|
||||
if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
|
||||
if (smpte.frames <= 2) {
|
||||
smpte.frames = 29;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
} else if (smpte.frames == 0) {
|
||||
smpte.frames = 29;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (smpte.frames == 0) {
|
||||
smpte.frames = 29;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
} else if (smpte.frames == 0) {
|
||||
smpte.frames = 29;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
case MTC_30_FPS:
|
||||
if (smpte.frames == 0) {
|
||||
smpte.frames = 29;
|
||||
case 60:
|
||||
if (smpte.frames == 0) {
|
||||
smpte.frames = 59;
|
||||
wrap = SECONDS;
|
||||
}
|
||||
break;
|
||||
@ -275,17 +291,19 @@ increment_seconds( Time& smpte )
|
||||
}
|
||||
} else {
|
||||
// Go to highest possible frame in this second
|
||||
switch (smpte.rate) {
|
||||
case MTC_24_FPS:
|
||||
switch ((int)ceil(smpte.rate)) {
|
||||
case 24:
|
||||
smpte.frames = 23;
|
||||
break;
|
||||
case MTC_25_FPS:
|
||||
case 25:
|
||||
smpte.frames = 24;
|
||||
break;
|
||||
case MTC_30_FPS_DROP:
|
||||
case MTC_30_FPS:
|
||||
case 30:
|
||||
smpte.frames = 29;
|
||||
break;
|
||||
case 60:
|
||||
smpte.frames = 59;
|
||||
break;
|
||||
}
|
||||
|
||||
// Increment by one frame
|
||||
@ -305,17 +323,20 @@ seconds_floor( Time& smpte )
|
||||
frames_floor( smpte );
|
||||
|
||||
// Go to lowest possible frame in this second
|
||||
switch (smpte.rate) {
|
||||
case MTC_24_FPS:
|
||||
case MTC_25_FPS:
|
||||
case MTC_30_FPS:
|
||||
smpte.frames = 0;
|
||||
break;
|
||||
case MTC_30_FPS_DROP:
|
||||
if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
|
||||
smpte.frames = 2;
|
||||
switch ((int)ceil(smpte.rate)) {
|
||||
case 24:
|
||||
case 25:
|
||||
case 30:
|
||||
case 60:
|
||||
if (!(smpte.drop)) {
|
||||
smpte.frames = 0;
|
||||
} else {
|
||||
smpte.frames = 0;
|
||||
|
||||
if ((smpte.minutes % 10) && (smpte.seconds == 0)) {
|
||||
smpte.frames = 2;
|
||||
} else {
|
||||
smpte.frames = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user