summaryrefslogtreecommitdiff
path: root/libavformat/mpegts.c
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2019-01-14 22:07:51 +0200
committerJan Ekström <jeebjp@gmail.com>2019-02-10 03:30:56 +0200
commita03885b745be6ba324f0b24668c8e338d8b1e54c (patch)
tree79da4c8ee9501c21f792298d9cf67b9282497310 /libavformat/mpegts.c
parent100bfac6d6ecb3447dc3ac4b9d2c41085da59a8b (diff)
lavf/mpegts: add reading of ARIB data coding descriptor
This enables us to read the data coding type utilized for a specific private data stream, of which we currently are interested in ARIB caption streams. The component tag limitations are according to ARIB TR-B14, and the component IDs are defined in ARIB STD-B10.
Diffstat (limited to 'libavformat/mpegts.c')
-rw-r--r--libavformat/mpegts.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index f5a87c87cb..b347ec1736 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2058,6 +2058,50 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
break;
+ 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->request_probe = 0;
+ }
+ break;
default:
break;
}