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 353F543A1D for ; Tue, 5 Jul 2022 22:24:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4619068BA14; Wed, 6 Jul 2022 01:24:20 +0300 (EEST) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B543B68B7C5 for ; Wed, 6 Jul 2022 01:24:13 +0300 (EEST) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id BD09A200007 for ; Tue, 5 Jul 2022 22:24:12 +0000 (UTC) Date: Wed, 6 Jul 2022 00:24:11 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220705222411.GM396728@pb2> References: <20220701212511.GY396728@pb2> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 14/18] avcodec/hevcdec: Don't allocate redundant HEVCContexts 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="===============2459768893622324457==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2459768893622324457== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="S1IDi2G5OmSqtlSO" Content-Disposition: inline --S1IDi2G5OmSqtlSO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jul 02, 2022 at 08:32:06AM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > On Fri, Jul 01, 2022 at 12:29:45AM +0200, Andreas Rheinhardt wrote: > >> The HEVC decoder has both HEVCContext and HEVCLocalContext > >> structures. The latter is supposed to be the structure > >> containing the per-slicethread state. > >> > >> Yet up until now that is not how it is handled in practice: > >> Each HEVCLocalContext has a unique HEVCContext allocated for it > >> and each of these coincides except in exactly one field: The > >> corresponding HEVCLocalContext. This makes it possible to pass > >> the HEVCContext everywhere where logically a HEVCLocalContext > >> should be used. And up until recently, this is how it has been done. > >> > >> Yet the preceding patches changed this, making it possible > >> to avoid allocating redundant HEVCContexts. > >> > >> Signed-off-by: Andreas Rheinhardt > >> --- > >> libavcodec/hevcdec.c | 40 ++++++++++++++++------------------------ > >> libavcodec/hevcdec.h | 2 -- > >> 2 files changed, 16 insertions(+), 26 deletions(-) > >> > >> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c > >> index 9d1241f293..048fcc76b4 100644 > >> --- a/libavcodec/hevcdec.c > >> +++ b/libavcodec/hevcdec.c > >> @@ -2548,13 +2548,12 @@ static int hls_decode_entry_wpp(AVCodecContext= *avctxt, void *hevc_lclist, > >> { > >> HEVCLocalContext *lc =3D ((HEVCLocalContext**)hevc_lclist)[self_i= d]; > >> const HEVCContext *const s =3D lc->parent; > >> - HEVCContext *s1 =3D avctxt->priv_data; > >> - int ctb_size =3D 1<< s1->ps.sps->log2_ctb_size; > >> + int ctb_size =3D 1 << s->ps.sps->log2_ctb_size; > >> int more_data =3D 1; > >> int ctb_row =3D job; > >> - int ctb_addr_rs =3D s1->sh.slice_ctb_addr_rs + ctb_row * ((s1->ps= =2Esps->width + ctb_size - 1) >> s1->ps.sps->log2_ctb_size); > >> - int ctb_addr_ts =3D s1->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; > >> - int thread =3D ctb_row % s1->threads_number; > >> + int ctb_addr_rs =3D s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.s= ps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size); > >> + int ctb_addr_ts =3D s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; > >> + int thread =3D ctb_row % s->threads_number; > >> int ret; > >> =20 > >> if(ctb_row) { > >> @@ -2572,7 +2571,7 @@ static int hls_decode_entry_wpp(AVCodecContext *= avctxt, void *hevc_lclist, > >> =20 > >> ff_thread_await_progress2(s->avctx, ctb_row, thread, SHIFT_CT= B_WPP); > >> =20 > >> - if (atomic_load(&s1->wpp_err)) { > >> + if (atomic_load(&s->wpp_err)) { > >> ff_thread_report_progress2(s->avctx, ctb_row , thread, SH= IFT_CTB_WPP); > >=20 > > the consts in "const HEVCContext *const " make clang version 6.0.0-1ubu= ntu2 unhappy > > (this was building shared libs) > >=20 > >=20 > > CC libavcodec/hevcdec.o > > src/libavcodec/hevcdec.c:2574:13: error: address argument to atomic ope= ration must be a pointer to non-const _Atomic type ('const atomic_int *' (a= ka 'const _Atomic(int) *') invalid) > > if (atomic_load(&s->wpp_err)) { > > ^ ~~~~~~~~~~~ > > /usr/lib/llvm-6.0/lib/clang/6.0.0/include/stdatomic.h:134:29: note: exp= anded from macro 'atomic_load' > > #define atomic_load(object) __c11_atomic_load(object, __ATOMIC_SEQ_CST) > > ^ ~~~~~~ > > 1 error generated. > > src/ffbuild/common.mak:81: recipe for target 'libavcodec/hevcdec.o' fai= led > > make: *** [libavcodec/hevcdec.o] Error 1 > >=20 > > thx > >=20 >=20 > Thanks for testing this. atomic_load is indeed declared without const in > 7.17.7.2: >=20 > C atomic_load(volatile A *object); >=20 > Upon reflection this makes sense, because if atomics are implemented via > mutexes, even a read may involve a preceding write. So I'll cast const > away here, too, and add a comment. (It works when casting const away, > doesn't it?) This doesnt feel "right". These pointers should not be coming from a const if they are written to The compiler accepts it with an explicit cast though. With an implicit cast it produces a warning thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB He who knows, does not speak. He who speaks, does not know. -- Lao Tsu --S1IDi2G5OmSqtlSO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYsS6CAAKCRBhHseHBAsP qz0oAJ9cksJvtJTcGjsPZzJ04ecWV9NuSgCfVRwKENWXvNC9WxF4BH72t1oqh58= =bugS -----END PGP SIGNATURE----- --S1IDi2G5OmSqtlSO-- --===============2459768893622324457== 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". --===============2459768893622324457==--