mirror of https://github.com/nu774/fdkaac.git
wav/caf parser: add format checks
fixes https://github.com/nu774/fdkaac/issues/54
This commit is contained in:
parent
1a1ee2924f
commit
ecddb7d633
|
@ -75,8 +75,10 @@ int caf_desc(caf_reader_t *reader, int64_t chunk_size)
|
||||||
ENSURE(mFormatID == M4AF_FOURCC('l','p','c','m'));
|
ENSURE(mFormatID == M4AF_FOURCC('l','p','c','m'));
|
||||||
ENSURE(mSampleRate && mBytesPerPacket &&
|
ENSURE(mSampleRate && mBytesPerPacket &&
|
||||||
mChannelsPerFrame >= 1 && mChannelsPerFrame <= 8 &&
|
mChannelsPerFrame >= 1 && mChannelsPerFrame <= 8 &&
|
||||||
mBitsPerChannel && mFramesPerPacket == 1 &&
|
mBitsPerChannel > 0 && mBitsPerChannel < 256 &&
|
||||||
|
mFramesPerPacket == 1 &&
|
||||||
mBytesPerPacket % mChannelsPerFrame == 0 &&
|
mBytesPerPacket % mChannelsPerFrame == 0 &&
|
||||||
|
mBytesPerPacket < 256 &&
|
||||||
mBytesPerPacket >= mChannelsPerFrame * ((mBitsPerChannel + 7) / 8));
|
mBytesPerPacket >= mChannelsPerFrame * ((mBitsPerChannel + 7) / 8));
|
||||||
|
|
||||||
desc->sample_rate = mSampleRate;
|
desc->sample_rate = mSampleRate;
|
||||||
|
|
|
@ -113,8 +113,10 @@ int wav_fmt(wav_reader_t *reader, uint32_t size)
|
||||||
wValidBitsPerSample = wBitsPerSample;
|
wValidBitsPerSample = wBitsPerSample;
|
||||||
|
|
||||||
ENSURE(wFormatTag == 1 || wFormatTag == 3 || wFormatTag == 0xfffe);
|
ENSURE(wFormatTag == 1 || wFormatTag == 3 || wFormatTag == 0xfffe);
|
||||||
ENSURE(nChannels && nSamplesPerSec && nAvgBytesPerSec &&
|
ENSURE(nChannels > 0 && nChannels <= 8 &&
|
||||||
nBlockAlign && wBitsPerSample && !(wBitsPerSample & 7) &&
|
nSamplesPerSec && nAvgBytesPerSec &&
|
||||||
|
nBlockAlign && nBlockAlign < 256 &&
|
||||||
|
wBitsPerSample && wBitsPerSample < 256 && !(wBitsPerSample & 7) &&
|
||||||
nBlockAlign == nChannels * wBitsPerSample / 8);
|
nBlockAlign == nChannels * wBitsPerSample / 8);
|
||||||
|
|
||||||
if (wFormatTag == 3)
|
if (wFormatTag == 3)
|
||||||
|
|
Loading…
Reference in New Issue