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 5C01547275 for ; Sat, 2 Sep 2023 20:08:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9955568C74F; Sat, 2 Sep 2023 23:08:01 +0300 (EEST) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CAA5168C59E for ; Sat, 2 Sep 2023 23:07:54 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 07A0D1C0004 for ; Sat, 2 Sep 2023 20:07:53 +0000 (UTC) Date: Sat, 2 Sep 2023 22:07:53 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230902200753.GB8640@pb2> References: <20230826122328.95416-1-stefasab@gmail.com> <20230901165440.GA7802@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc 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: multipart/mixed; boundary="===============3399619390891948485==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3399619390891948485== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oLBj+sq0vYjzfsbl" Content-Disposition: inline --oLBj+sq0vYjzfsbl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 gene= rated > > > + * 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); > >=20 > > which of the two do you consider better? > >=20 > > First, here the central part we return is the vector > >=20 > > SwsVector *gaus_vec =3D sws_getGaussianVec(NULL, 1, 2); > > SwsVector *temp_vec =3D sws_ConvolveVec(NULL, in_vec, gaus_vec); > > sws_averageVec(temp_vec, temp_vec, in_vec); > >=20 > > av_free(gaus_vec); > > return temp_vec; // Error checking here happens by temp_vec being NULL = in all cases of error > >=20 > > vs. > >=20 > > Second, here the central part we return is the error code > >=20 > > SwsVector *gaus_vec =3D NULL; > > SwsVector *temp_vec =3D NULL; > > int err =3D sws_getGaussianVec(&gaus_vec, 1, 2); > > if (err<0) > > goto fail; > >=20 > > err =3D sws_ConvolveVec(&temp_vec, in_vec, gaus_vec); > > if (err<0) > > goto fail; > >=20 > > err =3D sws_averageVec(&temp_vec, temp_vec, in_vec); > > if (err<0) > > goto fail; >=20 > 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. thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 --oLBj+sq0vYjzfsbl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZPOWGAAKCRBhHseHBAsP qzbqAJ9FJTrZwEez/Cg868DdLGDgwqQdrACfVS/XEe9HxhihzJQDHwCQnIG6xwY= =y6Wj -----END PGP SIGNATURE----- --oLBj+sq0vYjzfsbl-- --===============3399619390891948485== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============3399619390891948485==--