diff options
author | Anton Khirnov <anton@khirnov.net> | 2013-11-17 11:41:08 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2024-02-07 11:46:55 +0100 |
commit | b711194cc55b62030b519b4ac529e1f3d65984cc (patch) | |
tree | 1190c51f05562ea43b9fb352e835c4d603fa220f | |
parent | 46f5e6c0dd84b59e973ec2e4128fb27e612afb6e (diff) |
lavf/anm: set average framerate and ts_flags
Also, validate the framerate.
-rw-r--r-- | libavformat/anm.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libavformat/anm.c b/libavformat/anm.c index f2ac6958a9..f14da8a511 100644 --- a/libavformat/anm.c +++ b/libavformat/anm.c @@ -82,7 +82,7 @@ static int read_header(AVFormatContext *s) AnmDemuxContext *anm = s->priv_data; AVIOContext *pb = s->pb; AVStream *st; - int i, ret; + int i, ret, fps; avio_skip(pb, 4); /* magic number */ if (avio_rl16(pb) != MAX_PAGES) { @@ -129,7 +129,18 @@ static int read_header(AVFormatContext *s) avio_skip(pb, 32); /* record_types */ st->nb_frames = avio_rl32(pb); - avpriv_set_pts_info(st, 64, 1, avio_rl16(pb)); + + fps = avio_rl16(pb); + if (!fps) { + av_log(s, AV_LOG_ERROR, "Invalid framerate.\n"); + goto invalid; + } + + avpriv_set_pts_info(st, 64, 1, fps); + st->avg_frame_rate = (AVRational){ fps, 1 }; + + st->ts_flags = AVFORMAT_TS_FLAG_RATE; + avio_skip(pb, 58); /* color cycling and palette data */ |