aboutsummaryrefslogtreecommitdiff
path: root/components/V4L2Decoder.cpp
diff options
context:
space:
mode:
authorChih-Yu Huang <akahuang@google.com>2020-07-22 12:25:33 +0900
committerAlexandre Courbot <acourbot@google.com>2020-08-04 20:29:03 +0900
commitf14abffcf37057345506d3b7d861f2e0b9070fb4 (patch)
tree834e8975075bbd805e1e6cf1df83b6f1df786dee /components/V4L2Decoder.cpp
parent8138025080a9cca0167a6f32dc7058046f84b871 (diff)
downloadv4l2_codec2-f14abffcf37057345506d3b7d861f2e0b9070fb4.tar.gz
V4L2Decoder: pass the same output buffer to V4L2 Queue slot
Originally we pass arbitrary output buffers to V4L2 Queue. However, the V4L2 stateful API requires the caller pass the same buffers to the output queue slot. This CL implement this requirement. Bug: 161770200 Bug: 161323057 Test: arc.VideoDecodeAccel.h264_vm runs first test successfully. Change-Id: I8f6c8871997f310425571b3983ae86f05c0c37c6
Diffstat (limited to 'components/V4L2Decoder.cpp')
-rw-r--r--components/V4L2Decoder.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/components/V4L2Decoder.cpp b/components/V4L2Decoder.cpp
index 275357e..71e3dc4 100644
--- a/components/V4L2Decoder.cpp
+++ b/components/V4L2Decoder.cpp
@@ -9,6 +9,8 @@
#include <stdint.h>
+#include <vector>
+
#include <base/bind.h>
#include <base/memory/ptr_util.h>
#include <log/log.h>
@@ -501,30 +503,36 @@ void V4L2Decoder::tryFetchVideoFrame() {
return;
}
- auto outputBuffer = mOutputQueue->GetFreeBuffer();
- if (!outputBuffer) {
- ALOGD("No free output buffer.");
- return;
- }
- mVideoFramePool->getVideoFrame(
- ::base::BindOnce(&V4L2Decoder::onVideoFrameReady, mWeakThis, std::move(*outputBuffer)));
+ mVideoFramePool->getVideoFrame(::base::BindOnce(&V4L2Decoder::onVideoFrameReady, mWeakThis));
}
-void V4L2Decoder::onVideoFrameReady(media::V4L2WritableBufferRef outputBuffer,
- std::unique_ptr<VideoFrame> frame) {
+void V4L2Decoder::onVideoFrameReady(
+ std::optional<VideoFramePool::FrameWithBlockId> frameWithBlockId) {
ALOGV("%s()", __func__);
ALOG_ASSERT(mTaskRunner->RunsTasksInCurrentSequence());
- if (!frame) {
- ALOGE("Get nullptr VideoFrame.");
+ if (!frameWithBlockId) {
+ ALOGE("Got nullptr VideoFrame.");
+ onError();
+ return;
+ }
+
+ // Unwrap our arguments.
+ std::unique_ptr<VideoFrame> frame;
+ uint32_t blockId;
+ std::tie(frame, blockId) = std::move(*frameWithBlockId);
+
+ ::base::Optional<media::V4L2WritableBufferRef> outputBuffer =
+ mOutputQueue->GetFreeBuffer(blockId);
+ if (!outputBuffer) {
+ ALOGE("No free output buffer.");
onError();
return;
}
- size_t bufferId = outputBuffer.BufferId();
- ALOGV("QBUF to output queue, bufferId=%zu", bufferId);
- std::move(outputBuffer).QueueDMABuf(frame->getFDs());
- mFrameAtDevice.insert(std::make_pair(bufferId, std::move(frame)));
+ ALOGV("QBUF to output queue, blockId=%u, fd: %d", blockId, frame->getFDs()[0].get());
+ std::move(*outputBuffer).QueueDMABuf(frame->getFDs());
+ mFrameAtDevice.insert(std::make_pair(blockId, std::move(frame)));
tryFetchVideoFrame();
}