From 233cc15be99a94891bfc62bbb79af38ee192d9ff Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 22 Dec 2012 21:46:28 +0100 Subject: vo_lavc: use reference counting Helps avoiding additional copies. --- video/out/vo_lavc.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'video/out/vo_lavc.c') diff --git a/video/out/vo_lavc.c b/video/out/vo_lavc.c index aa9077fb17..35041c7f63 100644 --- a/video/out/vo_lavc.c +++ b/video/out/vo_lavc.c @@ -85,13 +85,7 @@ static void uninit(struct vo *vo) if (vc->lastipts >= 0 && vc->stream) draw_image(vo, NULL); - if (vc->lastimg) { - // palette hack - if (vc->lastimg->imgfmt == IMGFMT_PAL8) - vc->lastimg->planes[1] = NULL; - talloc_free(vc->lastimg); - vc->lastimg = NULL; - } + mp_image_unrefp(&vc->lastimg); vo->priv = NULL; } @@ -171,11 +165,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, vc->buffer = talloc_size(vc, vc->buffer_size); - vc->lastimg = mp_image_alloc(format, width, height); - - // palette hack - if (vc->lastimg->imgfmt == IMGFMT_PAL8) - vc->lastimg->planes[1] = talloc_zero_size(vc, MP_PALETTE_SIZE); + mp_image_unrefp(&vc->lastimg); return 0; @@ -455,13 +445,9 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) mp_msg(MSGT_ENCODE, MSGL_INFO, "vo-lavc: Frame at pts %d got displayed %d times\n", (int) vc->lastframeipts, vc->lastdisplaycount); - mp_image_copy(vc->lastimg, mpi); + mp_image_setrefp(&vc->lastimg, mpi); vc->lastimg_wants_osd = true; - // palette hack - if (vc->lastimg->imgfmt == IMGFMT_PAL8) - memcpy(vc->lastimg->planes[1], mpi->planes[1], MP_PALETTE_SIZE); - vc->lastframeipts = vc->lastipts = frameipts; if (ectx->options->rawts && vc->lastipts < 0) { mp_msg(MSGT_ENCODE, MSGL_ERR, "vo-lavc: why does this happen? DEBUG THIS! vc->lastipts = %lld\n", (long long) vc->lastipts); @@ -501,6 +487,7 @@ static void draw_osd(struct vo *vo, struct osd_state *osd) }; mp_image_set_colorspace_details(vc->lastimg, &vc->colorspace); + mp_image_make_writeable(vc->lastimg); osd_draw_on_image(osd, dim, osd->vo_pts, OSD_DRAW_SUB_ONLY, vc->lastimg); } -- cgit v1.2.3