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

Commit f6e1ff25 authored by James Dong's avatar James Dong
Browse files

Call storeMetaDataInVideoBuffers() before get/setParameters() on index OMX_IndexParamPortDefinition

This can potentially save lot of memory for video recording use case since the video encoder
can advertise a much smaller size of the input buffers which are allocated by SF by default.

Change-Id: I582a356cd02c7852e13f2713d90ad5f1eb43177d
parent 5e7271d6
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -1643,25 +1643,26 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
        return PERMISSION_DENIED;
    }

    status_t err = OK;
    if (mIsMetaDataStoredInVideoBuffers && portIndex == kPortIndexInput) {
        err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexInput, OMX_TRUE);
        if (err != OK) {
            LOGE("Storing meta data in video buffers is not supported");
            return err;
        }
    }

    OMX_PARAM_PORTDEFINITIONTYPE def;
    InitOMXParams(&def);
    def.nPortIndex = portIndex;

    status_t err = mOMX->getParameter(
    err = mOMX->getParameter(
            mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));

    if (err != OK) {
        return err;
    }

    if (mIsMetaDataStoredInVideoBuffers && portIndex == kPortIndexInput) {
        err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexInput, OMX_TRUE);
        if (err != OK) {
            LOGE("Storing meta data in video buffers is not supported");
            return err;
        }
    }

    CODEC_LOGI("allocating %lu buffers of size %lu on %s port",
            def.nBufferCountActual, def.nBufferSize,
            portIndex == kPortIndexInput ? "input" : "output");