From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id CB1EE4AE13 for ; Sat, 27 Dec 2025 19:55:01 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'u6AnOK0p+jKJHPOF0TJjr2xrbFmcayTudDauCstrwZk=', expected b'nWVBuscd3ziELbnzk0zGnbU0hqbpsmLl783SEcVYr7g=')) header.d=niedermayer.cc header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1766865277; h=date : to : message-id : references : mime-version : in-reply-to : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : from; bh=XCXTOCf+2RpWDM6Yx8Axwx3mOl2OyPNd8oZ/XnBy1oc=; b=1DqCvtRj81RcUWZ31oOnsO2IDH3edizX0n3rYfSG2owE7jIGmOSUYn/zAuSn5bw7lZ4e+ F9a6xa7sV0WTbD0DeXt6KdB0HT0uuT33uR5/e+Ipe3CPIlARgEIlo+HiIHn47FEhUTd9kO4 Lbpn8U+w5tfPM6xNaf+j7V3ePG0YnOSOAQUy4yQWP9/HiSBSyTPLrlBf/Ok4VR0xI28Y37d I/qVx6gcDvniIUugbTaNpXDN9NIR8YOAAz6Mbaaymhe7Tf5DVQx2fe7MzXWuFp2+Z/kDBq4 THGMqvtbn4lj6Rw1DCkBG6rvk8SwkZ49O0oJUWSt+wbOqBhkJQRnVDjWymnQ== Received: from [172.20.0.4] (unknown [172.20.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 59799690BF0; Sat, 27 Dec 2025 21:54:37 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1766865252; b=Rs6r0OzfewtXU4FfkY52CERxHYShju4dw02iFkjUBKTcJT1w1XnKhIW82OjIO+eFM9Lmr H1VItkNCTrDAPGgbK8vVUJ3GFWEcEy0q9N2pb3RH33EJ2M4x/K+vKpfN25vvot0TDuwLKMx c150HqqRaidUC76cdooGM+3sgzcwJIMxfn+NLLkOoFMdoFYCmYEpHe96jYRXvGiEFWlmORp UCztiLZrvSaj28sgXx6+XFrUzYguYWUWCTKc8FBFsrW0TdzRND1EZ/dWFbLMaSuWHH9AXH7 W+Lv+o4KYznDcqkW44vSiUl7mw+OtogVPE+2RLlf3nz3oXCEX3iGebM1BqnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1766865252; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=u6AnOK0p+jKJHPOF0TJjr2xrbFmcayTudDauCstrwZk=; b=bKdg6ANsgFjG7e0CZ3ClbGd4VjFzBnwwZwOKFRvOGNAIRRePeqLE0afRlYjA1PSwKFcla moY8dXTbM2VoaoUoBGEpDGNV6HrZK9Zwz8WATdtz+lwTKnT0h4v3ub2FWO/xWvPeLuegyc9 7+9bQw/hhEgAdMlhqc8eXq2LKB6HIUlL+QviWBmrSaEDhhxyZgKWhiB48UUTTMCW4xUWF0l gHxiYXAjDoWc8F9HysTWgkIvO5r0U9ZmGxILFkL1N0hT5xAJD7s1uEmpDfPcX/0W0KURRiV pVVV5HVsQwSSnDw0XhVvF66qwEIzrvJoc2ERVi+PYj+oL9UWqQ75ak/U5ekg== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=niedermayer.cc; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=niedermayer.cc; arc=none (Message is not ARC signed); dmarc=none Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 34D00690B78 for ; Sat, 27 Dec 2025 21:53:59 +0200 (EET) Received: by mail.gandi.net (Postfix) with ESMTPSA id F0F2B43FE1 for ; Sat, 27 Dec 2025 19:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1766865238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nWVBuscd3ziELbnzk0zGnbU0hqbpsmLl783SEcVYr7g=; b=Yzsph3y+45SQwTNMtQcKZdtwCrUcA69zhqdEtXhodwx83y+vnOF2lUujefWrQ+BEA1xiAu sCxBbz4dKCZMqM2m5Lk/Q9B0yMYeJYbr57Dz1J6x9d1QGtncpip/2mO3coUAkcHVni9CPR HGE6qjckOxXSgzEsTiG+v14grCN7noUCMl+wFTt3JbWWeDGrxrCpfFd3d2ghOBgyaUmyGb PIDEo1YXWPxJ14MnqS10E8hXE1JexeMwAgp0kqm/c2gLaWJn6WnfxqUziO+mzTc/BzKVmR q8oLVOcbpXJ30VvjJr5e9mmiYy/ltJmkJsAg2haGSssymX6Fw4/s64C9sjOAHA== Date: Sat, 27 Dec 2025 20:53:57 +0100 To: FFmpeg development discussions and patches Message-ID: References: <20251223164441.123475-1-imraja729@gmail.com> MIME-Version: 1.0 In-Reply-To: <20251223164441.123475-1-imraja729@gmail.com> X-GND-Sasl: michael@niedermayer.cc X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdejvddviecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrhhlucfvnfffucdlfedtmdenucfjughrpeffhffvuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcupfhivgguvghrmhgrhigvrhcuoehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgeqnecuggftrfgrthhtvghrnhepieegkedtjeduffejhfetgeejtdegteetgfegtdfhjefgvefhteegkeejtddvhfevnecukfhppeeguddrieeirdeiiedrhedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieeirdehtddphhgvlhhopehlohgtrghlhhhoshhtpdhmrghilhhfrhhomhepmhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtpdhqihgupefhtdfhvdeugeefhffguddpmhhouggvpehsmhhtphhouhhtpdhnsggprhgtphhtthhopedupdhrtghpthhtohepfhhfmhhpvghgqdguvghvvghlsehffhhmphgvghdrohhrgh X-GND-State: clean X-GND-Score: -70 Message-ID-Hash: FMIQUDJMH4URGUKHDUVJ34U3UYEU5FJO X-Message-ID-Hash: FMIQUDJMH4URGUKHDUVJ34U3UYEU5FJO X-MailFrom: SRS0=hKB2=7B=niedermayer.cc=michael@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] Re: [PATCH v4] avfilter/vf_blackframe: add slice threading List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michael Niedermayer via ffmpeg-devel Cc: Michael Niedermayer Content-Type: multipart/mixed; boundary="===============4871531850942017951==" Archived-At: List-Archive: List-Post: --===============4871531850942017951== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="GMMi8pLBFn/mzSqe" Content-Disposition: inline --GMMi8pLBFn/mzSqe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Raja On Tue, Dec 23, 2025 at 10:14:41PM +0530, Raja Rathour via ffmpeg-devel wro= te: > --- > libavfilter/vf_blackframe.c | 80 ++++++++++++++++++++++++++++++++----- > 1 file changed, 71 insertions(+), 9 deletions(-) >=20 > diff --git a/libavfilter/vf_blackframe.c b/libavfilter/vf_blackframe.c > index f0aa53e133..f09d564bf7 100644 > --- a/libavfilter/vf_blackframe.c > +++ b/libavfilter/vf_blackframe.c > @@ -32,6 +32,7 @@ > =20 > #include "libavutil/internal.h" > #include "libavutil/opt.h" > +#include "libavutil/mem.h" > #include "avfilter.h" > #include "filters.h" > #include "video.h" > @@ -45,6 +46,14 @@ typedef struct BlackFrameContext { > unsigned int last_keyframe; ///< frame number of the last received k= ey-frame > } BlackFrameContext; > =20 > +typedef struct ThreadData { > + const uint8_t *data; // Pointer to the image data > + int linesize; // How wide is the memory line > + int bthresh; // The black threshold > + int width; // Image width > + unsigned int *counts; // POINTER to the array where threads write re= sults > +} ThreadData; > + > static const enum AVPixelFormat pix_fmts[] =3D { > AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_GRAY8, AV_PIX_FMT= _NV12, > AV_PIX_FMT_NV21, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_= YUV411P, > @@ -55,22 +64,72 @@ static const enum AVPixelFormat pix_fmts[] =3D { > snprintf(buf, sizeof(buf), format, value); \ > av_dict_set(metadata, key, buf, 0) > =20 > +static int blackframe_slice(AVFilterContext *ctx, void *arg, int jobnr, = int nb_jobs) > +{ > + ThreadData *td =3D arg; > + // --- C90 HARD FIX: ALL DECLARATIONS AT THE VERY TOP --- remove useless comments, like this > + int slice_start, slice_end, x, y; > + const uint8_t *p; > + unsigned int local_nblack =3D 0; > + // ------------------------------------------------------ > + > + // Safety check > + if (!td || !td->data || !td->counts) return 0; explain how these are possible conditions > + > + slice_start =3D (ctx->inputs[0]->h * jobnr) / nb_jobs; > + slice_end =3D (ctx->inputs[0]->h * (jobnr+1)) / nb_jobs; > + =20 > + p =3D td->data + slice_start * td->linesize; > + > + for (y =3D slice_start; y < slice_end; y++) { > + for (x =3D 0; x < td->width; x++) > + local_nblack +=3D p[x] < td->bthresh; > + p +=3D td->linesize; > + } > + > + // Save my private count > + td->counts[jobnr] =3D local_nblack; > + return 0; > +} > + > static int filter_frame(AVFilterLink *inlink, AVFrame *frame) > { > AVFilterContext *ctx =3D inlink->dst; > BlackFrameContext *s =3D ctx->priv; > - int x, i; > + // --- C90 HARD FIX: ALL DECLARATIONS AT THE VERY TOP --- > int pblack =3D 0; > - uint8_t *p =3D frame->data[0]; > AVDictionary **metadata; > char buf[32]; > - > - for (i =3D 0; i < frame->height; i++) { > - for (x =3D 0; x < inlink->w; x++) > - s->nblack +=3D p[x] < s->bthresh; > - p +=3D frame->linesize[0]; > + ThreadData td; > + int nb_threads; > + unsigned int *thread_counts; please use a descriptive name that describes whats in the array thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle --GMMi8pLBFn/mzSqe Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaVA5UQAKCRBhHseHBAsP q+SeAJ9BvSkXeAxf5Ga12WKMZZ8uR9h1BQCeOw5c9ce8Dj8VG5oxkiaB1IGBYSg= =01j8 -----END PGP SIGNATURE----- --GMMi8pLBFn/mzSqe-- --===============4871531850942017951== 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 To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org --===============4871531850942017951==--