diff options
author | wm4 <nfxjfg@googlemail.com> | 2017-02-02 11:27:54 +0100 |
---|---|---|
committer | wm4 <nfxjfg@googlemail.com> | 2017-02-13 08:01:20 +0100 |
commit | e3af49b14bf371e18fab1c12cba0239e6658672c (patch) | |
tree | 78b3f9c04691772d3708fc7662aae33888ed32d1 /libavutil/frame.c | |
parent | 2b9f92fcc5486361b63c4fab5a24c222dc8969ef (diff) | |
download | ffmpeg-streaming-e3af49b14bf371e18fab1c12cba0239e6658672c.zip ffmpeg-streaming-e3af49b14bf371e18fab1c12cba0239e6658672c.tar.gz |
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>
Merges Libav commit 04f3bd349651.
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 a08e0c5..2913982 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -379,6 +379,13 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif + 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; } @@ -513,6 +520,8 @@ void av_frame_unref(AVFrame *frame) av_buffer_unref(&frame->hw_frames_ctx); + av_buffer_unref(&frame->opaque_ref); + get_frame_defaults(frame); } |