From patchwork Fri Sep 24 00:30:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30526 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6506:0:0:0:0:0 with SMTP id z6csp987502iob; Thu, 23 Sep 2021 17:31:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzUFtq7FH1V1z8aEcPg/jSIKC0slTtQPblWokR8Cqoc9ujYtZikhbhCPeCPrpzJ6ABWk3N X-Received: by 2002:a17:906:8a41:: with SMTP id gx1mr8612258ejc.507.1632443495101; Thu, 23 Sep 2021 17:31:35 -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 bf24si7749970edb.7.2021.09.23.17.31.34; Thu, 23 Sep 2021 17:31:35 -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=Pdbs88EQ; 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 D9E1668A2F4; Fri, 24 Sep 2021 03:30:59 +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-co1nam11olkn2100.outbound.protection.outlook.com [40.92.18.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B4ADA68A41C for ; Fri, 24 Sep 2021 03:30:55 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D/dkxdR9aBzjt+rVRy/szZlOwFk8p7J6o2lla9ZfH2e9znAZCxM8+SJZFKJOyIqbwsxaUKsamyBfvWIcmu9sUl5Be/NfisERdW4IKvhEDa3zieXmXkklrkaq+0pNAxr/y6iWVr3sTFkOE2wnM2/GDy+NUQ0iJuutbdFaXi616m+/l1DqsO/ecwj3wo6bdDlB7AcE7jPUeM2QWsa99zef4i3B7YJC4e2hRoXcSUYnXuVqBrv7JiahArmItXhcjIO1zMbJ+fWzKnky8uUQu+GzTTGsknSKwb7HrGH345TKJ4SzCfJ9XIgqamv9/QZwliy5quSgjOt1a48bEUymcLp8CA== 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=Joq8Mh0BUC7n8Q/ZS3L1O4R/qXA5zV6APYAT74FXRbJPIU6yLzL9kKkVx3LIyPuF8ZV/eRg1m4KZHgUferRicrRHmyzmRbYoFma0zasqmDw52m4K6kjWTgg7jxw9w7BUjcJ0UC+/RYYfNQod4rbuH0tB7AMyuJOxQnhYKgrNwOmXqNtJ8nMz2eNO3lDFMaun3vcjFn1OlNC3DmZCLPasCpSAZGyqafIKuTdLl73Fu9rCSZdHgl+giMz+EYt75Kc4WrigLxip5ul/PXvnw/9oSwG8EMpHKqYuhevWmVgyrjTlHoMrTBXiPaZUAClPArxrW9o9Fn4Og6bcN/8C4E9oKA== 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=Pdbs88EQEkjYSVASsN6FJFKMrb5wAP7rsZmMfBPn3UT9BbAmJqZgaF0ueLA0izf4Rubw0Aycnq/sq8WIjO20JbRapIYpeT4RNKNpXU7CTRx4vqJNzMa9E6sVXNqXRgprMX3SqFhzjjSYyLxCTI7mn3WB1wxKe01IgLl2dQi/2CEToUDg2k9HFn7GLSBnCnvI990eOYBgMGqXR9m7rag7HqucS48vHtqqGrUbxNOkPAOXc5+miEbAzPYNChvhUzVckqhe0HsoM4Wpnw1QvjHEB1i+vK2mH/t8clve2BSjGvOvjzF0Q7/vOWNVpuemrAVzW+Ukq190ZTUSdh2mF1Vjdw== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5743.namprd04.prod.outlook.com (2603:10b6:208:38::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Fri, 24 Sep 2021 00:30:52 +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.4544.015; Fri, 24 Sep 2021 00:30:52 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v9 05/13] avfilter/avfilter: Handle subtitle frames Thread-Index: AQHXsNttVWpHHsjI90O8rBbsmMEYPw== Date: Fri, 24 Sep 2021 00:30:51 +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: [qp1VGOzoudImvUZAHKbuPLaj+x8dTk+u] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6d2e0f49-e237-434b-ee88-08d97ef2907a x-ms-traffictypediagnostic: MN2PR04MB5743: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Rph9sAmZW9JXklF7k/VnBmUbYl+nb2H21UlZ30X8IaCTWCCoMGo5JCqOYDAZ8ZmkC9d6rsrvMCNVO9UXmPj2H1oB+iW1B1Ppmg1l3F8x/dCrw08hud/Xtss5H0l1D5hiovE8ha4MjPUjVl9UJDSgK9m8okxI470dbFo2AZlz6Rq4S8VvCVZz4kiIu/CPg6Hg9nXxMzGljkQpXv/qcxZjlqHLLBLMjaHaB/8DPv7GsTSNobfB1xqXxgGcAYseV3F1K8uN34saNWt3heSYTKmmLzwonCwqs9o68kUleGUgKeNJRsG7+bU2nJJCTCNK/LgpU5K0D8XQ6oSDiqXX8ojMfII7V6XaaVKCMTmQC5ont6z9auln2v+uroeUoHBAheA5jRJ+lisjFn2t4sLZvk+Pug0BauY48ZB3iQn2tvQ6kmyJWlbprs/tkeSR6wAGgMZG x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: H4ZqMlrDmSiT0UXmc94XVgpLFd7c2tF2OwLQ3dRwNVcYDVl4gYlVDfosf7G5R6xz7N62A/yjin+66weqZH31HcW0iSFVAnlUfk0jE7PCcg0e+yMvdZUxoZ1A+jbqhIbpte0vthSLQvHVXqblDMUhGw== 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: 6d2e0f49-e237-434b-ee88-08d97ef2907a X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Sep 2021 00:30:51.9967 (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: MN2PR04MB5743 Subject: [FFmpeg-devel] [PATCH v9 05/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: o80CPzHS9pem 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. */