diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-12-29 23:26:36 +0100 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-12-31 00:41:35 +0100 |
commit | 1f265f52050e967d78e29d8e115c7dc849b14c4e (patch) | |
tree | c35814a7a10c70da45ef5700bd6b401a59558ba0 /libavformat | |
parent | faa94061dd7236cbaabd483e7b2df148cdbefb7f (diff) | |
download | ffmpeg-1f265f52050e967d78e29d8e115c7dc849b14c4e.tar.gz |
microdvd: sanitize AVPackets.
Current MicroDVD AVPackets contain timing information and trailing line
breaks. The data is now only composed of the markup data. Doing this
consistently between text subtitles decoders allows to use different
codec for various formats. For instance, MicroDVD markup is sometimes
found in some VPlayer files. Also, generally speaking, the subtitles
text decoders have no use of these timings (and they must not use them
since it would break any user timing adjustment).
Technically, this is a major ABI break. In practice, a mismatching
lavf/lavc will now error out for MicroDVD decoding. Supporting both
formats requires unnecessary complex and fragile code.
FATE needs update because line breaks in the ASS file were "\n" (because
that's what is used in the original file). ASS format expect "\r\n" line
breaks; this commit fixes this issue. Also note that this "\r\n"
trailing need to be moved at some point from the decoders to the ASS
muxer.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/microdvddec.c | 23 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
2 files changed, 19 insertions, 6 deletions
diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c index 5d5b83fea8..96ffa3da07 100644 --- a/libavformat/microdvddec.c +++ b/libavformat/microdvddec.c @@ -83,18 +83,19 @@ static int microdvd_read_header(AVFormatContext *s) return AVERROR(ENOMEM); while (!url_feof(s->pb)) { + char *p = line; AVPacket *sub; int64_t pos = avio_tell(s->pb); int len = ff_get_line(s->pb, line, sizeof(line)); if (!len) break; - if (i < 3) { + line[strcspn(line, "\r\n")] = 0; + if (i++ < 3) { int frame; double fps; char c; - i++; if ((sscanf(line, "{%d}{}%6lf", &frame, &fps) == 2 || sscanf(line, "{%d}{%*d}%6lf", &frame, &fps) == 2) && frame <= 1 && fps > 3 && fps < 100) @@ -107,12 +108,24 @@ static int microdvd_read_header(AVFormatContext *s) continue; } } - sub = ff_subtitles_queue_insert(µdvd->q, line, len, 0); +#define SKIP_FRAME_ID \ + p = strchr(p, '}'); \ + if (!p) { \ + av_log(s, AV_LOG_WARNING, "Invalid event \"%s\"" \ + " at line %d\n", line, i); \ + continue; \ + } \ + p++ + SKIP_FRAME_ID; + SKIP_FRAME_ID; + if (!*p) + continue; + sub = ff_subtitles_queue_insert(µdvd->q, p, strlen(p), 0); if (!sub) return AVERROR(ENOMEM); sub->pos = pos; - sub->pts = get_pts(sub->data); - sub->duration = get_duration(sub->data); + sub->pts = get_pts(line); + sub->duration = get_duration(line); } ff_subtitles_queue_finalize(µdvd->q); avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num); diff --git a/libavformat/version.h b/libavformat/version.h index 90d47d02d1..6fb42d84ed 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -30,7 +30,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 54 -#define LIBAVFORMAT_VERSION_MINOR 56 +#define LIBAVFORMAT_VERSION_MINOR 57 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |