summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-12-22 21:46:28 +0100
committerwm4 <wm4@nowhere>2013-01-13 20:04:11 +0100
commit233cc15be99a94891bfc62bbb79af38ee192d9ff (patch)
treeda9cf9929a30b1af185f7745f1223a78b2f32f23 /video
parent5830d639b8d58b0911510db1ccb5de296adfcb4b (diff)
downloadmpv-233cc15be99a94891bfc62bbb79af38ee192d9ff.tar.bz2
mpv-233cc15be99a94891bfc62bbb79af38ee192d9ff.tar.xz
vo_lavc: use reference counting
Helps avoiding additional copies.
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_lavc.c21
1 files changed, 4 insertions, 17 deletions
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);
}