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 BA8834A4B7 for ; Thu, 28 Mar 2024 16:53:36 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E037068D0E4; Thu, 28 Mar 2024 18:53:33 +0200 (EET) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4846F68D01B for ; Thu, 28 Mar 2024 18:53:28 +0200 (EET) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6e6082eab17so1094534b3a.1 for ; Thu, 28 Mar 2024 09:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711644805; x=1712249605; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=5E05i/7T+/66LbTbwEqpqLwG2G09axfHnrAz+rZ83Jc=; b=CvdEeMax1/wtJKzoHnJ9dfENeL7bCmaVty+IrXIi41pskQDS4LOICTWJgv0L3af3zz DpBaT8gVSQ/K8r40lEhWpXQNH/cHbQhUd08fotwZlNcERY6PSKWfk3YAydUp9fBmU0rV oe8XCwAiWkLlgMeFRbujkm9iSD3L3Q58ybZAZlgOGSePdSsxUrGZaKxoAf58QyTWkSeY rCkQ+gSqPkUrl2p7/mB55LcazmfNQW7a6oRPxj7vceOSpdLy/J7/uUC/2C/hTk8sh8oG D7uMVQnuBNTX55T+XnHtiSou5t4QB2lkMqXPwWuQIZh5lN62Y6F46NAphGBS7NPWi5oe n3Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711644805; x=1712249605; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5E05i/7T+/66LbTbwEqpqLwG2G09axfHnrAz+rZ83Jc=; b=kpEBJ89KIb/nXSRNTy3JoV8fs2249kOAQH3IalK2la6D94ISYFApePIlO5pYh3yY3g 64hlsLmya2DQg2sVm0u9Gy0JHKYzPPQeq0cs22zzM0yhB7dQOFCKboRDwI6NtKNctmaH O7FHfznl79nBOKuaN1etO8dLqeS0BKlkQ4Qnyy0Qi/zjd5VvcSJjcwZV1Xs5GvQyhwJp HRJFq2zfVuCcb887nAkW7iBQ/Q3318S+eZic6ixn5H+o5z2ybPi9XP88Lmiw797Zrye4 2ZUWTMhFEh/sKq/le8mz0/pt2DoubJHTi/4q8R7UfCCOwLrNf3NZLDI5c2XZAeuTZEql cBgQ== X-Gm-Message-State: AOJu0Yw8ZL49vHf18LHi4KL0C/TXilHd/GeL8i1m5BWV+0TuFI4fevzL nlgXEAbTV5z98fOp68qw4S5xPdl0COJbuwcbYoUuu7SBHXmqp9hjm/hqE1Ip X-Google-Smtp-Source: AGHT+IH8lD/W2mj9znA5AzT9AgwXAohpfal/z9xurjNndTzV/GlVihiK11YFcMk4uA7sOS8trUhFxQ== X-Received: by 2002:a05:6a20:3b0f:b0:1a3:ac79:5771 with SMTP id c15-20020a056a203b0f00b001a3ac795771mr3098260pzh.14.1711644804869; Thu, 28 Mar 2024 09:53:24 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id w4-20020a1709029a8400b001d8f111804asm1822860plp.113.2024.03.28.09.53.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 09:53:24 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 28 Mar 2024 13:52:44 -0300 Message-ID: <20240328165250.64259-1-jamrial@gmail.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/7 v5] avutil/frame: add helper for adding side data w/ AVBufferRef to array 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: Signed-off-by: James Almer --- libavutil/frame.c | 19 +++++++++++++++++++ libavutil/frame.h | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index ef1613c344..87cc8450c8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -812,6 +812,25 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, return ret; } +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef **pbuf, unsigned int flags) +{ + const AVSideDataDescriptor *desc = av_frame_side_data_desc(type); + AVFrameSideData *sd_dst = NULL; + AVBufferRef *buf = *pbuf; + + if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) + remove_side_data(sd, nb_sd, type); + + sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); + if (!sd_dst) + return NULL; + + *pbuf = NULL; + return sd_dst; +} + int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 3b6d746a16..8d16924432 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1062,6 +1062,30 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags); +/** + * Add a new side data entry to an array from an existing AVBufferRef. + * + * @param sd pointer to array of side data to which to add another entry, + * or to NULL in order to start a new array. + * @param nb_sd pointer to an integer containing the number of entries in + * the array. + * @param type type of the added side data + * @param buf Pointer to AVBufferRef to add to the array. On success, + * the function takes ownership of the AVBufferRef and *buf is + * set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set + * in which case the ownership will remain with the caller. + * @param flags Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0. + * + * @return newly added side data on success, NULL on error. + * @note In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of + * matching AVFrameSideDataType will be removed before the addition + * is attempted. + * + */ +AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, + enum AVFrameSideDataType type, + AVBufferRef **buf, unsigned int flags); + /** * Add a new side data entry to an array based on existing side data, taking * a reference towards the contained AVBufferRef. -- 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".