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 6DDC146A41 for ; Fri, 1 Sep 2023 20:39:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 89D0B68C756; Fri, 1 Sep 2023 23:38:42 +0300 (EEST) Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7BCF68C705 for ; Fri, 1 Sep 2023 23:38:32 +0300 (EEST) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2bb9a063f26so42420751fa.2 for ; Fri, 01 Sep 2023 13:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693600712; x=1694205512; 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=wRgSt3iB2xo4i7BvrW+oUQgwY6uZjn9t/OXUoXPUdsA=; b=mO2oDw8J8PjeuPfuqiZ1Bp3QA2sOg9trQkK1oCGB9waLQgqeOfhYFAjKtwJr3sPtiD GQYSWDTrEE2m/tS2YTIOzdB92rPtcCS2BDMAnnoekSo3rPYY1km/tVaNDq0WnsAuo86s t+kq6VA+JWzqsiUS7rPXaEHrOVJUVBoQalgRJRxFLnoqFS2IQU0WY9Cr50rnuM+yRwrf FjYho73WjvA2fIFY+E84DMgGFACDAhfUv2kaxTBpKvL9mrzQKmAZjrc7n4UDKgd/rcTf Ix9lqd2o4V0e9aagsROHpwAppXHhGq/NfOG8hTXTN79akq5Kirgxk89N/AngyaGjIHsm 3zbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693600712; x=1694205512; 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=wRgSt3iB2xo4i7BvrW+oUQgwY6uZjn9t/OXUoXPUdsA=; b=j3xR+Aw0Ukfm7a3lwKV/XN9WU8oPJkUb6r0khaas53uunGHosIDAK/ovyFC7ng8EuH UJo4+dzCTPVXdxkmWZOJjdeCqyllu2/q2/rYsRGdwCAnAq5ngUZYWZyYghqDTJ9MrgSO NfEnWJWUI0D0OlMUUTzbYvk8j1jVDLmnCcnHvcHBrZAewgPb895yXhWEmd5sSIs7n3MA ZsRGgizc0sRpSP2FA20ENDfv22UJIyJkxqX9/oF1uLC4aPbStkouaVCF4wLOoYILz1n4 1E88/YIM5qQpch5h/JEteaDWxrUa5/FmfzqFFkuW+D+lufb1C2u/VAdSBKWpn8R7Sor5 ABTA== X-Gm-Message-State: AOJu0YyA6yVfpiwj9VvGLcjlF+hnCazVG0UOLSzF0pwSUcjm63H/oxlP 6WXQpI3nh2c6YYL9jR9S72Bx4g4bRktb4Q== X-Google-Smtp-Source: AGHT+IGchxQsOqT8GoYsq8lJj8qNTYLEuBre6IA2IMO6L3T9gNQ7CY6dxMJB/7n46QE/XxV6iTNCHA== X-Received: by 2002:a2e:9194:0:b0:2bd:2240:8376 with SMTP id f20-20020a2e9194000000b002bd22408376mr2628789ljg.14.1693600712076; Fri, 01 Sep 2023 13:38:32 -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 k17-20020a2e9211000000b002b9a1e9ba68sm907954ljg.136.2023.09.01.13.38.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 13:38:31 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 1 Sep 2023 23:38:15 +0300 Message-ID: <20230901203828.275197-6-jeebjp@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901203828.275197-1-jeebjp@gmail.com> References: <20230901203828.275197-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 05/13] 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 9eff851d64..0b1a8e5244 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -95,6 +95,21 @@ void av_frame_side_data_set_uninit(AVFrameSideDataSet *set) wipe_side_data(&set->sd, &set->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)); @@ -945,14 +960,7 @@ FF_ENABLE_DEPRECATION_WARNINGS 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.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".