42 const unsigned char *ptr = p->
buf;
46 if (sscanf(ptr,
"%*u:%*u:%*u.%*u,%*u:%*u:%*u.%*u%c", &c) == 1)
48 if (!strncmp(ptr,
"[INFORMATION]", 13))
56 int hh1, mm1, ss1, ms1;
57 int hh2, mm2, ss2, ms2;
59 if (sscanf(s,
"%u:%u:%u.%u,%u:%u:%u.%u",
60 &hh1, &mm1, &ss1, &ms1, &hh2, &mm2, &ss2, &ms2) == 8) {
61 end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
62 *start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
63 *duration = end - *
start;
74 int res = 0, new_event = 1;
95 line[strcspn(line,
"\r\n")] = 0;
97 if (line[0] ==
'[' && strncmp(line,
"[br]", 4)) {
100 if (strstr(line,
"[COLF]") || strstr(line,
"[SIZE]") ||
101 strstr(line,
"[FONT]") || strstr(line,
"[STYLE]"))
106 if (!strncmp(line,
"[END INFORMATION]", 17) || !strncmp(line,
"[SUBTITLE]", 10)) {
111 }
else if (strncmp(line,
"[INFORMATION]", 13)) {
114 char key[32],
value[128];
116 for (i = 1; i <
sizeof(key) - 1 && line[i] && line[i] !=
']'; i++)
122 while (line[i] ==
' ')
124 while (j <
sizeof(value) - 1 && line[i] && line[i] !=
']')
125 value[j++] = line[i++];
131 }
else if (
read_ts(line, &pts_start, &duration) >= 0) {
149 sub->
pts = pts_start;
170 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
174 min_ts, ts, max_ts, flags);
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int64_t pos
byte position in stream, -1 if unknown
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
Remove and destroy all the subtitles packets.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
Generic read_packet() callback for subtitles demuxers using this queue system.
static av_cold int end(AVCodecContext *avctx)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static const uint8_t header[24]
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
AVDictionary * metadata
Metadata that applies to the whole file.
#define AV_BPRINT_SIZE_UNLIMITED
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
enum AVMediaType codec_type
General type of the encoded data.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
GLsizei GLboolean const GLfloat * value
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
This structure contains the data a format has to probe a file.
common internal api header.
void * priv_data
Format private data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVCodecParameters * codecpar
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
AVPacket * ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, const uint8_t *event, size_t len, int merge)
Insert a new subtitle event.
This structure stores compressed data.
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...
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.