aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2022-05-17 23:04:08 -0700
committerBo Hu <bohu@google.com>2022-05-18 15:26:51 +0000
commit38858f07809b4f089c4ba710f9b31eddfc83c1f3 (patch)
treefa7118c885b68c2deaa4e36c108c1a2643bcaeb0
parenta707249b7241aaf7dc0c9c9415eb9837177f2ae9 (diff)
downloadgoldfish-opengl-38858f07809b4f089c4ba710f9b31eddfc83c1f3.tar.gz
codecs: get decoder output mode using pool id
There are two modes of decoding: 1, decoding into bytebuffer 2, decoding into surface (host color buffer for emulator) previous way of getting this mode is not working anymore. now, change it to use the buffer pool id, which is either GRAPHIC(host color buffer) or LINEAR (bytebuffer). Bug: 232881288 Test: atest android.media.decoder.cts.ImageReaderDecoderTest Change-Id: Iff124e74fb95ebb4377a311d1224ef9bb944f195
-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()) {