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 <jamrial@gmail.com>
master
James Almer 4 weeks ago
parent 7f9c7f9849
commit 42e72d5c8b
  1. 3
      doc/APIchanges
  2. 17
      libavutil/frame.c
  3. 5
      libavutil/frame.h
  4. 4
      libavutil/version.h

@ -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.

@ -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;
}

@ -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.

@ -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, \

Loading…
Cancel
Save