diff options
Diffstat (limited to 'system/codecs/c2/decoders')
-rw-r--r-- | system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp | 32 | ||||
-rw-r--r-- | system/codecs/c2/decoders/hevcdec/C2GoldfishHevcDec.cpp | 32 | ||||
-rw-r--r-- | system/codecs/c2/decoders/vpxdec/C2GoldfishVpxDec.cpp | 45 |
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()) { |