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

Function mad_timer_count

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

* NAME: timer->count() * DESCRIPTION: return timer value in selected units */

Source from the content-addressed store, hash-verified

268 * DESCRIPTION: return timer value in selected units
269 */
270signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
271{
272 switch (units) {
273 case MAD_UNITS_HOURS:
274 return timer.seconds / 60 / 60;
275
276 case MAD_UNITS_MINUTES:
277 return timer.seconds / 60;
278
279 case MAD_UNITS_SECONDS:
280 return timer.seconds;
281
282 case MAD_UNITS_DECISECONDS:
283 case MAD_UNITS_CENTISECONDS:
284 case MAD_UNITS_MILLISECONDS:
285
286 case MAD_UNITS_8000_HZ:
287 case MAD_UNITS_11025_HZ:
288 case MAD_UNITS_12000_HZ:
289 case MAD_UNITS_16000_HZ:
290 case MAD_UNITS_22050_HZ:
291 case MAD_UNITS_24000_HZ:
292 case MAD_UNITS_32000_HZ:
293 case MAD_UNITS_44100_HZ:
294 case MAD_UNITS_48000_HZ:
295
296 case MAD_UNITS_24_FPS:
297 case MAD_UNITS_25_FPS:
298 case MAD_UNITS_30_FPS:
299 case MAD_UNITS_48_FPS:
300 case MAD_UNITS_50_FPS:
301 case MAD_UNITS_60_FPS:
302 case MAD_UNITS_75_FPS:
303 return timer.seconds * (signed long) units +
304 (signed long) scale_rational(timer.fraction, MAD_TIMER_RESOLUTION,
305 units);
306
307 case MAD_UNITS_23_976_FPS:
308 case MAD_UNITS_24_975_FPS:
309 case MAD_UNITS_29_97_FPS:
310 case MAD_UNITS_47_952_FPS:
311 case MAD_UNITS_49_95_FPS:
312 case MAD_UNITS_59_94_FPS:
313 return (mad_timer_count(timer, -units) + 1) * 1000 / 1001;
314 }
315
316 /* unsupported units */
317 return 0;
318}
319
320/*
321 * NAME: timer->fraction()

Callers 1

mad_timer_stringFunction · 0.85

Calls 1

scale_rationalFunction · 0.85

Tested by

no test coverage detected