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 2770A40FC2 for ; Sat, 12 Feb 2022 00:14:39 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 206E768AEE9; Sat, 12 Feb 2022 02:14:09 +0200 (EET) Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 63B8E68AF80 for ; Sat, 12 Feb 2022 02:14:01 +0200 (EET) Received: by mail-oi1-f170.google.com with SMTP id x4so1100156oic.9 for ; Fri, 11 Feb 2022 16:14:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=XR2CMMX7mL9Q0Tz5/MqHSV2QY4xN1jvYQjcEgKHTTLo=; b=XinrC94gDPxlK27Xrc6muJ5QcIEwmXw22i5lukr9EToaDqg0SFfnoGt+hD/CXLouMz nAQbCcqiDfoz+0U8pMRE4Yqa6VFMsAZCGnB9pTGpOGkbHNnk6if78u+rZgTGc9CQvnPM e05bUhzm8UZNp/BPclu6Qn71YvKMCtp+Ds+YccrK23CeUv1LgmKNdU59+J6VQ9Ee9XK2 nMr5XbTSEZeP7Q10XRWHljE0tgQ3GB+vnl9zpklchFmqY89aEcWEdN1R31to7j7SdDBG oT3mFCij314HQ+vATD5bVF8muNNfIo3SUnYROmskr8sqIM3se1zJVsQFR99013el7T+p ztPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XR2CMMX7mL9Q0Tz5/MqHSV2QY4xN1jvYQjcEgKHTTLo=; b=Zhh/ucVdutkLg+x9tgEjXQScI/v2/Ai9NFkK22/3ua78e8ezoZ1SS3O8bBLpgyAiT2 SzWc5UZR1CmTQSPj1roAhsTDu4zIUbMexB4OYQC40mgoShb8R4rcWgVmCnaCJ0BhwiK3 ellK0PSAs7fWnl4LTAxxkTVP5jo8w7HJmVPXKxxVPFWR8EC8Zt+hAzmYxOkKnJTxYoMD o2uImIW9YYNHRAOcsOSUsyVpUGaqiBVOnURAXPllQKKVNP7Ih0TpIO74jlwKuoT+qfOx V/LZkPVNu4aIa3F75ihXUZs4++IKa41N61OwHFJTr2HkIR70iXcokRTPEeSdKZqQF/ZO TrCA== X-Gm-Message-State: AOAM531QlAeu2tWEm4qnCUMQDqn18qXqGaObBLl6aAb2Uipm93b6Wmvi m9EU2637ggTkqIAPKihemApHGCq9uGg= X-Google-Smtp-Source: ABdhPJxa4iMpH/3bN6MurviW6UZ5fj0JApe6jISpu5j5IAIA2CdENliyoUcqWruxEXNO9EIGS3Ro6g== X-Received: by 2002:aca:ad97:: with SMTP id w145mr1363893oie.166.1644624839743; Fri, 11 Feb 2022 16:13:59 -0800 (PST) Received: from localhost.localdomain ([191.83.214.101]) by smtp.gmail.com with ESMTPSA id k19sm9777448oot.41.2022.02.11.16.13.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 16:13:59 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Feb 2022 21:13:01 -0300 Message-Id: <20220212001301.4090-4-jamrial@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220212001301.4090-1-jamrial@gmail.com> References: <20220212001301.4090-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] avformat/vapoursynth: stop hardcoding sizeof(AVFrame) 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: Use instead the new internal avpriv_avframe_size constant. This will ensure the actual size of AVFrame from the libavutil loaded at runtime is used instead. Also add the missing padding bytes required by the AVPacket API while at it. Signed-off-by: James Almer --- libavformat/vapoursynth.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/vapoursynth.c b/libavformat/vapoursynth.c index 1578a6ac77..5c57f3a71c 100644 --- a/libavformat/vapoursynth.c +++ b/libavformat/vapoursynth.c @@ -31,6 +31,7 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" #include "libavutil/eval.h" +#include "libavutil/frame_internal.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -344,6 +345,7 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) const AVPixFmtDescriptor *desc; AVBufferRef *vsframe_ref = NULL; struct vsframe_ref_data *ref_data; + const size_t size = avpriv_avframe_size; int err = 0; int i; @@ -382,11 +384,13 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) props = vs->vsapi->getFramePropsRO(vsframe); - frame = av_frame_alloc(); + frame = (AVFrame *)av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); if (!frame) { err = AVERROR(ENOMEM); goto end; } + // Set frame defaults + av_frame_unref(frame); frame->format = st->codecpar->format; frame->width = st->codecpar->width; @@ -432,8 +436,8 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) frame->buf[i]->size = frame->linesize[i] * plane_h; } - pkt->buf = av_buffer_create((uint8_t*)frame, sizeof(*frame), - free_frame, NULL, 0); + pkt->buf = av_buffer_create((uint8_t*)frame, size + AV_INPUT_BUFFER_PADDING_SIZE, + free_frame, NULL, AV_BUFFER_FLAG_READONLY); if (!pkt->buf) { err = AVERROR(ENOMEM); goto end; @@ -442,7 +446,7 @@ static int read_packet_vs(AVFormatContext *s, AVPacket *pkt) frame = NULL; // pkt owns it now pkt->data = pkt->buf->data; - pkt->size = pkt->buf->size; + pkt->size = size; pkt->flags |= AV_PKT_FLAG_TRUSTED; if (vs->is_cfr) -- 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".