Loading media/codec2/sfplugin/CCodecBuffers.cpp +23 −7 Original line number Diff line number Diff line Loading @@ -1340,6 +1340,9 @@ status_t OutputBuffersArray::registerBuffer( ALOGD("[%s] grabBuffer failed: %d", mName, err); return err; } if (buffer) { mBufferType = buffer->data().type(); } c2Buffer->setFormat(mFormat); if (!convert(buffer, &c2Buffer) && !c2Buffer->copy(buffer)) { ALOGD("[%s] copy buffer failed", mName); Loading Loading @@ -1405,16 +1408,27 @@ size_t OutputBuffersArray::numActiveSlots() const { } void OutputBuffersArray::realloc(const std::shared_ptr<C2Buffer> &c2buffer) { switch (c2buffer->data().type()) { // Handle cases where c2buffer is nullptr (e.g., during EOS events) // by using a default buffer type and relying on subsequent buffers for type information if (c2buffer != nullptr) { mBufferType = c2buffer->data().type(); } switch (mBufferType) { case C2BufferData::LINEAR: { uint32_t size = kLinearBufferSize; const std::vector<C2ConstLinearBlock> &linear_blocks = c2buffer->data().linearBlocks(); if (c2buffer != nullptr) { const std::vector<C2ConstLinearBlock> &linear_blocks = c2buffer->data().linearBlocks(); const uint32_t block_size = linear_blocks.front().size(); if (block_size < kMaxLinearBufferSize / 2) { size = block_size * 2; } else { size = kMaxLinearBufferSize; } } else { // This is done to satisfy the allocator. size = 0; } mAlloc = [format = mFormat, size] { return new LocalLinearBuffer(format, new ABuffer(size)); }; Loading @@ -1441,7 +1455,7 @@ void OutputBuffersArray::realloc(const std::shared_ptr<C2Buffer> &c2buffer) { case C2BufferData::LINEAR_CHUNKS: [[fallthrough]]; case C2BufferData::GRAPHIC_CHUNKS: [[fallthrough]]; default: ALOGD("Unsupported type: %d", (int)c2buffer->data().type()); ALOGD("Unsupported type: %d", (int)mBufferType); return; } mImpl.realloc(mAlloc); Loading @@ -1458,6 +1472,8 @@ void OutputBuffersArray::transferFrom(OutputBuffers* source) { mReorderStash = std::move(source->mReorderStash); mDepth = source->mDepth; mKey = source->mKey; mBufferType = source->getPixelFormatIfApplicable() != PIXEL_FORMAT_UNKNOWN ? C2BufferData::GRAPHIC : C2BufferData::LINEAR; } // FlexOutputBuffers Loading media/codec2/sfplugin/CCodecBuffers.h +4 −1 Original line number Diff line number Diff line Loading @@ -1012,7 +1012,8 @@ protected: class OutputBuffersArray : public OutputBuffers { public: OutputBuffersArray(const char *componentName, const char *name = "Output[N]") : OutputBuffers(componentName, name) { } : OutputBuffers(componentName, name), mBufferType(C2BufferData::INVALID) { } ~OutputBuffersArray() override = default; /** Loading Loading @@ -1080,6 +1081,8 @@ public: private: BuffersArrayImpl mImpl; std::function<sp<Codec2Buffer>()> mAlloc; C2BufferData::type_t mBufferType; }; class FlexOutputBuffers : public OutputBuffers { Loading Loading
media/codec2/sfplugin/CCodecBuffers.cpp +23 −7 Original line number Diff line number Diff line Loading @@ -1340,6 +1340,9 @@ status_t OutputBuffersArray::registerBuffer( ALOGD("[%s] grabBuffer failed: %d", mName, err); return err; } if (buffer) { mBufferType = buffer->data().type(); } c2Buffer->setFormat(mFormat); if (!convert(buffer, &c2Buffer) && !c2Buffer->copy(buffer)) { ALOGD("[%s] copy buffer failed", mName); Loading Loading @@ -1405,16 +1408,27 @@ size_t OutputBuffersArray::numActiveSlots() const { } void OutputBuffersArray::realloc(const std::shared_ptr<C2Buffer> &c2buffer) { switch (c2buffer->data().type()) { // Handle cases where c2buffer is nullptr (e.g., during EOS events) // by using a default buffer type and relying on subsequent buffers for type information if (c2buffer != nullptr) { mBufferType = c2buffer->data().type(); } switch (mBufferType) { case C2BufferData::LINEAR: { uint32_t size = kLinearBufferSize; const std::vector<C2ConstLinearBlock> &linear_blocks = c2buffer->data().linearBlocks(); if (c2buffer != nullptr) { const std::vector<C2ConstLinearBlock> &linear_blocks = c2buffer->data().linearBlocks(); const uint32_t block_size = linear_blocks.front().size(); if (block_size < kMaxLinearBufferSize / 2) { size = block_size * 2; } else { size = kMaxLinearBufferSize; } } else { // This is done to satisfy the allocator. size = 0; } mAlloc = [format = mFormat, size] { return new LocalLinearBuffer(format, new ABuffer(size)); }; Loading @@ -1441,7 +1455,7 @@ void OutputBuffersArray::realloc(const std::shared_ptr<C2Buffer> &c2buffer) { case C2BufferData::LINEAR_CHUNKS: [[fallthrough]]; case C2BufferData::GRAPHIC_CHUNKS: [[fallthrough]]; default: ALOGD("Unsupported type: %d", (int)c2buffer->data().type()); ALOGD("Unsupported type: %d", (int)mBufferType); return; } mImpl.realloc(mAlloc); Loading @@ -1458,6 +1472,8 @@ void OutputBuffersArray::transferFrom(OutputBuffers* source) { mReorderStash = std::move(source->mReorderStash); mDepth = source->mDepth; mKey = source->mKey; mBufferType = source->getPixelFormatIfApplicable() != PIXEL_FORMAT_UNKNOWN ? C2BufferData::GRAPHIC : C2BufferData::LINEAR; } // FlexOutputBuffers Loading
media/codec2/sfplugin/CCodecBuffers.h +4 −1 Original line number Diff line number Diff line Loading @@ -1012,7 +1012,8 @@ protected: class OutputBuffersArray : public OutputBuffers { public: OutputBuffersArray(const char *componentName, const char *name = "Output[N]") : OutputBuffers(componentName, name) { } : OutputBuffers(componentName, name), mBufferType(C2BufferData::INVALID) { } ~OutputBuffersArray() override = default; /** Loading Loading @@ -1080,6 +1081,8 @@ public: private: BuffersArrayImpl mImpl; std::function<sp<Codec2Buffer>()> mAlloc; C2BufferData::type_t mBufferType; }; class FlexOutputBuffers : public OutputBuffers { Loading