From patchwork Sat Sep 11 06:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 30121 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp2167854iov; Fri, 10 Sep 2021 23:04:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyazU6xib0Wnz3qRFyS9i02AtuuzhD3vJuPcVtSbiMHtAKNoBs+/kGRW7waTNnn9iB3EaNQ X-Received: by 2002:aa7:d592:: with SMTP id r18mr1766316edq.172.1631340270410; Fri, 10 Sep 2021 23:04:30 -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 a22si998834edy.561.2021.09.10.23.04.30; Fri, 10 Sep 2021 23:04:30 -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=hU2R19VQ; 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 6284A689F4D; Sat, 11 Sep 2021 09:03:07 +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-dm6nam11olkn2078.outbound.protection.outlook.com [40.92.19.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A9C556804A0 for ; Sat, 11 Sep 2021 09:02:57 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BS4nf31xNzsyppcZNFVHa5dNVfGvAuCQItbFqECb0L1J8NckOqC6O8UInXr9UGR6d02xQhPxhDHeCKUZ9P4SQnXeIhiz/+CYtGjZHXq73pZYWgXQzSWVMY8VlAoiqP5bYxEZfEUwG7dKGOAGZKBh4yPD9Wm4NVn8wXoKz9fqqgu0gB2da6Rl84xS0M7mXlSiNOmKuwHGo/grCKUwt9YybLb1PZTgOoDP4CLr+PfKFb5r9G4wmFpfZhceDu3KoQUH9fxNAEIiPN43ZqMi6XKp7eYcHMA3p1y8SKx1SaYFxvvlAk5ZSfJBCFPGpJkz2VrtXDaPJiAUtMQCCcR3Haw4Pw== 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=m/L9kFouJhbaoutLNkW/URHRVJEnVxCP9d8De8r0V/Ac8OSjAjQ4gpx+vsimE9zBSYDhQSYK7DqBNh23f91m9rN/fCpPZC75/BNOj5uojWblBirL/n9rDibtZLaafH9mZnczi0ZqHpBaKXZiPXBsIlDl0RJ9JvfHd8O6slt/7V0cLnPK1W19bJ5WbIKMjaeWrfaJWXMxFPKYZgyDTRn57mY7i281iAjDPiUfbKJ01w7aBBrzBH2uhjkVn1gHXSuRpVL/IRdudteh5rx1/FsO+VOCPrsZbXfA7WZ70RtovIXXhWMkTa8rt9B78uDGm6Zg7jsUNSuox2F0g9w1QybBBA== 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=hU2R19VQMl2lxojFONEdIPnKDO6U2bf8huOZI8I0C9eXMUf/3dQOYkyAxQkUz8g+TrRuWmzQg83wK5+OWCmq6hHKTGGP2EnjEFifcJ25UC1gUXGOUB9K8Arj4hJ5atVylpYQQq7MTmUfNuVZRkiUUEll4aJb2WT13T2qngm9xIzoyurfBwTg9soa9K13ROtugi4CTPlzC+x4hia3c4XDwIzk6+HQgmmXsTrmYJzwbwT25MeqtYg5oA4u8/pkWU2VSF2hieb4QFJMbUHNsRTQ4v26OBin5H+EB+DqFAkF6RvaXo1yQTijO7gxgOoMBBp5Y8wH0/pjER/K2H29AZBDGw== Received: from MN2PR04MB5981.namprd04.prod.outlook.com (2603:10b6:208:da::10) by MN2PR04MB5776.namprd04.prod.outlook.com (2603:10b6:208:a2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Sat, 11 Sep 2021 06:02:55 +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; Sat, 11 Sep 2021 06:02:55 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v3 09/18] avfilter/subtitles: Add subtitles.c Thread-Index: AdedcjHqTEHvIfSYQeKZnsoPIJEEXA== Date: Sat, 11 Sep 2021 06:02:54 +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: [buzUkZZmnJyy4FKUTiJ2J6DxGHQAzvsj1rp7sNrjuKM=] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5a725c3c-d207-4b98-8b60-08d974e9cc25 x-ms-traffictypediagnostic: MN2PR04MB5776: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: U3Tw+sEv1dXLoVMC7VdLbtargpzLygicS3vLs3H0PfBRJAlIKuwRl2j8Y9wcwhSePIBKyod1/Q3plXvCq2AMzZ1qCEfE15C5JzNoQAw8jmZZGNhYMoPPBm0rbMGphHjHGNfPl59WIc7+mpTUecsyrdDKsvWdBEV7NFCFYneDWhK67vHUGibhwGWaBu+sFN9IArVdqZSkN5AI9fYB8VABDNuz483eslheD5vH7KGTUrLkD29TA30ZuBKx6MXIJQqpGrM8Yf3Bk78Me/60XpFt56vtHPqeseAkktX/RBSlAnLya0FnHJMCXJ1bJRJo/ls8lqhMxljk9xcvA5EXG3qwt1XpN8fdq2WjZPFgqimG0vWKO+Os7nAgXb69GcU7RPRgIl4/BTDNssHzqpJYvaLVkCmXGu1KkK8aifh3UUj6Ev0VdGVLMRrU/s4a/Ma5qkab x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: GkxtyY3OHDxf7R2ixsw4ZwIHHEqNrhPwgFqZ2QmhTUYFv56K5P32rD3JiWq9oBcdYho6gaJJiAHeZlTXeHW6jR2F8iaoshreFc6WtD+yBoqs9WlXP3G17KlyydHkiKhV/jEScstL+J2sMu9e9Cl5AA== 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: 5a725c3c-d207-4b98-8b60-08d974e9cc25 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Sep 2021 06:02:54.9990 (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: MN2PR04MB5776 Subject: [FFmpeg-devel] [PATCH v3 09/18] 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: yYzucSL6YMsY 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 */