vf.c

来自「君正早期ucos系统(只有早期的才不没有打包成库),MPLAYER,文件系统,图」· C语言 代码 · 共 744 行 · 第 1/2 页

C
744
字号
#include <uclib.h>#include <uclib.h>#include <uclib.h>#include "config.h"#ifdef HAVE_MALLOC_H#include <uclib.h>#endif#ifdef MP_DEBUG#include <assert.h>#endif#include "mp_msg.h"#include "help_mp.h"#include "m_option.h"#include "m_struct.h"#include "img_format.h"#include "mp_image.h"#include "vf.h"#include "libvo/fastmemcpy.h"#ifdef JZ4740_IPU//#define memalign  jz4740_alloc_frame#endif#ifdef USE_16M_SDRAMextern vf_info_t vf_info_scale;extern vf_info_t vf_info_vo;#elseextern vf_info_t vf_info_vo;extern vf_info_t vf_info_rectangle;extern vf_info_t vf_info_bmovl;extern vf_info_t vf_info_crop;extern vf_info_t vf_info_expand;extern vf_info_t vf_info_pp;extern vf_info_t vf_info_scale;extern vf_info_t vf_info_format;extern vf_info_t vf_info_noformat;extern vf_info_t vf_info_yuy2;extern vf_info_t vf_info_flip;extern vf_info_t vf_info_rgb2bgr;extern vf_info_t vf_info_rotate;extern vf_info_t vf_info_mirror;extern vf_info_t vf_info_palette;extern vf_info_t vf_info_lavc;extern vf_info_t vf_info_zrmjpeg;extern vf_info_t vf_info_dvbscale;extern vf_info_t vf_info_cropdetect;extern vf_info_t vf_info_test;extern vf_info_t vf_info_noise;extern vf_info_t vf_info_yvu9;extern vf_info_t vf_info_lavcdeint;extern vf_info_t vf_info_eq;extern vf_info_t vf_info_eq2;extern vf_info_t vf_info_halfpack;extern vf_info_t vf_info_dint;extern vf_info_t vf_info_1bpp;extern vf_info_t vf_info_2xsai;extern vf_info_t vf_info_unsharp;extern vf_info_t vf_info_swapuv;extern vf_info_t vf_info_il;extern vf_info_t vf_info_fil;extern vf_info_t vf_info_boxblur;extern vf_info_t vf_info_sab;extern vf_info_t vf_info_smartblur;extern vf_info_t vf_info_perspective;extern vf_info_t vf_info_down3dright;extern vf_info_t vf_info_field;extern vf_info_t vf_info_denoise3d;extern vf_info_t vf_info_hqdn3d;extern vf_info_t vf_info_detc;extern vf_info_t vf_info_telecine;extern vf_info_t vf_info_tinterlace;extern vf_info_t vf_info_tfields;extern vf_info_t vf_info_ivtc;extern vf_info_t vf_info_ilpack;extern vf_info_t vf_info_dsize;extern vf_info_t vf_info_decimate;extern vf_info_t vf_info_softpulldown;extern vf_info_t vf_info_pullup;extern vf_info_t vf_info_filmdint;extern vf_info_t vf_info_framestep;extern vf_info_t vf_info_tile;extern vf_info_t vf_info_delogo;extern vf_info_t vf_info_remove_logo;extern vf_info_t vf_info_hue;extern vf_info_t vf_info_spp;extern vf_info_t vf_info_uspp;extern vf_info_t vf_info_fspp;extern vf_info_t vf_info_pp7;extern vf_info_t vf_info_yuvcsp;extern vf_info_t vf_info_kerndeint;extern vf_info_t vf_info_rgbtest;extern vf_info_t vf_info_qp;extern vf_info_t vf_info_phase;extern vf_info_t vf_info_divtc;extern vf_info_t vf_info_harddup;extern vf_info_t vf_info_softskip;extern vf_info_t vf_info_screenshot;extern vf_info_t vf_info_ass;extern vf_info_t vf_info_mcdeint;extern vf_info_t vf_info_yadif;extern vf_info_t vf_info_blackframe;extern vf_info_t vf_info_geq;extern vf_info_t vf_info_ow;#endif// list of available filters:static vf_info_t* filter_list[]={#ifdef USE_16M_SDRAM    &vf_info_scale,    &vf_info_vo,#else    &vf_info_rectangle,#ifdef HAVE_POSIX_SELECT    &vf_info_bmovl,#endif    &vf_info_crop,    &vf_info_expand,#ifdef USE_LIBPOSTPROC    &vf_info_pp,#endif    &vf_info_scale,//    &vf_info_osd,    &vf_info_vo,    &vf_info_format,    &vf_info_noformat,    &vf_info_yuy2,    &vf_info_flip,    &vf_info_rgb2bgr,    &vf_info_rotate,    &vf_info_mirror,    &vf_info_palette,#ifdef USE_LIBAVCODEC    &vf_info_lavc,    &vf_info_lavcdeint,    &vf_info_pp7,#endif#ifdef HAVE_ZR    &vf_info_zrmjpeg,#endif    &vf_info_dvbscale,    &vf_info_cropdetect,    &vf_info_test,    &vf_info_noise,    &vf_info_yvu9,    &vf_info_eq,    &vf_info_eq2,    &vf_info_halfpack,    &vf_info_dint,    &vf_info_1bpp,    &vf_info_2xsai,    &vf_info_unsharp,    &vf_info_swapuv,    &vf_info_il,    &vf_info_fil,    &vf_info_boxblur,    &vf_info_sab,    &vf_info_smartblur,    &vf_info_perspective,    &vf_info_down3dright,    &vf_info_field,    &vf_info_denoise3d,    &vf_info_hqdn3d,    &vf_info_detc,    &vf_info_telecine,    &vf_info_tinterlace,    &vf_info_tfields,    &vf_info_ivtc,    &vf_info_ilpack,    &vf_info_dsize,    &vf_info_decimate,    &vf_info_softpulldown,    &vf_info_pullup,    &vf_info_filmdint,    &vf_info_framestep,    &vf_info_tile,    &vf_info_delogo,    &vf_info_remove_logo,    &vf_info_hue,#ifdef USE_LIBAVCODEC_A    &vf_info_spp,    &vf_info_uspp,    &vf_info_fspp,    &vf_info_qp,    &vf_info_mcdeint,    &vf_info_geq,#endif    &vf_info_yuvcsp,    &vf_info_kerndeint,    &vf_info_rgbtest,    &vf_info_phase,    &vf_info_divtc,    &vf_info_harddup,    &vf_info_softskip,#ifdef HAVE_PNG    &vf_info_screenshot,#endif#ifdef USE_ASS    &vf_info_ass,#endif    &vf_info_yadif,    &vf_info_blackframe,    &vf_info_ow,#endif    NULL};// For the vf optionm_obj_settings_t* vf_settings = NULL;m_obj_list_t vf_obj_list = {  (void**)filter_list,  M_ST_OFF(vf_info_t,name),  M_ST_OFF(vf_info_t,info),  M_ST_OFF(vf_info_t,opts)};//============================================================================// mpi stuff:void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){    int y;    if(mpi->flags&MP_IMGFLAG_PLANAR){	y0&=~1;h+=h&1;	if(x0==0 && w==mpi->width){	    // full width clear:	    memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h);	    memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift));	    memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift));	} else	for(y=y0;y<y0+h;y+=2){	    memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w);	    memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w);	    memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));	    memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift));	}	return;    }    // packed:    for(y=y0;y<y0+h;y++){	unsigned char* dst=mpi->planes[0]+mpi->stride[0]*y+(mpi->bpp>>3)*x0;	if(mpi->flags&MP_IMGFLAG_YUV){	    unsigned int* p=(unsigned int*) dst;	    int size=(mpi->bpp>>3)*w/4;	    int i;#ifdef WORDS_BIGENDIAN#define CLEAR_PACKEDYUV_PATTERN 0x00800080#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x80008000#else#define CLEAR_PACKEDYUV_PATTERN 0x80008000#define CLEAR_PACKEDYUV_PATTERN_SWAPPED 0x00800080#endif	    if(mpi->flags&MP_IMGFLAG_SWAPPED){	        for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;		for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN_SWAPPED;	    } else {	        for(i=0;i<size-3;i+=4) p[i]=p[i+1]=p[i+2]=p[i+3]=CLEAR_PACKEDYUV_PATTERN;		for(;i<size;i++) p[i]=CLEAR_PACKEDYUV_PATTERN;	    }	} else	    memset(dst,0,(mpi->bpp>>3)*w);    }}mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){  mp_image_t* mpi=NULL;  int w2;#ifdef MP_DEBUG  assert(w == -1 || w >= vf->w);  assert(h == -1 || h >= vf->h);  assert(vf->w > 0);  assert(vf->h > 0);#endif//  fprintf(stderr, "get_image: %d:%d, vf: %d:%d\n", w,h,vf->w,vf->h);  if (w == -1) w = vf->w;  if (h == -1) h = vf->h;  w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w;    if(vf->put_image==vf_next_put_image){      // passthru mode, if the filter uses the fallback/default put_image() code      return vf_get_image(vf->next,outfmt,mp_imgtype,mp_imgflag,w,h);  }    // Note: we should call libvo first to check if it supports direct rendering  // and if not, then fallback to software buffers:  switch(mp_imgtype){  case MP_IMGTYPE_EXPORT:    if(!vf->imgctx.export_images[0]) vf->imgctx.export_images[0]=new_mp_image(w2,h);    mpi=vf->imgctx.export_images[0];    break;  case MP_IMGTYPE_STATIC:    if(!vf->imgctx.static_images[0]) vf->imgctx.static_images[0]=new_mp_image(w2,h);    mpi=vf->imgctx.static_images[0];    break;  case MP_IMGTYPE_TEMP:    if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);    mpi=vf->imgctx.temp_images[0];    break;  case MP_IMGTYPE_IPB:    if(!(mp_imgflag&MP_IMGFLAG_READABLE)){ // B frame:      if(!vf->imgctx.temp_images[0]) vf->imgctx.temp_images[0]=new_mp_image(w2,h);      mpi=vf->imgctx.temp_images[0];      break;    }  case MP_IMGTYPE_IP:    if(!vf->imgctx.static_images[vf->imgctx.static_idx]) vf->imgctx.static_images[vf->imgctx.static_idx]=new_mp_image(w2,h);    mpi=vf->imgctx.static_images[vf->imgctx.static_idx];    vf->imgctx.static_idx^=1;    break;  }  if(mpi){    mpi->type=mp_imgtype;    mpi->w=vf->w; mpi->h=vf->h;    // keep buffer allocation status & color flags only://    mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);    mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;    // accept restrictions & draw_slice flags only:    mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK);    if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;    if(mpi->width!=w2 || mpi->height!=h){//	printf("vf.c: MPI parameters changed!  %dx%d -> %dx%d   \n", mpi->width,mpi->height,w2,h);	if(mpi->flags&MP_IMGFLAG_ALLOCATED){	    if(mpi->width<w2 || mpi->height<h){		// need to re-allocate buffer memory:		free(mpi->planes[0]);		mpi->flags&=~MP_IMGFLAG_ALLOCATED;		mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");	    }//	} else {	} {	    mpi->width=w2; mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;	    mpi->height=h; mpi->chroma_height=(h + (1<<mpi->chroma_y_shift) - 1)>>mpi->chroma_y_shift;	}    }    if(!mpi->bpp) mp_image_setfmt(mpi,outfmt);    if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){	// check libvo first!	if(vf->get_image) vf->get_image(vf,mpi);	        if(!(mpi->flags&MP_IMGFLAG_DIRECT)){          // non-direct and not yet allocated image. allocate it!	  	  // check if codec prefer aligned stride:  	  if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){	      int align=(mpi->flags&MP_IMGFLAG_PLANAR &&	                 mpi->flags&MP_IMGFLAG_YUV) ?			 (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME	      w2=((w+align)&(~align));	      if(mpi->width!=w2){	          // we have to change width... check if we CAN co it:		  int flags=vf->query_format(vf,outfmt); // should not fail		  if(!(flags&3)) mp_msg(MSGT_DECVIDEO,MSGL_WARN,"??? vf_get_image{vf->query_format(outfmt)} failed!\n");//		  printf("query -> 0x%X    \n",flags);		  if(flags&VFCAP_ACCEPT_STRIDE){	              mpi->width=w2;		      mpi->chroma_width=(w2 + (1<<mpi->chroma_x_shift) - 1)>>mpi->chroma_x_shift;		  }	      }	  }	  	  // IF09 - allocate space for 4. plane delta info - unused	  if (mpi->imgfmt == IMGFMT_IF09)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?