From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer
Date: Fri, 29 Mar 2024 21:25:07 +0100
Message-ID: <GV1P250MB0737B8C893BF5FE242BCFFD38F3A2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <GV1P250MB07371C0961019DBE2766185A8F342@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM>
Andreas Rheinhardt:
> While this change IMO makes the control flow clearer
> for the human reader, it is especially important for
> GCC: It erroneously believes that it is possible to
> enter the SHORT2(UNUSED|LONG) cases without having
> entered the preceding block that initializes pic,
> frame_num, structure and j; it would emit -Wmaybe-uninitialized
> warnings for these variables if they were not pseudo-
> initialized with av_uninit(). This patch allows to remove
> the latter.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/h264_refs.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
> index 9bc7b20988..c2ba4b9b9e 100644
> --- a/libavcodec/h264_refs.c
> +++ b/libavcodec/h264_refs.c
> @@ -646,8 +646,9 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
> av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode,
> h->mmco[i].short_pic_num, h->mmco[i].long_arg);
>
> - if (mmco[i].opcode == MMCO_SHORT2UNUSED ||
> - mmco[i].opcode == MMCO_SHORT2LONG) {
> + switch (mmco[i].opcode) {
> + case MMCO_SHORT2UNUSED:
> + case MMCO_SHORT2LONG:
> frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
> pic = find_short(h, frame_num, &j);
> if (!pic) {
> @@ -659,16 +660,12 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
> }
> continue;
> }
> - }
> -
> - switch (mmco[i].opcode) {
> - case MMCO_SHORT2UNUSED:
> - if (h->avctx->debug & FF_DEBUG_MMCO)
> - av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
> - h->mmco[i].short_pic_num, h->short_ref_count);
> - remove_short(h, frame_num, structure ^ PICT_FRAME);
> - break;
> - case MMCO_SHORT2LONG:
> + if (mmco[i].opcode == MMCO_SHORT2UNUSED) {
> + if (h->avctx->debug & FF_DEBUG_MMCO)
> + av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
> + h->mmco[i].short_pic_num, h->short_ref_count);
> + remove_short(h, frame_num, structure ^ PICT_FRAME);
> + } else {
> if (h->long_ref[mmco[i].long_arg] != pic)
> remove_long(h, mmco[i].long_arg, 0);
>
> @@ -678,6 +675,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
> h->long_ref[mmco[i].long_arg]->long_ref = 1;
> h->long_ref_count++;
> }
> + }
> break;
> case MMCO_LONG2UNUSED:
> j = pic_num_extract(h, mmco[i].long_arg, &structure);
Will apply the rest of this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
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:[~2024-03-29 20:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused Andreas Rheinhardt
2024-03-27 17:30 ` James Zern via ffmpeg-devel
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer Andreas Rheinhardt
2024-03-29 20:25 ` Andreas Rheinhardt [this message]
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 4/6] avcodec/h264_refs: Use smaller scope, don't use av_uninit Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 5/6] avcodec/ratecontrol: Use forward declaration for AVExpr Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 6/6] avutil/opt: Avoid av_uninit Andreas Rheinhardt
2024-03-27 17:29 ` [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it James Zern via ffmpeg-devel
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=GV1P250MB0737B8C893BF5FE242BCFFD38F3A2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--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