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

Commit 5b3d305e authored by Shunkai Yao's avatar Shunkai Yao Committed by Automerger Merge Worker
Browse files

Merge "Downmix Effect: Fix processed samples" into main am: 9afbd388

parents 079cfa4d 9afbd388
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -111,7 +111,6 @@ void DownmixContext::reset() {
}
}


IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int samples) {
IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int samples) {
    LOG(DEBUG) << __func__ << " in " << in << " out " << out << " sample " << samples;
    IEffect::Status status = {EX_ILLEGAL_ARGUMENT, 0, 0};
    IEffect::Status status = {EX_ILLEGAL_ARGUMENT, 0, 0};


    if (in == nullptr || out == nullptr ||
    if (in == nullptr || out == nullptr ||
@@ -132,7 +131,6 @@ IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int sample
    bool accumulate = false;
    bool accumulate = false;
    int frames = samples * sizeof(float) / getInputFrameSize();
    int frames = samples * sizeof(float) / getInputFrameSize();
    if (mType == Downmix::Type::STRIP) {
    if (mType == Downmix::Type::STRIP) {
        int inputChannelCount = getChannelCount(mChMask);
        while (frames) {
        while (frames) {
            if (accumulate) {
            if (accumulate) {
                out[0] = std::clamp(out[0] + in[0], -1.f, 1.f);
                out[0] = std::clamp(out[0] + in[0], -1.f, 1.f);
@@ -141,7 +139,7 @@ IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int sample
                out[0] = in[0];
                out[0] = in[0];
                out[1] = in[1];
                out[1] = in[1];
            }
            }
            in += inputChannelCount;
            in += mInputChannelCount;
            out += 2;
            out += 2;
            frames--;
            frames--;
        }
        }
@@ -153,8 +151,11 @@ IEffect::Status DownmixContext::downmixProcess(float* in, float* out, int sample
            return status;
            return status;
        }
        }
    }
    }
    LOG(DEBUG) << __func__ << " done processing";
    int producedSamples = (samples / mInputChannelCount) << 1;
    return {STATUS_OK, samples, samples};
    LOG(DEBUG) << __func__ << " done processing " << samples << " samples, generated "
               << producedSamples << " frameSize: " << getInputFrameSize() << " - "
               << getOutputFrameSize();
    return {STATUS_OK, samples, producedSamples};
}
}


void DownmixContext::init_params(const Parameter::Common& common) {
void DownmixContext::init_params(const Parameter::Common& common) {