There is an irregular frame inserted in the test.flac. The frame blocksize is expected to be fixed value 4096, but one frame with variable blocksize 4608 is inserted in that file. As a result, the index of the next frame will become a larger number than expected by our [calculation][0].
The index is calculated by
```cpp
mIndex = Header().mVariableBlockSize
? Header().mFrameOrSampleNum
: Header().mFrameOrSampleNum *
std::max(Header().mBlocksize, aPreviousBlocksize);
```
Suppose the blocksize is fixed to 4096 for mFrameOrSampleNum in [0, 98], the blocksize becomes variable to 4608 for mFrameOrSampleNum = 99 (actually it might be a random number), then the blocksize becomes fixed to 4096 again for the reset of the files, then
1. `mIndex(i)` = `i` * 4096 for `i` in [0, 99]
2. `mIndex(99)` = 100
3. `mIndex(100)` = 100 * 4608 = 460800
4. `mIndex(j)` = j * 4096 for j >= 101
As a result, the `mIndex(101)` = 101 * 4096 = 413696 < `mIndex(100)`.
I guess that's why it cannot be decoded normally. The file is poorly muxed.
[0]: https://searchfox.org/mozilla-central/rev/dc0adc07db3df9431a0876156f50c65d580010cb/dom/media/flac/FlacDemuxer.cpp#356
Bug 1528265 Comment 5 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
There is an irregular frame inserted in the test.flac. The frame blocksize is expected to be fixed value 4096, but one frame with variable blocksize 4608 is inserted in that file. As a result, the index of the next frame will become a larger number than expected by our [calculation][0].
The index is calculated by
```cpp
mIndex = Header().mVariableBlockSize
? Header().mFrameOrSampleNum
: Header().mFrameOrSampleNum *
std::max(Header().mBlocksize, aPreviousBlocksize);
```
Suppose the blocksize is fixed to 4096 for mFrameOrSampleNum in [0, 98], the blocksize becomes variable to 4608 for mFrameOrSampleNum = 99 (actually it might be a random number), then the blocksize becomes fixed to 4096 again for the reset of the files, then
1. `mIndex(i)` = `i` * 4096 for `i` in [0, 99]
2. `mIndex(99)` = 99
3. `mIndex(100)` = 100 * 4608 = 460800
4. `mIndex(j)` = j * 4096 for j >= 101
As a result, the `mIndex(101)` = 101 * 4096 = 413696 < `mIndex(100)`.
I guess that's why it cannot be decoded normally. The file is poorly muxed.
[0]: https://searchfox.org/mozilla-central/rev/dc0adc07db3df9431a0876156f50c65d580010cb/dom/media/flac/FlacDemuxer.cpp#356
There is an irregular frame inserted in the test.flac. The frame blocksize is expected to be fixed value 4096, but one frame with variable blocksize 4608 is inserted in that file. As a result, the index of the next frame will become a larger number than expected by our [calculation][0].
The index is calculated by
```cpp
mIndex = Header().mVariableBlockSize
? Header().mFrameOrSampleNum
: Header().mFrameOrSampleNum *
std::max(Header().mBlocksize, aPreviousBlocksize);
```
Suppose the blocksize is fixed to 4096 for mFrameOrSampleNum in [0, 98], the blocksize becomes variable to 4608 for mFrameOrSampleNum = 99 (actually it might be a random number), then the blocksize becomes fixed to 4096 again for the reset of the files, then
1. `mIndex(i)` = `i` * 4096 for `i` in [0, 98]
2. `mIndex(99)` = 99
3. `mIndex(100)` = 100 * 4608 = 460800
4. `mIndex(j)` = j * 4096 for j >= 101
As a result, the `mIndex(101)` = 101 * 4096 = 413696 < `mIndex(100)`.
I guess that's why it cannot be decoded normally. The file is poorly muxed.
[0]: https://searchfox.org/mozilla-central/rev/dc0adc07db3df9431a0876156f50c65d580010cb/dom/media/flac/FlacDemuxer.cpp#356
There is an irregular frame inserted in the test.flac. The frame blocksize is expected to be fixed value 4096, but one frame with variable blocksize 4608 is inserted in that file. As a result, the index of the next frame will become a larger number than expected by our [calculation][0].
The index is calculated by
```cpp
mIndex = Header().mVariableBlockSize
? Header().mFrameOrSampleNum
: Header().mFrameOrSampleNum *
std::max(Header().mBlocksize, aPreviousBlocksize);
```
Suppose the blocksize is fixed to 4096 for mFrameOrSampleNum in [0, 98], the blocksize becomes variable to 4608 for mFrameOrSampleNum = 99 (actually it might be a random number), then the blocksize becomes fixed to 4096 again for the reset of the files, then
1. `mIndex(i)` = `i` * 4096 for `i` in [0, 98]
2. `mIndex(99)` = 99
3. `mIndex(100)` = 100 * 4608 = 460800
4. `mIndex(j)` = j * 4096 for j >= 101
As a result, the `mIndex(101)` = 101 * 4096 = 413696 < `mIndex(100)`.
I guess that's why the playback hangs in the middle. The file is poorly muxed.
[0]: https://searchfox.org/mozilla-central/rev/dc0adc07db3df9431a0876156f50c65d580010cb/dom/media/flac/FlacDemuxer.cpp#356