From patchwork Thu Apr 15 15:21:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zheng qian X-Patchwork-Id: 26928 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 81C4F44B734 for ; Thu, 15 Apr 2021 18:29:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5173F68A04F; Thu, 15 Apr 2021 18:29:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E15D76881A9 for ; Thu, 15 Apr 2021 18:29:38 +0300 (EEST) Received: by mail-pg1-f181.google.com with SMTP id f29so17146910pgm.8 for ; Thu, 15 Apr 2021 08:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xqq-im.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=y0iks4xYDSt+ZotT464fgwj/JCz5W8suczLK6NM0KyY=; b=g57eBhm4T6eqyjgcSaeOUUrHreIRGtzyWfWPYVZpyG5wo/QohI541OukxWQxhmDgoI ARMOqb5sddVB7ML+hUdK7wCmzQlIEo720m6aKag+6caPaDVC5S2HPUEHwIt/He7/qxl7 0HCNC1r5EfCAe1ZhKx2nFeZmJz5fgdKjdJqExpxnEFQvbGy8lFvvSKikWcQ3HDxYq4ki rq46OHZklBNL8CQ5q9aVHvu40FTvppzekSrtiv0mS6eEByWz0z/bMO5HvOSehfXwOv6H XPLrW+Dpl4NV8WqX9q3Iib5ekOUSmIM0Ej/RHHmL043KtnxrBgAGG9VeZa822IoFDi/3 pjcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=y0iks4xYDSt+ZotT464fgwj/JCz5W8suczLK6NM0KyY=; b=BU11WVS+IsQlxOD5ulM5n+Lm8S3mQN+odZFQKl9miAXRP1kIuTZZXErWh89bHzE9vz 8bkGA9DKJ5MB1uxYmm3E5EmuUkSvoeaDdlKDr4kDDWvPw0H7s13pEirLRieGQqHevG6Z JMBuQUQT3uWJQN0DMGAYzaaeb+sEIfGQa3jK7ih3gnZtfOpkJBHK7z6JkzG2PU/W7wF+ kB6NNBlnCJlPKBulvASflcoSrLxpbg/Sx7SHGXe93UjgredOLq3R8zVWIz6kIzweRL9q GjmUgMdLXrtRN0IPEW3NdVfS9qId+rcIUtTAJSpZZoym1xzR5PSClwyoZMYBbYCAEc/i hvCg== X-Gm-Message-State: AOAM5309IyrVANYQ1Yj2hsHRugEhDVJ41FwxdSV0Icc7eWEDiq5ttL7I wkAyNc+jIh3QEU+409nOFfS8lzhroZCuDGcX X-Google-Smtp-Source: ABdhPJy1VID+pzYRjrm6iH/QPU89pD1ITyW6KwOX3kE0RhWIVvsiR4nqHfCMyDOBPN5VNojqwJEOtg== X-Received: by 2002:a62:ce4f:0:b029:258:2b6c:7741 with SMTP id y76-20020a62ce4f0000b02902582b6c7741mr2433356pfg.33.1618500166230; Thu, 15 Apr 2021 08:22:46 -0700 (PDT) Received: from zhengqian-xps.lan (ngn-nat1.v4.open.ad.jp. [202.222.12.138]) by smtp.gmail.com with ESMTPSA id q8sm2824301pgn.22.2021.04.15.08.22.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Apr 2021 08:22:45 -0700 (PDT) From: zheng qian To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Apr 2021 00:21:33 +0900 Message-Id: <20210415152133.85408-1-xqq@xqq.im> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210410031017.1271-1-xqq@xqq.im> References: <20210410031017.1271-1-xqq@xqq.im> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 1/1] avformat/mpegtsenc: Write necessary descriptors into PMT for arib_caption muxing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: zheng qian , jeebjp@gmail.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Changes since v2: Generate stream_identifier and data_component_id from profile The recognization of ARIB STD-B24 caption has been introduced in commit a03885b, which is used as closed caption in Japanese / Brazilian Digital Television. But arib_caption stream copy is not working correctly caused by the missing of descriptors in PMT. ARIB caption data inside remuxed mpegts stream could not be recognized as an arib_caption subtitle track once again because of the missing of descriptors. This patch writes stream_identifier_descriptor and data_component_descriptor by generating stream_identifier and data_component_id from ARIB profile. arib_caption remuxing could be worked correctly through this patch. Signed-off-by: zheng qian --- libavformat/mpegtsenc.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index a357f3a6aa..f302af84ff 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -357,6 +357,7 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st) break; case AV_CODEC_ID_DVB_SUBTITLE: case AV_CODEC_ID_DVB_TELETEXT: + case AV_CODEC_ID_ARIB_CAPTION: stream_type = STREAM_TYPE_PRIVATE_DATA; break; case AV_CODEC_ID_SMPTE_KLV: @@ -714,6 +715,34 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) } *len_ptr = q - len_ptr - 1; + } else if (codec_id == AV_CODEC_ID_ARIB_CAPTION) { + uint8_t stream_identifier; + uint16_t data_component_id; + + if (st->codecpar->profile == FF_PROFILE_ARIB_PROFILE_A) { + // non-mobile captioning service ("profile A") + stream_identifier = 0x30; + data_component_id = 0x0008; + } else if (st->codecpar->profile == FF_PROFILE_ARIB_PROFILE_C) { + // (1seg) captioning service ("profile C") + stream_identifier = 0x87; + data_component_id = 0x0012; + } else { + break; + } + + // stream_identifier_descriptor + *q++ = 0x52; // descriptor_tag + *q++ = 1; // descriptor_length + *q++ = stream_identifier; // component_tag: stream_identifier + + // data_component_descriptor, defined in ARIB STD-B10, part 2, 6.2.20 + *q++ = 0xFD; // descriptor_tag: ARIB data coding type descriptor + *q++ = 3; // descriptor_length + put16(&q, data_component_id); // data_component_id + // additional_arib_caption_info: defined in ARIB STD-B24, fascicle 1, Part 3, 9.6.1 + // Use most commonly used value 0x3D: DMF(0x3), Reserved(0x3), Timing(0x1) + *q++ = 0x3D; } break; case AVMEDIA_TYPE_VIDEO: