+ case 0xfd: /* ARIB data coding type descriptor */
+ // STD-B24, fascicle 3, chapter 4 defines private_stream_1
+ // for captions
+ if (stream_type == STREAM_TYPE_PRIVATE_DATA) {
+ // This structure is defined in STD-B10, part 1, listing 5.4 and
+ // part 2, 6.2.20).
+ // Listing of data_component_ids is in STD-B10, part 2, Annex J.
+ // Component tag limits are documented in TR-B14, fascicle 2,
+ // Vol. 3, Section 2, 4.2.8.1
+ int actual_component_tag = st->stream_identifier - 1;
+ int picked_profile = FF_PROFILE_UNKNOWN;
+ int data_component_id = get16(pp, desc_end);
+ if (data_component_id < 0)
+ return AVERROR_INVALIDDATA;
+
+ switch (data_component_id) {
+ case 0x0008:
+ // [0x30..0x37] are component tags utilized for
+ // non-mobile captioning service ("profile A").
+ if (actual_component_tag >= 0x30 &&
+ actual_component_tag <= 0x37) {
+ picked_profile = FF_PROFILE_ARIB_PROFILE_A;
+ }
+ break;
+ case 0x0012:
+ // component tag 0x87 signifies a mobile/partial reception
+ // (1seg) captioning service ("profile C").
+ if (actual_component_tag == 0x87) {
+ picked_profile = FF_PROFILE_ARIB_PROFILE_C;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (picked_profile == FF_PROFILE_UNKNOWN)
+ break;
+
+ st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
+ st->codecpar->codec_id = AV_CODEC_ID_ARIB_CAPTION;
+ st->codecpar->profile = picked_profile;
+ st->internal->request_probe = 0;
+ }
+ break;
+ case 0xb0: /* DOVI video stream descriptor */
+ {
+ uint32_t buf;
+ AVDOVIDecoderConfigurationRecord *dovi;
+ size_t dovi_size;
+ int ret;
+ if (desc_end - *pp < 4) // (8 + 8 + 7 + 6 + 1 + 1 + 1) / 8
+ return AVERROR_INVALIDDATA;
+
+ dovi = av_dovi_alloc(&dovi_size);
+ if (!dovi)
+ return AVERROR(ENOMEM);
+
+ dovi->dv_version_major = get8(pp, desc_end);
+ dovi->dv_version_minor = get8(pp, desc_end);
+ buf = get16(pp, desc_end);
+ dovi->dv_profile = (buf >> 9) & 0x7f; // 7 bits
+ dovi->dv_level = (buf >> 3) & 0x3f; // 6 bits
+ dovi->rpu_present_flag = (buf >> 2) & 0x01; // 1 bit
+ dovi->el_present_flag = (buf >> 1) & 0x01; // 1 bit
+ dovi->bl_present_flag = buf & 0x01; // 1 bit
+ if (desc_end - *pp >= 20) { // 4 + 4 * 4
+ buf = get8(pp, desc_end);
+ dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits
+ } else {
+ // 0 stands for None
+ // Dolby Vision V1.2.93 profiles and levels
+ dovi->dv_bl_signal_compatibility_id = 0;
+ }
+
+ ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF,
+ (uint8_t *)dovi, dovi_size);
+ if (ret < 0) {
+ av_free(dovi);
+ return ret;
+ }
+
+ av_log(fc, AV_LOG_TRACE, "DOVI, version: %d.%d, profile: %d, level: %d, "
+ "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n",
+ dovi->dv_version_major, dovi->dv_version_minor,
+ dovi->dv_profile, dovi->dv_level,
+ dovi->rpu_present_flag,
+ dovi->el_present_flag,
+ dovi->bl_present_flag,
+ dovi->dv_bl_signal_compatibility_id);
+ }
+ break;