26 #include "libavutil/intreadwrite.h"
28 #define MAX_LINESIZE 2048
46 if (sscanf(ptr,
"{%*d}{}%c", &c) != 1 &&
47 sscanf(ptr,
"{%*d}{%*d}%c", &c) != 1 &&
48 sscanf(ptr,
"{DEFAULT}{}%c", &c) != 1)
60 if (sscanf(buf,
"{%d}{%c", &frame, &c) == 2)
67 int frame_start, frame_end;
69 if (sscanf(buf,
"{%d}{%d}", &frame_start, &frame_end) == 2)
70 return frame_end - frame_start;
93 line[strcspn(line,
"\r\n")] = 0;
99 if ((sscanf(line,
"{%d}{}%6lf", &frame, &fps) == 2 ||
100 sscanf(line,
"{%d}{%*d}%6lf", &frame, &fps) == 2)
101 && frame <= 1 && fps > 3 && fps < 100)
102 pts_info =
av_d2q(fps, 100000);
103 if (!st->
codec->
extradata && sscanf(line,
"{DEFAULT}{}%c", &c) == 1) {
111 #define SKIP_FRAME_ID \
112 p = strchr(p, '}'); \
114 av_log(s, AV_LOG_WARNING, "Invalid event \"%s\"" \
115 " at line %d\n", line, i); \
144 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
148 min_ts, ts, max_ts, flags);
int64_t pos
byte position in stream, -1 if unknown
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
AVCodecContext * codec
Codec context associated with this stream.
void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
Remove and destroy all the subtitles packets.
AVPacket * ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, const uint8_t *event, int len, int merge)
Insert a new subtitle event.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
Generic read_packet() callback for subtitles demuxers using this queue system.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static av_cold int read_close(AVFormatContext *ctx)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
void * priv_data
Format private data.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVRational av_d2q(double d, int max) av_const
Convert a double precision floating point number to a rational.
void ff_subtitles_queue_finalize(FFDemuxSubtitlesQueue *q)
Set missing durations and sort subtitles by PTS, and then byte position.
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
static int read_header(FFV1Context *f)
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.
enum AVMediaType codec_type
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
rational number numerator/denominator
This structure contains the data a format has to probe a file.
static av_always_inline int ff_subtitles_next_line(const char *ptr)
Get the number of characters to increment to jump to the next line, or to the end of the string...
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.