Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions c2_components/include/mfx_c2_decoder_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,6 @@ class MfxC2DecoderComponent : public MfxC2Component

std::vector<std::unique_ptr<C2Param>> m_updatingC2Configures;

uint64_t m_consumerUsage;

uint32_t m_surfaceNum;
std::list<std::shared_ptr<mfxFrameSurface1>> m_surfacePool; // used in case of system memory

Expand Down Expand Up @@ -278,6 +276,7 @@ class MfxC2DecoderComponent : public MfxC2Component
std::shared_ptr<C2StreamColorAspectsTuning::output> m_defaultColorAspects;
std::shared_ptr<C2StreamColorAspectsInfo::input> m_inColorAspects;
std::shared_ptr<C2StreamColorAspectsInfo::output> m_outColorAspects;
std::shared_ptr<C2StreamUsageTuning::output> m_outputUsage;
/* ----------------------------------------Setters------------------------------------------- */
static C2R OutputSurfaceAllocatorSetter(bool mayBlock, C2P<C2PortSurfaceAllocatorTuning::output> &me);
static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe,
Expand Down
24 changes: 14 additions & 10 deletions c2_components/src/mfx_c2_decoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ enum VP8_LEVEL {
LEVEL_VP8_Version0 = C2_PROFILE_LEVEL_VENDOR_START,
};


C2R MfxC2DecoderComponent::OutputSurfaceAllocatorSetter(bool mayBlock, C2P<C2PortSurfaceAllocatorTuning::output> &me) {
(void)mayBlock;
(void)me;
Expand Down Expand Up @@ -221,6 +220,13 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo
.withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>("video/raw"))
.build());

addParameter(
DefineParam(m_outputUsage, C2_PARAMKEY_OUTPUT_STREAM_USAGE)
.withDefault(new C2StreamUsageTuning::output(0u, kDefaultConsumerUsage))
.withFields({C2F(m_outputUsage, value).any()})
.withSetter(Setter<decltype(*m_outputUsage)>::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;
Expand Down Expand Up @@ -279,7 +285,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(
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -1123,7 +1125,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> 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);
Expand Down Expand Up @@ -1182,9 +1184,11 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> 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;
}
Expand All @@ -1211,7 +1215,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> 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...");
Expand Down Expand Up @@ -1685,7 +1689,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) {
Expand All @@ -1710,7 +1714,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);
}
Expand Down