mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 04:36:24 +01:00
Add option pointer to vf struct
This commit is contained in:
parent
7039bc090a
commit
0d59f81e54
@ -135,6 +135,7 @@ int vo_gamma_hue = 1000;
|
||||
extern vd_functions_t* mpvdec; // FIXME!
|
||||
|
||||
int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){
|
||||
struct MPOpts *opts = sh->opts;
|
||||
int i,j;
|
||||
unsigned int out_fmt=0;
|
||||
int screen_size_x=0;//SCREEN_SIZE_X;
|
||||
@ -157,7 +158,7 @@ int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outf
|
||||
|
||||
if(get_video_quality_max(sh)<=0 && divx_quality){
|
||||
// user wants postprocess but no pp filter yet:
|
||||
sh->vfilter=vf=vf_open_filter(vf,"pp",NULL);
|
||||
sh->vfilter=vf=vf_open_filter(opts, vf,"pp",NULL);
|
||||
}
|
||||
|
||||
// check if libvo and codec has common outfmt (no conversion):
|
||||
@ -197,13 +198,13 @@ csp_again:
|
||||
// TODO: no match - we should use conversion...
|
||||
if(strcmp(vf->info->name,"scale") && palette!=-1){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_INFO,MSGTR_CouldNotFindColorspace);
|
||||
sc=vf=vf_open_filter(vf,"scale",NULL);
|
||||
sc=vf=vf_open_filter(opts, vf,"scale",NULL);
|
||||
goto csp_again;
|
||||
} else
|
||||
if(palette==1){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_V,"vd: Trying -vf palette...\n");
|
||||
palette=-1;
|
||||
vf=vf_open_filter(vf,"palette",NULL);
|
||||
vf=vf_open_filter(opts, vf,"palette",NULL);
|
||||
goto csp_again;
|
||||
} else
|
||||
{ // sws failed, if the last filter (vf_vo) support MPEGPES try to append vf_lavc
|
||||
@ -218,7 +219,7 @@ csp_again:
|
||||
for(vo = vf ; vo->next ; vo = vo->next)
|
||||
vp = vo;
|
||||
if(vo->query_format(vo,IMGFMT_MPEGPES) && (!vp || (vp && strcmp(vp->info->name,"lavc")))) {
|
||||
ve = vf_open_filter(vo,"lavc",NULL);
|
||||
ve = vf_open_filter(opts, vo,"lavc",NULL);
|
||||
if(vp) vp->next = ve;
|
||||
else vf = ve;
|
||||
goto csp_again;
|
||||
|
@ -51,8 +51,8 @@ static vf_info_t* encoder_list[]={
|
||||
NULL
|
||||
};
|
||||
|
||||
vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args){
|
||||
vf_instance_t* vf_open_encoder(struct MPOpts *opts, vf_instance_t* next, const char *name, char *args){
|
||||
char* vf_args[] = { "_oldargs_", args, NULL };
|
||||
return vf_open_plugin(encoder_list,next,name,vf_args);
|
||||
return vf_open_plugin(opts, encoder_list,next,name,vf_args);
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){
|
||||
return vf_next_query_format(vf,fmt);
|
||||
}
|
||||
|
||||
vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){
|
||||
vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){
|
||||
vf_instance_t* vf;
|
||||
int i;
|
||||
for(i=0;;i++){
|
||||
@ -438,6 +438,7 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t
|
||||
}
|
||||
vf=malloc(sizeof(vf_instance_t));
|
||||
memset(vf,0,sizeof(vf_instance_t));
|
||||
vf->opts = opts;
|
||||
vf->info=filter_list[i];
|
||||
vf->next=next;
|
||||
vf->config=vf_next_config;
|
||||
@ -465,7 +466,7 @@ vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args){
|
||||
vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args){
|
||||
if(args && strcmp(args[0],"_oldargs_")) {
|
||||
int i,l = 0;
|
||||
for(i = 0 ; args && args[2*i] ; i++)
|
||||
@ -487,7 +488,7 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args
|
||||
mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter
|
||||
"[%s]\n", name);
|
||||
}
|
||||
return vf_open_plugin(filter_list,next,name,args);
|
||||
return vf_open_plugin(opts, filter_list,next,name,args);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -498,11 +499,12 @@ vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args
|
||||
* \return pointer to the filter instance that was created.
|
||||
*/
|
||||
vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) {
|
||||
struct MPOpts *opts = (*vf)->opts;
|
||||
vf_instance_t *vo, *prev = NULL, *new;
|
||||
// Find the last filter (should be vf_vo)
|
||||
for (vo = *vf; vo->next; vo = vo->next)
|
||||
prev = vo;
|
||||
new = vf_open_filter(vo, name, args);
|
||||
new = vf_open_filter(opts, vo, name, args);
|
||||
if (prev)
|
||||
prev->next = new;
|
||||
else
|
||||
@ -514,6 +516,7 @@ vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args) {
|
||||
|
||||
unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred){
|
||||
vf_instance_t* vf=*vfp;
|
||||
struct MPOpts *opts = vf->opts;
|
||||
const unsigned int* p;
|
||||
unsigned int best=0;
|
||||
int ret;
|
||||
@ -527,7 +530,7 @@ unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned
|
||||
if(best) return best; // bingo, they have common csp!
|
||||
// ok, then try with scale:
|
||||
if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion!
|
||||
vf=vf_open_filter(vf,"scale",NULL);
|
||||
vf=vf_open_filter(opts, vf,"scale",NULL);
|
||||
if(!vf) return 0; // failed to init "scale"
|
||||
// try the preferred csp first:
|
||||
if(preferred && vf->query_format(vf,preferred)) best=preferred; else
|
||||
@ -622,6 +625,7 @@ int vf_config_wrapper(struct vf_instance_s* vf,
|
||||
int vf_next_config(struct vf_instance_s* vf,
|
||||
int width, int height, int d_width, int d_height,
|
||||
unsigned int voflags, unsigned int outfmt){
|
||||
struct MPOpts *opts = vf->opts;
|
||||
int miss;
|
||||
int flags=vf->next->query_format(vf->next,outfmt);
|
||||
if(!flags){
|
||||
@ -629,7 +633,7 @@ int vf_next_config(struct vf_instance_s* vf,
|
||||
// let's insert the 'scale' filter, it does the job for us:
|
||||
vf_instance_t* vf2;
|
||||
if(vf->next->info==&vf_info_scale) return 0; // scale->scale
|
||||
vf2=vf_open_filter(vf->next,"scale",NULL);
|
||||
vf2=vf_open_filter(opts, vf->next,"scale",NULL);
|
||||
if(!vf2) return 0; // shouldn't happen!
|
||||
vf->next=vf2;
|
||||
flags=vf->next->query_format(vf->next,outfmt);
|
||||
@ -643,7 +647,7 @@ int vf_next_config(struct vf_instance_s* vf,
|
||||
if(miss&VFCAP_ACCEPT_STRIDE){
|
||||
// vf requires stride support but vf->next doesn't support it!
|
||||
// let's insert the 'expand' filter, it does the job for us:
|
||||
vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL);
|
||||
vf_instance_t* vf2=vf_open_filter(opts, vf->next,"expand",NULL);
|
||||
if(!vf2) return 0; // shouldn't happen!
|
||||
vf->next=vf2;
|
||||
}
|
||||
@ -690,6 +694,7 @@ void vf_next_draw_slice(struct vf_instance_s* vf,unsigned char** src, int * stri
|
||||
//============================================================================
|
||||
|
||||
vf_instance_t* append_filters(vf_instance_t* last){
|
||||
struct MPOpts *opts = last->opts;
|
||||
vf_instance_t* vf;
|
||||
int i;
|
||||
|
||||
@ -699,7 +704,7 @@ vf_instance_t* append_filters(vf_instance_t* last){
|
||||
/* NOP */;
|
||||
for(i-- ; i >= 0 ; i--) {
|
||||
//printf("Open filter %s\n",vf_settings[i].name);
|
||||
vf = vf_open_filter(last,vf_settings[i].name,vf_settings[i].attribs);
|
||||
vf = vf_open_filter(opts, last,vf_settings[i].name,vf_settings[i].attribs);
|
||||
if(vf) last=vf;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "mp_image.h"
|
||||
|
||||
struct MPOpts;
|
||||
struct vf_instance_s;
|
||||
struct vf_priv_s;
|
||||
|
||||
@ -59,6 +60,7 @@ typedef struct vf_instance_s {
|
||||
struct vf_instance_s* next;
|
||||
mp_image_t *dmpi;
|
||||
struct vf_priv_s* priv;
|
||||
struct MPOpts *opts;
|
||||
} vf_instance_t;
|
||||
|
||||
// control codes:
|
||||
@ -97,10 +99,10 @@ typedef struct vf_seteq_s
|
||||
void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h);
|
||||
mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h);
|
||||
|
||||
vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args);
|
||||
vf_instance_t* vf_open_filter(vf_instance_t* next, const char *name, char **args);
|
||||
vf_instance_t* vf_open_plugin(struct MPOpts *opts, const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args);
|
||||
vf_instance_t* vf_open_filter(struct MPOpts *opts, vf_instance_t* next, const char *name, char **args);
|
||||
vf_instance_t* vf_add_before_vo(vf_instance_t **vf, char *name, char **args);
|
||||
vf_instance_t* vf_open_encoder(vf_instance_t* next, const char *name, char *args);
|
||||
vf_instance_t* vf_open_encoder(struct MPOpts *opts, vf_instance_t* next, const char *name, char *args);
|
||||
|
||||
unsigned int vf_match_csp(vf_instance_t** vfp,const unsigned int* list,unsigned int preferred);
|
||||
void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src);
|
||||
|
18
mencoder.c
18
mencoder.c
@ -871,21 +871,21 @@ default: {
|
||||
if (!ve) {
|
||||
switch(mux_v->codec){
|
||||
case VCODEC_LIBAVCODEC:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"lavc",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"lavc",(char *)mux_v); break;
|
||||
case VCODEC_RAW:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"raw",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"raw",(char *)mux_v); break;
|
||||
case VCODEC_VFW:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"vfw",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"vfw",(char *)mux_v); break;
|
||||
case VCODEC_LIBDV:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"libdv",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"libdv",(char *)mux_v); break;
|
||||
case VCODEC_XVID:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"xvid",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"xvid",(char *)mux_v); break;
|
||||
case VCODEC_QTVIDEO:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"qtvideo",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"qtvideo",(char *)mux_v); break;
|
||||
case VCODEC_NUV:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"nuv",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"nuv",(char *)mux_v); break;
|
||||
case VCODEC_X264:
|
||||
sh_video->vfilter=vf_open_encoder(NULL,"x264",(char *)mux_v); break;
|
||||
sh_video->vfilter=vf_open_encoder(&opts, NULL,"x264",(char *)mux_v); break;
|
||||
}
|
||||
if(!mux_v->bih || !sh_video->vfilter){
|
||||
mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_EncoderOpenFailed);
|
||||
@ -896,7 +896,7 @@ default: {
|
||||
// append 'expand' filter, it fixes stride problems and renders osd:
|
||||
if (auto_expand) {
|
||||
char* vf_args[] = { "osd", "1", NULL };
|
||||
sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand",vf_args);
|
||||
sh_video->vfilter=vf_open_filter(&opts, sh_video->vfilter,"expand",vf_args);
|
||||
}
|
||||
sh_video->vfilter=append_filters(sh_video->vfilter);
|
||||
|
||||
|
@ -2155,12 +2155,12 @@ int reinit_video_chain(void) {
|
||||
current_module="init_video_filters";
|
||||
{
|
||||
char* vf_arg[] = { "_oldargs_", (char*)mpctx->video_out , NULL };
|
||||
sh_video->vfilter=(void*)vf_open_filter(NULL,"vo",vf_arg);
|
||||
sh_video->vfilter=(void*)vf_open_filter(opts, NULL,"vo",vf_arg);
|
||||
}
|
||||
#ifdef HAVE_MENU
|
||||
if(use_menu) {
|
||||
char* vf_arg[] = { "_oldargs_", menu_root, NULL };
|
||||
vf_menu = vf_open_plugin(libmenu_vfs,sh_video->vfilter,"menu",vf_arg);
|
||||
vf_menu = vf_open_plugin(opts,libmenu_vfs,sh_video->vfilter,"menu",vf_arg);
|
||||
if(!vf_menu) {
|
||||
mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantOpenLibmenuFilterWithThisRootMenu,menu_root);
|
||||
use_menu = 0;
|
||||
@ -2184,7 +2184,7 @@ int reinit_video_chain(void) {
|
||||
extern vf_info_t vf_info_ass;
|
||||
const vf_info_t* libass_vfs[] = {&vf_info_ass, NULL};
|
||||
char* vf_arg[] = {"auto", "1", NULL};
|
||||
vf_instance_t* vf_ass = vf_open_plugin(libass_vfs,sh_video->vfilter,"ass",vf_arg);
|
||||
vf_instance_t* vf_ass = vf_open_plugin(opts, libass_vfs,sh_video->vfilter,"ass",vf_arg);
|
||||
if (vf_ass)
|
||||
sh_video->vfilter=(void*)vf_ass;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user