From patchwork Sat Apr 10 03:10:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zheng qian X-Patchwork-Id: 26828 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 38853448B3C for ; Sat, 10 Apr 2021 06:36:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0F50A687FA3; Sat, 10 Apr 2021 06:36:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ACBE0687F43 for ; Sat, 10 Apr 2021 06:36:32 +0300 (EEST) Received: by mail-il1-f169.google.com with SMTP id w2so6318379ilj.12 for ; Fri, 09 Apr 2021 20:36:32 -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=G4yjpqg1rAnA18mh0/EoXwqcDONKdK9GkPldrOAq/vE=; b=0bbpGpDHNqVckdKbl3TZHONn0iaf9DeiRBeMmjzOsc+sOfuknK9m6VjCTZN7IAKyxB RRWZe+ejaIZMixZqmPcJ0yznbIAyPRCtSw2ugzagpScfN9d9N74ivGr2odTsDMbyZO9/ U2lLaK5GU7mTnlIHD9SYtw/8bGqn+hCucOXEnbg2s9XgBE2daa/rkgpXEuLTFfmH8D+D vmkLxUVpeLnCUR6vVy4F98qKRYMrfNn3Y3QdA1plPp8WWk3Q8kcrKgGX1iPtqy2pk8JO weZUId3426S/QBehCvQQ280GzEgkyKbO/8L+rt85CCPBPXkSW7Y9UYq3JSKzFaZnsQHi XB3g== 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=G4yjpqg1rAnA18mh0/EoXwqcDONKdK9GkPldrOAq/vE=; b=VpJbm7tM3qqUOXbbCQ68nu7OyeN8nkADmfCBkwFnYBzoIfGJOXJfE4E+xmyJledOQn x/3iwJ/PbQfE3/42MSDlvtF/pC5NWcVAiTr+ltYs8/p8ST9MxmGOML68SISGX0PRkHMt pjdCzKU+vdtS5a1xMVyxH3zCtbc1a6RUk+MJrjytK/rCCJTG9Rs7sjCsle/Kh43YF7uN UnRYNpNRtDLDCzgYYEfn84wIectEK6hh4JuTmbH9RbQ3mH/2hsDdVjWmVDXjyWMlM9ad aP/4MrfTZbiHsMI5aCnICoNthJDXKzuF2hY8IH4ACZ35VNS7eOH5LIXd9y0IKOOWslhq GhzQ== X-Gm-Message-State: AOAM532tseU/+Elr9eKQmOuUhSUfwMWFvs89vcJbZxzTH/DxrEj3hPbZ bB/Bi3ewRflymPVhaupu4vpaVugHMY1LqLVc X-Google-Smtp-Source: ABdhPJxXIsDuZqtw0TBT+z8Ec5SyICFndgPoflht4X/J4K5BwpyP8+atfg88cuGrkv24jYRbmIey2w== X-Received: by 2002:a63:d146:: with SMTP id c6mr16705852pgj.131.1618024347820; Fri, 09 Apr 2021 20:12:27 -0700 (PDT) Received: from zhengqian-xps.lan (ngn-nat1.v4.open.ad.jp. [202.222.12.138]) by smtp.gmail.com with ESMTPSA id u14sm3300035pji.15.2021.04.09.20.12.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Apr 2021 20:12:27 -0700 (PDT) From: zheng qian To: ffmpeg-devel@ffmpeg.org Date: Sat, 10 Apr 2021 12:10:17 +0900 Message-Id: <20210410031017.1271-2-xqq@xqq.im> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210410031017.1271-1-xqq@xqq.im> References: <20210406081816.54105-1-xqq@xqq.im> <20210410031017.1271-1-xqq@xqq.im> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/2] libavformat/mpegtsenc: Write necessary descriptors into PMT for arib_caption 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Stream copy for arib_caption into mpegts is not working correctly for now. This patch utilizes the data stored in codecpar->extradata to write necessary stream_identifier_descriptor and data_component_descriptor into PMT table for arib_caption remuxing. This patch fixes the copying of arib_caption. After this patch, arib_caption inside the outputted (remuxed) mpegts stream can be recognized correctly as an arib_caption subtitle stream. Signed-off-by: zheng qian --- libavformat/mpegtsenc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index a357f3a6aa..e26a5d3b51 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,8 +715,21 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) } *len_ptr = q - len_ptr - 1; + } else if (codec_id == AV_CODEC_ID_ARIB_CAPTION) { + if (st->codecpar->extradata && st->codecpar->extradata_size >= 4) { + // stream_identifier_descriptor + *q++ = 0x52; // descriptor_tag + *q++ = 1; // descriptor_length + *q++ = st->codecpar->extradata[0]; // component_tag: stream_identifier + + // data_component_descriptor + *q++ = 0xFD; // descriptor_tag: ARIB data coding type descriptor + *q++ = 3; // descriptor_length + memcpy(q, &st->codecpar->extradata[1], 3); // data_component_id & additional_arib_caption_info + q += 3; + } } - break; + break; case AVMEDIA_TYPE_VIDEO: if (stream_type == STREAM_TYPE_VIDEO_DIRAC) { put_registration_descriptor(&q, MKTAG('d', 'r', 'a', 'c'));