Commit 0786598f authored by wm4's avatar wm4 Committed by Clément Bœsch

avformat/microdvd: skip BOM properly

The BOM is already skipped in the probe function, but not the header
read function. This could cause the header to be misparsed, such as
not interpreting the FPS line.
parent b79dfd16
...@@ -71,22 +71,29 @@ static int get_duration(const char *buf) ...@@ -71,22 +71,29 @@ static int get_duration(const char *buf)
return -1; return -1;
} }
static const char *bom = "\xEF\xBB\xBF";
static int microdvd_read_header(AVFormatContext *s) static int microdvd_read_header(AVFormatContext *s)
{ {
AVRational pts_info = (AVRational){ 2997, 125 }; /* default: 23.976 fps */ AVRational pts_info = (AVRational){ 2997, 125 }; /* default: 23.976 fps */
MicroDVDContext *microdvd = s->priv_data; MicroDVDContext *microdvd = s->priv_data;
AVStream *st = avformat_new_stream(s, NULL); AVStream *st = avformat_new_stream(s, NULL);
int i = 0; int i = 0;
char line[MAX_LINESIZE]; char line_buf[MAX_LINESIZE];
if (!st) if (!st)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
while (!url_feof(s->pb)) { while (!url_feof(s->pb)) {
char *p = line; char *p;
AVPacket *sub; AVPacket *sub;
int64_t pos = avio_tell(s->pb); int64_t pos = avio_tell(s->pb);
int len = ff_get_line(s->pb, line, sizeof(line)); int len = ff_get_line(s->pb, line_buf, sizeof(line_buf));
char *line = line_buf;
if (!strncmp(line, bom, 3))
line += 3;
p = line;
if (!len) if (!len)
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment