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 C932C49FAC for ; Sun, 17 Mar 2024 20:01:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ADCB168D1D0; Sun, 17 Mar 2024 22:01:17 +0200 (EET) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4B8E768CE16 for ; Sun, 17 Mar 2024 22:01:10 +0200 (EET) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-513c8b72b24so4040429e87.3 for ; Sun, 17 Mar 2024 13:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710705669; x=1711310469; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fUiSfTg77PKxwGlt5i3KDYZDuzE5HlYxtvwdcZx5qco=; b=fZkCNNMDyorwkL9jFxYpy2gyEcN6Yra55BHntBeuwia9b25os42Q6Ry9jhoQrVGrzj lFZ1Y9nTBgENvmcWLyaALv/8Tx9/IoiGzKcfpDDjwscTUxsIdDBqd3/FRndGkcKonR7/ 4Nm4+syItL1u0rHvsC0zCHh8RVCZ52fk83lqq+bVvCdWt3TIOnueByErr3TkxjX6ubr1 iSSNzz/V8EkZ9QOMuFLVMKMnVIC8RTSUTOHGCUc6OddVK0JRH21vLwGidhfMPuosszYP QW9i5eXOlv17bFtn1r9bFomNYMXfTJj8hl4ygr2bSyBYV8lU+eyWtECdBlKAKZgG4Sf7 f6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710705669; x=1711310469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fUiSfTg77PKxwGlt5i3KDYZDuzE5HlYxtvwdcZx5qco=; b=nKuqa5hxkMLTeP+9pA/Co92hvacbKfegRcDL7j2xeyfIdTAudJWsC414kvOvljd7tb GQBjIpdLvLW4wdRkIdmkrafnFZ29qpO8AjayYzQh2uGxf859CPxjr6rrgRbxWGQ9JdjO rfUPRPGv1FOc1Mody46v/MGYFAOmmUGdgjLRV1CsDhhYfBPuxNy6yV+ahoMNUcX9yLoH jUdifiqGkDOzAfZGfEDuQPygBaO0t6iZWmNM0ESnqAjVKEY8e4VIfNB18aJ9b+K/TkgG Rp8PtuBdjZZmVgZyKBEqPqJJxQl6Gy/EXy7mxfZ7fq7zflAHrslWlphXkbsCR/GUVkU2 13Mw== X-Gm-Message-State: AOJu0YwCLgoLUL6NMJ+j1hMKWpy5/yKyVzjkblMycNYpAiFAcc1j4il+ qWF4GFLFyIfAYz/E657O5cizdTIBlcQf26v7XelH8bk060nUpJt4tgB7DntA X-Google-Smtp-Source: AGHT+IHFrA3SaSYPdpLW2oh3/vqPrRLlpWGBre221sPDpkcCFr3qXObZWePMKUEXwFKitH1K/eF3wg== X-Received: by 2002:a19:ca0b:0:b0:513:dda5:a37f with SMTP id a11-20020a19ca0b000000b00513dda5a37fmr3359948lfg.23.1710705669340; Sun, 17 Mar 2024 13:01:09 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id y3-20020a056512044300b00513c844603fsm1340462lfk.41.2024.03.17.13.01.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Mar 2024 13:01:09 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Mar 2024 22:00:38 +0200 Message-ID: <20240317200100.152097-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240317200100.152097-1-jeebjp@gmail.com> References: <20240317200100.152097-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v9 01/14] avutil/frame: split side data list wiping out to non-AVFrame function 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: This will make it possible to to reuse logic in further commits. --- libavutil/frame.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 079cf6595b..ab425b2235 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -63,14 +63,19 @@ static void free_side_data(AVFrameSideData **ptr_sd) av_freep(ptr_sd); } -static void wipe_side_data(AVFrame *frame) +static void wipe_side_data(AVFrameSideData ***sd, int *nb_side_data) { - for (int i = 0; i < frame->nb_side_data; i++) { - free_side_data(&frame->side_data[i]); + for (int i = 0; i < *nb_side_data; i++) { + free_side_data(&((*sd)[i])); } - frame->nb_side_data = 0; + *nb_side_data = 0; + + av_freep(sd); +} - av_freep(&frame->side_data); +static void frame_side_data_wipe(AVFrame *frame) +{ + wipe_side_data(&frame->side_data, &frame->nb_side_data); } AVFrame *av_frame_alloc(void) @@ -288,7 +293,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data(dst, sd_src->type, sd_src->size); if (!sd_dst) { - wipe_side_data(dst); + frame_side_data_wipe(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); @@ -297,7 +302,7 @@ FF_ENABLE_DEPRECATION_WARNINGS sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, ref); if (!sd_dst) { av_buffer_unref(&ref); - wipe_side_data(dst); + frame_side_data_wipe(dst); return AVERROR(ENOMEM); } } @@ -437,7 +442,7 @@ int av_frame_replace(AVFrame *dst, const AVFrame *src) if (ret < 0) goto fail; - wipe_side_data(dst); + frame_side_data_wipe(dst); av_dict_free(&dst->metadata); ret = frame_copy_props(dst, src, 0); if (ret < 0) @@ -536,7 +541,7 @@ void av_frame_unref(AVFrame *frame) if (!frame) return; - wipe_side_data(frame); + frame_side_data_wipe(frame); for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]); -- 2.44.0 _______________________________________________ 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".