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 B301746A9D for ; Thu, 29 Feb 2024 16:43:36 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D7B4B68D1C2; Thu, 29 Feb 2024 18:43:24 +0200 (EET) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8938F68D131 for ; Thu, 29 Feb 2024 18:43:17 +0200 (EET) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5131c48055cso1199601e87.1 for ; Thu, 29 Feb 2024 08:43:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709224997; x=1709829797; 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=RHkw25Juxh5yrUTZH86hFQuSA0cCadhyyy+WL+TEYx0=; b=OSjj9vsvkv3OpSBR+LwbODarXrxQHLfIwHQAdkZml819gndZNXr3sqTT+jsfgNeGTC +rn3xdek9cQhBLEGlO9g8ASVEdy1WKO6TXut37Q6rzr+A9GxYsYyk7uh0By96A+Zd/u8 FjlQ2O/aEgGGTGlDphR3NRXhqAa2WUir6YNf43eRCAbo2EsLkLUoJveFAqkU6ERL3wUF 2iwWI/RPoLlRBQz6ChMNoaiWE1cuF7rOkvu6gAqGkIFMC4qVrsMMvSZG8XU9Ni+2kHTk SqUvya3p//DPhoyXHTKoQhRQKhCs4kg39XycN+AEjkK/9AEzpGqmNjjEMQpYsLicE+N+ 6LUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709224997; x=1709829797; 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=RHkw25Juxh5yrUTZH86hFQuSA0cCadhyyy+WL+TEYx0=; b=YDyzS0s1GY6SUoGDOltaR+OsWVcgJJI3YKD0wBO++XColocoXDFqiz5jBE5m9r7Of9 3hVOUZKVnQu/1R5Cypc6lCeq68D8+dQ1EUJxU2zyzzwI89Hr3rXBKm6yTnApQBCahntg JSPh0EEwRjr4lm15oojJnMpTLgMN54DPnEk+ty4fockJRI/hPb+BNnfq0u6oMtPPl/KS u9wS0cMw4r+e4xInPTADjFYC9PmzW+0qsZvfBsDWklZxJ331QDo+Edtj0UlchzzmG622 s+nTtI+JIU48oNTagFbDj9AGe3IImAayc2ZF6HIPHPDBxh/ITyoXh/3+5hHQjFKOUQHG NJXQ== X-Gm-Message-State: AOJu0YyQHD4w/K5k6y9NsrwacqCyl9P7/uZxtnfbFOiAEijkjoCzQTxz kPu9J2jQXaeMww1cLYbFHnibnt6ID23VAUKgvv1+bpwmd05zbDbWDF8HF/K0 X-Google-Smtp-Source: AGHT+IHBPtzP1uHwWd/3d78CeYjSoz27DA77G0Oot7bOrY1Pcx714PI/UZCW11jc+e26VtlAdu5BSg== X-Received: by 2002:ac2:57c1:0:b0:512:e7dd:2532 with SMTP id k1-20020ac257c1000000b00512e7dd2532mr1693323lfo.30.1709224996537; Thu, 29 Feb 2024 08:43:16 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id k6-20020ac24566000000b00513290734cbsm206248lfm.292.2024.02.29.08.43.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 08:43:16 -0800 (PST) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Feb 2024 18:42:48 +0200 Message-ID: <20240229164307.3535613-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240229164307.3535613-1-jeebjp@gmail.com> References: <20240229164307.3535613-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v7 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 a3f07ca089..d94710687b 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -75,14 +75,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) @@ -337,7 +342,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); @@ -346,7 +351,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); } } @@ -525,7 +530,7 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif - wipe_side_data(dst); + frame_side_data_wipe(dst); av_dict_free(&dst->metadata); ret = frame_copy_props(dst, src, 0); if (ret < 0) @@ -624,7 +629,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".