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 7B54D4039B for ; Mon, 20 Dec 2021 16:04:11 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B7BE968AFCF; Mon, 20 Dec 2021 18:04:09 +0200 (EET) 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 ED01168AF6F for ; Mon, 20 Dec 2021 18:04:02 +0200 (EET) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 0B6161C000A for ; Mon, 20 Dec 2021 16:04:01 +0000 (UTC) Date: Mon, 20 Dec 2021 17:04:01 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20211220160401.GT2829255@pb2> References: <20211219235700.16595-1-michael@niedermayer.cc> <1cb14cd4-ba85-ec5b-4969-0e7c6b13b7b0@gmail.com> MIME-Version: 1.0 In-Reply-To: <1cb14cd4-ba85-ec5b-4969-0e7c6b13b7b0@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH 1/3] 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="===============5774660117434577944==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5774660117434577944== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9/sVue9zPU2J+4bE" Content-Disposition: inline --9/sVue9zPU2J+4bE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 19, 2021 at 09:00:27PM -0300, James Almer wrote: >=20 >=20 > On 12/19/2021 8:56 PM, Michael Niedermayer wrote: > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/ass.c | 33 +++++++++++++++++++++++++++------ > > libavcodec/ass.h | 7 +++++++ > > 2 files changed, 34 insertions(+), 6 deletions(-) > >=20 > > diff --git a/libavcodec/ass.c b/libavcodec/ass.c > > index 725e4d42ba1..06714678722 100644 > > --- a/libavcodec/ass.c > > +++ b/libavcodec/ass.c > > @@ -114,17 +114,31 @@ char *ff_ass_get_dialog(int readorder, int layer,= const char *style, > > speaker ? speaker : "", text); > > } > > -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, unsigned *nb_rect_allocated) > > { > > - AVSubtitleRect **rects, *rect; > > + AVSubtitleRect **rects =3D sub->rects, *rect; > > char *ass_str; > > + uint64_t new_nb =3D 0; > > - rects =3D av_realloc_array(sub->rects, sub->num_rects+1, sizeof(*s= ub->rects)); > > - if (!rects) > > + if (sub->num_rects >=3D UINT_MAX) > > return AVERROR(ENOMEM); > > - sub->rects =3D rects; > > + > > + if (nb_rect_allocated && *nb_rect_allocated <=3D sub->num_rects) { > > + new_nb =3D FFMIN(sub->num_rects + sub->num_rects/16LL + 1, UIN= T_MAX); >=20 > Isn't this what av_fast_realloc() is for? No, its what av_fast_realloc_array() would be for but that is not in git yet I think we should wait for that to become available before changing the used function (1 change less / less work) thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle --9/sVue9zPU2J+4bE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYcCpbQAKCRBhHseHBAsP q3X2AJ4j6cQIKHpnxoLLA6aunGUlVS69mQCfcLTfHzbZijjFhRk1DFk5E20UU+4= =HrUJ -----END PGP SIGNATURE----- --9/sVue9zPU2J+4bE-- --===============5774660117434577944== 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". --===============5774660117434577944==--