From patchwork Fri Mar 31 16:21:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jan_Ekstr=C3=B6m?= X-Patchwork-Id: 40952 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851647pzb; Fri, 31 Mar 2023 09:22:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YiMGEN9MRCBKXOFa1Z7LjnQAqyUDj4937pze5NRMwieD0Y00OXD37Hkd2fz+VDdtqGe+SD X-Received: by 2002:aa7:c490:0:b0:4fa:315a:cb55 with SMTP id m16-20020aa7c490000000b004fa315acb55mr28820068edq.21.1680279773208; Fri, 31 Mar 2023 09:22:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279773; cv=none; d=google.com; s=arc-20160816; b=GVBR7MkUzdHbOTxAKUJ2YgtcwFO1on6Vss/8ctsV1d0v7YUQU/uVq/IAQ7UieFGy7e dLsbyMKXebN15Sx35kl/HbqoxYCl3zh6ibORpg59cJE5WNH+7DUjMXblFQ/RPiQwahJ3 gWzhEPhCXL+Ae+mcLxQWVoM41eosd2FJ4BI6WpY10JHYcNwRRehnQtj6UIPPO1l2VbiS sDL0mSPlEf1SYsv21psJYNStSlCtMLee6tCZLcjorI2mdiUBl89vZ1PeiGY//lDSZvhX cZ4eKmANdGluHhxIBzjTe8Zrnf8MjSGkX+kiQ+QPy7SyFSX6C0b4ILcP+nEWtKM9KBRT Eh1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=LS47aM0TguAWhKDF1I/i5kWVI1wnYsjWG1QAG2WVlE0=; b=InwiWocYb7amLVHyfYDsloyNqwWNy3AM6IEfZBO8AqOZCOZqZbQ2XmMDsc51Z+w//f BAcSNAYsfI+xDW/6royuMKxl9kA9jIMrTCiCPtPJScMYBROCKytmDTkkm0fAEO7IGdXE /RXAJ5ZnKjPS4intRxfAkgO59IMtgw3TsD8NyXrYp1/Ci2mEltsFi0BCjUyM2EEyvRgV qG5pJaRbyCnv4LZRNugg18kijQlowQd3eYx0hfGI9XMp7h9ikc+ZWcPdq8OgrEr1fOcg uvORKVfPaqUcOiNory3Ci+DtaGeKF2osOJfi6A1uIz+JZNx7n0mqsyvytXB6iun7/KoQ hxFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=d9LPhDLx; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n8-20020a056402514800b004bd1a7dba86si446297edd.410.2023.03.31.09.22.52; Fri, 31 Mar 2023 09:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=d9LPhDLx; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1A49B68C303; Fri, 31 Mar 2023 19:22:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5253568C283 for ; Fri, 31 Mar 2023 19:22:16 +0300 (EEST) Received: by mail-lj1-f171.google.com with SMTP id a44so4975841ljr.10 for ; Fri, 31 Mar 2023 09:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279735; 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=JWrL5L2Awwi8EyK5S5G0YfWizUrCXnEw0SdKnzbf4xA=; b=d9LPhDLx9undcNxWnT9p/lIwMSwdt8oOHAFb423IF8k+gCpP2zenroLV80/D7Qbp9b QwPt4APoYHsZvZqHIB9ZBvACkSided3FCSIf3sYfbyGauKQKIi44+WposAEgRMybC+yR nPXTQKYKuG/DSyXcM0ER7GIBOSHdGZfOdGj+guDZPN9JVZl5D7dyzW5R+lWuHUNwO//E 9fE4PFZParE0MWm/mF5OBp+TqqQ6SUmOALFsGH843dDjPXPqbMNBY16LXqEUFK7ycJf6 1PlKOeN0ETFaXuwRj5GnJG5MkKxI2iOTDxULbAmX1gC+EhMvzu0Rt2QjVpmMcBop7EXJ GN7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279735; 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=JWrL5L2Awwi8EyK5S5G0YfWizUrCXnEw0SdKnzbf4xA=; b=SDmSyb+Su5un7Mh9tlJz4OG/SLoVP9Ui4Klf9obu/mt8osZdN6pFesKxK0Lqb7zrwR P4v+NlhAhR19cp4QWOV0gJQ7/GJxUgHFL9hnHGX8l6HNsH8xl68uyhZy7qd81Kv8Kbd9 flp3N3VnGjIz4Ey6pd8YK6ZtZYlonXd6fxPVvs4Fut3TwGQNVNIdxS/SMSakj7eLbPTq sDpMiHwoFvgNWJlCrLZzuAo5nPCroqlkiqLcSWu201bdGShUbbcEPg+0UPfKP9V5pRRq OnS1KacU/t1UKHn43T5ZdMKkPvOAbZlrOADgvGpjoYUk6+DLGlQvrbKSX8F8YC+Pmf12 sdFw== X-Gm-Message-State: AAQBX9cWE/8tgudybUMHL+iQko+ZV5YPizvrQANKQz3tgQs0r6YW4hG4 U8Kp8Z/pxk9KTt8IDuVfRjGkc4A+J8A= X-Received: by 2002:a2e:9d82:0:b0:2a6:1780:7700 with SMTP id c2-20020a2e9d82000000b002a617807700mr1972234ljj.1.1680279735190; Fri, 31 Mar 2023 09:22:15 -0700 (PDT) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id n20-20020a2e8794000000b0029573844d03sm411483lji.109.2023.03.31.09.22.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:14 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:55 +0300 Message-Id: <20230331162205.428735-3-jeebjp@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230331162205.428735-1-jeebjp@gmail.com> References: <20230331162205.428735-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v1 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: bWYiRE3mDn/i --- libavutil/frame.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index c905e8d611..019613e4d2 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -76,14 +76,18 @@ 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 wipe_side_data_from_frame(AVFrame *frame) { + wipe_side_data(&frame->side_data, &frame->nb_side_data); } AVFrame *av_frame_alloc(void) @@ -326,7 +330,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); + wipe_side_data_from_frame(dst); return AVERROR(ENOMEM); } memcpy(sd_dst->data, sd_src->data, sd_src->size); @@ -335,7 +339,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); + wipe_side_data_from_frame(dst); return AVERROR(ENOMEM); } } @@ -486,7 +490,7 @@ void av_frame_unref(AVFrame *frame) if (!frame) return; - wipe_side_data(frame); + wipe_side_data_from_frame(frame); for (int i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++) av_buffer_unref(&frame->buf[i]);