[FFmpeg-devel] [PATCH 2/5] avformat/mpegts: Recognize arib_superimpose by ARIB data coding descriptor

zheng qian xqq at xqq.im
Sat Jun 12 12:30:29 EEST 2021


Signed-off-by: zheng qian <xqq at xqq.im>
---
 libavformat/mpegts.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index a02965bacf..6c5fb53c51 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;
+            enum AVCodecID arib_codec_id = AV_CODEC_ID_NONE;
             int picked_profile = FF_PROFILE_UNKNOWN;
             int data_component_id = get16(pp, desc_end);
             if (data_component_id < 0)
@@ -2122,17 +2123,30 @@ 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)
+                    arib_codec_id = AV_CODEC_ID_ARIB_CAPTION;
+                    picked_profile = FF_PROFILE_ARIB_PROFILE_A;
+                } else if (actual_component_tag >= 0x38 &&
+                           actual_component_tag <= 0x3F) {
+                    // superimpose (Profile A)
+                    arib_codec_id = AV_CODEC_ID_ARIB_SUPERIMPOSE;
                     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)
+                    arib_codec_id = AV_CODEC_ID_ARIB_CAPTION;
+                    picked_profile = FF_PROFILE_ARIB_PROFILE_C;
+                } else if (actual_component_tag == 0x88) {
+                    // superimpose (Profile C)
+                    arib_codec_id = AV_CODEC_ID_ARIB_SUPERIMPOSE;
                     picked_profile = FF_PROFILE_ARIB_PROFILE_C;
                 }
                 break;
@@ -2140,11 +2154,11 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
                 break;
             }
 
-            if (picked_profile == FF_PROFILE_UNKNOWN)
+            if (arib_codec_id == AV_CODEC_ID_NONE || picked_profile == FF_PROFILE_UNKNOWN)
                 break;
 
             st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
-            st->codecpar->codec_id   = AV_CODEC_ID_ARIB_CAPTION;
+            st->codecpar->codec_id   = arib_codec_id;
             st->codecpar->profile    = picked_profile;
             st->internal->request_probe        = 0;
         }
-- 
2.29.2



More information about the ffmpeg-devel mailing list