From patchwork Tue Jun 22 06:54:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 28598 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2042:0:0:0:0 with SMTP id z2csp2700119iod; Mon, 21 Jun 2021 23:55:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycNVNa2oWmIgB5fjl2yC29IKoc2u6TkrYT9ciu51fX87hfUAjEZ+ax/QYVfiRmtZ8DnsUp X-Received: by 2002:a17:906:cb81:: with SMTP id mf1mr2396023ejb.199.1624344907374; Mon, 21 Jun 2021 23:55:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624344907; cv=none; d=google.com; s=arc-20160816; b=WKet5Rs5EZUVY11BIrXeZSwlCdJXcYuwjfEuXs8FXstlnNTIMQZY0GBC913CyQSgrQ ooBTIrghIDiPrAX9vUT5WmopCP4YiIBmIcYHoVIdMoGxeRrdoX4prw6NFBrSskgnSYM3 MTB40/tm8U1Kerv0HMKFDwBUuM4QRiqUDgFSu4Nl9l7L/fT/3HWnT+EKBZwFFlsU1m8L ar45Q5SP3lAmlEUtjHVWGB1ds96uLF8xLTlFZIS92B/6RXybyWJUPA7ztUPgD5RpFhUR tUjDEgxpIwj9JmGLjg8+mQpHPbzx9v2gA6oAxDHNbG9tAbkJv7neSBIta898ZvybD54b bbfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=hZSl0xQT0XegT1e8oPMyluBbpebVhiT4ffMBdSQ0HA8=; b=KAkpImu1jRJpYy243pFMfK5Kjh42qbnjVNkmkgEqIaEg7Z9QZzfLgXEqySGKY9dP0m 1D+wnPYUwLNHR/b7ncsTL2elBoJlHveNdpybpA0sI4izJaR14V/NHChRqCI6Aq/iA3hW JNBExgXswDAUNzu/W8Ghd21mXEfN5pctmkcILpPczAEHGOyrzq4FeIl4aDAY1Auei1Av 5xQJpBVD2pfaAbOnVeTlEwiFRP7UcH8yxcjBwfu/kQH0TLIClMrjEQiVIaXlQF3gEPKv TcQ1pDitwaNXvp29FvpTI4FMenXnWpcY3Ta9L4m/dzqGUMoGOQQyMbt/OOYsq+7B0WTD XAMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=JfsVoKUO; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dp16si15347640ejc.164.2021.06.21.23.55.07; Mon, 21 Jun 2021 23:55:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=JfsVoKUO; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 13B5A689F59; Tue, 22 Jun 2021 09:54:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 48325680815 for ; Tue, 22 Jun 2021 09:54:45 +0300 (EEST) Received: by mail-lj1-f179.google.com with SMTP id r16so28615598ljk.9 for ; Mon, 21 Jun 2021 23:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=O0X0ut7avnuakB1W3T/+oJ4oCFEgVfvXnRJXhg1aqgc=; b=JfsVoKUOJOdfo9ihJcTOeTsLL7upkHoiEp8JoWdAdzTjbAItrcISpBG8TuESfzPEaU ptoKJgmW2KpY4pT0BoGgbEuBO4tuTogRCvKOn0Q3DhIdmWJRaNZbYo3V+Y+p5x4UZCIG YKAkmnp2GN8Ecfg7NqGRleqPrvipjO0SH04XZjOb80aN1KAjdOWpkO4BkCDupmpcHX1O pGXWg4oWCqbSv24+M/8JcAPHErepuR/T32cpw9oaqF2GEReRr3kCR1YbNSQRFwLDuCey nzCM1owRGTlnxi2uEKnZ+BGAjHqipUpgb7KVCkx0FhzZMn6Sg29r0yujhuwAeSq3j+Wg xWCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=O0X0ut7avnuakB1W3T/+oJ4oCFEgVfvXnRJXhg1aqgc=; b=pLpTTorJ2CRdM5NvlIaFRZyv7aOittENdQp8trgZHD6pN/puQjK0IPhc7TxTSROvw9 k6XRvHtr/12fkWiqetZOVGYgcPF2ZRdns62azixhF/KEa+voJ5qM86HnPTkYud5PRzl7 BYale7tIvss2u+QMw6MNM3+f6DJgd2TOSX8qU9WcGlvARRNwHTdgB04Py99urSwe7+GZ 0jmeGdebwmQaLEK9/xc85wvk6SKpbjGsG1zX1i+fJbiwcVoPmjsDXzTooQRUtwxLD8Hp iUACgLzcw8ZoojHjD+Zn4R8qdLSHVboxVTUyIgb2RTaB9CvCVyYAYsB6FX6xO6XNfv8u wiKQ== X-Gm-Message-State: AOAM532IEDlhqXrGtthdtJRqNtCQHAdJ00ntwlEReL64mhxtssiClh7w gzzqnWC1lrz5d6c304rD31+oN01rSsQ= X-Received: by 2002:a2e:97cf:: with SMTP id m15mr1884243ljj.450.1624344884498; Mon, 21 Jun 2021 23:54:44 -0700 (PDT) Received: from localhost.localdomain (91-159-194-103.elisa-laajakaista.fi. [91.159.194.103]) by smtp.gmail.com with ESMTPSA id d9sm2101417lfi.287.2021.06.21.23.54.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 23:54:44 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Jun 2021 09:54:33 +0300 Message-Id: <20210622065434.9006-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210622065434.9006-1-jeebjp@gmail.com> References: <20210622065434.9006-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] avformat/ttml: split TTML paragraph based or not check into header X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: LfrR4cgmppul From: Jan Ekström This way it can be re-utilized in movenc. Signed-off-by: Jan Ekström --- libavformat/ttmlenc.c | 9 ++------- libavformat/ttmlenc.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 libavformat/ttmlenc.h diff --git a/libavformat/ttmlenc.c b/libavformat/ttmlenc.c index 7577cb543b..5c4cd8b5e9 100644 --- a/libavformat/ttmlenc.c +++ b/libavformat/ttmlenc.c @@ -29,6 +29,7 @@ #include "avformat.h" #include "internal.h" +#include "ttmlenc.h" #include "libavcodec/ttmlenc.h" #include "libavutil/internal.h" @@ -137,13 +138,7 @@ static int ttml_write_header(AVFormatContext *ctx) 0); const char *printed_lang = (lang && lang->value) ? lang->value : ""; - // Not perfect, but decide whether the packet is a document or not - // by the existence of the lavc ttmlenc extradata. - ttml_ctx->input_type = (st->codecpar->extradata && - st->codecpar->extradata_size >= TTMLENC_EXTRADATA_SIGNATURE_SIZE && - !memcmp(st->codecpar->extradata, - TTMLENC_EXTRADATA_SIGNATURE, - TTMLENC_EXTRADATA_SIGNATURE_SIZE)) ? + ttml_ctx->input_type = ff_is_ttml_stream_paragraph_based(st->codecpar) ? PACKET_TYPE_PARAGRAPH : PACKET_TYPE_DOCUMENT; diff --git a/libavformat/ttmlenc.h b/libavformat/ttmlenc.h new file mode 100644 index 0000000000..2da233b8f1 --- /dev/null +++ b/libavformat/ttmlenc.h @@ -0,0 +1,39 @@ +/* + * Generic TTML helpers + * Copyright (c) 2021 24i + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_TTMLENC_H +#define AVFORMAT_TTMLENC_H + +#include "avformat.h" +#include "libavcodec/ttmlenc.h" + +static inline unsigned int ff_is_ttml_stream_paragraph_based(AVCodecParameters *codecpar) +{ + // Not perfect, but decide whether the packet is a document or not + // by the existence of the lavc ttmlenc extradata. + return (codecpar->extradata && + codecpar->extradata_size >= TTMLENC_EXTRADATA_SIGNATURE_SIZE && + !memcmp(codecpar->extradata, + TTMLENC_EXTRADATA_SIGNATURE, + TTMLENC_EXTRADATA_SIGNATURE_SIZE)); +} + +#endif /* AVFORMAT_TTMLENC_H */