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 1E73C49DD3 for ; Mon, 11 Mar 2024 21:00:23 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 486A168D162; Mon, 11 Mar 2024 22:59:03 +0200 (EET) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 209A168D0F4 for ; Mon, 11 Mar 2024 22:58:50 +0200 (EET) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-513b1de881aso875224e87.3 for ; Mon, 11 Mar 2024 13:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710190729; x=1710795529; 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=u6xOhH1H03IjAyc7GApYRyBh/Z4vNUf5n3GmG98Fr/Q=; b=mMLExjMiC1j1bwtG96avt8/PqFqK+ODItTl5EKKUa9OtJUpMc6Anpbs+5lY73vlPVi HJwWPKY5k7eY/wNjnFiEW/xbkcfwXkhX2ydDiPy8R3VvASgsQ/3QEwa0XzEZRrEoAwjf 9s9Mcyk49VPMzjrVHEcJKVZ1qDZNsexgM1iKpzSp6oICjmFvfYOCJrtUhjiwa/3QixZ7 XKMOJDpyxcT34BbKJIdXFummAUa1XVWqjaO75TUkGmKNJ27f4kv3dogdM8hsEUdjFxtK Ddd5BA3lXpzPBwZvsaUnxLr35+Jok6EWBLShSRV364koGFIpijkcT2sZsgLeRan7tFZA u2Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710190729; x=1710795529; 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=u6xOhH1H03IjAyc7GApYRyBh/Z4vNUf5n3GmG98Fr/Q=; b=fLW96L1THSUuZlWfi8n5Z9BhlnekQWciPO2G+8oIkMH5JA0oLQhzA1PDwoVMNEAPaB jyqQOZr5f9BR7qEpUb1Jmcy8spxKuoKWizuNrSTMs9l9T2EupOZIsH90KTwPoeH78R9K Ed4l3gPqLwn3N+iBvmf6PfVpPTJAA6CFPlAkInV1mKgWf+yEiXWz0HVDiKN3KhbRpnjt bOH6C9zrah9ZIUrb7Qzh0MtzvV1UBWuGrgz6PwJeWZc33N1tttgCsXyn4Ba3VsqPfN8M beBWpzsWt1gFH3bMg3kdOppY+QYZ+zHj6JAuG9zpwhWkTcxz9oq9DUb95i02c/E0GPvT Ag0g== X-Gm-Message-State: AOJu0YzuGkazzHDne3sXyFRPB4l54fw07/6IHI9cA7W2RsYAIsqUMaVr gglTJyt/VRXJ7dyNe+nAM22TpckWtzdBC7FeZUEF0rZP2pg2YzrZPRz9YV0O X-Google-Smtp-Source: AGHT+IHoK3q3TF/7YbSx0xcP7Asz+vYu4clIml6GNfvi3Vg2A+gKLcQN1MD5ZSJz0mkQus52pcWOEw== X-Received: by 2002:a19:7507:0:b0:512:fdc8:4910 with SMTP id y7-20020a197507000000b00512fdc84910mr1162082lfe.36.1710190729233; Mon, 11 Mar 2024 13:58:49 -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.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 13:58:48 -0700 (PDT) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Mar 2024 22:58:33 +0200 Message-ID: <20240311205844.3569895-11-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 10/14] avcodec: add helper for configuring AVCodecContext's frame 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 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 allows API clients that wish to configure multiple entries at a time to do so without writing the looping code themselves. --- libavcodec/avcodec.c | 30 ++++++++++++++++++++++++++++++ libavcodec/avcodec.h | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index a9a87bb58c..0ced87b946 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -686,3 +686,33 @@ int attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *fr return ff_decode_receive_frame(avctx, frame); return ff_encode_receive_frame(avctx, frame); } + +int avcodec_configure_side_data(AVCodecContext *avctx, + const AVFrameSideData **sd, const int nb_sd, + unsigned int flags) +{ + if (!avctx) + return AVERROR(EINVAL); + + if (!sd) { + av_frame_side_data_free( + &avctx->frame_side_data, &avctx->nb_frame_side_data); + return 0; + } + + if (nb_sd > 0 && nb_sd == avctx->nb_frame_side_data && + sd == (const AVFrameSideData **)avctx->frame_side_data) + return AVERROR(EINVAL); + + for (int i = 0; i < nb_sd; i++) { + int ret = av_frame_side_data_clone( + &avctx->frame_side_data, &avctx->nb_frame_side_data, sd[i], flags); + if (ret < 0) { + av_frame_side_data_free( + &avctx->frame_side_data, &avctx->nb_frame_side_data); + return ret; + } + } + + return 0; +} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 432a3fd153..6de4dc0f7b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3075,6 +3075,27 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size); */ int avcodec_is_open(AVCodecContext *s); +/** + * Add multiple side data entries to an AVCodecContext's array in one go, for + * example from an AVFrame. + * + * In case the function fails to add a side data entry, it will clear the + * whole side data set. + * + * @param avctx context to which the side data should be added + * @param sd array of side data to use as input. + * if null, clears out the side data for this context. + * @param nb_sd integer containing the number of entries in the array. + * @param flags Some combination of AV_FRAME_SIDE_DATA_SET_FLAG_* flags, or 0. + * + * @return negative error code on failure, >=0 on success. + * + * @see av_frame_side_data_new regarding the flags. + */ +int avcodec_configure_side_data(AVCodecContext *avctx, + const AVFrameSideData **sd, const int nb_sd, + unsigned int flags); + /** * @} */ -- 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".