summaryrefslogtreecommitdiffstats
path: root/video/mp_image.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-04-15 15:33:53 +0200
committerwm4 <wm4@nowhere>2016-04-15 15:33:53 +0200
commitd04aa5ef4e12f5bee3343e833e1209774e9204d9 (patch)
tree0e5cea32ab7cb527d60af3c368842efb12a2f70f /video/mp_image.c
parente6cdfdfa7446dca9b6737650e912ccd6122050b6 (diff)
downloadmpv-d04aa5ef4e12f5bee3343e833e1209774e9204d9.tar.bz2
mpv-d04aa5ef4e12f5bee3343e833e1209774e9204d9.tar.xz
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.)
Diffstat (limited to 'video/mp_image.c')
-rw-r--r--video/mp_image.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/video/mp_image.c b/video/mp_image.c
index 05cac1b3ef..0910bb9abc 100644
--- a/video/mp_image.c
+++ b/video/mp_image.c
@@ -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)
{