Loading media/codec2/sfplugin/CCodecBufferChannel.cpp +6 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define LOG_TAG "CCodecBufferChannel" #define LOG_TAG "CCodecBufferChannel" #define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> #include <utils/Log.h> #include <utils/Trace.h> #include <algorithm> #include <algorithm> #include <atomic> #include <atomic> Loading Loading @@ -326,6 +328,8 @@ status_t CCodecBufferChannel::queueInputBufferInternal( } } c2_status_t err = C2_OK; c2_status_t err = C2_OK; if (!items.empty()) { if (!items.empty()) { ScopedTrace trace(ATRACE_TAG, android::base::StringPrintf( "CCodecBufferChannel::queue(%s@ts=%lld)", mName, (long long)timeUs).c_str()); { { Mutexed<PipelineWatcher>::Locked watcher(mPipelineWatcher); Mutexed<PipelineWatcher>::Locked watcher(mPipelineWatcher); PipelineWatcher::Clock::time_point now = PipelineWatcher::Clock::now(); PipelineWatcher::Clock::time_point now = PipelineWatcher::Clock::now(); Loading Loading @@ -1913,6 +1917,8 @@ bool CCodecBufferChannel::handleWork( // When using input surface we need to restore the original input timestamp. // When using input surface we need to restore the original input timestamp. timestamp = work->input.ordinal.customOrdinal; timestamp = work->input.ordinal.customOrdinal; } } ScopedTrace trace(ATRACE_TAG, android::base::StringPrintf( "CCodecBufferChannel::onWorkDone(%s@ts=%lld)", mName, timestamp.peekll()).c_str()); ALOGV("[%s] onWorkDone: input %lld, codec %lld => output %lld => %lld", ALOGV("[%s] onWorkDone: input %lld, codec %lld => output %lld => %lld", mName, mName, work->input.ordinal.customOrdinal.peekll(), work->input.ordinal.customOrdinal.peekll(), Loading media/codec2/sfplugin/Codec2Buffer.cpp +11 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define LOG_TAG "Codec2Buffer" #define LOG_TAG "Codec2Buffer" #define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> #include <utils/Log.h> #include <utils/Trace.h> #include <aidl/android/hardware/graphics/common/Cta861_3.h> #include <aidl/android/hardware/graphics/common/Cta861_3.h> #include <aidl/android/hardware/graphics/common/Smpte2086.h> #include <aidl/android/hardware/graphics/common/Smpte2086.h> Loading Loading @@ -229,6 +231,7 @@ public: mAllocatedDepth(0), mAllocatedDepth(0), mBackBufferSize(0), mBackBufferSize(0), mMediaImage(new ABuffer(sizeof(MediaImage2))) { mMediaImage(new ABuffer(sizeof(MediaImage2))) { ATRACE_CALL(); if (!format->findInt32(KEY_COLOR_FORMAT, &mClientColorFormat)) { if (!format->findInt32(KEY_COLOR_FORMAT, &mClientColorFormat)) { mClientColorFormat = COLOR_FormatYUV420Flexible; mClientColorFormat = COLOR_FormatYUV420Flexible; } } Loading Loading @@ -581,6 +584,7 @@ public: * Copy C2GraphicView to MediaImage2. * Copy C2GraphicView to MediaImage2. */ */ status_t copyToMediaImage() { status_t copyToMediaImage() { ATRACE_CALL(); if (mInitCheck != OK) { if (mInitCheck != OK) { return mInitCheck; return mInitCheck; } } Loading Loading @@ -619,7 +623,9 @@ sp<GraphicBlockBuffer> GraphicBlockBuffer::Allocate( const sp<AMessage> &format, const sp<AMessage> &format, const std::shared_ptr<C2GraphicBlock> &block, const std::shared_ptr<C2GraphicBlock> &block, std::function<sp<ABuffer>(size_t)> alloc) { std::function<sp<ABuffer>(size_t)> alloc) { ATRACE_BEGIN("GraphicBlockBuffer::Allocate block->map()"); C2GraphicView view(block->map().get()); C2GraphicView view(block->map().get()); ATRACE_END(); if (view.error() != C2_OK) { if (view.error() != C2_OK) { ALOGD("C2GraphicBlock::map failed: %d", view.error()); ALOGD("C2GraphicBlock::map failed: %d", view.error()); return nullptr; return nullptr; Loading Loading @@ -664,6 +670,7 @@ GraphicBlockBuffer::GraphicBlockBuffer( } } std::shared_ptr<C2Buffer> GraphicBlockBuffer::asC2Buffer() { std::shared_ptr<C2Buffer> GraphicBlockBuffer::asC2Buffer() { ATRACE_CALL(); uint32_t width = mView.width(); uint32_t width = mView.width(); uint32_t height = mView.height(); uint32_t height = mView.height(); if (!mWrapped) { if (!mWrapped) { Loading Loading @@ -752,8 +759,10 @@ sp<ConstGraphicBlockBuffer> ConstGraphicBlockBuffer::Allocate( ALOGD("C2Buffer precond fail"); ALOGD("C2Buffer precond fail"); return nullptr; return nullptr; } } ATRACE_BEGIN("ConstGraphicBlockBuffer::Allocate block->map()"); std::unique_ptr<const C2GraphicView> view(std::make_unique<const C2GraphicView>( std::unique_ptr<const C2GraphicView> view(std::make_unique<const C2GraphicView>( buffer->data().graphicBlocks()[0].map().get())); buffer->data().graphicBlocks()[0].map().get())); ATRACE_END(); std::unique_ptr<const C2GraphicView> holder; std::unique_ptr<const C2GraphicView> holder; GraphicView2MediaImageConverter converter(*view, format, false /* copy */); GraphicView2MediaImageConverter converter(*view, format, false /* copy */); Loading Loading @@ -854,11 +863,13 @@ bool ConstGraphicBlockBuffer::canCopy(const std::shared_ptr<C2Buffer> &buffer) c return false; return false; } } ATRACE_BEGIN("ConstGraphicBlockBuffer::canCopy block->map()"); GraphicView2MediaImageConverter converter( GraphicView2MediaImageConverter converter( buffer->data().graphicBlocks()[0].map().get(), buffer->data().graphicBlocks()[0].map().get(), // FIXME: format() is not const, but we cannot change it, so do a const cast here // FIXME: format() is not const, but we cannot change it, so do a const cast here const_cast<ConstGraphicBlockBuffer *>(this)->format(), const_cast<ConstGraphicBlockBuffer *>(this)->format(), true /* copy */); true /* copy */); ATRACE_END(); if (converter.initCheck() != OK) { if (converter.initCheck() != OK) { ALOGD("ConstGraphicBlockBuffer::canCopy: converter init failed: %d", converter.initCheck()); ALOGD("ConstGraphicBlockBuffer::canCopy: converter init failed: %d", converter.initCheck()); return false; return false; Loading media/codec2/sfplugin/utils/Codec2BufferUtils.cpp +24 −2 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define LOG_TAG "Codec2BufferUtils" #define LOG_TAG "Codec2BufferUtils" #define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> #include <utils/Log.h> #include <utils/Trace.h> #include <libyuv.h> #include <libyuv.h> Loading @@ -36,8 +38,8 @@ namespace android { namespace { namespace { /** /** * A flippable, optimizable memcpy. Constructs such as (from ? src : dst) do not work as the results are * A flippable, optimizable memcpy. Constructs such as (from ? src : dst) * always const. * do not work as the results are always const. */ */ template<bool ToA, size_t S> template<bool ToA, size_t S> struct MemCopier { struct MemCopier { Loading Loading @@ -139,15 +141,18 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView if (IsNV12(view)) { if (IsNV12(view)) { if (IsNV12(img)) { if (IsNV12(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV12"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); return OK; return OK; } else if (IsNV21(img)) { } else if (IsNV21(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV21"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(img)) { } else if (IsI420(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->I420"); if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -155,15 +160,18 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView } } } else if (IsNV21(view)) { } else if (IsNV21(view)) { if (IsNV12(img)) { if (IsNV12(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV12"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(img)) { } else if (IsNV21(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV21"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); return OK; return OK; } else if (IsI420(img)) { } else if (IsI420(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->I420"); if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -171,22 +179,26 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView } } } else if (IsI420(view)) { } else if (IsI420(view)) { if (IsNV12(img)) { if (IsNV12(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV12"); if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(img)) { } else if (IsNV21(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV21"); if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(img)) { } else if (IsI420(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->I420"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); return OK; return OK; } } } } ScopedTrace trace(ATRACE_TAG, "ImageCopy: generic"); return _ImageCopy<true>(view, img, imgBase); return _ImageCopy<true>(view, img, imgBase); } } Loading @@ -210,15 +222,18 @@ status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage int height = view.crop().height; int height = view.crop().height; if (IsNV12(img)) { if (IsNV12(img)) { if (IsNV12(view)) { if (IsNV12(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV12"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); return OK; return OK; } else if (IsNV21(view)) { } else if (IsNV21(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV21"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(view)) { } else if (IsI420(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->I420"); if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -226,15 +241,18 @@ status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage } } } else if (IsNV21(img)) { } else if (IsNV21(img)) { if (IsNV12(view)) { if (IsNV12(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV12"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(view)) { } else if (IsNV21(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV21"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); return OK; return OK; } else if (IsI420(view)) { } else if (IsI420(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->I420"); if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -242,22 +260,26 @@ status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage } } } else if (IsI420(img)) { } else if (IsI420(img)) { if (IsNV12(view)) { if (IsNV12(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV12"); if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(view)) { } else if (IsNV21(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV21"); if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(view)) { } else if (IsI420(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->I420"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); return OK; return OK; } } } } ScopedTrace trace(ATRACE_TAG, "ImageCopy: generic"); return _ImageCopy<false>(view, img, imgBase); return _ImageCopy<false>(view, img, imgBase); } } Loading Loading
media/codec2/sfplugin/CCodecBufferChannel.cpp +6 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define LOG_TAG "CCodecBufferChannel" #define LOG_TAG "CCodecBufferChannel" #define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> #include <utils/Log.h> #include <utils/Trace.h> #include <algorithm> #include <algorithm> #include <atomic> #include <atomic> Loading Loading @@ -326,6 +328,8 @@ status_t CCodecBufferChannel::queueInputBufferInternal( } } c2_status_t err = C2_OK; c2_status_t err = C2_OK; if (!items.empty()) { if (!items.empty()) { ScopedTrace trace(ATRACE_TAG, android::base::StringPrintf( "CCodecBufferChannel::queue(%s@ts=%lld)", mName, (long long)timeUs).c_str()); { { Mutexed<PipelineWatcher>::Locked watcher(mPipelineWatcher); Mutexed<PipelineWatcher>::Locked watcher(mPipelineWatcher); PipelineWatcher::Clock::time_point now = PipelineWatcher::Clock::now(); PipelineWatcher::Clock::time_point now = PipelineWatcher::Clock::now(); Loading Loading @@ -1913,6 +1917,8 @@ bool CCodecBufferChannel::handleWork( // When using input surface we need to restore the original input timestamp. // When using input surface we need to restore the original input timestamp. timestamp = work->input.ordinal.customOrdinal; timestamp = work->input.ordinal.customOrdinal; } } ScopedTrace trace(ATRACE_TAG, android::base::StringPrintf( "CCodecBufferChannel::onWorkDone(%s@ts=%lld)", mName, timestamp.peekll()).c_str()); ALOGV("[%s] onWorkDone: input %lld, codec %lld => output %lld => %lld", ALOGV("[%s] onWorkDone: input %lld, codec %lld => output %lld => %lld", mName, mName, work->input.ordinal.customOrdinal.peekll(), work->input.ordinal.customOrdinal.peekll(), Loading
media/codec2/sfplugin/Codec2Buffer.cpp +11 −0 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define LOG_TAG "Codec2Buffer" #define LOG_TAG "Codec2Buffer" #define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> #include <utils/Log.h> #include <utils/Trace.h> #include <aidl/android/hardware/graphics/common/Cta861_3.h> #include <aidl/android/hardware/graphics/common/Cta861_3.h> #include <aidl/android/hardware/graphics/common/Smpte2086.h> #include <aidl/android/hardware/graphics/common/Smpte2086.h> Loading Loading @@ -229,6 +231,7 @@ public: mAllocatedDepth(0), mAllocatedDepth(0), mBackBufferSize(0), mBackBufferSize(0), mMediaImage(new ABuffer(sizeof(MediaImage2))) { mMediaImage(new ABuffer(sizeof(MediaImage2))) { ATRACE_CALL(); if (!format->findInt32(KEY_COLOR_FORMAT, &mClientColorFormat)) { if (!format->findInt32(KEY_COLOR_FORMAT, &mClientColorFormat)) { mClientColorFormat = COLOR_FormatYUV420Flexible; mClientColorFormat = COLOR_FormatYUV420Flexible; } } Loading Loading @@ -581,6 +584,7 @@ public: * Copy C2GraphicView to MediaImage2. * Copy C2GraphicView to MediaImage2. */ */ status_t copyToMediaImage() { status_t copyToMediaImage() { ATRACE_CALL(); if (mInitCheck != OK) { if (mInitCheck != OK) { return mInitCheck; return mInitCheck; } } Loading Loading @@ -619,7 +623,9 @@ sp<GraphicBlockBuffer> GraphicBlockBuffer::Allocate( const sp<AMessage> &format, const sp<AMessage> &format, const std::shared_ptr<C2GraphicBlock> &block, const std::shared_ptr<C2GraphicBlock> &block, std::function<sp<ABuffer>(size_t)> alloc) { std::function<sp<ABuffer>(size_t)> alloc) { ATRACE_BEGIN("GraphicBlockBuffer::Allocate block->map()"); C2GraphicView view(block->map().get()); C2GraphicView view(block->map().get()); ATRACE_END(); if (view.error() != C2_OK) { if (view.error() != C2_OK) { ALOGD("C2GraphicBlock::map failed: %d", view.error()); ALOGD("C2GraphicBlock::map failed: %d", view.error()); return nullptr; return nullptr; Loading Loading @@ -664,6 +670,7 @@ GraphicBlockBuffer::GraphicBlockBuffer( } } std::shared_ptr<C2Buffer> GraphicBlockBuffer::asC2Buffer() { std::shared_ptr<C2Buffer> GraphicBlockBuffer::asC2Buffer() { ATRACE_CALL(); uint32_t width = mView.width(); uint32_t width = mView.width(); uint32_t height = mView.height(); uint32_t height = mView.height(); if (!mWrapped) { if (!mWrapped) { Loading Loading @@ -752,8 +759,10 @@ sp<ConstGraphicBlockBuffer> ConstGraphicBlockBuffer::Allocate( ALOGD("C2Buffer precond fail"); ALOGD("C2Buffer precond fail"); return nullptr; return nullptr; } } ATRACE_BEGIN("ConstGraphicBlockBuffer::Allocate block->map()"); std::unique_ptr<const C2GraphicView> view(std::make_unique<const C2GraphicView>( std::unique_ptr<const C2GraphicView> view(std::make_unique<const C2GraphicView>( buffer->data().graphicBlocks()[0].map().get())); buffer->data().graphicBlocks()[0].map().get())); ATRACE_END(); std::unique_ptr<const C2GraphicView> holder; std::unique_ptr<const C2GraphicView> holder; GraphicView2MediaImageConverter converter(*view, format, false /* copy */); GraphicView2MediaImageConverter converter(*view, format, false /* copy */); Loading Loading @@ -854,11 +863,13 @@ bool ConstGraphicBlockBuffer::canCopy(const std::shared_ptr<C2Buffer> &buffer) c return false; return false; } } ATRACE_BEGIN("ConstGraphicBlockBuffer::canCopy block->map()"); GraphicView2MediaImageConverter converter( GraphicView2MediaImageConverter converter( buffer->data().graphicBlocks()[0].map().get(), buffer->data().graphicBlocks()[0].map().get(), // FIXME: format() is not const, but we cannot change it, so do a const cast here // FIXME: format() is not const, but we cannot change it, so do a const cast here const_cast<ConstGraphicBlockBuffer *>(this)->format(), const_cast<ConstGraphicBlockBuffer *>(this)->format(), true /* copy */); true /* copy */); ATRACE_END(); if (converter.initCheck() != OK) { if (converter.initCheck() != OK) { ALOGD("ConstGraphicBlockBuffer::canCopy: converter init failed: %d", converter.initCheck()); ALOGD("ConstGraphicBlockBuffer::canCopy: converter init failed: %d", converter.initCheck()); return false; return false; Loading
media/codec2/sfplugin/utils/Codec2BufferUtils.cpp +24 −2 Original line number Original line Diff line number Diff line Loading @@ -16,7 +16,9 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define LOG_TAG "Codec2BufferUtils" #define LOG_TAG "Codec2BufferUtils" #define ATRACE_TAG ATRACE_TAG_VIDEO #include <utils/Log.h> #include <utils/Log.h> #include <utils/Trace.h> #include <libyuv.h> #include <libyuv.h> Loading @@ -36,8 +38,8 @@ namespace android { namespace { namespace { /** /** * A flippable, optimizable memcpy. Constructs such as (from ? src : dst) do not work as the results are * A flippable, optimizable memcpy. Constructs such as (from ? src : dst) * always const. * do not work as the results are always const. */ */ template<bool ToA, size_t S> template<bool ToA, size_t S> struct MemCopier { struct MemCopier { Loading Loading @@ -139,15 +141,18 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView if (IsNV12(view)) { if (IsNV12(view)) { if (IsNV12(img)) { if (IsNV12(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV12"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); return OK; return OK; } else if (IsNV21(img)) { } else if (IsNV21(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV21"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(img)) { } else if (IsI420(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->I420"); if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -155,15 +160,18 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView } } } else if (IsNV21(view)) { } else if (IsNV21(view)) { if (IsNV12(img)) { if (IsNV12(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV12"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(img)) { } else if (IsNV21(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV21"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); return OK; return OK; } else if (IsI420(img)) { } else if (IsI420(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->I420"); if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -171,22 +179,26 @@ status_t ImageCopy(uint8_t *imgBase, const MediaImage2 *img, const C2GraphicView } } } else if (IsI420(view)) { } else if (IsI420(view)) { if (IsNV12(img)) { if (IsNV12(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV12"); if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(img)) { } else if (IsNV21(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV21"); if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(img)) { } else if (IsI420(img)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->I420"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); return OK; return OK; } } } } ScopedTrace trace(ATRACE_TAG, "ImageCopy: generic"); return _ImageCopy<true>(view, img, imgBase); return _ImageCopy<true>(view, img, imgBase); } } Loading @@ -210,15 +222,18 @@ status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage int height = view.crop().height; int height = view.crop().height; if (IsNV12(img)) { if (IsNV12(img)) { if (IsNV12(view)) { if (IsNV12(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV12"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width, height / 2); return OK; return OK; } else if (IsNV21(view)) { } else if (IsNV21(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->NV21"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(view)) { } else if (IsI420(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV12->I420"); if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, if (!libyuv::NV12ToI420(src_y, src_stride_y, src_u, src_stride_u, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -226,15 +241,18 @@ status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage } } } else if (IsNV21(img)) { } else if (IsNV21(img)) { if (IsNV12(view)) { if (IsNV12(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV12"); if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, if (!libyuv::NV21ToNV12(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(view)) { } else if (IsNV21(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->NV21"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width, height / 2); return OK; return OK; } else if (IsI420(view)) { } else if (IsI420(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: NV21->I420"); if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, if (!libyuv::NV21ToI420(src_y, src_stride_y, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { dst_u, dst_stride_u, dst_v, dst_stride_v, width, height)) { return OK; return OK; Loading @@ -242,22 +260,26 @@ status_t ImageCopy(C2GraphicView &view, const uint8_t *imgBase, const MediaImage } } } else if (IsI420(img)) { } else if (IsI420(img)) { if (IsNV12(view)) { if (IsNV12(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV12"); if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV12(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { dst_y, dst_stride_y, dst_u, dst_stride_u, width, height)) { return OK; return OK; } } } else if (IsNV21(view)) { } else if (IsNV21(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->NV21"); if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, if (!libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v, src_stride_v, dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { dst_y, dst_stride_y, dst_v, dst_stride_v, width, height)) { return OK; return OK; } } } else if (IsI420(view)) { } else if (IsI420(view)) { ScopedTrace trace(ATRACE_TAG, "ImageCopy: I420->I420"); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_y, src_stride_y, dst_y, dst_stride_y, width, height); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_u, src_stride_u, dst_u, dst_stride_u, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); libyuv::CopyPlane(src_v, src_stride_v, dst_v, dst_stride_v, width / 2, height / 2); return OK; return OK; } } } } ScopedTrace trace(ATRACE_TAG, "ImageCopy: generic"); return _ImageCopy<false>(view, img, imgBase); return _ImageCopy<false>(view, img, imgBase); } } Loading