Frame table
Video

## Data Structures

struct | gavl_frame_table_t
| frame table structure More...

## Functions

GAVL_PUBLIC gavl_frame_table_t * | gavl_frame_table_create ()
| Create a frame table. More...
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. More...
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. More...
GAVL_PUBLIC gavl_frame_table_t * | gavl_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 *t, const char *filename)
| Save a frame table to a file. More...
GAVL_PUBLIC gavl_frame_table_t * | gavl_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_frame_table_create()

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_frame_table_create_audio()

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

  samplerate | Samplerate for this stream
  offset | PTS offset of this stream in samples
  duration | Sample count
  fmt_ret | If non-null, returns the timecode format

Returns
  A newly allocated frame table

Since 1.1.2.

## gavl_frame_table_create_cfr()

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

  offset | Timestamp of the first frame
  frame_duration | Duration of each frame
  num_frames | Number of frames
  start_timecode | Timecode of the first frame (or GAVL_TIMECODE_UNDEFINED)

Returns
  A newly allocated frame table

Since 1.1.2.

## gavl_frame_table_copy()

GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_copy | ( | const gavl_frame_table_t * | tab | ) |

Copy a frame table to another.

Parameters

  tab | A frame table

Returns
  A newly allocated copy

Since 1.1.2.

## gavl_frame_table_destroy()

GAVL_PUBLIC void gavl_frame_table_destroy | ( | gavl_frame_table_t * | t | ) |

Destroy a frame table and free all memory.

Parameters

  t | A frame table

Since 1.1.2.

## gavl_frame_table_append_entry()

GAVL_PUBLIC void gavl_frame_table_append_entry | ( | gavl_frame_table_t * | t,
|  | int64_t | duration
| ) |  |

Append an entry.

Parameters

  t | A frame table
  duration | The duration of this frame

Since 1.1.2.

## gavl_frame_table_append_timecode()

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

Append a timecodes.

Parameters

  t | A frame table
  pts | Presentation time of that frame
  tc | Timecode of that frame

Since 1.1.2.

## gavl_frame_table_frame_to_time()

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

  t | A frame table
  frame | Frame index (starting with zero)
  duration | If 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_frame_table_time_to_frame()

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

  t | A frame table
  time | Time in stream timescale
  start_time | If 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_frame_table_time_to_timecode()

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

  t | A frame table
  time | Time in stream timescale
  start_time | If non NULL, returns the start time of that frame
  fmt | Timecode format

Returns
  The interpolated timecode that frame or GAVL_TIMECODE_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

## gavl_frame_table_timecode_to_time()

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

  t | A frame table
  tc | Timecode
  fmt | Timecode format

Returns
  The pts corresponding to that timecode or GAVL_TIME_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

## gavl_frame_table_frame_to_timecode()

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

  t | A frame table
  frame | Frame index
  start_time | If non NULL, returns the start time of that frame
  fmt | Timecode format

Returns
  The interpolated timecode that frame or GAVL_TIMECODE_UNDEFINED if such frame doesn't exist.

Since 1.1.2.

## gavl_frame_table_num_frames()

GAVL_PUBLIC int64_t gavl_frame_table_num_frames | ( | const gavl_frame_table_t * | t | ) |

get the total number of frames

Parameters

  t | A frame table

Returns
  The total number of frames

Since 1.1.2.

## gavl_frame_table_duration()

GAVL_PUBLIC int64_t gavl_frame_table_duration | ( | const gavl_frame_table_t * | t | ) |

get the total duration of all frames

Parameters

  t | A frame table

Returns
  Total duration

Since 1.1.2.

## gavl_frame_table_end_time()

GAVL_PUBLIC int64_t gavl_frame_table_end_time | ( | const gavl_frame_table_t * | t | ) |

get the end time of the last frame

Parameters

  t | A frame table

Returns
  End time

Since 1.1.2.

## gavl_frame_table_save()

GAVL_PUBLIC int gavl_frame_table_save | ( | const gavl_frame_table_t * | t,
|  | const char * | filename
| ) |  |

Save a frame table to a file.

Parameters

  t | Tab frame table
  filename | Filename

Returns
  1 on success, 0 on error

Since 1.1.2.

## gavl_frame_table_load()

GAVL_PUBLIC gavl_frame_table_t * gavl_frame_table_load | ( | const char * | filename | ) |

Load a frame table from a file.

Parameters

  filename | Filename

Returns
  The loaded frame table or NULL if an error occurred

Since 1.1.2.

## gavl_frame_table_dump()

GAVL_PUBLIC void gavl_frame_table_dump | ( | const gavl_frame_table_t * | t | ) |

Dump a frame table to stderr for debugging.

Parameters

  t | A frame table

Since 1.1.2.