diff options
author | wm4 <wm4@nowhere> | 2013-03-09 20:50:06 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-03-13 23:51:30 +0100 |
commit | 514d8a7c9dfde2acc89ee4d19dd9db6b9db5b882 (patch) | |
tree | 5a4eeebc797a16866a7dc4f8b846854c9a33f0b8 /video/mp_image.c | |
parent | 71b09be04056d9a505f32c71375ebc327d842ae4 (diff) | |
download | mpv-514d8a7c9dfde2acc89ee4d19dd9db6b9db5b882.tar.bz2 mpv-514d8a7c9dfde2acc89ee4d19dd9db6b9db5b882.tar.xz |
video: make use of libavcodec refcounting
Now lavc_dr1.c is not used anymore if libavcodec is recent enough.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r-- | video/mp_image.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 57124eab11..72da838822 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -459,3 +459,31 @@ void mp_image_copy_fields_from_av_frame(struct mp_image *dst, if (src->repeat_pict == 1) dst->fields |= MP_IMGFIELD_REPEAT_FIRST; } + +#if HAVE_AVUTIL_REFCOUNTING + +static void frame_free(void *p) +{ + AVFrame *frame = p; + av_frame_free(&frame); +} + +static bool frame_is_unique(void *p) +{ + AVFrame *frame = p; + return av_frame_is_writable(frame); +} + +// Create a new mp_image reference to av_frame. +struct mp_image *mp_image_from_av_frame(struct AVFrame *av_frame) +{ + AVFrame *new_ref = av_frame_clone(av_frame); + if (!new_ref) + abort(); // OOM + struct mp_image t = {0}; + mp_image_copy_fields_from_av_frame(&t, new_ref); + return mp_image_new_external_ref(&t, new_ref, NULL, NULL, frame_is_unique, + frame_free); +} + +#endif /* HAVE_AVUTIL_REFCOUNTING */ |