History

demux_mkv: fix image detection

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.

Kacper Michajłow committed 2 years ago

Commit 22ed5d01 parent abe8f3f1 file · +8 −8Browse files

Unified · Split

demux/demux_mkv.c+8−8
@@ -2044,14 +2044,14 @@ static void probe_if_image(demuxer_t *demuxer) · 2043 unmodified lines
20442044
20452045 int64_t timecode = -1;
20462046 // Arbitrary restriction on packet reading.
2047− for (int i = 0; i < 1000; i++) {
2048− int ret = read_next_block_into_queue(demuxer);
2049− if (ret == 1 && mkv_d->blocks[i].track == track) {
2050− if (timecode != mkv_d->blocks[i].timecode)
2051− ++video_blocks;
2052− timecode = mkv_d->blocks[i].timecode;
2053− }
2054− // No need to read more
2047+ for (size_t block = 0; block < 100000; block++) {
2048+ if (block >= mkv_d->num_blocks && read_next_block_into_queue(demuxer) != 1)
2049+ break;
2050+ if (mkv_d->blocks[block].track != track)
2051+ continue;
2052+ if (timecode != mkv_d->blocks[block].timecode)
2053+ ++video_blocks;
2054+ timecode = mkv_d->blocks[block].timecode;
20552055 if (video_blocks > 1)
20562056 break;
20572057 }

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