mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-06 01:07:36 +08: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:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user