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

Commit c1e24ce7 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

MPEG4Extractor: reduce buffer size for audio tracks

We don't need 3.4 MB buffers for audio, and also don't need 8 of them.
Reduce the size of audio buffers, and allocate fewer buffers initially,
but leave the limit at 8.

Bug: 79420581
Test: manual, Camera, CTS
Change-Id: I180c42c59735b9f04eeeea4f4bd5976da50f5ec6
parent 1bf09f5b
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -1610,7 +1610,10 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {

                const char *mime;
                CHECK(mLastTrack->meta.findCString(kKeyMIMEType, &mime));
                if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
                if (!strncmp(mime, "audio/", 6)) {
                    // for audio, use 128KB
                    max_size = 1024 * 128;
                } else if (!strcmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
                        || !strcmp(mime, MEDIA_MIMETYPE_VIDEO_HEVC)) {
                    // AVC & HEVC requires compression ratio of at least 2, and uses
                    // macroblocks
@@ -3858,9 +3861,10 @@ status_t MPEG4Source::start(MetaDataBase *params) {
    }

    // Allow up to kMaxBuffers, but not if the total exceeds kMaxBufferSize.
    const size_t kInitialBuffers = 2;
    const size_t kMaxBuffers = 8;
    const size_t buffers = min(kMaxBufferSize / max_size, kMaxBuffers);
    mGroup = new MediaBufferGroup(buffers, max_size);
    const size_t realMaxBuffers = min(kMaxBufferSize / max_size, kMaxBuffers);
    mGroup = new MediaBufferGroup(kInitialBuffers, max_size, realMaxBuffers);
    mSrcBuffer = new (std::nothrow) uint8_t[max_size];
    if (mSrcBuffer == NULL) {
        // file probably specified a bad max size