From patchwork Tue Sep 21 23:54:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30439 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp2919149iob; Tue, 21 Sep 2021 16:55:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweXTe9ePTb2U+OIio8EFniEhHm25nDZrcpix6eizAre2hw8aco9s2pKtXIQ312DFedxGjy X-Received: by 2002:a50:bf0b:: with SMTP id f11mr23861652edk.134.1632268524106; Tue, 21 Sep 2021 16:55:24 -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 s12si530937ejc.488.2021.09.21.16.55.23; Tue, 21 Sep 2021 16:55:24 -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=Fvk9ENpV; 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 0D8F168B098; Wed, 22 Sep 2021 02:54:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12olkn2108.outbound.protection.outlook.com [40.92.22.108]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A79B68B08A for ; Wed, 22 Sep 2021 02:54:47 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgBQ9vPc8eKPUwBAHKtsrhVzy2OTcFYR0JjNJM6YZHVXs3ZhMKYJCYnSF1sfYq5M7IWdGeXhAI1nsEpWlJXT1QDt2YLDLA+3EWVLjLO+Cl3Z6RIYaWlSJq4szFjpYkNe2fj+fcUqI9X/rxTm1ldr2DArxy6y427/jptofa9Dw5GzYwubanldrdj2VVLfGC/AKc2SUcNoOBGXYV4SdJ3by8kjBAfIGKWVOD8QVB0x3apJnVCHcROhIjAH9HDXzzffCpMmFCIxDYhu4F3AYi9Rxb2aRHOXcmqdPycONBukFBAlG17sTIDKOb+FwZmqGTvFZIXoiQHDOSUHQ6RaDv3i/Q== 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=NIgyOMw9fqwN/sBrJbogLGZkd/if0/rqbkNX3QMKS5A=; b=oKZVlom8T6iio/4TDTiPr1O8V143CgQDx4tzeGg07+ErYVWpOMKKDmxbQmhZoPDKQJklhb9VqMKOY6TAe+TPuI29qxqyDlj6m7Jgc0X9c/hDLTCT90Sb6Q10Yg2BlOBCZlxFDb3UD/VDE9h/StRVeZaAQpk7QV7qu23zVQ4Ru4MRYf8ImEGbv9IwLXYKw6OqORtyuORmcD1OPIFek4LT1p9k9lx2Lwnz3gi4Rxw4TOawIu0rpOKjqLNYrr0cbVSHvlMrACbhOtqZ5T8hyFaSXXkoG7aE/QQyh/CCkOJgHqmvGlxHxq2opEfw7Xf6GXXxTDVKf3wDQQGXFXVxqUpWAA== 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=NIgyOMw9fqwN/sBrJbogLGZkd/if0/rqbkNX3QMKS5A=; b=Fvk9ENpVDTJ5v/f5Mz9aiVB1qfT7ZUUVHFxJ8KOye/y8eEYlWQAWwsnm3M9qMJUtYRs6Udl2NzA2wDXi5l/hHHSWTJ5PxvSrMBDZn/zW5RfxxxUXpvBYgYToH8WkAEUBwzKUnE6YU12yrV8+tiqCaScGze24q8pY0OMN7fngAN1pUxJ7onYX4Q5SMhhdsl5cVobdmaDFC53gpYB0jB7+o98WQkU/nTTmr11C3UtBBxLlLhV3APGaZOsBta3NKp7l08jBer7cXEw+snufzXEofTjejiEYBbjnR44N8J+T07osm1CN16y7KxEfOc8XdeBAKSOv/N8hPSRfFu4bk5fr3g== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5808.namprd04.prod.outlook.com (2603:10b6:208:a3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.18; Tue, 21 Sep 2021 23:54:37 +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.019; Tue, 21 Sep 2021 23:54:37 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v8 04/13] avfilter/avfilter: Handle subtitle frames Thread-Index: AQHXr0QHUj4oxfg3hkOPUSjMK1m+3A== Date: Tue, 21 Sep 2021 23:54:35 +0000 Message-ID: References: <2f4d7190c46bde35cfef16e74900bd11a42856a8.1632266268.git.softworkz@hotmail.com> In-Reply-To: <2f4d7190c46bde35cfef16e74900bd11a42856a8.1632266268.git.softworkz@hotmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [8cPabkWYQIG55SQe6RrByt/j+yGCkMQS] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0c0f477e-5689-4f02-9de7-08d97d5b2b8f x-ms-traffictypediagnostic: MN2PR04MB5808: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: P7dz6SfFRA1AVZLfeR4XpZZ7H63+HeVDV5Eh0Sx2ZYkD9lulrE2IQxR6wDEY2zIy01pXm6Uk6tazqiNoyhtJPi/003z+ovf/RHXOLCzEm/xVxk4mzoH6tihWd+9gWtZyVzkkiFw9ecCZTPRqS5F3BfIEyAu88VWytHKnRKaTpWfcH8cwz0ediPstBsRxMsgcXTiOsIQGEed/0OHOQc+a1FLxMeKMfYBg7XBEfts9R0DdDfKM1MZ3TihhWeVlB4TZo+VSAg34UMYirOTlxE97Vfd6v0hXaWyNwgMsmbM0N5PDOukEANFQMkhEdCuJ2aB9iR/5aH/mSsSBC3xxhlXLlrDnmJw62wcTBxTjks6okPhj40Hu0CtCJg0iJ4vySqogZX510kTKZGzqCdyxVbzFqYZAfUiG0b47V5g2AgZyJKsfsGC+VkkanDwy2bmrDgEs x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: Py8v6IedA9BaIg1hTaoyyWj8jxDHM7TjBYtvRaNtJIldL/FfJM2abm09VdzZHseChL9OegtcpatHDngkFXeZsNY+ANnpiyRQgWH6r3WBK7CAal8oJ+7CP26dLz/vmG4YaCH/ElujSoS8ob/Q5yODdA== 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: 0c0f477e-5689-4f02-9de7-08d97d5b2b8f X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2021 23:54:35.0738 (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: MN2PR04MB5808 Subject: [FFmpeg-devel] [PATCH v8 04/13] 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: 5r5zTJfrFvel 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 ef349a67f9..c567b7893b 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. */