From patchwork Sun Sep 12 03:21:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30179 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2863244iov; Sat, 11 Sep 2021 20:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL/r1sOYaDgm71CMpKoQ/z3gSQC5vEYv/LyDrqnc8BqlvqlNX5HvX4YScrlCw4fP6zAKx/ X-Received: by 2002:a17:906:c20d:: with SMTP id d13mr5645991ejz.259.1631416974541; Sat, 11 Sep 2021 20:22:54 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bl4si4404145ejb.689.2021.09.11.20.22.54; Sat, 11 Sep 2021 20:22:54 -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=@hotmail.com header.s=selector1 header.b=MSoMJKvB; arc=fail (body hash mismatch); 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=NONE dis=NONE) header.from=hotmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ABD2768AA09; Sun, 12 Sep 2021 06:21:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10olkn2062.outbound.protection.outlook.com [40.92.41.62]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2368D68A990 for ; Sun, 12 Sep 2021 06:21:55 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jvZ59ulFIxceyTg2Lr9wk7quFfgYNRDJ6WxdZX+pqhCCdQ1hvXgILN0afIHih8R9C/Yf4bv21U831OgdUex7dGNrM1cRNb65JOvdfZFNG41zQvYKhr9cwJC/sEiLKMP6PV+MYbsiBAAmPz4PeR62B1WE66RJBalqpSCYAvqsh798tK7Ztb4M0XUIJCWpYyFREAO2hHiWmyrPW8n2w/OWln/reCjQx7JllcHgkUklC7buzyKcL3laCPQwBa6dFpZoIRVYMEj//gQafZ2QMtPlqrrIypE9qVzMlFYRUymkiq09Lmg9qIyOpDAz2OBynf+T2+eP1EJAwmGaVUtSj3u8dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=F7KiL0JgeBQiLvU1j+IFUBxLV16yq73XsRMrhvmcWuA=; b=neSBn0wjNm+4/22NMdzidY9dwFHUwKS+znibY9FrOW+3peGMCut3J97CthL7MFnpyV2m4cgm4u8PP9ZVS8gyUhMk2qCSwehXsoLqKUKNNiGxk8U5xqLiAKqamHLwsBdoaEH8b1LH60/leyqTGrsfQqpTAsR4/FLKpZqyFXWA2Th16CYZGPY97rEl6zBWMnD7JiXg1UefV1a/u9yGgsA4HNjFhFoYkSP5pB5efS05vX7f54VyEtt2RvTJBmHN4LcFtBZXi4926MBSP0QhcSs4h4LBHBoAH4LHzmEJ3NhBHqcNXsf64du7YGn+qVJHPsehbCHt+EtY2tIHOtCnpo+XMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F7KiL0JgeBQiLvU1j+IFUBxLV16yq73XsRMrhvmcWuA=; b=MSoMJKvBfc5dQduwK3CtKheLt8opXyHlfYENqToDmRKjwOhKDW4vpWOjzzgAYFAiQRXlaoKVqAVGhv4ycW64zoTE0CBe0ZeCaeeeLyCAHWn3f6LGsTzyzVZiTxdS9K3vKt/bUAemlc8dCb/HDsH0BI4j8QHpeoFvF80YODOqPLUMrsLUgsSdnZarvWfMGZZ2JkQs1em5E9LR3xva4YdDv7Sa1F0OqwlIFpGxmLAJPq1O2m6vzM3DLrgo45h/zOtpCRuRQVjDHuB33t1etaYGIQ46JYengPU0JVoVn00aM0U63N9XQgsUNlCp8fj//qab3MRJ7K7K9B9+gb5oZB+Dow== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5728.namprd04.prod.outlook.com (2603:10b6:208:3d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Sun, 12 Sep 2021 03:21:48 +0000 Received: from MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb]) by MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::ecfe:2528:2012:22cb%5]) with mapi id 15.20.4500.018; Sun, 12 Sep 2021 03:21:48 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v5 06/12] avfilter/avfilter: Handle subtitle frames Thread-Index: AQHXp4VS2cRC4/LjO0a44pTNw1mrHQ== Date: Sun, 12 Sep 2021 03:21:48 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [Hz7viq6/avBPrxCw72IHPi47WoWfmXTGF1+ycNjqDEU=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9980056c-3bd6-4d81-3eb3-08d9759c74ef x-ms-traffictypediagnostic: MN2PR04MB5728: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7WZgrpT3OdjAUmhyxEUhHgLI89cELq0rsVnc/2RVwH3tHL4hPtoYO3c4/eetMGV0Y91aPZ3NVFnFFj3R4fDU08ITzbnpcSglaRslUoSUoZr8a84ax/ho2HTr9GbXHUvHfoGuzz1dpAKmlOgf6swHjl/uSjDN7i3dGQnF1qKCXrzzB7WA9O2CN2wEF8rcYmpDlNUCyNm2Y6aCJ2KmJL8ajqWB38tBTZQy4KY7GoEsTDtHxzh8eaSB8XexdYFB89wBt8wIgSTvqxOftSVZ9OutyI3zNEZORD/5WlKdlAb2r3fW7cO5YX+I3G99l0zRSbe+cC7j1N3qARUJbXy5v38FoXsNGFU5xVV37CqUluosyQ5PtnVgQKx4mPmgZmikA4f2lKCMN+r8wO7C8wl4WudNejmivgJyv8h2mVPPOpUO0Ko2MQHyzsCdRXklnP3xb3tX x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: K00q1bl0f8McGm+HkRjMCggz+eUs8eKIhHp6tPh+j6z9miFk2kI4+cpXomW7g1OAdq7YfcQyvUgwsdbTSxsSSqtfZZBqPM27RdVMJhMkhYQvhLUi1NuiCAXNYfr5UD4gaD1ApOJwD6VDuGHb2HfIug== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3174-20-msonline-outlook-529c7.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR04MB5981.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 9980056c-3bd6-4d81-3eb3-08d9759c74ef X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Sep 2021 03:21:48.5620 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5728 Subject: [FFmpeg-devel] [PATCH v5 06/12] avfilter/avfilter: Handle subtitle frames 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: IK1GzOb4sB27 Signed-off-by: softworkz --- libavfilter/avfilter.c | 8 +++++--- libavfilter/avfiltergraph.c | 5 +++++ libavfilter/formats.c | 14 ++++++++++++++ libavfilter/formats.h | 3 +++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index a04f8ed62f..961e55e7b4 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -56,7 +56,8 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end) ref->linesize[0], ref->linesize[1], ref->linesize[2], ref->linesize[3], ref->pts, ref->pkt_pos); - if (ref->width) { + switch(ref->type) { + case AVMEDIA_TYPE_VIDEO: ff_tlog(ctx, " a:%d/%d s:%dx%d i:%c iskey:%d type:%c", ref->sample_aspect_ratio.num, ref->sample_aspect_ratio.den, ref->width, ref->height, @@ -64,12 +65,13 @@ void ff_tlog_ref(void *ctx, AVFrame *ref, int end) ref->top_field_first ? 'T' : 'B', /* Top / Bottom */ ref->key_frame, av_get_picture_type_char(ref->pict_type)); - } - if (ref->nb_samples) { + break; + case AVMEDIA_TYPE_AUDIO: ff_tlog(ctx, " cl:%"PRId64"d n:%d r:%d", ref->channel_layout, ref->nb_samples, ref->sample_rate); + break; } ff_tlog(ctx, "]%s", end ? "\n" : ""); diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 45b028cd9c..7a5a4ea419 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -314,6 +314,8 @@ static int filter_link_check_formats(void *log, AVFilterLink *link, AVFilterForm return ret; break; + case AVMEDIA_TYPE_SUBTITLE: + return 0; default: av_assert0(!"reached"); } @@ -444,6 +446,9 @@ static int query_formats(AVFilterGraph *graph, void *log_ctx) if (!link) continue; + if (link->type == AVMEDIA_TYPE_SUBTITLE) + continue; + neg = ff_filter_get_negotiation(link); av_assert0(neg); for (neg_step = 1; neg_step < neg->nb_mergers; neg_step++) { diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 1bf7d36195..704774d763 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavcodec/avcodec.h" #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/common.h" @@ -430,6 +431,12 @@ int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) return 0; } +int ff_add_subtitle_type(AVFilterFormats **avff, int64_t fmt) +{ + ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats); + return 0; +} + AVFilterFormats *ff_all_formats(enum AVMediaType type) { AVFilterFormats *ret = NULL; @@ -447,6 +454,13 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type) return NULL; fmt++; } + } else if (type == AVMEDIA_TYPE_SUBTITLE) { + if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_BITMAP) < 0) + return NULL; + if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_ASS) < 0) + return NULL; + if (ff_add_subtitle_type(&ret, AV_SUBTITLE_FMT_TEXT) < 0) + return NULL; } return ret; diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 471cb42bc4..25ae511fc1 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -180,6 +180,9 @@ int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts); av_warn_unused_result int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout); +av_warn_unused_result +int ff_add_subtitle_type(AVFilterFormats **avff, int64_t fmt); + /** * Add *ref as a new reference to f. */