diff --git a/c2_components/include/mfx_c2_decoder_component.h b/c2_components/include/mfx_c2_decoder_component.h index a020291e..89298acb 100755 --- a/c2_components/include/mfx_c2_decoder_component.h +++ b/c2_components/include/mfx_c2_decoder_component.h @@ -243,8 +243,6 @@ class MfxC2DecoderComponent : public MfxC2Component std::vector> m_updatingC2Configures; - uint64_t m_consumerUsage; - uint32_t m_surfaceNum; std::list> m_surfacePool; // used in case of system memory @@ -281,6 +279,7 @@ class MfxC2DecoderComponent : public MfxC2Component std::shared_ptr m_defaultColorAspects; std::shared_ptr m_codedColorAspects; std::shared_ptr m_colorAspects; + std::shared_ptr m_outputUsage; /* ----------------------------------------Setters------------------------------------------- */ static C2R OutputSurfaceAllocatorSetter(bool mayBlock, C2P &me); static C2R SizeSetter(bool mayBlock, const C2P &oldMe, diff --git a/c2_components/src/mfx_c2_decoder_component.cpp b/c2_components/src/mfx_c2_decoder_component.cpp index f5985bb3..85fb749d 100755 --- a/c2_components/src/mfx_c2_decoder_component.cpp +++ b/c2_components/src/mfx_c2_decoder_component.cpp @@ -57,7 +57,6 @@ enum VP8_LEVEL { LEVEL_VP8_Version0 = C2_PROFILE_LEVEL_VENDOR_START, }; - C2R MfxC2DecoderComponent::OutputSurfaceAllocatorSetter(bool mayBlock, C2P &me) { (void)mayBlock; (void)me; @@ -222,6 +221,13 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo .withConstValue(AllocSharedString("video/raw")) .build()); + addParameter( + DefineParam(m_outputUsage, C2_PARAMKEY_OUTPUT_STREAM_USAGE) + .withDefault(new C2StreamUsageTuning::output(0u, C2AndroidMemoryUsage::HW_CODEC_WRITE)) + .withFields({C2F(m_outputUsage, value).any()}) + .withSetter(Setter::StrictValueWithNoDeps) + .build()); + switch(m_decoderType) { case DECODER_H264: { m_uOutputDelay = /*max_dpb_size*/16 + /*for async depth*/1 + /*for msdk unref in sync part*/1; @@ -280,7 +286,6 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo } case DECODER_H265: { m_uOutputDelay = /*max_dpb_size*/16 + /*for async depth*/1 + /*for msdk unref in sync part*/1; - m_uInputDelay = 15; addParameter( @@ -640,9 +645,6 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo m_hdrStaticInfo->maxCll = 0; m_hdrStaticInfo->maxFall = 0; - // By default prepare buffer to be displayed on any of the common surfaces - m_consumerUsage = kDefaultConsumerUsage; - MFX_ZERO_MEMORY(m_signalInfo); //m_paramStorage.DumpParams(); } @@ -1124,7 +1126,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr c2_all if (MFX_ERR_NONE == mfx_res) { // set memory type according to consumer usage sent from framework - m_mfxVideoParams.IOPattern = (C2MemoryUsage::CPU_READ == m_consumerUsage) ? + m_mfxVideoParams.IOPattern = (C2MemoryUsage::CPU_READ == m_outputUsage->value) ? MFX_IOPATTERN_OUT_SYSTEM_MEMORY : MFX_IOPATTERN_OUT_VIDEO_MEMORY; MFX_DEBUG_TRACE_I32(m_mfxVideoParams.IOPattern); MFX_DEBUG_TRACE_I32(m_mfxVideoParams.mfx.FrameInfo.Width); @@ -1183,9 +1185,11 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr c2_all uint64_t usage, igbp_id; android::_UnwrapNativeCodec2GrallocMetadata(out_block->handle(), &width, &height, &format, &usage, &stride, &generation, &igbp_id, &igbp_slot); - if ((!igbp_id && !igbp_slot) || (!igbp_id && igbp_slot == 0xffffffff)) + MFX_DEBUG_TRACE_PRINTF("m_outputUsage is C2MemoryUsage::CPU_READ? %s", m_outputUsage->value == C2MemoryUsage::CPU_READ? "Y": "N"); + if((!igbp_id && !igbp_slot) || (!igbp_id && igbp_slot == 0xffffffff) || m_outputUsage->value == C2MemoryUsage::CPU_READ) { // No surface & BQ + MFX_DEBUG_TRACE_PRINTF("No surface & BQ, Force to use System memory"); m_mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; m_allocator = nullptr; } @@ -1212,7 +1216,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr c2_all if (m_allocator) { m_allocator->SetC2Allocator(c2_allocator); m_allocator->SetBufferCount(m_uOutputDelay); - m_allocator->SetConsumerUsage(m_consumerUsage); + m_allocator->SetConsumerUsage(m_outputUsage->value); } MFX_DEBUG_TRACE_MSG("Decoder initializing..."); @@ -1748,7 +1752,7 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_VIDEO_MEMORY) { - C2MemoryUsage mem_usage = {m_consumerUsage, C2AndroidMemoryUsage::HW_CODEC_WRITE}; + C2MemoryUsage mem_usage = {m_outputUsage->value, C2AndroidMemoryUsage::HW_CODEC_WRITE}; res = m_c2Allocator->fetchGraphicBlock(width, height, MfxFourCCToGralloc(fourcc), mem_usage, out_block); if (res == C2_OK) { @@ -1773,7 +1777,7 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig } } else if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_SYSTEM_MEMORY) { - C2MemoryUsage mem_usage = {m_consumerUsage, C2MemoryUsage::CPU_WRITE}; + C2MemoryUsage mem_usage = {m_outputUsage->value, C2MemoryUsage::CPU_WRITE}; res = m_c2Allocator->fetchGraphicBlock(width, height, MfxFourCCToGralloc(fourcc, false), mem_usage, out_block); }