33 #include "libavutil/avstring.h"
34 #include "libavutil/bprint.h"
35 #include "libavutil/intreadwrite.h"
46 return (sscanf(ptr,
"%*u:%*u:%*u.%*u %*u:%*u:%*u.%*u %c", &c) == 1 ||
47 sscanf(ptr,
"@%*u @%*u %c", &c) == 1);
52 const char *ptr = p->
buf;
58 while (ptr < ptr_end) {
61 if (*ptr !=
'#' && *ptr !=
'\n') {
71 static const char *
const cmds[] = {
106 unsigned hs, ms, ss, fs;
107 unsigned he,
me, se, fe;
108 int ts_start, ts_end;
111 if (sscanf(buf,
"%u:%u:%u.%u %u:%u:%u.%u %n",
113 &he, &me, &se, &fe, &len) == 8) {
114 ts_start = (hs*3600 + ms*60 + ss) * jacosub->
timeres + fs;
115 ts_end = (he*3600 + me*60 + se) * jacosub->
timeres + fe;
120 if (sscanf(buf,
"@%u @%u %n", &ts_start, &ts_end, &len) == 2)
126 ts_start = (ts_start + jacosub->
shift) * 100 / jacosub->
timeres;
127 ts_end = (ts_end + jacosub->
shift) * 100 / jacosub->
timeres;
129 *duration = ts_start + ts_end;
136 int a = 0,
b = 0,
c = 0, d = 0;
137 #define SSEP "%*1[.:]"
141 if (*buf ==
'-' || a < 0) {
147 case 4:
return sign * ((a*3600 +
b*60 +
c) * timeres + d);
148 case 3:
return sign * (( a*60 +
b) * timeres +
c);
149 case 2:
return sign * ((
a) * timeres +
b);
178 const char *p = line;
192 merge_line = len > 1 && !strcmp(&line[len - 2],
"\\\n");
205 cmd_len = strlen(
cmds[i]);
213 switch (
cmds[i][0]) {
222 jacosub->
timeres = strtol(p, NULL, 10);
238 for (i = 0; i < jacosub->
q.
nb_subs; i++) {
254 int64_t min_ts, int64_t ts, int64_t max_ts,
int flags)
258 min_ts, ts, max_ts, flags);
int64_t pos
byte position in stream, -1 if unknown
AVCodecContext * codec
Codec context associated with this stream.
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.
AVPacket * ff_subtitles_queue_insert(FFDemuxSubtitlesQueue *q, const uint8_t *event, int len, int merge)
Insert a new subtitle event.
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.
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
void * priv_data
Format private data.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int buf_size
Size of buf except extra allocated bytes.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Init a print buffer.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_ARRAY_ELEMS(a)
Buffer to print data progressively.
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)
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
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
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 int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
static av_always_inline const char * jss_skip_whitespace(const char *p)
common internal api header.
AVPacket * subs
array of subtitles packets
void av_bprintf(AVBPrint *buf, const char *fmt,...) av_printf_format(2
Append a formatted string to a print buffer.
This structure stores compressed data.
int nb_subs
number of subtitles packets
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...