FFmpeg
Functions
seek.c File Reference
#include <stdint.h>
#include "libavutil/avassert.h"
#include "libavutil/mathematics.h"
#include "libavutil/timestamp.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"

Go to the source code of this file.

Functions

void avpriv_update_cur_dts (AVFormatContext *s, AVStream *ref_st, int64_t timestamp)
 Update cur_dts of all streams based on the given timestamp and AVStream. More...
 
void ff_reduce_index (AVFormatContext *s, int stream_index)
 Ensure the index uses less memory than the maximum specified in AVFormatContext.max_index_size by discarding entries if it grows too large. More...
 
int ff_add_index_entry (AVIndexEntry **index_entries, int *nb_index_entries, unsigned int *index_entries_allocated_size, int64_t pos, int64_t timestamp, int size, int distance, int flags)
 Internal version of av_add_index_entry. More...
 
int av_add_index_entry (AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
 Add an index entry into a sorted list. More...
 
int ff_index_search_timestamp (const AVIndexEntry *entries, int nb_entries, int64_t wanted_timestamp, int flags)
 Internal version of av_index_search_timestamp. More...
 
void ff_configure_buffers_for_index (AVFormatContext *s, int64_t time_tolerance)
 
int av_index_search_timestamp (AVStream *st, int64_t wanted_timestamp, int flags)
 Get the index for a specific timestamp. More...
 
int avformat_index_get_entries_count (const AVStream *st)
 Get the index entry count for the given AVStream. More...
 
const AVIndexEntryavformat_index_get_entry (AVStream *st, int idx)
 Get the AVIndexEntry corresponding to the given index. More...
 
const AVIndexEntryavformat_index_get_entry_from_timestamp (AVStream *st, int64_t wanted_timestamp, int flags)
 Get the AVIndexEntry corresponding to the given timestamp. More...
 
static int64_t read_timestamp (AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, int64_t(*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t))
 
int ff_seek_frame_binary (AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
 Perform a binary search using av_index_search_timestamp() and AVInputFormat.read_timestamp(). More...
 
int ff_find_last_ts (AVFormatContext *s, int stream_index, int64_t *ts, int64_t *pos, int64_t(*read_timestamp_func)(struct AVFormatContext *, int, int64_t *, int64_t))
 
int64_t ff_gen_search (AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t(*read_timestamp_func)(struct AVFormatContext *, int, int64_t *, int64_t))
 Perform a binary search using read_timestamp(). More...
 
static int seek_frame_byte (AVFormatContext *s, int stream_index, int64_t pos, int flags)
 
static int seek_frame_generic (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 
static int seek_frame_internal (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 
int av_seek_frame (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 Seek to the keyframe at timestamp. More...
 
int avformat_seek_file (AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
 Seek to timestamp ts. More...
 
void ff_read_frame_flush (AVFormatContext *s)
 Flush the frame reader. More...
 
int avformat_flush (AVFormatContext *s)
 Discard all internally buffered data. More...
 

Function Documentation

◆ avpriv_update_cur_dts()

void avpriv_update_cur_dts ( AVFormatContext s,
AVStream ref_st,
int64_t  timestamp 
)

Update cur_dts of all streams based on the given timestamp and AVStream.

Stream ref_st unchanged, others set cur_dts in their native time base. Only needed for timestamp wrapping or if (dts not set and pts!=dts).

Parameters
timestampnew dts expressed in time_base of param ref_st
ref_streference stream giving time_base of param timestamp

Definition at line 32 of file seek.c.

Referenced by aa_read_header(), aa_read_seek(), ff_seek_frame_binary(), idcin_read_seek(), mp3_seek(), mpc8_read_seek(), mxf_read_seek(), read_seek(), seek_frame_generic(), and vpk_read_seek().

◆ ff_reduce_index()

void ff_reduce_index ( AVFormatContext s,
int  stream_index 
)

Ensure the index uses less memory than the maximum specified in AVFormatContext.max_index_size by discarding entries if it grows too large.

Definition at line 45 of file seek.c.

Referenced by av_read_frame(), mpegps_read_pes_header(), mpegts_get_dts(), and read_frame_internal().

◆ ff_add_index_entry()

int ff_add_index_entry ( AVIndexEntry **  index_entries,
int nb_index_entries,
unsigned int index_entries_allocated_size,
int64_t  pos,
int64_t  timestamp,
int  size,
int  distance,
int  flags 
)

Internal version of av_add_index_entry.

Definition at line 59 of file seek.c.

Referenced by av_add_index_entry(), read_header(), and scan_file().

◆ ff_index_search_timestamp()

int ff_index_search_timestamp ( const AVIndexEntry entries,
int  nb_entries,
int64_t  wanted_timestamp,
int  flags 
)

Internal version of av_index_search_timestamp.

Definition at line 127 of file seek.c.

Referenced by av_index_search_timestamp(), avformat_index_get_entry_from_timestamp(), ff_add_index_entry(), mxf_read_seek(), and read_seek().

◆ ff_configure_buffers_for_index()

void ff_configure_buffers_for_index ( AVFormatContext s,
int64_t  time_tolerance 
)

Definition at line 170 of file seek.c.

Referenced by mov_read_header().

◆ read_timestamp()

static int64_t read_timestamp ( AVFormatContext s,
int  stream_index,
int64_t *  ppos,
int64_t  pos_limit,
int64_t(*)(struct AVFormatContext *, int, int64_t *, int64_t)  read_timestamp 
)
static

Definition at line 273 of file seek.c.

Referenced by ff_find_last_ts(), and ff_gen_search().

◆ ff_seek_frame_binary()

int ff_seek_frame_binary ( AVFormatContext s,
int  stream_index,
int64_t  target_ts,
int  flags 
)

Perform a binary search using av_index_search_timestamp() and AVInputFormat.read_timestamp().

Parameters
target_tstarget timestamp in the time base of the given stream
stream_indexstream number

Definition at line 282 of file seek.c.

Referenced by asf_read_seek(), ogg_read_seek(), rm_read_seek(), and seek_frame_internal().

◆ ff_find_last_ts()

int ff_find_last_ts ( AVFormatContext s,
int  stream_index,
int64_t *  ts,
int64_t *  pos,
int64_t(*)(struct AVFormatContext *, int, int64_t *, int64_t)  read_timestamp_func 
)

Definition at line 352 of file seek.c.

Referenced by ff_gen_search(), and find_duration().

◆ ff_gen_search()

int64_t ff_gen_search ( AVFormatContext s,
int  stream_index,
int64_t  target_ts,
int64_t  pos_min,
int64_t  pos_max,
int64_t  pos_limit,
int64_t  ts_min,
int64_t  ts_max,
int  flags,
int64_t *  ts_ret,
int64_t(*)(struct AVFormatContext *, int, int64_t *, int64_t)  read_timestamp 
)

Perform a binary search using read_timestamp().

Parameters
target_tstarget timestamp in the time base of the given stream
stream_indexstream number

Definition at line 390 of file seek.c.

Referenced by ff_seek_frame_binary(), and read_seek().

◆ seek_frame_byte()

static int seek_frame_byte ( AVFormatContext s,
int  stream_index,
int64_t  pos,
int  flags 
)
static

Definition at line 497 of file seek.c.

Referenced by seek_frame_internal().

◆ seek_frame_generic()

static int seek_frame_generic ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 518 of file seek.c.

Referenced by seek_frame_internal().

◆ seek_frame_internal()

static int seek_frame_internal ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 589 of file seek.c.

Referenced by av_seek_frame().

◆ ff_read_frame_flush()

void ff_read_frame_flush ( AVFormatContext s)