annotate ffmpeg/libavformat/seek.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * seek utility functions for use within format handlers
yading@11 3 *
yading@11 4 * Copyright (c) 2009 Ivan Schreter
yading@11 5 *
yading@11 6 * This file is part of FFmpeg.
yading@11 7 *
yading@11 8 * FFmpeg is free software; you can redistribute it and/or
yading@11 9 * modify it under the terms of the GNU Lesser General Public
yading@11 10 * License as published by the Free Software Foundation; either
yading@11 11 * version 2.1 of the License, or (at your option) any later version.
yading@11 12 *
yading@11 13 * FFmpeg is distributed in the hope that it will be useful,
yading@11 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 16 * Lesser General Public License for more details.
yading@11 17 *
yading@11 18 * You should have received a copy of the GNU Lesser General Public
yading@11 19 * License along with FFmpeg; if not, write to the Free Software
yading@11 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 21 */
yading@11 22
yading@11 23 #ifndef AVFORMAT_SEEK_H
yading@11 24 #define AVFORMAT_SEEK_H
yading@11 25
yading@11 26 #include "avformat.h"
yading@11 27
yading@11 28 /**
yading@11 29 * structure to store parser state of one AVStream
yading@11 30 */
yading@11 31 typedef struct AVParserStreamState {
yading@11 32 // saved members of AVStream
yading@11 33 AVCodecParserContext *parser;
yading@11 34 int64_t last_IP_pts;
yading@11 35 int64_t cur_dts;
yading@11 36 int64_t reference_dts;
yading@11 37 int probe_packets;
yading@11 38 } AVParserStreamState;
yading@11 39
yading@11 40 /**
yading@11 41 * structure to store parser state of AVFormat
yading@11 42 */
yading@11 43 typedef struct AVParserState {
yading@11 44 int64_t fpos; ///< file position at the time of call
yading@11 45
yading@11 46 // saved members of AVFormatContext
yading@11 47 AVPacketList *packet_buffer; ///< packet buffer of original state
yading@11 48 AVPacketList *parse_queue; ///< parse queue of original state
yading@11 49 AVPacketList *raw_packet_buffer; ///< raw packet buffer of original state
yading@11 50 int raw_packet_buffer_remaining_size; ///< remaining space in raw_packet_buffer
yading@11 51
yading@11 52 // saved info for streams
yading@11 53 int nb_streams; ///< number of streams with stored state
yading@11 54 AVParserStreamState *stream_states; ///< states of individual streams (array)
yading@11 55 } AVParserState;
yading@11 56
yading@11 57 /**
yading@11 58 * Search for the sync point of all active streams.
yading@11 59 *
yading@11 60 * This routine is not supposed to be called directly by a user application,
yading@11 61 * but by demuxers.
yading@11 62 *
yading@11 63 * A sync point is defined as a point in stream, such that, when decoding start
yading@11 64 * from this point, the decoded output of all streams synchronizes closest
yading@11 65 * to the given timestamp ts. This routine also takes timestamp limits into account.
yading@11 66 * Thus, the output will synchronize no sooner than ts_min and no later than ts_max.
yading@11 67 *
yading@11 68 * @param stream_index stream index for time base reference of timestamps
yading@11 69 * @param pos approximate position where to start searching for key frames
yading@11 70 * @param min_ts minimum allowed timestamp (position, if AVSEEK_FLAG_BYTE set)
yading@11 71 * @param ts target timestamp (or position, if AVSEEK_FLAG_BYTE set in flags)
yading@11 72 * @param max_ts maximum allowed timestamp (position, if AVSEEK_FLAG_BYTE set)
yading@11 73 * @param flags if AVSEEK_FLAG_ANY is set, seek to any frame, otherwise only
yading@11 74 * to a keyframe. If AVSEEK_FLAG_BYTE is set, search by
yading@11 75 * position, not by timestamp.
yading@11 76 * @return -1 if no such sync point could be found, otherwise stream position
yading@11 77 * (stream is repositioned to this position)
yading@11 78 */
yading@11 79 int64_t ff_gen_syncpoint_search(AVFormatContext *s,
yading@11 80 int stream_index,
yading@11 81 int64_t pos,
yading@11 82 int64_t min_ts,
yading@11 83 int64_t ts,
yading@11 84 int64_t max_ts,
yading@11 85 int flags);
yading@11 86
yading@11 87 /**
yading@11 88 * Store current parser state and file position.
yading@11 89 *
yading@11 90 * This function can be used by demuxers before a destructive seeking algorithm
yading@11 91 * to store the parser state. Depending on the outcome of the seek, either the original
yading@11 92 * state can be restored or the new state kept and the original state freed.
yading@11 93 *
yading@11 94 * @note As a side effect, the original parser state is reset, since structures
yading@11 95 * are relinked to the stored state instead of being deeply-copied (for
yading@11 96 * performance reasons and to keep the code simple).
yading@11 97 *
yading@11 98 * @param s context from which to save state
yading@11 99 * @return parser state object or NULL if memory could not be allocated
yading@11 100 */
yading@11 101 AVParserState *ff_store_parser_state(AVFormatContext *s);
yading@11 102
yading@11 103 /**
yading@11 104 * Restore previously saved parser state and file position.
yading@11 105 *
yading@11 106 * Saved state will be invalidated and freed by this call, since internal
yading@11 107 * structures will be relinked back to the stored state instead of being
yading@11 108 * deeply-copied.
yading@11 109 *
yading@11 110 * @param s context to which to restore state (same as used for storing state)
yading@11 111 * @param state state to restore
yading@11 112 */
yading@11 113 void ff_restore_parser_state(AVFormatContext *s, AVParserState *state);
yading@11 114
yading@11 115 /**
yading@11 116 * Free previously saved parser state.
yading@11 117 *
yading@11 118 * @param s context to which the state belongs (same as used for storing state)
yading@11 119 * @param state state to free
yading@11 120 */
yading@11 121 void ff_free_parser_state(AVFormatContext *s, AVParserState *state);
yading@11 122
yading@11 123 #endif /* AVFORMAT_SEEK_H */