annotate ffmpeg/libavformat/subtitles.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 * Copyright (c) 2012 Clément Bœsch
yading@11 3 *
yading@11 4 * This file is part of FFmpeg.
yading@11 5 *
yading@11 6 * FFmpeg is free software; you can redistribute it and/or
yading@11 7 * modify it under the terms of the GNU Lesser General Public
yading@11 8 * License as published by the Free Software Foundation; either
yading@11 9 * version 2.1 of the License, or (at your option) any later version.
yading@11 10 *
yading@11 11 * FFmpeg is distributed in the hope that it will be useful,
yading@11 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 14 * Lesser General Public License for more details.
yading@11 15 *
yading@11 16 * You should have received a copy of the GNU Lesser General Public
yading@11 17 * License along with FFmpeg; if not, write to the Free Software
yading@11 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 19 */
yading@11 20
yading@11 21 #ifndef AVFORMAT_SUBTITLES_H
yading@11 22 #define AVFORMAT_SUBTITLES_H
yading@11 23
yading@11 24 #include <stdint.h>
yading@11 25 #include "avformat.h"
yading@11 26 #include "libavutil/bprint.h"
yading@11 27
yading@11 28 typedef struct {
yading@11 29 AVPacket *subs; ///< array of subtitles packets
yading@11 30 int nb_subs; ///< number of subtitles packets
yading@11 31 int allocated_size; ///< allocated size for subs
yading@11 32 int current_sub_idx; ///< current position for the read packet callback
yading@11 33 } FFDemuxSubtitlesQueue;
yading@11 34
yading@11 35 /**
yading@11 36 * Insert a new subtitle event.
yading@11 37 *
yading@11 38 * @param event the subtitle line, may not be zero terminated
yading@11 39 * @param len the length of the event (in strlen() sense, so without '\0')
yading@11 40 * @param merge set to 1 if the current event should be concatenated with the
yading@11 41 * previous one instead of adding a new entry, 0 otherwise
yading@11 42 */
yading@11 43 AVPacket *ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q,
yading@11 44 const uint8_t *event, int len, int merge);
yading@11 45
yading@11 46 /**
yading@11 47 * Set missing durations and sort subtitles by PTS, and then byte position.
yading@11 48 */
yading@11 49 void ff_subtitles_queue_finalize(FFDemuxSubtitlesQueue *q);
yading@11 50
yading@11 51 /**
yading@11 52 * Generic read_packet() callback for subtitles demuxers using this queue
yading@11 53 * system.
yading@11 54 */
yading@11 55 int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt);
yading@11 56
yading@11 57 /**
yading@11 58 * Update current_sub_idx to emulate a seek. Except the first parameter, it
yading@11 59 * matches AVInputFormat->read_seek2 prototypes.
yading@11 60 */
yading@11 61 int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int stream_index,
yading@11 62 int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
yading@11 63
yading@11 64 /**
yading@11 65 * Remove and destroy all the subtitles packets.
yading@11 66 */
yading@11 67 void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q);
yading@11 68
yading@11 69 /**
yading@11 70 * SMIL helper to load next chunk ("<...>" or untagged content) in buf.
yading@11 71 *
yading@11 72 * @param c cached character, to avoid a backward seek
yading@11 73 */
yading@11 74 int ff_smil_extract_next_chunk(AVIOContext *pb, AVBPrint *buf, char *c);
yading@11 75
yading@11 76 /**
yading@11 77 * SMIL helper to point on the value of an attribute in the given tag.
yading@11 78 *
yading@11 79 * @param s SMIL tag ("<...>")
yading@11 80 * @param attr the attribute to look for
yading@11 81 */
yading@11 82 const char *ff_smil_get_attr_ptr(const char *s, const char *attr);
yading@11 83
yading@11 84 /**
yading@11 85 * @brief Read a subtitles chunk.
yading@11 86 *
yading@11 87 * A chunk is defined by a multiline "event", ending with a second line break.
yading@11 88 * The trailing line breaks are trimmed. CRLF are supported.
yading@11 89 * Example: "foo\r\nbar\r\n\r\nnext" will print "foo\r\nbar" into buf, and pb
yading@11 90 * will focus on the 'n' of the "next" string.
yading@11 91 *
yading@11 92 * @param pb I/O context
yading@11 93 * @param buf an initialized buf where the chunk is written
yading@11 94 *
yading@11 95 * @note buf is cleared before writing into it.
yading@11 96 */
yading@11 97 void ff_subtitles_read_chunk(AVIOContext *pb, AVBPrint *buf);
yading@11 98
yading@11 99 #endif /* AVFORMAT_SUBTITLES_H */