diff options
author | wm4 <nfxjfg@googlemail.com> | 2017-02-02 13:27:54 +0300 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2017-02-11 13:37:45 +0300 |
commit | 04f3bd349651694f30feeb8c4ed9bc58106fca54 (patch) | |
tree | d48fd34fb20bcc877e24a4bb6fd7f4cff10edb67 /libavutil/frame.c | |
parent | 4de220d2e3751c459f8739a08ac6ca52e63eba30 (diff) |
AVFrame: add an opaque_ref field
This is an extended version of the AVFrame.opaque field, which can be
used to attach arbitrary user information to an AVFrame.
The usefulness of the opaque field is rather limited, because it can
store only up to 32 bits of information (or 64 bit on 64 bit systems).
It's not possible to set this field to a memory allocation, because
there is no way to deallocate it correctly.
The opaque_ref field circumvents this by letting the user set an
AVBuffer, which makes the user data refcounted.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavutil/frame.c')
-rw-r--r-- | libavutil/frame.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c index aa5820c0e9..9cd5f9ab37 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -317,6 +317,8 @@ void av_frame_unref(AVFrame *frame) av_buffer_unref(&frame->hw_frames_ctx); + av_buffer_unref(&frame->opaque_ref); + get_frame_defaults(frame); } @@ -440,6 +442,13 @@ FF_ENABLE_DEPRECATION_WARNINGS av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); } + av_buffer_unref(&dst->opaque_ref); + if (src->opaque_ref) { + dst->opaque_ref = av_buffer_ref(src->opaque_ref); + if (!dst->opaque_ref) + return AVERROR(ENOMEM); + } + return 0; } |