[FFmpeg-devel] [PATCH v2 06/12] avutil/frame: add helper for getting side data from set
Jan Ekström
jeebjp at gmail.com
Wed Apr 12 00:20:46 EEST 2023
---
libavutil/frame.c | 22 +++++++++++++++++-----
libavutil/frame.h | 10 ++++++++++
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 29e9b631f8..3386cda627 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -720,16 +720,28 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set,
return ret;
}
-AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
- enum AVFrameSideDataType type)
+AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set,
+ enum AVFrameSideDataType type)
{
- for (int i = 0; i < frame->nb_side_data; i++) {
- if (frame->side_data[i]->type == type)
- return frame->side_data[i];
+ for (int i = 0; i < set.nb_side_data; i++) {
+ if (set.side_data[i]->type == type)
+ return set.side_data[i];
}
return NULL;
}
+AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
+ enum AVFrameSideDataType type)
+{
+ return av_get_side_data_from_set(
+ (const AVFrameSideDataSet){
+ .side_data = frame->side_data,
+ .nb_side_data = frame->nb_side_data
+ },
+ type
+ );
+}
+
static int frame_copy_video(AVFrame *dst, const AVFrame *src)
{
const uint8_t *src_data[4];
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 167a8f0ff6..8aa50e3ad8 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -1011,6 +1011,16 @@ AVFrameSideData *av_new_side_data_to_set(AVFrameSideDataSet *set,
enum AVFrameSideDataType type,
size_t size);
+/**
+ * @param set a set to which the side data should be added
+ * @param type type of the added side data
+ *
+ * @return a pointer to the side data of a given type on success, NULL if there
+ * is no side data with such type in this set.
+ */
+AVFrameSideData *av_get_side_data_from_set(const AVFrameSideDataSet set,
+ enum AVFrameSideDataType type);
+
/**
* @}
*/
--
2.40.0
More information about the ffmpeg-devel
mailing list