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

Commit 9cf12df1 authored by Chong Zhang's avatar Chong Zhang
Browse files

SoftVPX related perf tuning

- Boost decoding thread priority to match ACodec's for video

- Bump up SoftVPX input/output buffer count to 16

- Set buffer count in native window when SoftwareRenderer is used

- Set native window usage to READ_NEVER | WRITE_RARELY to avoid
  unnecessary cache invalidation upon lock/unlock

bug: 72841545
Change-Id: Ib7ac3f881fd0612884ecee68ffc79d6fa8f8ca37
parent fd4fb71b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2951,8 +2951,8 @@ status_t MediaCodec::onReleaseOutputBuffer(const sp<AMessage> &msg) {

        if (mSoftRenderer != NULL) {
            std::list<FrameRenderTracker::Info> doneFrames = mSoftRenderer->render(
                    buffer->data(), buffer->size(),
                    mediaTimeUs, renderTimeNs, NULL, buffer->format());
                    buffer->data(), buffer->size(), mediaTimeUs, renderTimeNs,
                    mPortBuffers[kPortIndexOutput].size(), buffer->format());

            // if we are running, notify rendered frames
            if (!doneFrames.empty() && mState == STARTED && mOnFrameRenderedNotification != NULL) {
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ protected:

private:
    enum {
        kNumBuffers = 4
        kNumBuffers = 16
    };

    enum {
+13 −6
Original line number Diff line number Diff line
@@ -60,7 +60,8 @@ SoftwareRenderer::~SoftwareRenderer() {
    mConverter = NULL;
}

void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {
void SoftwareRenderer::resetFormatIfChanged(
        const sp<AMessage> &format, size_t numOutputBuffers) {
    CHECK(format != NULL);

    int32_t colorFormatNew;
@@ -168,7 +169,7 @@ void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {
    CHECK_EQ(0,
            native_window_set_usage(
            mNativeWindow.get(),
            GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_OFTEN
            GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_RARELY
            | GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_EXTERNAL_DISP));

    CHECK_EQ(0,
@@ -184,6 +185,11 @@ void SoftwareRenderer::resetFormatIfChanged(const sp<AMessage> &format) {
    CHECK_EQ(0, native_window_set_buffers_format(
                mNativeWindow.get(),
                halFormat));
    if (OK != native_window_set_buffer_count(
                mNativeWindow.get(), numOutputBuffers + 4)) {
        ALOGE("Failed to set native window buffer count to (%zu + 4)",
                numOutputBuffers);
    }

    // NOTE: native window uses extended right-bottom coordinate
    android_native_rect_t crop;
@@ -219,8 +225,8 @@ void SoftwareRenderer::clearTracker() {

std::list<FrameRenderTracker::Info> SoftwareRenderer::render(
        const void *data, size_t , int64_t mediaTimeUs, nsecs_t renderTimeNs,
        void* /*platformPrivate*/, const sp<AMessage>& format) {
    resetFormatIfChanged(format);
        size_t numOutputBuffers, const sp<AMessage>& format) {
    resetFormatIfChanged(format, numOutputBuffers);
    FrameRenderTracker::Info *info = NULL;

    ANativeWindowBuffer *buf;
@@ -243,8 +249,9 @@ std::list<FrameRenderTracker::Info> SoftwareRenderer::render(
    Rect bounds(mCropWidth, mCropHeight);

    void *dst;
    CHECK_EQ(0, mapper.lock(
                buf->handle, GRALLOC_USAGE_SW_WRITE_OFTEN, bounds, &dst));
    CHECK_EQ(0, mapper.lock(buf->handle,
            GRALLOC_USAGE_SW_READ_NEVER | GRALLOC_USAGE_SW_WRITE_RARELY,
            bounds, &dst));

    // TODO move the other conversions also into ColorConverter, and
    // fix cropping issues (when mCropLeft/Top != 0 or mWidth != mCropWidth)
+4 −3
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:

    std::list<FrameRenderTracker::Info> render(
            const void *data, size_t size, int64_t mediaTimeUs, nsecs_t renderTimeNs,
            void *platformPrivate, const sp<AMessage> &format);
            size_t numOutputBuffers, const sp<AMessage> &format);
    void clearTracker();

private:
@@ -59,10 +59,11 @@ private:
    HDRStaticInfo mHDRStaticInfo;
    FrameRenderTracker mRenderTracker;

    void resetFormatIfChanged(
            const sp<AMessage> &format, size_t numOutputBuffers);

    SoftwareRenderer(const SoftwareRenderer &);
    SoftwareRenderer &operator=(const SoftwareRenderer &);

    void resetFormatIfChanged(const sp<AMessage> &format);
};

}  // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ SimpleSoftOMXComponent::SimpleSoftOMXComponent(
    mLooper->start(
            false, // runOnCallingThread
            false, // canCallJava
            ANDROID_PRIORITY_FOREGROUND);
            ANDROID_PRIORITY_AUDIO);
}

void SimpleSoftOMXComponent::prepareForDestruction() {