History

avformat/smush: read ANIMv2 a/v parameters

SMUSH ANIM files with subversion 2 provide additional fields for framerate and samplerate, use them if available, otherwise default to 12 fps which is the default for almost all ANIMv2 since 1995. Fixes the too-fast playback of test files from LucasArts games released 1995-1997. It was not noticed since Audio for those isn't decoded by ffmpeg.

Manuel Lauss committed 1 year ago

Commit d2113431 parent 3b0e6c01 file · +14 −3Browse files

Unified · Split

libavformat/smush.c+14−3
@@ -51,7 +51,7 @@ static int smush_read_header(AVFormatContext *ctx) · 50 unmodified lines
5151 AVStream *vst, *ast;
5252 uint32_t magic, nframes, size, subversion, i;
5353 uint32_t width = 0, height = 0, got_audio = 0, read = 0;
54− uint32_t sample_rate, channels, palette[256];
54+ uint32_t sample_rate, channels, palette[256], frame_rate = 15;
5555 int ret;
5656
5757 magic = avio_rb32(pb);
@@ -64,6 +64,7 @@ static int smush_read_header(AVFormatContext *ctx) · 6 unmodified lines
6464 size = avio_rb32(pb);
6565 if (size < 3 * 256 + 6)
6666 return AVERROR_INVALIDDATA;
67+ size -= 3 * 256 + 6;
6768
6869 smush->version = 0;
6970 subversion = avio_rl16(pb);
@@ -76,7 +77,17 @@ static int smush_read_header(AVFormatContext *ctx) · 6 unmodified lines
7677 for (i = 0; i < 256; i++)
7778 palette[i] = avio_rb24(pb);
7879
79− avio_skip(pb, size - (3 * 256 + 6));
80+ if (subversion > 1) {
81+ if (size < 12)
82+ return AVERROR_INVALIDDATA;
83+ size -= 12;
84+ frame_rate = avio_rl32(pb);
85+ avio_skip(pb, 4); // max size of FRME chunk in file
86+ sample_rate = avio_rl32(pb);
87+ if (frame_rate < 1 || frame_rate > 70)
88+ frame_rate = 12;
89+ }
90+ avio_skip(pb, size);
8091 } else if (magic == MKBETAG('S', 'A', 'N', 'M')) {
8192 if (avio_rb32(pb) != MKBETAG('S', 'H', 'D', 'R'))
8293 return AVERROR_INVALIDDATA;
@@ -146,7 +157,7 @@ static int smush_read_header(AVFormatContext *ctx) · 63 unmodified lines
146157
147158 smush->video_stream_index = vst->index;
148159
149− avpriv_set_pts_info(vst, 64, 1, 15);
160+ avpriv_set_pts_info(vst, 64, 1, frame_rate);
150161
151162 vst->start_time = 0;
152163 vst->duration =

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t