1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-23 16:36:56 +00:00

vo_lavc: use reference counting

Helps avoiding additional copies.
This commit is contained in:
wm4 2012-12-22 21:46:28 +01:00
parent 5830d639b8
commit 233cc15be9

View File

@ -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);
}