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

Commit f577bc89 authored by Steve Kondik's avatar Steve Kondik Committed by Steve Kondik
Browse files

stagefright: Fix codec lookup bugs on NuPlayer

 * Fix use of WMA/WMV software codecs
 * Fix mpeg2 software codec name
 * Don't override the component name in ACodec. This actually breaks
   stuff because the format isn't available in the kInit message.

Change-Id: I93c292e039de5f24c2ccbd6ae2242b06d28fe518
parent 7c07c9f4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
    ALOGV("[%s] onConfigure (surface=%p)", mComponentName.c_str(), surface.get());

    ExtendedCodec::overrideMimeType(format, &mime);
    ExtendedCodec::overrideComponentName(0, format, &mComponentName, &mime, false);

    /* time allocateNode here */
    {
@@ -118,8 +119,12 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
        ExtendedStats::AutoProfile autoProfile(STATS_PROFILE_ALLOCATE_NODE(isVideo),
                mPlayerExtendedStats == NULL ? NULL : mPlayerExtendedStats->getProfileTimes());

        if (!mComponentName.startsWith(mime.c_str())) {
            mCodec = MediaCodec::CreateByComponentName(mCodecLooper, mComponentName.c_str());
        } else {
            mCodec = MediaCodec::CreateByType(mCodecLooper, mime.c_str(), false /* encoder */);
        }
    }

    int32_t secure = 0;
    if (format->findInt32("secure", &secure) && secure != 0) {
+4 −9
Original line number Diff line number Diff line
@@ -4731,6 +4731,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
            encoder = false;
        }

        ALOGV("onAllocateComponent %s %d", mime.c_str(), encoder);
#ifdef ENABLE_AV_ENHANCEMENTS
    // Call UseQCHWAACEncoder with no arguments to get the correct state since
    // MediaCodecSource does not pass the output format details when calling
@@ -4756,20 +4757,13 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
                &matchingCodecs);
#endif
    } else
#endif
        OMXCodec::findMatchingCodecs(
                mime.c_str(),
                encoder, // createEncoder
                NULL,  // matchComponentName
                0,     // flags
                &matchingCodecs);
#else
    OMXCodec::findMatchingCodecs(
                mime.c_str(),
                encoder, // createEncoder
                NULL,  // matchComponentName
                0,     // flags
                &matchingCodecs);
#endif
    }

    sp<CodecObserver> observer = new CodecObserver;
@@ -4779,7 +4773,8 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
            ++matchIndex) {
        componentName = matchingCodecs.itemAt(matchIndex).mName.string();
        quirks = matchingCodecs.itemAt(matchIndex).mQuirks;
        ExtendedCodec::overrideComponentName(quirks, msg, &componentName, &mime, encoder);
        // this doesn't work here as the format isn't passed in the message
        //ExtendedCodec::overrideComponentName(quirks, msg, &componentName, &mime, encoder);

        pid_t tid = androidGetTid();
        int prevPriority = androidGetThreadPriority(tid);
+17 −7
Original line number Diff line number Diff line
@@ -244,6 +244,23 @@ void ExtendedCodec::overrideComponentName(
       }
    }

    int32_t wmvVersion = 0;
    if (!strncasecmp(mime->c_str(), MEDIA_MIMETYPE_VIDEO_WMV, strlen(MEDIA_MIMETYPE_VIDEO_WMV)) &&
            msg->findInt32(getMsgKey(kKeyWMVVersion), &wmvVersion)) {
        ALOGD("Found WMV version key %d", wmvVersion);
        if (wmvVersion == 1) {
            ALOGD("Use FFMPEG for unsupported WMV track");
            componentName->setTo("OMX.ffmpeg.wmv.decoder");
        }
    }

    int32_t encodeOptions = 0;
    if (!isEncoder && !strncasecmp(mime->c_str(), MEDIA_MIMETYPE_AUDIO_WMA, strlen(MEDIA_MIMETYPE_AUDIO_WMA)) &&
            !msg->findInt32(getMsgKey(kKeyWMAEncodeOpt), &encodeOptions)) {
        ALOGD("Use FFMPEG for unsupported WMA track");
        componentName->setTo("OMX.ffmpeg.wma.decoder");
    }

    if (!isEncoder && !strncasecmp(mime->c_str(), MEDIA_MIMETYPE_VIDEO_HEVC, strlen(MEDIA_MIMETYPE_VIDEO_HEVC))) {
        sw_codectype = property_get("media.swhevccodectype", value, NULL);
        enableSwHevc = atoi(value);
@@ -422,13 +439,6 @@ status_t ExtendedCodec::setVideoFormat(
    } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_DIVX311, mime)) {
        *compressionFormat= (OMX_VIDEO_CODINGTYPE)QOMX_VIDEO_CodingDivx;
    } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_WMV, mime)) {
        int32_t wmvVersion = 0;
        if (msg->findInt32(getMsgKey(kKeyWMVVersion), &wmvVersion)) {
            if (wmvVersion == 1) {
                ALOGE("Unsupported WMV version %d", wmvVersion);
                return ERROR_UNSUPPORTED;
            }
        }
        *compressionFormat = OMX_VIDEO_CodingWMV;
    } else if (!strcasecmp(MEDIA_MIMETYPE_CONTAINER_MPEG2, mime)) {
        *compressionFormat = OMX_VIDEO_CodingMPEG2;
+2 −2
Original line number Diff line number Diff line
@@ -363,7 +363,7 @@ status_t FFMPEGSoftCodec::setSupportedRole(
        { MEDIA_MIMETYPE_AUDIO_DTS,
          "audio_decoder.dts", NULL },
        { MEDIA_MIMETYPE_VIDEO_MPEG2,
          "video_decoder.mpeg2v", NULL },
          "video_decoder.mpeg2", NULL },
        { MEDIA_MIMETYPE_VIDEO_DIVX,
          "video_decoder.divx", NULL },
        { MEDIA_MIMETYPE_VIDEO_DIVX4,
@@ -371,7 +371,7 @@ status_t FFMPEGSoftCodec::setSupportedRole(
        { MEDIA_MIMETYPE_VIDEO_DIVX311,
          "video_decoder.divx", NULL },
        { MEDIA_MIMETYPE_VIDEO_WMV,
          "video_decoder.vc1",  NULL },
          "video_decoder.wmv",  NULL },
        { MEDIA_MIMETYPE_VIDEO_RV,
          "video_decoder.rv", NULL },
        { MEDIA_MIMETYPE_VIDEO_FLV1,
+2 −2
Original line number Diff line number Diff line
@@ -29,10 +29,10 @@
        <MediaCodec name="OMX.ffmpeg.atrial.decoder" type="audio/ffmpeg" />

        <!--  ffmpeg video codecs -->
        <MediaCodec name="OMX.ffmpeg.mpeg2v.decoder" type="video/mpeg2"/>
        <MediaCodec name="OMX.ffmpeg.mpeg2.decoder"  type="video/mpeg2"/>
        <MediaCodec name="OMX.ffmpeg.wmv.decoder"    type="video/x-ms-wmv"/>
        <MediaCodec name="OMX.ffmpeg.rv.decoder"     type="video/vnd.rn-realvideo"/>
        <MediaCodec name="OMX.ffmpeg.flv1.decoder"   type="video/x-flv"/>

        <MediaCodec name="OMX.ffmpeg.vtrial.decoder" type="video/ffmpeg" />
    </Decoders>
</Included>
Loading