Skip to content

Commit cc2d2d0

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 6459655 commit cc2d2d0

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
@@ -243,8 +243,6 @@ class MfxC2DecoderComponent : public MfxC2Component
243243

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

246-
uint64_t m_consumerUsage;
247-
248246
uint32_t m_surfaceNum;
249247
std::list<std::shared_ptr<mfxFrameSurface1>> m_surfacePool; // used in case of system memory
250248

@@ -281,6 +279,7 @@ class MfxC2DecoderComponent : public MfxC2Component
281279
std::shared_ptr<C2StreamColorAspectsTuning::output> m_defaultColorAspects;
282280
std::shared_ptr<C2StreamColorAspectsInfo::input> m_codedColorAspects;
283281
std::shared_ptr<C2StreamColorAspectsInfo::output> m_colorAspects;
282+
std::shared_ptr<C2StreamUsageTuning::output> m_outputUsage;
284283
/* ----------------------------------------Setters------------------------------------------- */
285284
static C2R OutputSurfaceAllocatorSetter(bool mayBlock, C2P<C2PortSurfaceAllocatorTuning::output> &me);
286285
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
@@ -57,7 +57,6 @@ enum VP8_LEVEL {
5757
LEVEL_VP8_Version0 = C2_PROFILE_LEVEL_VENDOR_START,
5858
};
5959

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

224+
addParameter(
225+
DefineParam(m_outputUsage, C2_PARAMKEY_OUTPUT_STREAM_USAGE)
226+
.withDefault(new C2StreamUsageTuning::output(0u, C2AndroidMemoryUsage::HW_CODEC_WRITE))
227+
.withFields({C2F(m_outputUsage, value).any()})
228+
.withSetter(Setter<decltype(*m_outputUsage)>::StrictValueWithNoDeps)
229+
.build());
230+
225231
switch(m_decoderType) {
226232
case DECODER_H264: {
227233
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
280286
}
281287
case DECODER_H265: {
282288
m_uOutputDelay = /*max_dpb_size*/16 + /*for async depth*/1 + /*for msdk unref in sync part*/1;
283-
284289
m_uInputDelay = 15;
285290

286291
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
}
@@ -1124,7 +1126,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> c2_all
11241126

11251127
if (MFX_ERR_NONE == mfx_res) {
11261128
// set memory type according to consumer usage sent from framework
1127-
m_mfxVideoParams.IOPattern = (C2MemoryUsage::CPU_READ == m_consumerUsage) ?
1129+
m_mfxVideoParams.IOPattern = (C2MemoryUsage::CPU_READ == m_outputUsage->value) ?
11281130
MFX_IOPATTERN_OUT_SYSTEM_MEMORY : MFX_IOPATTERN_OUT_VIDEO_MEMORY;
11291131
MFX_DEBUG_TRACE_I32(m_mfxVideoParams.IOPattern);
11301132
MFX_DEBUG_TRACE_I32(m_mfxVideoParams.mfx.FrameInfo.Width);
@@ -1183,9 +1185,11 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> c2_all
11831185
uint64_t usage, igbp_id;
11841186
android::_UnwrapNativeCodec2GrallocMetadata(out_block->handle(), &width, &height, &format, &usage,
11851187
&stride, &generation, &igbp_id, &igbp_slot);
1186-
if ((!igbp_id && !igbp_slot) || (!igbp_id && igbp_slot == 0xffffffff))
1188+
MFX_DEBUG_TRACE_PRINTF("m_outputUsage is C2MemoryUsage::CPU_READ? %s", m_outputUsage->value == C2MemoryUsage::CPU_READ? "Y": "N");
1189+
if((!igbp_id && !igbp_slot) || (!igbp_id && igbp_slot == 0xffffffff) || m_outputUsage->value == C2MemoryUsage::CPU_READ)
11871190
{
11881191
// No surface & BQ
1192+
MFX_DEBUG_TRACE_PRINTF("No surface & BQ, Force to use System memory");
11891193
m_mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;
11901194
m_allocator = nullptr;
11911195
}
@@ -1212,7 +1216,7 @@ mfxStatus MfxC2DecoderComponent::InitDecoder(std::shared_ptr<C2BlockPool> c2_all
12121216
if (m_allocator) {
12131217
m_allocator->SetC2Allocator(c2_allocator);
12141218
m_allocator->SetBufferCount(m_uOutputDelay);
1215-
m_allocator->SetConsumerUsage(m_consumerUsage);
1219+
m_allocator->SetConsumerUsage(m_outputUsage->value);
12161220
}
12171221

12181222
MFX_DEBUG_TRACE_MSG("Decoder initializing...");
@@ -1748,7 +1752,7 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig
17481752

17491753
if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_VIDEO_MEMORY) {
17501754

1751-
C2MemoryUsage mem_usage = {m_consumerUsage, C2AndroidMemoryUsage::HW_CODEC_WRITE};
1755+
C2MemoryUsage mem_usage = {m_outputUsage->value, C2AndroidMemoryUsage::HW_CODEC_WRITE};
17521756
res = m_c2Allocator->fetchGraphicBlock(width, height,
17531757
MfxFourCCToGralloc(fourcc), mem_usage, out_block);
17541758
if (res == C2_OK) {
@@ -1773,7 +1777,7 @@ c2_status_t MfxC2DecoderComponent::AllocateC2Block(uint32_t width, uint32_t heig
17731777
}
17741778
} else if (m_mfxVideoParams.IOPattern == MFX_IOPATTERN_OUT_SYSTEM_MEMORY) {
17751779

1776-
C2MemoryUsage mem_usage = {m_consumerUsage, C2MemoryUsage::CPU_WRITE};
1780+
C2MemoryUsage mem_usage = {m_outputUsage->value, C2MemoryUsage::CPU_WRITE};
17771781
res = m_c2Allocator->fetchGraphicBlock(width, height,
17781782
MfxFourCCToGralloc(fourcc, false), mem_usage, out_block);
17791783
}

0 commit comments

Comments
 (0)