diff options
author | wm4 <wm4@nowhere> | 2016-04-15 15:11:08 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-04-15 15:31:23 +0200 |
commit | e6cdfdfa7446dca9b6737650e912ccd6122050b6 (patch) | |
tree | 92ec8cfea60d5b16b38fe292fc40dafae56f0d19 /video/mp_image.c | |
parent | bbaedfd0c5d59a22762c80c96406d5887f8ca488 (diff) | |
download | mpv-e6cdfdfa7446dca9b6737650e912ccd6122050b6.tar.bz2 mpv-e6cdfdfa7446dca9b6737650e912ccd6122050b6.tar.xz |
mp_image: simplify mp_image_steal_data()
Why was this so complex.
Diffstat (limited to 'video/mp_image.c')
-rw-r--r-- | video/mp_image.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index 0238a102f6..05cac1b3ef 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -164,20 +164,12 @@ void mp_image_steal_data(struct mp_image *dst, struct mp_image *src) assert(dst->imgfmt == src->imgfmt && dst->w == src->w && dst->h == src->h); assert(dst->bufs[0] && src->bufs[0]); - for (int p = 0; p < MP_MAX_PLANES; p++) { - dst->planes[p] = src->planes[p]; - dst->stride[p] = src->stride[p]; - } - mp_image_copy_attributes(dst, src); + mp_image_destructor(dst); // unref old + talloc_free_children(dst); - for (int p = 0; p < MP_MAX_PLANES; p++) { - av_buffer_unref(&dst->bufs[p]); - dst->bufs[p] = src->bufs[p]; - src->bufs[p] = NULL; - } - av_buffer_unref(&dst->hwctx); - dst->hwctx = src->hwctx; - src->hwctx = NULL; + *dst = *src; + + *src = (struct mp_image){0}; talloc_free(src); } @@ -752,14 +744,12 @@ struct AVFrame *mp_image_to_av_frame_and_unref(struct mp_image *img) return NULL; } mp_image_copy_fields_to_av_frame(frame, new_ref); - for (int p = 0; p < MP_MAX_PLANES; p++) { + for (int p = 0; p < MP_MAX_PLANES; p++) frame->buf[p] = new_ref->bufs[p]; - new_ref->bufs[p] = NULL; - } #if HAVE_AVUTIL_HAS_HWCONTEXT frame->hw_frames_ctx = new_ref->hwctx; #endif - new_ref->hwctx = NULL; + *new_ref = (struct mp_image){0}; talloc_free(new_ref); return frame; } |