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 3AD6E4248C for ; Wed, 16 Mar 2022 20:52:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5D77068B025; Wed, 16 Mar 2022 22:52:12 +0200 (EET) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE3E86808CA for ; Wed, 16 Mar 2022 22:52:05 +0200 (EET) Received: by mail-ot1-f43.google.com with SMTP id x8-20020a9d6288000000b005b22c373759so2224551otk.8 for ; Wed, 16 Mar 2022 13:52:05 -0700 (PDT) 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=/JmI0vmhh5T/Veq+2+ziLRlAr4ufz9ZPNcd/rBRLxr4=; b=Vj0ytZO2W0snjUyClR8sH2GQZG2XGfGCYzVPYIUlrje+Er9xw92sbtqoYzh/Vb0RCV zgqIIeqroMMLegS/ueKTCUbaWTrwheilZ3quZnizBHCRF11FDYgTCHrsG0/qUnhtF1v7 TXMR6qpNhj2HXrQCRAb5QYYSIMzvd6xzJbuwm4byri33PUiitVAInB43qTrdBegZ9hTE KE7KRhdXp9ZAfeItdR0BRs333I9Od4kQdtwfFe+dRxZDHypY4m2Qomj4iHRAc/dC6waY 9vESb9c+C/FBB7oz40QzKaoPCarw4JLtdbUVRT/OxMGhsjNzgA4XJTXnTUkRHFWwEtWz QflA== 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=/JmI0vmhh5T/Veq+2+ziLRlAr4ufz9ZPNcd/rBRLxr4=; b=EB7d2dnSMYc3GlsxjlhmMwXEaA2WYGWfjAr912qZpnN+n92J6Zy5N5boCKK0GlCZw9 exrN+Z0d55IU2EhvaBoP7NucWETdIr79Hi0faXPJfRAmcTWbu3HJMwg0gohRQ3qGFZhD CI0EnTX9MLw/RrSHWZSC5WS7XRIOyj2M+36/fG/2+AWtcguZzbdt3VjupGWOMOPLUbHt Q/iNHLQk7Gw+Sdi2CacarQuKOmhbsFItHTdnx9ZAyy5hWriXw7QmZE+i7+duat5LLWY+ ZkikzCSgbciv+5cyXwx1Olxw/scFtjIvFoH5AXkAqlNd73jg/9Q3VBmR8sa+EFX529tY f2qw== X-Gm-Message-State: AOAM532bMw/E74WrQoDTKaoZeH25rQmH/zCqEdQIJqmSg792VVBppZw3 jsnjyNpM7QOqfES7xoCW57fkPZyYCp01Gw== X-Google-Smtp-Source: ABdhPJzr+0S1Hiy2GF5ZcaUsj/fOqDCN2bV/X9qPQFJj7lRNNyiGjpVfesmLU964nrBbrXsV6jgNRg== X-Received: by 2002:a05:6830:2709:b0:5b0:69e:6b67 with SMTP id j9-20020a056830270900b005b0069e6b67mr615300otu.170.1647463923281; Wed, 16 Mar 2022 13:52:03 -0700 (PDT) Received: from [192.168.0.13] ([186.136.131.95]) by smtp.gmail.com with ESMTPSA id v21-20020a4ade95000000b00320f814c73bsm1354726oou.47.2022.03.16.13.52.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Mar 2022 13:52:02 -0700 (PDT) Message-ID: <905fd001-1562-816d-332e-4a0d10fcbfab@gmail.com> Date: Wed, 16 Mar 2022 17:52:01 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220314210603.23870-1-cus@passwd.hu> <20220314210603.23870-4-cus@passwd.hu> From: James Almer In-Reply-To: <20220314210603.23870-4-cus@passwd.hu> Subject: Re: [FFmpeg-devel] [PATCH 4/4] avfilter/vf_zscale: realign output buffer if needed 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/14/2022 6:06 PM, Marton Balint wrote: > Output buffer alignment might be different to ZIMG_ALIGNMENT or it may not be > aligned at all if a downstream filter (e.g. vf_pad) intentionally misaligns it. av_frame_get_buffer() align parameter is used to align linesizes, not buffers. av_malloc() has a hardcoded alignment defined at compile time based on configure settings. If what you need is aligned data pointers, you should either use the trick i used in the libdav1d wrapper, or change av_malloc() in order to use av_cpu_max_align(). > > Or maybe we should unconditionally always allocate output with > av_frame_get_buffer() instead of ff_get_video_buffer()? > > Signed-off-by: Marton Balint > --- > libavfilter/vf_zscale.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c > index ceefc95224..2061e38bcc 100644 > --- a/libavfilter/vf_zscale.c > +++ b/libavfilter/vf_zscale.c > @@ -632,7 +632,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des > return 0; > } > > -static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame) > +static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame, int needs_copy) > { > AVFrame *aligned = NULL; > int ret = 0, plane, planes; > @@ -654,10 +654,10 @@ static int realign_frame(const AVPixFmtDescriptor *desc, AVFrame **frame) > if ((ret = av_frame_get_buffer(aligned, ZIMG_ALIGNMENT)) < 0) > goto fail; > > - if ((ret = av_frame_copy(aligned, *frame)) < 0) > + if (needs_copy && (ret = av_frame_copy(aligned, *frame)) < 0) > goto fail; > > - if ((ret = av_frame_copy_props(aligned, *frame)) < 0) > + if (needs_copy && (ret = av_frame_copy_props(aligned, *frame)) < 0) > goto fail; > > av_frame_free(frame); > @@ -786,9 +786,12 @@ static int filter_frame(AVFilterLink *link, AVFrame *in) > goto fail; > } > > + if ((ret = realign_frame(odesc, &out, 0)) < 0) > + goto fail; > + > av_frame_copy_props(out, in); > > - if ((ret = realign_frame(desc, &in)) < 0) > + if ((ret = realign_frame(desc, &in, 1)) < 0) > goto fail; > > snprintf(buf, sizeof(buf)-1, "%d", outlink->w); _______________________________________________ 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".