From patchwork Thu Sep 16 20:30:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30281 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1582262iov; Thu, 16 Sep 2021 13:31:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0TdKVXxRneQsGkhBUKol5aYuS5/6WkeMt9rgyL6fpalz1iN4pD1plMQd925BmMpdc+CEY X-Received: by 2002:a50:becb:: with SMTP id e11mr7754744edk.161.1631824261646; Thu, 16 Sep 2021 13:31:01 -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 m4si4855244edv.496.2021.09.16.13.31.01; Thu, 16 Sep 2021 13:31:01 -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=aiaQG3MB; 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 235EB68B0C1; Thu, 16 Sep 2021 23:30:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11olkn2053.outbound.protection.outlook.com [40.92.18.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B0C4668B0A8 for ; Thu, 16 Sep 2021 23:30:26 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JNMtLV/VsLB5WzW1wyyvUVBfom2TV4HjseuN1Ug3j7+SncsN/WSe9TNJtoERePCQYmzO5Nmf20+kGMRoRrocf0dsSZmDM6/AgCtQ00dvFpF9VWSWqWdRq2WD9SE072TYWnrDPm5ojNlkA6ybZ/juSqVn/EdMJgPWArr+gUrP5nOOl4RQToI6r+ElY9SBlQPabCqMPw1ASDLfL3UmQ5iiE3J4wg7y4GZCrgNi4DLVAjRYRBlGN9yIiWlJZe8bFzpNNqkpA/OnBW989qnokNYiSzirW3n+IWwLjpYT2WbTx+2IVCWGqvuR/xNxc3Af54yWLhU85W7z0INT2U/xBT7JAw== 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=Xr8d11wZykDqFMTRb+5mfEdthuwTJ2wtrxVs94vWML4=; b=kkDqDxtElkOZVrx9xJuW+rJ3qJzyw8vf0Q9gbCCYongSNkbJOevf8RtGBsJiLZqjxqNgzr7RhNYvhGs2+aFf6xF52S9yA+lsFynxXktKgGQMhIPkBUNRTKH5VMoe8BQqrnxgeAtDnlvE4JWB/aUjHP5IlLMsIPB+Qi7fPY2bxn+HN5/bS7hXM0aBVc6W4mzv0cSzYPTYcKsG99woR5cCYhWTu5pcjzpvS4VztMuxSnLT9F8ZhNRR4BLKaEC/GaSxY9iNUi/GAcdIlu1ObPxnJIDfyBi7+CudSj/tEU/3Fly5kL4zk0P+9L5o/ciUXe5yEoy7YxzvRXyhWgX/xr48gQ== 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=Xr8d11wZykDqFMTRb+5mfEdthuwTJ2wtrxVs94vWML4=; b=aiaQG3MB3dtfwtU6IF7FMEEZIGus3n/eDClpWaGyl+R3tGWQuqywJ6NtIsZ1RwKArU3sQSGqQZTWiegpJDpfKSRrG/uU7cXknN4h4ZJnyVZ5Zi050IDV47tgybFJeNnWS3bJz0O41OFamhxttb29aXnp7/R1Y1xQHG+HLkGYkKLjKr2fGPWFL8wfFzaSLWG4EK7TngKJwnUliTV/4GXSqGmspx4J4mparP0QLV7e6Hx8hzQxpOLrxFJsuqF7E5GrPCiNeKYWiH3TPi9boHdxREh2fSrHDTlBqvAjPSMuqJpLjsu9c03A3qRZS+LM3Ktwsovx3imkVTeLSPTueTEKEw== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB6240.namprd04.prod.outlook.com (2603:10b6:208:e2::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Thu, 16 Sep 2021 20:30:15 +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.4523.016; Thu, 16 Sep 2021 20:30:15 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v6 04/11] avfilter/avfilter: Handle subtitle frames Thread-Index: AQHXqzmnWMGyDyrEr0+jhZqZ5bRitQ== Date: Thu, 16 Sep 2021 20:30:15 +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: [v7W90IW/WG0i9g0qXVz1mnnfoVqfqx+U] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3b344511-2b28-4a9d-32f1-08d97950ca80 x-ms-traffictypediagnostic: MN2PR04MB6240: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KOMJtyCB59Cs1ydJuNfW58j5mWOxC9kaJZQPmqrtdFwga94SM+F1Z1T/8SCT09iSaaQtSZ8vrIw3ZYi/NEnr2g/bJFvBNyIGQx4OT0kqrklAW7Y0r5VMu5vcpkEk8FYnIMwZAC+3yq4Dj+cCQuak6O6W2PBVQZh4sv0iRV1QlmiiaJXc6m0+GMpkOquieOy0JzFMs1qB1sg6wCjR8flZsThc+hTSVMpJ9VxFpxm7XjVYoB/px20Vb5pcyD5fRxv4Jje++ohxzZ1e6WMVRwTzJNFhPuSWsbgL4iKlVT2r7W9vAAfYAufxxZzpZKhfmpvpM7IOIevYYMnjr8gkwgdJDdXrShTU1sur6v2Ge9RAbLADtyBsvqS/NLWgfg2NKP1Tu9ATUIjEs9SR2wjfHgnZJYs6fGOM0nSxdvKw9XSS2G199TmaL5Tf6fuBbx1R+2gr x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: cD6Fuxbu3iAG2KF/q2ztA8yw8FzApkU3h1CfQpkXOPyQK1T9XILrKi1UycNEgVdfz7eyb0X2J6TQQjH/O/rWIluYvZjrtUfvRKaFqpCvt3awUZEe/WyN5WvADaiKQgvMX4vYLPE85QKHzaWu18Yjbg== 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: 3b344511-2b28-4a9d-32f1-08d97950ca80 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Sep 2021 20:30:15.0500 (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: MN2PR04MB6240 Subject: [FFmpeg-devel] [PATCH v6 04/11] 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: OaokvuD6wOlN 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 ac46bde782..3f303fbafa 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -57,7 +57,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, @@ -65,12 +66,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. */