From patchwork Thu Nov 25 17:53:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soft Works X-Patchwork-Id: 31680 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp1098736iob; Thu, 25 Nov 2021 09:55:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5EGfHC3eNAmVl1UVJzEU0aWWgaRYKlgSNFbH8bl2v8ldSbHG8m85zwsg3LMD++/NCeQ7G X-Received: by 2002:a17:906:b084:: with SMTP id x4mr33127643ejy.214.1637862948509; Thu, 25 Nov 2021 09:55:48 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fp5si6071193ejc.517.2021.11.25.09.55.47; Thu, 25 Nov 2021 09:55:48 -0800 (PST) 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=q0XbZcD6; 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 D094168AE42; Thu, 25 Nov 2021 19:53:11 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12olkn2096.outbound.protection.outlook.com [40.92.23.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A40868A990 for ; Thu, 25 Nov 2021 19:53:09 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ox5PrtEOMDWZlN+RMp7NIA/mYvjW1awzyBlfn0W2KjhBKhl/4dF24hVDtxojMfRxACpYH2PwzTRqi6wpwY9nB6bflaIBPSWTNyEttUq/0vvxQc2n2Ag+An3fafZPLeefdmUoO5QEG1Y1Xed38BMG0U29IOICCn8pIrYxm94+eHK5UkmYjKn5sd7+arFH+MR7QkZouEBzrn6MN4TOqb9M4zLaTqQray897X48mfZxVpjDPxF73ESjRrhvmICVaaSzNNTx2/jSjGiS4wcqaCQtazuW+Qjcnnc3ulru1Gkw+CPdL8wDfXcQqaRaJhdmHcK/dLTDGI+waEpRZWB1U4pOdw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v5gpq/nWaWx7GForJeFN0kMPQngSZrpiD6rtajUMXUQ=; b=XU7YmfptG7lEd6RfJEGgrlQCds1Wtkxa7Cz+isz8yCw3PJeeY/jSegxsmvFfDTE1PKYTspHbyaDdmE0nGoWz8MhmWDDiRCV/saH57Phu/J/y1UUUWbm6KqEeyEvbKf0TpfY+o8uONlKuo4/pp2gWiuPz4Xbsv3fGKfJPCDrBHUopj7fPSEmA05EDHcs5Cgi1f36iCNoYCuwO4JFdBk9AYFcQdvlXLdkNIwoUOeeQilQIO2hinnBDIf9I4xufntUcTPMZOsv7aednDbjge6hrpNYmfjYvdIL3/dqfY09kFUsUTgXvtg6QXk0fggICdkiyu89ojvLA9qS2HWXRWkEPWQ== 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=v5gpq/nWaWx7GForJeFN0kMPQngSZrpiD6rtajUMXUQ=; b=q0XbZcD6ad0UUR4l5yUQrWtPF3Sx1+WoVQViNFJozru+301fPpwlD7VyibiKQ8POcoc2b3f/JEpIZo9U8i8chEJE9BUey6HOCjkQ4SVjA6TdFzK1KBw7UAEgqrAVFPSita6lT05VB1yA0bYntiXKWs11mi1m4mZCta3DghzEG9CcetLm2+/UcK4Kr/+Fx1M4U/6TKm83hhYIZrvMk8I7zy8vf0JXue86XU8oB4Ees42ZLyT9tWXSB0N3MgNq7HhD5UbWlbdQ6LCsPAO7BvZvs/pGs8nhlq9+kWTTWmPwHfLoGckmS9plB6p2XSCBdE5sDTUZ+7M6p5nRSMIrSMqscQ== Received: from DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM (2603:10b6:8:b::20) by DM8P223MB0112.NAMP223.PROD.OUTLOOK.COM (2603:10b6:8:5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Thu, 25 Nov 2021 17:53:07 +0000 Received: from DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM ([fe80::9c8d:fc63:9488:9775]) by DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM ([fe80::9c8d:fc63:9488:9775%5]) with mapi id 15.20.4734.022; Thu, 25 Nov 2021 17:53:07 +0000 From: Soft Works To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v16 00/16] Subtitle Filtering Thread-Index: AQGhWlzKNcMC5tIs2zGwnKZRCOu+Pg== Date: Thu, 25 Nov 2021 17:53:07 +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: [ZQ6qvqixsCyaLNAJYBZemJbpvGnlMePC] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9ef8e13e-c92c-4a4e-db0a-08d9b03c7006 x-ms-traffictypediagnostic: DM8P223MB0112: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: LW8VrTgMYSjXjFJsyNPkaExZv0CGKT+P9SncYPrEg5q+QtdMWRU2wmV6Hvt8IK/JbY62GaLU+PR6CUnJ91X78V5HkeUQYeE8feO34T7EQU8bOtMziQ08zDwTA88AaPbel6+f0JuPHHxeIBjQdFdJeBBhqg+krVxY3GVfKOgijCM/Yc2Lo0pvnAXtIzCS8z6O4tIldlzLR9I19IhsehrgHI8rXUp3nLOzCgH4r0LxPCdS+5b8sZlLvQJDV9/n7j9r7013rXXzfTug8BhhZKD3E1YxC0MU9nkV3ZVpbqfA6l9bIyo7yQXcvLsffRyJYXTD4MvgJT1aDc5jmi07S/E7QCxxXSAy1SGXrdsUPjrBmNHOhRXQPru9K8wWnZDiYD2Dp2r1IwUimkDTU38JDpIN+ub0KaWoDpKdu9hPslSObsFMXIGaHVjuBpogSOv2tCg/zZ3UKm3hbULfNIbICVxieenJIx26vJy6inKXOqvzuBJbVdH4epstp9B1pGumNc9JWmDIYCaEM6LmGCBT1Mac0oODuAIZuor34m5b1hd8cUTFjD0sqdQjfLQDq0mf3ew1EOADcDAX1WZQpfQAMEH9gQ== x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: H0j97TWUmj6aPx6uA9WaYTFpkddHzrvDTorLqGgAmkzW1GBG10tn+UQRwSATFMvVjb5ihLsxUJjHPAuoW2EEl9iGl9hqjyFwqYUgycGlpmKjWg8ynJE19n3tAH5LkzDKFZjH5QMTOjWARIEyOqmde/o9v58R6wdmHPiL1tM+Gzj0W/U/xYnAHHK6+pVC5edjOs22mBv3Uwg7kFYHpjSjIGuMLSprh3UyH7Zh64EYBVnS/iaaLaOFln2ZZW36ZtNT0gOjIFaNd0HmiEx7a9LD5ojjkv5oboWladvzHW/BXnITHrnHaMeWwQy97jAmTvifD2hNeL9kh9FyIdsBA1zMvd2X7DCQCKmGJ2T2aE2Sqt+RjJzYKvy2N8+4hDSooOGQ1089wh5u/2UGo+WnyOAk789Ur9omHy0XEgmBnjghT7/CFsTPTNRU4Ra4RwlCqUmQxOQuBtEgENziW3ZWYRFkxHW1WOGGv0UwMZeqLKXvqZ2QcBur3A571/2JcB2reT5n0y5d/rLmhCshbEhbpLW5ztE6FHguJmsbQYYflJy/L+FJbYV3lZzK3YeoLej/27uZhs8r2Rh0HRGsI7yRJKbxztum48NPYR0xCP1Aj4Wz294yt1kTwW6sle2iHscBam9V8fOpfeD+YQfhblaV0XPw+gqxa97OP89jMF98oksohT1JAYPj+SvF8ElHwxnzEvmFKES7qePbRRCflVr3czF/vA== MIME-Version: 1.0 X-OriginatorOrg: sct-15-20-3912-16-msonline-outlook-1fc6d.templateTenant X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 9ef8e13e-c92c-4a4e-db0a-08d9b03c7006 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Nov 2021 17:53:07.2932 (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: DM8P223MB0112 Subject: [FFmpeg-devel] [PATCH v16 00/16] Subtitle Filtering 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: tlsxkdMEcQJH Root commit for adding subtitle filtering capabilities. In detail: - Add type (AVMediaType) field to AVFrame Replaces previous way of distinction which was based on checking width and height to determine whether a frame is audio or video - Add subtitle fields to AVFrame - Add new struct AVSubtitleArea, similar to AVSubtitleRect, but different allocation logic. Cannot and must not be used interchangeably, hence the new struct - Move enum AVSubtitleType, AVSubtitle and AVSubtitleRect to avutil - Add public-named members to enum AVSubtitleType (AV_SUBTITLE_FMT_) - Add avcodec_decode_subtitle3 which takes subtitle frames, serving as compatibility shim to legacy subtitle decoding - Add additional methods for conversion between old and new API New in V15 - Added missing reference to subfmt.h iun libzvbi-teletextdec.c - Fixed Fate error in patch 15/16 - Removed all trsiling whitespace in tilers.texi New in V15 - Rebased to upstream changes - avcodec/subtitles: Migrate subtitle encoders to frame-based API and provide compatibility shim for legacy api - fftools/ffmpeg: Use new frame-based subtitle encoding API - AVSubtitleArea: copy flags field, make params const - graphicsubs2text: Don't emit duplicate frames - graphicsubs2text: Combined OCR output into a single AVSubtitleArea (I have a prototype for detecting text colors and positions, but it's not ready at this point) - splitcc: cleanup local subtitle_header ref - stripstyles: add parameter for ass layer selection - avcodec/subtitles: deferred loading of ass header for text subtitle encoders - verified all example command lines in the docs are working, added somre more Kind regards, softworkz softworkz (16): global: Prepare AVFrame for subtitle handling global: Move ass helper functions to avutil as avpriv_ and extend ass dialog parsing fftools/play,probe: Adjust for subtitle changes avfilter/subtitles: Add subtitles.c for subtitle frame allocation avfilter/avfilter: Handle subtitle frames avfilter/sbuffer: Add sbuffersrc and sbuffersink filters avfilter/overlaygraphicsubs: Add overlaygraphicsubs and graphicsub2video filters fftools/ffmpeg: Replace sub2video with subtitle frame filtering avfilter/overlaytextsubs: Add overlaytextsubs and textsubs2video filters avfilter/textmod: Add textmod, censor and show_speaker filters avfilter/stripstyles: Add stripstyles filter avfilter/splitcc: Add splitcc filter for closed caption handling avfilter/graphicsub2text: Add new graphicsub2text filter (OCR) avfilter/subscale: Add filter for scaling and/or re-arranging graphical subtitles avcodec/subtitles: Migrate subtitle encoders to frame-based API and provide a compatibility shim for the legacy api fftools/ffmpeg: Use new frame-based subtitle encoding API configure | 7 +- doc/filters.texi | 756 +++++++++++++++ fftools/ffmpeg.c | 553 ++++++----- fftools/ffmpeg.h | 15 +- fftools/ffmpeg_filter.c | 217 +++-- fftools/ffmpeg_hw.c | 2 +- fftools/ffmpeg_opt.c | 3 +- fftools/ffplay.c | 102 +- fftools/ffprobe.c | 48 +- libavcodec/Makefile | 56 +- libavcodec/ass.h | 129 +-- libavcodec/assdec.c | 2 +- libavcodec/assenc.c | 83 +- libavcodec/avcodec.c | 19 - libavcodec/avcodec.h | 82 +- libavcodec/ccaption_dec.c | 19 +- libavcodec/decode.c | 53 +- libavcodec/dvbsubenc.c | 85 +- libavcodec/dvdsubenc.c | 89 +- libavcodec/encode.c | 98 +- libavcodec/jacosubdec.c | 2 +- libavcodec/libaribb24.c | 2 +- libavcodec/libzvbi-teletextdec.c | 15 +- libavcodec/microdvddec.c | 7 +- libavcodec/movtextdec.c | 3 +- libavcodec/movtextenc.c | 115 ++- libavcodec/mpl2dec.c | 2 +- libavcodec/pgssubdec.c | 1 + libavcodec/realtextdec.c | 2 +- libavcodec/samidec.c | 2 +- libavcodec/srtdec.c | 2 +- libavcodec/srtenc.c | 104 ++- libavcodec/subviewerdec.c | 2 +- libavcodec/tests/avcodec.c | 2 - libavcodec/textdec.c | 4 +- libavcodec/ttmlenc.c | 95 +- libavcodec/utils.c | 11 + libavcodec/webvttdec.c | 2 +- libavcodec/webvttenc.c | 81 +- libavcodec/xsubenc.c | 65 +- libavfilter/Makefile | 15 + libavfilter/allfilters.c | 13 + libavfilter/avfilter.c | 30 +- libavfilter/avfilter.h | 11 + libavfilter/avfiltergraph.c | 5 + libavfilter/buffersink.c | 63 ++ libavfilter/buffersink.h | 15 + libavfilter/buffersrc.c | 72 ++ libavfilter/buffersrc.h | 1 + libavfilter/formats.c | 22 + libavfilter/formats.h | 3 + libavfilter/internal.h | 19 +- libavfilter/sf_graphicsub2text.c | 354 +++++++ libavfilter/sf_splitcc.c | 316 +++++++ libavfilter/sf_stripstyles.c | 196 ++++ libavfilter/sf_subscale.c | 883 ++++++++++++++++++ libavfilter/sf_textmod.c | 697 ++++++++++++++ libavfilter/subtitles.c | 63 ++ libavfilter/subtitles.h | 44 + libavfilter/vf_overlaygraphicsubs.c | 737 +++++++++++++++ libavfilter/vf_overlaytextsubs.c | 624 +++++++++++++ libavfilter/vf_subtitles.c | 50 +- libavformat/utils.c | 1 + libavutil/Makefile | 4 + {libavcodec => libavutil}/ass.c | 73 +- libavutil/ass_internal.h | 139 +++ {libavcodec => libavutil}/ass_split.c | 30 +- .../ass_split_internal.h | 24 +- libavutil/frame.c | 194 +++- libavutil/frame.h | 93 +- libavutil/subfmt.c | 243 +++++ libavutil/subfmt.h | 185 ++++ tests/ref/fate/filter-overlay-dvdsub-2397 | 181 ++-- tests/ref/fate/sub-dvb | 162 ++-- tests/ref/fate/sub2video | 116 +-- tests/ref/fate/sub2video_basic | 135 +-- tests/ref/fate/sub2video_time_limited | 4 +- 77 files changed, 7373 insertions(+), 1381 deletions(-) create mode 100644 libavfilter/sf_graphicsub2text.c create mode 100644 libavfilter/sf_splitcc.c create mode 100644 libavfilter/sf_stripstyles.c create mode 100644 libavfilter/sf_subscale.c create mode 100644 libavfilter/sf_textmod.c create mode 100644 libavfilter/subtitles.c create mode 100644 libavfilter/subtitles.h create mode 100644 libavfilter/vf_overlaygraphicsubs.c create mode 100644 libavfilter/vf_overlaytextsubs.c rename {libavcodec => libavutil}/ass.c (73%) create mode 100644 libavutil/ass_internal.h rename {libavcodec => libavutil}/ass_split.c (94%) rename libavcodec/ass_split.h => libavutil/ass_split_internal.h (89%) create mode 100644 libavutil/subfmt.c create mode 100644 libavutil/subfmt.h