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

Commit 45d80595 authored by Sungtak Lee's avatar Sungtak Lee
Browse files

Reduce the latecy of encoding 1st frame

Current encode batching mandates delay for the first frame. Since photo
images are one frame, reduce the latency for encoding the first frame

Test: atest android.media.cts.VideoEncoderTest
Bug: 145356198
Change-Id: I6a8f7dd374a3252ba93f386d3c62cd735fe82802
(cherry picked from commit 84e512b6)
Merged-In: I6a8f7dd374a3252ba93f386d3c62cd735fe82802
parent 4f74cca0
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public:
            android::base::unique_fd &&fd0,
            android::base::unique_fd &&fd1) {
        Mutexed<Jobs>::Locked jobs(mJobs);
        auto it = jobs->queues.try_emplace(comp, comp, systemTime()).first;
        auto it = jobs->queues.try_emplace(comp, comp).first;
        it->second.workList.emplace_back(
                std::move(work), fenceFd, std::move(fd0), std::move(fd1));
        jobs->cond.broadcast();
@@ -79,7 +79,8 @@ protected:
            for (auto it = jobs->queues.begin(); it != jobs->queues.end(); ) {
                Queue &queue = it->second;
                if (queue.workList.empty()
                        || nowNs - queue.lastQueuedTimestampNs < kIntervalNs) {
                        || (queue.lastQueuedTimestampNs != 0 &&
                            nowNs - queue.lastQueuedTimestampNs < kIntervalNs)) {
                    ++it;
                    continue;
                }
@@ -104,6 +105,7 @@ protected:
                    sp<Fence> fence(new Fence(fenceFd));
                    fence->waitForever(LOG_TAG);
                }
                queue.lastQueuedTimestampNs = nowNs;
                comp->queue(&items);
                for (android::base::unique_fd &ufd : uniqueFds) {
                    (void)ufd.release();
@@ -143,8 +145,8 @@ private:
        android::base::unique_fd fd1;
    };
    struct Queue {
        Queue(const std::shared_ptr<Codec2Client::Component> &comp, nsecs_t timestamp)
            : component(comp), lastQueuedTimestampNs(timestamp) {}
        Queue(const std::shared_ptr<Codec2Client::Component> &comp)
            : component(comp), lastQueuedTimestampNs(0) {}
        Queue(const Queue &) = delete;
        Queue &operator =(const Queue &) = delete;