ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Thu Jan 2 12:10:17 2025 -0300| [42e72d5c8b57d542d360f42805c9d368dcea61a1] | committer: James Almer
avutil/frame: add AV_FRAME_SIDE_DATA_FLAG_NEW_REF The flag is documented but did not exist. So introduce it as it can be useful. Signed-off-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42e72d5c8b57d542d360f42805c9d368dcea61a1 --- doc/APIchanges | 3 +++ libavutil/frame.c | 17 ++++++++--------- libavutil/frame.h | 5 +++++ libavutil/version.h | 4 ++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index d2c84e3905..0104eefe6a 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07 API changes, most recent first: +2025-01-05 - xxxxxxxxxx - lavc 59.55.100 - frame.h + Add AV_FRAME_SIDE_DATA_FLAG_NEW_REF. + 2025-01-05 - xxxxxxxxxx - lavc 61.31.100 - avcodec.h Deprecate AVCodecContext->properties. diff --git a/libavutil/frame.c b/libavutil/frame.c index ab0d8f535f..10b59545f0 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -868,21 +868,20 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, AVFrameSideData *sd_dst = NULL; AVBufferRef *buf = *pbuf; + if ((flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF) && !(buf = av_buffer_ref(*pbuf))) + return NULL; if (flags & AV_FRAME_SIDE_DATA_FLAG_UNIQUE) remove_side_data(sd, nb_sd, type); if ((!desc || !(desc->props & AV_SIDE_DATA_PROP_MULTI)) && (sd_dst = (AVFrameSideData *)av_frame_side_data_get(*sd, *nb_sd, type))) { sd_dst = replace_side_data_from_buf(sd_dst, buf, flags); - if (sd_dst) - *pbuf = NULL; - return sd_dst; - } - - sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); - if (!sd_dst) - return NULL; + } else + sd_dst = add_side_data_from_buf(sd, nb_sd, type, buf); - *pbuf = NULL; + if (sd_dst && !(flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF)) + *pbuf = NULL; + else if (!sd_dst && (flags & AV_FRAME_SIDE_DATA_FLAG_NEW_REF)) + av_buffer_unref(&buf); return sd_dst; } diff --git a/libavutil/frame.h b/libavutil/frame.h index 993fa6b65a..c757d998fc 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1082,6 +1082,11 @@ void av_frame_side_data_free(AVFrameSideData ***sd, int *nb_sd); * Applies only for side data types without the AV_SIDE_DATA_PROP_MULTI prop. */ #define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1) +/** + * Create a new reference to the passed in buffer instead of taking ownership + * of it. + */ +#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2) /** * Add new side data entry to an array. diff --git a/libavutil/version.h b/libavutil/version.h index f2c609da78..a6f344a4c3 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,8 +79,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 59 -#define LIBAVUTIL_VERSION_MINOR 54 -#define LIBAVUTIL_VERSION_MICRO 101 +#define LIBAVUTIL_VERSION_MINOR 55 +#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".