aboutsummaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorDavid Staessens <dstaessens@google.com>2020-07-30 16:26:23 +0900
committerDavid Staessens <dstaessens@google.com>2020-08-31 17:01:32 +0900
commitfbad28ce8e5fec0f3a4794a9411bc19241197b9a (patch)
treefd5633c1161a9e194164299b225398f86ec66640 /components
parentf2cb0f3fb3b6b36bce7412714cd0c6e382cb1cc8 (diff)
downloadv4l2_codec2-fbad28ce8e5fec0f3a4794a9411bc19241197b9a.tar.gz
v4l2_codec2: Mark V4L2EncodeComponent buffers as BufferUsage::VIDEO_ENCODER.
This CL adds the BufferUsage::VIDEO_ENCODER flag to the V4L2EncodeComponent's input and output buffers so they are properly synced between the encoder and crosvm. Bug: 162371919 Test: tast run $HOST arc.VideoEncodeAccel.h264_vm on hatch-arc-r Change-Id: I9179c556e77718d2c9af7584bfa3540d82db07ac
Diffstat (limited to 'components')
-rw-r--r--components/V4L2EncodeComponent.cpp8
-rw-r--r--components/V4L2EncodeInterface.cpp7
-rw-r--r--components/include/v4l2_codec2/components/V4L2EncodeInterface.h2
3 files changed, 16 insertions, 1 deletions
diff --git a/components/V4L2EncodeComponent.cpp b/components/V4L2EncodeComponent.cpp
index b5ada11..f3a10a5 100644
--- a/components/V4L2EncodeComponent.cpp
+++ b/components/V4L2EncodeComponent.cpp
@@ -15,6 +15,7 @@
#include <C2AllocatorGralloc.h>
#include <C2PlatformSupport.h>
#include <C2Work.h>
+#include <android/hardware/graphics/common/1.0/types.h>
#include <base/bind.h>
#include <base/bind_helpers.h>
#include <log/log.h>
@@ -29,6 +30,8 @@
#include <v4l2_device.h>
#include <video_pixel_format.h>
+using android::hardware::graphics::common::V1_0::BufferUsage;
+
namespace android {
namespace {
@@ -1160,7 +1163,10 @@ std::shared_ptr<C2LinearBlock> V4L2EncodeComponent::fetchOutputBlock() {
ALOGV("Fetching linear block (size: %u)", mOutputBufferSize);
std::shared_ptr<C2LinearBlock> outputBlock;
c2_status_t status = mOutputBlockPool->fetchLinearBlock(
- mOutputBufferSize, {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &outputBlock);
+ mOutputBufferSize,
+ C2MemoryUsage(C2MemoryUsage::CPU_READ |
+ static_cast<uint64_t>(BufferUsage::VIDEO_ENCODER)),
+ &outputBlock);
if (status != C2_OK) {
ALOGE("Failed to fetch linear block (error: %d)", status);
reportError(status);
diff --git a/components/V4L2EncodeInterface.cpp b/components/V4L2EncodeInterface.cpp
index 50bc4aa..fb715b1 100644
--- a/components/V4L2EncodeInterface.cpp
+++ b/components/V4L2EncodeInterface.cpp
@@ -11,6 +11,7 @@
#include <C2PlatformSupport.h>
#include <SimpleC2Interface.h>
+#include <android/hardware/graphics/common/1.0/types.h>
#include <media/stagefright/MediaDefs.h>
#include <utils/Log.h>
@@ -18,6 +19,8 @@
#include <v4l2_codec2/common/V4L2ComponentCommon.h>
#include <video_codecs.h>
+using android::hardware::graphics::common::V1_0::BufferUsage;
+
namespace android {
namespace {
@@ -332,6 +335,10 @@ void V4L2EncodeInterface::Initialize(const C2String& name) {
DefineParam(mInputFormat, C2_PARAMKEY_INPUT_STREAM_BUFFER_TYPE)
.withConstValue(new C2StreamBufferTypeSetting::input(0u, C2BufferData::GRAPHIC))
.build());
+ addParameter(DefineParam(mInputMemoryUsage, C2_PARAMKEY_INPUT_STREAM_USAGE)
+ .withConstValue(new C2StreamUsageTuning::input(
+ 0u, static_cast<uint64_t>(BufferUsage::VIDEO_ENCODER)))
+ .build());
addParameter(
DefineParam(mOutputFormat, C2_PARAMKEY_OUTPUT_STREAM_BUFFER_TYPE)
diff --git a/components/include/v4l2_codec2/components/V4L2EncodeInterface.h b/components/include/v4l2_codec2/components/V4L2EncodeInterface.h
index e41ddff..f480d25 100644
--- a/components/include/v4l2_codec2/components/V4L2EncodeInterface.h
+++ b/components/include/v4l2_codec2/components/V4L2EncodeInterface.h
@@ -60,6 +60,8 @@ protected:
// The input format kind; should be C2FormatVideo.
std::shared_ptr<C2StreamBufferTypeSetting::input> mInputFormat;
+ // The memory usage flag of input buffer; should be BufferUsage::VIDEO_ENCODER.
+ std::shared_ptr<C2StreamUsageTuning::input> mInputMemoryUsage;
// The output format kind; should be C2FormatCompressed.
std::shared_ptr<C2StreamBufferTypeSetting::output> mOutputFormat;
// The MIME type of input port; should be MEDIA_MIMETYPE_VIDEO_RAW.