mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-08 06:09:50 +00:00
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 04f3bd3496.
This commit is contained in:
parent
2b9f92fcc5
commit
e3af49b14b
4 changed files with 24 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue