From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4790E4034A for ; Mon, 21 Feb 2022 11:32:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 41B6368A785; Mon, 21 Feb 2022 13:32:18 +0200 (EET) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B72A86899EC for ; Mon, 21 Feb 2022 13:32:11 +0200 (EET) Received: by mail-yb1-f171.google.com with SMTP id y6so33631983ybc.5 for ; Mon, 21 Feb 2022 03:32:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=F/hf4WZzA2RHB131Yppyzn78On2PiPGwjpmEV23flmg=; b=Ty5XiAP29UQHm01RXd5tqp5eQWNZ2AB6l+DVxkSlTkOjF1u9J9dZhfdzZBGHuiJX9/ 0RCBmReu5RRCdt9n1BYgwPDjXFXKGr0naFl25PhU6T4ako++9u0uaDkC1A5yVyym1XOK oDE+lUlb+QAXeMnYhuK8+GpP2az0vA2Tkc5iAzhARRGrBiur5eI0QMV7A5845ShFWdGG vHNXir3MHwDasvihZuw+2f521nQKpsXaigJlp95QCY2AwwhjYjq64cio8wJputiYQQWv mweh1zv1/bIHSCRStbmF3sSLCgj2Hwb0dkUutYICE4K6E2D7Tv3xq2s8wPIFgm68KPgY f5Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=F/hf4WZzA2RHB131Yppyzn78On2PiPGwjpmEV23flmg=; b=JeL7ccIMXEAmgL7YtpPkZ3GOKGu2HsRHqWlM1atgRiWYXCFWsus+9hXfjGOVR7mCr2 e7HbzvbsEYyTQGzsHFNgPKAY4p2/rgZ6wY56RzXsdrs2UyCPJTUvN/No11YHPZje4iLg qCU6BrAa0f/dCt2W3aAvlSW8Yo3BRUI3W+6/d9PR+3fOHtbh7rGsS+mShMqpiBekmZY3 9IOxs09I79FtSUHQ+OpGXsRmXFSkG+SpvTbb43SzXG9HJ3D20ILAXXe6q1gGnx7r3X25 EcAGTWC9wWtearerYFZVi0dLJtxytXcktPeUL5Z5vHApx1r6vsVhf7tJOOQAo5wciTYQ +OAg== X-Gm-Message-State: AOAM532wHp4JfXsixLA0K0rrdO1XP4gk8JVRXCvP93FI3ip/gMi68Sh1 kI0nn15qkOZJ3fw6lCSeDrM5kC12j/h+ptX1GKvCj8f6EJc= X-Google-Smtp-Source: ABdhPJxkrGut7aXvRaoU2ivSvMr28yb4P0hIBtCtmG0PKVgf8kXcOo+Xozkn32b6o3iKBtskvLXI3xEXr3EwT0ea1wI= X-Received: by 2002:a25:ae22:0:b0:624:5e77:d2d6 with SMTP id a34-20020a25ae22000000b006245e77d2d6mr9470074ybj.571.1645443130197; Mon, 21 Feb 2022 03:32:10 -0800 (PST) MIME-Version: 1.0 References: <20220220220242.401901-1-onemda@gmail.com> <51258010-516b-ca27-4dba-3f05506ea5b3@gmail.com> In-Reply-To: <51258010-516b-ca27-4dba-3f05506ea5b3@gmail.com> From: Paul B Mahol Date: Mon, 21 Feb 2022 12:33:38 +0100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH] avfilter/framepool: fix alignment requirements for audio and video filters X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Mon, Feb 21, 2022 at 2:54 AM James Almer wrote: > > > On 2/20/2022 7:02 PM, Paul B Mahol wrote: > > Signed-off-by: Paul B Mahol > > --- > > 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 > > > > #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".