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

Commit cc59da67 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 5631102 from 7c504d9e to qt-c2f2-release

Change-Id: If63cb6fc429a972a7578f81e19704a1ff3ee4d29
parents f29b50a7 7c504d9e
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;
+36 −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 :
@@ -761,9 +794,11 @@ c2_status_t C2InterfaceHelper::query(
            if (p != nullptr) {
                heapParams->push_back(std::move(p));
            } else {
                heapParams->push_back(nullptr);
                paramNoMemory = true;
            }
        } else {
            heapParams->push_back(nullptr);
            paramNotFound = true;
        }
    }
+9 −14
Original line number Diff line number Diff line
@@ -505,45 +505,40 @@ media_status_t WAVSource::read(

    // TODO: add capability to return data as float PCM instead of 16 bit PCM.
    if (mWaveFormat == WAVE_FORMAT_PCM) {
        const size_t bytesPerFrame = (mBitsPerSample >> 3) * mNumChannels;
        const size_t numFrames = n / bytesPerFrame;
        const size_t numSamples = numFrames * mNumChannels;
        if (mOutputFloat) {
            float *fdest = (float *)buffer->data();
            buffer->set_range(0, 4 * numSamples);
            switch (mBitsPerSample) {
            case 8: {
                buffer->set_range(0, 4 * n);
                memcpy_to_float_from_u8(fdest, (const uint8_t *)buffer->data(), n);
                memcpy_to_float_from_u8(fdest, (const uint8_t *)buffer->data(), numSamples);
            } break;
            case 16: {
                const size_t numSamples = n / 2;
                buffer->set_range(0, 4 * numSamples);
                memcpy_to_float_from_i16(fdest, (const int16_t *)buffer->data(), numSamples);
            } break;
            case 24: {
                const size_t numSamples = n / 3;
                buffer->set_range(0, 4 * numSamples);
                memcpy_to_float_from_p24(fdest, (const uint8_t *)buffer->data(), numSamples);
            } break;
            case 32: { // buffer range is correct
                const size_t numSamples = n / 4;
                memcpy_to_float_from_i32(fdest, (const int32_t *)buffer->data(), numSamples);
            } break;
            }
        } else {
            int16_t *idest = (int16_t *)buffer->data();
            buffer->set_range(0, 2 * numSamples);
            switch (mBitsPerSample) {
            case 8: {
                buffer->set_range(0, 2 * n);
                memcpy_to_i16_from_u8(idest, (const uint8_t *)buffer->data(), n);
                memcpy_to_i16_from_u8(idest, (const uint8_t *)buffer->data(), numSamples);
            } break;
            case 16:
                break; // no translation needed
                // no conversion needed
                break;
            case 24: {
                const size_t numSamples = n / 3;
                buffer->set_range(0, 2 * numSamples);
                memcpy_to_i16_from_p24(idest, (const uint8_t *)buffer->data(), numSamples);
            } break;
            case 32: {
                const size_t numSamples = n / 4;
                buffer->set_range(0, 2 * numSamples);
                memcpy_to_i16_from_i32(idest, (const int32_t *)buffer->data(), numSamples);
            } break;
            }