mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
avutil/frame: Add private_ref to AVFrame
This gives FFmpeg libs a field that they can freely and safely use. Avoiding the need of wrapping of a users opaque_ref field and its issues. Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
dd435c957a
commit
1fa3a9a31d
@ -383,12 +383,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
av_buffer_unref(&dst->opaque_ref);
|
av_buffer_unref(&dst->opaque_ref);
|
||||||
|
av_buffer_unref(&dst->private_ref);
|
||||||
if (src->opaque_ref) {
|
if (src->opaque_ref) {
|
||||||
dst->opaque_ref = av_buffer_ref(src->opaque_ref);
|
dst->opaque_ref = av_buffer_ref(src->opaque_ref);
|
||||||
if (!dst->opaque_ref)
|
if (!dst->opaque_ref)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
if (src->private_ref) {
|
||||||
|
dst->private_ref = av_buffer_ref(src->private_ref);
|
||||||
|
if (!dst->private_ref)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -524,6 +529,7 @@ void av_frame_unref(AVFrame *frame)
|
|||||||
av_buffer_unref(&frame->hw_frames_ctx);
|
av_buffer_unref(&frame->hw_frames_ctx);
|
||||||
|
|
||||||
av_buffer_unref(&frame->opaque_ref);
|
av_buffer_unref(&frame->opaque_ref);
|
||||||
|
av_buffer_unref(&frame->private_ref);
|
||||||
|
|
||||||
get_frame_defaults(frame);
|
get_frame_defaults(frame);
|
||||||
}
|
}
|
||||||
|
@ -563,6 +563,19 @@ typedef struct AVFrame {
|
|||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AVBufferRef for internal use by a single libav* library.
|
||||||
|
* Must not be used to transfer data between libraries.
|
||||||
|
* Has to be NULL when ownership of the frame leaves the respective library.
|
||||||
|
*
|
||||||
|
* Code outside the FFmpeg libs should never check or change the contents of the buffer ref.
|
||||||
|
*
|
||||||
|
* FFmpeg calls av_buffer_unref() on it when the frame is unreferenced.
|
||||||
|
* av_frame_copy_props() calls create a new reference with av_buffer_ref()
|
||||||
|
* for the target frame's private_ref field.
|
||||||
|
*/
|
||||||
|
AVBufferRef *private_ref;
|
||||||
} AVFrame;
|
} AVFrame;
|
||||||
|
|
||||||
#if FF_API_FRAME_GET_SET
|
#if FF_API_FRAME_GET_SET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user