| 2596 | } |
| 2597 | |
| 2598 | static int parse_mca_labels(MXFContext *mxf, MXFTrack *source_track, MXFDescriptor *descriptor, AVStream *st) |
| 2599 | { |
| 2600 | AVChannelLayout *ch_layout = &st->codecpar->ch_layout; |
| 2601 | char *language = NULL; |
| 2602 | int ambigous_language = 0; |
| 2603 | enum AVAudioServiceType service_type = AV_AUDIO_SERVICE_TYPE_NB; |
| 2604 | int ambigous_service_type = 0; |
| 2605 | int ret; |
| 2606 | |
| 2607 | for (int i = 0; i < descriptor->sub_descriptors_count; i++) { |
| 2608 | char *channel_language; |
| 2609 | |
| 2610 | MXFMCASubDescriptor *label = mxf_resolve_strong_ref(mxf, &descriptor->sub_descriptors_refs[i], AudioChannelLabelSubDescriptor); |
| 2611 | if (label == NULL) |
| 2612 | continue; |
| 2613 | |
| 2614 | if (ch_layout->order == AV_CHANNEL_ORDER_UNSPEC) { |
| 2615 | av_channel_layout_uninit(ch_layout); |
| 2616 | ret = av_channel_layout_custom_init(ch_layout, descriptor->channels); |
| 2617 | if (ret < 0) |
| 2618 | return ret; |
| 2619 | } |
| 2620 | |
| 2621 | for (const MXFChannelOrderingUL* channel_ordering = mxf_channel_ordering; channel_ordering->uid[0]; channel_ordering++) { |
| 2622 | if (IS_KLV_KEY(channel_ordering->uid, label->mca_label_dictionary_id)) { |
| 2623 | int target_channel = label->mca_channel_id; |
| 2624 | if (target_channel == 0 && descriptor->channels == 1) |
| 2625 | target_channel = 1; |
| 2626 | if (target_channel <= 0 || target_channel > descriptor->channels) { |
| 2627 | av_log(mxf->fc, AV_LOG_ERROR, "AudioChannelLabelSubDescriptor has invalid MCA channel ID %d\n", target_channel); |
| 2628 | return AVERROR_INVALIDDATA; |
| 2629 | } |
| 2630 | ch_layout->u.map[target_channel - 1].id = channel_ordering->channel; |
| 2631 | if (service_type == AV_AUDIO_SERVICE_TYPE_NB) |
| 2632 | service_type = channel_ordering->service_type; |
| 2633 | else if (service_type != channel_ordering->service_type) |
| 2634 | ambigous_service_type = 1; |
| 2635 | break; |
| 2636 | } |
| 2637 | } |
| 2638 | |
| 2639 | channel_language = label->language; |
| 2640 | if (!channel_language) { |
| 2641 | MXFMCASubDescriptor *group = find_mca_link_id(mxf, SoundfieldGroupLabelSubDescriptor, &label->soundfield_group_link_id); |
| 2642 | if (group) { |
| 2643 | channel_language = group->language; |
| 2644 | if (!channel_language && group->group_of_soundfield_groups_link_id_count) { |
| 2645 | MXFMCASubDescriptor *supergroup = find_mca_link_id(mxf, GroupOfSoundfieldGroupsLabelSubDescriptor, |
| 2646 | group->group_of_soundfield_groups_link_id_refs); |
| 2647 | if (supergroup) |
| 2648 | channel_language = supergroup->language; |
| 2649 | } |
| 2650 | } |
| 2651 | } |
| 2652 | if (channel_language) { |
| 2653 | if (language && strcmp(language, channel_language)) |
| 2654 | ambigous_language = 1; |
| 2655 | else |
no test coverage detected