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
51 AVStream *vst, *ast;51 AVStream *vst, *ast;
52 uint32_t magic, nframes, size, subversion, i;52 uint32_t magic, nframes, size, subversion, i;
53 uint32_t width = 0, height = 0, got_audio = 0, read = 0;53 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;
55 int ret;55 int ret;
56 56
57 magic = avio_rb32(pb);57 magic = avio_rb32(pb);
@@ -64,6 +64,7 @@ static int smush_read_header(AVFormatContext *ctx) · 6 unmodified lines
64 size = avio_rb32(pb);64 size = avio_rb32(pb);
65 if (size < 3 * 256 + 6)65 if (size < 3 * 256 + 6)
66 return AVERROR_INVALIDDATA;66 return AVERROR_INVALIDDATA;
67 size -= 3 * 256 + 6;
67 68
68 smush->version = 0;69 smush->version = 0;
69 subversion = avio_rl16(pb);70 subversion = avio_rl16(pb);
@@ -76,7 +77,17 @@ static int smush_read_header(AVFormatContext *ctx) · 6 unmodified lines
76 for (i = 0; i < 256; i++)77 for (i = 0; i < 256; i++)
77 palette[i] = avio_rb24(pb);78 palette[i] = avio_rb24(pb);
78 79
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);
80 } else if (magic == MKBETAG('S', 'A', 'N', 'M')) {91 } else if (magic == MKBETAG('S', 'A', 'N', 'M')) {
81 if (avio_rb32(pb) != MKBETAG('S', 'H', 'D', 'R'))92 if (avio_rb32(pb) != MKBETAG('S', 'H', 'D', 'R'))
82 return AVERROR_INVALIDDATA;93 return AVERROR_INVALIDDATA;
@@ -146,7 +157,7 @@ static int smush_read_header(AVFormatContext *ctx) · 63 unmodified lines
146 157
147 smush->video_stream_index = vst->index;158 smush->video_stream_index = vst->index;
148 159
149 avpriv_set_pts_info(vst, 64, 1, 15);160 avpriv_set_pts_info(vst, 64, 1, frame_rate);
150 161
151 vst->start_time = 0;162 vst->start_time = 0;
152 vst->duration =163 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