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 4BD2A40BEF for ; Tue, 8 Mar 2022 12:58:47 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2967668B122; Tue, 8 Mar 2022 14:58:45 +0200 (EET) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 85E8968A8A5 for ; Tue, 8 Mar 2022 14:58:38 +0200 (EET) Received: by mail-ot1-f51.google.com with SMTP id x8-20020a9d6288000000b005b22c373759so5370562otk.8 for ; Tue, 08 Mar 2022 04:58:38 -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=jill3f9NwzITo9k7lY8yQ3gpAW2XbyS+unv9PsoHKtw=; b=ASuTiaXnFOLdXveAbgVdn8f6vvvxfLOeO5aIVdk4lKTLUBiv+uqEaEQhmLq5gtNCUb ZMnN3zc/+o89zofxwV3SHm7wVr+jKr8wzRPwCwhgY1RFfBtW3dnGyDfXFJR3hVyrPjG0 vcT/7mOi0XbO7FjNs6ZcwGBj950qin7/1P946EKo52oSUY4CcXuVJf/3Niafq2t+XPlE Do2qSFRZ5lpDjC7ArPFOiDCOYcBdDiLXNOnJqaN24GoOsHRI26DTbCrcOA8KAg0KEh9l FQL14BlLhr3dDJ9Pj4mqGOycRuGmGk4EfRfrhQQEPOF2szKMCz/fPdofcqUK0rZwrzBN 7Iew== 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=jill3f9NwzITo9k7lY8yQ3gpAW2XbyS+unv9PsoHKtw=; b=YmgXcciDL8H2nJdBxL/CEJzqr8GtCTo/T1R8G9eWheXWJFU5E5mdhIh3m+AqifKOfB nWpySgZkgBn57J4KxXm9l2PZXFDui1cMF5KrC6YVEokEDZTdTZqV6YDQzjaOrDN/e9AN qY/KOnGqrCar1oi5hOBPOrzNTxKgCnFNq1SNmUv8GTRVVk4jvTyAEmLUlTrUYWfsgbYF oLVm9hAI0eiEFlWK7RzvN9j9u5DYHDOLqMuDxqhwq27+bLCDaIqtWCYODBMKnuUEf/6q wAuY03uF+QotEaDXtUbSV6ca3b2j9ujesENZslzzjZgNIjcF/lSXKk6ZmfRUNb408XNW C5QQ== X-Gm-Message-State: AOAM532Cnx+hYW1+fIdC/NHou4cnyTNoy8woYWFpqgJMHIxmS1XtBJTU YubUiYzTsL4UgasIif1uIBch2K1XvPg= X-Google-Smtp-Source: ABdhPJw+MxOOHiPnSSvxnXzsJ0ZsNdxkc2DmrCBmHktjKVi8mDM5x7ICczAIcI7U4RfWwWdETChP3A== X-Received: by 2002:a05:6830:4ca:b0:5b2:3595:9967 with SMTP id s10-20020a05683004ca00b005b235959967mr4958038otd.385.1646744316403; Tue, 08 Mar 2022 04:58:36 -0800 (PST) Received: from [192.168.0.10] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id n38-20020a056870822600b000da40b5af22sm2971680oae.31.2022.03.08.04.58.35 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Mar 2022 04:58:35 -0800 (PST) Message-ID: <66477573-dc45-daa0-eb26-11e587df8b3f@gmail.com> Date: Tue, 8 Mar 2022 09:58:33 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220306153939.5285-1-jamrial@gmail.com> <164674376831.19727.10448729510669371223@lain.red.khirnov.net> From: James Almer In-Reply-To: <164674376831.19727.10448729510669371223@lain.red.khirnov.net> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/hevc_refs: don't use the frame's AVBufferRef sizes when initializing planes 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/8/2022 9:49 AM, Anton Khirnov wrote: > Quoting James Almer (2022-03-06 16:39:39) >> Use the actual plane sizes instead. >> >> Signed-off-by: James Almer >> --- >> libavcodec/hevc_refs.c | 14 +++++++++++--- >> 1 file changed, 11 insertions(+), 3 deletions(-) >> >> diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c >> index 35b8e5e696..b0035356ac 100644 >> --- a/libavcodec/hevc_refs.c >> +++ b/libavcodec/hevc_refs.c >> @@ -22,6 +22,7 @@ >> */ >> >> #include "libavutil/avassert.h" >> +#include "libavutil/imgutils.h" >> >> #include "thread.h" >> #include "hevc.h" >> @@ -401,9 +402,16 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc) >> >> if (!s->avctx->hwaccel) { >> if (!s->ps.sps->pixel_shift) { >> - for (i = 0; frame->frame->buf[i]; i++) >> - memset(frame->frame->buf[i]->data, 1 << (s->ps.sps->bit_depth - 1), >> - frame->frame->buf[i]->size); >> + size_t sizes[4]; >> + ptrdiff_t linesizes[4]; >> + for (i = 0; i < 4; i++) >> + linesizes[i] = frame->frame->linesize[i]; >> + if (av_image_fill_plane_sizes(sizes, frame->frame->format, frame->frame->height, linesizes) < 0) { >> + ff_hevc_unref_frame(s, frame, ~0); >> + return NULL; >> + } >> + for (i = 0; frame->frame->data[i]; i++) >> + memset(frame->frame->data[i], 1 << (s->ps.sps->bit_depth - 1), sizes[i]); > > wouldn't it be simpler and shorter to use linesize[i] * (height >> sps->vshift)? That's what av_image_fill_plane_sizes() does to fill sizes[]. If we do it manually we also need to ensure to do it only for i > 0, so it's not that much of a simplification. But ok, will send a patch with that change. Could we for that matter change AVFrame linesize to ptrdiff_t in the next bump? Alongside the relevant imgutils helpers, if possible. Half this patch is just doing int -> ptrdiff_t, which is why it looks so big. _______________________________________________ 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".