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 E154D48DF5 for ; Tue, 27 Feb 2024 22:12:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0815E68CB2D; Wed, 28 Feb 2024 00:12:46 +0200 (EET) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 086F168C119 for ; Wed, 28 Feb 2024 00:12:37 +0200 (EET) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2d27184197cso60225601fa.1 for ; Tue, 27 Feb 2024 14:12:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709071956; x=1709676756; 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=z0oik7AgsGKAGFTerOO8crnlz4XqejOv/RaXy9CdOa8=; b=Q737WFR3Ffcp0qT2i8SN0LVde4DZvqCf1P05lVXpFy6doRFTW7oSJrpdihP+Vdpy2C s49b3Fe18XRZqfro8wdR163HizdpmmKH+29mG2MV3XSXCK2CG3jA+bVs69bhJMTfBHJ4 esCq9ANUJHA0f4deCm3GaYQ8TDtKIw67LalwmUKGDCVUM+ubaxY3RlcEANkc0Gwggvhw Ishj2amd9YHypF79C/436Rkdd0zetobDm32BpHSxXjSEmRPWwBtzf38qN+HYfM08y+M/ AHW6QRQ65i/A7/K1EbFV65gtczVKnNdOU988ryBmPZgsAa3SO4yOoq6CMcbNBPzDbcEB ZXLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709071956; x=1709676756; 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=z0oik7AgsGKAGFTerOO8crnlz4XqejOv/RaXy9CdOa8=; b=v+tVoPFC/A5l3cmvnZ5/LJB2wg+DyLmQg7V2JwO6jjLGFHeMaBa2SI9NjlCKx2fP4J BY6mfYVhaWmRY6dPTDscQggmTOHkB8FXfvWCRPj7l0kTZUpcewc2ihy+Jje9cKqb3r66 nwlb++ONn1zr8xqY6hPN4gK6SZBbaW5esdARVq2tkFo5j0kMu1RDubxR3mEg0/dd4aZv vGUbwg6q7qwUc/hJrYvGD5g0NKYIiBZBGSGS666gtnxhTbw5lhdZov0dMlayNTqymsmv fF4l1qTfewYiTyKfLyOILCKmiSCQoclNyu6dGapoKaqnTddjWEmFokvhUyx5lLm/PavI isBw== X-Gm-Message-State: AOJu0YydCrkZLunZEQGlm2c+maTXYdOlXoKkvqYmOQ5gx4FiQcUhKgNB 3Qrm83Q1QWjnQ0u5YFUxeF10T2bsMnIgiivn2h2/aQJEfho8oYf54Exy5R24 X-Google-Smtp-Source: AGHT+IHZ6hMmwDHRWa65ucCWlwmtrD2rpemhHn8CnEDNoEFCw1V3TatVZV9u3gx3JRoxR2Tp5KZrZA== X-Received: by 2002:a2e:9cd1:0:b0:2d2:a7af:f017 with SMTP id g17-20020a2e9cd1000000b002d2a7aff017mr1184963ljj.49.1709071955901; Tue, 27 Feb 2024 14:12:35 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id j9-20020a2e8009000000b002d09bc941e8sm1373564ljg.139.2024.02.27.14.12.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 14:12:35 -0800 (PST) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Feb 2024 00:12:04 +0200 Message-ID: <20240227221226.1377758-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240227221226.1377758-1-jeebjp@gmail.com> References: <20240227221226.1377758-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v6 01/13] 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.43.2 _______________________________________________ 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".