From patchwork Tue Mar 31 20:25:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Eugen Hoyos X-Patchwork-Id: 18557 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id F21AB44A5F7 for ; Tue, 31 Mar 2020 23:26:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C496468AF49; Tue, 31 Mar 2020 23:26:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4228F68AF26 for ; Tue, 31 Mar 2020 23:26:04 +0300 (EEST) Received: by mail-io1-f67.google.com with SMTP id c16so8776775iod.6 for ; Tue, 31 Mar 2020 13:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=uCY9b6Y4KlZ4wbwipT40Wsc1JnECKOIwpaIfKuKw/PI=; b=DJC4E3qH23n2CZd7VSr9ZqHFMx5A8cNwHKwx2GGbZRY57+4ax+tfr7j4QAS0vYItZf yMkNP7BPcP8pF3+8Za9hoe7g+yfXHZFx1S99OkCDCfVS4DEK5oG82XYSdX2+O8yu2bAX Y8dOPhfpc2llJmu6Bc6CA6VR1toqwcqEAhTORKNV3YW86LV1yCQwrYl6GTtl1dOOmXlG qNALNZwV/SNlAHJz3mpHe5odQDo2KSUg58YaeiaqRtNdt9X2WakOzfn8cM16M7m5+12Q SjtVDPraAdgkqj0DiFhI3GIxGO7dNjs7Q8VnJMgkdbZy0UCaPps5KKF8uEv+4Nj2uKH6 4UaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=uCY9b6Y4KlZ4wbwipT40Wsc1JnECKOIwpaIfKuKw/PI=; b=kyARseg9HkoDZ9RAs8hDXdvBLux58+ZNX6gDXMwW3KUEM/CByW/YdxWyhohuHXVaWv dlDYR2LbWzDH7X2S3jUL/Kq8pFE7QGfAl0H4rEMfeDwherk2/3YXrUvNP0JBKa0lmL8G F4sz0GWskaNi9bw04V6hwqW8FgAktPbAAi9jzJIxskiyfZ1opnltgUjqUu8nroTTL7Xa 6HZVBoaTy0phtBsb7PNGV7sbNBLUgyR8vGCPTpA7vIehVi3+he0X21uWVWmC/4g6FLib LXNLbvjxmPzrATotO583bQXmz8I/T/fDp1mUGz0dJuZ/t/cM2vDCadP2bDnS0YE8rSNw QBOg== X-Gm-Message-State: ANhLgQ0E8lQh6KDOz+srKVZHD7VFXnOr+tYNuoZPkaw/h6utEG90eReg C+LvlwxeTfrp43x1/NwWu+vYAmjiVR3wGYR+mp8GgA== X-Google-Smtp-Source: ADFU+vtA6yniaTbuKTmhAu2eLxQS3kJJn9uusucjVs+LM+5Z+5HMfNk5LMtCZBzPjubitfROvCHFFfNJpdPF/mhf0V8= X-Received: by 2002:a6b:c916:: with SMTP id z22mr17346653iof.138.1585686362799; Tue, 31 Mar 2020 13:26:02 -0700 (PDT) MIME-Version: 1.0 From: Carl Eugen Hoyos Date: Tue, 31 Mar 2020 22:25:51 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH]lavfi/deshake_opencl: Do not use bool X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Hi! Attached patch fixes compilation with opencl for powerpc where bool always had a meaning different from other architectures. Other work-arounds certainly exist but we usually don't like bool anyway. Fixes ticket #8591. Please comment, Carl Eugen From 3e5e2bf95aaf1e782eba7243e053f0b0d5955699 Mon Sep 17 00:00:00 2001 From: Carl Eugen Hoyos Date: Tue, 31 Mar 2020 22:20:10 +0200 Subject: [PATCH] lavfi/deshake_opencl: Do not use bool, powerpc does not like it. Fixes ticket #8591. --- libavfilter/vf_deshake_opencl.c | 61 ++++++++++++++++----------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/libavfilter/vf_deshake_opencl.c b/libavfilter/vf_deshake_opencl.c index 0ef015808f..4f1bb09362 100644 --- a/libavfilter/vf_deshake_opencl.c +++ b/libavfilter/vf_deshake_opencl.c @@ -45,7 +45,6 @@ * the use of this software, even if advised of the possibility of such damage. */ -#include #include #include #include "libavutil/opt.h" @@ -205,7 +204,7 @@ typedef struct DeshakeOpenCLContext { // These variables are used in the activate callback int64_t duration; - bool eof; + int eof; // State for random number generation AVLFG alfg; @@ -233,7 +232,7 @@ typedef struct DeshakeOpenCLContext { CropInfo crop_uv; // Whether or not we are processing YUV input (as oppposed to RGB) - bool is_yuv; + int is_yuv; // The underlying format of the hardware surfaces int sw_format; @@ -357,7 +356,7 @@ static void run_estimate_kernel(const MotionVector *point_pairs, double *model) } // Checks that the 3 points in the given array are not collinear -static bool points_not_collinear(const cl_float2 **points) +static int points_not_collinear(const cl_float2 **points) { int j, k, i = 2; @@ -373,17 +372,17 @@ static bool points_not_collinear(const cl_float2 **points) // (3839, 2159), this prevents a third point from being within roughly // 0.5 of a pixel of the line connecting the two on both axes if (fabs(dx2*dy1 - dy2*dx1) <= 1.0) { - return false; + return 0; } } } - return true; + return 1; } // Checks a subset of 3 point pairs to make sure that the points are not collinear // and not too close to each other -static bool check_subset(const MotionVector *pairs_subset) +static int check_subset(const MotionVector *pairs_subset) { const cl_float2 *prev_points[] = { &pairs_subset[0].p.p1, @@ -401,7 +400,7 @@ static bool check_subset(const MotionVector *pairs_subset) } // Selects a random subset of 3 points from point_pairs and places them in pairs_subset -static bool get_subset( +static int get_subset( AVLFG *alfg, const MotionVector *point_pairs, const int num_point_pairs, @@ -482,10 +481,10 @@ static int find_inliers( for (i = 0; i < n; i++) { if (err[i] <= t) { // This is an inlier - point_pairs[i].should_consider = true; + point_pairs[i].should_consider = 1; num_inliers += 1; } else { - point_pairs[i].should_consider = false; + point_pairs[i].should_consider = 0; } } @@ -525,7 +524,7 @@ static int ransac_update_num_iters(double confidence, double num_outliers, int m // Estimates an affine transform between the given pairs of points using RANdom // SAmple Consensus -static bool estimate_affine_2d( +static int estimate_affine_2d( DeshakeOpenCLContext *deshake_ctx, MotionVector *point_pairs, DebugMatches *debug_matches, @@ -535,7 +534,7 @@ static bool estimate_affine_2d( const int max_iters, const double confidence ) { - bool result = false; + int result = 0; double best_model[6], model[6]; MotionVector pairs_subset[3], best_pairs[3]; @@ -544,24 +543,24 @@ static bool estimate_affine_2d( // We need at least 3 points to build a model from if (num_point_pairs < 3) { - return false; + return 0; } else if (num_point_pairs == 3) { // There are only 3 points, so RANSAC doesn't apply here run_estimate_kernel(point_pairs, model_out); for (int i = 0; i < 3; ++i) { - point_pairs[i].should_consider = true; + point_pairs[i].should_consider = 1; } - return true; + return 1; } for (iter = 0; iter < niters; ++iter) { - bool found = get_subset(&deshake_ctx->alfg, point_pairs, num_point_pairs, pairs_subset, 10000); + int found = get_subset(&deshake_ctx->alfg, point_pairs, num_point_pairs, pairs_subset, 10000); if (!found) { if (iter == 0) { - return false; + return 0; } break; @@ -600,7 +599,7 @@ static bool estimate_affine_2d( // Find the inliers again for the best model for debugging find_inliers(point_pairs, num_point_pairs, best_model, deshake_ctx->ransac_err, threshold); - result = true; + result = 1; } return result; @@ -618,7 +617,7 @@ static void optimize_model( ) { float move_x_val = 0.01; float move_y_val = 0.01; - bool move_x = true; + int move_x = 1; float old_move_x_val = 0; double model[6]; int last_changed = 0; @@ -668,9 +667,9 @@ static void optimize_model( } if (old_move_x_val < 0) { - move_x = false; + move_x = 0; } else { - move_x = true; + move_x = 1; } } } @@ -681,7 +680,7 @@ static void optimize_model( // // (Pick random subsets, compute model, find total error, iterate until error // is minimized.) -static bool minimize_error( +static int minimize_error( DeshakeOpenCLContext *deshake_ctx, MotionVector *inliers, DebugMatches *debug_matches, @@ -689,18 +688,18 @@ static bool minimize_error( double *model_out, const int max_iters ) { - bool result = false; + int result = 0; float best_err = FLT_MAX; double best_model[6], model[6]; MotionVector pairs_subset[3], best_pairs[3]; for (int i = 0; i < max_iters; i++) { float total_err = 0; - bool found = get_subset(&deshake_ctx->alfg, inliers, num_inliers, pairs_subset, 10000); + int found = get_subset(&deshake_ctx->alfg, inliers, num_inliers, pairs_subset, 10000); if (!found) { if (i == 0) { - return false; + return 0; } break; @@ -734,7 +733,7 @@ static bool minimize_error( debug_matches->model_matches[pi] = best_pairs[pi]; } debug_matches->num_model_matches = 3; - result = true; + result = 1; optimize_model(deshake_ctx, best_pairs, inliers, num_inliers, best_err, model_out); return result; @@ -1170,7 +1169,7 @@ static int deshake_opencl_init(AVFilterContext *avctx) ff_framequeue_global_init(&fqg); ff_framequeue_init(&ctx->fq, &fqg); - ctx->eof = false; + ctx->eof = 0; ctx->smooth_window = (int)(av_q2d(avctx->inputs[0]->frame_rate) * ctx->smooth_window_multiplier); ctx->curr_frame = 0; @@ -1262,9 +1261,9 @@ static int deshake_opencl_init(AVFilterContext *avctx) } if (desc->flags & AV_PIX_FMT_FLAG_RGB) { - ctx->is_yuv = false; + ctx->is_yuv = 0; } else { - ctx->is_yuv = true; + ctx->is_yuv = 1; } ctx->sw_format = hw_frames_ctx->sw_format; @@ -1971,7 +1970,7 @@ no_motion_data: new_vals[RingbufScaleY] = 1.0f; for (int i = 0; i < num_vectors; i++) { - deshake_ctx->matches_contig_host[i].should_consider = false; + deshake_ctx->matches_contig_host[i].should_consider = 0; } debug_matches.num_model_matches = 0; @@ -2085,7 +2084,7 @@ static int activate(AVFilterContext *ctx) if (!deshake_ctx->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) { if (status == AVERROR_EOF) { - deshake_ctx->eof = true; + deshake_ctx->eof = 1; } } -- 2.24.1