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

Function DvDif_Time2String

Source/MediaInfo/Multiple/File_DvDif.cpp:255–305  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

253
254//---------------------------------------------------------------------------
255static std::array<char, 12> DvDif_Time2String(int32u Value, bool DSF = false)
256{
257 unsigned HH = Value & 0x3F;
258 unsigned HU = Value & 0xF;
259 Value >>= 4;
260 unsigned HT = Value & 0x3;
261 Value >>= 4;
262 unsigned MM = Value & 0x7F;
263 unsigned MU = Value & 0xF;
264 Value >>= 4;
265 unsigned MT = Value & 0x7;
266 Value >>= 4;
267 unsigned SS = Value & 0x7F;
268 unsigned SU = Value & 0xF;
269 Value >>= 4;
270 unsigned ST = Value & 0x7;
271 Value >>= 4;
272 unsigned FU = Value & 0xF;
273 Value >>= 4;
274 unsigned FT = Value & 0x3;
275 std::array<char, 12> Result;
276 if (HU >= 10 || MU >= 10 || SU >= 10 || HH >= 0x24 || MM >= 0x60 || SS >= 0x60) {
277 Result[0] = '\0';
278 return Result;
279 }
280 Result[0] = '0' + HT;
281 Result[1] = '0' + HU;
282 Result[2] = ':';
283 Result[3] = '0' + MT;
284 Result[4] = '0' + MU;
285 Result[5] = ':';
286 Result[6] = '0' + ST;
287 Result[7] = '0' + SU;
288 if (FU < 10) {
289 unsigned FF = FT * 10 + FU;
290 unsigned const FrameRate = DSF ? 25 : 30;
291 if (FF < FrameRate) {
292 auto ms = (FF * 1000 + FrameRate / 2) / FrameRate;
293 Result[8] = '.';
294 Result[9] = '0' + ms / 100;
295 ms = ms % 100;
296 Result[10] = '0' + ms / 10;
297 ms = ms % 10;
298 Result[11] = '0' + ms;
299 }
300 }
301 else {
302 Result[8] = '\0';
303 }
304 return Result;
305}
306
307//***************************************************************************
308// Constructor/Destructor

Callers 2

Streams_FinishMethod · 0.85
rectimeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected