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

Commit edf4e6f0 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change I8f658214 into eclair-mr2

* changes:
  Minor tweaks to the mp3 and aac software decoders, propagate duration to output format.
parents d912f464 ebd0d94d
Loading
Loading
Loading
Loading
+12 −7
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@ AACDecoder::AACDecoder(const sp<MediaSource> &source)
      mBufferGroup(NULL),
      mBufferGroup(NULL),
      mConfig(new tPVMP4AudioDecoderExternal),
      mConfig(new tPVMP4AudioDecoderExternal),
      mDecoderBuf(NULL),
      mDecoderBuf(NULL),
      mLastSeekTimeUs(0),
      mAnchorTimeUs(0),
      mNumSamplesOutput(0),
      mNumSamplesOutput(0),
      mInputBuffer(NULL) {
      mInputBuffer(NULL) {
}
}
@@ -79,7 +79,7 @@ status_t AACDecoder::start(MetaData *params) {


    mSource->start();
    mSource->start();


    mLastSeekTimeUs = 0;
    mAnchorTimeUs = 0;
    mNumSamplesOutput = 0;
    mNumSamplesOutput = 0;
    mStarted = true;
    mStarted = true;


@@ -112,13 +112,16 @@ sp<MetaData> AACDecoder::getFormat() {


    int32_t numChannels;
    int32_t numChannels;
    int32_t sampleRate;
    int32_t sampleRate;
    int64_t durationUs;
    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
    CHECK(srcFormat->findInt64(kKeyDuration, &durationUs));


    sp<MetaData> meta = new MetaData;
    sp<MetaData> meta = new MetaData;
    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
    meta->setInt32(kKeyChannelCount, numChannels);
    meta->setInt32(kKeyChannelCount, numChannels);
    meta->setInt32(kKeySampleRate, sampleRate);
    meta->setInt32(kKeySampleRate, sampleRate);
    meta->setInt64(kKeyDuration, durationUs);


    return meta;
    return meta;
}
}
@@ -150,11 +153,13 @@ status_t AACDecoder::read(
            return err;
            return err;
        }
        }


        if (seekTimeUs >= 0) {
        int64_t timeUs;
            CHECK(mInputBuffer->meta_data()->findInt64(
        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
                        kKeyTime, &mLastSeekTimeUs));
            mAnchorTimeUs = timeUs;

            mNumSamplesOutput = 0;
            mNumSamplesOutput = 0;
        } else {
            // We must have a new timestamp after seeking.
            CHECK(seekTimeUs < 0);
        }
        }
    }
    }


@@ -189,7 +194,7 @@ status_t AACDecoder::read(


    buffer->meta_data()->setInt64(
    buffer->meta_data()->setInt64(
            kKeyTime,
            kKeyTime,
            mLastSeekTimeUs
            mAnchorTimeUs
                + (mNumSamplesOutput * 1000000) / mConfig->samplingRate);
                + (mNumSamplesOutput * 1000000) / mConfig->samplingRate);


    mNumSamplesOutput += mConfig->frameLength;
    mNumSamplesOutput += mConfig->frameLength;
+6 −0
Original line number Original line Diff line number Diff line
@@ -78,13 +78,16 @@ sp<MetaData> MP3Decoder::getFormat() {


    int32_t numChannels;
    int32_t numChannels;
    int32_t sampleRate;
    int32_t sampleRate;
    int64_t durationUs;
    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
    CHECK(srcFormat->findInt64(kKeyDuration, &durationUs));


    sp<MetaData> meta = new MetaData;
    sp<MetaData> meta = new MetaData;
    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
    meta->setInt32(kKeyChannelCount, numChannels);
    meta->setInt32(kKeyChannelCount, numChannels);
    meta->setInt32(kKeySampleRate, sampleRate);
    meta->setInt32(kKeySampleRate, sampleRate);
    meta->setInt64(kKeyDuration, durationUs);


    return meta;
    return meta;
}
}
@@ -120,6 +123,9 @@ status_t MP3Decoder::read(
        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
        if (mInputBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) {
            mAnchorTimeUs = timeUs;
            mAnchorTimeUs = timeUs;
            mNumSamplesOutput = 0;
            mNumSamplesOutput = 0;
        } else {
            // We must have a new timestamp after seeking.
            CHECK(seekTimeUs < 0);
        }
        }
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ private:


    tPVMP4AudioDecoderExternal *mConfig;
    tPVMP4AudioDecoderExternal *mConfig;
    void *mDecoderBuf;
    void *mDecoderBuf;
    int64_t mLastSeekTimeUs;
    int64_t mAnchorTimeUs;
    int64_t mNumSamplesOutput;
    int64_t mNumSamplesOutput;


    MediaBuffer *mInputBuffer;
    MediaBuffer *mInputBuffer;