From: Anton Khirnov <anton@khirnov.net>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec/hevc_refs: don't use the frame's AVBufferRef sizes when initializing planes
Date: Tue, 08 Mar 2022 14:06:17 +0100
Message-ID: <164674477786.9519.9222035290167680642@lain.red.khirnov.net> (raw)
In-Reply-To: <66477573-dc45-daa0-eb26-11e587df8b3f@gmail.com>
Quoting James Almer (2022-03-08 13:58:33)
>
>
> On 3/8/2022 9:49 AM, Anton Khirnov wrote:
> > Quoting James Almer (2022-03-06 16:39:39)
> >> Use the actual plane sizes instead.
> >>
> >> Signed-off-by: James Almer <jamrial@gmail.com>
> >> ---
> >> libavcodec/hevc_refs.c | 14 +++++++++++---
> >> 1 file changed, 11 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
> >> index 35b8e5e696..b0035356ac 100644
> >> --- a/libavcodec/hevc_refs.c
> >> +++ b/libavcodec/hevc_refs.c
> >> @@ -22,6 +22,7 @@
> >> */
> >>
> >> #include "libavutil/avassert.h"
> >> +#include "libavutil/imgutils.h"
> >>
> >> #include "thread.h"
> >> #include "hevc.h"
> >> @@ -401,9 +402,16 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
> >>
> >> if (!s->avctx->hwaccel) {
> >> if (!s->ps.sps->pixel_shift) {
> >> - for (i = 0; frame->frame->buf[i]; i++)
> >> - memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1),
> >> - frame->frame->buf[i]->size);
> >> + size_t sizes[4];
> >> + ptrdiff_t linesizes[4];
> >> + for (i = 0; i < 4; i++)
> >> + linesizes[i] = frame->frame->linesize[i];
> >> + if (av_image_fill_plane_sizes(sizes, frame->frame->format, frame->frame->height, linesizes) < 0) {
> >> + ff_hevc_unref_frame(s, frame, ~0);
> >> + return NULL;
> >> + }
> >> + for (i = 0; frame->frame->data[i]; i++)
> >> + memset(frame->frame->data[i], 1 << (s->ps.sps->bit_depth - 1), sizes[i]);
> >
> > wouldn't it be simpler and shorter to use linesize[i] * (height >> sps->vshift)?
>
> That's what av_image_fill_plane_sizes() does to fill sizes[].
> If we do it manually we also need to ensure to do it only for i > 0, so
> it's not that much of a simplification. But ok, will send a patch with
> that change.
vshift is a per-plane array, so you don't have to
>
> Could we for that matter change AVFrame linesize to ptrdiff_t in the
> next bump? Alongside the relevant imgutils helpers, if possible.
> Half this patch is just doing int -> ptrdiff_t, which is why it looks so
> big.
Might be a lot of work, but I'm certainly not against.
--
Anton Khirnov
_______________________________________________
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".
prev parent reply other threads:[~2022-03-08 13:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 15:39 James Almer
2022-03-08 12:49 ` Anton Khirnov
2022-03-08 12:58 ` James Almer
2022-03-08 13:02 ` Hendrik Leppkes
2022-03-08 13:06 ` Anton Khirnov [this message]
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=164674477786.9519.9222035290167680642@lain.red.khirnov.net \
--to=anton@khirnov.net \
--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