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

Commit 6afb4fd9 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10098552 from 1dbbf67c to udc-release

Change-Id: I21eec6e66f51d775d5d40814e3d154e4e497e822
parents fb249311 1dbbf67c
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -542,15 +542,15 @@ status_t C2SoftAomEnc::initEncoder() {
    mCodecConfiguration->kf_max_dist = 3000;
    // Encoder determines optimal key frame placement automatically.
    mCodecConfiguration->kf_mode = AOM_KF_AUTO;
    // Initial value of the buffer level in ms.
    mCodecConfiguration->rc_buf_initial_sz = 500;
    // Amount of data that the encoder should try to maintain in ms.
    mCodecConfiguration->rc_buf_optimal_sz = 600;
    // The amount of data that may be buffered by the decoding
    // application in ms.
    mCodecConfiguration->rc_buf_sz = 1000;

    if (mBitrateControlMode == AOM_CBR) {
        // Initial value of the buffer level in ms.
        mCodecConfiguration->rc_buf_initial_sz = 500;
        // Amount of data that the encoder should try to maintain in ms.
        mCodecConfiguration->rc_buf_optimal_sz = 600;
        // Maximum amount of bits that can be subtracted from the target
        // bitrate - expressed as percentage of the target bitrate.
        mCodecConfiguration->rc_undershoot_pct = 100;
@@ -563,7 +563,7 @@ status_t C2SoftAomEnc::initEncoder() {
        mCodecConfiguration->rc_undershoot_pct = 100;
        // Maximum amount of bits that can be added to the target
        // bitrate - expressed as percentage of the target bitrate.
        mCodecConfiguration->rc_overshoot_pct = 25;
        mCodecConfiguration->rc_overshoot_pct = 100;
    }

    if (mIntf->getSyncFramePeriod() >= 0) {
@@ -576,6 +576,12 @@ status_t C2SoftAomEnc::initEncoder() {
    }
    if (mMaxQuantizer > 0) {
        mCodecConfiguration->rc_max_quantizer = mMaxQuantizer;
    } else {
        if (mBitrateControlMode == AOM_VBR) {
            // For VBR we are limiting MaxQP to 52 (down 11 steps) to maintain quality
            // 52 comes from experiments done on libaom standalone app
            mCodecConfiguration->rc_max_quantizer = 52;
        }
    }

    mCodecContext = new aom_codec_ctx_t;
+6 −4
Original line number Diff line number Diff line
@@ -1523,8 +1523,8 @@ c2_status_t Codec2Client::Component::setOutputSurface(
    uint64_t consumerUsage = kDefaultConsumerUsage;
    {
        if (surface) {
            int usage = 0;
            status_t err = surface->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS, &usage);
            uint64_t usage = 0;
            status_t err = surface->getConsumerUsage(&usage);
            if (err != NO_ERROR) {
                ALOGD("setOutputSurface -- failed to get consumer usage bits (%d/%s). ignoring",
                        err, asString(err));
@@ -1537,8 +1537,7 @@ c2_status_t Codec2Client::Component::setOutputSurface(
                // they do not exist inside of C2 scope. Any buffer usage shall be communicated
                // through the sideband channel.

                // do an unsigned conversion as bit-31 may be 1
                consumerUsage = (uint32_t)usage | kDefaultConsumerUsage;
                consumerUsage = usage | kDefaultConsumerUsage;
            }
        }

@@ -1562,6 +1561,8 @@ c2_status_t Codec2Client::Component::setOutputSurface(
                    static_cast<uint64_t>(blockPoolId),
                    bqId == 0 ? nullHgbp : igbp);

    mOutputBufferQueue->expireOldWaiters();

    if (!transStatus.isOk()) {
        LOG(ERROR) << "setOutputSurface -- transaction failed.";
        return C2_TRANSACTION_FAILED;
@@ -1607,6 +1608,7 @@ void Codec2Client::Component::stopUsingOutputSurface(
                       << status << ".";
        }
    }
    mOutputBufferQueue->expireOldWaiters();
}

c2_status_t Codec2Client::Component::connectToInputSurface(
+6 −0
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ struct OutputBufferQueue {
                   int maxDequeueBufferCount,
                   std::shared_ptr<V1_2::SurfaceSyncObj> *syncObj);

    // If there are waiters to allocate from the old surface, wake up and expire
    // them.
    void expireOldWaiters();

    // Stop using the current output surface. Pending buffer opeations will not
    // perform anymore.
    void stop();
@@ -90,6 +94,8 @@ private:
    std::weak_ptr<_C2BlockPoolData> mPoolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
    std::shared_ptr<C2SurfaceSyncMemory> mSyncMem;
    bool mStopped;
    std::mutex mOldMutex;
    std::shared_ptr<C2SurfaceSyncMemory> mOldMem;

    bool registerBuffer(const C2ConstGraphicBlock& block);
};
+17 −1
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
    sp<GraphicBuffer> buffers[BufferQueueDefs::NUM_BUFFER_SLOTS];
    std::weak_ptr<_C2BlockPoolData>
            poolDatas[BufferQueueDefs::NUM_BUFFER_SLOTS];
    std::shared_ptr<C2SurfaceSyncMemory> oldMem;
    {
        std::scoped_lock<std::mutex> l(mMutex);
        bool stopped = mStopped;
@@ -238,7 +239,7 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
            }
            return false;
        }
        std::shared_ptr<C2SurfaceSyncMemory> oldMem = mSyncMem;
        oldMem = mSyncMem;
        C2SyncVariables *oldSync = mSyncMem ? mSyncMem->mem() : nullptr;
        if (oldSync) {
            oldSync->lock();
@@ -314,11 +315,26 @@ bool OutputBufferQueue::configure(const sp<IGraphicBufferProducer>& igbp,
            newSync->unlock();
        }
    }
    {
        std::scoped_lock<std::mutex> l(mOldMutex);
        mOldMem = oldMem;
    }
    ALOGD("remote graphic buffer migration %zu/%zu",
          success, tryNum);
    return true;
}

void OutputBufferQueue::expireOldWaiters() {
    std::scoped_lock<std::mutex> l(mOldMutex);
    if (mOldMem) {
        C2SyncVariables *oldSync = mOldMem->mem();
        if (oldSync) {
            oldSync->notifyAll();
        }
        mOldMem.reset();
    }
}

void OutputBufferQueue::stop() {
    std::scoped_lock<std::mutex> l(mMutex);
    mStopped = true;
+23 −0
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@
#include <string_view>
#include <vector>

#include <android-base/expected.h>
#include <error/Result.h>
#include <media/AudioParameter.h>
#include <utils/String16.h>
#include <utils/Vector.h>

@@ -51,4 +54,24 @@ class ConversionHelperAidl {
    const std::string mClassName;
};

// 'action' must accept a value of type 'T' and return 'status_t'.
// The function returns 'true' if the parameter was found, and the action has succeeded.
// The function returns 'false' if the parameter was not found.
// Any errors get propagated, if there are errors it means the parameter was found.
template<typename T, typename F>
error::Result<bool> filterOutAndProcessParameter(
        AudioParameter& parameters, const String8& key, const F& action) {
    if (parameters.containsKey(key)) {
        T value;
        status_t status = parameters.get(key, value);
        if (status == OK) {
            parameters.remove(key);
            status = action(value);
            if (status == OK) return true;
        }
        return base::unexpected(status);
    }
    return false;
}

}  // namespace android
Loading