From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 19B4246AE2 for ; Sun, 3 Sep 2023 00:25:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D553668C64C; Sun, 3 Sep 2023 03:25:18 +0300 (EEST) Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ECE8D68C588 for ; Sun, 3 Sep 2023 03:25:11 +0300 (EEST) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-40061928e5aso3124655e9.3 for ; Sat, 02 Sep 2023 17:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693700710; x=1694305510; darn=ffmpeg.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=vDxBH9lT5uaKgw5EZMcQQgsPX+9csCGA5H5gYMj3hxE=; b=e1dHYU3OByP904SEmtEzCaR6cn0hmWLW2M7t0b7PmCajPUCDZ+HFoOmna8BJEfCC1J z6d4E1s7eovLzRNqJ4v9lYRqBZJZfwDQb6ZlhbwC2JBwTYheBxI5usgpMpFJQkU7H3zQ Vh49GJJ4PD2hA1Y65bHPnn3hcn5xVsoACGxN2Sb4EpC9dZ1rQPTAAwn8ZuEgIOjUbWr/ k/NaAL8Q8fY/TKQv0IvZiNqe8XakvYyto5TNzpZQQnJiXDtyOW1XozLZblbMIp85hKCG SbYKt6nGqxWgPwgqiu8J0iK6ogpgbMbXPGbw2ZlgyxA8L+n+QbDIU8RyiCMI/zebcXhQ NChQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693700710; x=1694305510; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vDxBH9lT5uaKgw5EZMcQQgsPX+9csCGA5H5gYMj3hxE=; b=FPX64Gom+3AacTyshCfp3mXZVUQCWdr/WcUzsJ8Ze/czI8e/IDpDxrQ5cHG/kC0OtS cZrPVcuN6MJ33lCgKSMOTk98VBlwxan/m5z/CafAIw/2A7hausjeJMLnKmKDzDw6ORFK LB6zDe7zHi6dMpO22UCwB4Zwmy0xpbeixQUNYx8l2x/MK3ZHopfmD5Fjf/pGjGRrqFw7 EXCMZqJS+5XS6jf1oCydFwnWDaRo79kU/a8jMg+7+R1yHqYzVv8q7TzGT3uZDkLdn0kG q3W0k9s6Mg32NV4gqlNzDx7Diee6aa7i53QQszZ58dYo3bg1XCk/2t5CMa9FLlwRuu09 CzTA== X-Gm-Message-State: AOJu0YwaME3sp2b3lLh3w/fxo+tg4dO5hQ7Q3FRVm/gBM7qkFTP1/jCJ DlUYCygOlM/9VDUOEL++qUZpqUqP084= X-Google-Smtp-Source: AGHT+IG8nLBWR1Se9bIc+Rs6zKJuZNnwuTlzN+B08aKEi4lZ++GiNg0xZbHra8cO8Uw4TIuMsq9Ktg== X-Received: by 2002:a7b:cb8a:0:b0:401:73b2:f043 with SMTP id m10-20020a7bcb8a000000b0040173b2f043mr4567027wmi.1.1693700710183; Sat, 02 Sep 2023 17:25:10 -0700 (PDT) Received: from mariano ([82.84.194.139]) by smtp.gmail.com with ESMTPSA id t12-20020a7bc3cc000000b003fef19bb55csm9412858wmj.34.2023.09.02.17.25.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Sep 2023 17:25:09 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id A758CBFCDA; Sun, 3 Sep 2023 02:25:07 +0200 (CEST) Date: Sun, 3 Sep 2023 02:25:07 +0200 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: Mail-Followup-To: FFmpeg development discussions and patches References: <20230826122328.95416-1-stefasab@gmail.com> <20230901165440.GA7802@pb2> <20230902200753.GB8640@pb2> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230902200753.GB8640@pb2> User-Agent: Mutt/2.1.4 (2021-12-11) Subject: Re: [FFmpeg-devel] [PATCH] lsws/swscale.h: introduce sws_get_gaussian_vec 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On date Saturday 2023-09-02 22:07:53 +0200, Michael Niedermayer wrote: > On Fri, Sep 01, 2023 at 08:38:26PM +0200, Stefano Sabatini wrote: > > On date Friday 2023-09-01 18:54:40 +0200, Michael Niedermayer wrote: > > > On Thu, Aug 31, 2023 at 07:16:20PM +0200, Stefano Sabatini wrote: > > [...] > > > > +/** > > > > + * Compute and return a normalized Gaussian vector. > > > > + * > > > > + * @param vecp: pointer where the computed vector is put in case of > > > > + * success > > > > + * @param standard_deviation the standard deviation used to generate > > > > + * the Gaussian vector, must be a non-negative value > > > > + * @param quality the quality of the generated Gaussian vector, must > > > > + * be a non-negative value. It affects the lenght of the generated > > > > + * vector. A value equal to 3 corresponds to high quality. > > > > + * @param log_ctx a pointer to an arbitrary struct of which the first > > > > + * field is a pointer to an AVClass struct (used for av_log) > > > > + * used for logging, can be NULL > > > > + * > > > > + * @return a negative error code on error, non negative otherwise > > > > + */ > > > > +int sws_get_gaussian_vec(SwsVector **vecp, > > > > + double standard_deviation, double quality, > > > > + void *log_ctx); > > > > > > which of the two do you consider better? > > > > > > First, here the central part we return is the vector > > > > > > SwsVector *gaus_vec = sws_getGaussianVec(NULL, 1, 2); > > > SwsVector *temp_vec = sws_ConvolveVec(NULL, in_vec, gaus_vec); > > > sws_averageVec(temp_vec, temp_vec, in_vec); > > > > > > av_free(gaus_vec); > > > return temp_vec; // Error checking here happens by temp_vec being NULL in all cases of error > > > > > > vs. > > > > > > Second, here the central part we return is the error code > > > > > > SwsVector *gaus_vec = NULL; > > > SwsVector *temp_vec = NULL; > > > int err = sws_getGaussianVec(&gaus_vec, 1, 2); > > > if (err<0) > > > goto fail; > > > > > > err = sws_ConvolveVec(&temp_vec, in_vec, gaus_vec); > > > if (err<0) > > > goto fail; > > > > > > err = sws_averageVec(&temp_vec, temp_vec, in_vec); > > > if (err<0) > > > goto fail; > > > > The latter pattern enables differentiation between error codes (ENOMEM > > or EINVAL) and provides feedback in the log message. With the former > > you only know if it fails, but you don't know why (relevant in case > > e.g. we make the parameter tunable by a filter and we don't want to > > add additional validation and logging at the filter level). > > can the API be designed so that optionally the user could choose to > only check the error code after several steps ? > (this would avoid the need for 1 check per call where the fine grained > information is not needed) > I mean similar to the concept of NAN in floating point so that a failure > can be propagated and only at the end checked. Well, with the new approach you can do: SwsVector *gaus_vec, *temp_vec, *avg_vec; sws_get_gaussian_vec(&gaus_vec, 1, 2); sws_get_convolution_vec(&temp_vec, in_vec, gaus_vec); sws_get_average_vec(&avg_vec, temp_vec, in_vec); av_free(gaus_vec); av_free(temp_vec); return avg_vec; // Error checking here happens by avg_vec being NULL in all cases of error If you want to disable the log we could add a log_ctx_offset parameter. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".