diff mbox series

[FFmpeg-devel,v3,2/4] avformat/mpegts: Recognize ARIB superimpose stream

Message ID 20210717023829.84846-2-xqq@xqq.im
State New
Headers show
Series [FFmpeg-devel,v3,1/4] avformat: Introduce AV_DISPOSITION_URGENT disposition flag for emergency alert | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

zheng qian July 17, 2021, 2:38 a.m. UTC
Recognize ARIB superimpose stream through ARIB data coding descriptor,
and re-use AV_CODEC_ID_ARIB_CAPTION codec id with an extra disposition
flag AV_DISPOSITION_URGENT.

Signed-off-by: zheng qian <xqq@xqq.im>
---
 libavformat/mpegts.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index a02965bacf..44a1841859 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2106,8 +2106,8 @@  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
+        // STD-B24, fascicle 3, chapter 4 defines
+        // private_stream_1 for captions, and private_stream_2 for superimpose
         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).
@@ -2115,6 +2115,7 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
             // Component tag limits are documented in TR-B14, fascicle 2,
             // Vol. 3, Section 2, 4.2.8.1
             int actual_component_tag = st->internal->stream_identifier - 1;
+            int is_superimpose = 0;
             int picked_profile = FF_PROFILE_UNKNOWN;
             int data_component_id = get16(pp, desc_end);
             if (data_component_id < 0)
@@ -2122,17 +2123,28 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
 
             switch (data_component_id) {
             case 0x0008:
-                // [0x30..0x37] are component tags utilized for
+                // [0x30..0x37] and [0x38..0x3F] are component tags utilized for
                 // non-mobile captioning service ("profile A").
                 if (actual_component_tag >= 0x30 &&
                     actual_component_tag <= 0x37) {
+                    // caption (Profile A)
+                    picked_profile = FF_PROFILE_ARIB_PROFILE_A;
+                } else if (actual_component_tag >= 0x38 &&
+                           actual_component_tag <= 0x3F) {
+                    // superimpose (Profile A)
+                    is_superimpose = 1;
                     picked_profile = FF_PROFILE_ARIB_PROFILE_A;
                 }
                 break;
             case 0x0012:
-                // component tag 0x87 signifies a mobile/partial reception
+                // component tag 0x87 and 0x88 signifies a mobile/partial reception
                 // (1seg) captioning service ("profile C").
                 if (actual_component_tag == 0x87) {
+                    // caption (Profile C)
+                    picked_profile = FF_PROFILE_ARIB_PROFILE_C;
+                } else if (actual_component_tag == 0x88) {
+                    // superimpose (Profile C)
+                    is_superimpose = 1;
                     picked_profile = FF_PROFILE_ARIB_PROFILE_C;
                 }
                 break;
@@ -2147,6 +2159,9 @@  int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
             st->codecpar->codec_id   = AV_CODEC_ID_ARIB_CAPTION;
             st->codecpar->profile    = picked_profile;
             st->internal->request_probe        = 0;
+            if (is_superimpose) {
+                st->disposition |= AV_DISPOSITION_URGENT;
+            }
         }
         break;
     case 0xb0: /* DOVI video stream descriptor */