Go to the documentation of this file.
36 {
"start_time",
"set the start time (offset) of the subtitles, in ms",
38 { .i64 = 15000 }, INT64_MIN, INT64_MAX,
50 #define BETWEEN(a, amin, amax) ((unsigned)((a) - (amin)) <= (amax) - (amin))
52 #define HEX_DIGIT_TEST(c) (BETWEEN(c, '0', '9') || BETWEEN((c) | 32, 'a', 'z'))
53 #define HEX_DIGIT_VAL(c) ((c) <= '9' ? (c) - '0' : ((c) | 32) - 'a' + 10)
54 #define ERR_CODE(c) ((c) < 0 ? (c) : AVERROR_INVALIDDATA)
66 for (
i = bytes - 1;
i >= 0;
i--)
79 while (*cur_byte ==
' ' || *cur_byte ==
'\t' ||
80 *cur_byte ==
'\n' || *cur_byte ==
'\r')
100 while (*cur_byte > 0 && *cur_byte !=
'"') {
101 if (*cur_byte ==
'\\') {
105 if ((*cur_byte | 32) ==
'u') {
107 for (
i = 0;
i < 4;
i++) {
147 static const char *
const text[] = {
"false",
"true" };
152 for (
i = 0;
i < 2;
i++) {
159 if (
BETWEEN(*cur_byte | 32,
'a',
'z'))
172 if ((
unsigned)*cur_byte -
'0' > 9)
174 while (
BETWEEN(*cur_byte,
'0',
'9')) {
175 if (
val > INT_MAX/10 - (*cur_byte -
'0'))
177 val =
val * 10 + (*cur_byte -
'0');
186 int ret, cur_byte, start_of_par;
187 AVBPrint label, content;
198 if (
ret < 0 || strcmp(label.str,
"captions"))
213 if (!strcmp(label.str,
"startOfParagraph")) {
217 }
else if (!strcmp(label.str,
"content")) {
221 }
else if (!strcmp(label.str,
"startTime")) {
225 }
else if (!strcmp(label.str,
"duration")) {
296 for (
i = 0;
i <
tc->subs.nb_subs;
i++)
297 tc->subs.subs[
i]->pts +=
tc->start_time;
299 last =
tc->subs.subs[
tc->subs.nb_subs - 1];
328 static const char *
const tags[] = {
329 "\"captions\"",
"\"duration\"",
"\"content\"",
330 "\"startOfParagraph\"",
"\"startTime\"",
332 unsigned i, count = 0;
335 if (p->
buf[strspn(p->
buf,
" \t\r\n")] !=
'{')
338 if (!(t = strstr(p->
buf, tags[
i])))
340 t += strlen(tags[
i]);
341 t += strspn(t,
" \t\r\n");
350 int64_t min_ts, int64_t ts, int64_t max_ts,
355 min_ts, ts, max_ts,
flags);
359 .
name =
"tedcaptions",
static void skip_spaces(AVIOContext *pb, int *cur_byte)
#define AV_BPRINT_SIZE_UNLIMITED
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
static const AVOption tedcaptions_options[]
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
static int tedcaptions_read_seek(AVFormatContext *avf, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
const AVInputFormat ff_tedcaptions_demuxer
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define AV_BPRINT_SIZE_AUTOMATIC
static double val(void *priv, double ch)
int64_t duration
Decoding: duration of the stream, in stream time base.
int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Update current_sub_idx to emulate a seek.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_ARRAY_ELEMS(a)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static const AVClass tedcaptions_demuxer_class
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
FFDemuxSubtitlesQueue subs
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
Generic read_packet() callback for subtitles demuxers using this queue system.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
and forward the result(frame or status change) to the corresponding input. If nothing is possible
const char * av_default_item_name(void *ptr)
Return the context name.
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
static int tedcaptions_read_packet(AVFormatContext *avf, AVPacket *packet)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define HEX_DIGIT_TEST(c)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static int64_t start_time
#define AV_NOPTS_VALUE
Undefined timestamp value.
void ff_subtitles_queue_finalize(void *log_ctx, FFDemuxSubtitlesQueue *q)
Set missing durations, sort subtitles by PTS (and then byte position), and drop duplicated events.
static void av_bprint_utf8(AVBPrint *bp, unsigned c)
void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
Remove and destroy all the subtitles packets.
static av_cold int tedcaptions_read_probe(const AVProbeData *p)
int probe_packets
Number of packets to buffer for codec probing.
static int parse_string(AVIOContext *pb, int *cur_byte, AVBPrint *bp, int full)
AVPacket * ff_subtitles_queue_insert_bprint(FFDemuxSubtitlesQueue *q, const AVBPrint *event, int merge)
Same as ff_subtitles_queue_insert but takes an AVBPrint input.
static int parse_int(AVIOContext *pb, int *cur_byte, int64_t *result)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static int expect_byte(AVIOContext *pb, int *cur_byte, uint8_t c)
enum AVPacketSideDataType packet
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static void next_byte(AVIOContext *pb, int *cur_byte)
static int tedcaptions_read_close(AVFormatContext *avf)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
@ AV_CODEC_ID_TEXT
raw UTF-8 text
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int parse_file(AVIOContext *pb, FFDemuxSubtitlesQueue *subs)
static int parse_boolean(AVIOContext *pb, int *cur_byte, int *result)
static int read_probe(const AVProbeData *p)
#define AV_OPT_FLAG_SUBTITLE_PARAM
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int64_t pos
byte position in stream, -1 if unknown
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
void * priv_data
Format private data.
static int parse_label(AVIOContext *pb, int *cur_byte, AVBPrint *bp)
static av_cold int tedcaptions_read_header(AVFormatContext *avf)
#define BETWEEN(a, amin, amax)