70 hi = ts_hi * tb_hi.
num * tb_lo.
den;
71 lo = ts_lo * tb_lo.
num * tb_hi.
den;
102 int keyframes_to_find,
112 int terminated_count = 0;
124 if (sp->
pos_hi == INT64_MAX) {
127 sp->
ts_hi = INT64_MAX;
128 sp->
pos_hi = INT64_MAX - 1;
193 if (sp->
pos_hi == INT64_MAX) {
196 sp->
ts_hi = INT64_MAX;
197 sp->
pos_hi = INT64_MAX - 1;
199 if (terminated_count == keyframes_to_find)
207 if (sp->
pos_lo == INT64_MAX) {
212 }
else if (sp->
ts_lo < ts) {
220 if (sp->
pos_hi == INT64_MAX) {
225 if (*found_hi >= keyframes_to_find && first_iter) {
231 }
else if (sp->
ts_hi > ts) {
255 int keyframes_to_find = 0;
258 int found_lo = 0, found_hi = 0;
269 if (stream_index >= 0) {
291 sp->
ts_lo = INT64_MAX;
293 sp->
ts_hi = INT64_MAX;
306 if (!keyframes_to_find) {
315 curpos =
FFMAX(pos - step / 2, 0);
323 &found_lo, &found_hi,
325 if (found_lo == keyframes_to_find && found_hi == keyframes_to_find)
360 min_distance = INT64_MAX;
362 if (sp->
pos_lo != INT64_MAX
369 if (sp->
pos_hi != INT64_MAX
374 if (distance < min_distance) {
379 if (min_distance == INT64_MAX) {
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVParserState * ff_store_parser_state(AVFormatContext *s)
Store current parser state and file position.
void av_free_packet(AVPacket *pkt)
Free a packet.
AVRational first_ts_tb
timebase for first_ts
memory handling functions
int64_t pos
byte position in stream, -1 if unknown
int64_t ts_lo
frame presentation timestamp or same as pos_lo for byte seeking
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static int sync(AVFormatContext *s, uint8_t *header)
Read input until we find the next ident.
static void search_hi_lo_keyframes(AVFormatContext *s, int64_t timestamp, AVRational timebase, int flags, AVSyncPoint *sync, int keyframes_to_find, int *found_lo, int *found_hi, int first_iter)
Partial search for keyframes in multiple streams.
AVPacketList * raw_packet_buffer
raw packet buffer of original state
struct AVPacketList * packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
int64_t pos_lo
position of the frame with low timestamp in file or INT64_MAX if not found (yet)
AVParserStreamState * stream_states
states of individual streams (array)
#define RAW_PACKET_BUFFER_SIZE
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t term_ts
termination timestamp (which TS we already read)
struct AVPacketList * raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
AVRational term_ts_tb
timebase for term_ts
structure to store parser state of one AVStream
void ff_restore_parser_state(AVFormatContext *s, AVParserState *state)
Restore previously saved parser state and file position.
helper structure describing keyframe search state of one stream
int flags
A combination of AV_PKT_FLAG values.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare 2 timestamps each in its own timebases.
static float distance(float x, float y, int band)
unsigned int nb_streams
A list of all streams in the file.
int64_t ts_hi
frame presentation timestamp or same as pos_hi for byte seeking
structure to store parser state of AVFormat
#define MAX_PROBE_PACKETS
void av_parser_close(AVCodecParserContext *s)
int terminated
termination flag for the current iteration
int64_t first_ts
first packet timestamp in this iteration (to fill term_ts later)
int buffer_size
Maximum buffer size.
int64_t last_pos
last known position of a frame, for multi-frame packets
int raw_packet_buffer_remaining_size
AVIOContext * pb
I/O context.
int64_t reference_dts
Timestamp corresponding to the last dts sync point.
AVPacketList * parse_queue
parse queue of original state
rational number numerator/denominator
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int nb_streams
number of streams with stored state
struct AVPacketList * parse_queue
Packets split by the parser get queued here.
static void free_packet_list(AVPacketList *pktl)
AVCodecParserContext * parser
int64_t ff_gen_syncpoint_search(AVFormatContext *s, int stream_index, int64_t pos, int64_t ts_min, int64_t ts, int64_t ts_max, int flags)
Search for the sync point of all active streams.
struct AVPacketList * next
int64_t fpos
file position at the time of call
void ff_free_parser_state(AVFormatContext *s, AVParserState *state)
Free previously saved parser state.
int raw_packet_buffer_remaining_size
remaining space in raw_packet_buffer
static int64_t ts_distance(int64_t ts_hi, AVRational tb_hi, int64_t ts_lo, AVRational tb_lo)
Compute a distance between timestamps.
struct AVCodecParserContext * parser
AVPacketList * packet_buffer
packet buffer of original state
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t pos_hi
position of the frame with high timestamp in file or INT64_MAX if not found (yet) ...