From 90a839f6611a7e4ffd6c5af35ba0f16e88b9e2bd Mon Sep 17 00:00:00 2001 From: Emilian Peev Date: Wed, 2 Oct 2019 15:12:50 -0700 Subject: [PATCH] Camera: Set input timestamp before returning depth jpegs The depth jpeg result and image timestamps must always match. Set the depth jpeg output surface timestamp accordingly before returning the resulting output buffer. Bug: 142011420 Test: atest cts/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java#testDynamicDepthCapture Change-Id: I2d70367d3cc60014d24cc138e4ca882b2111e161 --- .../libcameraservice/api2/DepthCompositeStream.cpp | 11 +++++++++-- .../libcameraservice/api2/DepthCompositeStream.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/services/camera/libcameraservice/api2/DepthCompositeStream.cpp b/services/camera/libcameraservice/api2/DepthCompositeStream.cpp index 8ebaa2b2c7..0b9101619d 100644 --- a/services/camera/libcameraservice/api2/DepthCompositeStream.cpp +++ b/services/camera/libcameraservice/api2/DepthCompositeStream.cpp @@ -247,7 +247,7 @@ int64_t DepthCompositeStream::getNextFailingInputLocked(int64_t *currentTs /*ino return ret; } -status_t DepthCompositeStream::processInputFrame(const InputFrame &inputFrame) { +status_t DepthCompositeStream::processInputFrame(nsecs_t ts, const InputFrame &inputFrame) { status_t res; sp outputANW = mOutputSurface; ANativeWindowBuffer *anb; @@ -370,6 +370,13 @@ status_t DepthCompositeStream::processInputFrame(const InputFrame &inputFrame) { return NO_MEMORY; } + res = native_window_set_buffers_timestamp(mOutputSurface.get(), ts); + if (res != OK) { + ALOGE("%s: Stream %d: Error setting timestamp: %s (%d)", __FUNCTION__, + getStreamId(), strerror(-res), res); + return res; + } + ALOGV("%s: Final jpeg size: %zu", __func__, finalJpegSize); uint8_t* header = static_cast (dstBuffer) + (gb->getWidth() - sizeof(struct camera3_jpeg_blob)); @@ -459,7 +466,7 @@ bool DepthCompositeStream::threadLoop() { } } - auto res = processInputFrame(mPendingInputFrames[currentTs]); + auto res = processInputFrame(currentTs, mPendingInputFrames[currentTs]); Mutex::Autolock l(mMutex); if (res != OK) { ALOGE("%s: Failed processing frame with timestamp: %" PRIu64 ": %s (%d)", __FUNCTION__, diff --git a/services/camera/libcameraservice/api2/DepthCompositeStream.h b/services/camera/libcameraservice/api2/DepthCompositeStream.h index 975c59bc5c..28a7826c5d 100644 --- a/services/camera/libcameraservice/api2/DepthCompositeStream.h +++ b/services/camera/libcameraservice/api2/DepthCompositeStream.h @@ -97,7 +97,7 @@ private: size_t maxJpegSize, uint8_t jpegQuality, std::vector>* items /*out*/); std::unique_ptr getImagingModel(); - status_t processInputFrame(const InputFrame &inputFrame); + status_t processInputFrame(nsecs_t ts, const InputFrame &inputFrame); // Buffer/Results handling void compilePendingInputLocked();