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 24820496AA for ; Mon, 18 Mar 2024 21:32:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 46C5A68D388; Mon, 18 Mar 2024 23:31:59 +0200 (EET) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E44AE68D282 for ; Mon, 18 Mar 2024 23:31:50 +0200 (EET) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-513d3746950so5920580e87.1 for ; Mon, 18 Mar 2024 14:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710797510; x=1711402310; 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=W5/1RHWqC2cPmddcNByqoHiWEvb5xGrDf297itatVhg/C7WUIu6/XnmaQqXGzPNe5x KugHdq6MxFdBPt2fHslgLT/s1XX1IgBBr82oS+sTPAxY8A8l2j6lM07h/NMIhFSZPqWu 8hlWozlln/vRWBk5njEldpJWyXniDFkRX2DcWZzMr4knXdx/GLfj1U08Gr+U576Gjx6H 1gUYcnUiYa7eH3+pPO4nVs9qyW6G+5ZvTCK6nV+NDHmr5avwqHbwhh3flG81wkwaxL4V mWk0d+hQbOmGKyUILgc4ORhNTXHgLwJ0oX2XijF8ih4N+GMQAxgEQqGe2G2LCWxbrnRZ NtuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710797510; x=1711402310; 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=Yf0bEY0BYcDkmTuNlOhZOglpVw2yndPL5UBEX8ynxe8EV/DAtrn5V0ILRXMd4RCMdS DB5mJlzTKu/USpNsYVUtK9sjT76EOeZ4nSfv/a51/aeewwBo3tzQAuUiQtjTdcYx5MVL GBd7OXCLzh2LcI4npc5jje/5hSnU3c1k+IgbA5xV8viARntnwSD4ccExH+Xae2LMfhkX Ci4cS3P1fb0yKXSPavrPUBVR3rqqEejB5BI14Xtod+RQi5KEsqAwyt9XcvqSgNWdPn4C Z6nr2xi9Wpkq4aCfDU6dMqS1L7jLJCFLuMemYH+4VrHJaEGMgHBlHc6js7RXClH7aUMY aqAA== X-Gm-Message-State: AOJu0YzG8x+m7t1hUCaHRiTbBkRs9QXmpLj9nMZnwb00mu56DbxH4oER gUj4BeHEhK7gelCpmh3wbznaoB4UW0h3jQ2w6tyGvmBUVCdKkvkI76cg4az+ X-Google-Smtp-Source: AGHT+IFG+mO94SnPGDSAhiOTkCZonBr/VwqByLOxtS2d3gzvYbbuAnc7GccERMUrB29QVJKX3Xoc3Q== X-Received: by 2002:a19:384e:0:b0:512:be8e:79da with SMTP id d14-20020a19384e000000b00512be8e79damr8310627lfj.8.1710797510104; Mon, 18 Mar 2024 14:31:50 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id c13-20020a056512324d00b00514b5462dc7sm186929lfr.56.2024.03.18.14.31.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 14:31:49 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 18 Mar 2024 23:31:24 +0200 Message-ID: <20240318213141.1376789-2-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240318213141.1376789-1-jeebjp@gmail.com> References: <20240318213141.1376789-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v10 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".