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 59BEE49DE1 for ; Mon, 11 Mar 2024 20:59:30 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E6B8068D123; Mon, 11 Mar 2024 22:58:56 +0200 (EET) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A5FBC68CC87 for ; Mon, 11 Mar 2024 22:58:47 +0200 (EET) Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-51323dfce59so3149658e87.3 for ; Mon, 11 Mar 2024 13:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710190727; x=1710795527; 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=SX/5t3OnNyyrTjUoUgECAvlHZbTTCZv0dEnzDbr+2vY=; b=DioehAkeulE5h2zuWFY+mLIaDYLpLG5NvP33yQDI8TTqxg8o4XGiCBbi0hor4N7BuB kVT4WcYIXsJY04XgZmMzEs5ivokqDGcYZpvIzru40AFjE+1Out2NMeQhMFn0BUwv9Rwk 952UrKlITr999REJrPFoUszi3IJweXmchg1T+A8HacglmqgMM6D246WoZQYCCqoWakzy UZpBw0ff3uhbbzYoL7eo1FKRSI313sq716rCc7tZupm5v9yS2nBU0uw77WI4mZgZLHyK oQzxL2lziDeGBPc+O5cWyAe8q7iZvk19ADaIB20q23yyXU8k4NK/EoGZkylAHMNUw2wr RInw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710190727; x=1710795527; 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=SX/5t3OnNyyrTjUoUgECAvlHZbTTCZv0dEnzDbr+2vY=; b=enkBwgp6sBjCW6wVzqJ21PwO/uB9s9pnhPBecx53IcM7L3nUMBC6YGrlcgCln+nFze JAWTJ6k9LbggIqIWE/UtWPctH95Rd8HgFAon93zYQ6WyjN26OwX7OxqSNRIMsKE+Gw3k DPFpwVWyoDt+sa//pX/3AAmEeFvUwocLwJQBagrVERpdnbvspnqpQMMeVdV8Uyl9d4bz Qyz6xEjuZOg44biGALkbtlcrm7EEvJvwTCEkNh1KV2ZDG83yLRHmb7qHDS6R8vph0T6S SoNdY6ZKYUiCi+6HCqGpXTrgfm3Bmv83Ta0tLGjt2sJFljkQdhxkTDfr/fEw+0i5XLXJ yejQ== X-Gm-Message-State: AOJu0YwqhpaseMjEusxXa/4TR5m49y3e7l/23Fe6wmHJboaMhp5T0thd AcutFkkmmLE4QRz9RkRxTLCqKyK7Utp1RsUq0yP1CqAnusX8CRVb/kemx7ZV X-Google-Smtp-Source: AGHT+IHIhQve3TDRsh8X6bQEngrIiWbUTRZCgsAgb0uem87IHEpsZAvnFZLh0Xz2iuZoMFx280wbSA== X-Received: by 2002:a05:6512:29a:b0:513:78c5:fcaa with SMTP id j26-20020a056512029a00b0051378c5fcaamr4740331lfp.39.1710190726744; Mon, 11 Mar 2024 13:58:46 -0700 (PDT) Received: from maomao.mshome.net (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id c17-20020ac25f71000000b0051333104075sm1249247lfc.259.2024.03.11.13.58.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 13:58:46 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Mar 2024 22:58:27 +0200 Message-ID: <20240311205844.3569895-5-jeebjp@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311205844.3569895-1-jeebjp@gmail.com> References: <20240311205844.3569895-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v8 04/14] avutil/frame: split side data removal 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 reuse logic in further commits. --- libavutil/frame.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 9ebe830c5c..dd27456031 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -83,6 +83,21 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd) wipe_side_data(sd, nb_sd); } +static void remove_side_data(AVFrameSideData ***sd, int *nb_side_data, + const enum AVFrameSideDataType type) +{ + for (int i = *nb_side_data - 1; i >= 0; i--) { + AVFrameSideData *entry = ((*sd)[i]); + if (entry->type != type) + continue; + + free_side_data(&entry); + + ((*sd)[i]) = ((*sd)[*nb_side_data - 1]); + (*nb_side_data)--; + } +} + AVFrame *av_frame_alloc(void) { AVFrame *frame = av_malloc(sizeof(*frame)); @@ -801,14 +816,7 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src) void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type) { - for (int i = frame->nb_side_data - 1; i >= 0; i--) { - AVFrameSideData *sd = frame->side_data[i]; - if (sd->type == type) { - free_side_data(&frame->side_data[i]); - frame->side_data[i] = frame->side_data[frame->nb_side_data - 1]; - frame->nb_side_data--; - } - } + remove_side_data(&frame->side_data, &frame->nb_side_data, type); } const char *av_frame_side_data_name(enum AVFrameSideDataType type) -- 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".