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

Commit a575c841 authored by Dheeraj CVR's avatar Dheeraj CVR
Browse files

stagefright: update support for omap3 decoders and encoders

OMAP3 uses 2 decoders, 720P.Decoder and Video.Decoder.

720P.Decoder is proprietary OMAP3 decoder from ITTIAM. Only
one instance of the 720P decoder can run at a time due to memory
restrictions (512MB) and it's quite slow at thumbnail generation
and it's resource hungry.

Video.Decoder is opensource and could support WVGA resolutions.
It only supports baseline profile and max level 31 for AVC, but
could run 4 instances at the same time and is quite fast especially
for watching WhatsApp videos :P

Using the 720P decoder for low resolution videos is not optimal and
trying to use the Video.Decoder for videos other than Baseline profile
will crash the entire DSP and would require a reboot. Currently
stagefright uses codecs in the order they appear in media_codecs.xml
without querying the supported level and profile from the decoder,
due to which wrong codecs are selected causing problems.

Similarly there are 2 encoders, 720P.Encoder and Video.Encoder. They
support different resolutions and should be used selectively.

This patch has been forward ported from Gingerbread branch.

Change-Id: I74f843fe5d28faefa0b51191778ab2ee8c54f5f6
parent 8e22dd0c
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -674,6 +674,31 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
            CODEC_LOGI(
                    "AVC profile = %u (%s), level = %u",
                    profile, AVCProfileToString(profile), level);
#ifdef OMAP_ENHANCEMENT
            int32_t width, height;
            bool success = meta->findInt32(kKeyWidth, &width);
            success = success && meta->findInt32(kKeyHeight, &height);
            CHECK(success);
            if (!strcmp(mComponentName, "OMX.TI.720P.Decoder")
                && (profile == 0x42 /* Baseline */ && level <= 31)
                && (width * height <= 414720 /* 864x480 */)
                && (width <= 864 && height <= 864 ))
            {
                // Though this decoder can handle this profile/level,
                // we prefer to use "OMX.TI.Video.Decoder" for
                // Baseline Profile with level <=31 and sub 720p
                return ERROR_UNSUPPORTED;
            }
            if (!strcmp(mComponentName, "OMX.TI.Video.Decoder")
                && (profile != 0x42 /* Baseline */ || level > 31)) {
                // This stream exceeds the decoder's capabilities. The decoder
                // does not handle this gracefully and would clobber the heap
                // and wreak havoc instead...

                CODEC_LOGE("Profile and/or level exceed the decoder's capabilities.");
                return ERROR_UNSUPPORTED;
            }
#endif
        } else if (meta->findData(kKeyVorbisInfo, &type, &data, &size)) {
            addCodecSpecificData(data, size);

@@ -706,6 +731,18 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
    if (mIsEncoder) {
        CHECK(meta->findInt32(kKeyBitRate, &bitRate));
    }
#ifdef OMAP_ENHANCEMENT
        if (!strcmp(mComponentName, "OMX.TI.Video.encoder")) {
            int32_t width, height;
            bool success = meta->findInt32(kKeyWidth, &width);
            success = success && meta->findInt32(kKeyHeight, &height);
            CHECK(success);
            if (width * height > 414720 /* 864x480 */) {
                // require OMX.TI.720P.Encoder
                return ERROR_UNSUPPORTED;
            }
        }
#endif
    if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB, mMIME)) {
        setAMRFormat(false /* isWAMR */, bitRate);
    } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB, mMIME)) {