Skip to content

Commit 18a9f1a

Browse files
committed
Add a param for setting output usage.
Add a parameter to AOSP for setting the buffer useage of output memory Once it is set as CPU_READ, force to use system memory, instead of video memory. Remove the valiable m_consumerUsage which is only set as default. Tracked-On: OAM-111768 Signed-off-by: Shaofeng Tang <shaofeng.tang@intel.com>
1 parent 38994a0 commit 18a9f1a

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

c2_components/include/mfx_c2_decoder_component.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ class MfxC2DecoderComponent : public MfxC2Component
240240

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

243-
uint64_t m_consumerUsage;
244-
245243
uint32_t m_surfaceNum;
246244
std::list<std::shared_ptr<mfxFrameSurface1>> m_surfacePool; // used in case of system memory
247245

@@ -278,6 +276,7 @@ class MfxC2DecoderComponent : public MfxC2Component
278276
std::shared_ptr<C2StreamColorAspectsTuning::output> m_defaultColorAspects;
279277
std::shared_ptr<C2StreamColorAspectsInfo::input> m_inColorAspects;
280278
std::shared_ptr<C2StreamColorAspectsInfo::output> m_outColorAspects;
279+
std::shared_ptr<C2StreamUsageTuning::output> m_outputUsage;
281280
/* ----------------------------------------Setters------------------------------------------- */
282281
static C2R OutputSurfaceAllocatorSetter(bool mayBlock, C2P<C2PortSurfaceAllocatorTuning::output> &me);
283282
static C2R SizeSetter(bool mayBlock, const C2P<C2StreamPictureSizeInfo::output> &oldMe,

c2_components/src/mfx_c2_decoder_component.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ enum VP8_LEVEL {
5858
LEVEL_VP8_Version0 = C2_PROFILE_LEVEL_VENDOR_START,
5959
};
6060

61-
6261
C2R MfxC2DecoderComponent::OutputSurfaceAllocatorSetter(bool mayBlock, C2P<C2PortSurfaceAllocatorTuning::output> &me) {
6362
(void)mayBlock;
6463
(void)me;
@@ -221,6 +220,13 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo
221220
.withConstValue(AllocSharedString<C2PortMediaTypeSetting::output>("video/raw"))
222221
.build());
223222

223+
addParameter(
224+
DefineParam(m_outputUsage, C2_PARAMKEY_OUTPUT_STREAM_USAGE)
225+
.withDefault(new C2StreamUsageTuning::output(0u, kDefaultConsumerUsage))
226+
.withFields({C2F(m_outputUsage, value).any()})
227+
.withSetter(Setter<decltype(*m_outputUsage)>::StrictValueWithNoDeps)
228+
.build());
229+
224230
switch(m_decoderType) {
225231
case DECODER_H264: {
226232
m_uOutputDelay = /*max_dpb_size*/16 + /*for async depth*/1 + /*for msdk unref in sync part*/1;
@@ -279,7 +285,6 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo
279285
}
280286
case DECODER_H265: {
281287
m_uOutputDelay = /*max_dpb_size*/16 + /*for async depth*/1 + /*for msdk unref in sync part*/1;
282-
283288
m_uInputDelay = 15;
284289

285290
addParameter(
@@ -640,9 +645,6 @@ MfxC2DecoderComponent::MfxC2DecoderComponent(const C2String name, const CreateCo
640645
m_hdrStaticInfo->maxCll = 0;
641646
m_hdrStaticInfo->maxFall = 0;
642647

643-
// By default prepare buffer to be displayed on any of the common surfaces
644-
m_consumerUsage = kDefaultConsumerUsage;
645-
646648
MFX_ZERO_MEMORY(m_signalInfo);
647649
//m_paramStorage.DumpParams();
648650
}
@@ -1123,7 +1125,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> c2_all
11231125

11241126
if (MFX_ERR_NONE == mfx_res) {
11251127
// set memory type according to consumer usage sent from framework
1126-
m_mfxVideoParams.IOPattern = (C2MemoryUsage::CPU_READ == m_consumerUsage) ?
1128+
m_mfxVideoParams.IOPattern = (C2MemoryUsage::CPU_READ == m_outputUsage->value) ?
11271129
MFX_IOPATTERN_OUT_SYSTEM_MEMORY : MFX_IOPATTERN_OUT_VIDEO_MEMORY;
11281130
MFX_DEBUG_TRACE_I32(m_mfxVideoParams.IOPattern);
11291131
MFX_DEBUG_TRACE_I32(m_mfxVideoParams.mfx.FrameInfo.Width);
@@ -1182,9 +1184,11 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> c2_all
11821184
uint64_t usage, igbp_id;
11831185
android::_UnwrapNativeCodec2GrallocMetadata(out_block->handle(), &width, &height, &format, &usage,
11841186
&stride, &generation, &igbp_id, &igbp_slot);
1185-
if ((!igbp_id && !igbp_slot) || (!igbp_id && igbp_slot == 0xffffffff))
1187+
MFX_DEBUG_TRACE_PRINTF("m_outputUsage is C2MemoryUsage::CPU_READ? %s", m_outputUsage->value == C2MemoryUsage::CPU_READ? "Y": "N");
1188+
if((!igbp_id && !igbp_slot) || (!igbp_id && igbp_slot == 0xffffffff) || m_outputUsage->value == C2MemoryUsage::CPU_READ)
11861189
{
11871190
// No surface & BQ
1191+
MFX_DEBUG_TRACE_PRINTF("No surface & BQ, Force to use System memory");
11881192
m_mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
11891193
m_allocator = nullptr;
11901194
}
@@ -1211,7 +1215,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> c2_all
12111215
if (m_allocator) {
12121216
m_allocator->SetC2Allocator(c2_allocator);
12131217
m_allocator->SetBufferCount(m_uOutputDelay);
1214-
m_allocator->SetConsumerUsage(m_consumerUsage);
1218+
m_allocator->SetConsumerUsage(m_outputUsage->value);
12151219
}
12161220

12171221
MFX_DEBUG_TRACE_MSG("Decoder initializing...");
@@ -1685,7 +1689,7 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig
16851689

16861690
if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_VIDEO_MEMORY) {
16871691

1688-
C2MemoryUsage mem_usage = {m_consumerUsage, C2AndroidMemoryUsage::HW_CODEC_WRITE};
1692+
C2MemoryUsage mem_usage = {m_outputUsage->value, C2AndroidMemoryUsage::HW_CODEC_WRITE};
16891693
res = m_c2Allocator->fetchGraphicBlock(width, height,
16901694
MfxFourCCToGralloc(fourcc), mem_usage, out_block);
16911695
if (res == C2_OK) {
@@ -1710,7 +1714,7 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig
17101714
}
17111715
} else if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_SYSTEM_MEMORY) {
17121716

1713-
C2MemoryUsage mem_usage = {m_consumerUsage, C2MemoryUsage::CPU_WRITE};
1717+
C2MemoryUsage mem_usage = {m_outputUsage->value, C2MemoryUsage::CPU_WRITE};
17141718
res = m_c2Allocator->fetchGraphicBlock(width, height,
17151719
MfxFourCCToGralloc(fourcc, false), mem_usage, out_block);
17161720
}

0 commit comments

Comments
 (0)