Loading media/codec2/components/avc/C2SoftAvcDec.cpp +43 −2 Original line number Diff line number Diff line Loading @@ -335,7 +335,8 @@ C2SoftAvcDec::C2SoftAvcDec( mIvColorFormat(IV_YUV_420P), mWidth(320), mHeight(240), mHeaderDecoded(false) { mHeaderDecoded(false), mOutIndex(0u) { GENERATE_FILE_NAMES(); CREATE_DUMP_FILE(mInFile); } Loading Loading @@ -692,6 +693,33 @@ void C2SoftAvcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wor buffer->setInfo(mIntf->getColorAspects_l()); } class FillWork { public: FillWork(uint32_t flags, C2WorkOrdinalStruct ordinal, const std::shared_ptr<C2Buffer>& buffer) : mFlags(flags), mOrdinal(ordinal), mBuffer(buffer) {} ~FillWork() = default; void operator()(const std::unique_ptr<C2Work>& work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)mFlags; work->worklets.front()->output.buffers.clear(); work->worklets.front()->output.ordinal = mOrdinal; work->workletsProcessed = 1u; work->result = C2_OK; if (mBuffer) { work->worklets.front()->output.buffers.push_back(mBuffer); } ALOGV("timestamp = %lld, index = %lld, w/%s buffer", mOrdinal.timestamp.peekll(), mOrdinal.frameIndex.peekll(), mBuffer ? "" : "o"); } private: const uint32_t mFlags; const C2WorkOrdinalStruct mOrdinal; const std::shared_ptr<C2Buffer> mBuffer; }; auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)0; work->worklets.front()->output.buffers.clear(); Loading @@ -700,7 +728,20 @@ void C2SoftAvcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wor work->workletsProcessed = 1u; }; if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) { bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0); // TODO: Check if cloneAndSend can be avoided by tracking number of frames remaining if (eos) { if (buffer) { mOutIndex = index; C2WorkOrdinalStruct outOrdinal = work->input.ordinal; cloneAndSend( mOutIndex, work, FillWork(C2FrameData::FLAG_INCOMPLETE, outOrdinal, buffer)); buffer.reset(); } } else { fillWork(work); } } else { finish(index, fillWork); } Loading media/codec2/components/avc/C2SoftAvcDec.h +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <media/stagefright/foundation/ColorUtils.h> #include <atomic> #include <SimpleC2Component.h> #include "ih264_typedefs.h" Loading Loading @@ -163,6 +164,7 @@ private: bool mSignalledOutputEos; bool mSignalledError; bool mHeaderDecoded; std::atomic_uint64_t mOutIndex; // Color aspects. These are ISO values and are meant to detect changes in aspects to avoid // converting them to C2 values for each frame struct VuiColorAspects { Loading media/codec2/components/hevc/C2SoftHevcDec.cpp +43 −2 Original line number Diff line number Diff line Loading @@ -329,7 +329,8 @@ C2SoftHevcDec::C2SoftHevcDec( mIvColorformat(IV_YUV_420P), mWidth(320), mHeight(240), mHeaderDecoded(false) { mHeaderDecoded(false), mOutIndex(0u) { } C2SoftHevcDec::~C2SoftHevcDec() { Loading Loading @@ -688,6 +689,33 @@ void C2SoftHevcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wo buffer->setInfo(mIntf->getColorAspects_l()); } class FillWork { public: FillWork(uint32_t flags, C2WorkOrdinalStruct ordinal, const std::shared_ptr<C2Buffer>& buffer) : mFlags(flags), mOrdinal(ordinal), mBuffer(buffer) {} ~FillWork() = default; void operator()(const std::unique_ptr<C2Work>& work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)mFlags; work->worklets.front()->output.buffers.clear(); work->worklets.front()->output.ordinal = mOrdinal; work->workletsProcessed = 1u; work->result = C2_OK; if (mBuffer) { work->worklets.front()->output.buffers.push_back(mBuffer); } ALOGV("timestamp = %lld, index = %lld, w/%s buffer", mOrdinal.timestamp.peekll(), mOrdinal.frameIndex.peekll(), mBuffer ? "" : "o"); } private: const uint32_t mFlags; const C2WorkOrdinalStruct mOrdinal; const std::shared_ptr<C2Buffer> mBuffer; }; auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)0; work->worklets.front()->output.buffers.clear(); Loading @@ -696,7 +724,20 @@ void C2SoftHevcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wo work->workletsProcessed = 1u; }; if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) { bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0); // TODO: Check if cloneAndSend can be avoided by tracking number of frames remaining if (eos) { if (buffer) { mOutIndex = index; C2WorkOrdinalStruct outOrdinal = work->input.ordinal; cloneAndSend( mOutIndex, work, FillWork(C2FrameData::FLAG_INCOMPLETE, outOrdinal, buffer)); buffer.reset(); } } else { fillWork(work); } } else { finish(index, fillWork); } Loading media/codec2/components/hevc/C2SoftHevcDec.h +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <media/stagefright/foundation/ColorUtils.h> #include <atomic> #include <SimpleC2Component.h> #include "ihevc_typedefs.h" Loading Loading @@ -121,6 +122,7 @@ struct C2SoftHevcDec : public SimpleC2Component { bool mSignalledOutputEos; bool mSignalledError; bool mHeaderDecoded; std::atomic_uint64_t mOutIndex; // Color aspects. These are ISO values and are meant to detect changes in aspects to avoid // converting them to C2 values for each frame Loading media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp +43 −2 Original line number Diff line number Diff line Loading @@ -315,7 +315,8 @@ C2SoftMpeg2Dec::C2SoftMpeg2Dec( mOutBufferDrain(nullptr), mIvColorformat(IV_YUV_420P), mWidth(320), mHeight(240) { mHeight(240), mOutIndex(0u) { // If input dump is enabled, then open create an empty file GENERATE_FILE_NAMES(); CREATE_DUMP_FILE(mInFile); Loading Loading @@ -766,6 +767,33 @@ void C2SoftMpeg2Dec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &w buffer->setInfo(mIntf->getColorAspects_l()); } class FillWork { public: FillWork(uint32_t flags, C2WorkOrdinalStruct ordinal, const std::shared_ptr<C2Buffer>& buffer) : mFlags(flags), mOrdinal(ordinal), mBuffer(buffer) {} ~FillWork() = default; void operator()(const std::unique_ptr<C2Work>& work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)mFlags; work->worklets.front()->output.buffers.clear(); work->worklets.front()->output.ordinal = mOrdinal; work->workletsProcessed = 1u; work->result = C2_OK; if (mBuffer) { work->worklets.front()->output.buffers.push_back(mBuffer); } ALOGV("timestamp = %lld, index = %lld, w/%s buffer", mOrdinal.timestamp.peekll(), mOrdinal.frameIndex.peekll(), mBuffer ? "" : "o"); } private: const uint32_t mFlags; const C2WorkOrdinalStruct mOrdinal; const std::shared_ptr<C2Buffer> mBuffer; }; auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)0; work->worklets.front()->output.buffers.clear(); Loading @@ -774,7 +802,20 @@ void C2SoftMpeg2Dec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &w work->workletsProcessed = 1u; }; if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) { bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0); // TODO: Check if cloneAndSend can be avoided by tracking number of frames remaining if (eos) { if (buffer) { mOutIndex = index; C2WorkOrdinalStruct outOrdinal = work->input.ordinal; cloneAndSend( mOutIndex, work, FillWork(C2FrameData::FLAG_INCOMPLETE, outOrdinal, buffer)); buffer.reset(); } } else { fillWork(work); } } else { finish(index, fillWork); } Loading Loading
media/codec2/components/avc/C2SoftAvcDec.cpp +43 −2 Original line number Diff line number Diff line Loading @@ -335,7 +335,8 @@ C2SoftAvcDec::C2SoftAvcDec( mIvColorFormat(IV_YUV_420P), mWidth(320), mHeight(240), mHeaderDecoded(false) { mHeaderDecoded(false), mOutIndex(0u) { GENERATE_FILE_NAMES(); CREATE_DUMP_FILE(mInFile); } Loading Loading @@ -692,6 +693,33 @@ void C2SoftAvcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wor buffer->setInfo(mIntf->getColorAspects_l()); } class FillWork { public: FillWork(uint32_t flags, C2WorkOrdinalStruct ordinal, const std::shared_ptr<C2Buffer>& buffer) : mFlags(flags), mOrdinal(ordinal), mBuffer(buffer) {} ~FillWork() = default; void operator()(const std::unique_ptr<C2Work>& work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)mFlags; work->worklets.front()->output.buffers.clear(); work->worklets.front()->output.ordinal = mOrdinal; work->workletsProcessed = 1u; work->result = C2_OK; if (mBuffer) { work->worklets.front()->output.buffers.push_back(mBuffer); } ALOGV("timestamp = %lld, index = %lld, w/%s buffer", mOrdinal.timestamp.peekll(), mOrdinal.frameIndex.peekll(), mBuffer ? "" : "o"); } private: const uint32_t mFlags; const C2WorkOrdinalStruct mOrdinal; const std::shared_ptr<C2Buffer> mBuffer; }; auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)0; work->worklets.front()->output.buffers.clear(); Loading @@ -700,7 +728,20 @@ void C2SoftAvcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wor work->workletsProcessed = 1u; }; if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) { bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0); // TODO: Check if cloneAndSend can be avoided by tracking number of frames remaining if (eos) { if (buffer) { mOutIndex = index; C2WorkOrdinalStruct outOrdinal = work->input.ordinal; cloneAndSend( mOutIndex, work, FillWork(C2FrameData::FLAG_INCOMPLETE, outOrdinal, buffer)); buffer.reset(); } } else { fillWork(work); } } else { finish(index, fillWork); } Loading
media/codec2/components/avc/C2SoftAvcDec.h +2 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ #include <media/stagefright/foundation/ColorUtils.h> #include <atomic> #include <SimpleC2Component.h> #include "ih264_typedefs.h" Loading Loading @@ -163,6 +164,7 @@ private: bool mSignalledOutputEos; bool mSignalledError; bool mHeaderDecoded; std::atomic_uint64_t mOutIndex; // Color aspects. These are ISO values and are meant to detect changes in aspects to avoid // converting them to C2 values for each frame struct VuiColorAspects { Loading
media/codec2/components/hevc/C2SoftHevcDec.cpp +43 −2 Original line number Diff line number Diff line Loading @@ -329,7 +329,8 @@ C2SoftHevcDec::C2SoftHevcDec( mIvColorformat(IV_YUV_420P), mWidth(320), mHeight(240), mHeaderDecoded(false) { mHeaderDecoded(false), mOutIndex(0u) { } C2SoftHevcDec::~C2SoftHevcDec() { Loading Loading @@ -688,6 +689,33 @@ void C2SoftHevcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wo buffer->setInfo(mIntf->getColorAspects_l()); } class FillWork { public: FillWork(uint32_t flags, C2WorkOrdinalStruct ordinal, const std::shared_ptr<C2Buffer>& buffer) : mFlags(flags), mOrdinal(ordinal), mBuffer(buffer) {} ~FillWork() = default; void operator()(const std::unique_ptr<C2Work>& work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)mFlags; work->worklets.front()->output.buffers.clear(); work->worklets.front()->output.ordinal = mOrdinal; work->workletsProcessed = 1u; work->result = C2_OK; if (mBuffer) { work->worklets.front()->output.buffers.push_back(mBuffer); } ALOGV("timestamp = %lld, index = %lld, w/%s buffer", mOrdinal.timestamp.peekll(), mOrdinal.frameIndex.peekll(), mBuffer ? "" : "o"); } private: const uint32_t mFlags; const C2WorkOrdinalStruct mOrdinal; const std::shared_ptr<C2Buffer> mBuffer; }; auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)0; work->worklets.front()->output.buffers.clear(); Loading @@ -696,7 +724,20 @@ void C2SoftHevcDec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &wo work->workletsProcessed = 1u; }; if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) { bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0); // TODO: Check if cloneAndSend can be avoided by tracking number of frames remaining if (eos) { if (buffer) { mOutIndex = index; C2WorkOrdinalStruct outOrdinal = work->input.ordinal; cloneAndSend( mOutIndex, work, FillWork(C2FrameData::FLAG_INCOMPLETE, outOrdinal, buffer)); buffer.reset(); } } else { fillWork(work); } } else { finish(index, fillWork); } Loading
media/codec2/components/hevc/C2SoftHevcDec.h +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <media/stagefright/foundation/ColorUtils.h> #include <atomic> #include <SimpleC2Component.h> #include "ihevc_typedefs.h" Loading Loading @@ -121,6 +122,7 @@ struct C2SoftHevcDec : public SimpleC2Component { bool mSignalledOutputEos; bool mSignalledError; bool mHeaderDecoded; std::atomic_uint64_t mOutIndex; // Color aspects. These are ISO values and are meant to detect changes in aspects to avoid // converting them to C2 values for each frame Loading
media/codec2/components/mpeg2/C2SoftMpeg2Dec.cpp +43 −2 Original line number Diff line number Diff line Loading @@ -315,7 +315,8 @@ C2SoftMpeg2Dec::C2SoftMpeg2Dec( mOutBufferDrain(nullptr), mIvColorformat(IV_YUV_420P), mWidth(320), mHeight(240) { mHeight(240), mOutIndex(0u) { // If input dump is enabled, then open create an empty file GENERATE_FILE_NAMES(); CREATE_DUMP_FILE(mInFile); Loading Loading @@ -766,6 +767,33 @@ void C2SoftMpeg2Dec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &w buffer->setInfo(mIntf->getColorAspects_l()); } class FillWork { public: FillWork(uint32_t flags, C2WorkOrdinalStruct ordinal, const std::shared_ptr<C2Buffer>& buffer) : mFlags(flags), mOrdinal(ordinal), mBuffer(buffer) {} ~FillWork() = default; void operator()(const std::unique_ptr<C2Work>& work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)mFlags; work->worklets.front()->output.buffers.clear(); work->worklets.front()->output.ordinal = mOrdinal; work->workletsProcessed = 1u; work->result = C2_OK; if (mBuffer) { work->worklets.front()->output.buffers.push_back(mBuffer); } ALOGV("timestamp = %lld, index = %lld, w/%s buffer", mOrdinal.timestamp.peekll(), mOrdinal.frameIndex.peekll(), mBuffer ? "" : "o"); } private: const uint32_t mFlags; const C2WorkOrdinalStruct mOrdinal; const std::shared_ptr<C2Buffer> mBuffer; }; auto fillWork = [buffer](const std::unique_ptr<C2Work> &work) { work->worklets.front()->output.flags = (C2FrameData::flags_t)0; work->worklets.front()->output.buffers.clear(); Loading @@ -774,7 +802,20 @@ void C2SoftMpeg2Dec::finishWork(uint64_t index, const std::unique_ptr<C2Work> &w work->workletsProcessed = 1u; }; if (work && c2_cntr64_t(index) == work->input.ordinal.frameIndex) { bool eos = ((work->input.flags & C2FrameData::FLAG_END_OF_STREAM) != 0); // TODO: Check if cloneAndSend can be avoided by tracking number of frames remaining if (eos) { if (buffer) { mOutIndex = index; C2WorkOrdinalStruct outOrdinal = work->input.ordinal; cloneAndSend( mOutIndex, work, FillWork(C2FrameData::FLAG_INCOMPLETE, outOrdinal, buffer)); buffer.reset(); } } else { fillWork(work); } } else { finish(index, fillWork); } Loading