diff options
Diffstat (limited to 'media/codec2/hal/common/MultiAccessUnitHelper.cpp')
-rw-r--r-- | media/codec2/hal/common/MultiAccessUnitHelper.cpp | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/media/codec2/hal/common/MultiAccessUnitHelper.cpp b/media/codec2/hal/common/MultiAccessUnitHelper.cpp index 9221a24cbd..03a76e901f 100644 --- a/media/codec2/hal/common/MultiAccessUnitHelper.cpp +++ b/media/codec2/hal/common/MultiAccessUnitHelper.cpp @@ -73,12 +73,17 @@ MultiAccessUnitInterface::MultiAccessUnitInterface( for (std::shared_ptr<C2ParamDescriptor> &desc : supportedParams) { mSupportedParamIndexSet.insert(desc->index()); } + mParamFields.emplace_back(mLargeFrameParams.get(), &(mLargeFrameParams.get()->maxSize)); + mParamFields.emplace_back(mLargeFrameParams.get(), &(mLargeFrameParams.get()->thresholdSize)); if (mC2ComponentIntf) { c2_status_t err = mC2ComponentIntf->query_vb({&mKind}, {}, C2_MAY_BLOCK, nullptr); } } +bool MultiAccessUnitInterface::isValidField(const C2ParamField &field) const { + return (std::find(mParamFields.begin(), mParamFields.end(), field) != mParamFields.end()); +} bool MultiAccessUnitInterface::isParamSupported(C2Param::Index index) { return (mSupportedParamIndexSet.count(index) != 0); } @@ -91,18 +96,23 @@ C2Component::kind_t MultiAccessUnitInterface::kind() const { return (C2Component::kind_t)(mKind.value); } -void MultiAccessUnitInterface::getDecoderSampleRateAndChannelCount( - uint32_t &sampleRate_, uint32_t &channelCount_) const { +bool MultiAccessUnitInterface::getDecoderSampleRateAndChannelCount( + uint32_t * const sampleRate_, uint32_t * const channelCount_) const { + if (sampleRate_ == nullptr || sampleRate_ == nullptr) { + return false; + } if (mC2ComponentIntf) { C2StreamSampleRateInfo::output sampleRate; C2StreamChannelCountInfo::output channelCount; c2_status_t res = mC2ComponentIntf->query_vb( {&sampleRate, &channelCount}, {}, C2_MAY_BLOCK, nullptr); - if (res == C2_OK) { - sampleRate_ = sampleRate.value; - channelCount_ = channelCount.value; + if (res == C2_OK && sampleRate.value > 0 && channelCount.value > 0) { + *sampleRate_ = sampleRate.value; + *channelCount_ = channelCount.value; + return true; } } + return false; } //C2MultiAccessUnitBuffer @@ -315,26 +325,10 @@ c2_status_t MultiAccessUnitHelper::scatter( } } if (!processedWork->empty()) { - { - C2LargeFrame::output multiAccessParams = mInterface->getLargeFrameParam(); - if (mInterface->kind() == C2Component::KIND_DECODER) { - uint32_t sampleRate = 0; - uint32_t channelCount = 0; - uint32_t frameSize = 0; - mInterface->getDecoderSampleRateAndChannelCount( - sampleRate, channelCount); - if (sampleRate > 0 && channelCount > 0) { - frameSize = channelCount * 2; - multiAccessParams.maxSize = - (multiAccessParams.maxSize / frameSize) * frameSize; - multiAccessParams.thresholdSize = - (multiAccessParams.thresholdSize / frameSize) * frameSize; - } - } - frameInfo.mLargeFrameTuning = multiAccessParams; - std::lock_guard<std::mutex> l(mLock); - mFrameHolder.push_back(std::move(frameInfo)); - } + C2LargeFrame::output multiAccessParams = mInterface->getLargeFrameParam(); + frameInfo.mLargeFrameTuning = multiAccessParams; + std::lock_guard<std::mutex> l(mLock); + mFrameHolder.push_back(std::move(frameInfo)); } } return C2_OK; @@ -501,6 +495,20 @@ c2_status_t MultiAccessUnitHelper::processWorklets(MultiAccessUnitInfo &frame, frame.reset(); return C2_OK; } + int64_t sampleTimeUs = 0; + uint32_t frameSize = 0; + uint32_t sampleRate = 0; + uint32_t channelCount = 0; + if (mInterface->getDecoderSampleRateAndChannelCount(&sampleRate, &channelCount)) { + sampleTimeUs = (1000000u) / (sampleRate * channelCount * 2); + frameSize = channelCount * 2; + if (mInterface->kind() == C2Component::KIND_DECODER) { + frame.mLargeFrameTuning.maxSize = + (frame.mLargeFrameTuning.maxSize / frameSize) * frameSize; + frame.mLargeFrameTuning.thresholdSize = + (frame.mLargeFrameTuning.thresholdSize / frameSize) * frameSize; + } + } c2_status_t c2ret = allocateWork(frame, true); if (c2ret != C2_OK) { return c2ret; @@ -515,15 +523,7 @@ c2_status_t MultiAccessUnitHelper::processWorklets(MultiAccessUnitInfo &frame, outputFramedata.infoBuffers.insert(outputFramedata.infoBuffers.begin(), (*worklet)->output.infoBuffers.begin(), (*worklet)->output.infoBuffers.end()); - int64_t sampleTimeUs = 0; - uint32_t frameSize = 0; - uint32_t sampleRate = 0; - uint32_t channelCount = 0; - mInterface->getDecoderSampleRateAndChannelCount(sampleRate, channelCount); - if (sampleRate > 0 && channelCount > 0) { - sampleTimeUs = (1000000u) / (sampleRate * channelCount * 2); - frameSize = channelCount * 2; - } + LOG(DEBUG) << "maxOutSize " << frame.mLargeFrameTuning.maxSize << " threshold " << frame.mLargeFrameTuning.thresholdSize; if ((*worklet)->output.buffers.size() > 0) { |