in src/cdi/baseline_profiles_1_00.c [190:249]
static bool CreateOptionalParamsString(const CdiAvmVideoConfig* video_config_ptr, char* optional_params_str,
const size_t array_size)
{
bool ret = true;
optional_params_str[0] = '\0';
size_t pos = 0;
const size_t max_pos = array_size;
// Optionally add "interlace" parameter.
if (max_pos > pos && video_config_ptr->interlace) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " interlace;");
}
// Optionally add "segmented" parameter.
if (max_pos > pos && video_config_ptr->segmented) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " segmented;");
}
// Optionally add "TCS" parameter.
if (max_pos > pos && kCdiAvmVidTcsSDR != video_config_ptr->tcs) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " TCS=%s;",
CdiAvmKeyEnumToString(kKeyAvmVideoTcsType, video_config_ptr->tcs,
&video_config_ptr->version));
}
// Optionally add "RANGE" parameter.
if (max_pos > pos && kCdiAvmVidRangeNarrow != video_config_ptr->range) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " RANGE=%s;",
CdiAvmKeyEnumToString(kKeyAvmVideoRangeType, video_config_ptr->range,
&video_config_ptr->version));
}
// Optionally add "PAR" parameter.
if (max_pos > pos && (1 != video_config_ptr->par_width || 1 != video_config_ptr->par_height)) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " PAR=%u:%u;", video_config_ptr->par_width,
video_config_ptr->par_height);
}
// Optionally add "alpha_included" parameter.
if (max_pos > pos && kCdiAvmAlphaUsed == video_config_ptr->alpha_channel) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " alpha_included=enabled;");
}
// Optionally add "partial_frame" parameter.
if (max_pos > pos && (0 != video_config_ptr->horizontal_size || 0 != video_config_ptr->vertical_size ||
0 != video_config_ptr->start_horizontal_pos || 0 != video_config_ptr->start_vertical_pos)) {
pos += snprintf(&optional_params_str[pos], max_pos - pos, " partial_frame=%ux%u+%u+%u;",
video_config_ptr->horizontal_size, video_config_ptr->vertical_size,
video_config_ptr->start_horizontal_pos, video_config_ptr->start_vertical_pos);
}
// Verify that the string is not longer than the buffer size.
if (max_pos <= pos) {
CDI_LOG_THREAD(kLogError, "optional parameters list is too long");
ret = false;
}
return ret;
}