cta: parse short audio descriptors

Co-authored-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This commit is contained in:
Sebastian Wick 2022-09-06 19:21:50 +02:00 committed by Simon Ser
parent c995305a69
commit 8fbc366c7c
9 changed files with 814 additions and 36 deletions

412
cta.c
View file

@ -18,6 +18,10 @@
* Exclusive upper bound for the detailed timing definitions in the CTA block.
*/
#define CTA_DTD_END 127
/**
* Number of bytes in a CTA short audio descriptor.
*/
#define CTA_SAD_SIZE 3
static void
add_failure(struct di_edid_cta *cta, const char fmt[], ...)
@ -85,6 +89,397 @@ parse_video_block(struct di_edid_cta *cta, struct di_cta_video_block *video,
return true;
}
static bool
parse_sad_format(struct di_edid_cta *cta, const uint8_t data[static CTA_SAD_SIZE],
enum di_cta_audio_format *format)
{
uint8_t code, code_ext;
code = get_bit_range(data[0], 6, 3);
switch (code) {
case 0x0:
add_failure_until(cta, 3,
"Audio Data Block: Audio Format Code 0x00 is reserved.");
return false;
case 0x1:
*format = DI_CTA_AUDIO_FORMAT_LPCM;
break;
case 0x2:
*format = DI_CTA_AUDIO_FORMAT_AC3;
break;
case 0x3:
*format = DI_CTA_AUDIO_FORMAT_MPEG1;
break;
case 0x4:
*format = DI_CTA_AUDIO_FORMAT_MP3;
break;
case 0x5:
*format = DI_CTA_AUDIO_FORMAT_MPEG2;
break;
case 0x6:
*format = DI_CTA_AUDIO_FORMAT_AAC_LC;
break;
case 0x7:
*format = DI_CTA_AUDIO_FORMAT_DTS;
break;
case 0x8:
*format = DI_CTA_AUDIO_FORMAT_ATRAC;
break;
case 0x9:
*format = DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO;
break;
case 0xA:
*format = DI_CTA_AUDIO_FORMAT_ENHANCED_AC3;
break;
case 0xB:
*format = DI_CTA_AUDIO_FORMAT_DTS_HD;
break;
case 0xC:
*format = DI_CTA_AUDIO_FORMAT_MAT;
break;
case 0xD:
*format = DI_CTA_AUDIO_FORMAT_DST;
break;
case 0xE:
*format = DI_CTA_AUDIO_FORMAT_WMA_PRO;
break;
case 0xF:
code_ext = get_bit_range(data[2], 7, 3);
switch (code_ext) {
case 0x04:
*format = DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC;
break;
case 0x05:
*format = DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2;
break;
case 0x06:
*format = DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC;
break;
case 0x07:
*format = DI_CTA_AUDIO_FORMAT_DRA;
break;
case 0x08:
*format = DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND;
break;
case 0x0A:
*format = DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND;
break;
case 0x0B:
*format = DI_CTA_AUDIO_FORMAT_MPEGH_3D;
break;
case 0x0C:
*format = DI_CTA_AUDIO_FORMAT_AC4;
break;
case 0x0D:
*format = DI_CTA_AUDIO_FORMAT_LPCM_3D;
break;
default:
add_failure_until(cta, 3,
"Audio Data Block: Unknown Audio Ext Format 0x%02x.",
code_ext);
return false;
}
break;
default:
add_failure_until(cta, 3,
"Audio Data Block: Unknown Audio Format 0x%02x.",
code);
return false;
}
return true;
}
static bool
parse_sad(struct di_edid_cta *cta, struct di_cta_audio_block *audio,
const uint8_t data[static CTA_SAD_SIZE])
{
enum di_cta_audio_format format;
struct di_cta_sad_priv *priv;
struct di_cta_sad *sad;
struct di_cta_sad_sample_rates *sample_rates;
struct di_cta_sad_lpcm *lpcm;
struct di_cta_sad_mpegh_3d *mpegh_3d;
struct di_cta_sad_mpeg_aac *mpeg_aac;
struct di_cta_sad_mpeg_surround *mpeg_surround;
struct di_cta_sad_mpeg_aac_le *mpeg_aac_le;
struct di_cta_sad_enhanced_ac3 *enhanced_ac3;
struct di_cta_sad_mat *mat;
struct di_cta_sad_wma_pro *wma_pro;
if (!parse_sad_format(cta, data, &format))
return true;
priv = calloc(1, sizeof(*priv));
if (!priv)
return false;
sad = &priv->base;
sample_rates = &priv->supported_sample_rates;
lpcm = &priv->lpcm;
mpegh_3d = &priv->mpegh_3d;
mpeg_aac = &priv->mpeg_aac;
mpeg_surround = &priv->mpeg_surround;
mpeg_aac_le = &priv->mpeg_aac_le;
enhanced_ac3 = &priv->enhanced_ac3;
mat = &priv->mat;
wma_pro = &priv->wma_pro;
sad->format = format;
/* TODO: Find DRA documentation */
switch (format) {
case DI_CTA_AUDIO_FORMAT_LPCM:
case DI_CTA_AUDIO_FORMAT_AC3:
case DI_CTA_AUDIO_FORMAT_MPEG1:
case DI_CTA_AUDIO_FORMAT_MP3:
case DI_CTA_AUDIO_FORMAT_MPEG2:
case DI_CTA_AUDIO_FORMAT_AAC_LC:
case DI_CTA_AUDIO_FORMAT_DTS:
case DI_CTA_AUDIO_FORMAT_ATRAC:
case DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO:
case DI_CTA_AUDIO_FORMAT_ENHANCED_AC3:
case DI_CTA_AUDIO_FORMAT_DTS_HD:
case DI_CTA_AUDIO_FORMAT_MAT:
case DI_CTA_AUDIO_FORMAT_DST:
case DI_CTA_AUDIO_FORMAT_WMA_PRO:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC:
/* DRA is not documented but this is what edid-decode does */
case DI_CTA_AUDIO_FORMAT_DRA:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND:
sad->max_channels = get_bit_range(data[0], 2, 0) + 1;
break;
case DI_CTA_AUDIO_FORMAT_LPCM_3D:
sad->max_channels = (get_bit_range(data[0], 2, 0) |
(get_bit_range(data[0], 7, 7) << 3) |
(get_bit_range(data[1], 7, 7) << 4)) + 1;
break;
case DI_CTA_AUDIO_FORMAT_MPEGH_3D:
case DI_CTA_AUDIO_FORMAT_AC4:
break;
}
switch (format) {
case DI_CTA_AUDIO_FORMAT_LPCM:
case DI_CTA_AUDIO_FORMAT_AC3:
case DI_CTA_AUDIO_FORMAT_MPEG1:
case DI_CTA_AUDIO_FORMAT_MP3:
case DI_CTA_AUDIO_FORMAT_MPEG2:
case DI_CTA_AUDIO_FORMAT_AAC_LC:
case DI_CTA_AUDIO_FORMAT_DTS:
case DI_CTA_AUDIO_FORMAT_ATRAC:
case DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO:
case DI_CTA_AUDIO_FORMAT_ENHANCED_AC3:
case DI_CTA_AUDIO_FORMAT_DTS_HD:
case DI_CTA_AUDIO_FORMAT_MAT:
case DI_CTA_AUDIO_FORMAT_DST:
case DI_CTA_AUDIO_FORMAT_WMA_PRO:
/* DRA is not documented but this is what edid-decode does */
case DI_CTA_AUDIO_FORMAT_DRA:
case DI_CTA_AUDIO_FORMAT_MPEGH_3D:
case DI_CTA_AUDIO_FORMAT_LPCM_3D:
sample_rates->has_192_khz = has_bit(data[1], 6);
sample_rates->has_176_4_khz = has_bit(data[1], 5);
/* fallthrough */
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND:
sample_rates->has_96_khz = has_bit(data[1], 4);
sample_rates->has_88_2_khz = has_bit(data[1], 3);
sample_rates->has_48_khz = has_bit(data[1], 2);
sample_rates->has_44_1_khz = has_bit(data[1], 1);
sample_rates->has_32_khz = has_bit(data[1], 0);
break;
case DI_CTA_AUDIO_FORMAT_AC4:
sample_rates->has_192_khz = has_bit(data[1], 6);
sample_rates->has_96_khz = has_bit(data[1], 4);
sample_rates->has_48_khz = has_bit(data[1], 2);
sample_rates->has_44_1_khz = has_bit(data[1], 1);
break;
}
sad->supported_sample_rates = sample_rates;
switch (format) {
case DI_CTA_AUDIO_FORMAT_AC3:
case DI_CTA_AUDIO_FORMAT_MPEG1:
case DI_CTA_AUDIO_FORMAT_MP3:
case DI_CTA_AUDIO_FORMAT_MPEG2:
case DI_CTA_AUDIO_FORMAT_AAC_LC:
case DI_CTA_AUDIO_FORMAT_DTS:
case DI_CTA_AUDIO_FORMAT_ATRAC:
sad->max_bitrate_kbs = data[2] * 8;
break;
default:
break;
}
switch (format) {
case DI_CTA_AUDIO_FORMAT_LPCM:
case DI_CTA_AUDIO_FORMAT_LPCM_3D:
lpcm->has_sample_size_24_bits = has_bit(data[2], 2);
lpcm->has_sample_size_20_bits = has_bit(data[2], 1);
lpcm->has_sample_size_16_bits = has_bit(data[2], 0);
sad->lpcm = lpcm;
default:
break;
}
switch (format) {
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND:
mpeg_aac->has_frame_length_1024 = has_bit(data[2], 2);
mpeg_aac->has_frame_length_960 = has_bit(data[2], 1);
sad->mpeg_aac = mpeg_aac;
break;
default:
break;
}
if (format == DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC) {
mpeg_aac_le->supports_multichannel_sound = has_bit(data[2], 0);
sad->mpeg_aac_le = mpeg_aac_le;
}
switch (format) {
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND:
mpeg_surround->signaling = has_bit(data[2], 0);
sad->mpeg_surround = mpeg_surround;
break;
default:
break;
}
if (format == DI_CTA_AUDIO_FORMAT_MPEGH_3D) {
mpegh_3d->low_complexity_profile = has_bit(data[2], 0);
mpegh_3d->baseline_profile = has_bit(data[2], 1);
mpegh_3d->level = get_bit_range(data[0], 2, 0);
if (mpegh_3d->level > DI_CTA_SAD_MPEGH_3D_LEVEL_5) {
add_failure_until(cta, 3,
"Unknown MPEG-H 3D Audio Level 0x%02x.",
mpegh_3d->level);
mpegh_3d->level = DI_CTA_SAD_MPEGH_3D_LEVEL_UNSPECIFIED;
}
sad->mpegh_3d = mpegh_3d;
}
if (format == DI_CTA_AUDIO_FORMAT_ENHANCED_AC3) {
enhanced_ac3->supports_joint_object_coding =
has_bit(data[2], 0);
enhanced_ac3->supports_joint_object_coding_ACMOD28 =
has_bit(data[2], 1);
sad->enhanced_ac3 = enhanced_ac3;
}
if (format == DI_CTA_AUDIO_FORMAT_MAT) {
mat->supports_object_audio_and_channel_based =
has_bit(data[2], 0);
if (mat->supports_object_audio_and_channel_based)
mat->requires_hash_calculation = !has_bit(data[2], 0);
sad->mat = mat;
}
if (format == DI_CTA_AUDIO_FORMAT_WMA_PRO) {
wma_pro->profile = get_bit_range(data[2], 2, 0);
sad->wma_pro = wma_pro;
}
switch (format) {
case DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO:
case DI_CTA_AUDIO_FORMAT_DTS_HD:
case DI_CTA_AUDIO_FORMAT_DST:
/* TODO data[2] 7:0 contains unknown Audio Format Code dependent value */
break;
default:
break;
}
if (format == DI_CTA_AUDIO_FORMAT_AC4) {
/* TODO data[2] 2:0 contains unknown Audio Format Code dependent value */
}
switch (format) {
case DI_CTA_AUDIO_FORMAT_LPCM:
case DI_CTA_AUDIO_FORMAT_WMA_PRO:
if (has_bit(data[0], 7) || has_bit(data[1], 7) ||
get_bit_range(data[2], 7, 3) != 0)
add_failure_until(cta, 3,
"Bits F17, F27, F37:F33 must be 0.");
break;
case DI_CTA_AUDIO_FORMAT_AC3:
case DI_CTA_AUDIO_FORMAT_MPEG1:
case DI_CTA_AUDIO_FORMAT_MP3:
case DI_CTA_AUDIO_FORMAT_MPEG2:
case DI_CTA_AUDIO_FORMAT_AAC_LC:
case DI_CTA_AUDIO_FORMAT_DTS:
case DI_CTA_AUDIO_FORMAT_ATRAC:
case DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO:
case DI_CTA_AUDIO_FORMAT_ENHANCED_AC3:
case DI_CTA_AUDIO_FORMAT_DTS_HD:
case DI_CTA_AUDIO_FORMAT_MAT:
case DI_CTA_AUDIO_FORMAT_DST:
if (has_bit(data[0], 7) || has_bit(data[1], 7))
add_failure_until(cta, 3,
"Bits F17, F27 must be 0.");
break;
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC:
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND:
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND:
if (has_bit(data[0], 7) || get_bit_range(data[2], 7, 5) != 0)
add_failure_until(cta, 3,
"Bits F17, F27:F25 must be 0.");
break;
case DI_CTA_AUDIO_FORMAT_MPEGH_3D:
if (has_bit(data[0], 7) || has_bit(data[1], 7) ||
has_bit(data[2], 2))
add_failure_until(cta, 3,
"Bits F17, F27, F32 must be 0.");
break;
case DI_CTA_AUDIO_FORMAT_AC4:
if ((data[0] & 0x87) != 0 || (data[1] & 0xA9) != 0)
add_failure_until(cta, 3,
"Bits F17, F12:F10, F27, F25, F23, "
"F20 must be 0.");
break;
/* DRA documentation missing */
case DI_CTA_AUDIO_FORMAT_DRA:
case DI_CTA_AUDIO_FORMAT_LPCM_3D:
break;
}
assert(audio->sads_len < EDID_CTA_MAX_AUDIO_BLOCK_ENTRIES);
audio->sads[audio->sads_len++] = priv;
return true;
}
static bool
parse_audio_block(struct di_edid_cta *cta, struct di_cta_audio_block *audio,
const uint8_t *data, size_t size)
{
size_t i;
if (size % 3 != 0)
add_failure(cta, "Broken CTA-861 audio block length %d.", size);
for (i = 0; i + 3 <= size; i += 3) {
if (!parse_sad(cta, audio, &data[i]))
return false;
}
return true;
}
static bool
parse_video_cap_block(struct di_edid_cta *cta,
struct di_cta_video_cap_block *video_cap,
@ -242,6 +637,7 @@ destroy_data_block(struct di_cta_data_block *data_block)
{
size_t i;
struct di_cta_video_block *video;
struct di_cta_audio_block *audio;
switch (data_block->tag) {
case DI_CTA_DATA_BLOCK_VIDEO:
@ -249,6 +645,11 @@ destroy_data_block(struct di_cta_data_block *data_block)
for (i = 0; i < video->svds_len; i++)
free(video->svds[i]);
break;
case DI_CTA_DATA_BLOCK_AUDIO:
audio = &data_block->audio;
for (i = 0; i < audio->sads_len; i++)
free(audio->sads[i]);
break;
default:
break; /* Nothing to do */
}
@ -271,6 +672,8 @@ parse_data_block(struct di_edid_cta *cta, uint8_t raw_tag, const uint8_t *data,
switch (raw_tag) {
case 1:
tag = DI_CTA_DATA_BLOCK_AUDIO;
if (!parse_audio_block(cta, &data_block->audio, data, size))
goto error;
break;
case 2:
tag = DI_CTA_DATA_BLOCK_VIDEO;
@ -531,6 +934,15 @@ di_cta_data_block_get_svds(const struct di_cta_data_block *block)
return (const struct di_cta_svd *const *) block->video.svds;
}
const struct di_cta_sad *const *
di_cta_data_block_get_sads(const struct di_cta_data_block *block)
{
if (block->tag != DI_CTA_DATA_BLOCK_AUDIO) {
return NULL;
}
return (const struct di_cta_sad *const *) block->audio.sads;
}
const struct di_cta_colorimetry_block *
di_cta_data_block_get_colorimetry(const struct di_cta_data_block *block)
{

View file

@ -102,6 +102,169 @@ print_cta_vesa_transfer_characteristics(const struct di_cta_vesa_transfer_charac
uncommon_features.cta_transfer_characteristics = true;
}
static const char *
cta_audio_format_name(enum di_cta_audio_format format)
{
switch (format) {
case DI_CTA_AUDIO_FORMAT_LPCM:
return "Linear PCM";
case DI_CTA_AUDIO_FORMAT_AC3:
return "AC-3";
case DI_CTA_AUDIO_FORMAT_MPEG1:
return "MPEG 1 (Layers 1 & 2)";
case DI_CTA_AUDIO_FORMAT_MP3:
return "MPEG 1 Layer 3 (MP3)";
case DI_CTA_AUDIO_FORMAT_MPEG2:
return "MPEG2 (multichannel)";
case DI_CTA_AUDIO_FORMAT_AAC_LC:
return "AAC LC";
case DI_CTA_AUDIO_FORMAT_DTS:
return "DTS";
case DI_CTA_AUDIO_FORMAT_ATRAC:
return "ATRAC";
case DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO:
return "One Bit Audio";
case DI_CTA_AUDIO_FORMAT_ENHANCED_AC3:
return "Enhanced AC-3 (DD+)";
case DI_CTA_AUDIO_FORMAT_DTS_HD:
return "DTS-HD";
case DI_CTA_AUDIO_FORMAT_MAT:
return "MAT (MLP)";
case DI_CTA_AUDIO_FORMAT_DST:
return "DST";
case DI_CTA_AUDIO_FORMAT_WMA_PRO:
return "WMA Pro";
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC:
return "MPEG-4 HE AAC";
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2:
return "MPEG-4 HE AAC v2";
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC:
return "MPEG-4 AAC LC";
case DI_CTA_AUDIO_FORMAT_DRA:
return "DRA";
case DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND:
return "MPEG-4 HE AAC + MPEG Surround";
case DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND:
return "MPEG-4 AAC LC + MPEG Surround";
case DI_CTA_AUDIO_FORMAT_MPEGH_3D:
return "MPEG-H 3D Audio";
case DI_CTA_AUDIO_FORMAT_AC4:
return "AC-4";
case DI_CTA_AUDIO_FORMAT_LPCM_3D:
return "L-PCM 3D Audio";
}
abort();
}
static const char *
cta_sad_mpegh_3d_level_name(enum di_cta_sad_mpegh_3d_level level)
{
switch (level) {
case DI_CTA_SAD_MPEGH_3D_LEVEL_UNSPECIFIED:
return "Unspecified";
case DI_CTA_SAD_MPEGH_3D_LEVEL_1:
return "Level 1";
case DI_CTA_SAD_MPEGH_3D_LEVEL_2:
return "Level 2";
case DI_CTA_SAD_MPEGH_3D_LEVEL_3:
return "Level 3";
case DI_CTA_SAD_MPEGH_3D_LEVEL_4:
return "Level 4";
case DI_CTA_SAD_MPEGH_3D_LEVEL_5:
return "Level 5";
}
abort();
}
static void
print_cta_sads(const struct di_cta_sad *const *sads)
{
size_t i;
const struct di_cta_sad *sad;
for (i = 0; sads[i] != NULL; i++) {
sad = sads[i];
printf(" %s:\n", cta_audio_format_name(sad->format));
if (sad->max_channels != 0)
printf(" Max channels: %d\n", sad->max_channels);
if (sad->mpegh_3d)
printf(" MPEG-H 3D Audio Level: %s\n",
cta_sad_mpegh_3d_level_name(sad->mpegh_3d->level));
printf(" Supported sample rates (kHz):");
if (sad->supported_sample_rates->has_192_khz)
printf(" 192");
if (sad->supported_sample_rates->has_176_4_khz)
printf(" 176.4");
if (sad->supported_sample_rates->has_96_khz)
printf(" 96");
if (sad->supported_sample_rates->has_88_2_khz)
printf(" 88.2");
if (sad->supported_sample_rates->has_48_khz)
printf(" 48");
if (sad->supported_sample_rates->has_44_1_khz)
printf(" 44.1");
if (sad->supported_sample_rates->has_32_khz)
printf(" 32");
printf("\n");
if (sad->lpcm) {
printf(" Supported sample sizes (bits):");
if (sad->lpcm->has_sample_size_24_bits)
printf(" 24");
if (sad->lpcm->has_sample_size_20_bits)
printf(" 20");
if (sad->lpcm->has_sample_size_16_bits)
printf(" 16");
printf("\n");
}
if (sad->max_bitrate_kbs != 0)
printf(" Maximum bit rate: %d kb/s\n", sad->max_bitrate_kbs);
if (sad->enhanced_ac3 && sad->enhanced_ac3->supports_joint_object_coding)
printf(" Supports Joint Object Coding\n");
if (sad->enhanced_ac3 && sad->enhanced_ac3->supports_joint_object_coding_ACMOD28)
printf(" Supports Joint Object Coding with ACMOD28\n");
if (sad->mat) {
if (sad->mat->supports_object_audio_and_channel_based) {
printf(" Supports Dolby TrueHD, object audio PCM and channel-based PCM\n");
printf(" Hash calculation %srequired for object audio PCM or channel-based PCM\n",
sad->mat->requires_hash_calculation ? "" : "not ");
} else {
printf(" Supports only Dolby TrueHD\n");
}
}
if (sad->wma_pro) {
printf(" Profile: %u\n",sad->wma_pro->profile);
}
if (sad->mpegh_3d && sad->mpegh_3d->low_complexity_profile)
printf(" Supports MPEG-H 3D Audio Low Complexity Profile\n");
if (sad->mpegh_3d && sad->mpegh_3d->baseline_profile)
printf(" Supports MPEG-H 3D Audio Baseline Profile\n");
if (sad->mpeg_aac) {
printf(" AAC audio frame lengths:%s%s\n",
sad->mpeg_aac->has_frame_length_1024 ? " 1024_TL" : "",
sad->mpeg_aac->has_frame_length_960 ? " 960_TL" : "");
}
if (sad->mpeg_surround) {
printf(" Supports %s signaled MPEG Surround data\n",
sad->mpeg_surround->signaling == DI_CTA_SAD_MPEG_SURROUND_SIGNALING_IMPLICIT ?
"only implicitly" : "implicitly and explicitly");
}
if (sad->mpeg_aac_le && sad->mpeg_aac_le->supports_multichannel_sound)
printf(" Supports 22.2ch System H\n");
}
}
static const char *
cta_data_block_tag_name(enum di_cta_data_block_tag tag)
{
@ -181,6 +344,7 @@ print_cta(const struct di_edid_cta *cta)
const struct di_cta_colorimetry_block *colorimetry;
const struct di_cta_hdr_static_metadata_block *hdr_static_metadata;
const struct di_cta_vesa_transfer_characteristics *transfer_characteristics;
const struct di_cta_sad *const *sads;
size_t i;
const struct di_edid_detailed_timing_def *const *detailed_timing_defs;
@ -262,6 +426,10 @@ print_cta(const struct di_edid_cta *cta)
transfer_characteristics = di_cta_data_block_get_vesa_transfer_characteristics(data_block);
print_cta_vesa_transfer_characteristics(transfer_characteristics);
break;
case DI_CTA_DATA_BLOCK_AUDIO:
sads = di_cta_data_block_get_sads(data_block);
print_cta_sads(sads);
break;
default:
break; /* Ignore */
}

View file

@ -33,6 +33,13 @@
* is 63 bytes, and each SVD uses 1 byte.
*/
#define EDID_CTA_MAX_VIDEO_BLOCK_ENTRIES 63
/**
* The maximum number of SAD entries in an audio data block.
*
* Each data block has its size described in a 5-bit field, so its maximum size
* is 63 bytes, and each SAD uses 3 bytes.
*/
#define EDID_CTA_MAX_AUDIO_BLOCK_ENTRIES 21
struct di_edid_cta {
int revision;
@ -61,11 +68,32 @@ struct di_cta_video_block {
size_t svds_len;
};
struct di_cta_sad_priv {
struct di_cta_sad base;
struct di_cta_sad_sample_rates supported_sample_rates;
struct di_cta_sad_lpcm lpcm;
struct di_cta_sad_mpegh_3d mpegh_3d;
struct di_cta_sad_mpeg_aac mpeg_aac;
struct di_cta_sad_mpeg_surround mpeg_surround;
struct di_cta_sad_mpeg_aac_le mpeg_aac_le;
struct di_cta_sad_enhanced_ac3 enhanced_ac3;
struct di_cta_sad_mat mat;
struct di_cta_sad_wma_pro wma_pro;
};
struct di_cta_audio_block {
/* NULL-terminated */
struct di_cta_sad_priv *sads[EDID_CTA_MAX_AUDIO_BLOCK_ENTRIES + 1];
size_t sads_len;
};
struct di_cta_data_block {
enum di_cta_data_block_tag tag;
/* Used for DI_CTA_DATA_BLOCK_VIDEO */
struct di_cta_video_block video;
/* used for DI_CTA_DATA_BLOCK_AUDIO */
struct di_cta_audio_block audio;
/* Used for DI_CTA_DATA_BLOCK_VIDEO_CAP */
struct di_cta_video_cap_block video_cap;
/* Used for DI_CTA_DATA_BLOCK_COLORIMETRY */

View file

@ -118,6 +118,186 @@ enum di_cta_data_block_tag {
enum di_cta_data_block_tag
di_cta_data_block_get_tag(const struct di_cta_data_block *block);
/**
* Audio formats, defined in tables 37 and 39.
*
* Note, the enum values don't match the specification.
*/
enum di_cta_audio_format {
/* L-PCM */
DI_CTA_AUDIO_FORMAT_LPCM = 1,
/* AC-3 */
DI_CTA_AUDIO_FORMAT_AC3,
/* MPEG-1 (layers 1 & 2) */
DI_CTA_AUDIO_FORMAT_MPEG1,
/* MP3 */
DI_CTA_AUDIO_FORMAT_MP3,
/* MPEG-2 */
DI_CTA_AUDIO_FORMAT_MPEG2,
/* AAC LC */
DI_CTA_AUDIO_FORMAT_AAC_LC,
/* DTS */
DI_CTA_AUDIO_FORMAT_DTS,
/* ATRAC */
DI_CTA_AUDIO_FORMAT_ATRAC,
/* One Bit Audio */
DI_CTA_AUDIO_FORMAT_ONE_BIT_AUDIO,
/* Enhanced AC-3 */
DI_CTA_AUDIO_FORMAT_ENHANCED_AC3,
/* DTS-HD and DTS-UHD */
DI_CTA_AUDIO_FORMAT_DTS_HD,
/* MAT */
DI_CTA_AUDIO_FORMAT_MAT,
/* DST */
DI_CTA_AUDIO_FORMAT_DST,
/* WMA Pro */
DI_CTA_AUDIO_FORMAT_WMA_PRO,
/* MPEG-4 HE AAC */
DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC,
/* MPEG-4 HE AAC v2 */
DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2,
/* MPEG-4 AAC LC */
DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC,
/* DRA */
DI_CTA_AUDIO_FORMAT_DRA,
/* MPEG-4 HE AAC + MPEG Surround */
DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND,
/* MPEG-4 AAC LC + MPEG Surround */
DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND,
/* MPEG-H 3D Audio */
DI_CTA_AUDIO_FORMAT_MPEGH_3D,
/* AC-4 */
DI_CTA_AUDIO_FORMAT_AC4,
/* L-PCM 3D Audio */
DI_CTA_AUDIO_FORMAT_LPCM_3D,
};
struct di_cta_sad_sample_rates {
bool has_192_khz; /* 192 kHz */
bool has_176_4_khz; /* 176.4 kHz */
bool has_96_khz; /* 96 kHz */
bool has_88_2_khz; /* 88.2 kHz */
bool has_48_khz; /* 48 kHz */
bool has_44_1_khz; /* 44.1 kHz */
bool has_32_khz; /* 32 kHz */
};
enum di_cta_sad_mpegh_3d_level {
DI_CTA_SAD_MPEGH_3D_LEVEL_UNSPECIFIED = 0,
DI_CTA_SAD_MPEGH_3D_LEVEL_1 = 1,
DI_CTA_SAD_MPEGH_3D_LEVEL_2 = 2,
DI_CTA_SAD_MPEGH_3D_LEVEL_3 = 3,
DI_CTA_SAD_MPEGH_3D_LEVEL_4 = 4,
DI_CTA_SAD_MPEGH_3D_LEVEL_5 = 5,
};
struct di_cta_sad_mpegh_3d {
/* Maximum supported MPEG-H 3D level, zero if unspecified */
enum di_cta_sad_mpegh_3d_level level;
/* True if MPEG-H 3D Audio Low Complexity Profile is supported */
bool low_complexity_profile;
/* True if MPEG-H 3D Audio Baseline Profile is supported */
bool baseline_profile;
};
struct di_cta_sad_mpeg_aac {
/* True if AAC audio frame lengths of 960 samples is supported */
bool has_frame_length_960;
/* True if AAC audio frame lengths of 1024 samples is supported */
bool has_frame_length_1024;
};
enum di_cta_sad_mpeg_surround_signaling {
/* Only implicitly signaled MPEG Surround data supported */
DI_CTA_SAD_MPEG_SURROUND_SIGNALING_IMPLICIT = 0,
/* Implicitly and explicitly signaled MPEG Surround data supported */
DI_CTA_SAD_MPEG_SURROUND_SIGNALING_IMPLICIT_AND_EXPLICIT = 1,
};
struct di_cta_sad_mpeg_surround {
/* MPEG Surround signaling */
enum di_cta_sad_mpeg_surround_signaling signaling;
};
struct di_cta_sad_mpeg_aac_le {
/* True if Rec. ITU-R BS.2051 System H 22.2 multichannel sound is supported */
bool supports_multichannel_sound;
};
struct di_cta_sad_lpcm {
bool has_sample_size_24_bits; /* 24 bits */
bool has_sample_size_20_bits; /* 20 bits */
bool has_sample_size_16_bits; /* 16 bits */
};
struct di_cta_sad_enhanced_ac3 {
bool supports_joint_object_coding;
bool supports_joint_object_coding_ACMOD28;
};
struct di_cta_sad_mat {
bool supports_object_audio_and_channel_based;
bool requires_hash_calculation;
};
struct di_cta_sad_wma_pro {
int profile;
};
/**
* A CTA short audio descriptor (SAD), defined in section 7.5.2.
*/
struct di_cta_sad {
/* Format */
enum di_cta_audio_format format;
/* Maximum number of channels, zero if unset */
int32_t max_channels;
/* Supported sample rates */
const struct di_cta_sad_sample_rates *supported_sample_rates;
/* Maximum bitrate (kb/s), zero if unset */
int32_t max_bitrate_kbs;
/* Additional metadata for LPCM, NULL unless format is
* DI_CTA_AUDIO_FORMAT_LPCM or DI_CTA_AUDIO_FORMAT_LPCM_3D */
const struct di_cta_sad_lpcm *lpcm;
/* Additional metadata for MPEG-H 3D Audio, NULL unless format is
* DI_CTA_AUDIO_FORMAT_MPEGH_3D */
const struct di_cta_sad_mpegh_3d *mpegh_3d;
/* Additional metadata for MPEG4 AAC, NULL unless format is
* DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC or
* DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_V2 or
* DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC or
* DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND or
* DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND */
const struct di_cta_sad_mpeg_aac *mpeg_aac;
/* Additional metadata for MPEG4 Surround, NULL unless format is
* DI_CTA_AUDIO_FORMAT_MPEG4_HE_AAC_MPEG_SURROUND or
* DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC_MPEG_SURROUND */
const struct di_cta_sad_mpeg_surround *mpeg_surround;
/* Additional metadata for MPEG4 AAC LC, NULL unless format is
* DI_CTA_AUDIO_FORMAT_MPEG4_AAC_LC */
const struct di_cta_sad_mpeg_aac_le *mpeg_aac_le;
/* Additional metadata for Enhanced AC-3, NULL unless format is
* DI_CTA_AUDIO_FORMAT_ENHANCED_AC3 */
const struct di_cta_sad_enhanced_ac3 *enhanced_ac3;
/* Additional metadata for Dolby MAT, NULL unless format is
* DI_CTA_AUDIO_FORMAT_MAT */
const struct di_cta_sad_mat *mat;
/* Additional metadata for WMA Pro, NULL unless format is
* DI_CTA_AUDIO_FORMAT_WMA_PRO */
const struct di_cta_sad_wma_pro *wma_pro;
};
/**
* Get an array of short audio descriptors from a CTA data block.
*
* Returns NULL if the data block tag is not DI_CTA_DATA_BLOCK_AUDIO.
*
* The returned array is NULL-terminated.
*/
const struct di_cta_sad *const *
di_cta_data_block_get_sads(const struct di_cta_data_block *data_block);
/**
* Over- and underscan capability.
*/

View file

@ -1,20 +1,15 @@
--- ref
+++ di
@@ -58,12 +58,8 @@
@@ -58,7 +58,7 @@
Supports YCbCr 4:2:2
Native detailed modes: 0
Video Data Block:
- VIC 97: 3840x2160 60.000000 Hz 16:9 135.000 kHz 594.000000 MHz
+ VIC 97
Audio Data Block:
- Linear PCM:
- Max channels: 2
- Supported sample rates (kHz): 48 44.1 32
- Supported sample sizes (bits): 24 20 16
Video Capability Data Block:
YCbCr quantization: Selectable (via AVI YQ)
RGB quantization: Selectable (via AVI Q)
@@ -73,54 +69,12 @@
Linear PCM:
Max channels: 2
@@ -73,54 +73,12 @@
VESA Display Transfer Characteristics Data Block:
White transfer characteristics: 6 33 77 129 192 252 348 415 490 598 666 796 873 932 998 1023
VESA Video Display Device Data Block:

View file

@ -9,7 +9,7 @@
DMT 0x09: 800x600 60.316541 Hz 4:3 37.879 kHz 40.000000 MHz
DMT 0x10: 1024x768 60.003840 Hz 4:3 48.363 kHz 65.000000 MHz
DMT 0x23: 1280x1024 60.019740 Hz 5:4 63.981 kHz 108.000000 MHz
@@ -61,33 +61,21 @@
@@ -61,33 +61,25 @@
Supports YCbCr 4:2:2
Native detailed modes: 0
Video Data Block:
@ -40,10 +40,10 @@
+ VIC 33
+ VIC 34
Audio Data Block:
- Linear PCM:
- Max channels: 2
- Supported sample rates (kHz): 48 44.1 32
- Supported sample sizes (bits): 24 20 16
Linear PCM:
Max channels: 2
Supported sample rates (kHz): 48 44.1 32
Supported sample sizes (bits): 24 20 16
Speaker Allocation Data Block:
- FL/FR - Front Left/Right
- Vendor-Specific Data Block (HDMI), OUI 00-0C-03:
@ -56,7 +56,7 @@
Detailed Timing Descriptors:
DTD 3: 1280x720 59.654270 Hz 16:9 44.621 kHz 74.250000 MHz (700 mm x 392 mm)
Hfront 64 Hsync 128 Hback 192 Hpol P
@@ -98,34 +86,14 @@
@@ -98,34 +90,14 @@
DTD 5: 1920x1080 60.000000 Hz 16:9 67.500 kHz 148.500000 MHz (518 mm x 324 mm)
Hfront 88 Hsync 44 Hback 148 Hpol P
Vfront 4 Vsync 5 Vback 36 Vpol P

View file

@ -1,6 +1,6 @@
--- ref
+++ di
@@ -73,57 +73,32 @@
@@ -73,57 +73,36 @@
Supports YCbCr 4:2:2
Native detailed modes: 1
Video Data Block:
@ -39,10 +39,10 @@
+ VIC 97
+ VIC 96
Audio Data Block:
- Linear PCM:
- Max channels: 2
- Supported sample rates (kHz): 96 48 44.1 32
- Supported sample sizes (bits): 24 20 16
Linear PCM:
Max channels: 2
Supported sample rates (kHz): 96 48 44.1 32
Supported sample sizes (bits): 24 20 16
Speaker Allocation Data Block:
- FL/FR - Front Left/Right
- Vendor-Specific Data Block (HDMI), OUI 00-0C-03:
@ -75,7 +75,7 @@
HDR Static Metadata Data Block:
Electro optical transfer functions:
Traditional gamma - SDR luminance range
@@ -133,7 +108,6 @@
@@ -133,7 +112,6 @@
Static metadata type 1
Desired content max luminance: 92 (366.802 cd/m^2)
Desired content max frame-average luminance: 92 (366.802 cd/m^2)
@ -83,7 +83,7 @@
Detailed Timing Descriptors:
DTD 2: 2560x1440 59.950550 Hz 16:9 88.787 kHz 241.500000 MHz (700 mm x 390 mm)
Hfront 48 Hsync 32 Hback 80 Hpol P
@@ -144,29 +118,12 @@
@@ -144,29 +122,12 @@
DTD 4: 1280x768 59.870228 Hz 5:3 47.776 kHz 79.500000 MHz (700 mm x 390 mm)
Hfront 64 Hsync 128 Hback 192 Hpol N
Vfront 3 Vsync 7 Vback 20 Vpol P

View file

@ -9,14 +9,9 @@
Display Product Name: 'S27A950D'
Extension blocks: 1
Checksum: 0x1b
@@ -41,29 +39,13 @@
Basic audio support
Native detailed modes: 0
Audio Data Block:
- Linear PCM:
- Max channels: 2
- Supported sample rates (kHz): 48 44.1 32
- Supported sample sizes (bits): 24 20 16
@@ -46,24 +44,12 @@
Supported sample rates (kHz): 48 44.1 32
Supported sample sizes (bits): 24 20 16
Speaker Allocation Data Block:
- FL/FR - Front Left/Right
-Checksum: 0x71 Unused space in Extension Block: 115 bytes

View file

@ -1,6 +1,6 @@
--- ref
+++ di
@@ -79,35 +79,29 @@
@@ -79,35 +79,33 @@
Supports YCbCr 4:2:2
Native detailed modes: 1
Video Data Block:
@ -33,10 +33,10 @@
+ VIC 34
+ VIC 1
Audio Data Block:
- Linear PCM:
- Max channels: 2
- Supported sample rates (kHz): 192 176.4 96 88.2 48 44.1 32
- Supported sample sizes (bits): 24 20 16
Linear PCM:
Max channels: 2
Supported sample rates (kHz): 192 176.4 96 88.2 48 44.1 32
Supported sample sizes (bits): 24 20 16
Speaker Allocation Data Block:
- FL/FR - Front Left/Right
Detailed Timing Descriptors:
@ -52,7 +52,7 @@
DTD 4: 1280x720 60.000000 Hz 16:9 45.000 kHz 74.250000 MHz (597 mm x 336 mm)
Hfront 110 Hsync 40 Hback 220 Hpol P
Vfront 5 Vsync 5 Vback 20 Vpol P
@@ -117,28 +111,14 @@
@@ -117,28 +115,14 @@
DTD 6: 1920x1080 50.000000 Hz 16:9 56.250 kHz 148.500000 MHz (597 mm x 336 mm)
Hfront 528 Hsync 44 Hback 148 Hpol P
Vfront 4 Vsync 5 Vback 36 Vpol P