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 91AFA47141 for ; Sun, 26 Nov 2023 20:00:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D83BF68CFA5; Sun, 26 Nov 2023 21:59:04 +0200 (EET) Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0133468CF71 for ; Sun, 26 Nov 2023 21:58:51 +0200 (EET) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-507cd62472dso4670712e87.0 for ; Sun, 26 Nov 2023 11:58:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701028731; x=1701633531; 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=/PQK9vsRBA3AipKqaL/Nrb6qEl8CzWv4bCOxL3HtR20=; b=TqVVzFBUizEoxzVoTZt5qDl1NsM7VcQELy8OYZS1/WIWE4qiqPoUQCFlxNp1yce5Ox QgHzBSmvWbzgZ6dUUuisCJVFmlNObudt0wh1c+sM/hw+1zX56iStE4Tb7rOryhenUL7B s+BHkrCGC48sgGS7N2hDC+H2mNdMAqfBpWQWZKem0qcLx4SlUJNaPUeIcLCPRk7SFw17 SF3V4fU0REsJlf5Li6omhvA1SSMoIjyVdjcomDVUvpE2DS4WptNA1ysaJKj7i3/Jz8m8 iNMwWYmIpIGCJMzX7pRgEln0/CzSRJomKVzPPZaWf4a750edkKuhzIWDxqF/IWZV4S/F cklw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701028731; x=1701633531; 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=/PQK9vsRBA3AipKqaL/Nrb6qEl8CzWv4bCOxL3HtR20=; b=QQJW0XMi6pYBYRAXKaPeXXL2l4jgvPFqEKKarHmt5uREwpvexinjfGLifrUbwiP3+f 7dHboLGU9AKuOdF6r2G3JNVMOFQGRjh7qe+Szwjt5h228GOtRFFbusaK0w4jt2iuU+0/ eIHuO6XyNhUp+Uc5wKxHHem8p6mftAcelKVZkVNB7DAllumaDULoc+HFqHKQBAksfckS H8GiShAlaV1UV2yBSE52sbx1863lG4o8rNjdUD6t33MBKxoaaaXZ2J2VChtK4TUvFAJp NbzcIFRVzp7GaD86jEl3+GyLmLXuZgu8uYkKtLv6p7jjhnNIKpnZN/tXd15RrG3e+Coa Ra4A== X-Gm-Message-State: AOJu0Yzjdr3wkKIJln5kyCpEc8E7b54dkFRJxc/qiIjeeOUwmODos9lK +I40JNhqlRAmprLUncuJkZTe9dXS1aA= X-Google-Smtp-Source: AGHT+IGNZzFl3IfhNsg3Gu8/SnuzkExQR+X1/C8NvQJMrxEmHVNpH0F6KlD2l1rhokdkCfkkl5f3LA== X-Received: by 2002:ac2:5f09:0:b0:507:9ef4:8309 with SMTP id 9-20020ac25f09000000b005079ef48309mr2357722lfq.25.1701028731101; Sun, 26 Nov 2023 11:58:51 -0800 (PST) Received: from localhost.localdomain (91-153-198-187.elisa-laajakaista.fi. [91.153.198.187]) by smtp.gmail.com with ESMTPSA id k16-20020ac24f10000000b00500d1a72734sm1281833lfr.130.2023.11.26.11.58.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 11:58:50 -0800 (PST) From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 26 Nov 2023 21:58:29 +0200 Message-ID: <20231126195838.392467-11-jeebjp@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231126195838.392467-1-jeebjp@gmail.com> References: <20231126195838.392467-1-jeebjp@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 10/14] avcodec: add helper for configuring AVCodecContext's side data set 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 | 28 ++++++++++++++++++++++++++++ libavcodec/avcodec.h | 20 ++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 2dda310e91..9b56af8114 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -718,3 +718,31 @@ 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 AVFrameSideDataSet *set, + unsigned int flags) +{ + if (!avctx) + return AVERROR(EINVAL); + + if (!set) { + av_frame_side_data_set_uninit(&avctx->frame_sd_set); + return 0; + } + + if (set->nb_sd > 0 && set->nb_sd == avctx->frame_sd_set.nb_sd && + set->sd == avctx->frame_sd_set.sd) + return AVERROR(EINVAL); + + for (int i = 0; i < set->nb_sd; i++) { + int ret = av_frame_side_data_set_entry_from_sd( + &avctx->frame_sd_set, set->sd[i], flags); + if (ret < 0) { + av_frame_side_data_set_uninit(&avctx->frame_sd_set); + return ret; + } + } + + return 0; +} diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0c1a8ade49..40261594f1 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3154,6 +3154,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 set a set from which the side data should be added from. + * if null, clears out the side data for this context. + * @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 AVFrameSideDataSet *set, + unsigned int flags); + /** * @} */ -- 2.43.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".