You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
frame: add an av_frame_new_side_data_from_buf function
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
This commit is contained in:
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
|
|||||||
|
|
||||||
API changes, most recent first:
|
API changes, most recent first:
|
||||||
|
|
||||||
|
2018-03-xx - xxxxxxx - lavu 56.8.100 - frame.h
|
||||||
|
Add av_frame_new_side_data_from_buf().
|
||||||
|
|
||||||
2018-02-xx - xxxxxxx
|
2018-02-xx - xxxxxxx
|
||||||
Change av_ripemd_update(), av_murmur3_update() and av_hash_update() length
|
Change av_ripemd_update(), av_murmur3_update() and av_hash_update() length
|
||||||
parameter type to size_t at next major bump.
|
parameter type to size_t at next major bump.
|
||||||
|
|||||||
@@ -26,11 +26,6 @@
|
|||||||
#include "mem.h"
|
#include "mem.h"
|
||||||
#include "samplefmt.h"
|
#include "samplefmt.h"
|
||||||
|
|
||||||
|
|
||||||
static AVFrameSideData *frame_new_side_data(AVFrame *frame,
|
|
||||||
enum AVFrameSideDataType type,
|
|
||||||
AVBufferRef *buf);
|
|
||||||
|
|
||||||
#if FF_API_FRAME_GET_SET
|
#if FF_API_FRAME_GET_SET
|
||||||
MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
|
MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
|
||||||
MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration)
|
MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration)
|
||||||
@@ -356,8 +351,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
}
|
}
|
||||||
memcpy(sd_dst->data, sd_src->data, sd_src->size);
|
memcpy(sd_dst->data, sd_src->data, sd_src->size);
|
||||||
} else {
|
} else {
|
||||||
sd_dst = frame_new_side_data(dst, sd_src->type, av_buffer_ref(sd_src->buf));
|
AVBufferRef *ref = av_buffer_ref(sd_src->buf);
|
||||||
|
sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, ref);
|
||||||
if (!sd_dst) {
|
if (!sd_dst) {
|
||||||
|
av_buffer_unref(&ref);
|
||||||
wipe_side_data(dst);
|
wipe_side_data(dst);
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
@@ -642,9 +639,9 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static AVFrameSideData *frame_new_side_data(AVFrame *frame,
|
AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
|
||||||
enum AVFrameSideDataType type,
|
enum AVFrameSideDataType type,
|
||||||
AVBufferRef *buf)
|
AVBufferRef *buf)
|
||||||
{
|
{
|
||||||
AVFrameSideData *ret, **tmp;
|
AVFrameSideData *ret, **tmp;
|
||||||
|
|
||||||
@@ -652,17 +649,17 @@ static AVFrameSideData *frame_new_side_data(AVFrame *frame,
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
|
if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
|
||||||
goto fail;
|
return NULL;
|
||||||
|
|
||||||
tmp = av_realloc(frame->side_data,
|
tmp = av_realloc(frame->side_data,
|
||||||
(frame->nb_side_data + 1) * sizeof(*frame->side_data));
|
(frame->nb_side_data + 1) * sizeof(*frame->side_data));
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto fail;
|
return NULL;
|
||||||
frame->side_data = tmp;
|
frame->side_data = tmp;
|
||||||
|
|
||||||
ret = av_mallocz(sizeof(*ret));
|
ret = av_mallocz(sizeof(*ret));
|
||||||
if (!ret)
|
if (!ret)
|
||||||
goto fail;
|
return NULL;
|
||||||
|
|
||||||
ret->buf = buf;
|
ret->buf = buf;
|
||||||
ret->data = ret->buf->data;
|
ret->data = ret->buf->data;
|
||||||
@@ -672,17 +669,18 @@ static AVFrameSideData *frame_new_side_data(AVFrame *frame,
|
|||||||
frame->side_data[frame->nb_side_data++] = ret;
|
frame->side_data[frame->nb_side_data++] = ret;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
fail:
|
|
||||||
av_buffer_unref(&buf);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
|
AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
|
||||||
enum AVFrameSideDataType type,
|
enum AVFrameSideDataType type,
|
||||||
int size)
|
int size)
|
||||||
{
|
{
|
||||||
|
AVFrameSideData *ret;
|
||||||
return frame_new_side_data(frame, type, av_buffer_alloc(size));
|
AVBufferRef *buf = av_buffer_alloc(size);
|
||||||
|
ret = av_frame_new_side_data_from_buf(frame, type, buf);
|
||||||
|
if (!ret)
|
||||||
|
av_buffer_unref(&buf);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
|
AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
|
||||||
|
|||||||
@@ -800,6 +800,22 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
|
|||||||
enum AVFrameSideDataType type,
|
enum AVFrameSideDataType type,
|
||||||
int size);
|
int size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new side data to a frame from an existing AVBufferRef
|
||||||
|
*
|
||||||
|
* @param frame a frame to which the side data should be added
|
||||||
|
* @param type the type of the added side data
|
||||||
|
* @param buf an AVBufferRef to add as side data. The ownership of
|
||||||
|
* the reference is transferred to the frame.
|
||||||
|
*
|
||||||
|
* @return newly added side data on success, NULL on error. On failure
|
||||||
|
* the frame is unchanged and the AVBufferRef remains owned by
|
||||||
|
* the caller.
|
||||||
|
*/
|
||||||
|
AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
|
||||||
|
enum AVFrameSideDataType type,
|
||||||
|
AVBufferRef *buf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a pointer to the side data of a given type on success, NULL if there
|
* @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 frame.
|
* is no side data with such type in this frame.
|
||||||
|
|||||||
@@ -79,8 +79,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_MAJOR 56
|
#define LIBAVUTIL_VERSION_MAJOR 56
|
||||||
#define LIBAVUTIL_VERSION_MINOR 7
|
#define LIBAVUTIL_VERSION_MINOR 8
|
||||||
#define LIBAVUTIL_VERSION_MICRO 101
|
#define LIBAVUTIL_VERSION_MICRO 100
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
LIBAVUTIL_VERSION_MINOR, \
|
LIBAVUTIL_VERSION_MINOR, \
|
||||||
|
|||||||
Reference in New Issue
Block a user