From patchwork Fri Mar 31 16:21:57 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: 40953 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp851719pzb; Fri, 31 Mar 2023 09:23:01 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYyOvorZOd1RhfKbVBtuQbzYWq+c84bhOK/lz3Lf4zbaGbqgI4bqtdsBUMMHQLXhcggk9o X-Received: by 2002:a05:6402:2027:b0:4fd:1f7b:9fbd with SMTP id ay7-20020a056402202700b004fd1f7b9fbdmr9587066edb.6.1680279781592; Fri, 31 Mar 2023 09:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279781; cv=none; d=google.com; s=arc-20160816; b=0LR1FnzAePr+I2jXBWyhc+e8orNeQJ0p5U2BnEj8GWrYtwn3Y79F/4nQfa8nSK9I03 lSi1cpHONqmsYJUlLjeOjiSE2H8G3qve/mhZAUF1yUTnfO8nVAq9azJkRGJV9626wCy2 adwT+GedtpcWFrOwjBnnx2gP7y/pWmJ873hu36gnSez2RoUZ7RntBd9scV7fUk7XGvGq HS9jwtIdcG3G0jsd1GYIBp8EZDATu2791NW9LQxDMi1MCPPfcxNIzuEGSAJKKX24BQ/Y Xkk5KhL/43zAoNnwOiTj+5iCXRPTCENYInujaWVA+LfqwCqEa7ltqzrb3zb3kpluspDv 30uA== 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=+Cjch5dmkBnNtSbGU2z1a5ZdKOvv+AjeiEfSe9FIpEg=; b=k5PJ2h0tRm7ytdT5Y8XxspnzirhRc/1mAQrWiUHS7d+drW6Lf+shbLBi/KC2SBZRbw HmK5Bga/2juJeVRPBb1JX404casx1gQ+tRl9dT5OTV/MwJtXlrFqZP0NmbpPY3Y3JS7T 6qvCJagbVNbWPM65XaT9Y1pT+MmKFW9td3HBtFY3sZ6FXbESpkkTXlSHxjfHsD3rj25a V0G8oFADXAZO108YjajCFfGNRCMdMPfr5udXjB9tR1FJg8V/mRWNZfMJTj39OpIo2Sjt rLJWj1M0rxXp1KA6YykRMzcYTrBxPLyQCWTGavepsxjcBBtvM6B2y+30wbiuFVtPaTFB UDng== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=OK1CWTKB; 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 n13-20020a056402060d00b004acd2bb0015si2373358edv.346.2023.03.31.09.23.01; Fri, 31 Mar 2023 09:23:01 -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=OK1CWTKB; 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 0646268C30E; Fri, 31 Mar 2023 19:22:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D2A0B68C282 for ; Fri, 31 Mar 2023 19:22:16 +0300 (EEST) Received: by mail-lj1-f182.google.com with SMTP id x20so23602126ljq.9 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=1680279736; 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=oGm3z9HAZvdROOvpvc/CCFyByzV9Mm1Tc8AJQSIbiRc=; b=OK1CWTKBG6EJyP22gOyTAggyfgAX8Dtfe1WzKORCAyi/jeboh0NeYwgv9pLr0YY1Bo aLpFtLZxmBFyvwmMPI8a1/AQMgnVJL/CxA9/Mx5uFkV7t/ZM2d8IuRRO3RaUHFTEdzNv Qzqg9UatVvPIdL8poiDFozCY+x0HwpoXHksyBWOmnpZP3nYymARG7y+4IPFavKlNh0c9 SWY1ZgmAaBOLjZ++JgEZ/8Dr2QxbQFviWi9gx/1Uq2bjQIhFf3NVPC3/+8H2cpwAbPWg Zl2qUBtERAVgRH5bre363koeR5N+5WviDirPctFzn/902cwlLCI3aDpvYtIOECDOJx8r 9mNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279736; 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=oGm3z9HAZvdROOvpvc/CCFyByzV9Mm1Tc8AJQSIbiRc=; b=GgLMBy8V6oZUVHUlt9+6qJmMlMwILEtLX+A06T5nGMH+RiKi2QVPmDO65ps6yMooyK OikSMyrEHMeqAoeCG+/YNmH5QpNJhWhLsZRux9NYsTl/DE6d6Dz7yJx9baAQo2UXln5m zPDPSBQoUvF42x92Yua1zQ36RggSlzHuPjisVYYkzOoFYSEpSiQbUmitFalnd5Q+lMge G1eu3wm8W6StY2b394f20x5y0PWgQvW8xZAdd6Cku2tSqvDiisWAG4C6f7+s5eaXqJce DY9cMyU5LPnNykd3dMnioQQ72asPkv9Fh1M2mwMC7kIc5xv8zrAmvCFr5H256RPGKNex IC6w== X-Gm-Message-State: AAQBX9fJAoG303AtnFhRSR+OHj1rIrOTKC4GDQR/g4BgLS5T6Xn10Ihs wVMxOZCXJVYPrzUwGsWJzo/GxnnQTDs= X-Received: by 2002:a2e:b16e:0:b0:28b:6525:e6b1 with SMTP id a14-20020a2eb16e000000b0028b6525e6b1mr2866273ljm.24.1680279736008; Fri, 31 Mar 2023 09:22:16 -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.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:15 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:21:57 +0300 Message-Id: <20230331162205.428735-5-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 04/12] avutil/frame: split side_data_from_buf to base and AVFrame func 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: jX6d+trgCdWn --- libavutil/frame.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 24038cc0fa..ab1a4e7f6a 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -648,23 +648,23 @@ FF_ENABLE_DEPRECATION_WARNINGS return NULL; } -AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, - enum AVFrameSideDataType type, - AVBufferRef *buf) +static AVFrameSideData *add_side_data_to_set_from_buf(AVFrameSideDataSet *set, + enum AVFrameSideDataType type, + AVBufferRef *buf) { AVFrameSideData *ret, **tmp; if (!buf) return NULL; - if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1) + if (set->nb_side_data > INT_MAX / sizeof(*set->side_data) - 1) return NULL; - tmp = av_realloc(frame->side_data, - (frame->nb_side_data + 1) * sizeof(*frame->side_data)); + tmp = av_realloc(set->side_data, + (set->nb_side_data + 1) * sizeof(*set->side_data)); if (!tmp) return NULL; - frame->side_data = tmp; + set->side_data = tmp; ret = av_mallocz(sizeof(*ret)); if (!ret) @@ -675,7 +675,23 @@ AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, ret->size = buf->size; ret->type = type; - frame->side_data[frame->nb_side_data++] = ret; + set->side_data[set->nb_side_data++] = ret; + + return ret; +} + +AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, + enum AVFrameSideDataType type, + AVBufferRef *buf) +{ + AVFrameSideDataSet set = { + .side_data = frame->side_data, + .nb_side_data = frame->nb_side_data, + }; + AVFrameSideData *ret = add_side_data_to_set_from_buf(&set, type, buf); + + frame->side_data = set.side_data; + frame->nb_side_data = set.nb_side_data; return ret; }