diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-05-22 03:00:58 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-05-22 03:00:58 +0000 |
commit | 9103412bdd9af250cdacee0bfe56a5c85560756b (patch) | |
tree | 1001f753ed1eb3c318aacaf2c8003e622c7e3a34 | |
parent | 53879138aec7a4e0cfdf4b9dbe3fc83f40e828f8 (diff) | |
parent | 7a89d56c8584659d24758c6e20f0cc0c21344dde (diff) | |
download | goldfish-opengl-9103412bdd9af250cdacee0bfe56a5c85560756b.tar.gz |
Snap for 7389169 from 7a89d56c8584659d24758c6e20f0cc0c21344dde to sc-d1-release
Change-Id: I54c55a27d7954aadcc2b9ec6ae9ff7e44981b315
-rw-r--r-- | system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp | 36 | ||||
-rw-r--r-- | system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.h | 3 | ||||
-rw-r--r-- | system/hwc2/Display.cpp | 20 |
3 files changed, 32 insertions, 27 deletions
diff --git a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp index aaf5f877..7f955355 100644 --- a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp +++ b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.cpp @@ -657,14 +657,6 @@ C2GoldfishAvcDec::ensureDecoderState(const std::shared_ptr<C2BlockPool> &pool) { UnwrapNativeCodec2GrallocHandle(c2Handle); mHostColorBufferId = getColorBufferHandle(grallocHandle); DDD("found handle %d", mHostColorBufferId); - } else { - C2GraphicView wView = mOutBlock->map().get(); - if (wView.error()) { - ALOGE("graphic view map failed %d", wView.error()); - return C2_CORRUPTED; - } - mByteBuffer = - const_cast<uint8_t *>(wView.data()[C2PlanarLayout::PLANE_Y]); } DDD("provided (%dx%d) required (%dx%d)", mOutBlock->width(), mOutBlock->height(), ALIGN16(mWidth), mHeight); @@ -737,22 +729,32 @@ void C2GoldfishAvcDec::getVuiParams(h264_image_t &img) { } } -void C2GoldfishAvcDec::copyImageData(uint8_t *pBuffer, h264_image_t &img) { +void C2GoldfishAvcDec::copyImageData(h264_image_t &img) { getVuiParams(img); if (mEnableAndroidNativeBuffers) return; - int myStride = mWidth; + + auto writeView = mOutBlock->map().get(); + if (writeView.error()) { + ALOGE("graphic view map failed %d", writeView.error()); + return; + } + size_t dstYStride = writeView.layout().planes[C2PlanarLayout::PLANE_Y].rowInc; + size_t dstUVStride = writeView.layout().planes[C2PlanarLayout::PLANE_U].rowInc; + + uint8_t *pYBuffer = const_cast<uint8_t *>(writeView.data()[C2PlanarLayout::PLANE_Y]); + uint8_t *pUBuffer = const_cast<uint8_t *>(writeView.data()[C2PlanarLayout::PLANE_U]); + uint8_t *pVBuffer = const_cast<uint8_t *>(writeView.data()[C2PlanarLayout::PLANE_V]); + for (int i = 0; i < mHeight; ++i) { - memcpy(pBuffer + i * myStride, img.data + i * mWidth, mWidth); + memcpy(pYBuffer + i * dstYStride, img.data + i * mWidth, mWidth); } - int Y = myStride * mHeight; for (int i = 0; i < mHeight / 2; ++i) { - memcpy(pBuffer + Y + i * myStride / 2, + memcpy(pUBuffer + i * dstUVStride, img.data + mWidth * mHeight + i * mWidth / 2, mWidth / 2); } - int UV = Y / 4; for (int i = 0; i < mHeight / 2; ++i) { - memcpy(pBuffer + Y + UV + i * myStride / 2, + memcpy(pVBuffer + i * dstUVStride, img.data + mWidth * mHeight * 5 / 4 + i * mWidth / 2, mWidth / 2); } @@ -918,7 +920,7 @@ void C2GoldfishAvcDec::process(const std::unique_ptr<C2Work> &work, DDD("got data %" PRIu64 " with pts %" PRIu64, mPts2Index[mImg.pts], mImg.pts); mHeaderDecoded = true; - copyImageData(mByteBuffer, mImg); + copyImageData(mImg); finishWork(mPts2Index[mImg.pts], work); removePts(mImg.pts); } else { @@ -985,7 +987,7 @@ C2GoldfishAvcDec::drainInternal(uint32_t drainMode, // mImg = mContext->getImage(); if (mImg.data != nullptr) { DDD("got data in drain mode %" PRIu64 " with pts %" PRIu64, mPts2Index[mImg.pts], mImg.pts); - copyImageData(mByteBuffer, mImg); + copyImageData(mImg); finishWork(mPts2Index[mImg.pts], work); removePts(mImg.pts); } else { diff --git a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.h b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.h index c726418a..d906d025 100644 --- a/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.h +++ b/system/codecs/c2/decoders/avcdec/C2GoldfishAvcDec.h @@ -99,9 +99,8 @@ class C2GoldfishAvcDec : public SimpleC2Component { int mHostColorBufferId{-1}; void getVuiParams(h264_image_t &img); - void copyImageData(uint8_t *pBuffer, h264_image_t &img); + void copyImageData(h264_image_t &img); - uint8_t *mByteBuffer{nullptr}; h264_image_t mImg{}; uint32_t mConsumedBytes{0}; uint8_t *mInPBuffer{nullptr}; diff --git a/system/hwc2/Display.cpp b/system/hwc2/Display.cpp index 99a7c010..bed6b64f 100644 --- a/system/hwc2/Display.cpp +++ b/system/hwc2/Display.cpp @@ -98,10 +98,9 @@ HWC2::Error Display::init(uint32_t width, uint32_t height, uint32_t dpiX, return HWC2::Error::None; } -HWC2::Error Display::updateParameters(uint32_t width, uint32_t height, - uint32_t dpiX, uint32_t dpiY, - uint32_t refreshRateHz, - const std::optional<std::vector<uint8_t>>& edid) { +HWC2::Error Display::updateParameters( + uint32_t width, uint32_t height, uint32_t dpiX, uint32_t dpiY, + uint32_t refreshRateHz, const std::optional<std::vector<uint8_t>>& edid) { DEBUG_LOG("%s updating display:%" PRIu64 " width:%d height:%d dpiX:%d dpiY:%d refreshRateHz:%d", __FUNCTION__, mId, width, height, dpiX, dpiY, refreshRateHz); @@ -205,8 +204,13 @@ HWC2::Error Display::destroyLayer(hwc2_layer_t layerId) { return HWC2::Error::BadLayer; } - std::remove_if(mOrderedLayers.begin(), mOrderedLayers.end(), - [layerId](Layer* layer) { return layer->getId() == layerId; }); + mOrderedLayers.erase(std::remove_if(mOrderedLayers.begin(), // + mOrderedLayers.end(), // + [layerId](Layer* layer) { + return layer->getId() == layerId; + }), + mOrderedLayers.end()); + mLayers.erase(it); DEBUG_LOG("%s destroyed layer:%" PRIu64, __FUNCTION__, layerId); @@ -305,8 +309,8 @@ HWC2::Error Display::getColorModes(uint32_t* outNumModes, int32_t* outModes) { } // we only support HAL_COLOR_MODE_NATIVE so far - uint32_t numModes = - std::min<uint32_t>(*outNumModes, static_cast<uint32_t>(mColorModes.size())); + uint32_t numModes = std::min<uint32_t>( + *outNumModes, static_cast<uint32_t>(mColorModes.size())); std::copy_n(mColorModes.cbegin(), numModes, outModes); *outNumModes = numModes; return HWC2::Error::None; |