mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 23:32:26 +00:00
mp_image: add mp_image_to_av_frame()
What mp_image_to_av_frame_and_unref() should have been. (The _unref variant is still useful though.)
This commit is contained in:
parent
e6cdfdfa74
commit
d04aa5ef4e
@ -729,14 +729,9 @@ struct mp_image *mp_image_from_av_frame(struct AVFrame *av_frame)
|
||||
}
|
||||
|
||||
// Convert the mp_image reference to a AVFrame reference.
|
||||
// Warning: img is unreferenced (i.e. free'd). This is asymmetric to
|
||||
// mp_image_from_av_frame(). It was done as some sort of optimization,
|
||||
// but now these semantics are pointless.
|
||||
// On failure, img is only unreffed.
|
||||
struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img)
|
||||
struct AVFrame *mp_image_to_av_frame(struct mp_image *img)
|
||||
{
|
||||
struct mp_image *new_ref = mp_image_new_ref(img);
|
||||
talloc_free(img);
|
||||
AVFrame *frame = av_frame_alloc();
|
||||
if (!frame || !new_ref) {
|
||||
talloc_free(new_ref);
|
||||
@ -754,6 +749,14 @@ struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img)
|
||||
return frame;
|
||||
}
|
||||
|
||||
// Same as mp_image_to_av_frame(), but unref img. (It does so even on failure.)
|
||||
struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img)
|
||||
{
|
||||
AVFrame *frame = mp_image_to_av_frame(img);
|
||||
talloc_free(img);
|
||||
return frame;
|
||||
}
|
||||
|
||||
void memcpy_pic(void *dst, const void *src, int bytesPerLine, int height,
|
||||
int dstStride, int srcStride)
|
||||
{
|
||||
|
@ -159,6 +159,7 @@ void mp_image_copy_fields_from_av_frame(struct mp_image *dst,
|
||||
void mp_image_copy_fields_to_av_frame(struct AVFrame *dst,
|
||||
struct mp_image *src);
|
||||
struct mp_image *mp_image_from_av_frame(struct AVFrame *av_frame);
|
||||
struct AVFrame *mp_image_to_av_frame(struct mp_image *img);
|
||||
struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img);
|
||||
|
||||
void memcpy_pic(void *dst, const void *src, int bytesPerLine, int height,
|
||||
|
Loading…
Reference in New Issue
Block a user