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 89B1A42297 for ; Tue, 1 Mar 2022 15:03:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 01A0E68B27A; Tue, 1 Mar 2022 17:03:22 +0200 (EET) Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0688168A987 for ; Tue, 1 Mar 2022 17:03:16 +0200 (EET) Received: by mail-oi1-f176.google.com with SMTP id i5so16452514oih.1 for ; Tue, 01 Mar 2022 07:03:15 -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:content-language:to :references:from:subject:in-reply-to:content-transfer-encoding; bh=28D+5NHAmeyka7FXKiosqg+ICUbJzoCZtnX2r4DUZH8=; b=IJKWvtAxeKVnMou2EXbbyj4SCF7P7ODsS54pGsh8fPL/IXTNYrA6viNcZaRv7v8+hJ lSfCnbb3a7zl2RS9vyyFmo54fRGqaLR6ntRItrq0kEj0mPzzjEt3NpwKdrJ4h9t3LoeY k7JcMEfJXQtyJ/vnROA3dqgf8iMY67+l/Hgmn06gQBwwlk9do0jKfz5aZ+zb6Eyf0X3l Ta89glZ8KvDs8ytKNxSS2hfb6UV5zakUUhz6w9mhusdfjX9IRZ9Jto4PpB/5ilrtbBJV fC8zY3NftPzMO8njwAAhI+UvgOTTAOk3HPtL+oev2tC7PzgeMRGegQ+o/UXIBPunHvpF rf4w== 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 :content-language:to:references:from:subject:in-reply-to :content-transfer-encoding; bh=28D+5NHAmeyka7FXKiosqg+ICUbJzoCZtnX2r4DUZH8=; b=BddV76UAIQdyma1viKU2zL04L9m4mqGk+hqvsSq1SHwjdC4zY30gi/wLH/ntYam+w7 pvA2Nyhdz+s87bBd7WrM10IlI4gpJ9Nlv7rKA+Enk2LLcMDZ7tuInwLjD8NSTS4phEdS txzilQJEZtB9PM28mVoy8YbQbtKSbOUAIBtzdaH4/Jy5MkRTn/UYAvm1o4u4v7kS5SrJ DTyq70vLg1Rbyi7ixd+0catykrPU4jtwyWiarrCwPP9GtFYrVsXh1Ycdg00gMuTzGmyn sshxaXAMgZ7fERt4ESdd/meaqcJuFeU/99AgCQ49SfNTHMM8I3RJZNcAlTeLJlt6E3mY 7HYw== X-Gm-Message-State: AOAM53375pfGwTn33ADFDtyhpJe+SrFIbfdmZbqsldZ4eMgITfE8pD85 Qra+9GPu31zuXqgjFoFngGhLDjUU56X1iA== X-Google-Smtp-Source: ABdhPJwWtFKj6rbm6tredymHm2c4hbpy+Ou/99q8gcBgdKupZJWQ/TFX0EKeTep1wtoQAfKYMesbZw== X-Received: by 2002:a05:6808:14cd:b0:2d7:2ec3:a923 with SMTP id f13-20020a05680814cd00b002d72ec3a923mr15574790oiw.25.1646146992156; Tue, 01 Mar 2022 07:03:12 -0800 (PST) Received: from [192.168.0.10] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id i2-20020a056870c1c200b000d7355852b3sm2200365oad.19.2022.03.01.07.03.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 07:03:11 -0800 (PST) Message-ID: Date: Tue, 1 Mar 2022 12:03:09 -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: <20220301142310.16367-1-jamrial@gmail.com> <7b7c3b92-c5a6-9d50-bf79-07016ea02009@gmail.com> From: James Almer In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avfilter/framepool: use av_image_fill_plane_sizes() to calculate pool sizes 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 3/1/2022 11:53 AM, Paul B Mahol wrote: > On Tue, Mar 1, 2022 at 3:36 PM James Almer wrote: > >> On 3/1/2022 11:31 AM, Paul B Mahol wrote: >>> On Tue, Mar 1, 2022 at 3:23 PM James Almer wrote: >>> >>>> Signed-off-by: James Almer >>>> --- >>>> libavfilter/framepool.c | 20 ++++++++++++++------ >>>> 1 file changed, 14 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/libavfilter/framepool.c b/libavfilter/framepool.c >>>> index 5b510c9af9..cf6a1d0ea0 100644 >>>> --- a/libavfilter/framepool.c >>>> +++ b/libavfilter/framepool.c >>>> @@ -57,6 +57,8 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* >>>> (*alloc)(size_t size), >>>> int i, ret; >>>> FFFramePool *pool; >>>> const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format); >>>> + ptrdiff_t linesizes[4]; >>>> + size_t sizes[4]; >>>> >>>> if (!desc) >>>> return NULL; >>>> @@ -89,13 +91,19 @@ FFFramePool *ff_frame_pool_video_init(AVBufferRef* >>>> (*alloc)(size_t size), >>>> } >>>> } >>>> >>>> - for (i = 0; i < 4 && pool->linesize[i]; i++) { >>>> - int h = pool->height; >>>> - if (i == 1 || i == 2) >>>> - h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h); >>>> + for (i = 0; i < 4; i++) >>>> + linesizes[i] = pool->linesize[i]; >>>> >>>> - pool->pools[i] = av_buffer_pool_init(pool->linesize[i] * h + >>>> align, >>>> - alloc); >>>> + if (av_image_fill_plane_sizes(sizes, pool->format, >>>> + FFALIGN(pool->height, align), >>>> >>> >>> This is not needed for height. >> >> av_frame_get_buffer() does it, and the lavc pool uses >> avcodec_align_dimensions2() to align height and achieve the same effect >> (Look at what it does for yuv422p). It's the only change in >> 17a59a634c39b00a680c6ebbaea58db95594d13d that could have generated the >> issue Haihao reported. >> > > I see only victims of cargo cultism here. Filter frames are unrelated to > avcodec frames. > > Why I can not reproduce the issue, I'm on similar intel cpu. What CPU do you have? He has an Ice-Lake, so av_cpu_max_align() returns 64. Unless you have one of those, or an Alder-Lake with the E-cores disabled, you'll get 32 out of it. Hardcode align to 64 in ff_default_get_video_buffer() to reproduce the failure. Also, i was wrong and aligning height makes no difference, it will still fail, so the problem is elsewhere. > > >> >>> >>> Original reporter never posted valgrind report of bug. >>> >>> >>>> + linesizes) < 0) { >>>> + goto fail; >>>> + } >>>> + >>>> + for (i = 0; i < 4 && sizes[i]; i++) { >>>> + if (sizes[i] > SIZE_MAX - align) >>>> + goto fail; >>>> + pool->pools[i] = av_buffer_pool_init(sizes[i] + align, alloc); >>>> if (!pool->pools[i]) >>>> goto fail; >>>> } >>>> -- >>>> 2.35.1 >>>> >>>> _______________________________________________ >>>> 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". >> > _______________________________________________ > 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".