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

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

Merge change I85adf5e5 into eclair-mr2

* changes:
  Propagate duration from input to output only if available, support multiple full frames of audio per input buffer in AMR/AAC decoders.
parents 930ab3d9 85adf5e5
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -293,6 +293,7 @@ sp<MediaSource> OMXCodec::Create(
    CHECK(success);

#if BUILD_WITH_FULL_STAGEFRIGHT
    if (!createEncoder) {
        if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
            return new AACDecoder(source);
        } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) {
@@ -305,6 +306,7 @@ sp<MediaSource> OMXCodec::Create(
                    && (flags & kPreferSoftwareCodecs)) {
            return new AVCDecoder(source);
        }
    }
#endif

    Vector<String8> matchingCodecs;
+5 −3
Original line number Diff line number Diff line
@@ -128,16 +128,18 @@ sp<MetaData> AACDecoder::getFormat() {

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

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

    int64_t durationUs;
    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
        meta->setInt64(kKeyDuration, durationUs);
    }

    return meta;
}
+14 −7
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ sp<MetaData> AMRNBDecoder::getFormat() {

    int32_t numChannels;
    int32_t sampleRate;
    int64_t durationUs;

    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
    CHECK_EQ(numChannels, 1);
@@ -95,13 +94,15 @@ sp<MetaData> AMRNBDecoder::getFormat() {
    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
    CHECK_EQ(sampleRate, kSampleRate);

    CHECK(srcFormat->findInt64(kKeyDuration, &durationUs));

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

    int64_t durationUs;
    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
        meta->setInt64(kKeyDuration, durationUs);
    }

    return meta;
}
@@ -160,10 +161,16 @@ status_t AMRNBDecoder::read(

    buffer->set_range(0, kNumSamplesPerFrame * sizeof(int16_t));

    CHECK_EQ(numBytesRead, mInputBuffer->range_length());
    CHECK(numBytesRead <= mInputBuffer->range_length());

    mInputBuffer->set_range(
            mInputBuffer->range_offset() + numBytesRead,
            mInputBuffer->range_length() - numBytesRead);

    if (mInputBuffer->range_length() == 0) {
        mInputBuffer->release();
        mInputBuffer = NULL;
    }

    buffer->meta_data()->setInt64(
            kKeyTime,
+14 −7
Original line number Diff line number Diff line
@@ -93,7 +93,6 @@ sp<MetaData> AMRWBDecoder::getFormat() {

    int32_t numChannels;
    int32_t sampleRate;
    int64_t durationUs;

    CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels));
    CHECK_EQ(numChannels, 1);
@@ -101,13 +100,15 @@ sp<MetaData> AMRWBDecoder::getFormat() {
    CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate));
    CHECK_EQ(sampleRate, kSampleRate);

    CHECK(srcFormat->findInt64(kKeyDuration, &durationUs));

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

    int64_t durationUs;
    if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
        meta->setInt64(kKeyDuration, durationUs);
    }

    return meta;
}
@@ -170,7 +171,7 @@ status_t AMRWBDecoder::read(

    int16 mode = ((inputPtr[0] >> 3) & 0x0f);
    size_t frameSize = getFrameSize(mode);
    CHECK_EQ(mInputBuffer->range_length(), frameSize);
    CHECK(mInputBuffer->range_length() >= frameSize);

    int16 frameType;
    RX_State rx_state;
@@ -197,8 +198,14 @@ status_t AMRWBDecoder::read(

    buffer->set_range(0, numSamplesOutput * sizeof(int16_t));

    mInputBuffer->set_range(
            mInputBuffer->range_offset() + frameSize,
            mInputBuffer->range_length() - frameSize);

    if (mInputBuffer->range_length() == 0) {
        mInputBuffer->release();
        mInputBuffer = NULL;
    }

    buffer->meta_data()->setInt64(
            kKeyTime,
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ AVCDecoder::AVCDecoder(const sp<MediaSource> &source)
    mFormat->setInt32(kKeyHeight, height);
    mFormat->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
    mFormat->setCString(kKeyDecoderComponent, "AVCDecoder");

    int64_t durationUs;
    if (mSource->getFormat()->findInt64(kKeyDuration, &durationUs)) {
        mFormat->setInt64(kKeyDuration, durationUs);
    }
}

AVCDecoder::~AVCDecoder() {
Loading