From patchwork Wed Nov 1 09:48:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44473 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da5:b0:15d:8365:d4b8 with SMTP id gl37csp317192pzb; Wed, 1 Nov 2023 02:47:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhxttiuRkjvxqO0dfSkwUxBjHyS1b1mF35HScT10UYCYQDDSkmfVCgE7WaJx4ZahMYNr0T X-Received: by 2002:a50:cd81:0:b0:540:a6ab:4c33 with SMTP id p1-20020a50cd81000000b00540a6ab4c33mr12831612edi.8.1698832057635; Wed, 01 Nov 2023 02:47:37 -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 hp20-20020a1709073e1400b009d2f590f95fsi1353731ejc.126.2023.11.01.02.47.37; Wed, 01 Nov 2023 02:47:37 -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=@outlook.com header.s=selector1 header.b=jklKqDKE; 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8504C68CDC0; Wed, 1 Nov 2023 11:47:26 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2027.outbound.protection.outlook.com [40.92.75.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 15BB368CD9E for ; Wed, 1 Nov 2023 11:47:20 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JXiBZKa3Qsk2/w/CI3FRbdferXhvysgefXN/uOCmSz12ER1CbybtXv+Lj5T+8Uliff7cDtmcj1kG0FHXQJKE+KbO9Aj1T6lMjK6RwUY2FxjjSGEkCFSevdD0bdlb9G/rrtFisUmrPekLkcHkeuBK5YCw2SEm4/SczhUjigErYY60QOutAfFSxTae0/uyW2DxKHT3lZTEp+FTdHgh7H9YvSjovk6QKSxmuuzsrAACWRZ9sMybLx6I02+6Z+i+JL+DWPiART+CI5IReg9QwecxJtKV63fshvJUBUdAEM+9paWMeNyaG4K7n015M5CuVJY31g5cxyIeEKO+xEBxV9Es5A== 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=XuXGsUPFtutBHg4AngdveaUuKAmhBSNM3rIuKkRsCag=; b=WIF6sML3n5Q0qTHwhZty84TWZfh6COcdfcDWXZxr7sh8SPYBOuLzWqogJeRt3RDKmNJXyfazjXZ07wb2j3sy6iL6GKn+YfRNJX3yoE+eDoppQWj64Th0BUANkrIoJlAEKcZQEgof+7MQ+o2A2w4ux8ALbbD9gq8vG8kAkTDco8gFIWJUSzfVqTNtasr6s2ZbWK13XghSZDWqcKxDxtkSBOtIQWYJBDZFMNSfqhkTjBxVyiiQB+R+xrUxpkFGB8JITB9WkvFU/+caeZIAIzua/8HvPiMD5Zd1k6gL32Kz5k3gMr2sOgwKyADKo8C6b3xSi4vJDDh8+6QgbJj3xaL4tw== 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=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XuXGsUPFtutBHg4AngdveaUuKAmhBSNM3rIuKkRsCag=; b=jklKqDKE0X4F61FCxoEADQWTY/E0ZSBFc0LUCmGhU4Gxn6ycLiMJ8xvRi7FWd/ErxsCK95yPrecYXocoSOWKKCJRhGYP3HR4QvJFWlMfX/AQqoJ4Y+L+wMhs96FJZHeEiVwx7CC69d4/rwCS1ZxopMDGLNtHld6sStEhkRLYHMMENA2t0SQZ+0fMH4H9cKCcoRnF/82jwYuLSRi2+JszbfjPhO8IFzNrrt/Mq98C5bEGMZdTFCdguUFLCbDeQy3O3FE3OIPT4PZ7Oyit+OCBWRE5opWaKa+jLYyxE48eY725wABs7ecujA36LBtd/lmyvLvxcL4pWxwYQnXcU1G5gw== Received: from GV1SPRMB0033.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8b::7) by AS8P250MB0120.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:373::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.29; Wed, 1 Nov 2023 09:47:15 +0000 Received: from GV1SPRMB0033.EURP250.PROD.OUTLOOK.COM ([fe80::54a8:bde1:da41:a768]) by GV1SPRMB0033.EURP250.PROD.OUTLOOK.COM ([fe80::54a8:bde1:da41:a768%3]) with mapi id 15.20.6933.029; Wed, 1 Nov 2023 09:47:15 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 1 Nov 2023 10:48:21 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [UXXsY2S118aSMdt05Jzgf/sfa4fIV97AppumqJt7XY0=] X-ClientProxiedBy: ZR0P278CA0039.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::8) To GV1SPRMB0033.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8b::7) X-Microsoft-Original-Message-ID: <20231101094821.3588273-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0033:EE_|AS8P250MB0120:EE_ X-MS-Office365-Filtering-Correlation-Id: d504265a-e33d-4bd1-78b1-08dbdabf87a2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UU6vAD14aVZ32EwgdKZPe6fnNirK1tK8ZlqtILjL+xMEtVVfNf9Pw5Rfqxvm1N1FmleuSnJSzRADcUrvoIUGLURAmxfaJ/kqmatH45sWmDMg1Jkdp/Cao6SQxomvKyT2tEEialO4qe+WA/ZZiYONB0SUEwt9WqtlYIJiOKZdPtJ5m7IU+RsKMvahFsSh1bgeGoEDJpa5+qeCWLqyqW84o4Fi/xjKsRW3aq3i2jugqbo6tmzcEfHbtSmIEc+WT4l4aZQYpZOltMorh+RXw7gRWZH844n8gflUQITrbMbnwkGip8kqL3BUL7C7LaxMaqkGJAan1B1KdLtfLsV2AONb0eTeG25Jrb7p9ozHKMVsZ+8Z2WnDeVrkw2iid3dVen27iQffAW7jFSoOqpthI+z+vlUQEBHxBdtJFCPTmtegB1t9arrhLRKU8oNBNl+QRyCahdD1FnxqN0hoomMKdgZ7rp8ORuIDNAHljIjRbHbj/kL+WkM6AYfkZIY0lcYNvv2AyTdVNJk91NpZytEYB3LObCOfG8Q4+U/vpwusnXiVFAQ3EYd2boIn54pSELsRLO6BqnwF2v/B45/24/X1V+XWLMkbxBYhJqLTI3KdrFS9rVPQoa9VCua4NJllPftdGkrb X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hPTRm9OcL1PYOvIWYmqSbcC7X/CDYiexlyIR864DWM10819wWzow1jyhiIpgtbpeHH5D0S1PRc/zjqOGZhgz2uqLHKLrX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PsZKmkv4BdO2tO0T2WSRgE8Yv6ZEuF4ShgQTKuFE2gn468WFS1AQMUEoGRsoifxUoycZFLgLltZsuFxgzbvjyFgmqJfHdrndxLNleVYerivnF2h6AVuAz X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d504265a-e33d-4bd1-78b1-08dbdabf87a2 X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0033.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2023 09:47:15.4636 (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: AS8P250MB0120 Subject: [FFmpeg-devel] [PATCH 4/4] avfilter/deshake: Merge header into its only user 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: qVPu4YWiyHNV Signed-off-by: Andreas Rheinhardt --- libavfilter/deshake.h | 83 ---------------------------------------- libavfilter/vf_deshake.c | 55 +++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 84 deletions(-) delete mode 100644 libavfilter/deshake.h diff --git a/libavfilter/deshake.h b/libavfilter/deshake.h deleted file mode 100644 index 406cbab2f6..0000000000 --- a/libavfilter/deshake.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2013 Wei Gao - * Copyright (C) 2013 Lenny Wang - * - * 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_DESHAKE_H -#define AVFILTER_DESHAKE_H - -#include "config.h" -#include "avfilter.h" -#include "transform.h" -#include "libavutil/pixelutils.h" - - -enum SearchMethod { - EXHAUSTIVE, ///< Search all possible positions - SMART_EXHAUSTIVE, ///< Search most possible positions (faster) - SEARCH_COUNT -}; - -typedef struct IntMotionVector { - int x; ///< Horizontal shift - int y; ///< Vertical shift -} IntMotionVector; - -typedef struct MotionVector { - double x; ///< Horizontal shift - double y; ///< Vertical shift -} MotionVector; - -typedef struct Transform { - MotionVector vec; ///< Motion vector - double angle; ///< Angle of rotation - double zoom; ///< Zoom percentage -} Transform; - -#define MAX_R 64 - -typedef struct DeshakeContext { - const AVClass *class; - int counts[2*MAX_R+1][2*MAX_R+1]; /// < Scratch buffer for motion search - double *angles; ///< Scratch buffer for block angles - unsigned angles_size; - AVFrame *ref; ///< Previous frame - int rx; ///< Maximum horizontal shift - int ry; ///< Maximum vertical shift - int edge; ///< Edge fill method - int blocksize; ///< Size of blocks to compare - int contrast; ///< Contrast threshold - int search; ///< Motion search method - av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function - Transform last; ///< Transform from last frame - int refcount; ///< Number of reference frames (defines averaging window) - FILE *fp; - Transform avg; - int cw; ///< Crop motion search to this box - int ch; - int cx; - int cy; - char *filename; ///< Motion search detailed log filename - int opencl; - int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch, - const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate, - enum FillMethod fill, AVFrame *in, AVFrame *out); -} DeshakeContext; - -#endif /* AVFILTER_DESHAKE_H */ diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c index cb062dd11f..299814fd65 100644 --- a/libavfilter/vf_deshake.c +++ b/libavfilter/vf_deshake.c @@ -51,15 +51,68 @@ #include "avfilter.h" #include "internal.h" +#include "transform.h" #include "video.h" #include "libavutil/common.h" #include "libavutil/file_open.h" #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" +#include "libavutil/pixelutils.h" #include "libavutil/qsort.h" -#include "deshake.h" + +enum SearchMethod { + EXHAUSTIVE, ///< Search all possible positions + SMART_EXHAUSTIVE, ///< Search most possible positions (faster) + SEARCH_COUNT +}; + +typedef struct IntMotionVector { + int x; ///< Horizontal shift + int y; ///< Vertical shift +} IntMotionVector; + +typedef struct MotionVector { + double x; ///< Horizontal shift + double y; ///< Vertical shift +} MotionVector; + +typedef struct Transform { + MotionVector vec; ///< Motion vector + double angle; ///< Angle of rotation + double zoom; ///< Zoom percentage +} Transform; + +#define MAX_R 64 + +typedef struct DeshakeContext { + const AVClass *class; + int counts[2*MAX_R+1][2*MAX_R+1]; /// < Scratch buffer for motion search + double *angles; ///< Scratch buffer for block angles + unsigned angles_size; + AVFrame *ref; ///< Previous frame + int rx; ///< Maximum horizontal shift + int ry; ///< Maximum vertical shift + int edge; ///< Edge fill method + int blocksize; ///< Size of blocks to compare + int contrast; ///< Contrast threshold + int search; ///< Motion search method + av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function + Transform last; ///< Transform from last frame + int refcount; ///< Number of reference frames (defines averaging window) + FILE *fp; + Transform avg; + int cw; ///< Crop motion search to this box + int ch; + int cx; + int cy; + char *filename; ///< Motion search detailed log filename + int opencl; + int (* transform)(AVFilterContext *ctx, int width, int height, int cw, int ch, + const float *matrix_y, const float *matrix_uv, enum InterpolateMethod interpolate, + enum FillMethod fill, AVFrame *in, AVFrame *out); +} DeshakeContext; #define OFFSET(x) offsetof(DeshakeContext, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM