From patchwork Fri Mar 31 16:22:00 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: 40956 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp852014pzb; Fri, 31 Mar 2023 09:23:28 -0700 (PDT) X-Google-Smtp-Source: AKy350axnxWHu6+xlPURVw8/ojl2nYwn+nyGf1xxTAW1/I5S7PihPBWrqZAEhmcc3j7HxESGFojV X-Received: by 2002:a17:906:9485:b0:933:c052:a277 with SMTP id t5-20020a170906948500b00933c052a277mr28119671ejx.12.1680279808205; Fri, 31 Mar 2023 09:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680279808; cv=none; d=google.com; s=arc-20160816; b=0elcTO0ET5vPa3sKBFaAJUD1dnB70HwsbY27fPnoeDSt/HCfSvKVkAB6u/lCyYn39h MMM+gJK6Ti08AjUhEMKE1ZcexcgTDOY/FL4nodNCsP3HIZPm5tdgm+XpPJS2/iPzcJSZ UCEgQnUPXmiOPuzwP8mq3Qp2hn2G3I80TfRix+pEEYSatWdhZfMdH7eXismpI1FvxO03 8MBO2YAg7xlDYbtT0IVJcY7CnK5MtyxrOLTwqAwG0iVDmIAn02pK750K8dqkil3eOceh FIJuJUxncrnc+FLxOl1DyDoVe0MJN3k0wlaTGMdq1OjRogTsuoOCe2Phj+2xhNXEyFgF GULg== 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=lg6F8WtWNLEm0GVCaRqRvtcjJWvhEis1KJsrUWUPpXs=; b=F7Nb61e9ikXifbdELDrTbVUbkYBKIbozWeF/5Ac9KKwm1CGKgtnY7Q6sHSLR/9AmEz ej8fDPuyzLI5NMsFaP1lBgB5d+D9GGF/xHSe1S3+Lg1Zv25PHr3gLVbmDZfxmE8p7GBP 9rOq31IiJ/CwSdpvFUu9bRFV/cCQ9/iun026U2aTdMbdolieIOpPX/KMvP3KaWM1f6LV 4EebZ0bGS2j8DKka7aHiM+76iiXGuOpQRaawv3ZG8p8QWGHkvH/lvJiijqNTlivJFmUM bui/z6Mpb8kINe6tID3xvU7rak8pOKen6uCcxaBbp2Sc1xY5gLg1s3ztA88p6Usp1Ne2 owUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="dqplRE/b"; 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 bh10-20020a170906a0ca00b0093e5b108711si589848ejb.942.2023.03.31.09.23.27; Fri, 31 Mar 2023 09:23:28 -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="dqplRE/b"; 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 1C0B168C2DD; Fri, 31 Mar 2023 19:22:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AE0F768C2A6 for ; Fri, 31 Mar 2023 19:22:17 +0300 (EEST) Received: by mail-lj1-f181.google.com with SMTP id x20so23602170ljq.9 for ; Fri, 31 Mar 2023 09:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680279737; 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=Bsb3lmthOCc6e7au7gufgrFzapDq9oLtvGA3KaskcJo=; b=dqplRE/bpyPk6Gl7+dfcbI4nK28rsCGaXWxYuI+ps2H7gXSWJ/Ks7Up3KWzmlq4aeX e95MZfiAJnCi7XAs52JTCmv6cy4apRs2xDFrKInlAqrxyQoDWOFysW9VTQaIoJ6PzdlO 9I6rAS/SFRN8TZjFFbveOoe9jqc2n/x7E5hx9A3msGdQKPDBT9Bnfsn2oOopS89tdXNe QIzheqfklqVtzdHA9T384YY2t3F9eAUxee+bizMTzao1pkD4eW4eTgtZBuXKZV8mnL6t 4/s3iAms8cfbr/I6bMSxEZDCpZCWf/h+gso2nKJ9uTax83kLSKX3mNKOGeUJu/Ckf11J nIZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680279737; 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=Bsb3lmthOCc6e7au7gufgrFzapDq9oLtvGA3KaskcJo=; b=tvBS2cmHvKewyqX+OGuPIED1LWSH4v+EtDMh1U2Op4J9mcOTS2Ezmn/Da+6AI/OSoQ co8v50Cna9L6cajkPffs/LqakHVasqVCtPQpQLzD9P+yz+udgbgsgSL2i1Qa5AYCS5m5 fqxpQjimWHFkLxlBhAIxk7uClgKNzlKQGCeUD997hYBUpKMYXpGIaHH1eiX9MtvQz5Ag 9Nlah/UaRLq5wbEYupcjJ48cD9a/ouuvGL4wfxkEVmQk8kT8uCEq1pZFGzzI7L8rqp8t yG7IX1FWPPQfEoQ8O2rswlCt7iyj9JdlbapjeoFPZIGwh4Wot6ejXVPRzAbzcUqepfsg EiYg== X-Gm-Message-State: AAQBX9e9R+bGB9FpMjOyFN/vlpntFaSKSjWz3Vit+Jn2Q7ibzKW/sa+7 GOfkIpzvLY4QnuzbVg3+z4+YcC7xR0k= X-Received: by 2002:a2e:9194:0:b0:293:32e0:5c8a with SMTP id f20-20020a2e9194000000b0029332e05c8amr8527073ljg.15.1680279737147; Fri, 31 Mar 2023 09:22:17 -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.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 09:22:16 -0700 (PDT) From: =?utf-8?q?Jan_Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 31 Mar 2023 19:22:00 +0300 Message-Id: <20230331162205.428735-8-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 07/12] avutil/frame: add helper for extending a set of side data 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: kLGgRAityQ88 --- libavutil/frame.c | 21 +++++++++++++++++++++ libavutil/frame.h | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index 3386cda627..ec4e44a11f 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -720,6 +720,27 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, return ret; } +int av_extend_side_data_set(AVFrameSideDataSet *dst, + const AVFrameSideDataSet src) +{ + for (int i = 0; i < src.nb_side_data; i++) { + const AVFrameSideData *sd_src = src.side_data[i]; + AVFrameSideData *sd_dst = + av_new_side_data_to_set(dst, sd_src->type, + sd_src->size); + if (!sd_dst) { + av_side_data_set_wipe(dst); + return AVERROR(ENOMEM); + } + + memcpy(sd_dst->data, sd_src->data, sd_src->size); + + av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); + } + + return 0; +} + AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set, enum AVFrameSideDataType type) { diff --git a/libavutil/frame.h b/libavutil/frame.h index 8aa50e3ad8..da8ac3237b 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1011,6 +1011,17 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set, enum AVFrameSideDataType type, size_t size); +/** + * Add multiple side data entries to a set in one go. + * + * @param dst a set to which the side data should be added + * @param src a set from which the side data should be copied from + * + * @return negative error code on failure, >=0 on success. + */ +int av_extend_side_data_set(AVFrameSideDataSet *dst, + const AVFrameSideDataSet src); + /** * @param set a set to which the side data should be added * @param type type of the added side data