From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_zscale: realign output buffer if needed Date: Wed, 16 Mar 2022 17:58:44 -0300 Message-ID: <60bc72af-9b5f-5c28-048a-43645e102929@gmail.com> (raw) In-Reply-To: <905fd001-1562-816d-332e-4a0d10fcbfab@gmail.com> On 3/16/2022 5:52 PM, James Almer wrote: > On 3/14/2022 6:06 PM, Marton Balint wrote: >> Output buffer alignment might be different to ZIMG_ALIGNMENT or it may >> not be >> aligned at all if a downstream filter (e.g. vf_pad) intentionally >> misaligns it. > > av_frame_get_buffer() align parameter is used to align linesizes, not > buffers. av_malloc() has a hardcoded alignment defined at compile time > based on configure settings. > > If what you need is aligned data pointers, you should either use the > trick i used in the libdav1d wrapper, or change av_malloc() in order to > use av_cpu_max_align(). > >> >> Or maybe we should unconditionally always allocate output with >> av_frame_get_buffer() instead of ff_get_video_buffer()? Also, ff_get_video_buffer() can be made to accept an align parameter, much like av_frame_get_buffer(). The latter (and av_frame_make_writable) should not be used in lavfi since you're losing the benefits from the AVFilterLink buffer pool. >> >> Signed-off-by: Marton Balint <cus@passwd.hu> >> --- >> libavfilter/vf_zscale.c | 11 +++++++---- >> 1 file changed, 7 insertions(+), 4 deletions(-) >> >> diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c >> index ceefc95224..2061e38bcc 100644 >> --- a/libavfilter/vf_zscale.c >> +++ b/libavfilter/vf_zscale.c >> @@ -632,7 +632,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, >> const AVPixFmtDescriptor *des >> return 0; >> } >> -static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame >> **frame) >> +static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame >> **frame, int needs_copy) >> { >> AVFrame *aligned = NULL; >> int ret = 0, plane, planes; >> @@ -654,10 +654,10 @@ static int realign_frame(const >> AVPixFmtDescriptor *desc, AVFrame **frame) >> if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) >> < 0) >> goto fail; >> - if ((ret = av_frame_copy(aligned, *frame)) < 0) >> + if (needs_copy && (ret = av_frame_copy(aligned, *frame)) >> < 0) >> goto fail; >> - if ((ret = av_frame_copy_props(aligned, *frame)) < 0) >> + if (needs_copy && (ret = av_frame_copy_props(aligned, >> *frame)) < 0) >> goto fail; >> av_frame_free(frame); >> @@ -786,9 +786,12 @@ static int filter_frame(AVFilterLink *link, >> AVFrame *in) >> goto fail; >> } >> + if ((ret = realign_frame(odesc, &out, 0)) < 0) >> + goto fail; >> + >> av_frame_copy_props(out, in); >> - if ((ret = realign_frame(desc, &in)) < 0) >> + if ((ret = realign_frame(desc, &in, 1)) < 0) >> goto fail; >> snprintf(buf, sizeof(buf)-1, "%d", outlink->w); _______________________________________________ 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:[~2022-03-16 20:58 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-14 21:06 [FFmpeg-devel] [PATCH 1/4] avfilter/x86/vf_blend: use unaligned movs for output Marton Balint 2022-03-14 21:06 ` [FFmpeg-devel] [PATCH 2/4] avfilter/vf_zscale: fix number of threads Marton Balint 2022-03-14 21:58 ` Paul B Mahol 2022-03-16 11:33 ` Victoria Zhislina 2022-03-16 19:26 ` Marton Balint 2022-03-14 21:06 ` [FFmpeg-devel] [PATCH 3/4] avfilter/vf_zscale: properly check return value of slice threads Marton Balint 2022-03-14 21:59 ` Paul B Mahol 2022-03-14 21:06 ` [FFmpeg-devel] [PATCH 4/4] avfilter/vf_zscale: realign output buffer if needed Marton Balint 2022-03-14 21:59 ` Paul B Mahol 2022-03-16 20:52 ` James Almer 2022-03-16 20:58 ` James Almer [this message] 2022-03-16 22:01 ` Marton Balint 2022-03-18 10:40 ` [FFmpeg-devel] [PATCH 1/4] avfilter/x86/vf_blend: use unaligned movs for output Paul B Mahol 2022-03-20 23:56 ` Marton Balint
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=60bc72af-9b5f-5c28-048a-43645e102929@gmail.com \ --to=jamrial@gmail.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