From ded932dbd40e326a8d42acb8c4b8297046f08695 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 22 Dec 2012 19:11:53 +0100 Subject: vo_image: render subs This makes it behave like vo_lavc. Unfortunately, the code for setting up the OSD dimensions (mp_osd_res) is copied from vo_lavc, but it doesn't look like something that should be factored out. --- video/out/vo_image.c | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) (limited to 'video/out/vo_image.c') diff --git a/video/out/vo_image.c b/video/out/vo_image.c index 2c9c6f3acf..7188abf9b0 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -36,12 +36,16 @@ #include "video/mp_image.h" #include "video/fmt-conversion.h" #include "video/image_writer.h" +#include "video/sws_utils.h" +#include "sub/sub.h" #include "core/m_option.h" struct priv { struct image_writer_opts *opts; char *outdir; + struct mp_image *current; + int frame; uint32_t d_width; @@ -74,6 +78,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, { struct priv *p = vo->priv; + mp_image_unrefp(&p->current); + p->d_width = d_width; p->d_height = d_height; @@ -88,22 +94,38 @@ static void check_events(struct vo *vo) { } -static void draw_osd(struct vo *vo, struct osd_state *osd) +static void draw_image(struct vo *vo, mp_image_t *mpi) { + struct priv *p = vo->priv; + + mp_image_setrefp(&p->current, mpi); + + mp_image_set_display_size(p->current, p->d_width, p->d_height); + mp_image_set_colorspace_details(p->current, &p->colorspace); } -static void flip_page(struct vo *vo) +static void draw_osd(struct vo *vo, struct osd_state *osd) { + struct priv *p = vo->priv; + + struct aspect_data asp = vo->aspdat; + double sar = (double)asp.orgw / asp.orgh; + double dar = (double)asp.prew / asp.preh; + + struct mp_osd_res dim = { + .w = asp.orgw, + .h = asp.orgh, + .display_par = sar / dar, + .video_par = dar / sar, + }; + + osd_draw_on_image(osd, dim, osd->vo_pts, OSD_DRAW_SUB_ONLY, p->current); } -static void draw_image(struct vo *vo, mp_image_t *mpi) +static void flip_page(struct vo *vo) { struct priv *p = vo->priv; - mp_image_t img = *mpi; - mp_image_set_display_size(&img, p->d_width, p->d_height); - mp_image_set_colorspace_details(&img, &p->colorspace); - void *t = talloc_new(NULL); char *filename = talloc_asprintf(t, "%08d.%s", p->frame, image_writer_file_ext(p->opts)); @@ -112,27 +134,26 @@ static void draw_image(struct vo *vo, mp_image_t *mpi) filename = mp_path_join(t, bstr0(p->outdir), bstr0(filename)); mp_msg(MSGT_VO, MSGL_STATUS, "\nSaving %s\n", filename); - write_image(&img, p->opts, filename); + write_image(p->current, p->opts, filename); talloc_free(t); + mp_image_unrefp(&p->current); (p->frame)++; } static int query_format(struct vo *vo, uint32_t fmt) { - enum PixelFormat av_format = imgfmt2pixfmt(fmt); - - // NOTE: accept everything that can be converted by swscale. screenshot.c - // always wants RGB (at least for now), but it probably doesn't matter - // whether we or screenshot.c do the conversion. - if (av_format != PIX_FMT_NONE && sws_isSupportedInput(av_format)) - return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; + if (mp_sws_supported_format(fmt)) + return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_OSD; return 0; } static void uninit(struct vo *vo) { + struct priv *p = vo->priv; + + mp_image_unrefp(&p->current); } static int preinit(struct vo *vo, const char *arg) -- cgit v1.2.3