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 F037946CD7 for ; Mon, 9 Oct 2023 17:18:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 92B4768CA80; Mon, 9 Oct 2023 20:18:02 +0300 (EEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0ED4C68C98A for ; Mon, 9 Oct 2023 20:17:56 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 5F3CB20005 for ; Mon, 9 Oct 2023 17:17:54 +0000 (UTC) Date: Mon, 9 Oct 2023 19:17:53 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20231009171753.GA3543730@pb2> References: <20231007163313.GP3543730@pb2> MIME-Version: 1.0 In-Reply-To: X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 06/13] avcodec/mpegvideo_enc: Don't overallocate arrays 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="===============4309897173663414090==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============4309897173663414090== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hVUY+LYn0LT07sdA" Content-Disposition: inline --hVUY+LYn0LT07sdA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Oct 09, 2023 at 02:30:21PM +0200, Andreas Rheinhardt wrote: > Andreas Rheinhardt: > > Michael Niedermayer: > >> On Fri, Oct 06, 2023 at 04:46:29AM +0200, Andreas Rheinhardt wrote: > >>> Only entries 0..max_b_frames are ever used. > >>> > >>> Signed-off-by: Andreas Rheinhardt > >>> --- > >>> libavcodec/mpegvideo_enc.c | 10 +++++----- > >>> 1 file changed, 5 insertions(+), 5 deletions(-) > >>> > >>> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c > >>> index 1e0aed8db9..c06fdd08fe 100644 > >>> --- a/libavcodec/mpegvideo_enc.c > >>> +++ b/libavcodec/mpegvideo_enc.c > >>> @@ -819,8 +819,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *av= ctx) > >>> !FF_ALLOCZ_TYPED_ARRAY(s->q_intra_matrix16, 32) || > >>> !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) || > >>> !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) || > >>> - !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_PICTU= RE_COUNT) || > >>> - !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTU= RE_COUNT)) > >>> + !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_B_FRA= MES + 1) || > >>> + !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_B_FRA= MES + 1)) > >>> return AVERROR(ENOMEM); > >>> =20 > >>> /* Allocate MV tables; the MV and MB tables will be copied > >>> @@ -1231,7 +1231,7 @@ static int load_input_picture(MpegEncContext *s= , const AVFrame *pic_arg) > >>> } > >>> =20 > >>> /* shift buffer entries */ > >>> - for (i =3D flush_offset; i < MAX_PICTURE_COUNT /*s->encoding_del= ay + 1*/; i++) > >>> + for (int i =3D flush_offset; i <=3D MAX_B_FRAMES; i++) > >>> s->input_picture[i - flush_offset] =3D s->input_picture[i]; > >>> =20 > >>> s->input_picture[encoding_delay] =3D pic; > >>> @@ -1450,9 +1450,9 @@ static int select_input_picture(MpegEncContext = *s) > >>> { > >>> int i, ret; > >>> =20 > >>> - for (i =3D 1; i < MAX_PICTURE_COUNT; i++) > >>> + for (int i =3D 1; i <=3D MAX_B_FRAMES; i++) > >>> s->reordered_input_picture[i - 1] =3D s->reordered_input_pic= ture[i]; > >> > >> I see the addition of "int" and that seems neither needed nor > >> explained why in the commit message > >> > >=20 > > It's part of the general switch to the loop-based iterators wherever > > possible (it is better because it automatically indicates that the value > > at the end of the loop doesn't matter and it also allows to more easily > > move blocks of code around). I always use them when I touch a loop. > >=20 > > If it matters: That i in the outer scope survives this patchset, but it > > won't survive for long. > >=20 >=20 > Are you ok with this patch ok > and the rest of the patchset? I'd like to > apply it tomorrow unless there are objections. i have no objections thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato --hVUY+LYn0LT07sdA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZSQ1vQAKCRBhHseHBAsP q7HjAJ0RWYVPidp1gEtZWXxM2TlRNU89eQCeO5SOOt1HdvfshI1rPsc4lSASoyA= =EWIX -----END PGP SIGNATURE----- --hVUY+LYn0LT07sdA-- --===============4309897173663414090== 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". --===============4309897173663414090==--