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 580E742442 for ; Sat, 18 Dec 2021 14:27:21 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9131868AE9B; Sat, 18 Dec 2021 16:27:19 +0200 (EET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C1B768AD15 for ; Sat, 18 Dec 2021 16:27:13 +0200 (EET) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 25E32200006 for ; Sat, 18 Dec 2021 14:27:11 +0000 (UTC) Date: Sat, 18 Dec 2021 15:27:11 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20211218142711.GN2829255@pb2> References: <20211217215155.19805-1-michael@niedermayer.cc> MIME-Version: 1.0 In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 1/4] avcodec/ass: Faster ff_ass_add_rect() 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="===============3368940426483798325==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============3368940426483798325== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Y/MuLCAROZVy4izK" Content-Disposition: inline --Y/MuLCAROZVy4izK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 17, 2021 at 11:15:06PM +0100, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/ass.c | 32 ++++++++++++++++++++++++++------ > > libavcodec/ass.h | 7 +++++++ > > 2 files changed, 33 insertions(+), 6 deletions(-) > >=20 > > diff --git a/libavcodec/ass.c b/libavcodec/ass.c > > index 725e4d42ba1..d0a4d678bb4 100644 > > --- a/libavcodec/ass.c > > +++ b/libavcodec/ass.c > > @@ -114,17 +114,30 @@ char *ff_ass_get_dialog(int readorder, int layer,= const char *style, > > speaker ? speaker : "", text); > > } > > =20 > > -int ff_ass_add_rect(AVSubtitle *sub, const char *dialog, > > +int ff_ass_add_rect2(AVSubtitle *sub, const char *dialog, > > int readorder, int layer, const char *style, > > - const char *speaker) > > + const char *speaker, size_t *nb_rect_allocated) > > { > > - AVSubtitleRect **rects, *rect; > > + AVSubtitleRect **rects =3D sub->rects, *rect; > > char *ass_str; > > + uint64_t new_nb =3D 0; > > =20 > > - rects =3D av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*s= ub->rects)); > > - if (!rects) > > + if (nb_rect_allocated && *nb_rect_allocated <=3D sub->num_rects) { > > + new_nb =3D sub->num_rects + sub->num_rects/16LL + 1; > > + } else if (!nb_rect_allocated) > > + new_nb =3D sub->num_rects + 1LL; > > + if (new_nb > SIZE_MAX) > > return AVERROR(ENOMEM); >=20 > AVSubtitle.num_rects is unsigned, so this number should always be > bounded by UINT_MAX (and nb_rect_allocated can be a pointer to unsigned, > too). i had that initially but then wanted to move to better types but missed this, changed it back locally thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data --Y/MuLCAROZVy4izK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYb3vuwAKCRBhHseHBAsP qzrlAJ9+IpWwmyTOuJ61w16G8ec/H6RvZQCfTmEjD1Q52o3XUDraqyQeZnbq41E= =ZZPB -----END PGP SIGNATURE----- --Y/MuLCAROZVy4izK-- --===============3368940426483798325== 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". --===============3368940426483798325==--