MCPcopy Create free account
hub / github.com/MediaArea/MediaInfoLib / ToString

Method ToString

Source/MediaInfo/TimeCode.cpp:748–818  ·  view source on GitHub ↗

---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

746
747//---------------------------------------------------------------------------
748string TimeCode::ToString() const
749{
750 if (!IsValid())
751 return {};
752 string FrameMaxS = to_string(GetFramesMax());
753 auto FrameMax_Length = FrameMaxS.size();
754 if (FrameMax_Length < 2)
755 FrameMax_Length = 2;
756 auto d = IsDropFrame();
757 auto t = IsTimed();
758 if (!IsSet())
759 {
760 string TC("--:--:--");
761 TC += t ? '.' : (d ? ';' : ':');
762 TC.append(FrameMax_Length, '-');
763 return TC;
764 }
765 string TC;
766 TC = to_string(GetHours());
767 if (TC.size() == 1)
768 TC.insert(0, 1, '0');
769 if (IsNegative())
770 TC.insert(0, 1, '-');
771 TC += ':';
772 auto MM = GetMinutes();
773 TC += ('0' + MM / 10);
774 TC += ('0' + MM % 10);
775 TC += ':';
776 auto SS = GetSeconds();
777 TC += ('0' + SS / 10);
778 TC += ('0' + SS % 10);
779 if (!GetFramesMax())
780 return TC;
781 TC += t ? '.' : (d ? ';' : ':');
782 if (t)
783 {
784 int AfterCommaMinus1;
785 AfterCommaMinus1 = PowersOf10_Size;
786 uint64_t FrameRate = (uint64_t)GetFramesMax() + 1;
787 while ((--AfterCommaMinus1) >= 0 && PowersOf10[AfterCommaMinus1] != FrameRate);
788 if (AfterCommaMinus1 < 0)
789 {
790 string FramesS = to_string(GetFrames() >> (int)IsField());
791 string FrameRateS = to_string(FrameRate);
792 if (FramesS.size() < FrameMax_Length)
793 TC.append(FrameMax_Length - FramesS.size(), '0');
794 TC += FramesS;
795 TC += 'S';
796 TC += FrameRateS;
797 }
798 else
799 {
800 for (int i = 0; i <= AfterCommaMinus1; i++)
801 TC += '0' + (GetFrames() / (i == AfterCommaMinus1 ? 1 : PowersOf10[AfterCommaMinus1 - i - 1]) % 10);
802 }
803 }
804 else
805 {

Callers 9

MediaInfoMethod · 0.45
Duration_Duration123Method · 0.45
Merge_FillTimeCodeFunction · 0.45
DurationIssueMethod · 0.45
MediaInfoMethod · 0.45
MediaInfoMethod · 0.45
MediaInfoMethod · 0.45
MediaInfoMethod · 0.45

Calls 3

to_stringFunction · 0.85
appendMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected