2 * Utility functions for seeking for use within FFmpeg format handlers.
4 * Copyright (c) 2009 Ivan Schreter
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef AVFORMAT_SEEK_H
24 #define AVFORMAT_SEEK_H
28 /// Opaque structure for parser state.
29 typedef struct AVParserState AVParserState
;
32 * Search for sync point of all active streams.
34 * This is not supposed to be called directly by a user application,
37 * A sync point is a point in stream, so that decoding from this point,
38 * output of decoders of all streams synchronizes closest to given timestamp
39 * ts (but taking timestamp limits into account, i.e., no sooner than ts_min
40 * and no later than ts_max).
42 * @param stream_index stream index for time base reference of timestamps.
43 * @param pos approximate position where to start searching for key frames.
44 * @param min_ts minimum allowed timestamp (position, if AVSEEK_FLAG_BYTE set).
45 * @param ts target timestamp (or position, if AVSEEK_FLAG_BYTE set in flags).
46 * @param max_ts maximum allowed timestamp (position, if AVSEEK_FLAG_BYTE set).
47 * @param flags if AVSEEK_FLAG_ANY is set, seek to any frame, otherwise only
48 * to a keyframe. If AVSEEK_FLAG_BYTE is set, search by
49 * position, not by timestamp.
50 * @return < 0 if no such sync point could be found, otherwise stream position
51 * (stream is repositioned to this position).
53 int64_t ff_gen_syncpoint_search(AVFormatContext
*s
,
62 * Store current parser state and file position.
64 * This function can be used by demuxers before destructive seeking algorithm
65 * to store parser state. After the seek, depending on outcome, original state
66 * can be restored or new state kept and original state freed.
68 * @note As a side effect, original parser state is reset, since structures
69 * are relinked to stored state instead of being deeply-copied (for
70 * performance reasons and to keep code simple).
72 * @param s context from which to save state.
73 * @return parser state object or NULL if memory could not be allocated.
75 AVParserState
*ff_store_parser_state(AVFormatContext
*s
);
78 * Restore previously saved parser state and file position.
80 * Saved state will be invalidated and freed by this call, since internal
81 * structures will be relinked back to stored state instead of being
84 * @param s context to which to restore state (same as used for storing state).
85 * @param state state to restore.
87 void ff_restore_parser_state(AVFormatContext
*s
, AVParserState
*state
);
90 * Free previously saved parser state.
92 * @param s context to which the state belongs (same as used for storing state).
93 * @param state state to free.
95 void ff_free_parser_state(AVFormatContext
*s
, AVParserState
*state
);
97 #endif /* AVFORMAT_SEEK_H */