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

Commit a5175b7a authored by Lajos Molnar's avatar Lajos Molnar Committed by android-build-merger
Browse files

Merge "Fix: Send valid frames for Vorbis in MKV" into qt-dev am: 00ffd9e0

am: a3e3dece

Change-Id: I4c8efb2d5c7bc22196b8b827d1f1f8ac5991ebae
parents b864e51c a3e3dece
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ private:
        HEVC,
        MP3,
        PCM,
        VORBIS,
        OTHER
    };

@@ -273,6 +274,8 @@ MatroskaSource::MatroskaSource(
        mType = MP3;
    } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) {
        mType = PCM;
    } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_VORBIS)) {
        mType = VORBIS;
    }
}

@@ -802,6 +805,26 @@ media_status_t MatroskaSource::readBlock() {
        AMediaFormat_setInt64(meta, AMEDIAFORMAT_KEY_TIME_US, timeUs);
        AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_IS_SYNC_FRAME, block->IsKey());

        if (mType == VORBIS) {
            int32_t sampleRate;
            if (!AMediaFormat_getInt32(trackInfo->mMeta, AMEDIAFORMAT_KEY_SAMPLE_RATE,
                                       &sampleRate)) {
                return AMEDIA_ERROR_MALFORMED;
            }
            int64_t durationUs;
            if (!AMediaFormat_getInt64(trackInfo->mMeta, AMEDIAFORMAT_KEY_DURATION,
                                       &durationUs)) {
                return AMEDIA_ERROR_MALFORMED;
            }
            // TODO: Explore if this can be handled similar to MPEG4 extractor where padding is
            // signalled instead of VALID_SAMPLES
            // Remaining valid samples in Vorbis track
            if (durationUs > timeUs) {
                int32_t validSamples = ((durationUs - timeUs) * sampleRate) / 1000000ll;
                AMediaFormat_setInt32(meta, AMEDIAFORMAT_KEY_VALID_SAMPLES, validSamples);
            }
        }

        status_t err = frame.Read(mExtractor->mReader, data + trackInfo->mHeaderLen);
        if (err == OK
                && mExtractor->mIsWebm