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.
This commit is contained in:
@@ -293,17 +293,19 @@ sp<MediaSource> OMXCodec::Create(
|
||||
CHECK(success);
|
||||
|
||||
#if BUILD_WITH_FULL_STAGEFRIGHT
|
||||
if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
|
||||
return new AACDecoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) {
|
||||
return new AMRNBDecoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) {
|
||||
return new AMRWBDecoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
|
||||
return new MP3Decoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
|
||||
&& (flags & kPreferSoftwareCodecs)) {
|
||||
return new AVCDecoder(source);
|
||||
if (!createEncoder) {
|
||||
if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
|
||||
return new AACDecoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) {
|
||||
return new AMRNBDecoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_WB)) {
|
||||
return new AMRWBDecoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
|
||||
return new MP3Decoder(source);
|
||||
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_AVC)
|
||||
&& (flags & kPreferSoftwareCodecs)) {
|
||||
return new AVCDecoder(source);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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);
|
||||
meta->setInt64(kKeyDuration, durationUs);
|
||||
|
||||
int64_t durationUs;
|
||||
if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
|
||||
meta->setInt64(kKeyDuration, durationUs);
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
meta->setInt64(kKeyDuration, durationUs);
|
||||
|
||||
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->release();
|
||||
mInputBuffer = NULL;
|
||||
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,
|
||||
|
||||
@@ -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);
|
||||
meta->setInt64(kKeyDuration, durationUs);
|
||||
|
||||
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->release();
|
||||
mInputBuffer = NULL;
|
||||
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,
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -94,16 +94,18 @@ sp<MetaData> MP3Decoder::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);
|
||||
meta->setInt64(kKeyDuration, durationUs);
|
||||
|
||||
int64_t durationUs;
|
||||
if (srcFormat->findInt64(kKeyDuration, &durationUs)) {
|
||||
meta->setInt64(kKeyDuration, durationUs);
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user