in src/cdi/baseline_profiles_2_00.c [191:287]
static bool MakeBaselineVideoConfiguration(const CdiAvmBaselineConfigCommon* baseline_ptr, CdiAvmConfig* config_ptr,
int* payload_unit_size_ptr)
{
bool ret = false;
const CdiAvmBaselineConfig* baseline_config_ptr = (CdiAvmBaselineConfig*)baseline_ptr;
const CdiAvmVideoConfig* video_config_ptr = &baseline_config_ptr->video_config;
char optional_params_str[512];
optional_params_str[0] = '\0';
size_t pos = 0;
const size_t max_pos = sizeof(optional_params_str);
// 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);
}
if (max_pos <= pos) {
CDI_LOG_THREAD(kLogError, "optional parameters list is too long");
} else {
char rate_str[20];
if (1 == video_config_ptr->frame_rate_den) {
snprintf(rate_str, sizeof(rate_str), "%u", video_config_ptr->frame_rate_num);
} else {
snprintf(rate_str, sizeof(rate_str), "%u/%u", video_config_ptr->frame_rate_num,
video_config_ptr->frame_rate_den);
}
int bit_depth = 8;
switch (video_config_ptr->depth) {
case kCdiAvmVidBitDepth8:
bit_depth = 8;
break;
case kCdiAvmVidBitDepth10:
bit_depth = 10;
break;
case kCdiAvmVidBitDepth12:
bit_depth = 12;
break;
}
pos = snprintf((char*)config_ptr->data, sizeof(config_ptr->data), "cdi_profile_version=%s; sampling=%s; "
"depth=%u; width=%u; height=%u; exactframerate=%s; colorimetry=%s;%s",
profile_version_video_str,
CdiAvmKeyEnumToString(kKeyAvmVideoSamplingType, video_config_ptr->sampling,
&video_config_ptr->version),
bit_depth, video_config_ptr->width, video_config_ptr->height, rate_str,
CdiAvmKeyEnumToString(kKeyAvmVideoColorimetryType, video_config_ptr->colorimetry,
&video_config_ptr->version),
optional_params_str);
if ((int)sizeof(config_ptr->data) <= pos) {
CDI_LOG_THREAD(kLogError, "video configuration string is too long");
} else {
// Conversion successful.
config_ptr->data_size = pos;
ret = GetVideoUnitSize(baseline_config_ptr, payload_unit_size_ptr);
}
}
return ret;
}