lavf/webvtt: use ff_subtitles_read_chunk().
The FATE test is updated because the line breaks in the dialogue rectangles are now proper CRLF.
This commit is contained in:
parent
3fa642d60f
commit
dc8b36746a
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_MAJOR 54
|
#define LIBAVFORMAT_VERSION_MAJOR 54
|
||||||
#define LIBAVFORMAT_VERSION_MINOR 59
|
#define LIBAVFORMAT_VERSION_MINOR 59
|
||||||
#define LIBAVFORMAT_VERSION_MICRO 101
|
#define LIBAVFORMAT_VERSION_MICRO 102
|
||||||
|
|
||||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
|
||||||
LIBAVFORMAT_VERSION_MINOR, \
|
LIBAVFORMAT_VERSION_MINOR, \
|
||||||
|
@ -54,29 +54,6 @@ static int64_t read_ts(const char *s)
|
|||||||
return AV_NOPTS_VALUE;
|
return AV_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t extract_cue(AVBPrint *buf, AVIOContext *pb)
|
|
||||||
{
|
|
||||||
int prev_chr_is_eol = 0;
|
|
||||||
int64_t pos = avio_tell(pb);
|
|
||||||
|
|
||||||
av_bprint_clear(buf);
|
|
||||||
for (;;) {
|
|
||||||
char c = avio_r8(pb);
|
|
||||||
if (!c)
|
|
||||||
break;
|
|
||||||
if (c == '\r' || c == '\n') {
|
|
||||||
if (prev_chr_is_eol)
|
|
||||||
break;
|
|
||||||
prev_chr_is_eol = (c == '\n');
|
|
||||||
} else
|
|
||||||
prev_chr_is_eol = 0;
|
|
||||||
if (c != '\r')
|
|
||||||
av_bprint_chars(buf, c, 1);
|
|
||||||
}
|
|
||||||
av_bprint_chars(buf, '\0', 1);
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int webvtt_read_header(AVFormatContext *s)
|
static int webvtt_read_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
WebVTTContext *webvtt = s->priv_data;
|
WebVTTContext *webvtt = s->priv_data;
|
||||||
@ -94,17 +71,21 @@ static int webvtt_read_header(AVFormatContext *s)
|
|||||||
av_bprint_init(&cue, 0, AV_BPRINT_SIZE_UNLIMITED);
|
av_bprint_init(&cue, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int i, len;
|
int i;
|
||||||
int64_t pos = extract_cue(&cue, s->pb);
|
int64_t pos;
|
||||||
AVPacket *sub;
|
AVPacket *sub;
|
||||||
const char *p = cue.str;
|
const char *p, *identifier;
|
||||||
const char *identifier = p;
|
|
||||||
//const char *settings = NULL;
|
//const char *settings = NULL;
|
||||||
int64_t ts_start, ts_end;
|
int64_t ts_start, ts_end;
|
||||||
|
|
||||||
if (!*p) // EOF
|
ff_subtitles_read_chunk(s->pb, &cue);
|
||||||
|
|
||||||
|
if (!cue.len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
p = identifier = cue.str;
|
||||||
|
pos = avio_tell(s->pb);
|
||||||
|
|
||||||
/* ignore header chunk */
|
/* ignore header chunk */
|
||||||
if (!strncmp(p, "\xEF\xBB\xBFWEBVTT", 9) ||
|
if (!strncmp(p, "\xEF\xBB\xBFWEBVTT", 9) ||
|
||||||
!strncmp(p, "WEBVTT", 6))
|
!strncmp(p, "WEBVTT", 6))
|
||||||
@ -143,8 +124,7 @@ static int webvtt_read_header(AVFormatContext *s)
|
|||||||
p++;
|
p++;
|
||||||
|
|
||||||
/* create packet */
|
/* create packet */
|
||||||
len = cue.str + cue.len - p - 1;
|
sub = ff_subtitles_queue_insert(&webvtt->q, p, strlen(p), 0);
|
||||||
sub = ff_subtitles_queue_insert(&webvtt->q, p, len, 0);
|
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
res = AVERROR(ENOMEM);
|
res = AVERROR(ENOMEM);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1 +1 @@
|
|||||||
5384a70c89ddca4b007fb7ffba95cffb
|
2cf38e2c99f8717f78a91a3f31197fb4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user