From patchwork Sun Sep 12 03:21:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30174 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2863166iov; Sat, 11 Sep 2021 20:22:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyW2a2DUdIcoSRpMblIBCr25kLZTOna6SXQjuSyiRXkrpwGwWFsUojfclzUptuofsd9BOA+ X-Received: by 2002:a50:99cc:: with SMTP id n12mr6163678edb.53.1631416964515; Sat, 11 Sep 2021 20:22:44 -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 a10si3643290ejf.122.2021.09.11.20.22.44; Sat, 11 Sep 2021 20:22:44 -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=WQWuaskS; 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 B50A268A477; Sun, 12 Sep 2021 06:21:57 +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 B35B668A477 for ; Sun, 12 Sep 2021 06:21:54 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vyr8L7qm1zK3/GoP81nJ9ogIsejOPhoPiBoupny1bIeV+/2EQiwnU2zs0fUcLTnw1nNtiEghxEHvG6iTHuTGYFjY02bkH0XEQktePdRpTCBKO4h3gdeb0TFmzvlS+aQqSvkJWh2Y0YZjGoJ8gx1AbvMki8/C6TW/PG2FRfhE++4Vvy6w0QzunCnYrIcl7q5Gft+HpiNbTc7ZkS/hcMP8X/f5i9ltj8talFTHvooCFsQBVbkZ46iG+i+ngv2vg2weLwh/tQ162sIjiQJz8nZ61Age1OTI9u9viiQK6+O30Bqcz6THI3CDnueV3+b6ymZuglowWAul6r+oWeE6BkcGHQ== 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=CKO00Z+wopx5s6Ftnr5+qcftpkI9g52J5OuXpmEgG7A=; b=jljzj+vmWluvQpzueRPr6eVE8CwD+VrtIaoeeAs1t7MVd/4Vq4UxiWRy3LiJbruCZFxInnM4CwwuRlLdB+4SceQjzGNvu7uzKByfm8lYyMtjhBGMPnstJ0P5GQUHHHWAljUraRTQySyNClrsmjkyFiRxRSRj3lxXKyDEirpHngfxKPgm0FbjfJDn9NiyId1nfeciDX4VQDL8y8oqMvAziIovPrklzeClYxq7+THBz6+p64kSpmQDMl1VpGoZvcnbA4raOWZQamtNDaGG/SoIa0jBbAX4h2tCbb/B30LE7w6+b7qZSpXPikorynlb+un0q4uRRI83uwd6KTotx0BrLA== 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=CKO00Z+wopx5s6Ftnr5+qcftpkI9g52J5OuXpmEgG7A=; b=WQWuaskSCu6TTqxx1qrFxZrBtqV/0iW2/r1/d/b0R4oO1yUCtAuDsUvXSjwzQ0q5okZY/lo4d9T853tUPYPMfOnxiUhooavAdmj94gLimsr+cQcXYLMrfWY0udMJyv+jsDdCLUKahkUXxpYgRcGZTe4mK2xLa9ZGmLeLZnFa7tPR74BcXekqwQYrsO8Iz0Qa+PuWlpu2ND5oA1WXqyiuB3bnE968xOc4hxgZtX/L4mRBz96/7FEDjhNA6FbpqulHAF7FST27PBEipBqA07aZ027sJCsZ0M0KGoXfO0plp8iJ2zlMZqFqBuZfGdUXcWWl24PGd1OZ+0R3VXeAQplllg== 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:46 +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:46 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v5 05/12] avfilter/subtitles: Add subtitles.c Thread-Index: AQHXp4VQqjiMYp/M4Ei1FKVxt5J5kw== Date: Sun, 12 Sep 2021 03:21:45 +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: [a3F6l4fjLVCrY51ztatJ8wYAjp9XD9hQCKwdzX7GBYo=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2ce90d2b-cf14-4a08-6bb1-08d9759c735b x-ms-traffictypediagnostic: MN2PR04MB5728: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: xSETviGrM44Eh9B1rrd5YsLljLvsyE/Rn11DCfqRraKvVBICu2/6aSDP7yvZ1BZqM/sOIdAIn881kLQ3NoqTURbn4RLmecM+JXzU3PQNbPxSLJACIia9Z8mbjqSyv9FTjEGuVkFojIGCaaJQ2I9/QBRCtzgB1VgiNN7yuFPodG1Xo+8JuHuVZz5ZmtyV2kk72Kz98tFi30mTdzX5Hr8ldaK6QdTOzq8EQ+m/8L8I7O6fe987rxBEfdrnmpFa96i47hjJ+iXdTithCybQ5g8tbi0TzG0v2ZRY0hgyP/jdrClx203XTL7UCw71MUOxsNnLT0vKMX3KcW+TuZdbhVXRF2uwpdmjRyS1fQnx6FJNJL/kUaZ9tln9tYzGBOMtznCWDIkGvYyetBKmxont6RRhGqvB2fGECzWYfxCFlfHCnEBNr8dLbXI0lzEBjKbFoc+U x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: cidPKNVOETI1T1IWx1eh9p/3kUgGNyYTyPQ371g1keSC9O4WXqG13dztbKF0OWvGG9gwFH8FjBOtdst0bP7tDfqfIbphpdm+ouqnNEVU6N7rcX/XsIl9wrdHvLLW2IJJb3kNO45wBTWxI/ZZF7LJOQ== 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: 2ce90d2b-cf14-4a08-6bb1-08d9759c735b X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Sep 2021 03:21:45.9725 (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 05/12] avfilter/subtitles: Add subtitles.c 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: 4fht3UoSPFNF Signed-off-by: softworkz --- libavfilter/Makefile | 1 + libavfilter/f_interleave.c | 3 ++ libavfilter/internal.h | 1 + libavfilter/subtitles.c | 61 ++++++++++++++++++++++++++++++++++++++ libavfilter/subtitles.h | 44 +++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 libavfilter/subtitles.c create mode 100644 libavfilter/subtitles.h diff --git a/libavfilter/Makefile b/libavfilter/Makefile index af957a5ac0..a510dd12b4 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -19,6 +19,7 @@ OBJS = allfilters.o \ framequeue.o \ graphdump.o \ graphparser.o \ + subtitles.o \ video.o \ OBJS-$(HAVE_THREADS) += pthread.o diff --git a/libavfilter/f_interleave.c b/libavfilter/f_interleave.c index b60e89762f..e8821dceba 100644 --- a/libavfilter/f_interleave.c +++ b/libavfilter/f_interleave.c @@ -32,6 +32,7 @@ #include "filters.h" #include "internal.h" #include "audio.h" +#include "subtitles.h" #include "video.h" typedef struct InterleaveContext { @@ -170,6 +171,8 @@ static av_cold int init(AVFilterContext *ctx) inpad.get_buffer.video = ff_null_get_video_buffer; break; case AVMEDIA_TYPE_AUDIO: inpad.get_buffer.audio = ff_null_get_audio_buffer; break; + case AVMEDIA_TYPE_SUBTITLE: + inpad.get_buffer.subtitle = ff_null_get_subtitles_buffer; break; default: av_assert0(0); } diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 6ddf024d93..8a9951d20e 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -90,6 +90,7 @@ struct AVFilterPad { union { AVFrame *(*video)(AVFilterLink *link, int w, int h); AVFrame *(*audio)(AVFilterLink *link, int nb_samples); + AVFrame *(*subtitle)(AVFilterLink *link, int format); } get_buffer; /** diff --git a/libavfilter/subtitles.c b/libavfilter/subtitles.c new file mode 100644 index 0000000000..90ec479e51 --- /dev/null +++ b/libavfilter/subtitles.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021 softworkz + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/common.h" + +#include "subtitles.h" +#include "avfilter.h" +#include "internal.h" + + +AVFrame *ff_null_get_subtitles_buffer(AVFilterLink *link, int format) +{ + return ff_get_subtitles_buffer(link->dst->outputs[0], format); +} + +AVFrame *ff_default_get_subtitles_buffer(AVFilterLink *link, int format) +{ + AVFrame *frame = NULL; + + // TODO: + //frame = ff_frame_pool_get(link->frame_pool); + + frame = av_frame_alloc(); + if (!frame) + return NULL; + + frame->format = format; + frame->type = AVMEDIA_TYPE_SUBTITLE; + + return frame; +} + +AVFrame *ff_get_subtitles_buffer(AVFilterLink *link, int format) +{ + AVFrame *ret = NULL; + + if (link->dstpad->get_buffer.subtitle) + ret = link->dstpad->get_buffer.subtitle(link, format); + + if (!ret) + ret = ff_default_get_subtitles_buffer(link, format); + + return ret; +} diff --git a/libavfilter/subtitles.h b/libavfilter/subtitles.h new file mode 100644 index 0000000000..d3d5491652 --- /dev/null +++ b/libavfilter/subtitles.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2021 softworkz + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_SUBTITLES_H +#define AVFILTER_SUBTITLES_H + +#include "avfilter.h" +#include "internal.h" + +/** default handler for get_subtitles_buffer() for subtitle inputs */ +AVFrame *ff_default_get_subtitles_buffer(AVFilterLink *link, int format); + +/** get_subtitles_buffer() handler for filters which simply pass subtitles along */ +AVFrame *ff_null_get_subtitles_buffer(AVFilterLink *link, int format); + +/** + * Request a subtitles buffer with a specific set of permissions. + * + * @param link the output link to the filter from which the buffer will + * be requested + * @param format The subtitles format. + * @return A reference to the subtitles. This must be unreferenced with + * avfilter_unref_buffer when you are finished with it. +*/ +AVFrame *ff_get_subtitles_buffer(AVFilterLink *link, int format); + +#endif /* AVFILTER_SUBTITLES_H */