annotate seek.h @ 5140:9c846d0a6803 libavformat

Use generic multi-stream key frame finding routine to implement read_seek2 and map read_seek to read_seek2.
author schreter
date Sat, 22 Aug 2009 16:07:50 +0000
parents 9b2d2f4aa042
children 26ba0ebacbb2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5139
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
1 /*
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
2 * Utility functions for seeking for use within FFmpeg format handlers.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
3 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
4 * Copyright (c) 2009 Ivan Schreter
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
5 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
6 * This file is part of FFmpeg.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
7 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
12 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
16 * Lesser General Public License for more details.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
17 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
21 */
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
22
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
23 #ifndef AVFORMAT_SEEK_H
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
24 #define AVFORMAT_SEEK_H
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
25
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
26 #include "avformat.h"
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
27
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
28 /// Opaque structure for parser state.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
29 typedef struct AVParserState AVParserState;
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
30
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
31 /**
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
32 * Search for sync point of all active streams.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
33 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
34 * This is not supposed to be called directly by a user application,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
35 * but by demuxers.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
36 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
37 * A sync point is a point in stream, so that decoding from this point,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
38 * output of decoders of all streams synchronizes closest to given timestamp
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
39 * ts (but taking timestamp limits into account, i.e., no sooner than ts_min
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
40 * and no later than ts_max).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
41 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
42 * @param stream_index stream index for time base reference of timestamps.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
43 * @param pos approximate position where to start searching for key frames.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
44 * @param min_ts minimum allowed timestamp (position, if AVSEEK_FLAG_BYTE set).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
45 * @param ts target timestamp (or position, if AVSEEK_FLAG_BYTE set in flags).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
46 * @param max_ts maximum allowed timestamp (position, if AVSEEK_FLAG_BYTE set).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
47 * @param flags if AVSEEK_FLAG_ANY is set, seek to any frame, otherwise only
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
48 * to a keyframe. If AVSEEK_FLAG_BYTE is set, search by
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
49 * position, not by timestamp.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
50 * @return < 0 if no such sync point could be found, otherwise stream position
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
51 * (stream is repositioned to this position).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
52 */
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
53 int64_t ff_gen_syncpoint_search(AVFormatContext *s,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
54 int stream_index,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
55 int64_t pos,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
56 int64_t min_ts,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
57 int64_t ts,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
58 int64_t max_ts,
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
59 int flags);
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
60
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
61 /**
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
62 * Store current parser state and file position.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
63 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
64 * This function can be used by demuxers before destructive seeking algorithm
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
65 * to store parser state. After the seek, depending on outcome, original state
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
66 * can be restored or new state kept and original state freed.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
67 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
68 * @note As a side effect, original parser state is reset, since structures
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
69 * are relinked to stored state instead of being deeply-copied (for
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
70 * performance reasons and to keep code simple).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
71 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
72 * @param s context from which to save state.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
73 * @return parser state object or NULL if memory could not be allocated.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
74 */
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
75 AVParserState *ff_store_parser_state(AVFormatContext *s);
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
76
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
77 /**
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
78 * Restore previously saved parser state and file position.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
79 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
80 * Saved state will be invalidated and freed by this call, since internal
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
81 * structures will be relinked back to stored state instead of being
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
82 * deeply-copied.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
83 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
84 * @param s context to which to restore state (same as used for storing state).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
85 * @param state state to restore.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
86 */
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
87 void ff_restore_parser_state(AVFormatContext *s, AVParserState *state);
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
88
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
89 /**
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
90 * Free previously saved parser state.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
91 *
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
92 * @param s context to which the state belongs (same as used for storing state).
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
93 * @param state state to free.
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
94 */
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
95 void ff_free_parser_state(AVFormatContext *s, AVParserState *state);
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
96
9b2d2f4aa042 Support for generic multi-stream key frame finding for new seek API.
schreter
parents:
diff changeset
97 #endif /* AVFORMAT_SEEK_H */