MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / mad_timer_string

Function mad_timer_string

modules/data/mp3/libmad/mad_timer.c:345–485  ·  view source on GitHub ↗

* NAME: timer->string() * DESCRIPTION: write a string representation of a timer using a template */

Source from the content-addressed store, hash-verified

343 * DESCRIPTION: write a string representation of a timer using a template
344 */
345void mad_timer_string(mad_timer_t timer,
346 char *dest, char const *format, enum mad_units units,
347 enum mad_units fracunits, unsigned long subparts)
348{
349 unsigned long hours, minutes, seconds, sub;
350 unsigned int frac;
351
352 timer = mad_timer_abs(timer);
353
354 seconds = timer.seconds;
355 frac = sub = 0;
356
357 switch (fracunits) {
358 case MAD_UNITS_HOURS:
359 case MAD_UNITS_MINUTES:
360 case MAD_UNITS_SECONDS:
361 break;
362
363 case MAD_UNITS_DECISECONDS:
364 case MAD_UNITS_CENTISECONDS:
365 case MAD_UNITS_MILLISECONDS:
366
367 case MAD_UNITS_8000_HZ:
368 case MAD_UNITS_11025_HZ:
369 case MAD_UNITS_12000_HZ:
370 case MAD_UNITS_16000_HZ:
371 case MAD_UNITS_22050_HZ:
372 case MAD_UNITS_24000_HZ:
373 case MAD_UNITS_32000_HZ:
374 case MAD_UNITS_44100_HZ:
375 case MAD_UNITS_48000_HZ:
376
377 case MAD_UNITS_24_FPS:
378 case MAD_UNITS_25_FPS:
379 case MAD_UNITS_30_FPS:
380 case MAD_UNITS_48_FPS:
381 case MAD_UNITS_50_FPS:
382 case MAD_UNITS_60_FPS:
383 case MAD_UNITS_75_FPS:
384 {
385 unsigned long denom;
386
387 denom = MAD_TIMER_RESOLUTION / fracunits;
388
389 frac = timer.fraction / denom;
390 sub = scale_rational(timer.fraction % denom, denom, subparts);
391 }
392 break;
393
394 case MAD_UNITS_23_976_FPS:
395 case MAD_UNITS_24_975_FPS:
396 case MAD_UNITS_29_97_FPS:
397 case MAD_UNITS_47_952_FPS:
398 case MAD_UNITS_49_95_FPS:
399 case MAD_UNITS_59_94_FPS:
400 /* drop-frame encoding */
401 /* N.B. this is only well-defined for MAD_UNITS_29_97_FPS */
402 {

Callers

nothing calls this directly

Calls 3

mad_timer_absFunction · 0.85
scale_rationalFunction · 0.85
mad_timer_countFunction · 0.85

Tested by

no test coverage detected