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 40F7142222 for ; Tue, 1 Mar 2022 08:05:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF78F68B1D3; Tue, 1 Mar 2022 10:05:44 +0200 (EET) Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 485B068004A for ; Tue, 1 Mar 2022 10:05:39 +0200 (EET) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-2dbc48104beso33352157b3.5 for ; Tue, 01 Mar 2022 00:05:39 -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=K6jykUp/g1cAO+c2fGnnX1P6qk5Qvs+LMRJ4oXQ5bPw=; b=CJmJ387Ka6rPAfnMyq9Xv0jbM9G03uz8uQ1ZDfj8eZnbO5Se3Zv0GXGlhCLfgEDdk/ Vg2WMju833IdNOXe24GQSaF7fqPAYK1y5khrB/kB5yLTb/Ca3/BoZf5CNZXIOg2fIPkk TXSNY3bmwSOwS5dFvt5IhDBVVoL8gSl22XgCkorouZSj+9ACpRwu1aQLblgEEbjbjm8N Q+DkbMMoIaocHt9w88jTmcrQ1GhBJypLl1GKYbhrZNsW5VtUqtQiAENoFihTT1tjaotf PmeXX0DoVME6lJxz35eJSEO/9rqmnqpZ/F4PqkerUBrYYyb0dyf8jbRRL8AsJFdqnW7s RLjQ== 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=K6jykUp/g1cAO+c2fGnnX1P6qk5Qvs+LMRJ4oXQ5bPw=; b=r17Qfcv5cTMsEMEoj6gALJc8btMGViKBqx4p6n3PrLJ0DOM9QtccIvTXAhShffG2Jo tV9V4vu22kHjtjmaNDKdSHiN2ZN1069YReWnY7O2bR+bIiX1SinEAl+cYP8gdtadO1lM YUc9/tbn/F+7fVS4Fs0RrNBpvHqfZOULHjZzRqeK/2a7ucx//GXRxIe4B2PDYW61W7oT scgVPmk7DKoi9HAuuFIwHk8qL3EZ5InTjIX388w/qFcr+z5mf9ZFVaTqARxJBF7nEUM+ 9OaND52t81MA2crUssgQjsBOwvoZJ+K+L2vrUZAyhV6TBoRSkO3JvskY6LnoRZ/0T3qL jitQ== X-Gm-Message-State: AOAM532AhDW5i+xKraNrYlfqTv/P5kp+iK9PE8EGp1NntSpuph2ZBHrn lsv9cng2R0vPLb1Opt/md0sqAUsfYwiPMWTggD/9QYr3hRY= X-Google-Smtp-Source: ABdhPJzKDCn/FHtbuN9Ho13RygVyMfx7D06VbS4mcq9C6mdd0DHFGK0AIddDUrf1AzUWq34Ok1uRIbkI8FcxpyHDal0= X-Received: by 2002:a81:486:0:b0:2d7:7785:3f33 with SMTP id 128-20020a810486000000b002d777853f33mr24139860ywe.516.1646121937585; Tue, 01 Mar 2022 00:05:37 -0800 (PST) MIME-Version: 1.0 References: <20220221122715.424475-1-onemda@gmail.com> In-Reply-To: From: Paul B Mahol Date: Tue, 1 Mar 2022 09:07:16 +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 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 > > --- > > 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 > > > > #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".