comparison libmpcodecs/vf_expand.c @ 9495:2837f8da12c4

experimental slices support
author arpi
date Sun, 23 Feb 2003 23:30:44 +0000
parents 12741a866acd
children c9012dcd3a70
comparison
equal deleted inserted replaced
9494:543ab3909b78 9495:2837f8da12c4
193 } 193 }
194 #endif 194 #endif
195 if(vf->priv->exp_w==mpi->width || 195 if(vf->priv->exp_w==mpi->width ||
196 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)) ){ 196 (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)) ){
197 // try full DR ! 197 // try full DR !
198 vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt, 198 mpi->priv=vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
199 mpi->type, mpi->flags, 199 mpi->type, mpi->flags,
200 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x), 200 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
201 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y)); 201 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
202 #if 1
203 if((vf->priv->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&
204 !(vf->priv->dmpi->flags & MP_IMGFLAG_DIRECT)){
205 printf("Full DR not possible, trying SLICES instead!\n");
206 return;
207 }
208 #endif
202 // set up mpi as a cropped-down image of dmpi: 209 // set up mpi as a cropped-down image of dmpi:
203 if(mpi->flags&MP_IMGFLAG_PLANAR){ 210 if(mpi->flags&MP_IMGFLAG_PLANAR){
204 mpi->planes[0]=vf->priv->dmpi->planes[0]+ 211 mpi->planes[0]=vf->priv->dmpi->planes[0]+
205 vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x; 212 vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x;
206 mpi->planes[1]=vf->priv->dmpi->planes[1]+ 213 mpi->planes[1]=vf->priv->dmpi->planes[1]+
215 vf->priv->exp_x*(vf->priv->dmpi->bpp/8); 222 vf->priv->exp_x*(vf->priv->dmpi->bpp/8);
216 } 223 }
217 mpi->stride[0]=vf->priv->dmpi->stride[0]; 224 mpi->stride[0]=vf->priv->dmpi->stride[0];
218 mpi->width=vf->priv->dmpi->width; 225 mpi->width=vf->priv->dmpi->width;
219 mpi->flags|=MP_IMGFLAG_DIRECT; 226 mpi->flags|=MP_IMGFLAG_DIRECT;
220 mpi->priv=(void*)vf->priv->dmpi; 227 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
221 } 228 // vf->priv->dmpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
229 }
230 }
231
232 static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
233 // printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);
234 if(!vf->next->draw_slice){
235 mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
236 return;
237 }
238 // they want slices!!! allocate the buffer.
239 if(!mpi->priv)
240 mpi->priv=vf->priv->dmpi=vf_get_image(vf->next,mpi->imgfmt,
241 // MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
242 mpi->type, mpi->flags,
243 MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
244 MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
245 if(!(vf->priv->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK))
246 printf("WARNING! next filter doesn't support SLICES, get ready for sig11...\n"); // shouldn't happen.
247 }
248
249 static void draw_slice(struct vf_instance_s* vf,
250 unsigned char** src, int* stride, int w,int h, int x, int y){
251 // printf("draw_slice() called %d at %d\n",h,y);
252 vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);
222 } 253 }
223 254
224 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ 255 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
225 if(mpi->flags&MP_IMGFLAG_DIRECT){ 256 if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){
226 vf->priv->dmpi=mpi->priv; 257 vf->priv->dmpi=mpi->priv;
258 mpi->priv=NULL;
227 #ifdef OSD_SUPPORT 259 #ifdef OSD_SUPPORT
228 if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h); 260 if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);
229 #endif 261 #endif
230 // we've used DR, so we're ready... 262 // we've used DR, so we're ready...
231 if(!(mpi->flags&MP_IMGFLAG_PLANAR)) 263 if(!(mpi->flags&MP_IMGFLAG_PLANAR))
278 } 310 }
279 311
280 static int open(vf_instance_t *vf, char* args){ 312 static int open(vf_instance_t *vf, char* args){
281 vf->config=config; 313 vf->config=config;
282 vf->control=control; 314 vf->control=control;
315 vf->start_slice=start_slice;
316 vf->draw_slice=draw_slice;
283 vf->get_image=get_image; 317 vf->get_image=get_image;
284 vf->put_image=put_image; 318 vf->put_image=put_image;
285 vf->priv=malloc(sizeof(struct vf_priv_s)); 319 vf->priv=malloc(sizeof(struct vf_priv_s));
286 vf->priv->exp_x= 320 vf->priv->exp_x=
287 vf->priv->exp_y= 321 vf->priv->exp_y=