diff options
Diffstat (limited to 'libmpcodecs/vf_scale.c')
-rw-r--r-- | libmpcodecs/vf_scale.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c index 9f96ad84d9..208136e812 100644 --- a/libmpcodecs/vf_scale.c +++ b/libmpcodecs/vf_scale.c @@ -24,6 +24,7 @@ #include "config.h" #include "mp_msg.h" #include "cpudetect.h" +#include "options.h" #include "img_format.h" #include "mp_image.h" @@ -58,15 +59,11 @@ static struct vf_priv_s { NULL }; -extern int opt_screen_size_x; -extern int opt_screen_size_y; -extern float screen_size_xy; - //===========================================================================// void sws_getFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam); -static unsigned int outfmt_list[]={ +static const unsigned int outfmt_list[]={ // YUV: IMGFMT_444P, IMGFMT_444P16_LE, @@ -166,9 +163,10 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format){ return best; } -static int config(struct vf_instance_s* vf, +static int config(struct vf_instance* vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt){ + struct MPOpts *opts = vf->opts; unsigned int best=find_best_out(vf, outfmt); int vo_flags; int int_sws_flags=0; @@ -350,7 +348,8 @@ static int config(struct vf_instance_s* vf, break; } } - if(!opt_screen_size_x && !opt_screen_size_y && !(screen_size_xy >= 0.001)){ + if (!opts->screen_size_x && !opts->screen_size_y + && !(opts->screen_size_xy >= 0.001)) { // Compute new d_width and d_height, preserving aspect // while ensuring that both are >= output size in pixels. if (vf->priv->h * d_width > vf->priv->w * d_height) { @@ -366,7 +365,7 @@ static int config(struct vf_instance_s* vf, return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best); } -static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){ +static void start_slice(struct vf_instance* vf, mp_image_t *mpi){ // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK); if(!(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) return; // shouldn't happen // they want slices!!! allocate the buffer. @@ -406,7 +405,7 @@ static void scale(struct SwsContext *sws1, struct SwsContext *sws2, uint8_t *src } } -static void draw_slice(struct vf_instance_s* vf, +static void draw_slice(struct vf_instance* vf, unsigned char** src, int* stride, int w,int h, int x, int y){ mp_image_t *dmpi=vf->dmpi; if(!dmpi){ @@ -417,7 +416,7 @@ static void draw_slice(struct vf_instance_s* vf, scale(vf->priv->ctx, vf->priv->ctx2, src, stride, y, h, dmpi->planes, dmpi->stride, vf->priv->interlaced); } -static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ +static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){ mp_image_t *dmpi=mpi->priv; // printf("vf_scale::put_image(): processing whole frame! dmpi=%p flag=%d\n", @@ -444,7 +443,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ return vf_next_put_image(vf,dmpi, pts); } -static int control(struct vf_instance_s* vf, int request, void* data){ +static int control(struct vf_instance* vf, int request, void* data){ int *table; int *inv_table; int r; @@ -507,7 +506,7 @@ static int control(struct vf_instance_s* vf, int request, void* data){ // supported Input formats: YV12, I420, IYUV, YUY2, UYVY, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8, Y800 -static int query_format(struct vf_instance_s* vf, unsigned int fmt){ +static int query_format(struct vf_instance* vf, unsigned int fmt){ switch(fmt){ case IMGFMT_YV12: case IMGFMT_I420: @@ -556,7 +555,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ return 0; // nomatching in-fmt } -static void uninit(struct vf_instance_s *vf){ +static void uninit(struct vf_instance *vf){ if(vf->priv->ctx) sws_freeContext(vf->priv->ctx); if(vf->priv->ctx2) sws_freeContext(vf->priv->ctx2); if(vf->priv->palette) free(vf->priv->palette); @@ -658,7 +657,7 @@ struct SwsContext *sws_getContextFromCmdLine(int srcW, int srcH, int srcFormat, } /// An example of presets usage -static struct size_preset { +static const struct size_preset { char* name; int w, h; } vf_size_presets_defs[] = { @@ -673,21 +672,21 @@ static struct size_preset { }; #define ST_OFF(f) M_ST_OFF(struct size_preset,f) -static m_option_t vf_size_preset_fields[] = { +static const m_option_t vf_size_preset_fields[] = { {"w", ST_OFF(w), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL}, {"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,1 ,0, NULL}, { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_size_preset = { +static const m_struct_t vf_size_preset = { "scale_size_preset", sizeof(struct size_preset), NULL, vf_size_preset_fields }; -static m_struct_t vf_opts; -static m_obj_presets_t size_preset = { +static const m_struct_t vf_opts; +static const m_obj_presets_t size_preset = { &vf_size_preset, // Input struct desc &vf_opts, // Output struct desc vf_size_presets_defs, // The list of presets @@ -697,7 +696,7 @@ static m_obj_presets_t size_preset = { /// Now the options #undef ST_OFF #define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { +static const m_option_t vf_opts_fields[] = { {"w", ST_OFF(w), CONF_TYPE_INT, M_OPT_MIN,-11,0, NULL}, {"h", ST_OFF(h), CONF_TYPE_INT, M_OPT_MIN,-11,0, NULL}, {"interlaced", ST_OFF(interlaced), CONF_TYPE_INT, M_OPT_RANGE, 0, 1, NULL}, @@ -712,7 +711,7 @@ static m_option_t vf_opts_fields[] = { { NULL, NULL, 0, 0, 0, 0, NULL } }; -static m_struct_t vf_opts = { +static const m_struct_t vf_opts = { "scale", sizeof(struct vf_priv_s), &vf_priv_dflt, |