If blocks were already demuxed we would skip them and ask for new ones. For files with few blocks it would return EOF without actually checking the content. Also make demux limit higher. In practice it doesn't matter, because if it is image, video track will have only 1 block. And if it is not image it will break on 2nd video block.
Unified · Split
| @@ -2044,14 +2044,14 @@ static void probe_if_image(demuxer_t *demuxer) · 2043 unmodified lines | |||
| 2044 | 2044 | ||
| 2045 | int64_t timecode = -1; | 2045 | int64_t timecode = -1; |
| 2046 | // Arbitrary restriction on packet reading. | 2046 | // Arbitrary restriction on packet reading. |
| 2047 | for (int i = 0; i < 1000; i++) { | 2047 | for (size_t block = 0; block < 100000; block++) { |
| 2048 | int ret = read_next_block_into_queue(demuxer); | 2048 | if (block >= mkv_d->num_blocks && read_next_block_into_queue(demuxer) != 1) |
| 2049 | if (ret == 1 && mkv_d->blocks[i].track == track) { | 2049 | break; |
| 2050 | if (timecode != mkv_d->blocks[i].timecode) | 2050 | if (mkv_d->blocks[block].track != track) |
| 2051 | ++video_blocks; | 2051 | continue; |
| 2052 | timecode = mkv_d->blocks[i].timecode; | 2052 | if (timecode != mkv_d->blocks[block].timecode) |
| 2053 | } | 2053 | ++video_blocks; |
| 2054 | // No need to read more | 2054 | timecode = mkv_d->blocks[block].timecode; |
| 2055 | if (video_blocks > 1) | 2055 | if (video_blocks > 1) |
| 2056 | break; | 2056 | break; |
| 2057 | } | 2057 | } |