From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 06/13] avcodec/mpegvideo_enc: Don't overallocate arrays
Date: Mon, 9 Oct 2023 19:17:53 +0200
Message-ID: <20231009171753.GA3543730@pb2> (raw)
In-Reply-To: <AS8P250MB0744DA037AAED65A167B82C48FCEA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
[-- Attachment #1.1: Type: text/plain, Size: 3140 bytes --]
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 <andreas.rheinhardt@outlook.com>
> >>> ---
> >>> 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 *avctx)
> >>> !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_PICTURE_COUNT) ||
> >>> - !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT))
> >>> + !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_B_FRAMES + 1) ||
> >>> + !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_B_FRAMES + 1))
> >>> return AVERROR(ENOMEM);
> >>>
> >>> /* 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)
> >>> }
> >>>
> >>> /* shift buffer entries */
> >>> - for (i = flush_offset; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++)
> >>> + for (int i = flush_offset; i <= MAX_B_FRAMES; i++)
> >>> s->input_picture[i - flush_offset] = s->input_picture[i];
> >>>
> >>> s->input_picture[encoding_delay] = pic;
> >>> @@ -1450,9 +1450,9 @@ static int select_input_picture(MpegEncContext *s)
> >>> {
> >>> int i, ret;
> >>>
> >>> - for (i = 1; i < MAX_PICTURE_COUNT; i++)
> >>> + for (int i = 1; i <= MAX_B_FRAMES; i++)
> >>> s->reordered_input_picture[i - 1] = s->reordered_input_picture[i];
> >>
> >> I see the addition of "int" and that seems neither needed nor
> >> explained why in the commit message
> >>
> >
> > 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.
> >
> > If it matters: That i in the outer scope survives this patchset, but it
> > won't survive for long.
> >
>
> 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
[...]
--
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
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
next prev parent reply other threads:[~2023-10-09 17:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 2:38 [FFmpeg-devel] [PATCH 01/13] avcodec/mpegvideo_enc: Fix abort on allocation errors Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 02/13] avcodec/mpegvideo_enc: Remove always-false checks Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 03/13] avcodec/mpegvideo_enc: Reindentation Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 04/13] avcodec/mpegvideo_enc: Don't pretend input to be non-refcounted Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 05/13] avcodec/mpegvideo_enc: Don't reget known values Andreas Rheinhardt
2023-10-08 16:51 ` Michael Niedermayer
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 06/13] avcodec/mpegvideo_enc: Don't overallocate arrays Andreas Rheinhardt
2023-10-07 16:33 ` Michael Niedermayer
2023-10-07 17:28 ` Andreas Rheinhardt
2023-10-09 12:30 ` Andreas Rheinhardt
2023-10-09 17:17 ` Michael Niedermayer [this message]
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 07/13] avcodec/mpegvideo_enc: Don't set write-only properties Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 08/13] avcodec/mpegvideo_enc: Remove dead block Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 09/13] avcodec/mpegvideo_enc: Don't allocate buffers unnecessarily Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 10/13] avcodec/mpegvideo_enc: Don't call av_frame_copy_props() unnecessarily Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 11/13] avcodec/mpegpicture: Move caller-specific parts of function to callers Andreas Rheinhardt
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 12/13] avcodec/mpeg(picture|video_dec): Move comment to more appropriate place Andreas Rheinhardt
2023-10-08 16:48 ` Michael Niedermayer
2023-10-06 2:46 ` [FFmpeg-devel] [PATCH 13/13] avcodec/vdpau_vc1: Fix indentation Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231009171753.GA3543730@pb2 \
--to=michael@niedermayer.cc \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git