From patchwork Thu Aug 19 07:43:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 29606 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp64324iov; Thu, 19 Aug 2021 00:43:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR/MgHDKZlu7YSeoee2zKQR7iiqY1qZ9LcwADMGWxNG8lOG8KDSC1mfQ7VrlFAF1J7AXaF X-Received: by 2002:a17:906:b18e:: with SMTP id w14mr14402910ejy.63.1629359021303; Thu, 19 Aug 2021 00:43:41 -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 ne31si3033465ejc.157.2021.08.19.00.43.40; Thu, 19 Aug 2021 00:43:41 -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=OkDdVjnO; 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 2643B6806E4; Thu, 19 Aug 2021 10:43:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11olkn2099.outbound.protection.outlook.com [40.92.19.99]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C8E396806E4 for ; Thu, 19 Aug 2021 10:43:20 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lPTRN9cN6uL7zq6aeygdW0n+7AiVQ1zxFD0HHcq8ePnuSR9WDzdUrer+7rEFC45Kt+/wKLsUK6Uj/fVR+nH6qx0f6WlLLj43MM/eT24zuATjGTvQhIh7/W/4md7qE0BnDgHhiDZ4TxUZhnyVF/hhLV7CTSwFKX6tCJlEcnreBW82ciT09uDOtuxxh9/ZiXDUY0Uk9a1xej4/wiKxyTK5Vu9sq8+FmLz/ZciDOAnzJKon/UqW90FVazY+KetkTKXvQBOR3p4LKtuNiAhZQ89MPPs7HZiv9QILrUWeValaobaduxDtGICfgvbDR+RLjC6Kl6LSRgcRtH8fcCZq9JecEg== 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=aStZ7U0TdMMw6ABbS0cNG7BM0ubvGM3ndz0EMcIthtE=; b=dcy4132t2CjhZnMgOkSyyWIEberuOo1AEfgMzJwxXHFzAu9ajBRulzUWm4DSeAgxzvDthtWFxbg9nBd4CQgDBm5GKTZgkLY0MHHJVgq/O05TNmbCeILVZ7hnkUZXdvMHNVHQvSdcUAcuQrjyByXYXj9QQ8g5vMmKOYnZPvzI7k+1pS2Lft/piv9XbC5fWwEOtxc+NlUmH0Iz89kLrey/6yHjonD/MnuuRvF6CxYwZpCaZh/Jh1vjkf/CHyLUS/BNpzZcr60OIZrtezOxB19fGjTiWHDIxymz9b1cyg6O7bDOg6aK3s3xcBtee43VdAafOPyu6YB48evPofoF1GV5qg== 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=aStZ7U0TdMMw6ABbS0cNG7BM0ubvGM3ndz0EMcIthtE=; b=OkDdVjnOziSYJIpRytAKcpqj+tp+3/dsprF15ld+XbI7O3AUoVoRm60uhK3IoUTHIKWdWe4MKGU2XlblV9rj2VlKU7rapfyPlyk63c2Xav5ZD1Jkc7aO3k2rZGgxFTvLUPwR2b9LDzoUDue49MCBDuIah9YnRimkOd8oyfLmpvUTagiMDqq+gwxH/8vKOA6b+8E9ziQqqh+8z7+Jzg5zeg5EGQCRY3t6NFsJKsrLpW+Q7cG88QzpaoWEjLKitVgCRYerx6fnximS805rbG+9IPjsXys34IbiBAuMNXLfPGAi/OfX4sfEDZVwxAxTkfDc6iQZJWmRITP/R0s4fM9TJw== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB6255.namprd04.prod.outlook.com (2603:10b6:208:d5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.22; Thu, 19 Aug 2021 07:43:13 +0000 Received: from MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::5d83:1c26:c2b1:3a30]) by MN2PR04MB5981.namprd04.prod.outlook.com ([fe80::5d83:1c26:c2b1:3a30%6]) with mapi id 15.20.4415.024; Thu, 19 Aug 2021 07:43:13 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH 2/9] avfilter/subtitles: Add subtitles.c Thread-Index: AdeUdgfh9/D5ComkTyS1ia3MCgrGOA== Date: Thu, 19 Aug 2021 07:43:13 +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: [wwHBVQcwWY+fkz8lt+r6jOL6ybeYiqgh] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: cf2669e4-7dea-4e4a-a5fd-08d962e4fff5 x-ms-traffictypediagnostic: MN2PR04MB6255: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kGt6zlUgn3WWaLbzA834uPUIlf98bfLRiXmGPAhsdi7bR+lRlImEDbUArM81LMgQ7T04lQbEVBdpmFwuEjMwjJJggcRhpVvzb4ha0TrNtkQhXatstUvj+xbVpAZNXzrnRyJDlrMyP+K8ptguZ9PHRO2OLsV1rjA61OnyZVwFtv7d8L48OrS4X7FTrmglQj7zT9z+AAr3cUQKIj9q38BAnq9G/h8DryQISnCd8bOubLYnDB+gCvQu2COuIYu4T2hBU5v8Ehnf6WEjQeJC2V9SZb0QMgpEhS/jxx/WVIlQOtHLaOrhPudO168SKmhTO0GRl4YbIhNt1CiRQF/Xlpt/cKYedz2aSdLMoKmnQIdOEF6wlvT0YywFxLLe3JO3D2nHchaN+JZAD/rod6wRQj6ChvbPI/e6EilRnSThYKex7arZJHZi+DdNZ0SOoAAxvq69 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: 8P8pr0Zz7sEV/fcYawhhZQAOVzHYkig7++lu76DfeGlJR94OpAzlouTt26O6NJY0KObXME5hsD7a2O48UHDm+IRsBSIeY6Pb/b3S0MKHJesWROAS+0aaLK00t//fIM2d0tMM+RaH4kqThjHB/GP+pA== 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: cf2669e4-7dea-4e4a-a5fd-08d962e4fff5 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2021 07:43:13.5320 (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: MN2PR04MB6255 Subject: [FFmpeg-devel] [PATCH 2/9] 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: ayYmfkcJzhpW Signed-off-by: softworkz --- libavfilter/Makefile | 1 + libavfilter/internal.h | 8 ++++++ libavfilter/subtitles.c | 61 +++++++++++++++++++++++++++++++++++++++++ libavfilter/subtitles.h | 42 ++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 libavfilter/subtitles.c create mode 100644 libavfilter/subtitles.h diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 102ce7beff..db32cf1265 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/internal.h b/libavfilter/internal.h index a0aa32af4d..4f9aedf151 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -87,6 +87,14 @@ struct AVFilterPad { AVFrame *(*audio)(AVFilterLink *link, int nb_samples); } get_buffer; + /** + * Callback function to get a subtitle buffer. If NULL, the filter system will + * use ff_default_get_subtitle_buffer(). + * + * Input subtitle pads only. + */ + AVFrame *(*get_subtitle_buffer)(AVFilterLink *link, int format); + /** * Filtering callback. This is where a filter receives a frame with * audio/video data and should do its processing. diff --git a/libavfilter/subtitles.c b/libavfilter/subtitles.c new file mode 100644 index 0000000000..188ff1289c --- /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_subtitle_buffer) + ret = link->dstpad->get_subtitle_buffer(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..b964b61c37 --- /dev/null +++ b/libavfilter/subtitles.h @@ -0,0 +1,42 @@ +/* + * 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 + * @return The subtitles format. + */ +AVFrame *ff_get_subtitles_buffer(AVFilterLink *link, int format); + +#endif /* AVFILTER_SUBTITLES_H */