Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 239dab84 authored by guochuang's avatar guochuang
Browse files

Matroskaextractor: improve findThumbnails() time.



For Matroska, traversing to find the first 20 keyframes is very
time-consuming, typically 1000 (1 key frame per 50 frames) - 2000 (
1 key frame per 100 frames) iterations are required, resulting in
findThumbnails() takes 2-4s, or even more.
Now add an additional judgment condition: when the parser time (the
timestamp of the current iteration block) exceeds 20s and at least one
key frame has been found, end the iteration.

Bug: 332463097
Test: atest CtsMediaExtractorTestCases
Change-Id: I21303552c4c862dd960054d86e1133e067f9326a
Signed-off-by: default avatarguochuang <guochuang@xiaomi.corp-partner.google.com>
parent 41829023
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -2279,6 +2279,8 @@ void MatroskaExtractor::findThumbnails() {
        int64_t thumbnailTimeUs = 0;
        size_t maxBlockSize = 0;
        while (!iter.eos() && j < 20) {
            int64_t blockTimeUs = iter.blockTimeUs();

            if (iter.block()->IsKey()) {
                ++j;

@@ -2289,8 +2291,12 @@ void MatroskaExtractor::findThumbnails() {

                if (blockSize > maxBlockSize) {
                    maxBlockSize = blockSize;
                    thumbnailTimeUs = iter.blockTimeUs();
                    thumbnailTimeUs = blockTimeUs;
                }
            }
            // Exit after 20s if we've already found at least one key frame.
            if (blockTimeUs > 20000000 && maxBlockSize > 0) {
                break;
            }
            iter.advance();
        }