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

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

Merge change 24179 into eclair

* changes:
  Support encoding amr-wb content in stagefright.
parents 85fa14d3 456db755
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ int main(int argc, char **argv) {
#endif

    sp<MetaData> encMeta = new MetaData;
    encMeta->setCString(kKeyMIMEType, 1 ? "audio/3gpp" : "audio/mp4a-latm");
    encMeta->setCString(kKeyMIMEType, 1 ? "audio/amr-wb" : "audio/mp4a-latm");
    encMeta->setInt32(kKeySampleRate, kSampleRate);
    encMeta->setInt32(kKeyChannelCount, kNumChannels);
    encMeta->setInt32(kKeyMaxInputSize, 8192);
@@ -248,7 +248,7 @@ int main(int argc, char **argv) {
        buffer->release();
        buffer = NULL;

        if (++n == 10000) {
        if (++n == 100) {
            break;
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ private:
    void setComponentRole();

    void setAMRFormat();
    void setAMRWBFormat();
    void setAACFormat(int32_t numChannels, int32_t sampleRate);

    status_t setVideoPortFormatType(
+37 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ static const CodecInfo kDecoderInfo[] = {
    { "audio/mpeg", "OMX.PV.mp3dec" },
    { "audio/3gpp", "OMX.TI.AMR.decode" },
    { "audio/3gpp", "OMX.PV.amrdec" },
    { "audio/amr-wb", "OMX.TI.WBAMR.decode" },
    { "audio/mp4a-latm", "OMX.TI.AAC.decode" },
    { "audio/mp4a-latm", "OMX.PV.aacdec" },
    { "video/mp4v-es", "OMX.qcom.video.decoder.mpeg4" },
@@ -65,6 +66,7 @@ static const CodecInfo kDecoderInfo[] = {
static const CodecInfo kEncoderInfo[] = {
    { "audio/3gpp", "OMX.TI.AMR.encode" },
    { "audio/3gpp", "OMX.PV.amrencnb" },
    { "audio/amr-wb", "OMX.TI.WBAMR.encode" },
    { "audio/mp4a-latm", "OMX.TI.AAC.encode" },
    { "audio/mp4a-latm", "OMX.PV.aacenc" },
    { "video/mp4v-es", "OMX.qcom.video.encoder.mpeg4" },
@@ -317,6 +319,9 @@ sp<OMXCodec> OMXCodec::Create(
    if (!strcasecmp("audio/3gpp", mime)) {
        codec->setAMRFormat();
    }
    if (!strcasecmp("audio/amr-wb", mime)) {
        codec->setAMRWBFormat();
    }
    if (!strcasecmp("audio/mp4a-latm", mime)) {
        int32_t numChannels, sampleRate;
        CHECK(meta->findInt32(kKeyChannelCount, &numChannels));
@@ -673,6 +678,7 @@ void OMXCodec::setComponentRole() {
    static const MimeToRole kMimeToRole[] = {
        { "audio/mpeg", "audio_decoder.mp3", "audio_encoder.mp3" },
        { "audio/3gpp", "audio_decoder.amrnb", "audio_encoder.amrnb" },
        { "audio/amr-wb", "audio_decoder.amrwb", "audio_encoder.amrwb" },
        { "audio/mp4a-latm", "audio_decoder.aac", "audio_encoder.aac" },
        { "video/avc",  "video_decoder.avc", "video_encoder.avc" },
        { "video/mp4v-es", "video_decoder.mpeg4", "video_encoder.mpeg4" },
@@ -1548,6 +1554,37 @@ void OMXCodec::setAMRFormat() {
    }
}

void OMXCodec::setAMRWBFormat() {
    if (!mIsEncoder) {
        OMX_AUDIO_PARAM_AMRTYPE def;
        InitOMXParams(&def);
        def.nPortIndex = kPortIndexInput;

        status_t err =
            mOMX->get_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def));

        CHECK_EQ(err, OK);

        def.eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
        def.eAMRBandMode = OMX_AUDIO_AMRBandModeWB0;

        err = mOMX->set_parameter(mNode, OMX_IndexParamAudioAmr, &def, sizeof(def));
        CHECK_EQ(err, OK);
    }

    ////////////////////////

    if (mIsEncoder) {
        sp<MetaData> format = mSource->getFormat();
        int32_t sampleRate;
        int32_t numChannels;
        CHECK(format->findInt32(kKeySampleRate, &sampleRate));
        CHECK(format->findInt32(kKeyChannelCount, &numChannels));

        setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
    }
}

void OMXCodec::setAACFormat(int32_t numChannels, int32_t sampleRate) {
    if (mIsEncoder) {
        setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);