20 #if defined(AJA_MAC) || defined(AJA_LINUX) || defined(AJA_BAREMETAL)
51 m_stdTcForHfr(bStdTcForHfr)
57 : m_stdTcForHfr(bStdTcForHfr)
59 Set(str.c_str(), timeBase, bDropFrame);
65 Set(str.c_str(), timeBase);
70 m_frame = other.m_frame;
71 m_stdTcForHfr = other.m_stdTcForHfr;
83 bool bHasSemicolon = str.find(
";", 0) != string::npos;
89 return (
int)::strlen(
"00:00:00:00") + 1;
99 return (uint32_t)(f + .5);
104 return (((x)>=0)?(x):-(x));
109 int64_t frameRate, frameRate2, frameDuration;
113 frameRate2 = frameRate;
124 if (frameRate == 0 || frameDuration == 0)
131 double dFrameRate = double(frameRate2) / double(frameDuration);
135 uint32_t hourFrames = tb*60*60;
136 uint32_t minuteFrames = tb*60;
137 uint32_t totalMinutes = (60*h) + m;
140 if ( (s == 0) && ((m % 10) > 0) && ((f & ~1) == 0))
143 frame = ((hourFrames * h) + (minuteFrames * m) + (tb * s) + f) - (dropFrames * (totalMinutes - (totalMinutes / 10)));
147 double dFrameRate = double(frameRate2) / double(frameDuration);
150 uint32_t hourFrames = tb*60*60;
151 uint32_t minuteFrames = tb*60;
153 frame = ((hourFrames * h) + (minuteFrames * m) + (tb * s) + f);
165 frame += bStdTcForHfr ? addFrame : 0;
173 int64_t frameRate,frameDuration;
176 uint32_t remainder = 0;
180 remainder = frame % 4;
186 remainder = frame % 2;
191 if (frameRate == 0 || frameDuration == 0 || frameRate < frameDuration)
198 double dFrameRate = double(frameRate) / double(frameDuration);
202 uint32_t framesPerMin = framesPerSec * 60;
203 uint32_t framesPerHr = framesPerMin * 60;
204 uint32_t framesPerDay = framesPerHr * 24;
209 frame = frame % framesPerDay;
212 h = uint32_t(frame / framesPerHr);
213 frame = frame % framesPerHr;
216 m = uint32_t(frame / framesPerMin);
217 frame = frame % framesPerMin;
220 s = uint32_t(frame / framesPerSec);
223 f = uint32_t(frame % framesPerSec);
229 uint32_t dropFramesPerSec = framesPerSec - droppedFrames;
230 uint32_t dropframesPerMin = (59 * framesPerSec) + dropFramesPerSec;
231 uint32_t dropframesPerTenMin = (9 * dropframesPerMin) + framesPerMin;
232 uint32_t dropframesPerHr = dropframesPerTenMin * 6;
233 uint32_t dropframesPerDay = dropframesPerHr * 24;
236 frame = frame % dropframesPerDay;
239 h = uint32_t(frame / dropframesPerHr);
240 frame = frame % dropframesPerHr;
243 m = uint32_t(10 * (frame / dropframesPerTenMin));
244 frame = frame % dropframesPerTenMin;
247 if (frame >= framesPerMin)
250 frame = frame - framesPerMin;
253 m += uint32_t(frame / dropframesPerMin);
254 frame = frame % dropframesPerMin;
262 s = uint32_t(frame / framesPerSec);
263 frame = frame % framesPerSec;
268 if (frame >= dropFramesPerSec)
271 frame = frame - dropFramesPerSec;
274 s += uint32_t(frame / framesPerSec);
275 frame = frame % framesPerSec;
283 if ( (s == 0) && (m % 10 != 0))
295 uint32_t remainder =
CalcHmsf(h, m, s, f, m_frame, timeBase, bDropFrame, m_stdTcForHfr);
301 uint32_t h = 0,m = 0,s = 0,f = 0;
302 uint32_t r =
CalcHmsf(h,m,s,f,m_frame,timeBase,bDropFrame,bStdTcForHfr);
304 char delim = bDropFrame ?
';' :
':';
305 std::ostringstream oss;
313 oss << setfill(
'0') << setw(2) << h << delim
314 << setfill(
'0') << setw(2) << m << delim
315 << setfill(
'0') << setw(2) << s << delim
316 << setfill(
'0') << setw(2) << f;
320 oss << setfill(
'0') << setw(2) << h << delim
321 << setfill(
'0') << setw(2) << m << delim
322 << setfill(
'0') << setw(2) << s << (r == 0 ? delim :
'.')
323 << setfill(
'0') << setw(2) << f;
327 oss << setfill(
'0') << setw(2) << h << delim
328 << setfill(
'0') << setw(2) << m << delim
329 << setfill(
'0') << setw(2) << s << (r <= 1 ? delim :
'.')
330 << setfill(
'0') << setw(2) << f;
337 oss << setfill(
'0') << setw(2) << h << delim
338 << setfill(
'0') << setw(2) << m << delim
339 << setfill(
'0') << setw(2) << s <<
'#'
340 << setfill(
'0') << setw(2) << f;
344 oss << setfill(
'0') << setw(2) << h << delim
345 << setfill(
'0') << setw(2) << m << delim
346 << setfill(
'0') << setw(2) << s <<
'#'
347 << setfill(
'0') << setw(3) << f;
355 oss << setfill(
'0') << setw(2) << h <<
':'
356 << setfill(
'0') << setw(2) << m <<
':'
357 << setfill(
'0') << setw(2) << s << delim
358 << setfill(
'0') << setw(2) << f;
364 oss << setfill(
'0') << setw(2) << h <<
':'
365 << setfill(
'0') << setw(2) << m <<
':'
366 << setfill(
'0') << setw(2) << s << delim
367 << setfill(
'0') << setw(2) << f;
371 oss << setfill(
'0') << setw(2) << h <<
':'
372 << setfill(
'0') << setw(2) << m <<
':'
373 << setfill(
'0') << setw(2) << s << delim
374 << setfill(
'0') << setw(3) << f;
378 str.assign(oss.str());
383 QueryString(str, timeBase, bDropFrame, m_stdTcForHfr, notation);
386 #if !defined(NTV2_DEPRECATE_17_5)
391 strncpy(pString, s.c_str(), s.length());
394 #endif // NTV2_DEPRECATE_17_5
403 uint32_t h=0, m=0, s=0, f=0;
404 uint32_t r =
CalcHmsf(h,m,s,f,m_frame,timeBase,bDrop,m_stdTcForHfr);
407 pBufr[0] = ((f/10) << 4) + (f % 10);
408 pBufr[1] = ((s/10) << 4) + (s % 10);
409 pBufr[2] = ((m/10) << 4) + (m % 10);
410 pBufr[3] = ((h/10) << 4) + (h % 10);
412 pBufr[0] = pBufr[0] | 0x40;
427 uint32_t frame =
CalcFrame(h, m, s, f, timeBase, bDropFrame, bStdTcForHfr, addFrame);
434 uint32_t frame =
CalcFrame(h, m, s, f, timeBase, bDropFrame, m_stdTcForHfr, 0);
441 const int valCount = 4;
442 uint32_t val[valCount];
443 ::memset(val,0,
sizeof(val));
448 size_t len = str.length();
452 int stdTcForHfr = m_stdTcForHfr;
455 for (
size_t i = 0; i < len; i++)
457 char theChar = str[len - i - 1];
458 if (::isdigit(theChar))
460 val[valOffset] = val[valOffset] + ((theChar -
'0') * valMult);
485 uint32_t frame =
CalcFrame(val[3], val[2], val[1], val[0], timeBase, bDropFrame, stdTcForHfr, addFrame);
492 Set(str, timeBase, bDropFrame);
500 int results[4] = {0, 0, 0, 0};
501 char delim[3] = {0, 0, 0};
503 uint32_t addFrame = 0;
506 for (
size_t i = str.length() - 1; i >= 0 && index >= 0; )
519 if (start > 0 && index > 0)
520 delim[index-1] = str[start - 1];
523 std::string numberStr = str.substr(start, i - start + 1);
532 bool stdTcForHfr = m_stdTcForHfr;
533 char lastDelim = delim[2];
535 if (lastDelim ==
'#')
539 if (fps >= 100 && stdTcForHfr ==
true && lastDelim ==
'.')
541 else if (fps >= 48 && stdTcForHfr ==
true && lastDelim ==
'.')
544 uint32_t frame =
CalcFrame(results[0], results[1], results[2], results[3], timeBase, bDrop, stdTcForHfr, addFrame);
555 uint32_t f = (((pBufr[0] & 0x30) >> 4) * 10) + (pBufr[0] & 0x0f);
556 uint32_t s = (((pBufr[1] & 0x70) >> 4) * 10) + (pBufr[1] & 0x0f);
557 uint32_t m = (((pBufr[2] & 0x70) >> 4) * 10) + (pBufr[2] & 0x0f);
558 uint32_t h = (((pBufr[3] & 0x30) >> 4) * 10) + (pBufr[3] & 0x0f);
560 SetHmsf(h,m,s,f,timeBase,bDrop);
567 return (inLo >> 10) & 0x01;
575 const uint32_t h0 (((inHi >> 16) & 0xF) );
576 const uint32_t h1 (((inHi >> 24) & 0x3) * 10);
578 const uint32_t m0 (((inHi ) & 0xF) );
579 const uint32_t m1 (((inHi >> 8) & 0x7) * 10);
581 const uint32_t s0 (((inLo >> 16) & 0xF) );
582 const uint32_t s1 (((inLo >> 24) & 0x7) * 10);
596 fieldID = ((inHi & (1u<<27)) != 0);
598 fieldID = ((inLo & (1u<<27)) != 0);
601 const uint32_t numFrames = (((((inLo >> 8) & 0x3) * 10) + (inLo & 0xF)) * 2) + uint32_t(fieldID);
603 f1 = (numFrames / 10) * 10;
607 f0 = ((inLo ) & 0xF);
608 f1 = ((inLo >> 8) & 0x3) * 10;
611 SetHmsf (h0+h1, m0+m1, s0+s1, f0+f1, inTimeBase, bDrop);
614 #if !defined(NTV2_DEPRECATE_17_5)
617 uint32_t dbb(0), low(0), high(0);
619 if (*pDbb) *pDbb = dbb;
620 if (*pLow) *pLow = low;
621 if (*pHigh) *pHigh = high;
623 #endif // !defined(NTV2_DEPRECATE_17_5)
647 m_frame = val.m_frame;
648 m_stdTcForHfr = val.m_stdTcForHfr;
658 bool bIsSame =
false;
659 if (m_frame == val.m_frame)
671 bool bIsLess = (m_frame < val.m_frame);
677 bool bIsLess = (m_frame < (uint32_t)val);
687 bool bIsGreater = (m_frame > val.m_frame);
693 bool bIsGreater = (m_frame > (uint32_t)val);
703 return !(*
this == val);
711 m_frame += val.m_frame;
726 if(val.m_frame > m_frame)
729 m_frame -= val.m_frame;
736 if((uint32_t)val > m_frame)