gavl
Data Structures | Functions
Frame table

Data Structures

struct  gavl_frame_table_t
 frame table structure More...
 

Functions

GAVL_PUBLIC gavl_frame_table_tgavl_frame_table_create ()
 Create a frame table. More...
 
GAVL_PUBLIC gavl_frame_table_tgavl_frame_table_create_audio (int samplerate, int64_t offset, int64_t duration, gavl_timecode_format_t *fmt_ret)
 Create a frame table for an audio stream. More...
 
GAVL_PUBLIC gavl_frame_table_tgavl_frame_table_create_cfr (int64_t offset, int64_t frame_duration, int64_t num_frames, gavl_timecode_t start_timecode)
 Create a frame table for constant framerate video. More...
 
GAVL_PUBLIC gavl_frame_table_tgavl_frame_table_copy (const gavl_frame_table_t *tab)
 Copy a frame table to another. More...
 
GAVL_PUBLIC void gavl_frame_table_destroy (gavl_frame_table_t *t)
 Destroy a frame table and free all memory. More...
 
GAVL_PUBLIC void gavl_frame_table_append_entry (gavl_frame_table_t *t, int64_t duration)
 Append an entry. More...
 
GAVL_PUBLIC void gavl_frame_table_append_timecode (gavl_frame_table_t *t, int64_t pts, gavl_timecode_t tc)
 Append a timecodes. More...
 
GAVL_PUBLIC int64_t gavl_frame_table_frame_to_time (const gavl_frame_table_t *t, int64_t frame, int *duration)
 Convert a frame index to a timestamp. More...
 
GAVL_PUBLIC int64_t gavl_frame_table_time_to_frame (const gavl_frame_table_t *t, int64_t time, int64_t *start_time)
 Convert a timestamp to a frame index. More...
 
GAVL_PUBLIC gavl_timecode_t gavl_frame_table_time_to_timecode (const gavl_frame_table_t *t, int64_t time, int64_t *start_time, const gavl_timecode_format_t *fmt)
 Convert a timestamp to a timecode. More...
 
GAVL_PUBLIC int64_t gavl_frame_table_timecode_to_time (const gavl_frame_table_t *t, gavl_timecode_t tc, const gavl_timecode_format_t *fmt)
 Convert a timecode to a timestamp. More...
 
GAVL_PUBLIC gavl_timecode_t gavl_frame_table_frame_to_timecode (const gavl_frame_table_t *t, int64_t frame, int64_t *start_time, const gavl_timecode_format_t *fmt)
 Convert a frame index to a timecode. More...
 
GAVL_PUBLIC int64_t gavl_frame_table_num_frames (const gavl_frame_table_t *t)
 get the total number of frames More...
 
GAVL_PUBLIC int64_t gavl_frame_table_duration (const gavl_frame_table_t *t)
 get the total duration of all frames More...
 
GAVL_PUBLIC int64_t gavl_frame_table_end_time (const gavl_frame_table_t *t)
 get the end time of the last frame More...
 
GAVL_PUBLIC int gavl_frame_table_save (const gavl_frame_table_t *tab, const char *filename)
 Save a frame table to a file. More...
 
GAVL_PUBLIC gavl_frame_table_tgavl_frame_table_load (const char *filename)
 Load a frame table from a file. More...
 
GAVL_PUBLIC void gavl_frame_table_dump (const gavl_frame_table_t *t)
 Dump a frame table to stderr for debugging. More...
 

Detailed Description

This is a table, which tolds the complete timing information of a video sequence. If is meant for e.g. for editing applications, where the complete timing must be known in advance.

A frame table is always associated with a gavl_video_format_t, which must be passed to most functions.

Function Documentation

GAVL_PUBLIC gavl_frame_table_t* gavl_frame_table_create ( )

Create a frame table.

Returns
A newly allocated frame table

Since 1.1.2.

GAVL_PUBLIC gavl_frame_table_t* gavl_frame_table_create_audio ( int  samplerate,
int64_t  offset,
int64_t  duration,
gavl_timecode_format_t fmt_ret 
)

Create a frame table for an audio stream.

Parameters
samplerateSamplerate for this stream
offsetPTS offset of this stream in samples
durationSample count
fmt_retIf non-null, returns the timecode format
Returns
A newly allocated frame table

Since 1.1.2.

GAVL_PUBLIC gavl_frame_table_t* gavl_frame_table_create_cfr ( int64_t  offset,
int64_t  frame_duration,
int64_t  num_frames,
gavl_timecode_t  start_timecode 
)

Create a frame table for constant framerate video.

Parameters
offsetTimestamp of the first frame
durationDuration of each frame
num_framesNumber of frames
fmtTimecode format (or NULL)
start_timecodeTimecode of the first frame (or GAVL_TIMECODE_UNDEFINED)
Returns
A newly allocated frame table

Since 1.1.2.

GAVL_PUBLIC gavl_frame_table_t* gavl_frame_table_copy ( const gavl_frame_table_t tab)

Copy a frame table to another.

Parameters
tabA frame table
Returns
A newly allocated copy

Since 1.1.2.

GAVL_PUBLIC void gavl_frame_table_destroy ( gavl_frame_table_t t)

Destroy a frame table and free all memory.

Parameters
tA frame table

Since 1.1.2.

GAVL_PUBLIC void gavl_frame_table_append_entry ( gavl_frame_table_t t,
int64_t  duration 
)

Append an entry.

Parameters
tA frame table
durationThe duration of this frame

Since 1.1.2.

GAVL_PUBLIC void gavl_frame_table_append_timecode ( gavl_frame_table_t t,
int64_t  pts,
gavl_timecode_t  tc 
)

Append a timecodes.

Parameters
tA frame table
ptsPresentation time of that frame
tcTimecode of that frame

Since 1.1.2.

GAVL_PUBLIC int64_t gavl_frame_table_frame_to_time ( const gavl_frame_table_t t,
int64_t  frame,
int *  duration 
)

Convert a frame index to a timestamp.

Parameters
tA frame table
frameFrame index (starting with zero)
durationIf non NULL, returns the duration of that frame
Returns
The timestamp of that frame in video timescale or GAVL_TIME_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

GAVL_PUBLIC int64_t gavl_frame_table_time_to_frame ( const gavl_frame_table_t t,
int64_t  time,
int64_t *  start_time 
)

Convert a timestamp to a frame index.

Parameters
tA frame table
timeTime in stream timescale
start_timeIf non NULL, returns the start time of that frame
Returns
The index that frame (starting with 0) or -1 if such frame doesn't exist.

Since 1.1.2.

GAVL_PUBLIC gavl_timecode_t gavl_frame_table_time_to_timecode ( const gavl_frame_table_t t,
int64_t  time,
int64_t *  start_time,
const gavl_timecode_format_t fmt 
)

Convert a timestamp to a timecode.

Parameters
tA frame table
timeTime in stream timescale
start_timeIf non NULL, returns the start time of that frame
fmtTimecode format
Returns
The interpolated timecode that frame or GAVL_TIMECODE_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

GAVL_PUBLIC int64_t gavl_frame_table_timecode_to_time ( const gavl_frame_table_t t,
gavl_timecode_t  tc,
const gavl_timecode_format_t fmt 
)

Convert a timecode to a timestamp.

Parameters
tA frame table
tcTimecode
fmtTimecode format
Returns
The pts corresponding to that timecode or GAVL_TIME_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

GAVL_PUBLIC gavl_timecode_t gavl_frame_table_frame_to_timecode ( const gavl_frame_table_t t,
int64_t  frame,
int64_t *  start_time,
const gavl_timecode_format_t fmt 
)

Convert a frame index to a timecode.

Parameters
tA frame table
frameFrame index
start_timeIf non NULL, returns the start time of that frame
fmtTimecode format
Returns
The interpolated timecode that frame or GAVL_TIMECODE_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

GAVL_PUBLIC int64_t gavl_frame_table_num_frames ( const gavl_frame_table_t t)

get the total number of frames

Parameters
tA frame table
Returns
The total number of frames

Since 1.1.2.

GAVL_PUBLIC int64_t gavl_frame_table_duration ( const gavl_frame_table_t t)

get the total duration of all frames

Parameters
tA frame table
Returns
Total duration

Since 1.1.2.

GAVL_PUBLIC int64_t gavl_frame_table_end_time ( const gavl_frame_table_t t)

get the end time of the last frame

Parameters
tA frame table
Returns
End time

Since 1.1.2.

GAVL_PUBLIC int gavl_frame_table_save ( const gavl_frame_table_t tab,
const char *  filename 
)

Save a frame table to a file.

Parameters
tTab frame table
filenameFilename
Returns
1 on success, 0 on error

Since 1.1.2.

GAVL_PUBLIC gavl_frame_table_t* gavl_frame_table_load ( const char *  filename)

Load a frame table from a file.

Parameters
filenameFilename
Returns
The loaded frame table or NULL if an error occurred

Since 1.1.2.

GAVL_PUBLIC void gavl_frame_table_dump ( const gavl_frame_table_t t)

Dump a frame table to stderr for debugging.

Parameters
tA frame table

Since 1.1.2.