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

Commit fce0d188 authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: enable adaptive playback based on codec format key



Added support for prepareForAdaptivePlayback() call in
configureCodec, if max-width and max-height keys are specified
in the format.  It is OK for this call to fail, if component
does not implement adaptive playback.

Change-Id: Ie15892bc666df103b635890a0fda799b204bb06c
Signed-off-by: default avatarLajos Molnar <lajos@google.com>
Bug: 7093648
Bug: 10192531
parent 56ce7260
Loading
Loading
Loading
Loading
+41 −1
Original line number Diff line number Diff line
@@ -1106,9 +1106,49 @@ status_t ACodec::configureCodec(
    if (!encoder && video && haveNativeWindow) {
        err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexOutput, OMX_TRUE);
        if (err != OK) {
            // allow failure
            ALOGE("[%s] storeMetaDataInBuffers failed w/ err %d",
                  mComponentName.c_str(), err);

            // if adaptive playback has been requested, try JB fallback
            // NOTE: THIS FALLBACK MECHANISM WILL BE REMOVED DUE TO ITS
            // LARGE MEMORY REQUIREMENT

            // we will not do adaptive playback on software accessed
            // surfaces as they never had to respond to changes in the
            // crop window, and we don't trust that they will be able to.
            int usageBits = 0;
            bool canDoAdaptivePlayback;

            sp<NativeWindowWrapper> windowWrapper(
                    static_cast<NativeWindowWrapper *>(obj.get()));
            sp<ANativeWindow> nativeWindow = windowWrapper->getNativeWindow();

            if (nativeWindow->query(
                    nativeWindow.get(),
                    NATIVE_WINDOW_CONSUMER_USAGE_BITS,
                    &usageBits) != OK) {
                canDoAdaptivePlayback = false;
            } else {
                canDoAdaptivePlayback =
                    (usageBits &
                            (GRALLOC_USAGE_SW_READ_MASK |
                             GRALLOC_USAGE_SW_WRITE_MASK)) == 0;
            }

            int32_t maxWidth = 0, maxHeight = 0;
            if (canDoAdaptivePlayback &&
                msg->findInt32("max-width", &maxWidth) &&
                msg->findInt32("max-height", &maxHeight)) {
                ALOGV("[%s] prepareForAdaptivePlayback(%ldx%ld)",
                      mComponentName.c_str(), maxWidth, maxHeight);

                err = mOMX->prepareForAdaptivePlayback(
                        mNode, kPortIndexOutput, OMX_TRUE, maxWidth, maxHeight);
                ALOGW_IF(err != OK,
                        "[%s] prepareForAdaptivePlayback failed w/ err %d",
                        mComponentName.c_str(), err);
            }
            // allow failure
            err = OK;
        } else {
            ALOGV("[%s] storeMetaDataInBuffers succeeded", mComponentName.c_str());
+8 −4
Original line number Diff line number Diff line
@@ -4620,11 +4620,15 @@ status_t QueryCodec(
        caps->mColorFormats.push(portFormat.eColorFormat);
    }

    if (!isEncoder && !strncmp(mime, "video/", 6) &&
            omx->storeMetaDataInBuffers(
                    node, 1 /* port index */, OMX_TRUE) == OK) {
    if (!isEncoder && !strncmp(mime, "video/", 6)) {
        if (omx->storeMetaDataInBuffers(
                    node, 1 /* port index */, OMX_TRUE) == OK ||
            omx->prepareForAdaptivePlayback(
                    node, 1 /* port index */, OMX_TRUE,
                    1280 /* width */, 720 /* height */) == OK) {
            caps->mFlags |= CodecCapabilities::kFlagSupportsAdaptivePlayback;
        }
    }

    CHECK_EQ(omx->freeNode(node), (status_t)OK);