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 D016A46A5E for ; Fri, 1 Sep 2023 18:38:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C258D68C718; Fri, 1 Sep 2023 21:38:36 +0300 (EEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C1C66680016 for ; Fri, 1 Sep 2023 21:38:30 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-401da71b7faso23781035e9.2 for ; Fri, 01 Sep 2023 11:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693593509; x=1694198309; 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=LJw+N23d1aAtI1MDIZlfe7zKRE9+Wd3pRrlU03hlGYE=; b=W75qa2c+7hYBM0TkL/K30uuWNXtasEOOwMVi47Oei17VXdez/76IK/tGwbjK5wNy1I EPEjO2ESCfgZWG6V6los0IwV4MwUhBEbTOI5pg27X1ey0AKO2n6dT04UA4fV6J9+Yf8n K7k8IH4LancCnGHYN091qdo6ZDCZldJWoB5JKePcPEBDLwgcLUmJXKAiCxrTpoYwZmo5 fQ5yHcZwDBEwLCM50clfQKycSfVq5BzPiEGS8C0BZxmIcVm3iskBgxzR5jjF4ikxJr6A Y4udAa7Nz8EGw4Ex+wZbFTEMm3KLRftu4lRyr8JPc8faIE+gcwFn96vQO62WufMeY83/ I7Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693593509; x=1694198309; 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=LJw+N23d1aAtI1MDIZlfe7zKRE9+Wd3pRrlU03hlGYE=; b=BEvxekhcbPs+HkkIzEksTnEbSj3jxopqGY13mJP6PxdS1diI1UIzDUL57Ocrn99XFy Y8H77uY9Yjko/ddxn6JYUQ4NbFozFYmQENMSdjgvyIUmG7AxxwTuM04B2gKedSctX7y5 Ina46FppkSlzYnx6LhdTnDJJ4V5hEkteNes7hBXUDgrQP7sGZUiB/crpaRW2KqWk2AGE fubKgm2EctWu2RzmSdxIsHw7kZtxJHyusZephyhehbRaY0ZWxXI5v8sktIBb9GkLK9ya QVt6rV3uIsIUVEez0/6TFDmNSGUll9VI1LOppFtGZumtijxoIkZgQWhcmKqEC54o5cjW BwsQ== X-Gm-Message-State: AOJu0YwHm6zmHWzqAwAbLMXCRonyILUNDjCw4Vcr4/XNqqNRInFNnTuv 5bbgHYnYQBGbPV+87sHInWW7AI4NfDI= X-Google-Smtp-Source: AGHT+IEWIbp1EKvvRiRu9gQyNYQq+yCTtyvzeOlps6UgI6wLxuUdcc9oZvYKdujr/ScVVXfVGhslEQ== X-Received: by 2002:a05:600c:2283:b0:401:b2c7:34a4 with SMTP id 3-20020a05600c228300b00401b2c734a4mr2581492wmf.11.1693593509282; Fri, 01 Sep 2023 11:38:29 -0700 (PDT) Received: from mariano ([82.84.194.139]) by smtp.gmail.com with ESMTPSA id c20-20020a7bc854000000b003feef5b0bb7sm5557410wml.40.2023.09.01.11.38.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 11:38:28 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 9BA03BFCDA; Fri, 1 Sep 2023 20:38:26 +0200 (CEST) Date: Fri, 1 Sep 2023 20:38:26 +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> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230901165440.GA7802@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 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). _______________________________________________ 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".