Mercurial > mplayer.hg
comparison libmpcodecs/vf.c @ 9593:e9a2af584986
Add the new -vf option wich is the same as vop in reverse order.
Syntax is we decided, so you can give the nomes or not with both
vop and vf. vf take precedence over vop.
author | albeu |
---|---|
date | Sat, 15 Mar 2003 18:01:02 +0000 |
parents | 0b4c387ddd4f |
children | 298e261aecd7 |
comparison
equal
deleted
inserted
replaced
9592:b20b0c80298b | 9593:e9a2af584986 |
---|---|
7 #include <malloc.h> | 7 #include <malloc.h> |
8 #endif | 8 #endif |
9 | 9 |
10 #include "../mp_msg.h" | 10 #include "../mp_msg.h" |
11 #include "../help_mp.h" | 11 #include "../help_mp.h" |
12 #include "../m_option.h" | |
13 #include "../m_struct.h" | |
12 | 14 |
13 | 15 |
14 #include "img_format.h" | 16 #include "img_format.h" |
15 #include "mp_image.h" | 17 #include "mp_image.h" |
16 #include "vf.h" | 18 #include "vf.h" |
57 extern vf_info_t vf_info_denoise3d; | 59 extern vf_info_t vf_info_denoise3d; |
58 extern vf_info_t vf_info_hqdn3d; | 60 extern vf_info_t vf_info_hqdn3d; |
59 extern vf_info_t vf_info_detc; | 61 extern vf_info_t vf_info_detc; |
60 extern vf_info_t vf_info_telecine; | 62 extern vf_info_t vf_info_telecine; |
61 extern vf_info_t vf_info_tfields; | 63 extern vf_info_t vf_info_tfields; |
62 | |
63 char** vo_plugin_args=(char**) NULL; | |
64 | 64 |
65 // list of available filters: | 65 // list of available filters: |
66 static vf_info_t* filter_list[]={ | 66 static vf_info_t* filter_list[]={ |
67 &vf_info_rectangle, | 67 &vf_info_rectangle, |
68 &vf_info_bmovl, | 68 &vf_info_bmovl, |
112 &vf_info_hqdn3d, | 112 &vf_info_hqdn3d, |
113 &vf_info_detc, | 113 &vf_info_detc, |
114 &vf_info_telecine, | 114 &vf_info_telecine, |
115 &vf_info_tfields, | 115 &vf_info_tfields, |
116 NULL | 116 NULL |
117 }; | |
118 | |
119 // For the vf option | |
120 m_obj_settings_t* vf_settings = NULL; | |
121 // For the vop option | |
122 m_obj_settings_t* vo_plugin_args = NULL; | |
123 m_obj_list_t vf_obj_list = { | |
124 (void**)filter_list, | |
125 M_ST_OFF(vf_info_t,name), | |
126 M_ST_OFF(vf_info_t,info), | |
127 M_ST_OFF(vf_info_t,opts) | |
117 }; | 128 }; |
118 | 129 |
119 //============================================================================ | 130 //============================================================================ |
120 // mpi stuff: | 131 // mpi stuff: |
121 | 132 |
304 static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){ | 315 static int vf_default_query_format(struct vf_instance_s* vf, unsigned int fmt){ |
305 if(fmt == IMGFMT_MPEGPES) return 0; | 316 if(fmt == IMGFMT_MPEGPES) return 0; |
306 return vf_next_query_format(vf,fmt); | 317 return vf_next_query_format(vf,fmt); |
307 } | 318 } |
308 | 319 |
309 vf_instance_t* vf_open_plugin(vf_info_t** filter_list, vf_instance_t* next, char *name, char *args){ | 320 vf_instance_t* vf_open_plugin(vf_info_t** filter_list, vf_instance_t* next, char *name, char **args){ |
310 vf_instance_t* vf; | 321 vf_instance_t* vf; |
311 int i; | 322 int i; |
312 for(i=0;;i++){ | 323 for(i=0;;i++){ |
313 if(!filter_list[i]){ | 324 if(!filter_list[i]){ |
314 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name); | 325 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name); |
324 vf->control=vf_next_control; | 335 vf->control=vf_next_control; |
325 vf->query_format=vf_default_query_format; | 336 vf->query_format=vf_default_query_format; |
326 vf->put_image=vf_next_put_image; | 337 vf->put_image=vf_next_put_image; |
327 vf->default_caps=VFCAP_ACCEPT_STRIDE; | 338 vf->default_caps=VFCAP_ACCEPT_STRIDE; |
328 vf->default_reqs=0; | 339 vf->default_reqs=0; |
329 if(vf->info->open(vf,args)>0) return vf; // Success! | 340 if(vf->info->opts) { // vf_vo get some special argument |
341 m_struct_t* st = vf->info->opts; | |
342 void* vf_priv = m_struct_alloc(st); | |
343 int n; | |
344 for(n = 0 ; args && args[2*n] ; n++) | |
345 m_struct_set(st,vf_priv,args[2*n],args[2*n+1]); | |
346 vf->priv = vf_priv; | |
347 args = NULL; | |
348 } else // Otherwise we should have the '_oldargs_' | |
349 if(args && !strcmp(args[0],"_oldargs_")) | |
350 args = (char**)args[1]; | |
351 else | |
352 args = NULL; | |
353 if(vf->info->open(vf,(char*)args)>0) return vf; // Success! | |
330 free(vf); | 354 free(vf); |
331 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name); | 355 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name); |
332 return NULL; | 356 return NULL; |
333 } | 357 } |
334 | 358 |
335 vf_instance_t* vf_open_filter(vf_instance_t* next, char *name, char *args){ | 359 vf_instance_t* vf_open_filter(vf_instance_t* next, char *name, char **args){ |
336 if(strcmp(name,"vo")) | 360 if(args && strcmp(args[0],"_oldargs_")) { |
337 mp_msg(MSGT_VFILTER,MSGL_INFO, | 361 int i,l = 0; |
338 args ? MSGTR_OpeningVideoFilter "[%s=%s]\n" | 362 for(i = 0 ; args && args[2*i] ; i++) |
339 : MSGTR_OpeningVideoFilter "[%s]\n",name,args); | 363 l += 1 + strlen(args[2*i]) + 1 + strlen(args[2*i+1]); |
340 return vf_open_plugin(filter_list,next,name,args); | 364 l += strlen(name); |
365 { | |
366 char str[l+1]; | |
367 char* p = str; | |
368 p += sprintf(str,"%s",name); | |
369 for(i = 0 ; args && args[2*i] ; i++) | |
370 p += sprintf(p," %s=%s",args[2*i],args[2*i+1]); | |
371 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str); | |
372 } | |
373 } else if(strcmp(name,"vo")) { | |
374 if(args && strcmp(args[0],"_oldargs_") == 0) | |
375 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter | |
376 "[%s=%s]\n", name,args[1]); | |
377 else | |
378 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter | |
379 "[%s]\n", name); | |
380 } | |
381 return vf_open_plugin(filter_list,next,name,args); | |
341 } | 382 } |
342 | 383 |
343 //============================================================================ | 384 //============================================================================ |
344 | 385 |
345 unsigned int vf_match_csp(vf_instance_t** vfp,unsigned int* list,unsigned int preferred){ | 386 unsigned int vf_match_csp(vf_instance_t** vfp,unsigned int* list,unsigned int preferred){ |
423 } | 464 } |
424 | 465 |
425 //============================================================================ | 466 //============================================================================ |
426 | 467 |
427 vf_instance_t* append_filters(vf_instance_t* last){ | 468 vf_instance_t* append_filters(vf_instance_t* last){ |
428 vf_instance_t* vf; | 469 vf_instance_t* vf; |
429 char** plugin_args = vo_plugin_args; | 470 int i; |
430 if(!vo_plugin_args) return last; | 471 |
431 while(*plugin_args){ | 472 // -vf take precedence over -vop |
432 char* name=strdup(*plugin_args); | 473 if(vf_settings) { |
433 char* args=strchr(name,'='); | 474 // We want to add them in the 'right order' |
434 if(args){args[0]=0;++args;} | 475 for(i = 0 ; vf_settings[i].name ; i++) |
435 vf=vf_open_filter(last,name,args); | 476 /* NOP */; |
436 if(vf) last=vf; | 477 for(i-- ; i >= 0 ; i--) { |
437 free(name); | 478 //printf("Open filter %s\n",vf_settings[i].name); |
438 ++plugin_args; | 479 vf = vf_open_filter(last,vf_settings[i].name,vf_settings[i].attribs); |
439 } | 480 if(vf) last=vf; |
440 return last; | 481 } |
482 } else if(vo_plugin_args) { | |
483 for(i = 0 ; vo_plugin_args[i].name ; i++) { | |
484 vf = vf_open_filter(last,vo_plugin_args[i].name, | |
485 vo_plugin_args[i].attribs); | |
486 if(vf) last=vf; | |
487 } | |
488 } | |
489 return last; | |
441 } | 490 } |
442 | 491 |
443 //============================================================================ | 492 //============================================================================ |
444 | 493 |
445 void vf_uninit_filter(vf_instance_t* vf){ | 494 void vf_uninit_filter(vf_instance_t* vf){ |