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 B5801422F4 for ; Thu, 3 Mar 2022 13:49:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 941C168AFD0; Thu, 3 Mar 2022 15:48:58 +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 3FA3768030F for ; Thu, 3 Mar 2022 15:48:52 +0200 (EET) Received: by mail-oi1-f176.google.com with SMTP id j24so4799400oii.11 for ; Thu, 03 Mar 2022 05:48:52 -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 :from:to:references:in-reply-to:content-transfer-encoding; bh=v3LYM/HDsluT/WR7x+68ih/mnzP3CAk+lPzl4a92ook=; b=IgdOhwH/77GNzfhqA37o04t9godgPWDJDMMdcZ0d4BauPihxaMHieaMKc3Ttafj6Wf etHQi85onyFRWrdyT31zDy2ez35tX1hLNSkZTgwsv535svqcetebHkHkwllW5Gb2m9hy 4oSxvqGtE1EqKU68/OKYLeRsPH+jtlQP4wsFcCdKXor+jVrzMojokzr6qifiVlu597FA E+ShgT7LQYFQIIHJ5ogvVAqMCUqeDVemkMYdexKT643BTLoo91Is1RWUhBE0KESXtbaS ayYtOA3zOZ9JRw0/FBmBxNPntXe9IAttZByakJwmE7mwr73MHhST7/ZuUikbXluxPIO1 /UlA== 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:from:to:references:in-reply-to :content-transfer-encoding; bh=v3LYM/HDsluT/WR7x+68ih/mnzP3CAk+lPzl4a92ook=; b=1pW+2lyLMDsyWrHPYslg05ThDXpbQ1XYv4G0TKyDKWkNghB4Sqx69w2JWCZWBPoSw9 fXSGW1lq76H5K5DIpSbDaZehlrgDfItf5racIR30OyLeAp1FdyRUA9ZgJUHz8UW005ey 96O4oOoau01cND/rVJNrpQtQL35NOIqibQSocc/7iQfU6C00ggzJJ0od4oK/B+1Aifdc YHhCSJSdlouxD5RyJvog/QzYrDvSHwYi1MdkQq6XhW6BpIqsEPWPSOhCXj0eBOQE59Vw Qg4lDXnVd5rcDYuVZbnF6xm44JNr0n0oXOBVmWml5Hly1TyVevytlnbTOIwZGroKqqWU CepA== X-Gm-Message-State: AOAM530lCTWLlkeKFpUmRRCzjs66/JZc//F7wwt5XLibONNcuRtrkeAs IZbkIbAD6OuuzzgL1gLlJE0TqEhyev0= X-Google-Smtp-Source: ABdhPJxK1HTuhhY9YI7IPp0qN6NMBRoyh2G7fNrnEV7i5lKmtvEXn95BbbXMwiG+i1Goxbpu+tItaw== X-Received: by 2002:a05:6808:bc4:b0:2d7:d1a:bb with SMTP id o4-20020a0568080bc400b002d70d1a00bbmr4573162oik.179.1646315330212; Thu, 03 Mar 2022 05:48:50 -0800 (PST) Received: from [192.168.0.10] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id v6-20020a056830140600b005af1486cb20sm928856otp.10.2022.03.03.05.48.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 05:48:49 -0800 (PST) Message-ID: <1e6e3de9-b08f-6613-ae14-77914b8b8e39@gmail.com> Date: Thu, 3 Mar 2022 10:48:47 -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 From: James Almer To: ffmpeg-devel@ffmpeg.org References: <20220301142310.16367-1-jamrial@gmail.com> In-Reply-To: <20220301142310.16367-1-jamrial@gmail.com> 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:23 AM, 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), > + 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; > } Ping. I can also remove the height padding if preferred. _______________________________________________ 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".