Skip to content

Commit

Permalink
[c2][encoder] AVC encoder low power mode configurable
Browse files Browse the repository at this point in the history
Make AVC encoder low power mode configurable in
media_codecs_intel_c2_video.xml.

Tracked-On: OAM-123091
Signed-off-by: Lina Sun <[email protected]>
  • Loading branch information
lsun30 committed Aug 6, 2024
1 parent 2b1598c commit ba2f890
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions c2_components/include/mfx_c2_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MfxC2Component : public C2ComponentInterface,
int flags{0};
bool dump_output{false};
uint32_t concurrent_instances{0};
bool low_power_mode{false};
};
protected:
/* State diagram:
Expand Down
4 changes: 4 additions & 0 deletions c2_components/src/mfx_c2_encoder_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,10 @@ mfxStatus MfxC2EncoderComponent::ResetSettings()
m_mfxVideoParamsConfig.NumExtParam = 0;
m_mfxVideoParamsConfig.ExtParam = nullptr;

// set low power mode for AVC encoder
if(m_mfxVideoParamsConfig.mfx.CodecId == MFX_CODEC_AVC && m_createConfig.low_power_mode)
m_mfxVideoParamsConfig.mfx.LowPower = MFX_CODINGOPTION_ON;

MFX_DEBUG_TRACE__mfxStatus(mfx_res);
return mfx_res;
}
Expand Down
1 change: 1 addition & 0 deletions c2_store/src/mfx_c2_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ c2_status_t MfxC2ComponentStore::readConfigFile()
config.flags = flags;
config.dump_output = m_xmlParser.dumpOutputEnabled(name.c_str());
config.concurrent_instances = m_xmlParser.getConcurrentInstances(name.c_str());
config.low_power_mode = m_xmlParser.getLowPowerMode(name.c_str());

m_componentsRegistry_.emplace(name, ComponentDesc(module.c_str(), media_type.c_str(), kind, config));
}
Expand Down
2 changes: 2 additions & 0 deletions c2_utils/include/mfx_c2_xml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class MfxXmlParser
C2String getMediaType(const char *name);
uint32_t getConcurrentInstances(const char *name);
bool dumpOutputEnabled(const char *name);
bool getLowPowerMode(const char *name);

private:

Expand All @@ -62,6 +63,7 @@ class MfxXmlParser
std::map<C2String, AttributeMap> typeMap; // map of types supported by this codec
bool dump_output{false};
uint32_t concurrentInstance{0};
bool lowPowerMode{false};
};

enum Section {
Expand Down
22 changes: 22 additions & 0 deletions c2_utils/src/mfx_c2_xml_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ bool MfxXmlParser::dumpOutputEnabled(const char *name) {
return codec->second.dump_output;
}

bool MfxXmlParser::getLowPowerMode(const char *name) {

MFX_DEBUG_TRACE_FUNC;

auto codec = m_codecMap.find(name);
if (codec == m_codecMap.end()) {
MFX_DEBUG_TRACE_STREAM("codec " << name << "wasn't found");
return false;
}
return codec->second.lowPowerMode;
}

c2_status_t MfxXmlParser::addMediaCodecFromAttributes(bool encoder, const char** attrs) {

MFX_DEBUG_TRACE_FUNC;
Expand Down Expand Up @@ -169,6 +181,7 @@ c2_status_t MfxXmlParser::addDiagnostics(const char **attrs) {
MFX_DEBUG_TRACE_FUNC;

bool dump_output{false};
bool lowPowerMode{false};

size_t i = 0;
while (attrs[i] != nullptr) {
Expand All @@ -179,6 +192,13 @@ c2_status_t MfxXmlParser::addDiagnostics(const char **attrs) {
}
dump_output = parseBoolean(attrs[i]);
MFX_DEBUG_TRACE_STREAM("dumpOutput value " << attrs[i] << " parsed to " << (int)dump_output);
} else if (strcmp(attrs[i], "lowPowerMode") == 0) {
if (attrs[++i] == nullptr) {
MFX_DEBUG_TRACE_STREAM("lowPowerMode is null");
return C2_BAD_VALUE;
}
lowPowerMode = parseBoolean(attrs[i]);
MFX_DEBUG_TRACE_STREAM("lowPowerMode value " << attrs[i] << " parsed to " << (int)lowPowerMode);
} else {
MFX_DEBUG_TRACE_STREAM("unrecognized attribute: " << attrs[i]);
return C2_BAD_VALUE;
Expand All @@ -187,6 +207,8 @@ c2_status_t MfxXmlParser::addDiagnostics(const char **attrs) {
}

m_currentCodec->second.dump_output = dump_output;
m_currentCodec->second.lowPowerMode = lowPowerMode;

return C2_OK;
}

Expand Down

0 comments on commit ba2f890

Please sign in to comment.