47 return (sscanf(ptr,
"%*u:%*u:%*u.%*u %*u:%*u:%*u.%*u %c", &c) == 1 ||
48 (sscanf(ptr,
"@%u @%u %c", &fs, &fe, &c) == 3 && fs < fe));
53 const char *ptr = p->
buf;
59 while (ptr < ptr_end) {
62 if (*ptr !=
'#' && *ptr !=
'\n') {
72 static const char *
const cmds[] = {
107 unsigned hs, ms, ss, fs;
108 unsigned he,
me, se, fe;
109 int ts_start, ts_end;
112 if (sscanf(buf,
"%u:%u:%u.%u %u:%u:%u.%u %n",
114 &he, &me, &se, &fe, &len) == 8) {
115 ts_start = (hs*3600 + ms*60 + ss) * jacosub->
timeres + fs;
116 ts_end = (he*3600 + me*60 + se) * jacosub->
timeres + fe;
121 if (sscanf(buf,
"@%u @%u %n", &ts_start, &ts_end, &len) == 2)
127 ts_start = (ts_start + jacosub->
shift) * 100 / jacosub->
timeres;
128 ts_end = (ts_end + jacosub->
shift) * 100 / jacosub->
timeres;
130 *duration = ts_start + ts_end;
137 int a = 0,
b = 0,
c = 0, d = 0;
138 #define SSEP "%*1[.:]"
142 if (*buf ==
'-' || a < 0) {
148 case 4:
return sign * ((a*3600 +
b*60 +
c) * timeres + d);
149 case 3:
return sign * (( a*60 +
b) * timeres +
c);
150 case 2:
return sign * ((
a) * timeres +
b);
179 const char *p = line;
193 merge_line = len > 1 && !strcmp(&line[len - 2],
"\\\n");
206 cmd_len = strlen(
cmds[i]);
214 switch (
cmds[i][0]) {
239 for (i = 0; i < jacosub->
q.
nb_subs; i++) {
258 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
262 min_ts, ts, max_ts, flags);
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int64_t pos
byte position in stream, -1 if unknown
void ff_subtitles_queue_clean(FFDemuxSubtitlesQueue *q)
Remove and destroy all the subtitles packets.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
int ff_subtitles_queue_read_packet(FFDemuxSubtitlesQueue *q, AVPacket *pkt)
Generic read_packet() callback for subtitles demuxers using this queue system.
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]
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
#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)
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
#define FF_ARRAY_ELEMS(a)
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static av_always_inline int jss_whitespace(char c)
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
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.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
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...
static av_always_inline const char * jss_skip_whitespace(const char *p)
common internal api header.
AVPacket * subs
array of subtitles packets
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void * priv_data
Format private data.
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.
int nb_subs
number of subtitles packets
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...