* [FFmpeg-devel] [PATCH] fix pad artifacting
@ 2025-02-01 0:18 Ben Lu via ffmpeg-devel
2025-02-01 0:52 ` Michael Niedermayer
0 siblings, 1 reply; 6+ messages in thread
From: Ben Lu via ffmpeg-devel @ 2025-02-01 0:18 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Ben Lu
When using pad with eval=frame with variable frame sizes, we get
significant artifacting. This is due to incorrect frame sizes, resulting in
invalid frames. Made changes to use the output width and height for frame
sizes when using eval=frame, with if statement guards to make sure the
normal usage is unaffected
Signed-off-by: Ben Lu <benlu@x.com>
---
libavfilter/vf_pad.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 49fb272b24..846dd0a9f4 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -237,15 +237,24 @@ static AVFrame *get_video_buffer(AVFilterLink
*inlink, int w, int h)
if (s->inlink_w <= 0)
return NULL;
- frame = ff_get_video_buffer(inlink->dst->outputs[0],
- w + (s->w - s->in_w),
- h + (s->h - s->in_h) + (s->x > 0));
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ frame = ff_get_video_buffer(inlink->dst->outputs[0], s->w, s->h);
+ } else {
+ frame = ff_get_video_buffer(inlink->dst->outputs[0],
+ w + (s->w - s->in_w),
+ h + (s->h - s->in_h) + (s->x > 0));
+ }
if (!frame)
return NULL;
- frame->width = w;
- frame->height = h;
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ frame->width = s->w;
+ frame->height = s->h;
+ } else {
+ frame->width = w;
+ frame->height = h;
+ }
for (plane = 0; plane < 4 && frame->data[plane] &&
frame->linesize[plane]; plane++) {
int hsub = s->draw.hsub[plane];
@@ -358,9 +367,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*in)
if (needs_copy) {
av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible
allocating new frame\n");
- out = ff_get_video_buffer(outlink,
- FFMAX(inlink->w, s->w),
- FFMAX(inlink->h, s->h));
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ out = ff_get_video_buffer(outlink, s->w, s->h);
+ } else {
+ out = ff_get_video_buffer(outlink,
+ FFMAX(inlink->w, s->w),
+ FFMAX(inlink->h, s->h));
+ }
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
--
2.35.1.70.gdb80f58b59-twtrsrc
_______________________________________________
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fix pad artifacting
2025-02-01 0:18 [FFmpeg-devel] [PATCH] fix pad artifacting Ben Lu via ffmpeg-devel
@ 2025-02-01 0:52 ` Michael Niedermayer
2025-02-03 13:58 ` Ben Lu via ffmpeg-devel
0 siblings, 1 reply; 6+ messages in thread
From: Michael Niedermayer @ 2025-02-01 0:52 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1166 bytes --]
Hi
On Sat, Feb 01, 2025 at 12:18:08AM +0000, Ben Lu via ffmpeg-devel wrote:
> When using pad with eval=frame with variable frame sizes, we get
> significant artifacting. This is due to incorrect frame sizes, resulting in
> invalid frames. Made changes to use the output width and height for frame
> sizes when using eval=frame, with if statement guards to make sure the
> normal usage is unaffected
>
> Signed-off-by: Ben Lu <benlu@x.com>
> ---
> libavfilter/vf_pad.c | 29 +++++++++++++++++++++--------
> 1 file changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
> index 49fb272b24..846dd0a9f4 100644
> --- a/libavfilter/vf_pad.c
> +++ b/libavfilter/vf_pad.c
> @@ -237,15 +237,24 @@ static AVFrame *get_video_buffer(AVFilterLink
> *inlink, int w, int h)
error: corrupt patch at line 10
check your editor line/word wrap break settings or attach the patch or use git send-email
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
"I am not trying to be anyone's saviour, I'm trying to think about the
future and not be sad" - Elon Musk
[-- 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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fix pad artifacting
2025-02-01 0:52 ` Michael Niedermayer
@ 2025-02-03 13:58 ` Ben Lu via ffmpeg-devel
2025-02-03 15:22 ` James Almer
0 siblings, 1 reply; 6+ messages in thread
From: Ben Lu via ffmpeg-devel @ 2025-02-03 13:58 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Ben Lu
Sorry about that, it looks correct in gmail and sending to myself also
looks fine, not sure where the line width corruption is happening. Our org
doesn't allow programmatic email.
Is it possible to use this gist?
https://gist.github.com/ayroblu/1d7bbfdf82aa9a127abefa4c5d518cdb
Also trying again:
Signed-off-by: Ben Lu <benlu@x.com>
---
libavfilter/vf_pad.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 49fb272b24..846dd0a9f4 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -237,15 +237,24 @@ static AVFrame *get_video_buffer(AVFilterLink
*inlink, int w, int h)
if (s->inlink_w <= 0)
return NULL;
- frame = ff_get_video_buffer(inlink->dst->outputs[0],
- w + (s->w - s->in_w),
- h + (s->h - s->in_h) + (s->x > 0));
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ frame = ff_get_video_buffer(inlink->dst->outputs[0], s->w, s->h);
+ } else {
+ frame = ff_get_video_buffer(inlink->dst->outputs[0],
+ w + (s->w - s->in_w),
+ h + (s->h - s->in_h) + (s->x > 0));
+ }
if (!frame)
return NULL;
- frame->width = w;
- frame->height = h;
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ frame->width = s->w;
+ frame->height = s->h;
+ } else {
+ frame->width = w;
+ frame->height = h;
+ }
for (plane = 0; plane < 4 && frame->data[plane] &&
frame->linesize[plane]; plane++) {
int hsub = s->draw.hsub[plane];
@@ -358,9 +367,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
*in)
if (needs_copy) {
av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible
allocating new frame\n");
- out = ff_get_video_buffer(outlink,
- FFMAX(inlink->w, s->w),
- FFMAX(inlink->h, s->h));
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ out = ff_get_video_buffer(outlink, s->w, s->h);
+ } else {
+ out = ff_get_video_buffer(outlink,
+ FFMAX(inlink->w, s->w),
+ FFMAX(inlink->h, s->h));
+ }
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
--
2.35.1.70.gdb80f58b59-twtrsrc
On Sat, Feb 1, 2025 at 12:52 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:
> Hi
>
> On Sat, Feb 01, 2025 at 12:18:08AM +0000, Ben Lu via ffmpeg-devel wrote:
> > When using pad with eval=frame with variable frame sizes, we get
> > significant artifacting. This is due to incorrect frame sizes, resulting
> in
> > invalid frames. Made changes to use the output width and height for frame
> > sizes when using eval=frame, with if statement guards to make sure the
> > normal usage is unaffected
> >
> > Signed-off-by: Ben Lu <benlu@x.com>
> > ---
> > libavfilter/vf_pad.c | 29 +++++++++++++++++++++--------
> > 1 file changed, 21 insertions(+), 8 deletions(-)
> >
> > diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
> > index 49fb272b24..846dd0a9f4 100644
> > --- a/libavfilter/vf_pad.c
> > +++ b/libavfilter/vf_pad.c
> > @@ -237,15 +237,24 @@ static AVFrame *get_video_buffer(AVFilterLink
> > *inlink, int w, int h)
>
> error: corrupt patch at line 10
>
> check your editor line/word wrap break settings or attach the patch or use
> git send-email
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> "I am not trying to be anyone's saviour, I'm trying to think about the
> future and not be sad" - Elon Musk
>
> _______________________________________________
> 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".
>
_______________________________________________
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fix pad artifacting
2025-02-03 13:58 ` Ben Lu via ffmpeg-devel
@ 2025-02-03 15:22 ` James Almer
2025-02-03 16:02 ` Ben Lu via ffmpeg-devel
0 siblings, 1 reply; 6+ messages in thread
From: James Almer @ 2025-02-03 15:22 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 514 bytes --]
On 2/3/2025 10:58 AM, Ben Lu via ffmpeg-devel wrote:
> Sorry about that, it looks correct in gmail and sending to myself also
> looks fine, not sure where the line width corruption is happening. Our org
> doesn't allow programmatic email.
Looks like lines with a single blank space are being replaced by empty
lines.
>
> Is it possible to use this gist?
Try to attach the output of git format-patch to an email instead. That
gist is only a diff of changes and missing all the git commit info.
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fix pad artifacting
2025-02-03 15:22 ` James Almer
@ 2025-02-03 16:02 ` Ben Lu via ffmpeg-devel
2025-02-06 17:03 ` Michael Niedermayer
0 siblings, 1 reply; 6+ messages in thread
From: Ben Lu via ffmpeg-devel @ 2025-02-03 16:02 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: Ben Lu
[-- Attachment #1: Type: text/plain, Size: 1116 bytes --]
Sure, looks like gmail is complying with a plaintext email RFC. Let me try
attaching to eml with:
`git format-patch -s -o "outputfolder" --add-header "X-Unsent: 1" --suffix
.eml --to ffmpeg-devel@ffmpeg.org -1 0f497eb391b`
On Mon, Feb 3, 2025 at 3:22 PM James Almer <jamrial@gmail.com> wrote:
> On 2/3/2025 10:58 AM, Ben Lu via ffmpeg-devel wrote:
> > Sorry about that, it looks correct in gmail and sending to myself also
> > looks fine, not sure where the line width corruption is happening. Our
> org
> > doesn't allow programmatic email.
>
> Looks like lines with a single blank space are being replaced by empty
> lines.
>
> >
> > Is it possible to use this gist?
>
> Try to attach the output of git format-patch to an email instead. That
> gist is only a diff of changes and missing all the git commit info.
>
> _______________________________________________
> 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".
>
[-- Attachment #2: 0001-fix-pad-artifacts.eml --]
[-- Type: message/rfc822, Size: 2305 bytes --]
From: Ben Lu <benlu@x.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [PATCH] fix pad artifacts
Date: Fri, 31 Jan 2025 23:13:25 +0000
Signed-off-by: Ben Lu <benlu@x.com>
---
libavfilter/vf_pad.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c
index 49fb272b24..846dd0a9f4 100644
--- a/libavfilter/vf_pad.c
+++ b/libavfilter/vf_pad.c
@@ -237,15 +237,24 @@ static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h)
if (s->inlink_w <= 0)
return NULL;
- frame = ff_get_video_buffer(inlink->dst->outputs[0],
- w + (s->w - s->in_w),
- h + (s->h - s->in_h) + (s->x > 0));
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ frame = ff_get_video_buffer(inlink->dst->outputs[0], s->w, s->h);
+ } else {
+ frame = ff_get_video_buffer(inlink->dst->outputs[0],
+ w + (s->w - s->in_w),
+ h + (s->h - s->in_h) + (s->x > 0));
+ }
if (!frame)
return NULL;
- frame->width = w;
- frame->height = h;
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ frame->width = s->w;
+ frame->height = s->h;
+ } else {
+ frame->width = w;
+ frame->height = h;
+ }
for (plane = 0; plane < 4 && frame->data[plane] && frame->linesize[plane]; plane++) {
int hsub = s->draw.hsub[plane];
@@ -358,9 +367,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
if (needs_copy) {
av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible allocating new frame\n");
- out = ff_get_video_buffer(outlink,
- FFMAX(inlink->w, s->w),
- FFMAX(inlink->h, s->h));
+ if (s->eval_mode == EVAL_MODE_FRAME) {
+ out = ff_get_video_buffer(outlink, s->w, s->h);
+ } else {
+ out = ff_get_video_buffer(outlink,
+ FFMAX(inlink->w, s->w),
+ FFMAX(inlink->h, s->h));
+ }
if (!out) {
av_frame_free(&in);
return AVERROR(ENOMEM);
--
2.35.1.70.gdb80f58b59-twtrsrc
[-- Attachment #3: 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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH] fix pad artifacting
2025-02-03 16:02 ` Ben Lu via ffmpeg-devel
@ 2025-02-06 17:03 ` Michael Niedermayer
0 siblings, 0 replies; 6+ messages in thread
From: Michael Niedermayer @ 2025-02-06 17:03 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2080 bytes --]
Hi Ben
On Mon, Feb 03, 2025 at 04:02:15PM +0000, Ben Lu via ffmpeg-devel wrote:
> Sure, looks like gmail is complying with a plaintext email RFC. Let me try
> attaching to eml with:
> `git format-patch -s -o "outputfolder" --add-header "X-Unsent: 1" --suffix
> .eml --to ffmpeg-devel@ffmpeg.org -1 0f497eb391b`
>
> On Mon, Feb 3, 2025 at 3:22 PM James Almer <jamrial@gmail.com> wrote:
>
> > On 2/3/2025 10:58 AM, Ben Lu via ffmpeg-devel wrote:
> > > Sorry about that, it looks correct in gmail and sending to myself also
> > > looks fine, not sure where the line width corruption is happening. Our
> > org
> > > doesn't allow programmatic email.
> >
> > Looks like lines with a single blank space are being replaced by empty
> > lines.
> >
> > >
> > > Is it possible to use this gist?
> >
> > Try to attach the output of git format-patch to an email instead. That
> > gist is only a diff of changes and missing all the git commit info.
> >
> > _______________________________________________
> > 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".
> >
> Date: Fri, 31 Jan 2025 23:13:25 +0000
> From: Ben Lu <benlu@x.com>
> To: ffmpeg-devel@ffmpeg.org
> Subject: [PATCH] fix pad artifacts
>
> Signed-off-by: Ben Lu <benlu@x.com>
> ---
> libavfilter/vf_pad.c | 29 +++++++++++++++++++++--------
> 1 file changed, 21 insertions(+), 8 deletions(-)
A more verbose commit message would be good
Also do you have some testcase for this ?
or even better something that can be added to fate ? So that a regression
could be detected.
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If one takes all money from those who grow wealth and gives it to those who
do not grow wealth, 10 years later, almost the same people who where wealthy
will be wealthy again, the same people who where poor will be poor again.
[-- 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".
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-02-06 17:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-01 0:18 [FFmpeg-devel] [PATCH] fix pad artifacting Ben Lu via ffmpeg-devel
2025-02-01 0:52 ` Michael Niedermayer
2025-02-03 13:58 ` Ben Lu via ffmpeg-devel
2025-02-03 15:22 ` James Almer
2025-02-03 16:02 ` Ben Lu via ffmpeg-devel
2025-02-06 17:03 ` Michael Niedermayer
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