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 7D8BC4206B for ; Mon, 21 Feb 2022 17:57:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 17B5568A8FD; Mon, 21 Feb 2022 19:57:38 +0200 (EET) Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBB416802C3 for ; Mon, 21 Feb 2022 19:57:30 +0200 (EET) Received: by mail-oo1-f53.google.com with SMTP id i6-20020a4ac506000000b0031c5ac6c078so6379565ooq.6 for ; Mon, 21 Feb 2022 09:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=+SE3u7YirV8PuK/yxf8qfzveF6gnWRLRBNLrsSvgtb8=; b=HrDLwJBhqCf1tQR/KCyKnTUUqcMWEat/tltSuvJB5t5o2ZNFdhLsroYMjZpQMQOPCl Xh6XRoGHf87Qac1+i2AXU0WaM4dfpHFvZVGE0pbvOuO2KEyqkKn4W4GYYT4pr4oNC6KR llCwJGVUF/eE6pJTEG6gBuIx+auEhlE5iVHFJdZEFABCwQhJf+pgde49tmK7E7O+miDz LsuF50f5phx6PHhgBuWULXqZ5GOKBQfgTTDoHyfAklAZH7cBpJYE45F9tSKA6xmqgYpL 7oiYxwrNudidrFBmW/FcUkGc6P75NSiZR4nvf1d+1nPUKjQbDNrzZmOahmlaNTpcpEkX 9NyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=+SE3u7YirV8PuK/yxf8qfzveF6gnWRLRBNLrsSvgtb8=; b=y9/S9abKhb5+3hZTu2AtOs+2+63ic0j5S7pX4sJTsnfaIIb2r/0o6lNVdYRGrz3TzA i1iLAGA8x5MVLmXtzweaLhx4I6ULT/QLu8J1cN+Ob1YPruqb+0eR2EQFAL5sV6xpMoB5 dwPBY8iY5vB4hZe09cm1KFtr14EpJJdHEYx1gaFQBFHsw0OtcuQZUZh07iDGk5OCiql0 WMWD6kheB/L5osOkuV8ixXnp+pT5Rqg2+SKI/56QJVMaFx9mOVMqo9ryKELdCStK+W8d PmlQzB7egDbJybKfZ8bweK/d50vqQGTBXH6COlHIM7GjZ2PMt9UQI153MntRX315iQ+H KVyQ== X-Gm-Message-State: AOAM532EzZk4C7sUGUsPPSWA5a00WKeG7WSMOJ8xR1qCrS6iTtvWFlOa 8ngwZfq/TME3+tI7TqNJlHv3LdP8dGgJag== X-Google-Smtp-Source: ABdhPJylvxAL8v+j7VlyyXqkLZ24qvx73nzPwuDq4CwHlKh/3UmXc6uzDZ4JXtDaGI9FQGYBo1kQ+w== X-Received: by 2002:a05:6870:a10f:b0:ce:c0c9:5cc with SMTP id m15-20020a056870a10f00b000cec0c905ccmr93098oae.30.1645466248907; Mon, 21 Feb 2022 09:57:28 -0800 (PST) Received: from [192.168.0.11] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id h30sm5800858otb.51.2022.02.21.09.57.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Feb 2022 09:57:28 -0800 (PST) Message-ID: <7e0b30ef-2d37-fba8-a5f7-9ef5dd678b69@gmail.com> Date: Mon, 21 Feb 2022 14:57:25 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220221122715.424475-1-onemda@gmail.com> From: James Almer In-Reply-To: <20220221122715.424475-1-onemda@gmail.com> 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 2/21/2022 9:27 AM, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > 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 > > #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".