* [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
@ 2022-02-20 22:02 Paul B Mahol
2022-02-20 22:02 ` [FFmpeg-devel] [PATCH] avformat/wvdec: parse last chunk that may store MD5 checksum Paul B Mahol
2022-02-21 1:53 ` [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters James Almer
0 siblings, 2 replies; 16+ messages in thread
From: Paul B Mahol @ 2022-02-20 22:02 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavfilter/audio.c | 11 +++++------
libavfilter/framepool.c | 16 ++++++----------
libavfilter/video.c | 11 +++++------
3 files changed, 16 insertions(+), 22 deletions(-)
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index cebc9709dd..a0408226a3 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -22,15 +22,13 @@
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
+#include "libavutil/cpu.h"
#include "audio.h"
#include "avfilter.h"
#include "framepool.h"
#include "internal.h"
-#define BUFFER_ALIGN 0
-
-
AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
@@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
AVFrame *frame = NULL;
int channels = link->channels;
int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
+ int align = av_cpu_max_align();
av_assert0(channels == channel_layout_nb_channels || !channel_layout_nb_channels);
if (!link->frame_pool) {
link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
- nb_samples, link->format, BUFFER_ALIGN);
+ nb_samples, link->format, align);
if (!link->frame_pool)
return NULL;
} else {
@@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
}
if (pool_channels != channels || pool_nb_samples < nb_samples ||
- pool_format != link->format || pool_align != BUFFER_ALIGN) {
+ pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
- nb_samples, link->format, BUFFER_ALIGN);
+ nb_samples, link->format, align);
if (!link->frame_pool)
return NULL;
}
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 7c63807df3..ebfd5dc0e0 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -76,14 +76,10 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
}
if (!pool->linesize[0]) {
- for(i = 1; i <= align; i += i) {
- ret = av_image_fill_linesizes(pool->linesize, pool->format,
- FFALIGN(pool->width, i));
- if (ret < 0) {
- goto fail;
- }
- if (!(pool->linesize[0] & (pool->align - 1)))
- break;
+ ret = av_image_fill_linesizes(pool->linesize, pool->format,
+ FFALIGN(pool->width, align));
+ if (ret < 0) {
+ goto fail;
}
for (i = 0; i < 4 && pool->linesize[i]; i++) {
@@ -92,11 +88,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
}
for (i = 0; i < 4 && pool->linesize[i]; i++) {
- int h = FFALIGN(pool->height, 32);
+ int h = pool->height;
if (i == 1 || i == 2)
h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
- pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 1,
+ pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h,
alloc);
if (!pool->pools[i])
goto fail;
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 7ef04144e4..fa3d588044 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "libavutil/buffer.h"
+#include "libavutil/cpu.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
@@ -32,9 +33,6 @@
#include "internal.h"
#include "video.h"
-#define BUFFER_ALIGN 32
-
-
AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
{
return ff_get_video_buffer(link->dst->outputs[0], w, h);
@@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
int pool_width = 0;
int pool_height = 0;
int pool_align = 0;
+ int align = av_cpu_max_align();
enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
if (link->hw_frames_ctx &&
@@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
if (!link->frame_pool) {
link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
- link->format, BUFFER_ALIGN);
+ link->format, align);
if (!link->frame_pool)
return NULL;
} else {
@@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
}
if (pool_width != w || pool_height != h ||
- pool_format != link->format || pool_align != BUFFER_ALIGN) {
+ pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
- link->format, BUFFER_ALIGN);
+ link->format, align);
if (!link->frame_pool)
return NULL;
}
--
2.33.0
_______________________________________________
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] 16+ messages in thread
* [FFmpeg-devel] [PATCH] avformat/wvdec: parse last chunk that may store MD5 checksum
2022-02-20 22:02 [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters Paul B Mahol
@ 2022-02-20 22:02 ` Paul B Mahol
2022-02-21 1:53 ` [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters James Almer
1 sibling, 0 replies; 16+ messages in thread
From: Paul B Mahol @ 2022-02-20 22:02 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavformat/wvdec.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/libavformat/wvdec.c b/libavformat/wvdec.c
index 0d5a86953d..ffefda1cce 100644
--- a/libavformat/wvdec.c
+++ b/libavformat/wvdec.c
@@ -108,7 +108,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
/* Blocks with zero samples don't contain actual audio information
* and should be ignored */
if (!wc->header.samples)
- return 0;
+ wc->block_parsed = 0;
// parse flags
flags = wc->header.flags;
rate_x = (flags & WV_DSD) ? 4 : 1;
@@ -121,7 +121,7 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
chan = wc->chan;
chmask = wc->chmask;
}
- if ((rate == -1 || !chan || flags & WV_DSD) && !wc->block_parsed) {
+ if ((rate == -1 || !chan || flags & WV_DSD || !wc->header.samples) && !wc->block_parsed) {
int64_t block_end = avio_tell(pb) + wc->header.blocksize;
if (!(pb->seekable & AVIO_SEEKABLE_NORMAL)) {
av_log(ctx, AV_LOG_ERROR,
@@ -187,6 +187,17 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
case 0x27:
rate = avio_rl24(pb);
break;
+ case 0x26:
+ if (size == 16) {
+ uint8_t md5[16];
+ char md5_hex[2 * sizeof(md5) + 1];
+
+ if (avio_read(pb, md5, 16) == 16) {
+ ff_data_to_hex(md5_hex, md5, sizeof(md5), 1);
+ av_log(ctx, AV_LOG_VERBOSE, "MD5=%s\n", md5_hex);
+ }
+ break;
+ }
default:
avio_skip(pb, size);
}
@@ -200,6 +211,8 @@ static int wv_read_block_header(AVFormatContext *ctx, AVIOContext *pb)
}
avio_seek(pb, block_end - wc->header.blocksize, SEEK_SET);
}
+ if (!wc->header.samples)
+ return 0;
if (!wc->bpp)
wc->bpp = bpp;
if (!wc->chan)
--
2.33.0
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-20 22:02 [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters Paul B Mahol
2022-02-20 22:02 ` [FFmpeg-devel] [PATCH] avformat/wvdec: parse last chunk that may store MD5 checksum Paul B Mahol
@ 2022-02-21 1:53 ` James Almer
2022-02-21 11:33 ` Paul B Mahol
1 sibling, 1 reply; 16+ messages in thread
From: James Almer @ 2022-02-21 1:53 UTC (permalink / raw)
To: ffmpeg-devel
On 2/20/2022 7:02 PM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
> libavfilter/audio.c | 11 +++++------
> libavfilter/framepool.c | 16 ++++++----------
> libavfilter/video.c | 11 +++++------
> 3 files changed, 16 insertions(+), 22 deletions(-)
>
> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> index cebc9709dd..a0408226a3 100644
> --- a/libavfilter/audio.c
> +++ b/libavfilter/audio.c
> @@ -22,15 +22,13 @@
> #include "libavutil/avassert.h"
> #include "libavutil/channel_layout.h"
> #include "libavutil/common.h"
> +#include "libavutil/cpu.h"
>
> #include "audio.h"
> #include "avfilter.h"
> #include "framepool.h"
> #include "internal.h"
>
> -#define BUFFER_ALIGN 0
> -
> -
> AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
> {
> return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
> AVFrame *frame = NULL;
> int channels = link->channels;
> int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
> + int align = av_cpu_max_align();
>
> av_assert0(channels == channel_layout_nb_channels || !channel_layout_nb_channels);
>
> if (!link->frame_pool) {
> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
> - nb_samples, link->format, BUFFER_ALIGN);
> + nb_samples, link->format, align);
> if (!link->frame_pool)
> return NULL;
> } else {
> @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
> }
>
> if (pool_channels != channels || pool_nb_samples < nb_samples ||
> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> + pool_format != link->format || pool_align != align) {
>
> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
> - nb_samples, link->format, BUFFER_ALIGN);
> + nb_samples, link->format, align);
> if (!link->frame_pool)
> return NULL;
> }
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index 7c63807df3..ebfd5dc0e0 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -76,14 +76,10 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
> }
>
> if (!pool->linesize[0]) {
> - for(i = 1; i <= align; i += i) {
> - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> - FFALIGN(pool->width, i));
> - if (ret < 0) {
> - goto fail;
> - }
> - if (!(pool->linesize[0] & (pool->align - 1)))
> - break;
> + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> + FFALIGN(pool->width, align));
> + if (ret < 0) {
> + goto fail;
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> @@ -92,11 +88,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> - int h = FFALIGN(pool->height, 32);
> + int h = pool->height;
> if (i == 1 || i == 2)
> h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>
> - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 1,
> + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h,
Why are you removing the padding on each plane? Just add align padding
bytes and it should be good.
> alloc);
> if (!pool->pools[i])
> goto fail;
> diff --git a/libavfilter/video.c b/libavfilter/video.c
> index 7ef04144e4..fa3d588044 100644
> --- a/libavfilter/video.c
> +++ b/libavfilter/video.c
> @@ -24,6 +24,7 @@
> #include <stdio.h>
>
> #include "libavutil/buffer.h"
> +#include "libavutil/cpu.h"
> #include "libavutil/hwcontext.h"
> #include "libavutil/imgutils.h"
>
> @@ -32,9 +33,6 @@
> #include "internal.h"
> #include "video.h"
>
> -#define BUFFER_ALIGN 32
> -
> -
> AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
> {
> return ff_get_video_buffer(link->dst->outputs[0], w, h);
> @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
> int pool_width = 0;
> int pool_height = 0;
> int pool_align = 0;
> + int align = av_cpu_max_align();
> enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
>
> if (link->hw_frames_ctx &&
> @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
>
> if (!link->frame_pool) {
> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
> - link->format, BUFFER_ALIGN);
> + link->format, align);
> if (!link->frame_pool)
> return NULL;
> } else {
> @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
> }
>
> if (pool_width != w || pool_height != h ||
> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> + pool_format != link->format || pool_align != align) {
>
> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
> - link->format, BUFFER_ALIGN);
> + link->format, align);
> if (!link->frame_pool)
> return NULL;
> }
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 1:53 ` [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters James Almer
@ 2022-02-21 11:33 ` Paul B Mahol
2022-02-21 12:08 ` James Almer
0 siblings, 1 reply; 16+ messages in thread
From: Paul B Mahol @ 2022-02-21 11:33 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Feb 21, 2022 at 2:54 AM James Almer <jamrial@gmail.com> wrote:
>
>
> On 2/20/2022 7:02 PM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol <onemda@gmail.com>
> > ---
> > libavfilter/audio.c | 11 +++++------
> > libavfilter/framepool.c | 16 ++++++----------
> > libavfilter/video.c | 11 +++++------
> > 3 files changed, 16 insertions(+), 22 deletions(-)
> >
> > diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> > index cebc9709dd..a0408226a3 100644
> > --- a/libavfilter/audio.c
> > +++ b/libavfilter/audio.c
> > @@ -22,15 +22,13 @@
> > #include "libavutil/avassert.h"
> > #include "libavutil/channel_layout.h"
> > #include "libavutil/common.h"
> > +#include "libavutil/cpu.h"
> >
> > #include "audio.h"
> > #include "avfilter.h"
> > #include "framepool.h"
> > #include "internal.h"
> >
> > -#define BUFFER_ALIGN 0
> > -
> > -
> > AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
> > {
> > return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> > @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link, int nb_samples)
> > AVFrame *frame = NULL;
> > int channels = link->channels;
> > int channel_layout_nb_channels =
> av_get_channel_layout_nb_channels(link->channel_layout);
> > + int align = av_cpu_max_align();
> >
> > av_assert0(channels == channel_layout_nb_channels ||
> !channel_layout_nb_channels);
> >
> > if (!link->frame_pool) {
> > link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> channels,
> > - nb_samples,
> link->format, BUFFER_ALIGN);
> > + nb_samples,
> link->format, align);
> > if (!link->frame_pool)
> > return NULL;
> > } else {
> > @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link, int nb_samples)
> > }
> >
> > if (pool_channels != channels || pool_nb_samples < nb_samples
> ||
> > - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> > + pool_format != link->format || pool_align != align) {
> >
> > ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> > link->frame_pool =
> ff_frame_pool_audio_init(av_buffer_allocz, channels,
> > - nb_samples,
> link->format, BUFFER_ALIGN);
> > + nb_samples,
> link->format, align);
> > if (!link->frame_pool)
> > return NULL;
> > }
> > diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> > index 7c63807df3..ebfd5dc0e0 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -76,14 +76,10 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
> > }
> >
> > if (!pool->linesize[0]) {
> > - for(i = 1; i <= align; i += i) {
> > - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > - FFALIGN(pool->width, i));
> > - if (ret < 0) {
> > - goto fail;
> > - }
> > - if (!(pool->linesize[0] & (pool->align - 1)))
> > - break;
> > + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > + FFALIGN(pool->width, align));
> > + if (ret < 0) {
> > + goto fail;
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > @@ -92,11 +88,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > - int h = FFALIGN(pool->height, 32);
> > + int h = pool->height;
> > if (i == 1 || i == 2)
> > h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
> >
> > - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16
> + 16 - 1,
> > + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h,
>
> Why are you removing the padding on each plane? Just add align padding
> bytes and it should be good.
>
linesize[i] is already aligned, why would there be need for additional
align at end of buffer?
> > alloc);
> > if (!pool->pools[i])
> > goto fail;
> > diff --git a/libavfilter/video.c b/libavfilter/video.c
> > index 7ef04144e4..fa3d588044 100644
> > --- a/libavfilter/video.c
> > +++ b/libavfilter/video.c
> > @@ -24,6 +24,7 @@
> > #include <stdio.h>
> >
> > #include "libavutil/buffer.h"
> > +#include "libavutil/cpu.h"
> > #include "libavutil/hwcontext.h"
> > #include "libavutil/imgutils.h"
> >
> > @@ -32,9 +33,6 @@
> > #include "internal.h"
> > #include "video.h"
> >
> > -#define BUFFER_ALIGN 32
> > -
> > -
> > AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
> > {
> > return ff_get_video_buffer(link->dst->outputs[0], w, h);
> > @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int w, int h)
> > int pool_width = 0;
> > int pool_height = 0;
> > int pool_align = 0;
> > + int align = av_cpu_max_align();
> > enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
> >
> > if (link->hw_frames_ctx &&
> > @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int w, int h)
> >
> > if (!link->frame_pool) {
> > link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz,
> w, h,
> > - link->format,
> BUFFER_ALIGN);
> > + link->format,
> align);
> > if (!link->frame_pool)
> > return NULL;
> > } else {
> > @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int w, int h)
> > }
> >
> > if (pool_width != w || pool_height != h ||
> > - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> > + pool_format != link->format || pool_align != align) {
> >
> > ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> > link->frame_pool =
> ff_frame_pool_video_init(av_buffer_allocz, w, h,
> > - link->format,
> BUFFER_ALIGN);
> > + link->format,
> align);
> > if (!link->frame_pool)
> > return NULL;
> > }
> _______________________________________________
> 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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 11:33 ` Paul B Mahol
@ 2022-02-21 12:08 ` James Almer
0 siblings, 0 replies; 16+ messages in thread
From: James Almer @ 2022-02-21 12:08 UTC (permalink / raw)
To: ffmpeg-devel
On 2/21/2022 8:33 AM, Paul B Mahol wrote:
> On Mon, Feb 21, 2022 at 2:54 AM James Almer <jamrial@gmail.com> wrote:
>
>>
>>
>> On 2/20/2022 7:02 PM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>> ---
>>> libavfilter/audio.c | 11 +++++------
>>> libavfilter/framepool.c | 16 ++++++----------
>>> libavfilter/video.c | 11 +++++------
>>> 3 files changed, 16 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
>>> index cebc9709dd..a0408226a3 100644
>>> --- a/libavfilter/audio.c
>>> +++ b/libavfilter/audio.c
>>> @@ -22,15 +22,13 @@
>>> #include "libavutil/avassert.h"
>>> #include "libavutil/channel_layout.h"
>>> #include "libavutil/common.h"
>>> +#include "libavutil/cpu.h"
>>>
>>> #include "audio.h"
>>> #include "avfilter.h"
>>> #include "framepool.h"
>>> #include "internal.h"
>>>
>>> -#define BUFFER_ALIGN 0
>>> -
>>> -
>>> AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
>>> {
>>> return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
>>> @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
>> *link, int nb_samples)
>>> AVFrame *frame = NULL;
>>> int channels = link->channels;
>>> int channel_layout_nb_channels =
>> av_get_channel_layout_nb_channels(link->channel_layout);
>>> + int align = av_cpu_max_align();
>>>
>>> av_assert0(channels == channel_layout_nb_channels ||
>> !channel_layout_nb_channels);
>>>
>>> if (!link->frame_pool) {
>>> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
>> channels,
>>> - nb_samples,
>> link->format, BUFFER_ALIGN);
>>> + nb_samples,
>> link->format, align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> } else {
>>> @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
>> *link, int nb_samples)
>>> }
>>>
>>> if (pool_channels != channels || pool_nb_samples < nb_samples
>> ||
>>> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
>>> + pool_format != link->format || pool_align != align) {
>>>
>>> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
>>> link->frame_pool =
>> ff_frame_pool_audio_init(av_buffer_allocz, channels,
>>> - nb_samples,
>> link->format, BUFFER_ALIGN);
>>> + nb_samples,
>> link->format, align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> }
>>> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
>>> index 7c63807df3..ebfd5dc0e0 100644
>>> --- a/libavfilter/framepool.c
>>> +++ b/libavfilter/framepool.c
>>> @@ -76,14 +76,10 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
>> (*alloc)(size_t size),
>>> }
>>>
>>> if (!pool->linesize[0]) {
>>> - for(i = 1; i <= align; i += i) {
>>> - ret = av_image_fill_linesizes(pool->linesize, pool->format,
>>> - FFALIGN(pool->width, i));
>>> - if (ret < 0) {
>>> - goto fail;
>>> - }
>>> - if (!(pool->linesize[0] & (pool->align - 1)))
>>> - break;
>>> + ret = av_image_fill_linesizes(pool->linesize, pool->format,
>>> + FFALIGN(pool->width, align));
>>> + if (ret < 0) {
>>> + goto fail;
>>> }
>>>
>>> for (i = 0; i < 4 && pool->linesize[i]; i++) {
>>> @@ -92,11 +88,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
>> (*alloc)(size_t size),
>>> }
>>>
>>> for (i = 0; i < 4 && pool->linesize[i]; i++) {
>>> - int h = FFALIGN(pool->height, 32);
>>> + int h = pool->height;
>>> if (i == 1 || i == 2)
>>> h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>>>
>>> - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16
>> + 16 - 1,
>>> + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h,
>>
>> Why are you removing the padding on each plane? Just add align padding
>> bytes and it should be good.
>>
>
> linesize[i] is already aligned, why would there be need for additional
> align at end of buffer?
FFALIGN(pool->width, align) can be pool->width. If so, then there would
be no padding at all.
>
>
>>> alloc);
>>> if (!pool->pools[i])
>>> goto fail;
>>> diff --git a/libavfilter/video.c b/libavfilter/video.c
>>> index 7ef04144e4..fa3d588044 100644
>>> --- a/libavfilter/video.c
>>> +++ b/libavfilter/video.c
>>> @@ -24,6 +24,7 @@
>>> #include <stdio.h>
>>>
>>> #include "libavutil/buffer.h"
>>> +#include "libavutil/cpu.h"
>>> #include "libavutil/hwcontext.h"
>>> #include "libavutil/imgutils.h"
>>>
>>> @@ -32,9 +33,6 @@
>>> #include "internal.h"
>>> #include "video.h"
>>>
>>> -#define BUFFER_ALIGN 32
>>> -
>>> -
>>> AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
>>> {
>>> return ff_get_video_buffer(link->dst->outputs[0], w, h);
>>> @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
>> *link, int w, int h)
>>> int pool_width = 0;
>>> int pool_height = 0;
>>> int pool_align = 0;
>>> + int align = av_cpu_max_align();
>>> enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
>>>
>>> if (link->hw_frames_ctx &&
>>> @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
>> *link, int w, int h)
>>>
>>> if (!link->frame_pool) {
>>> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz,
>> w, h,
>>> - link->format,
>> BUFFER_ALIGN);
>>> + link->format,
>> align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> } else {
>>> @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
>> *link, int w, int h)
>>> }
>>>
>>> if (pool_width != w || pool_height != h ||
>>> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
>>> + pool_format != link->format || pool_align != align) {
>>>
>>> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
>>> link->frame_pool =
>> ff_frame_pool_video_init(av_buffer_allocz, w, h,
>>> - link->format,
>> BUFFER_ALIGN);
>>> + link->format,
>> align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> }
>> _______________________________________________
>> 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".
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-03-01 13:43 ` James Almer
@ 2022-03-02 7:23 ` Xiang, Haihao
0 siblings, 0 replies; 16+ messages in thread
From: Xiang, Haihao @ 2022-03-02 7:23 UTC (permalink / raw)
To: ffmpeg-devel
On Tue, 2022-03-01 at 10:43 -0300, James Almer wrote:
> On 3/1/2022 4:12 AM, Xiang, Haihao wrote:
> > Hi,
> >
> > fate-vsynth1-mpeg2-422 is broken after this patch (commit 17a59a6).
> >
> > --- ./tests/ref/vsynth/vsynth1-mpeg2-422 2021-11-22
> > 12:59:25.013517219 +0800
> > +++ tests/data/fate/vsynth1-mpeg2-422 2022-03-01 13:30:48.446378312 +0800
> > @@ -1,4 +1,4 @@
> > -6e135a1a27235a320311a932147846b4 *tests/data/fate/vsynth1-mpeg2-
> > 422.mpeg2video
> > -730780 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> > -0273cd8463d1fc115378748239951560 *tests/data/fate/vsynth1-mpeg2-
> > 422.out.rawvideo
> > -stddev: 10.27 PSNR: 27.90 MAXDIFF: 162 bytes: 7603200/ 7603200
> > +ac2bfd738a93180bd3cb285367236d85 *tests/data/fate/vsynth1-mpeg2-
> > 422.mpeg2video
> > +702035 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> > +b8db8de89c37fab3b9a0248c2820a5ed *tests/data/fate/vsynth1-mpeg2-
> > 422.out.rawvideo
> > +stddev: 10.30 PSNR: 27.87 MAXDIFF: 167 bytes: 7603200/ 7603200
> >
> > configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --
> > shlibdir=/usr/lib/x86_64-linux-gnu --disable-static --enable-shared --
> > enable-gpl
> >
> > It works with option --disable-ssse3
> >
> > Below is the info for my CPU
> >
> > $ cat /proc/cpuinfo | grep 'model name' | head -1
> > model name : Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
> >
> > Thanks
> > Haihao
>
> Does this help?
>
> > diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> > index 5b510c9af9..8258a79845 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -90,7 +90,7 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> > (*alloc)(size_t size),
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > - int h = pool->height;
> > + int h = FFALIGN(pool->height, align);
> > if (i == 1 || i == 2)
> > h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>
> It's the only behavior change i could find in the patch that could make
> a difference.
>
The above change doesn't work for me.
Thanks
Haihao
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-03-01 7:12 ` Xiang, Haihao
2022-03-01 8:07 ` Paul B Mahol
@ 2022-03-01 13:43 ` James Almer
2022-03-02 7:23 ` Xiang, Haihao
1 sibling, 1 reply; 16+ messages in thread
From: James Almer @ 2022-03-01 13:43 UTC (permalink / raw)
To: ffmpeg-devel
On 3/1/2022 4:12 AM, Xiang, Haihao wrote:
> Hi,
>
> fate-vsynth1-mpeg2-422 is broken after this patch (commit 17a59a6).
>
> --- ./tests/ref/vsynth/vsynth1-mpeg2-422 2021-11-22 12:59:25.013517219 +0800
> +++ tests/data/fate/vsynth1-mpeg2-422 2022-03-01 13:30:48.446378312 +0800
> @@ -1,4 +1,4 @@
> -6e135a1a27235a320311a932147846b4 *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> -730780 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> -0273cd8463d1fc115378748239951560 *tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
> -stddev: 10.27 PSNR: 27.90 MAXDIFF: 162 bytes: 7603200/ 7603200
> +ac2bfd738a93180bd3cb285367236d85 *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> +702035 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> +b8db8de89c37fab3b9a0248c2820a5ed *tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
> +stddev: 10.30 PSNR: 27.87 MAXDIFF: 167 bytes: 7603200/ 7603200
>
> configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --disable-static --enable-shared --enable-gpl
>
> It works with option --disable-ssse3
>
> Below is the info for my CPU
>
> $ cat /proc/cpuinfo | grep 'model name' | head -1
> model name : Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
>
> Thanks
> Haihao
Does this help?
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index 5b510c9af9..8258a79845 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -90,7 +90,7 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> - int h = pool->height;
> + int h = FFALIGN(pool->height, align);
> if (i == 1 || i == 2)
> h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
It's the only behavior change i could find in the patch that could make
a difference.
I'll send a different approach in a bit either way.
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-03-01 7:12 ` Xiang, Haihao
@ 2022-03-01 8:07 ` Paul B Mahol
2022-03-01 13:43 ` James Almer
1 sibling, 0 replies; 16+ messages in thread
From: Paul B Mahol @ 2022-03-01 8:07 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Tue, Mar 1, 2022 at 8:12 AM Xiang, Haihao <
haihao.xiang-at-intel.com@ffmpeg.org> wrote:
> On Mon, 2022-02-21 at 13:27 +0100, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol <onemda@gmail.com>
> > ---
> > libavfilter/audio.c | 11 +++++------
> > libavfilter/framepool.c | 18 ++++++++----------
> > libavfilter/video.c | 11 +++++------
> > 3 files changed, 18 insertions(+), 22 deletions(-)
> >
> > diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> > index cebc9709dd..a0408226a3 100644
> > --- a/libavfilter/audio.c
> > +++ b/libavfilter/audio.c
> > @@ -22,15 +22,13 @@
> > #include "libavutil/avassert.h"
> > #include "libavutil/channel_layout.h"
> > #include "libavutil/common.h"
> > +#include "libavutil/cpu.h"
> >
> > #include "audio.h"
> > #include "avfilter.h"
> > #include "framepool.h"
> > #include "internal.h"
> >
> > -#define BUFFER_ALIGN 0
> > -
> > -
> > AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
> > {
> > return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> > @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link,
> > int nb_samples)
> > AVFrame *frame = NULL;
> > int channels = link->channels;
> > int channel_layout_nb_channels =
> av_get_channel_layout_nb_channels(link-
> > >channel_layout);
> > + int align = av_cpu_max_align();
> >
> > av_assert0(channels == channel_layout_nb_channels ||
> > !channel_layout_nb_channels);
> >
> > if (!link->frame_pool) {
> > link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> > channels,
> > - nb_samples,
> link->format,
> > BUFFER_ALIGN);
> > + nb_samples,
> link->format,
> > align);
> > if (!link->frame_pool)
> > return NULL;
> > } else {
> > @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link,
> > int nb_samples)
> > }
> >
> > if (pool_channels != channels || pool_nb_samples < nb_samples ||
> > - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> > + pool_format != link->format || pool_align != align) {
> >
> > ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> > link->frame_pool =
> ff_frame_pool_audio_init(av_buffer_allocz,
> > channels,
> > - nb_samples,
> link-
> > >format, BUFFER_ALIGN);
> > + nb_samples,
> link-
> > >format, align);
> > if (!link->frame_pool)
> > return NULL;
> > }
> > diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> > index 7c63807df3..5b510c9af9 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> > (*alloc)(size_t size),
> > }
> >
> > if (!pool->linesize[0]) {
> > - for(i = 1; i <= align; i += i) {
> > - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > - FFALIGN(pool->width, i));
> > - if (ret < 0) {
> > - goto fail;
> > - }
> > - if (!(pool->linesize[0] & (pool->align - 1)))
> > - break;
> > + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > + FFALIGN(pool->width, align));
> > + if (ret < 0) {
> > + goto fail;
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
> > + if ((pool->linesize[i] & (pool->align - 1)))
> > + goto fail;
> > }
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > - int h = FFALIGN(pool->height, 32);
> > + int h = pool->height;
> > if (i == 1 || i == 2)
> > h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
> >
> > - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16
> + 16
> > - 1,
> > + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h +
> align,
> > alloc);
> > if (!pool->pools[i])
> > goto fail;
> > diff --git a/libavfilter/video.c b/libavfilter/video.c
> > index 7ef04144e4..fa3d588044 100644
> > --- a/libavfilter/video.c
> > +++ b/libavfilter/video.c
> > @@ -24,6 +24,7 @@
> > #include <stdio.h>
> >
> > #include "libavutil/buffer.h"
> > +#include "libavutil/cpu.h"
> > #include "libavutil/hwcontext.h"
> > #include "libavutil/imgutils.h"
> >
> > @@ -32,9 +33,6 @@
> > #include "internal.h"
> > #include "video.h"
> >
> > -#define BUFFER_ALIGN 32
> > -
> > -
> > AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
> > {
> > return ff_get_video_buffer(link->dst->outputs[0], w, h);
> > @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int
> > w, int h)
> > int pool_width = 0;
> > int pool_height = 0;
> > int pool_align = 0;
> > + int align = av_cpu_max_align();
> > enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
> >
> > if (link->hw_frames_ctx &&
> > @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int
> > w, int h)
> >
> > if (!link->frame_pool) {
> > link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz,
> w, h,
> > - link->format,
> > BUFFER_ALIGN);
> > + link->format,
> align);
> > if (!link->frame_pool)
> > return NULL;
> > } else {
> > @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link,
> > int w, int h)
> > }
> >
> > if (pool_width != w || pool_height != h ||
> > - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> > + pool_format != link->format || pool_align != align) {
> >
> > ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> > link->frame_pool =
> ff_frame_pool_video_init(av_buffer_allocz, w,
> > h,
> > - link->format,
> > BUFFER_ALIGN);
> > + link->format,
> align);
> > if (!link->frame_pool)
> > return NULL;
> > }
>
> Hi,
>
> fate-vsynth1-mpeg2-422 is broken after this patch (commit 17a59a6).
>
> --- ./tests/ref/vsynth/vsynth1-mpeg2-422 2021-11-22
> 12:59:25.013517219 +0800
> +++ tests/data/fate/vsynth1-mpeg2-422 2022-03-01 13:30:48.446378312 +0800
> @@ -1,4 +1,4 @@
> -6e135a1a27235a320311a932147846b4
> *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> -730780 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> -0273cd8463d1fc115378748239951560
> *tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
> -stddev: 10.27 PSNR: 27.90 MAXDIFF: 162 bytes: 7603200/ 7603200
> +ac2bfd738a93180bd3cb285367236d85
> *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> +702035 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
> +b8db8de89c37fab3b9a0248c2820a5ed
> *tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
> +stddev: 10.30 PSNR: 27.87 MAXDIFF: 167 bytes: 7603200/ 7603200
>
> configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu
> --shlibdir=/usr/lib/x86_64-linux-gnu --disable-static --enable-shared
> --enable-gpl
>
> It works with option --disable-ssse3
>
> Below is the info for my CPU
>
Works fine here.
>
> $ cat /proc/cpuinfo | grep 'model name' | head -1
> model name : Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
>
> Thanks
> Haihao
>
> _______________________________________________
> 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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 12:27 Paul B Mahol
2022-02-21 17:57 ` James Almer
@ 2022-03-01 7:12 ` Xiang, Haihao
2022-03-01 8:07 ` Paul B Mahol
2022-03-01 13:43 ` James Almer
1 sibling, 2 replies; 16+ messages in thread
From: Xiang, Haihao @ 2022-03-01 7:12 UTC (permalink / raw)
To: ffmpeg-devel
On Mon, 2022-02-21 at 13:27 +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
> libavfilter/audio.c | 11 +++++------
> libavfilter/framepool.c | 18 ++++++++----------
> libavfilter/video.c | 11 +++++------
> 3 files changed, 18 insertions(+), 22 deletions(-)
>
> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> index cebc9709dd..a0408226a3 100644
> --- a/libavfilter/audio.c
> +++ b/libavfilter/audio.c
> @@ -22,15 +22,13 @@
> #include "libavutil/avassert.h"
> #include "libavutil/channel_layout.h"
> #include "libavutil/common.h"
> +#include "libavutil/cpu.h"
>
> #include "audio.h"
> #include "avfilter.h"
> #include "framepool.h"
> #include "internal.h"
>
> -#define BUFFER_ALIGN 0
> -
> -
> AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
> {
> return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link,
> int nb_samples)
> AVFrame *frame = NULL;
> int channels = link->channels;
> int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link-
> >channel_layout);
> + int align = av_cpu_max_align();
>
> av_assert0(channels == channel_layout_nb_channels ||
> !channel_layout_nb_channels);
>
> if (!link->frame_pool) {
> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> channels,
> - nb_samples, link->format,
> BUFFER_ALIGN);
> + nb_samples, link->format,
> align);
> if (!link->frame_pool)
> return NULL;
> } else {
> @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link,
> int nb_samples)
> }
>
> if (pool_channels != channels || pool_nb_samples < nb_samples ||
> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> + pool_format != link->format || pool_align != align) {
>
> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> channels,
> - nb_samples, link-
> >format, BUFFER_ALIGN);
> + nb_samples, link-
> >format, align);
> if (!link->frame_pool)
> return NULL;
> }
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index 7c63807df3..5b510c9af9 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
> }
>
> if (!pool->linesize[0]) {
> - for(i = 1; i <= align; i += i) {
> - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> - FFALIGN(pool->width, i));
> - if (ret < 0) {
> - goto fail;
> - }
> - if (!(pool->linesize[0] & (pool->align - 1)))
> - break;
> + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> + FFALIGN(pool->width, align));
> + if (ret < 0) {
> + goto fail;
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
> + if ((pool->linesize[i] & (pool->align - 1)))
> + goto fail;
> }
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> - int h = FFALIGN(pool->height, 32);
> + int h = pool->height;
> if (i == 1 || i == 2)
> h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>
> - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16
> - 1,
> + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + align,
> alloc);
> if (!pool->pools[i])
> goto fail;
> diff --git a/libavfilter/video.c b/libavfilter/video.c
> index 7ef04144e4..fa3d588044 100644
> --- a/libavfilter/video.c
> +++ b/libavfilter/video.c
> @@ -24,6 +24,7 @@
> #include <stdio.h>
>
> #include "libavutil/buffer.h"
> +#include "libavutil/cpu.h"
> #include "libavutil/hwcontext.h"
> #include "libavutil/imgutils.h"
>
> @@ -32,9 +33,6 @@
> #include "internal.h"
> #include "video.h"
>
> -#define BUFFER_ALIGN 32
> -
> -
> AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
> {
> return ff_get_video_buffer(link->dst->outputs[0], w, h);
> @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int
> w, int h)
> int pool_width = 0;
> int pool_height = 0;
> int pool_align = 0;
> + int align = av_cpu_max_align();
> enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
>
> if (link->hw_frames_ctx &&
> @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int
> w, int h)
>
> if (!link->frame_pool) {
> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
> - link->format,
> BUFFER_ALIGN);
> + link->format, align);
> if (!link->frame_pool)
> return NULL;
> } else {
> @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link,
> int w, int h)
> }
>
> if (pool_width != w || pool_height != h ||
> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> + pool_format != link->format || pool_align != align) {
>
> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w,
> h,
> - link->format,
> BUFFER_ALIGN);
> + link->format, align);
> if (!link->frame_pool)
> return NULL;
> }
Hi,
fate-vsynth1-mpeg2-422 is broken after this patch (commit 17a59a6).
--- ./tests/ref/vsynth/vsynth1-mpeg2-422 2021-11-22 12:59:25.013517219 +0800
+++ tests/data/fate/vsynth1-mpeg2-422 2022-03-01 13:30:48.446378312 +0800
@@ -1,4 +1,4 @@
-6e135a1a27235a320311a932147846b4 *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
-730780 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
-0273cd8463d1fc115378748239951560 *tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
-stddev: 10.27 PSNR: 27.90 MAXDIFF: 162 bytes: 7603200/ 7603200
+ac2bfd738a93180bd3cb285367236d85 *tests/data/fate/vsynth1-mpeg2-422.mpeg2video
+702035 tests/data/fate/vsynth1-mpeg2-422.mpeg2video
+b8db8de89c37fab3b9a0248c2820a5ed *tests/data/fate/vsynth1-mpeg2-422.out.rawvideo
+stddev: 10.30 PSNR: 27.87 MAXDIFF: 167 bytes: 7603200/ 7603200
configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --shlibdir=/usr/lib/x86_64-linux-gnu --disable-static --enable-shared --enable-gpl
It works with option --disable-ssse3
Below is the info for my CPU
$ cat /proc/cpuinfo | grep 'model name' | head -1
model name : Intel(R) Core(TM) i5-1035G1 CPU @ 1.00GHz
Thanks
Haihao
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 18:14 ` Paul B Mahol
@ 2022-02-21 22:36 ` James Almer
0 siblings, 0 replies; 16+ messages in thread
From: James Almer @ 2022-02-21 22:36 UTC (permalink / raw)
To: ffmpeg-devel
On 2/21/2022 3:14 PM, Paul B Mahol wrote:
> On Mon, Feb 21, 2022 at 6:57 PM James Almer <jamrial@gmail.com> wrote:
>
>>
>>
>> On 2/21/2022 9:27 AM, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol <onemda@gmail.com>
>>> ---
>>> libavfilter/audio.c | 11 +++++------
>>> libavfilter/framepool.c | 18 ++++++++----------
>>> libavfilter/video.c | 11 +++++------
>>> 3 files changed, 18 insertions(+), 22 deletions(-)
>>>
>>> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
>>> index cebc9709dd..a0408226a3 100644
>>> --- a/libavfilter/audio.c
>>> +++ b/libavfilter/audio.c
>>> @@ -22,15 +22,13 @@
>>> #include "libavutil/avassert.h"
>>> #include "libavutil/channel_layout.h"
>>> #include "libavutil/common.h"
>>> +#include "libavutil/cpu.h"
>>>
>>> #include "audio.h"
>>> #include "avfilter.h"
>>> #include "framepool.h"
>>> #include "internal.h"
>>>
>>> -#define BUFFER_ALIGN 0
>>> -
>>> -
>>> AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
>>> {
>>> return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
>>> @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
>> *link, int nb_samples)
>>> AVFrame *frame = NULL;
>>> int channels = link->channels;
>>> int channel_layout_nb_channels =
>> av_get_channel_layout_nb_channels(link->channel_layout);
>>> + int align = av_cpu_max_align();
>>>
>>> av_assert0(channels == channel_layout_nb_channels ||
>> !channel_layout_nb_channels);
>>>
>>> if (!link->frame_pool) {
>>> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
>> channels,
>>> - nb_samples,
>> link->format, BUFFER_ALIGN);
>>> + nb_samples,
>> link->format, align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> } else {
>>> @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
>> *link, int nb_samples)
>>> }
>>>
>>> if (pool_channels != channels || pool_nb_samples < nb_samples
>> ||
>>> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
>>> + pool_format != link->format || pool_align != align) {
>>>
>>> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
>>> link->frame_pool =
>> ff_frame_pool_audio_init(av_buffer_allocz, channels,
>>> - nb_samples,
>> link->format, BUFFER_ALIGN);
>>> + nb_samples,
>> link->format, align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> }
>>> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
>>> index 7c63807df3..5b510c9af9 100644
>>> --- a/libavfilter/framepool.c
>>> +++ b/libavfilter/framepool.c
>>> @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
>> (*alloc)(size_t size),
>>> }
>>>
>>> if (!pool->linesize[0]) {
>>> - for(i = 1; i <= align; i += i) {
>>> - ret = av_image_fill_linesizes(pool->linesize, pool->format,
>>> - FFALIGN(pool->width, i));
>>> - if (ret < 0) {
>>> - goto fail;
>>> - }
>>> - if (!(pool->linesize[0] & (pool->align - 1)))
>>> - break;
>>> + ret = av_image_fill_linesizes(pool->linesize, pool->format,
>>> + FFALIGN(pool->width, align));
>>> + if (ret < 0) {
>>> + goto fail;
>>> }
>>>
>>> for (i = 0; i < 4 && pool->linesize[i]; i++) {
>>> pool->linesize[i] = FFALIGN(pool->linesize[i],
>> pool->align);
>>> + if ((pool->linesize[i] & (pool->align - 1)))
>>
>> Wont this check always succeed?
>>
>>
> Works here fine, it just there for case of possible programming error in
> future.
> It never enters that condition here.
Ok, LGTM then.
>
>
>>> + goto fail;
>>> }
>>> }
>>>
>>> for (i = 0; i < 4 && pool->linesize[i]; i++) {
>>> - int h = FFALIGN(pool->height, 32);
>>> + int h = pool->height;
>>> if (i == 1 || i == 2)
>>> h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>>>
>>> - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16
>> + 16 - 1,
>>> + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h +
>> align,
>>> alloc);
>>> if (!pool->pools[i])
>>> goto fail;
>>> diff --git a/libavfilter/video.c b/libavfilter/video.c
>>> index 7ef04144e4..fa3d588044 100644
>>> --- a/libavfilter/video.c
>>> +++ b/libavfilter/video.c
>>> @@ -24,6 +24,7 @@
>>> #include <stdio.h>
>>>
>>> #include "libavutil/buffer.h"
>>> +#include "libavutil/cpu.h"
>>> #include "libavutil/hwcontext.h"
>>> #include "libavutil/imgutils.h"
>>>
>>> @@ -32,9 +33,6 @@
>>> #include "internal.h"
>>> #include "video.h"
>>>
>>> -#define BUFFER_ALIGN 32
>>> -
>>> -
>>> AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
>>> {
>>> return ff_get_video_buffer(link->dst->outputs[0], w, h);
>>> @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
>> *link, int w, int h)
>>> int pool_width = 0;
>>> int pool_height = 0;
>>> int pool_align = 0;
>>> + int align = av_cpu_max_align();
>>> enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
>>>
>>> if (link->hw_frames_ctx &&
>>> @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
>> *link, int w, int h)
>>>
>>> if (!link->frame_pool) {
>>> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz,
>> w, h,
>>> - link->format,
>> BUFFER_ALIGN);
>>> + link->format,
>> align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> } else {
>>> @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
>> *link, int w, int h)
>>> }
>>>
>>> if (pool_width != w || pool_height != h ||
>>> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
>>> + pool_format != link->format || pool_align != align) {
>>>
>>> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
>>> link->frame_pool =
>> ff_frame_pool_video_init(av_buffer_allocz, w, h,
>>> - link->format,
>> BUFFER_ALIGN);
>>> + link->format,
>> align);
>>> if (!link->frame_pool)
>>> return NULL;
>>> }
>> _______________________________________________
>> 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".
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 17:57 ` James Almer
@ 2022-02-21 18:14 ` Paul B Mahol
2022-02-21 22:36 ` James Almer
0 siblings, 1 reply; 16+ messages in thread
From: Paul B Mahol @ 2022-02-21 18:14 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Feb 21, 2022 at 6:57 PM James Almer <jamrial@gmail.com> wrote:
>
>
> On 2/21/2022 9:27 AM, Paul B Mahol wrote:
> > Signed-off-by: Paul B Mahol <onemda@gmail.com>
> > ---
> > libavfilter/audio.c | 11 +++++------
> > libavfilter/framepool.c | 18 ++++++++----------
> > libavfilter/video.c | 11 +++++------
> > 3 files changed, 18 insertions(+), 22 deletions(-)
> >
> > diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> > index cebc9709dd..a0408226a3 100644
> > --- a/libavfilter/audio.c
> > +++ b/libavfilter/audio.c
> > @@ -22,15 +22,13 @@
> > #include "libavutil/avassert.h"
> > #include "libavutil/channel_layout.h"
> > #include "libavutil/common.h"
> > +#include "libavutil/cpu.h"
> >
> > #include "audio.h"
> > #include "avfilter.h"
> > #include "framepool.h"
> > #include "internal.h"
> >
> > -#define BUFFER_ALIGN 0
> > -
> > -
> > AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
> > {
> > return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> > @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link, int nb_samples)
> > AVFrame *frame = NULL;
> > int channels = link->channels;
> > int channel_layout_nb_channels =
> av_get_channel_layout_nb_channels(link->channel_layout);
> > + int align = av_cpu_max_align();
> >
> > av_assert0(channels == channel_layout_nb_channels ||
> !channel_layout_nb_channels);
> >
> > if (!link->frame_pool) {
> > link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz,
> channels,
> > - nb_samples,
> link->format, BUFFER_ALIGN);
> > + nb_samples,
> link->format, align);
> > if (!link->frame_pool)
> > return NULL;
> > } else {
> > @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink
> *link, int nb_samples)
> > }
> >
> > if (pool_channels != channels || pool_nb_samples < nb_samples
> ||
> > - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> > + pool_format != link->format || pool_align != align) {
> >
> > ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> > link->frame_pool =
> ff_frame_pool_audio_init(av_buffer_allocz, channels,
> > - nb_samples,
> link->format, BUFFER_ALIGN);
> > + nb_samples,
> link->format, align);
> > if (!link->frame_pool)
> > return NULL;
> > }
> > diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> > index 7c63807df3..5b510c9af9 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
> > }
> >
> > if (!pool->linesize[0]) {
> > - for(i = 1; i <= align; i += i) {
> > - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > - FFALIGN(pool->width, i));
> > - if (ret < 0) {
> > - goto fail;
> > - }
> > - if (!(pool->linesize[0] & (pool->align - 1)))
> > - break;
> > + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > + FFALIGN(pool->width, align));
> > + if (ret < 0) {
> > + goto fail;
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > pool->linesize[i] = FFALIGN(pool->linesize[i],
> pool->align);
> > + if ((pool->linesize[i] & (pool->align - 1)))
>
> Wont this check always succeed?
>
>
Works here fine, it just there for case of possible programming error in
future.
It never enters that condition here.
> > + goto fail;
> > }
> > }
> >
> > for (i = 0; i < 4 && pool->linesize[i]; i++) {
> > - int h = FFALIGN(pool->height, 32);
> > + int h = pool->height;
> > if (i == 1 || i == 2)
> > h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
> >
> > - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16
> + 16 - 1,
> > + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h +
> align,
> > alloc);
> > if (!pool->pools[i])
> > goto fail;
> > diff --git a/libavfilter/video.c b/libavfilter/video.c
> > index 7ef04144e4..fa3d588044 100644
> > --- a/libavfilter/video.c
> > +++ b/libavfilter/video.c
> > @@ -24,6 +24,7 @@
> > #include <stdio.h>
> >
> > #include "libavutil/buffer.h"
> > +#include "libavutil/cpu.h"
> > #include "libavutil/hwcontext.h"
> > #include "libavutil/imgutils.h"
> >
> > @@ -32,9 +33,6 @@
> > #include "internal.h"
> > #include "video.h"
> >
> > -#define BUFFER_ALIGN 32
> > -
> > -
> > AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
> > {
> > return ff_get_video_buffer(link->dst->outputs[0], w, h);
> > @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int w, int h)
> > int pool_width = 0;
> > int pool_height = 0;
> > int pool_align = 0;
> > + int align = av_cpu_max_align();
> > enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
> >
> > if (link->hw_frames_ctx &&
> > @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int w, int h)
> >
> > if (!link->frame_pool) {
> > link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz,
> w, h,
> > - link->format,
> BUFFER_ALIGN);
> > + link->format,
> align);
> > if (!link->frame_pool)
> > return NULL;
> > } else {
> > @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink
> *link, int w, int h)
> > }
> >
> > if (pool_width != w || pool_height != h ||
> > - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> > + pool_format != link->format || pool_align != align) {
> >
> > ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> > link->frame_pool =
> ff_frame_pool_video_init(av_buffer_allocz, w, h,
> > - link->format,
> BUFFER_ALIGN);
> > + link->format,
> align);
> > if (!link->frame_pool)
> > return NULL;
> > }
> _______________________________________________
> 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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 12:27 Paul B Mahol
@ 2022-02-21 17:57 ` James Almer
2022-02-21 18:14 ` Paul B Mahol
2022-03-01 7:12 ` Xiang, Haihao
1 sibling, 1 reply; 16+ messages in thread
From: James Almer @ 2022-02-21 17:57 UTC (permalink / raw)
To: ffmpeg-devel
On 2/21/2022 9:27 AM, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
> libavfilter/audio.c | 11 +++++------
> libavfilter/framepool.c | 18 ++++++++----------
> libavfilter/video.c | 11 +++++------
> 3 files changed, 18 insertions(+), 22 deletions(-)
>
> diff --git a/libavfilter/audio.c b/libavfilter/audio.c
> index cebc9709dd..a0408226a3 100644
> --- a/libavfilter/audio.c
> +++ b/libavfilter/audio.c
> @@ -22,15 +22,13 @@
> #include "libavutil/avassert.h"
> #include "libavutil/channel_layout.h"
> #include "libavutil/common.h"
> +#include "libavutil/cpu.h"
>
> #include "audio.h"
> #include "avfilter.h"
> #include "framepool.h"
> #include "internal.h"
>
> -#define BUFFER_ALIGN 0
> -
> -
> AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
> {
> return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
> @@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
> AVFrame *frame = NULL;
> int channels = link->channels;
> int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
> + int align = av_cpu_max_align();
>
> av_assert0(channels == channel_layout_nb_channels || !channel_layout_nb_channels);
>
> if (!link->frame_pool) {
> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
> - nb_samples, link->format, BUFFER_ALIGN);
> + nb_samples, link->format, align);
> if (!link->frame_pool)
> return NULL;
> } else {
> @@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
> }
>
> if (pool_channels != channels || pool_nb_samples < nb_samples ||
> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> + pool_format != link->format || pool_align != align) {
>
> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
> - nb_samples, link->format, BUFFER_ALIGN);
> + nb_samples, link->format, align);
> if (!link->frame_pool)
> return NULL;
> }
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index 7c63807df3..5b510c9af9 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
> }
>
> if (!pool->linesize[0]) {
> - for(i = 1; i <= align; i += i) {
> - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> - FFALIGN(pool->width, i));
> - if (ret < 0) {
> - goto fail;
> - }
> - if (!(pool->linesize[0] & (pool->align - 1)))
> - break;
> + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> + FFALIGN(pool->width, align));
> + if (ret < 0) {
> + goto fail;
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
> + if ((pool->linesize[i] & (pool->align - 1)))
Wont this check always succeed?
> + goto fail;
> }
> }
>
> for (i = 0; i < 4 && pool->linesize[i]; i++) {
> - int h = FFALIGN(pool->height, 32);
> + int h = pool->height;
> if (i == 1 || i == 2)
> h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
>
> - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 1,
> + pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + align,
> alloc);
> if (!pool->pools[i])
> goto fail;
> diff --git a/libavfilter/video.c b/libavfilter/video.c
> index 7ef04144e4..fa3d588044 100644
> --- a/libavfilter/video.c
> +++ b/libavfilter/video.c
> @@ -24,6 +24,7 @@
> #include <stdio.h>
>
> #include "libavutil/buffer.h"
> +#include "libavutil/cpu.h"
> #include "libavutil/hwcontext.h"
> #include "libavutil/imgutils.h"
>
> @@ -32,9 +33,6 @@
> #include "internal.h"
> #include "video.h"
>
> -#define BUFFER_ALIGN 32
> -
> -
> AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
> {
> return ff_get_video_buffer(link->dst->outputs[0], w, h);
> @@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
> int pool_width = 0;
> int pool_height = 0;
> int pool_align = 0;
> + int align = av_cpu_max_align();
> enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
>
> if (link->hw_frames_ctx &&
> @@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
>
> if (!link->frame_pool) {
> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
> - link->format, BUFFER_ALIGN);
> + link->format, align);
> if (!link->frame_pool)
> return NULL;
> } else {
> @@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
> }
>
> if (pool_width != w || pool_height != h ||
> - pool_format != link->format || pool_align != BUFFER_ALIGN) {
> + pool_format != link->format || pool_align != align) {
>
> ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
> link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
> - link->format, BUFFER_ALIGN);
> + link->format, align);
> if (!link->frame_pool)
> return NULL;
> }
_______________________________________________
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] 16+ messages in thread
* [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
@ 2022-02-21 12:27 Paul B Mahol
2022-02-21 17:57 ` James Almer
2022-03-01 7:12 ` Xiang, Haihao
0 siblings, 2 replies; 16+ messages in thread
From: Paul B Mahol @ 2022-02-21 12:27 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavfilter/audio.c | 11 +++++------
libavfilter/framepool.c | 18 ++++++++----------
libavfilter/video.c | 11 +++++------
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index cebc9709dd..a0408226a3 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -22,15 +22,13 @@
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
+#include "libavutil/cpu.h"
#include "audio.h"
#include "avfilter.h"
#include "framepool.h"
#include "internal.h"
-#define BUFFER_ALIGN 0
-
-
AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
@@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
AVFrame *frame = NULL;
int channels = link->channels;
int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
+ int align = av_cpu_max_align();
av_assert0(channels == channel_layout_nb_channels || !channel_layout_nb_channels);
if (!link->frame_pool) {
link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
- nb_samples, link->format, BUFFER_ALIGN);
+ nb_samples, link->format, align);
if (!link->frame_pool)
return NULL;
} else {
@@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
}
if (pool_channels != channels || pool_nb_samples < nb_samples ||
- pool_format != link->format || pool_align != BUFFER_ALIGN) {
+ pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
- nb_samples, link->format, BUFFER_ALIGN);
+ nb_samples, link->format, align);
if (!link->frame_pool)
return NULL;
}
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index 7c63807df3..5b510c9af9 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -76,27 +76,25 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
}
if (!pool->linesize[0]) {
- for(i = 1; i <= align; i += i) {
- ret = av_image_fill_linesizes(pool->linesize, pool->format,
- FFALIGN(pool->width, i));
- if (ret < 0) {
- goto fail;
- }
- if (!(pool->linesize[0] & (pool->align - 1)))
- break;
+ ret = av_image_fill_linesizes(pool->linesize, pool->format,
+ FFALIGN(pool->width, align));
+ if (ret < 0) {
+ goto fail;
}
for (i = 0; i < 4 && pool->linesize[i]; i++) {
pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
+ if ((pool->linesize[i] & (pool->align - 1)))
+ goto fail;
}
}
for (i = 0; i < 4 && pool->linesize[i]; i++) {
- int h = FFALIGN(pool->height, 32);
+ int h = pool->height;
if (i == 1 || i == 2)
h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
- pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 1,
+ pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + align,
alloc);
if (!pool->pools[i])
goto fail;
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 7ef04144e4..fa3d588044 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "libavutil/buffer.h"
+#include "libavutil/cpu.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
@@ -32,9 +33,6 @@
#include "internal.h"
#include "video.h"
-#define BUFFER_ALIGN 32
-
-
AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
{
return ff_get_video_buffer(link->dst->outputs[0], w, h);
@@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
int pool_width = 0;
int pool_height = 0;
int pool_align = 0;
+ int align = av_cpu_max_align();
enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
if (link->hw_frames_ctx &&
@@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
if (!link->frame_pool) {
link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
- link->format, BUFFER_ALIGN);
+ link->format, align);
if (!link->frame_pool)
return NULL;
} else {
@@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
}
if (pool_width != w || pool_height != h ||
- pool_format != link->format || pool_align != BUFFER_ALIGN) {
+ pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
- link->format, BUFFER_ALIGN);
+ link->format, align);
if (!link->frame_pool)
return NULL;
}
--
2.33.0
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-21 11:07 ` Anton Khirnov
@ 2022-02-21 11:34 ` Paul B Mahol
0 siblings, 0 replies; 16+ messages in thread
From: Paul B Mahol @ 2022-02-21 11:34 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Mon, Feb 21, 2022 at 12:08 PM Anton Khirnov <anton@khirnov.net> wrote:
> Quoting Paul B Mahol (2022-02-20 19:07:47)
> > diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> > index aab408d355..aaf1642b4f 100644
> > --- a/libavfilter/framepool.c
> > +++ b/libavfilter/framepool.c
> > @@ -76,15 +76,13 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef*
> (*alloc)(size_t size),
> > }
> >
> > if (!pool->linesize[0]) {
> > - for(i = 1; i <= align; i += i) {
> > - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > - FFALIGN(pool->width, i));
> > - if (ret < 0) {
> > - goto fail;
> > - }
> > - if (!(pool->linesize[0] & (pool->align - 1)))
> > - break;
> > + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> > + FFALIGN(pool->width, align));
> > + if (ret < 0) {
> > + goto fail;
> > }
> > + if ((pool->linesize[0] & (pool->align - 1)))
>
> Check all of them, not just the first one.
>
Will do, it could overflow (among other things) in theory and result than
would not be wanted one.
>
> Otherwise looks good.
>
> --
> 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".
>
_______________________________________________
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] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
2022-02-20 18:07 Paul B Mahol
@ 2022-02-21 11:07 ` Anton Khirnov
2022-02-21 11:34 ` Paul B Mahol
0 siblings, 1 reply; 16+ messages in thread
From: Anton Khirnov @ 2022-02-21 11:07 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Quoting Paul B Mahol (2022-02-20 19:07:47)
> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
> index aab408d355..aaf1642b4f 100644
> --- a/libavfilter/framepool.c
> +++ b/libavfilter/framepool.c
> @@ -76,15 +76,13 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
> }
>
> if (!pool->linesize[0]) {
> - for(i = 1; i <= align; i += i) {
> - ret = av_image_fill_linesizes(pool->linesize, pool->format,
> - FFALIGN(pool->width, i));
> - if (ret < 0) {
> - goto fail;
> - }
> - if (!(pool->linesize[0] & (pool->align - 1)))
> - break;
> + ret = av_image_fill_linesizes(pool->linesize, pool->format,
> + FFALIGN(pool->width, align));
> + if (ret < 0) {
> + goto fail;
> }
> + if ((pool->linesize[0] & (pool->align - 1)))
Check all of them, not just the first one.
Otherwise looks good.
--
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".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters
@ 2022-02-20 18:07 Paul B Mahol
2022-02-21 11:07 ` Anton Khirnov
0 siblings, 1 reply; 16+ messages in thread
From: Paul B Mahol @ 2022-02-20 18:07 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
libavfilter/audio.c | 11 +++++------
libavfilter/framepool.c | 18 ++++++++----------
libavfilter/video.c | 11 +++++------
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/libavfilter/audio.c b/libavfilter/audio.c
index cebc9709dd..a0408226a3 100644
--- a/libavfilter/audio.c
+++ b/libavfilter/audio.c
@@ -22,15 +22,13 @@
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
+#include "libavutil/cpu.h"
#include "audio.h"
#include "avfilter.h"
#include "framepool.h"
#include "internal.h"
-#define BUFFER_ALIGN 0
-
-
AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
{
return ff_get_audio_buffer(link->dst->outputs[0], nb_samples);
@@ -41,12 +39,13 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
AVFrame *frame = NULL;
int channels = link->channels;
int channel_layout_nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
+ int align = av_cpu_max_align();
av_assert0(channels == channel_layout_nb_channels || !channel_layout_nb_channels);
if (!link->frame_pool) {
link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
- nb_samples, link->format, BUFFER_ALIGN);
+ nb_samples, link->format, align);
if (!link->frame_pool)
return NULL;
} else {
@@ -62,11 +61,11 @@ AVFrame *ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
}
if (pool_channels != channels || pool_nb_samples < nb_samples ||
- pool_format != link->format || pool_align != BUFFER_ALIGN) {
+ pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
link->frame_pool = ff_frame_pool_audio_init(av_buffer_allocz, channels,
- nb_samples, link->format, BUFFER_ALIGN);
+ nb_samples, link->format, align);
if (!link->frame_pool)
return NULL;
}
diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c
index aab408d355..aaf1642b4f 100644
--- a/libavfilter/framepool.c
+++ b/libavfilter/framepool.c
@@ -76,15 +76,13 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
}
if (!pool->linesize[0]) {
- for(i = 1; i <= align; i += i) {
- ret = av_image_fill_linesizes(pool->linesize, pool->format,
- FFALIGN(pool->width, i));
- if (ret < 0) {
- goto fail;
- }
- if (!(pool->linesize[0] & (pool->align - 1)))
- break;
+ ret = av_image_fill_linesizes(pool->linesize, pool->format,
+ FFALIGN(pool->width, align));
+ if (ret < 0) {
+ goto fail;
}
+ if ((pool->linesize[0] & (pool->align - 1)))
+ goto fail;
for (i = 0; i < 4 && pool->linesize[i]; i++) {
pool->linesize[i] = FFALIGN(pool->linesize[i], pool->align);
@@ -92,11 +90,11 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* (*alloc)(size_t size),
}
for (i = 0; i < 4 && pool->linesize[i]; i++) {
- int h = FFALIGN(pool->height, 32);
+ int h = pool->height;
if (i == 1 || i == 2)
h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
- pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + 16 + 16 - 0,
+ pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h,
alloc);
if (!pool->pools[i])
goto fail;
diff --git a/libavfilter/video.c b/libavfilter/video.c
index 7ef04144e4..fa3d588044 100644
--- a/libavfilter/video.c
+++ b/libavfilter/video.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include "libavutil/buffer.h"
+#include "libavutil/cpu.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
@@ -32,9 +33,6 @@
#include "internal.h"
#include "video.h"
-#define BUFFER_ALIGN 32
-
-
AVFrame *ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
{
return ff_get_video_buffer(link->dst->outputs[0], w, h);
@@ -46,6 +44,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
int pool_width = 0;
int pool_height = 0;
int pool_align = 0;
+ int align = av_cpu_max_align();
enum AVPixelFormat pool_format = AV_PIX_FMT_NONE;
if (link->hw_frames_ctx &&
@@ -65,7 +64,7 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
if (!link->frame_pool) {
link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
- link->format, BUFFER_ALIGN);
+ link->format, align);
if (!link->frame_pool)
return NULL;
} else {
@@ -76,11 +75,11 @@ AVFrame *ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
}
if (pool_width != w || pool_height != h ||
- pool_format != link->format || pool_align != BUFFER_ALIGN) {
+ pool_format != link->format || pool_align != align) {
ff_frame_pool_uninit((FFFramePool **)&link->frame_pool);
link->frame_pool = ff_frame_pool_video_init(av_buffer_allocz, w, h,
- link->format, BUFFER_ALIGN);
+ link->format, align);
if (!link->frame_pool)
return NULL;
}
--
2.33.0
_______________________________________________
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] 16+ messages in thread
end of thread, other threads:[~2022-03-02 7:23 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-20 22:02 [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters Paul B Mahol
2022-02-20 22:02 ` [FFmpeg-devel] [PATCH] avformat/wvdec: parse last chunk that may store MD5 checksum Paul B Mahol
2022-02-21 1:53 ` [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters James Almer
2022-02-21 11:33 ` Paul B Mahol
2022-02-21 12:08 ` James Almer
-- strict thread matches above, loose matches on Subject: below --
2022-02-21 12:27 Paul B Mahol
2022-02-21 17:57 ` James Almer
2022-02-21 18:14 ` Paul B Mahol
2022-02-21 22:36 ` James Almer
2022-03-01 7:12 ` Xiang, Haihao
2022-03-01 8:07 ` Paul B Mahol
2022-03-01 13:43 ` James Almer
2022-03-02 7:23 ` Xiang, Haihao
2022-02-20 18:07 Paul B Mahol
2022-02-21 11:07 ` Anton Khirnov
2022-02-21 11:34 ` Paul B Mahol
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