mirror of https://git.ffmpeg.org/ffmpeg.git
avformat/wavdec: w64: do not error out for broken files if data start is found
Also attempt to fix invalid block_align value.
This commit is contained in:
parent
84e0e2f43e
commit
71716406e6
|
@ -885,8 +885,11 @@ static int w64_read_header(AVFormatContext *s)
|
|||
if (avio_read(pb, guid, 16) != 16)
|
||||
break;
|
||||
size = avio_rl64(pb);
|
||||
if (size <= 24 || INT64_MAX - size < avio_tell(pb))
|
||||
if (size <= 24 || INT64_MAX - size < avio_tell(pb)) {
|
||||
if (data_ofs)
|
||||
break;
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (!memcmp(guid, ff_w64_guid_fmt, 16)) {
|
||||
/* subtract chunk header size - normal wav file doesn't count it */
|
||||
|
@ -894,7 +897,18 @@ static int w64_read_header(AVFormatContext *s)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
avio_skip(pb, FFALIGN(size, INT64_C(8)) - size);
|
||||
if (st->codecpar->block_align) {
|
||||
int block_align = st->codecpar->block_align;
|
||||
|
||||
block_align = FFMAX(block_align,
|
||||
((st->codecpar->bits_per_coded_sample + 7) / 8) *
|
||||
st->codecpar->ch_layout.nb_channels);
|
||||
if (block_align > st->codecpar->block_align) {
|
||||
av_log(s, AV_LOG_WARNING, "invalid block_align: %d, broken file.\n",
|
||||
st->codecpar->block_align);
|
||||
st->codecpar->block_align = block_align;
|
||||
}
|
||||
}
|
||||
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
|
||||
} else if (!memcmp(guid, ff_w64_guid_fact, 16)) {
|
||||
int64_t samples;
|
||||
|
|
Loading…
Reference in New Issue