aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2022-05-18 20:26:28 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-05-18 20:26:28 +0000
commitf10c21b64b71dd08e358e14e252768deeb6f89aa (patch)
treefa7118c885b68c2deaa4e36c108c1a2643bcaeb0
parent9bac8a5d08a69b848af3d6b1923c426f56bbf9d3 (diff)
parent38858f07809b4f089c4ba710f9b31eddfc83c1f3 (diff)
downloadgoldfish-opengl-f10c21b64b71dd08e358e14e252768deeb6f89aa.tar.gz
codecs: get decoder output mode using pool id am: 38858f0780
Original change: https://googleplex-android-review.googlesource.com/c/device/generic/goldfish-opengl/+/18458428 Change-Id: I31bfd73b643b728addbed5801ae374d84854a636 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp32
-rw-r--r--system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp32
-rw-r--r--system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp45
3 files changed, 27 insertions, 82 deletions
diff --git a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp
index d9e7f3bc..8e871458 100644
--- a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp
+++ b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp
@@ -670,31 +670,13 @@ C2GoldfishAvcDec::ensureDecoderState(const std::shared_ptr<C2BlockPool> &pool) {
void C2GoldfishAvcDec::checkMode(const std::shared_ptr<C2BlockPool> &pool) {
mWidth = mIntf->width();
mHeight = mIntf->height();
- {
- // now get the block
- constexpr uint32_t format = HAL_PIXEL_FORMAT_YCBCR_420_888;
- std::shared_ptr<C2GraphicBlock> block;
- C2MemoryUsage usage = {C2MemoryUsage::CPU_READ,
- C2MemoryUsage::CPU_WRITE};
- usage.expected = (uint64_t)(BufferUsage::VIDEO_DECODER);
-
- c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight,
- format, usage, &block);
- if (err != C2_OK) {
- ALOGE("fetchGraphicBlock for Output failed with status %d", err);
- return;
- }
- auto c2Handle = block->handle();
- native_handle_t *grallocHandle =
- UnwrapNativeCodec2GrallocHandle(c2Handle);
- int hostColorBufferId = getColorBufferHandle(grallocHandle);
- if (hostColorBufferId > 0) {
- DDD("decoding to host color buffer");
- mEnableAndroidNativeBuffers = true;
- } else {
- DDD("decoding to guest byte buffer");
- mEnableAndroidNativeBuffers = false;
- }
+ const bool isGraphic = (pool->getAllocatorId() == C2Allocator::GRAPHIC);
+ if (isGraphic) {
+ DDD("decoding to host color buffer");
+ mEnableAndroidNativeBuffers = false;
+ } else {
+ DDD("decoding to guest byte buffer");
+ mEnableAndroidNativeBuffers = false;
}
}
diff --git a/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp b/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp
index b2f684a6..7aac56f8 100644
--- a/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp
+++ b/system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp
@@ -661,31 +661,13 @@ C2GoldfishHevcDec::ensureDecoderState(const std::shared_ptr<C2BlockPool> &pool)
void C2GoldfishHevcDec::checkMode(const std::shared_ptr<C2BlockPool> &pool) {
mWidth = mIntf->width();
mHeight = mIntf->height();
- {
- // now get the block
- constexpr uint32_t format = HAL_PIXEL_FORMAT_YCBCR_420_888;
- std::shared_ptr<C2GraphicBlock> block;
- C2MemoryUsage usage = {C2MemoryUsage::CPU_READ,
- C2MemoryUsage::CPU_WRITE};
- usage.expected = (uint64_t)(BufferUsage::VIDEO_DECODER);
-
- c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 16), mHeight,
- format, usage, &block);
- if (err != C2_OK) {
- ALOGE("fetchGraphicBlock for Output failed with status %d", err);
- return;
- }
- auto c2Handle = block->handle();
- native_handle_t *grallocHandle =
- UnwrapNativeCodec2GrallocHandle(c2Handle);
- int hostColorBufferId = getColorBufferHandle(grallocHandle);
- if (hostColorBufferId > 0) {
- DDD("decoding to host color buffer");
- mEnableAndroidNativeBuffers = true;
- } else {
- DDD("decoding to guest byte buffer");
- mEnableAndroidNativeBuffers = false;
- }
+ const bool isGraphic = (pool->getAllocatorId() == C2Allocator::GRAPHIC);
+ if (isGraphic) {
+ DDD("decoding to host color buffer");
+ mEnableAndroidNativeBuffers = false;
+ } else {
+ DDD("decoding to guest byte buffer");
+ mEnableAndroidNativeBuffers = false;
}
}
diff --git a/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp b/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp
index 99ddcfd2..bb61cf94 100644
--- a/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp
+++ b/system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp
@@ -465,32 +465,13 @@ void C2GoldfishVpxDec::checkContext(const std::shared_ptr<C2BlockPool> &pool) {
mCtx = new vpx_codec_ctx_t;
mCtx->vpversion = mMode == MODE_VP8 ? 8 : 9;
- // check for decoding mode:
- {
- // now get the block
- constexpr uint32_t format = HAL_PIXEL_FORMAT_YCBCR_420_888;
- std::shared_ptr<C2GraphicBlock> block;
- C2MemoryUsage usage = {C2MemoryUsage::CPU_READ,
- C2MemoryUsage::CPU_WRITE};
- usage.expected = (uint64_t)(BufferUsage::VIDEO_DECODER);
-
- c2_status_t err = pool->fetchGraphicBlock(align(mWidth, 2), mHeight,
- format, usage, &block);
- if (err != C2_OK) {
- ALOGE("fetchGraphicBlock for Output failed with status %d", err);
- return;
- }
- auto c2Handle = block->handle();
- native_handle_t *grallocHandle =
- UnwrapNativeCodec2GrallocHandle(c2Handle);
- int hostColorBufferId = getColorBufferHandle(grallocHandle);
- if (hostColorBufferId > 0) {
- DDD("decoding to host color buffer");
- mEnableAndroidNativeBuffers = true;
- } else {
- DDD("decoding to guest byte buffer");
- mEnableAndroidNativeBuffers = false;
- }
+ const bool isGraphic = (pool->getAllocatorId() == C2Allocator::GRAPHIC);
+ if (isGraphic) {
+ DDD("decoding to host color buffer");
+ mEnableAndroidNativeBuffers = false;
+ } else {
+ DDD("decoding to guest byte buffer");
+ mEnableAndroidNativeBuffers = false;
}
mCtx->version = mEnableAndroidNativeBuffers ? 200 : 100;
@@ -721,24 +702,24 @@ C2GoldfishVpxDec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
return UNKNOWN_ERROR;
}
- bool decodingToByteBuffer = false;
- {
+ int hostColorBufferId = -1;
+ const bool decodingToHostColorBuffer = mEnableAndroidNativeBuffers;
+ if(decodingToHostColorBuffer){
auto c2Handle = block->handle();
native_handle_t *grallocHandle =
UnwrapNativeCodec2GrallocHandle(c2Handle);
- int hostColorBufferId = getColorBufferHandle(grallocHandle);
+ hostColorBufferId = getColorBufferHandle(grallocHandle);
if (hostColorBufferId > 0) {
DDD("found handle %d", hostColorBufferId);
} else {
- decodingToByteBuffer = true;
DDD("decode to buffer, because handle %d is invalid",
hostColorBufferId);
// change to -1 so host knows it is definitely invalid
// 0 is a bit confusing
hostColorBufferId = -1;
}
- setup_ctx_parameters(mCtx, hostColorBufferId);
}
+ setup_ctx_parameters(mCtx, hostColorBufferId);
vpx_image_t *img = vpx_codec_get_frame(mCtx);
@@ -798,7 +779,7 @@ C2GoldfishVpxDec::outputBuffer(const std::shared_ptr<C2BlockPool> &pool,
}
}
- if (decodingToByteBuffer) {
+ if (!decodingToHostColorBuffer) {
C2GraphicView wView = block->map().get();
if (wView.error()) {