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 3BC1149AC6 for ; Tue, 27 Feb 2024 22:13:54 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 708B568CDA5; Wed, 28 Feb 2024 00:12:55 +0200 (EET) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD14B68CACC for ; Wed, 28 Feb 2024 00:12:40 +0200 (EET) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d2991e8c12so2547161fa.0 for ; Tue, 27 Feb 2024 14:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709071959; x=1709676759; 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=jjIz9BARMumrQkOyfM5DQUenPk8Hig/J3i61SB+xDmo=; b=JNpc7Oy1DuoFetAz5rKWrmRNGXd2q7FSg0A6ftDROxWJVN0uqjLlX33d37vZq3kkp5 6yjVwIBAG2f3I5FEodKGOQdjl3izCZ8lSCKouTNQ9vfjydY0ar1Ke8iY8HlSxiZLCnGT mfOiNfAz4CJvB1YLCf1aqpxmdGsOSFyRE3okxEdYw/yPQmNWhbEFi+qpjf2uYQxbf39Y bIUSyF0+/WUVZ/x+Pimtl2r3ZI1yM7x8cQiHtKNKC9a+fc7EXvQFj7mtlZvdfR2jUpPW p7qvFjstAIsR7bFmrMMwRfInLyBF4IUuiC539hbOp4BzBXixS3yMIPvXhFcBN+VKZ5TF DOPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709071959; x=1709676759; 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=jjIz9BARMumrQkOyfM5DQUenPk8Hig/J3i61SB+xDmo=; b=Inb/H0OglV+l5Dx5rFGgGWpsUBwlvhnGWpVzSeR5KsCJPy73QxbgVcFPrB3fvJ9QpU GgbE+/Ir+pQddY9koOLYe9psIszbE340tpmBcGo2tYg+LwcNRcDEzjAXXXPF/gAtk/i1 BnXIkYAwMofDWlcdEldR05EdVxANWC1+/MCtTK0GFrEPZ9xTqv9eVPIMwihnvtGkHWUd FfhGcSy94gMPPb9T4GrQ2UDKZWL8kRWXIBEeDTBUTRZlo+uBMYS+lJm0B/nP9124Iv7L J2+ASV9e1L3DuxbMjJD+RxGTxENF3KshSk+cb5lvJh5UD0K7/1+htOKjYzybcJE172j3 k8NQ== X-Gm-Message-State: AOJu0YzS7cAmgIB2e8c3GIzQxJPDqIQ9NINcErr2GX3IjDUSe0dh8ux1 zbgYVS24JdZf1R8a1Ae+GY8tCbt6cGGiLfywgnEoDvElR/7IeuLIwz2uFOqc X-Google-Smtp-Source: AGHT+IEbCQoXcNaq987mCCtSegzqcOYNk9ctBtljZH9grph4IgecFLF6zESQqwtvGiQjHl2HaPx0qA== X-Received: by 2002:a2e:3315:0:b0:2d2:a9a4:c3f8 with SMTP id d21-20020a2e3315000000b002d2a9a4c3f8mr201286ljc.15.1709071959562; Tue, 27 Feb 2024 14:12:39 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id j9-20020a2e8009000000b002d09bc941e8sm1373564ljg.139.2024.02.27.14.12.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 14:12:39 -0800 (PST) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Feb 2024 00:12:12 +0200 Message-ID: <20240227221226.1377758-10-jeebjp@gmail.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240227221226.1377758-1-jeebjp@gmail.com> References: <20240227221226.1377758-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v6 09/13] 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 | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index a13b781996..d3ec41b280 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -720,3 +720,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_from_sd( + &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 411f4caad3..3b5ca9c0ef 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3162,6 +3162,26 @@ 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 set 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_set_new_entry regarding the flags. + */ +int avcodec_configure_side_data(AVCodecContext *avctx, + const AVFrameSideData **sd, const int nb_sd, + unsigned int flags); /** * @} */ -- 2.43.2 _______________________________________________ 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".