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 8243F40297 for ; Thu, 17 Aug 2023 21:49:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 12B0368C71F; Fri, 18 Aug 2023 00:49:09 +0300 (EEST) 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 2D67B68C552 for ; Fri, 18 Aug 2023 00:49:01 +0300 (EEST) Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-4ff92e369dfso297521e87.3 for ; Thu, 17 Aug 2023 14:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692308940; x=1692913740; 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=ogFJWMZX6zIk/onVXKv1EFunUb8leAUJGxwZxJXW2Oc=; b=m7vP+AbdAabNw/+xsNyW2bjp3rTHUkhSrM5PC+bcUt50cdwXhSxPmtnjxaYTtFn8pL X7x0B033spoTXosJgskMt0T/AiKr9da5UqsdfkH6+hZY5bkFYyNpP769X/vCxqh/4JhU kkcy2PadcILEgzNrV7lK1QJvBFsJHkKwH0hmFnFEdb3lbSVgT1bamuA6yZyz9RNSpKO0 EkD79vDLO49UbXDtZGazA9YtdiaOnx59AwcartEV8eGdqs1APlHC4HIk4+fmCzB1hLTl mgCNCo5p6fa2uEdvr2Ni3BGqAV2zGoNM0Xl0Yfb3wFF2Yv5LkyE704+XxZNBY0ZG/1Xe JZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692308940; x=1692913740; 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=ogFJWMZX6zIk/onVXKv1EFunUb8leAUJGxwZxJXW2Oc=; b=ccDZeTmEOvbczVhHkHFX/30D4G86bH0LxcT1wsO5uJmDJOjnBB27X581nVjRdfkDaI eUoo4y5Rc1fOSXluns3/tGoWhTi6nWH+KaMzfxKxaQo//3JvKf+LPpByADXSn9d6h5aj 9MzyAN+X6H/hVuzXUgOEjzMNaxmATbxNhdh+3gj3tEb6sKSdbN1ORVH6gJtwkHr9rATN T3LnRGYxhqpnQw6ogVJWWA5hdWYP5BsgUqtUxy7ZV6ca7CB4zvNQER8bRMNiPkdDYSE+ JG3viNrubb2x2mE+jwwk7xpE4coTSZ+WVfZ4IA/TH11biQ4kkhVOQwxHz3RNzAFygai2 lMWQ== X-Gm-Message-State: AOJu0Yy1J2UNwBAKpazelktrutcB0t/rrv1WRPIz6lAu87YRUG8z/2yA 5zvuhG86Z7sygRHwtnkljaf9hkNLM+g= X-Google-Smtp-Source: AGHT+IE9F68b+6DaJHDMsgearx5iaG1EdZxzGMr7H4derqgqjbGeFt/fHLl1akYh/i4RL/eV22j+dg== X-Received: by 2002:a05:6512:312a:b0:4fb:8435:3efc with SMTP id p10-20020a056512312a00b004fb84353efcmr310083lfd.16.1692308940168; Thu, 17 Aug 2023 14:49:00 -0700 (PDT) Received: from hifumi.mshome.net (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id w2-20020ac25982000000b004fe20d1b288sm62813lfn.159.2023.08.17.14.48.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Aug 2023 14:48:59 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 18 Aug 2023 00:48:40 +0300 Message-ID: <20230817214858.184010-3-jeebjp@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230817214858.184010-1-jeebjp@gmail.com> References: <20230817214858.184010-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 02/12] 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 b6cee2d886..4b8481b756 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.41.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".