diff options
Diffstat (limited to 'libmpcodecs/vf_expand.c')
-rw-r--r-- | libmpcodecs/vf_expand.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/libmpcodecs/vf_expand.c b/libmpcodecs/vf_expand.c index f843d8fe43..57226acb93 100644 --- a/libmpcodecs/vf_expand.c +++ b/libmpcodecs/vf_expand.c @@ -21,14 +21,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include "config.h" #include "mp_msg.h" -#include "help_mp.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" -#include "vd.h" #include "vf.h" #include "libvo/fastmemcpy.h" @@ -52,12 +52,13 @@ static struct vf_priv_s { int cfg_exp_x, cfg_exp_y; int exp_w,exp_h; int exp_x,exp_y; - int osd; + int osd_enabled; double aspect; int round; unsigned char* fb_ptr; int passthrough; int first_slice; + struct osd_state *osd; } const vf_priv_dflt = { -1,-1, -1,-1, @@ -120,7 +121,7 @@ static void remove_func(int x0,int y0, int w,int h){ } } -static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){ +static void draw_func(void *ctx, int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){ unsigned char* dst; if(!vo_osd_changed_flag && vf->dmpi->planes[0]==vf->priv->fb_ptr){ // ok, enough to update the area inside the video, leave the black bands @@ -202,10 +203,10 @@ static void draw_osd(struct vf_instance *vf_,int w,int h){ remove_func_2(vf->priv->exp_x+w,vf->priv->exp_y,vf->priv->exp_w-w-vf->priv->exp_x,h); } else { // partial clear: - vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func); + osd_remove_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,remove_func); } } - vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func); + osd_draw_text(vf->priv->osd, vf->priv->exp_w,vf->priv->exp_h,draw_func, NULL); // save buffer pointer for double buffering detection - yes, i know it's // ugly method, but note that codecs with DR support does the same... if(vf->dmpi) @@ -217,7 +218,9 @@ static void draw_osd(struct vf_instance *vf_,int w,int h){ static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, - unsigned int flags, unsigned int outfmt){ + unsigned int flags, unsigned int outfmt) +{ + struct MPOpts *opts = vf->opts; if(outfmt == IMGFMT_MPEGPES) { vf->priv->passthrough = 1; return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt); @@ -257,7 +260,7 @@ static int config(struct vf_instance *vf, if(vf->priv->exp_y<0 || vf->priv->exp_y+height>vf->priv->exp_h) vf->priv->exp_y=(vf->priv->exp_h-height)/2; vf->priv->fb_ptr=NULL; - if(!opt_screen_size_x && !opt_screen_size_y){ + if(!opts->screen_size_x && !opts->screen_size_y){ d_width=d_width*vf->priv->exp_w/width; d_height=d_height*vf->priv->exp_h/height; } @@ -273,9 +276,9 @@ static int config(struct vf_instance *vf, static void get_image(struct vf_instance *vf, mp_image_t *mpi){ // if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working #ifdef OSD_SUPPORT - if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){ + if(vf->priv->osd_enabled && (mpi->flags&MP_IMGFLAG_PRESERVE)){ // check if we have to render osd! - vo_update_osd(vf->priv->exp_w, vf->priv->exp_h); + osd_update(vf->priv->osd, vf->priv->exp_w, vf->priv->exp_h); if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y, vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return; } @@ -289,7 +292,7 @@ static void get_image(struct vf_instance *vf, mp_image_t *mpi){ FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) && !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){ - mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible); + mp_tmsg(MSGT_VFILTER, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n"); return; } // set up mpi as a cropped-down image of dmpi: @@ -329,7 +332,7 @@ static void start_slice(struct vf_instance *vf, mp_image_t *mpi){ FFMAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) - mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupportSlices); // shouldn't happen. + mp_tmsg(MSGT_VFILTER, MSGL_WARN, "WARNING! Next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen. vf->priv->first_slice = 1; } @@ -395,10 +398,10 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){ vf->dmpi=mpi->priv; - if(!vf->dmpi) { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; } + if(!vf->dmpi) { mp_tmsg(MSGT_VFILTER, MSGL_WARN, "Why do we get NULL??\n"); return 0; } mpi->priv=NULL; #ifdef OSD_SUPPORT - if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); + if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h); #endif // we've used DR, so we're ready... if(!(mpi->flags&MP_IMGFLAG_PLANAR)) @@ -433,7 +436,7 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette } #ifdef OSD_SUPPORT - if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); + if(vf->priv->osd_enabled) draw_osd(vf,mpi->w,mpi->h); #endif return vf_next_put_image(vf,vf->dmpi, pts); } @@ -443,8 +446,16 @@ static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){ static int control(struct vf_instance *vf, int request, void* data){ #ifdef OSD_SUPPORT switch(request){ + case VFCTRL_SET_OSD_OBJ: + vf->priv->osd = data; + break; case VFCTRL_DRAW_OSD: - if(vf->priv->osd) return CONTROL_TRUE; + if(vf->priv->osd_enabled) return CONTROL_TRUE; + break; + case VFCTRL_REDRAW_OSD: + if (vf->priv->osd_enabled) + return false; + break; } #endif return vf_next_control(vf,request,data); @@ -467,19 +478,19 @@ static int vf_open(vf_instance_t *vf, char *args){ vf->priv->cfg_exp_h, vf->priv->cfg_exp_x, vf->priv->cfg_exp_y, - vf->priv->osd, + vf->priv->osd_enabled, vf->priv->aspect, vf->priv->round); return 1; } #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static const m_option_t vf_opts_fields[] = { +static m_option_t vf_opts_fields[] = { {"w", ST_OFF(cfg_exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL}, {"h", ST_OFF(cfg_exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL}, {"x", ST_OFF(cfg_exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, {"y", ST_OFF(cfg_exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, - {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL}, + {"osd", ST_OFF(osd_enabled), CONF_TYPE_FLAG, 0 , 0, 1, NULL}, {"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL}, {"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } |