Mercurial > mplayer.hg
comparison libmpcodecs/vf.c @ 32703:84a45d5c1102
Remove tabs from two additional files that will be used in
the libmpcodecs wrapper for libavfilter.
author | cehoyos |
---|---|
date | Sat, 15 Jan 2011 20:40:18 +0000 |
parents | 1a9b4cb4ba01 |
children | b86ea534cfc7 |
comparison
equal
deleted
inserted
replaced
32702:7af3e6f901fd | 32703:84a45d5c1102 |
---|---|
226 // mpi stuff: | 226 // mpi stuff: |
227 | 227 |
228 void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){ | 228 void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){ |
229 int y; | 229 int y; |
230 if(mpi->flags&MP_IMGFLAG_PLANAR){ | 230 if(mpi->flags&MP_IMGFLAG_PLANAR){ |
231 y0&=~1;h+=h&1; | 231 y0&=~1;h+=h&1; |
232 if(x0==0 && w==mpi->width){ | 232 if(x0==0 && w==mpi->width){ |
233 // full width clear: | 233 // full width clear: |
234 memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h); | 234 memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h); |
235 memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift)); | 235 memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift)); |
236 memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift)); | 236 memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift)); |
237 } else | 237 } else |
238 for(y=y0;y<y0+h;y+=2){ | 238 for(y=y0;y<y0+h;y+=2){ |
239 memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w); | 239 memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w); |
240 memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w); | 240 memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w); |
241 memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift)); | 241 memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift)); |
242 memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift)); | 242 memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift)); |
243 } | 243 } |
244 return; | 244 return; |
245 } | 245 } |
246 // packed: | 246 // packed: |
247 for(y=y0;y<y0+h;y++){ | 247 for(y=y0;y<y0+h;y++){ |
248 unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0; | 248 unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0; |
249 if(mpi->flags&MP_IMGFLAG_YUV){ | 249 if(mpi->flags&MP_IMGFLAG_YUV){ |
250 unsigned int* p=(unsigned int*) dst; | 250 unsigned int* p=(unsigned int*) dst; |
251 int size=(mpi->bpp>>3)*w/4; | 251 int size=(mpi->bpp>>3)*w/4; |
252 int i; | 252 int i; |
253 #if HAVE_BIGENDIAN | 253 #if HAVE_BIGENDIAN |
254 #define CLEAR_PACKEDYUV_PATTERN 0x00800080 | 254 #define CLEAR_PACKEDYUV_PATTERN 0x00800080 |
255 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000 | 255 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000 |
256 #else | 256 #else |
257 #define CLEAR_PACKEDYUV_PATTERN 0x80008000 | 257 #define CLEAR_PACKEDYUV_PATTERN 0x80008000 |
258 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080 | 258 #define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080 |
259 #endif | 259 #endif |
260 if(mpi->flags&MP_IMGFLAG_SWAPPED){ | 260 if(mpi->flags&MP_IMGFLAG_SWAPPED){ |
261 for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN_SWAPPED; | 261 for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN_SWAPPED; |
262 for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN_SWAPPED; | 262 for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN_SWAPPED; |
263 } else { | 263 } else { |
264 for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN; | 264 for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN; |
265 for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN; | 265 for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN; |
266 } | 266 } |
267 } else | 267 } else |
268 memset(dst,0,(mpi->bpp>>3)*w); | 268 memset(dst,0,(mpi->bpp>>3)*w); |
269 } | 269 } |
270 } | 270 } |
271 | 271 |
272 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){ | 272 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){ |
273 mp_image_t* mpi=NULL; | 273 mp_image_t* mpi=NULL; |
335 } | 335 } |
336 if(mpi){ | 336 if(mpi){ |
337 mpi->type=mp_imgtype; | 337 mpi->type=mp_imgtype; |
338 mpi->w=vf->w; mpi->h=vf->h; | 338 mpi->w=vf->w; mpi->h=vf->h; |
339 // keep buffer allocation status & color flags only: | 339 // keep buffer allocation status & color flags only: |
340 // mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT); | 340 // mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT); |
341 mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS; | 341 mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS; |
342 // accept restrictions, draw_slice and palette flags only: | 342 // accept restrictions, draw_slice and palette flags only: |
343 mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE); | 343 mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE); |
344 if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; | 344 if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; |
345 if(mpi->width!=w2 || mpi->height!=h){ | 345 if(mpi->width!=w2 || mpi->height!=h){ |
346 // printf("vf.c: MPI parameters changed! %dx%d -> %dx%d \n", mpi->width,mpi->height,w2,h); | 346 // printf("vf.c: MPI parameters changed! %dx%d -> %dx%d \n", mpi->width,mpi->height,w2,h); |
347 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ | 347 if(mpi->flags&MP_IMGFLAG_ALLOCATED){ |
348 if(mpi->width<w2 || mpi->height<h){ | 348 if(mpi->width<w2 || mpi->height<h){ |
349 // need to re-allocate buffer memory: | 349 // need to re-allocate buffer memory: |
350 av_free(mpi->planes[0]); | 350 av_free(mpi->planes[0]); |
351 mpi->flags&=~MP_IMGFLAG_ALLOCATED; | 351 mpi->flags&=~MP_IMGFLAG_ALLOCATED; |
352 mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n"); | 352 mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n"); |
353 } | 353 } |
354 // } else { | 354 // } else { |
355 } { | 355 } { |
356 mpi->width=w2; mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift; | 356 mpi->width=w2; mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift; |
357 mpi->height=h; mpi->chroma_height=(h + (1<<mpi->chroma_y_shift) - 1)>>mpi->chroma_y_shift; | 357 mpi->height=h; mpi->chroma_height=(h + (1<<mpi->chroma_y_shift) - 1)>>mpi->chroma_y_shift; |
358 } | 358 } |
359 } | 359 } |
360 if(!mpi->bpp) mp_image_setfmt(mpi,outfmt); | 360 if(!mpi->bpp) mp_image_setfmt(mpi,outfmt); |
361 if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){ | 361 if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){ |
362 | 362 |
363 // check libvo first! | 363 // check libvo first! |
364 if(vf->get_image) vf->get_image(vf,mpi); | 364 if(vf->get_image) vf->get_image(vf,mpi); |
365 | 365 |
366 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ | 366 if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ |
367 // non-direct and not yet allocated image. allocate it! | 367 // non-direct and not yet allocated image. allocate it! |
368 if (!mpi->bpp) { // no way we can allocate this | 368 if (!mpi->bpp) { // no way we can allocate this |
369 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, | 369 mp_msg(MSGT_DECVIDEO, MSGL_FATAL, |
370 "vf_get_image: Tried to allocate a format that can not be allocated!\n"); | 370 "vf_get_image: Tried to allocate a format that can not be allocated!\n"); |
371 return NULL; | 371 return NULL; |
372 } | 372 } |
373 | 373 |
374 // check if codec prefer aligned stride: | 374 // check if codec prefer aligned stride: |
375 if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){ | 375 if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){ |
376 int align=(mpi->flags&MP_IMGFLAG_PLANAR && | 376 int align=(mpi->flags&MP_IMGFLAG_PLANAR && |
377 mpi->flags&MP_IMGFLAG_YUV) ? | 377 mpi->flags&MP_IMGFLAG_YUV) ? |
378 (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME | 378 (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME |
379 w2=((w+align)&(~align)); | 379 w2=((w+align)&(~align)); |
380 if(mpi->width!=w2){ | 380 if(mpi->width!=w2){ |
381 // we have to change width... check if we CAN co it: | 381 // we have to change width... check if we CAN co it: |
382 int flags=vf->query_format(vf,outfmt); // should not fail | 382 int flags=vf->query_format(vf,outfmt); // should not fail |
383 if(!(flags&3)) mp_msg(MSGT_DECVIDEO,MSGL_WARN,"??? vf_get_image{vf->query_format(outfmt)} failed!\n"); | 383 if(!(flags&3)) mp_msg(MSGT_DECVIDEO,MSGL_WARN,"??? vf_get_image{vf->query_format(outfmt)} failed!\n"); |
384 // printf("query -> 0x%X \n",flags); | 384 // printf("query -> 0x%X \n",flags); |
385 if(flags&VFCAP_ACCEPT_STRIDE){ | 385 if(flags&VFCAP_ACCEPT_STRIDE){ |
386 mpi->width=w2; | 386 mpi->width=w2; |
387 mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift; | 387 mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift; |
388 } | 388 } |
389 } | 389 } |
390 } | 390 } |
391 | 391 |
392 mp_image_alloc_planes(mpi); | 392 mp_image_alloc_planes(mpi); |
393 // printf("clearing img!\n"); | 393 // printf("clearing img!\n"); |
394 vf_mpi_clear(mpi,0,0,mpi->width,mpi->height); | 394 vf_mpi_clear(mpi,0,0,mpi->width,mpi->height); |
395 } | 395 } |
396 } | 396 } |
397 if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) | 397 if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK) |
398 if(vf->start_slice) vf->start_slice(vf,mpi); | 398 if(vf->start_slice) vf->start_slice(vf,mpi); |
399 if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){ | 399 if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){ |
400 mp_msg(MSGT_DECVIDEO,MSGL_V,"*** [%s] %s%s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n", | 400 mp_msg(MSGT_DECVIDEO,MSGL_V,"*** [%s] %s%s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n", |
401 vf->info->name, | 401 vf->info->name, |
402 (mpi->type==MP_IMGTYPE_EXPORT)?"Exporting": | 402 (mpi->type==MP_IMGTYPE_EXPORT)?"Exporting": |
403 ((mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating"), | 403 ((mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating"), |
404 (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)?" (slices)":"", | 404 (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)?" (slices)":"", |
405 mpi->width,mpi->height,mpi->bpp, | 405 mpi->width,mpi->height,mpi->bpp, |
406 (mpi->flags&MP_IMGFLAG_YUV)?"YUV":((mpi->flags&MP_IMGFLAG_SWAPPED)?"BGR":"RGB"), | 406 (mpi->flags&MP_IMGFLAG_YUV)?"YUV":((mpi->flags&MP_IMGFLAG_SWAPPED)?"BGR":"RGB"), |
407 (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", | 407 (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", |
408 mpi->bpp*mpi->width*mpi->height/8); | 408 mpi->bpp*mpi->width*mpi->height/8); |
409 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %p,%p,%p strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n", | 409 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %p,%p,%p strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n", |
410 mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2], | 410 mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2], |
411 mpi->stride[0], mpi->stride[1], mpi->stride[2], | 411 mpi->stride[0], mpi->stride[1], mpi->stride[2], |
412 mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift); | 412 mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift); |
413 mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED; | 413 mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED; |
414 } | 414 } |
415 | 415 |
416 mpi->qscale = NULL; | 416 mpi->qscale = NULL; |
417 } | 417 } |
418 mpi->usage_count++; | 418 mpi->usage_count++; |
419 // printf("\rVF_MPI: %p %p %p %d %d %d \n", | 419 // printf("\rVF_MPI: %p %p %p %d %d %d \n", |
420 // mpi->planes[0],mpi->planes[1],mpi->planes[2], | 420 // mpi->planes[0],mpi->planes[1],mpi->planes[2], |
421 // mpi->stride[0],mpi->stride[1],mpi->stride[2]); | 421 // mpi->stride[0],mpi->stride[1],mpi->stride[2]); |
422 return mpi; | 422 return mpi; |
423 } | 423 } |
424 | 424 |
425 //============================================================================ | 425 //============================================================================ |
426 | 426 |
432 | 432 |
433 vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){ | 433 vf_instance_t* vf_open_plugin(const vf_info_t* const* filter_list, vf_instance_t* next, const char *name, char **args){ |
434 vf_instance_t* vf; | 434 vf_instance_t* vf; |
435 int i; | 435 int i; |
436 for(i=0;;i++){ | 436 for(i=0;;i++){ |
437 if(!filter_list[i]){ | 437 if(!filter_list[i]){ |
438 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name); | 438 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotFindVideoFilter,name); |
439 return NULL; // no such filter! | 439 return NULL; // no such filter! |
440 } | 440 } |
441 if(!strcmp(filter_list[i]->name,name)) break; | 441 if(!strcmp(filter_list[i]->name,name)) break; |
442 } | 442 } |
443 vf=malloc(sizeof(vf_instance_t)); | 443 vf=malloc(sizeof(vf_instance_t)); |
444 memset(vf,0,sizeof(vf_instance_t)); | 444 memset(vf,0,sizeof(vf_instance_t)); |
445 vf->info=filter_list[i]; | 445 vf->info=filter_list[i]; |
446 vf->next=next; | 446 vf->next=next; |
453 if(vf->info->opts) { // vf_vo get some special argument | 453 if(vf->info->opts) { // vf_vo get some special argument |
454 const m_struct_t* st = vf->info->opts; | 454 const m_struct_t* st = vf->info->opts; |
455 void* vf_priv = m_struct_alloc(st); | 455 void* vf_priv = m_struct_alloc(st); |
456 int n; | 456 int n; |
457 for(n = 0 ; args && args[2*n] ; n++) | 457 for(n = 0 ; args && args[2*n] ; n++) |
458 m_struct_set(st,vf_priv,args[2*n],args[2*n+1]); | 458 m_struct_set(st,vf_priv,args[2*n],args[2*n+1]); |
459 vf->priv = vf_priv; | 459 vf->priv = vf_priv; |
460 args = NULL; | 460 args = NULL; |
461 } else // Otherwise we should have the '_oldargs_' | 461 } else // Otherwise we should have the '_oldargs_' |
462 if(args && !strcmp(args[0],"_oldargs_")) | 462 if(args && !strcmp(args[0],"_oldargs_")) |
463 args = (char**)args[1]; | 463 args = (char**)args[1]; |
464 else | 464 else |
465 args = NULL; | 465 args = NULL; |
466 if(vf->info->vf_open(vf,(char*)args)>0) return vf; // Success! | 466 if(vf->info->vf_open(vf,(char*)args)>0) return vf; // Success! |
467 free(vf); | 467 free(vf); |
468 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name); | 468 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CouldNotOpenVideoFilter,name); |
469 return NULL; | 469 return NULL; |
470 } | 470 } |
478 { | 478 { |
479 char str[l+1]; | 479 char str[l+1]; |
480 char* p = str; | 480 char* p = str; |
481 p += sprintf(str,"%s",name); | 481 p += sprintf(str,"%s",name); |
482 for(i = 0 ; args && args[2*i] ; i++) | 482 for(i = 0 ; args && args[2*i] ; i++) |
483 p += sprintf(p," %s=%s",args[2*i],args[2*i+1]); | 483 p += sprintf(p," %s=%s",args[2*i],args[2*i+1]); |
484 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str); | 484 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter "[%s]\n",str); |
485 } | 485 } |
486 } else if(strcmp(name,"vo")) { | 486 } else if(strcmp(name,"vo")) { |
487 if(args && strcmp(args[0],"_oldargs_") == 0) | 487 if(args && strcmp(args[0],"_oldargs_") == 0) |
488 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter | 488 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter |
489 "[%s=%s]\n", name,args[1]); | 489 "[%s=%s]\n", name,args[1]); |
490 else | 490 else |
491 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter | 491 mp_msg(MSGT_VFILTER,MSGL_INFO,MSGTR_OpeningVideoFilter |
492 "[%s]\n", name); | 492 "[%s]\n", name); |
493 } | 493 } |
494 return vf_open_plugin(filter_list,next,name,args); | 494 return vf_open_plugin(filter_list,next,name,args); |
495 } | 495 } |
496 | 496 |
497 /** | 497 /** |
520 vf_instance_t* vf=*vfp; | 520 vf_instance_t* vf=*vfp; |
521 const unsigned int* p; | 521 const unsigned int* p; |
522 unsigned int best=0; | 522 unsigned int best=0; |
523 int ret; | 523 int ret; |
524 if((p=list)) while(*p){ | 524 if((p=list)) while(*p){ |
525 ret=vf->query_format(vf,*p); | 525 ret=vf->query_format(vf,*p); |
526 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); | 526 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); |
527 if(ret&2){ best=*p; break;} // no conversion -> bingo! | 527 if(ret&2){ best=*p; break;} // no conversion -> bingo! |
528 if(ret&1 && !best) best=*p; // best with conversion | 528 if(ret&1 && !best) best=*p; // best with conversion |
529 ++p; | 529 ++p; |
530 } | 530 } |
531 if(best) return best; // bingo, they have common csp! | 531 if(best) return best; // bingo, they have common csp! |
532 // ok, then try with scale: | 532 // ok, then try with scale: |
533 if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion! | 533 if(vf->info == &vf_info_scale) return 0; // avoid infinite recursion! |
534 vf=vf_open_filter(vf,"scale",NULL); | 534 vf=vf_open_filter(vf,"scale",NULL); |
535 if(!vf) return 0; // failed to init "scale" | 535 if(!vf) return 0; // failed to init "scale" |
536 // try the preferred csp first: | 536 // try the preferred csp first: |
537 if(preferred && vf->query_format(vf,preferred)) best=preferred; else | 537 if(preferred && vf->query_format(vf,preferred)) best=preferred; else |
538 // try the list again, now with "scaler" : | 538 // try the list again, now with "scaler" : |
539 if((p=list)) while(*p){ | 539 if((p=list)) while(*p){ |
540 ret=vf->query_format(vf,*p); | 540 ret=vf->query_format(vf,*p); |
541 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); | 541 mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3); |
542 if(ret&2){ best=*p; break;} // no conversion -> bingo! | 542 if(ret&2){ best=*p; break;} // no conversion -> bingo! |
543 if(ret&1 && !best) best=*p; // best with conversion | 543 if(ret&1 && !best) best=*p; // best with conversion |
544 ++p; | 544 ++p; |
545 } | 545 } |
546 if(best) *vfp=vf; // else uninit vf !FIXME! | 546 if(best) *vfp=vf; // else uninit vf !FIXME! |
547 return best; | 547 return best; |
548 } | 548 } |
549 | 549 |
550 void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src){ | 550 void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src){ |
551 dst->pict_type= src->pict_type; | 551 dst->pict_type= src->pict_type; |
552 dst->fields = src->fields; | 552 dst->fields = src->fields; |
553 dst->qscale_type= src->qscale_type; | 553 dst->qscale_type= src->qscale_type; |
554 if(dst->width == src->width && dst->height == src->height){ | 554 if(dst->width == src->width && dst->height == src->height){ |
555 dst->qstride= src->qstride; | 555 dst->qstride= src->qstride; |
556 dst->qscale= src->qscale; | 556 dst->qscale= src->qscale; |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 void vf_queue_frame(vf_instance_t *vf, int (*func)(vf_instance_t *)) | 560 void vf_queue_frame(vf_instance_t *vf, int (*func)(vf_instance_t *)) |
561 { | 561 { |
568 // that could be stored so this was easier to implement. | 568 // that could be stored so this was easier to implement. |
569 | 569 |
570 int vf_output_queued_frame(vf_instance_t *vf) | 570 int vf_output_queued_frame(vf_instance_t *vf) |
571 { | 571 { |
572 while (1) { | 572 while (1) { |
573 int ret; | 573 int ret; |
574 vf_instance_t *current; | 574 vf_instance_t *current; |
575 vf_instance_t *last=NULL; | 575 vf_instance_t *last=NULL; |
576 int (*tmp)(vf_instance_t *); | 576 int (*tmp)(vf_instance_t *); |
577 for (current = vf; current; current = current->next) | 577 for (current = vf; current; current = current->next) |
578 if (current->continue_buffered_image) | 578 if (current->continue_buffered_image) |
579 last = current; | 579 last = current; |
580 if (!last) | 580 if (!last) |
581 return 0; | 581 return 0; |
582 tmp = last->continue_buffered_image; | 582 tmp = last->continue_buffered_image; |
583 last->continue_buffered_image = NULL; | 583 last->continue_buffered_image = NULL; |
584 ret = tmp(last); | 584 ret = tmp(last); |
585 if (ret > 0) { | 585 if (ret > 0) { |
586 vf->control(vf, VFCTRL_DRAW_OSD, NULL); | 586 vf->control(vf, VFCTRL_DRAW_OSD, NULL); |
587 #ifdef CONFIG_ASS | 587 #ifdef CONFIG_ASS |
588 vf->control(vf, VFCTRL_DRAW_EOSD, NULL); | 588 vf->control(vf, VFCTRL_DRAW_EOSD, NULL); |
589 #endif | 589 #endif |
590 } | 590 } |
591 if (ret) | 591 if (ret) |
592 return ret; | 592 return ret; |
593 } | 593 } |
594 } | 594 } |
595 | 595 |
596 | 596 |
597 /** | 597 /** |
605 * In following calls, it verifies that the configuration parameters | 605 * In following calls, it verifies that the configuration parameters |
606 * are unchanged, and returns either success or error. | 606 * are unchanged, and returns either success or error. |
607 * | 607 * |
608 */ | 608 */ |
609 int vf_config_wrapper(struct vf_instance *vf, | 609 int vf_config_wrapper(struct vf_instance *vf, |
610 int width, int height, int d_width, int d_height, | 610 int width, int height, int d_width, int d_height, |
611 unsigned int flags, unsigned int outfmt) | 611 unsigned int flags, unsigned int outfmt) |
612 { | 612 { |
613 int r; | 613 int r; |
614 if ((vf->default_caps&VFCAP_CONSTANT) && vf->fmt.have_configured) { | 614 if ((vf->default_caps&VFCAP_CONSTANT) && vf->fmt.have_configured) { |
615 if ((vf->fmt.orig_width != width) | 615 if ((vf->fmt.orig_width != width) |
616 || (vf->fmt.orig_height != height) | 616 || (vf->fmt.orig_height != height) |
617 || (vf->fmt.orig_fmt != outfmt)) { | 617 || (vf->fmt.orig_fmt != outfmt)) { |
618 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_ResolutionDoesntMatch); | 618 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_ResolutionDoesntMatch); |
619 return 0; | 619 return 0; |
620 } | 620 } |
621 return 1; | 621 return 1; |
622 } | 622 } |
629 return r; | 629 return r; |
630 } | 630 } |
631 | 631 |
632 int vf_next_config(struct vf_instance *vf, | 632 int vf_next_config(struct vf_instance *vf, |
633 int width, int height, int d_width, int d_height, | 633 int width, int height, int d_width, int d_height, |
634 unsigned int voflags, unsigned int outfmt){ | 634 unsigned int voflags, unsigned int outfmt){ |
635 int miss; | 635 int miss; |
636 int flags=vf->next->query_format(vf->next,outfmt); | 636 int flags=vf->next->query_format(vf->next,outfmt); |
637 if(!flags){ | 637 if(!flags){ |
638 // hmm. colorspace mismatch!!! | 638 // hmm. colorspace mismatch!!! |
639 // let's insert the 'scale' filter, it does the job for us: | 639 // let's insert the 'scale' filter, it does the job for us: |
640 vf_instance_t* vf2; | 640 vf_instance_t* vf2; |
641 if(vf->next->info==&vf_info_scale) return 0; // scale->scale | 641 if(vf->next->info==&vf_info_scale) return 0; // scale->scale |
642 vf2=vf_open_filter(vf->next,"scale",NULL); | 642 vf2=vf_open_filter(vf->next,"scale",NULL); |
643 if(!vf2) return 0; // shouldn't happen! | 643 if(!vf2) return 0; // shouldn't happen! |
644 vf->next=vf2; | 644 vf->next=vf2; |
645 flags=vf->next->query_format(vf->next,outfmt); | 645 flags=vf->next->query_format(vf->next,outfmt); |
646 if(!flags){ | 646 if(!flags){ |
647 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CannotFindColorspace); | 647 mp_msg(MSGT_VFILTER,MSGL_ERR,MSGTR_CannotFindColorspace); |
648 return 0; // FAIL | 648 return 0; // FAIL |
649 } | 649 } |
650 } | 650 } |
651 mp_msg(MSGT_VFILTER,MSGL_V,"REQ: flags=0x%X req=0x%X \n",flags,vf->default_reqs); | 651 mp_msg(MSGT_VFILTER,MSGL_V,"REQ: flags=0x%X req=0x%X \n",flags,vf->default_reqs); |
652 miss=vf->default_reqs - (flags&vf->default_reqs); | 652 miss=vf->default_reqs - (flags&vf->default_reqs); |
653 if(miss&VFCAP_ACCEPT_STRIDE){ | 653 if(miss&VFCAP_ACCEPT_STRIDE){ |
654 // vf requires stride support but vf->next doesn't support it! | 654 // vf requires stride support but vf->next doesn't support it! |
655 // let's insert the 'expand' filter, it does the job for us: | 655 // let's insert the 'expand' filter, it does the job for us: |
656 vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL); | 656 vf_instance_t* vf2=vf_open_filter(vf->next,"expand",NULL); |
657 if(!vf2) return 0; // shouldn't happen! | 657 if(!vf2) return 0; // shouldn't happen! |
658 vf->next=vf2; | 658 vf->next=vf2; |
659 } | 659 } |
660 vf->next->w = width; vf->next->h = height; | 660 vf->next->w = width; vf->next->h = height; |
661 return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt); | 661 return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt); |
662 } | 662 } |
663 | 663 |
683 return vf->next->put_image(vf->next,mpi, pts); | 683 return vf->next->put_image(vf->next,mpi, pts); |
684 } | 684 } |
685 | 685 |
686 void vf_next_draw_slice(struct vf_instance *vf,unsigned char** src, int * stride,int w, int h, int x, int y){ | 686 void vf_next_draw_slice(struct vf_instance *vf,unsigned char** src, int * stride,int w, int h, int x, int y){ |
687 if (vf->next->draw_slice) { | 687 if (vf->next->draw_slice) { |
688 vf->next->draw_slice(vf->next,src,stride,w,h,x,y); | 688 vf->next->draw_slice(vf->next,src,stride,w,h,x,y); |
689 return; | 689 return; |
690 } | 690 } |
691 if (!vf->dmpi) { | 691 if (!vf->dmpi) { |
692 mp_msg(MSGT_VFILTER,MSGL_ERR,"draw_slice: dmpi not stored by vf_%s\n", vf->info->name); | 692 mp_msg(MSGT_VFILTER,MSGL_ERR,"draw_slice: dmpi not stored by vf_%s\n", vf->info->name); |
693 return; | 693 return; |
694 } | 694 } |
695 if (!(vf->dmpi->flags & MP_IMGFLAG_PLANAR)) { | 695 if (!(vf->dmpi->flags & MP_IMGFLAG_PLANAR)) { |
696 memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+vf->dmpi->bpp/8*x, | 696 memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+vf->dmpi->bpp/8*x, |
697 src[0], vf->dmpi->bpp/8*w, h, vf->dmpi->stride[0], stride[0]); | 697 src[0], vf->dmpi->bpp/8*w, h, vf->dmpi->stride[0], stride[0]); |
698 return; | 698 return; |
699 } | 699 } |
700 memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+x, src[0], | 700 memcpy_pic(vf->dmpi->planes[0]+y*vf->dmpi->stride[0]+x, src[0], |
701 w, h, vf->dmpi->stride[0], stride[0]); | 701 w, h, vf->dmpi->stride[0], stride[0]); |
702 memcpy_pic(vf->dmpi->planes[1]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]+(x>>vf->dmpi->chroma_x_shift), | 702 memcpy_pic(vf->dmpi->planes[1]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1]+(x>>vf->dmpi->chroma_x_shift), |
703 src[1], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[1], stride[1]); | 703 src[1], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[1], stride[1]); |
704 memcpy_pic(vf->dmpi->planes[2]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]+(x>>vf->dmpi->chroma_x_shift), | 704 memcpy_pic(vf->dmpi->planes[2]+(y>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2]+(x>>vf->dmpi->chroma_x_shift), |
705 src[2], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[2], stride[2]); | 705 src[2], w>>vf->dmpi->chroma_x_shift, h>>vf->dmpi->chroma_y_shift, vf->dmpi->stride[2], stride[2]); |
706 } | 706 } |
707 | 707 |
708 //============================================================================ | 708 //============================================================================ |
709 | 709 |
710 vf_instance_t* append_filters(vf_instance_t* last){ | 710 vf_instance_t* append_filters(vf_instance_t* last){ |
735 free(vf); | 735 free(vf); |
736 } | 736 } |
737 | 737 |
738 void vf_uninit_filter_chain(vf_instance_t* vf){ | 738 void vf_uninit_filter_chain(vf_instance_t* vf){ |
739 while(vf){ | 739 while(vf){ |
740 vf_instance_t* next=vf->next; | 740 vf_instance_t* next=vf->next; |
741 vf_uninit_filter(vf); | 741 vf_uninit_filter(vf); |
742 vf=next; | 742 vf=next; |
743 } | 743 } |
744 } | 744 } |