comparison libmpcodecs/vf_scale.c @ 5565:0b301fec999a

capabilities support -> automatic insertion of scale, expand, pp
author arpi
date Thu, 11 Apr 2002 20:56:17 +0000
parents 04c5047ead0c
children 1972c3475d93
comparison
equal deleted inserted replaced
5564:efe856039f8f 5565:0b301fec999a
30 IMGFMT_I420, 30 IMGFMT_I420,
31 IMGFMT_IYUV, 31 IMGFMT_IYUV,
32 NULL 32 NULL
33 }; 33 };
34 34
35 static int config(struct vf_instance_s* vf, 35 static unsigned int find_best_out(vf_instance_t *vf){
36 int width, int height, int d_width, int d_height, 36 unsigned int best=0;
37 unsigned int flags, unsigned int outfmt){
38 unsigned int* p=outfmt_list; 37 unsigned int* p=outfmt_list;
39 unsigned int best=0;
40
41 // find the best outfmt: 38 // find the best outfmt:
42 while(*p){ 39 while(*p){
43 int ret=vf_next_query_format(vf,*p); 40 int ret=vf_next_query_format(vf,*p);
44 mp_msg(MSGT_VFILTER,MSGL_V,"scale: query(%s) -> %d\n",vo_format_name(*p),ret&3); 41 mp_msg(MSGT_VFILTER,MSGL_V,"scale: query(%s) -> %d\n",vo_format_name(*p),ret&3);
45 if(ret&2){ best=*p; break;} // no conversion -> bingo! 42 if(ret&2){ best=*p; break;} // no conversion -> bingo!
46 if(ret&1 && !best) best=*p; // best with conversion 43 if(ret&1 && !best) best=*p; // best with conversion
47 ++p; 44 ++p;
48 } 45 }
46 return best;
47 }
48
49 static int config(struct vf_instance_s* vf,
50 int width, int height, int d_width, int d_height,
51 unsigned int flags, unsigned int outfmt){
52 unsigned int best=find_best_out(vf);
53 int vo_flags;
54
49 if(!best){ 55 if(!best){
50 printf("SwScale: no supported outfmt found :(\n"); 56 printf("SwScale: no supported outfmt found :(\n");
51 return 0; 57 return 0;
58 }
59
60 vo_flags=vf->next->query_format(vf->next,best);
61
62 // scaling to dwidth*d_height, if all these TRUE:
63 // - option -zoom
64 // - no other sw/hw up/down scaling avail.
65 // - we're after postproc
66 // - user didn't set w:h
67 if(!(vo_flags&VFCAP_POSTPROC) && (flags&4) &&
68 vf->priv->w<0 && vf->priv->h<0){ // -zoom
69 int x=(vo_flags&VFCAP_SWSCALE) ? 0 : 1;
70 if(d_width<width || d_height<height){
71 // downscale!
72 if(vo_flags&VFCAP_HWSCALE_DOWN) x=0;
73 } else {
74 // upscale:
75 if(vo_flags&VFCAP_HWSCALE_UP) x=0;
76 }
77 if(x){
78 // user wants sw scaling! (-zoom)
79 vf->priv->w=d_width;
80 vf->priv->h=d_height;
81 }
52 } 82 }
53 83
54 // calculate the missing parameters: 84 // calculate the missing parameters:
55 if(vf->priv->w<=0) vf->priv->w=width; 85 if(vf->priv->w<=0) vf->priv->w=width;
56 if(vf->priv->h<=0) vf->priv->h=height; 86 if(vf->priv->h<=0) vf->priv->h=height;
108 case IMGFMT_BGR24: 138 case IMGFMT_BGR24:
109 case IMGFMT_BGR16: 139 case IMGFMT_BGR16:
110 case IMGFMT_BGR15: 140 case IMGFMT_BGR15:
111 case IMGFMT_RGB32: 141 case IMGFMT_RGB32:
112 case IMGFMT_RGB24: 142 case IMGFMT_RGB24:
113 case IMGFMT_Y800: 143 case IMGFMT_Y800: {
114 return 3; //vf_next_query_format(vf,fmt); 144 unsigned int best=find_best_out(vf);
145 int flags;
146 if(!best) return 0; // no matching out-fmt
147 flags=vf_next_query_format(vf,best);
148 if(!(flags&3)) return 0; // huh?
149 if(fmt!=best) flags&=~VFCAP_CSP_SUPPORTED_BY_HW;
150 // do not allow scaling, if we are before the PP fliter!
151 if(!(flags&VFCAP_POSTPROC)) flags|=VFCAP_SWSCALE;
152 return flags;
153 }
115 } 154 }
116 return 0; 155 return 0; // nomatching in-fmt
117 } 156 }
118 157
119 static int open(vf_instance_t *vf, char* args){ 158 static int open(vf_instance_t *vf, char* args){
120 vf->config=config; 159 vf->config=config;
121 vf->put_image=put_image; 160 vf->put_image=put_image;