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

Commit a3b38cac authored by Lajos Molnar's avatar Lajos Molnar Committed by android-build-merger
Browse files

Merge "codec2: use an index flag for split parameters" into qt-dev

am: 35b711dc

Change-Id: If8f95416e9a314df3f40d2d063a21887943ddaa4
parents 8bd5476d 35b711dc
Loading
Loading
Loading
Loading
+18 −11
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ enum C2ParamIndexKind : C2Param::type_index_t {

    /* pipeline characteristics */
    kParamIndexMediaType,
    kParamIndexDelayRequest,
    __kParamIndexRESERVED_0,
    kParamIndexDelay,
    kParamIndexMaxReferenceAge,
    kParamIndexMaxReferenceCount,
@@ -151,6 +151,9 @@ enum C2ParamIndexKind : C2Param::type_index_t {
    /* protected content */
    kParamIndexSecureMode,

    // deprecated
    kParamIndexDelayRequest = kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG,

    /* ------------------------------------ (trans/en)coders ------------------------------------ */

    kParamIndexBitrate = C2_PARAM_INDEX_CODER_PARAM_START,
@@ -779,22 +782,26 @@ typedef C2StreamParam<C2Setting, C2StringValue, kParamIndexMediaType> C2StreamMe
 * outstanding input frames queued to the component, it shall produce output.
 */

typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelayRequest> C2PortRequestedDelayTuning;
constexpr char C2_PARAMKEY_INPUT_DELAY_REQUEST[] = "input.delay.requested";
constexpr char C2_PARAMKEY_OUTPUT_DELAY_REQUEST[] = "output.delay.requested";
typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG>
        C2PortRequestedDelayTuning;
constexpr char C2_PARAMKEY_INPUT_DELAY_REQUEST[] = "input.delay"; // deprecated
constexpr char C2_PARAMKEY_OUTPUT_DELAY_REQUEST[] = "output.delay"; // deprecated

typedef C2GlobalParam<C2Tuning, C2Uint32Value, kParamIndexDelayRequest>
typedef C2GlobalParam<C2Tuning, C2Uint32Value,
                kParamIndexDelay | C2Param::CoreIndex::IS_REQUEST_FLAG>
        C2RequestedPipelineDelayTuning;
constexpr char C2_PARAMKEY_PIPELINE_DELAY_REQUEST[] = "pipeline-delay.requested";
constexpr char C2_PARAMKEY_PIPELINE_DELAY_REQUEST[] = "algo.delay"; // deprecated

// read-only
typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PortActualDelayTuning;
constexpr char C2_PARAMKEY_INPUT_DELAY[] = "input.delay.actual";
constexpr char C2_PARAMKEY_OUTPUT_DELAY[] = "output.delay.actual";
typedef C2PortParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PortDelayTuning;
typedef C2PortDelayTuning C2PortActualDelayTuning; // deprecated
constexpr char C2_PARAMKEY_INPUT_DELAY[] = "input.delay";
constexpr char C2_PARAMKEY_OUTPUT_DELAY[] = "output.delay";

// read-only
typedef C2GlobalParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2ActualPipelineDelayTuning;
constexpr char C2_PARAMKEY_PIPELINE_DELAY[] = "algo.delay.actual";
typedef C2GlobalParam<C2Tuning, C2Uint32Value, kParamIndexDelay> C2PipelineDelayTuning;
typedef C2PipelineDelayTuning C2ActualPipelineDelayTuning; // deprecated
constexpr char C2_PARAMKEY_PIPELINE_DELAY[] = "algo.delay";

/**
 * Reference characteristics.
+18 −4
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ public:
    //public:
        enum : uint32_t {
            IS_FLEX_FLAG    = 0x00010000,
            IS_REQUEST_FLAG = 0x00020000,
        };

    protected:
@@ -175,9 +176,9 @@ public:
            DIR_INPUT      = 0x00000000,
            DIR_OUTPUT     = 0x10000000,

            IS_STREAM_FLAG  = 0x02000000,
            STREAM_ID_MASK  = 0x01FE0000,
            STREAM_ID_SHIFT = 17,
            IS_STREAM_FLAG  = 0x00100000,
            STREAM_ID_MASK  = 0x03E00000,
            STREAM_ID_SHIFT = 21,
            MAX_STREAM_ID   = STREAM_ID_MASK >> STREAM_ID_SHIFT,
            STREAM_MASK     = IS_STREAM_FLAG | STREAM_ID_MASK,

@@ -360,6 +361,10 @@ public:
            mIndex = (mIndex & ~(DIR_MASK | IS_STREAM_FLAG)) | DIR_GLOBAL;
        }

        inline void convertToRequest() {
            mIndex = mIndex | IS_REQUEST_FLAG;
        }

        /**
         * Sets the stream index.
         * \return true on success, false if could not set index (e.g. not a stream param).
@@ -476,6 +481,15 @@ public:
        return copy;
    }

    /// Returns managed clone of |orig| as a stream parameter at heap.
    inline static std::unique_ptr<C2Param> CopyAsRequest(const C2Param &orig) {
        std::unique_ptr<C2Param> copy = Copy(orig);
        if (copy) {
            copy->_mIndex.convertToRequest();
        }
        return copy;
    }

#if 0
    template<typename P, class=decltype(C2Param(P()))>
    P *As() { return P::From(this); }
+7 −0
Original line number Diff line number Diff line
@@ -205,6 +205,13 @@ void ReflectedParamUpdater::addParamDesc(
        const std::shared_ptr<C2ParamReflector> &reflector, bool markVendor) {
    C2String paramName = desc->name();

    // Do not reflect requested parameters
    // TODO: split these once aliases are introduced into '.actual' and '.requested' and alias
    // the name to '.actual'.
    if (desc->index() & C2Param::CoreIndex::IS_REQUEST_FLAG) {
        return;
    }

    // prefix vendor parameters
    if (desc->index().isVendor() && markVendor) {
        paramName = "vendor." + paramName;
+34 −1
Original line number Diff line number Diff line
@@ -609,6 +609,9 @@ c2_status_t C2InterfaceHelper::config(
    // { depIx, paramIx } may be a suitable key
    std::map<size_t, std::pair<C2Param::Index, bool>> dependencies;

    std::vector<std::unique_ptr<C2Param>> paramRequests;
    std::vector<C2Param*> lateReadParams;

    // we cannot determine the last valid parameter, so add an extra
    // loop iteration after the last parameter
    for (size_t p_ix = 0; p_ix <= params.size(); ++p_ix) {
@@ -625,7 +628,27 @@ c2_status_t C2InterfaceHelper::config(
            }

            paramIx = p->index();

            // convert parameter to request in case this is a split parameter
            C2Param::Index requestParamIx = paramIx | C2Param::CoreIndex::IS_REQUEST_FLAG;

            // setting a request directly is handled as normal
            if (paramIx != requestParamIx) {
                paramDepIx = getDependencyIndex_l(requestParamIx);
                if (paramDepIx == SIZE_MAX) {
                    // not a split parameter, handle it normally
                    paramDepIx = getDependencyIndex_l(paramIx);
                } else {
                    // split parameter - replace with setting for the request - and queue to
                    // read back actual value
                    // TODO: read late params at the right time
                    lateReadParams.emplace_back(p);
                    std::unique_ptr<C2Param> request(C2Param::CopyAsRequest(*p));
                    p = request.get();
                    paramRequests.emplace_back(std::move(request));
                }
            }

            if (paramDepIx == SIZE_MAX) {
                // unsupported parameter
                paramNotFound = true;
@@ -715,6 +738,16 @@ c2_status_t C2InterfaceHelper::config(
        }
    }

    // get late read parameters
    for (C2Param *p : lateReadParams) {
        std::shared_ptr<C2Param> value = _mFactory->getParamValue(p->index());
        if (value) {
            p->updateFrom(*value);
        } else {
            p->invalidate();
        }
    }

    return (paramCorrupted ? C2_CORRUPTED :
            paramBlocking ? C2_BLOCKING :
            paramTimedOut ? C2_TIMED_OUT :