From patchwork Mon Aug 30 08:16:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 29875 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp3737609iov; Mon, 30 Aug 2021 01:16:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzALX9MvSPBc5jtbYzuaLkSH6XttmZRqtTl2/9o/3p1nfSHYlP82WHzzoYCv+3R0P+9ea/N X-Received: by 2002:a05:6402:b65:: with SMTP id cb5mr7232281edb.343.1630311410578; Mon, 30 Aug 2021 01:16:50 -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 18si17378436ejc.508.2021.08.30.01.16.50; Mon, 30 Aug 2021 01:16:50 -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=a50AadJm; 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 7D4E968A1CC; Mon, 30 Aug 2021 11:16:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10olkn2033.outbound.protection.outlook.com [40.92.40.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8EAFD688181 for ; Mon, 30 Aug 2021 11:16:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GxdXCF38H/0rC311u2svbYIb49/mXTb2o1IyL5nBMSVjFLKFnvYgkTI9Y8P9DubiYyb+K3lnV3ljbH2LeMJ4ziTsZEP5YZfuxjmMcESBZOZBPYc/MiLMzYj889SyR1VJbP+8ovxA3Z5l+uPVfIkgU9dNmkbuzM0NMUirIANaTlR6Kdyn9ZcS4GKDG1JiFnzZE8TlEpJJCqyhhR2TH0XnP6Vgsqsgcqm+cdYq3xwNDpyaSVsdnsirltOasvYbzWBAwzG20c/hEfk6q1FDv3uaHgECG0Mk7DFLR61IYfzP1bDkyY5nm234An2U3YKTcAMeW0aniBU3GfqVPZL9VAbUdw== 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:X-MS-Exchange-SenderADCheck; bh=6mQ1JRbpXaVnG+svbScYk7m3sMvQAZvDan9X40VibaM=; b=VhIWAUj9HeBQfVZeuC1MBUczcH4KezFNn8Limbb/UBFZYsVlt2PXxbgFGmSrORrUyZAOhEDb8W13k9NytCRYvBjAS9O8iVfBxIFSfNZFxh3JoUTQuClH5QpXfawQ7TNbJo0XKIQxpZvImoO6LTPFtkX73dLi3YX8W2c4zJrMC98TgRnONVX/ZNVRRfTJwrJkVikXTojECOwXHa5vZKa6eKvsxgYb0Be67DyRAfvHYKk0cZd/yrAtShAJlRuzFtq+soADp6W9xE3Wca2txa1MIDE4S8S3YLWyESwEH0xZnXKK6/1/XcUHJrRr3I0CdpeXdwUJnfK3xBPHP78oWCo8Gg== 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=6mQ1JRbpXaVnG+svbScYk7m3sMvQAZvDan9X40VibaM=; b=a50AadJmJtzgziio3TSu1OPvHIJKuFwUxkxgIuj6qEwAJGReFUADaaNNuP09G/V6iIA+QtLwemN9P2VHN92P8l7luwqCjhLGiTSJPD35BNwa/jODE2IyRKQWpM8/na9OB1sB6Tc9TlKzPcY9B9Ara2p+9BVwOiJCQsM6fBmV2i27IQvjcKJCMZ3Ku1BhMYdhLRF+LmXfxDUbOERhamPVjwOCnLVMpvUN/808VPdehtXyO8aits0jAu5uktc9mVWrNLdz3ak5Q4QCypLvn0N1W4E580x6IG4dUs0YaVkX1Si0Y/MlHJK9cRD0Dl5XIjMndORGjw2IWpFTzC6/RYVesg== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB6191.namprd04.prod.outlook.com (2603:10b6:208:de::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.23; Mon, 30 Aug 2021 08:16:36 +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.4457.024; Mon, 30 Aug 2021 08:16:36 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v2 3/8] avfilter/avfilter: Handle subtitle frames Thread-Index: AdeUdjgpG4tB/pZ/T5+8zhj48gT42A== Date: Mon, 30 Aug 2021 08:16:36 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [FJfNb0DvR84/shzsLeDSEX+34ijy9qYN] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bbed67de-4ea1-4819-0e60-08d96b8e7c63 x-ms-traffictypediagnostic: MN2PR04MB6191: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: dnhcHXeSF89vNEWheFlPLeyvPfneNW52ZAO/iwjywTlcwEeNlczRtU8tIYtwq3RTLsKNiJAD7HA0VpQwP6qBrpnMwpwtQpIOaqqFcQg+2bWlcKbnsD/hQ5LTSfY5hhI9/6pYL86FWms/XwlgKGOqVbEW7FB7oDUPMqQ93OiUzrDAT86kvjBeyyqNux804ZTotWiXyPqVXFldaSJXXqC38wIWknSE3BSThu4C+pHeKa+Y2+RjVo3dPeO+7g5bPF3hoNVdw8YUIcQAkaqx+9usCkazx6ZU5p0x/NtThPCfgFMJIOxBdLfLiNmzJt+txIAv7m3O81kb+oaQS6p3AJrJBwW2f2xFGfcNSY0q/ztVUFgb4soHbzWK9j+I6Rg6FqnuPLzVeorS/Tbgr6iVhklqs7GT6vFMnBPjiWopTKuwwXa+PJuIjRZCIK7xfPtAkHJ1 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: H4k0pZ7Tt1dYh9oDXwHHbTsb1eXdS8/in2G9rpnNNnXwP3FQ3+8SyEIAtKeYXlGke4mxT+9f3peK44UMjPLCcbRg5qa+cxvtVvRRrVnRFkhaRqna2Toyx9vgGi/cmH5HdzD6uVFogicaCY2mXdT6uQ== 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: bbed67de-4ea1-4819-0e60-08d96b8e7c63 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Aug 2021 08:16:36.5120 (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: MN2PR04MB6191 Subject: [FFmpeg-devel] [PATCH v2 3/8] 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: PH6at/+dAPfV Signed-off-by: softworkz --- v2 Update: - Implemented Andreas' suggestions - overlay_subs filter: - removed duplicated code - implemented direct (no pre-conversion) blending of graphical subtitle rects - Supported input formats: - all packed RGB formats (with and without alpha) - yuv420p, yuv422p, yuv444p libavfilter/avfilter.c | 8 +++++--- libavfilter/avfiltergraph.c | 5 +++++ libavfilter/formats.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index ea22b247de..5505c34678 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 41a91a9bda..4f581bc7a6 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -328,6 +328,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"); } @@ -463,6 +465,9 @@ static int query_formats(AVFilterGraph *graph, AVClass *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; neg_step++) { diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 9e39d65a3c..26d8e45263 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; } +static 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,10 @@ AVFilterFormats *ff_all_formats(enum AVMediaType type) return NULL; fmt++; } + } else if (type == AVMEDIA_TYPE_SUBTITLE) { + ff_add_subtitle_type(&ret, SUBTITLE_BITMAP); + ff_add_subtitle_type(&ret, SUBTITLE_ASS); + ff_add_subtitle_type(&ret, SUBTITLE_TEXT); } return ret;