gavl
Data Structures | Macros | Typedefs | Functions
Timecodes

Timecode definitions. More...

Data Structures

struct  gavl_timecode_format_t
 Timecode format. More...
 

Macros

#define GAVL_TIMECODE_SIGN_MASK   (0x1LL<<62)
 If 1, timecode is negative. More...
 
#define GAVL_TIMECODE_INVALID_MASK   (0x1LL<<63)
 If 1, timecode is invalid. More...
 
#define GAVL_TIMECODE_DROP_FRAME   (1<<0)
 NTSC drop frame is used. More...
 
#define GAVL_TIMECODE_UNDEFINED   GAVL_TIMECODE_INVALID_MASK
 Convenience macro. More...
 
#define GAVL_TIMECODE_STRING_LEN   26
 
#define GAVL_TIMECODE_STRING_LEN_SHORT   13
 

Typedefs

typedef uint64_t gavl_timecode_t
 Typedef for timecodes. More...
 

Functions

GAVL_PUBLIC void gavl_timecode_format_copy (gavl_timecode_format_t *dst, const gavl_timecode_format_t *src)
 Copy one timecode format to another. More...
 
GAVL_PUBLIC void gavl_timecode_to_hmsf (gavl_timecode_t tc, int *hours, int *minutes, int *seconds, int *frames)
 Extract the time part of the timecode. More...
 
GAVL_PUBLIC void gavl_timecode_to_ymd (gavl_timecode_t tc, int *year, int *month, int *day)
 Extract the date part of the timecode. More...
 
GAVL_PUBLIC void gavl_timecode_from_hmsf (gavl_timecode_t *tc, int hours, int minutes, int seconds, int frames)
 Set the time part of the timecode. More...
 
GAVL_PUBLIC void gavl_timecode_from_ymd (gavl_timecode_t *tc, int year, int month, int day)
 Set the date part of the timecode. More...
 
GAVL_PUBLIC int64_t gavl_timecode_to_framecount (const gavl_timecode_format_t *tf, gavl_timecode_t tc)
 Get the frame count from the timecode. More...
 
GAVL_PUBLIC gavl_timecode_t gavl_timecode_from_framecount (const gavl_timecode_format_t *tf, int64_t fc)
 Get a timecode from the frame count. More...
 
GAVL_PUBLIC void gavl_timecode_dump (const gavl_timecode_format_t *tf, gavl_timecode_t tc)
 Dump a timecode to stderr. More...
 
GAVL_PUBLIC void gavl_timecode_prettyprint (const gavl_timecode_format_t *tf, gavl_timecode_t tc, char str[GAVL_TIMECODE_STRING_LEN])
 Print a full timecode into a string. More...
 
GAVL_PUBLIC void gavl_timecode_prettyprint_short (gavl_timecode_t tc, char str[GAVL_TIMECODE_STRING_LEN_SHORT])
 Print a short timecode into a string. More...
 

Detailed Description

Timecode definitions.

Timecodes are usually associated with video frames and represent a unique time (e.g. Wall clock time) within the whole footage.

Since 1.1.0

Macro Definition Documentation

◆ GAVL_TIMECODE_SIGN_MASK

#define GAVL_TIMECODE_SIGN_MASK   (0x1LL<<62)

If 1, timecode is negative.

◆ GAVL_TIMECODE_INVALID_MASK

#define GAVL_TIMECODE_INVALID_MASK   (0x1LL<<63)

If 1, timecode is invalid.

◆ GAVL_TIMECODE_DROP_FRAME

#define GAVL_TIMECODE_DROP_FRAME   (1<<0)

NTSC drop frame is used.

◆ GAVL_TIMECODE_UNDEFINED

#define GAVL_TIMECODE_UNDEFINED   GAVL_TIMECODE_INVALID_MASK

Convenience macro.

◆ GAVL_TIMECODE_STRING_LEN

#define GAVL_TIMECODE_STRING_LEN   26

Length for a string into which a timecode will be printed

◆ GAVL_TIMECODE_STRING_LEN_SHORT

#define GAVL_TIMECODE_STRING_LEN_SHORT   13

Length for a string into which a short timecode will be printed

Typedef Documentation

◆ gavl_timecode_t

typedef uint64_t gavl_timecode_t

Typedef for timecodes.

Function Documentation

◆ gavl_timecode_format_copy()

GAVL_PUBLIC void gavl_timecode_format_copy ( gavl_timecode_format_t dst,
const gavl_timecode_format_t src 
)

Copy one timecode format to another.

Parameters
dstDestination format
srcSource format

◆ gavl_timecode_to_hmsf()

GAVL_PUBLIC void gavl_timecode_to_hmsf ( gavl_timecode_t  tc,
int *  hours,
int *  minutes,
int *  seconds,
int *  frames 
)

Extract the time part of the timecode.

Parameters
tcA timecode
hoursIf non NULL, returns the hours
minutesIf non NULL, returns the minutes
secondsIf non NULL, returns the seconds
framesIf non NULL, returns the frames

◆ gavl_timecode_to_ymd()

GAVL_PUBLIC void gavl_timecode_to_ymd ( gavl_timecode_t  tc,
int *  year,
int *  month,
int *  day 
)

Extract the date part of the timecode.

Parameters
tcA timecode
yearIf non NULL, returns the year
monthIf non NULL, returns the month
dayIf non NULL, returns the day

◆ gavl_timecode_from_hmsf()

GAVL_PUBLIC void gavl_timecode_from_hmsf ( gavl_timecode_t tc,
int  hours,
int  minutes,
int  seconds,
int  frames 
)

Set the time part of the timecode.

Parameters
tcA timecode
hoursThe hours
minutesThe minutes
secondsThe seconds
framesThe frames

◆ gavl_timecode_from_ymd()

GAVL_PUBLIC void gavl_timecode_from_ymd ( gavl_timecode_t tc,
int  year,
int  month,
int  day 
)

Set the date part of the timecode.

Parameters
tcA timecode
yearThe year
monthThe month
dayThe day

◆ gavl_timecode_to_framecount()

GAVL_PUBLIC int64_t gavl_timecode_to_framecount ( const gavl_timecode_format_t tf,
gavl_timecode_t  tc 
)

Get the frame count from the timecode.

Parameters
tfThe timecode format
tcA timecode
Returns
The frame count

If the time is larger than 24 hours, the framecount is calculated from 00:00:00, January 1, 1970

◆ gavl_timecode_from_framecount()

GAVL_PUBLIC gavl_timecode_t gavl_timecode_from_framecount ( const gavl_timecode_format_t tf,
int64_t  fc 
)

Get a timecode from the frame count.

Parameters
tfThe timecode format
fcThe frame count
Returns
The timecode corresponding to the framecount

If the date fields are non-zero, the framecount is calculated from 00:00:00, January 1, 1970

◆ gavl_timecode_dump()

GAVL_PUBLIC void gavl_timecode_dump ( const gavl_timecode_format_t tf,
gavl_timecode_t  tc 
)

Dump a timecode to stderr.

Parameters
tfThe timecode format
tcA timecode

This is used mainly for debugging

◆ gavl_timecode_prettyprint()

GAVL_PUBLIC void gavl_timecode_prettyprint ( const gavl_timecode_format_t tf,
gavl_timecode_t  tc,
char  str[GAVL_TIMECODE_STRING_LEN] 
)

Print a full timecode into a string.

Parameters
tfThe timecode format
tcA timecode
strString where the timecode will be printed

This prints the full timecode (including calendar date if available). For real-life applications, you might want to try gavl_timecode_prettyprint_short instead.

◆ gavl_timecode_prettyprint_short()

GAVL_PUBLIC void gavl_timecode_prettyprint_short ( gavl_timecode_t  tc,
char  str[GAVL_TIMECODE_STRING_LEN_SHORT] 
)

Print a short timecode into a string.

Parameters
tcA timecode
strString where the timecode will be printed

Since 1.1.1