vf_expand.c

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

C
481
字号
//    if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working#ifdef OSD_SUPPORT    if(vf->priv->osd && (mpi->flags&MP_IMGFLAG_PRESERVE)){	// check if we have to render osd!	vo_update_osd(vf->priv->exp_w, vf->priv->exp_h);	if(vo_osd_check_range_update(vf->priv->exp_x,vf->priv->exp_y,	    vf->priv->exp_x+mpi->w,vf->priv->exp_y+mpi->h)) return;    }#endif    if(vf->priv->exp_w==mpi->width ||       (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH)) ){	// try full DR !	mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,	    mpi->type, mpi->flags,             MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),             MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));#if 1	if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&	  !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){	    mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_FullDRNotPossible);	    return;	}#endif	// set up mpi as a cropped-down image of dmpi:	if(mpi->flags&MP_IMGFLAG_PLANAR){	    mpi->planes[0]=vf->dmpi->planes[0]+		vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x;	    mpi->planes[1]=vf->dmpi->planes[1]+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift);	    mpi->planes[2]=vf->dmpi->planes[2]+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift);	    mpi->stride[1]=vf->dmpi->stride[1];	    mpi->stride[2]=vf->dmpi->stride[2];	} else {	    mpi->planes[0]=vf->dmpi->planes[0]+		vf->priv->exp_y*vf->dmpi->stride[0]+		vf->priv->exp_x*(vf->dmpi->bpp/8);	}	mpi->stride[0]=vf->dmpi->stride[0];	mpi->width=vf->dmpi->width;	mpi->flags|=MP_IMGFLAG_DIRECT;	mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;//	vf->dmpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;    }}static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){//    printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);    if(!vf->next->draw_slice){	mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;	return;    }    // they want slices!!! allocate the buffer.    if(!mpi->priv)	mpi->priv=vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,//	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,	    MP_IMGTYPE_TEMP, mpi->flags,             MAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),             MAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));    if(!(vf->dmpi->flags&MP_IMGFLAG_DRAW_CALLBACK))	mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupportSlices); // shouldn't happen.    vf->priv->first_slice = 1;}static void draw_top_blackbar_slice(struct vf_instance_s* vf,				    unsigned char** src, int* stride, int w,int h, int x, int y){    if(vf->priv->exp_y>0 && y == 0) {	vf_next_draw_slice(vf, vf->dmpi->planes, vf->dmpi->stride,			   vf->dmpi->w,vf->priv->exp_y,0,0);    }    }static void draw_bottom_blackbar_slice(struct vf_instance_s* vf,				    unsigned char** src, int* stride, int w,int h, int x, int y){    if(vf->priv->exp_y+vf->h<vf->dmpi->h && y+h == vf->h) {	unsigned char *src2[MP_MAX_PLANES];	src2[0] = vf->dmpi->planes[0]		+ (vf->priv->exp_y+vf->h)*vf->dmpi->stride[0];	if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){	    src2[1] = vf->dmpi->planes[1]		+ ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[1];	    src2[2] = vf->dmpi->planes[2]		+ ((vf->priv->exp_y+vf->h)>>vf->dmpi->chroma_y_shift)*vf->dmpi->stride[2];	} else {	    src2[1] = vf->dmpi->planes[1]; // passthrough rgb8 palette	}	vf_next_draw_slice(vf, src2, vf->dmpi->stride,			   vf->dmpi->w,vf->dmpi->h-(vf->priv->exp_y+vf->h),			   0,vf->priv->exp_y+vf->h);    }}static void draw_slice(struct vf_instance_s* vf,        unsigned char** src, int* stride, int w,int h, int x, int y){//    printf("draw_slice() called %d at %d\n",h,y);        if (y == 0 && y+h == vf->h) {	// special case - only one slice	draw_top_blackbar_slice(vf, src, stride, w, h, x, y);	vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);	draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);	return;    }    if (vf->priv->first_slice) {	draw_top_blackbar_slice(vf, src, stride, w, h, x, y);	draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);    }    vf_next_draw_slice(vf,src,stride,w,h,x+vf->priv->exp_x,y+vf->priv->exp_y);    if (!vf->priv->first_slice) {	draw_top_blackbar_slice(vf, src, stride, w, h, x, y);	draw_bottom_blackbar_slice(vf, src, stride, w, h, x, y);    }    vf->priv->first_slice = 0;}static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){    if (vf->priv->passthrough) {      mp_image_t *dmpi = vf_get_image(vf->next, IMGFMT_MPEGPES,                                      MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);      dmpi->planes[0]=mpi->planes[0];      return vf_next_put_image(vf,dmpi, pts);    }    if(mpi->flags&MP_IMGFLAG_DIRECT || mpi->flags&MP_IMGFLAG_DRAW_CALLBACK){	vf->dmpi=mpi->priv;	if(!vf->dmpi) { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_FunWhydowegetNULL); return 0; }	mpi->priv=NULL;#ifdef OSD_SUPPORT	if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);#endif	// we've used DR, so we're ready...	if(!(mpi->flags&MP_IMGFLAG_PLANAR))	    vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette	return vf_next_put_image(vf,vf->dmpi, pts);    }    // hope we'll get DR buffer:    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,	vf->priv->exp_w, vf->priv->exp_h);        // copy mpi->dmpi...    if(mpi->flags&MP_IMGFLAG_PLANAR){	memcpy_pic(vf->dmpi->planes[0]+	        vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x,		mpi->planes[0], mpi->w, mpi->h,		vf->dmpi->stride[0],mpi->stride[0]);	memcpy_pic(vf->dmpi->planes[1]+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift),		mpi->planes[1], (mpi->w>>mpi->chroma_x_shift), (mpi->h>>mpi->chroma_y_shift),		vf->dmpi->stride[1],mpi->stride[1]);	memcpy_pic(vf->dmpi->planes[2]+		(vf->priv->exp_y>>mpi->chroma_y_shift)*vf->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift),		mpi->planes[2], (mpi->w>>mpi->chroma_x_shift), (mpi->h>>mpi->chroma_y_shift),		vf->dmpi->stride[2],mpi->stride[2]);    } else {	memcpy_pic(vf->dmpi->planes[0]+	        vf->priv->exp_y*vf->dmpi->stride[0]+vf->priv->exp_x*(vf->dmpi->bpp/8),		mpi->planes[0], mpi->w*(vf->dmpi->bpp/8), mpi->h,		vf->dmpi->stride[0],mpi->stride[0]);	vf->dmpi->planes[1] = mpi->planes[1]; // passthrough rgb8 palette    }#ifdef OSD_SUPPORT    if(vf->priv->osd) draw_osd(vf,mpi->w,mpi->h);#endif    return vf_next_put_image(vf,vf->dmpi, pts);}//===========================================================================//static int control(struct vf_instance_s* vf, int request, void* data){#ifdef OSD_SUPPORT    switch(request){    case VFCTRL_DRAW_OSD:	if(vf->priv->osd) return CONTROL_TRUE;    }#endif    return vf_next_control(vf,request,data);}static int query_format(struct vf_instance_s* vf, unsigned int fmt){  return (vf_next_query_format(vf,fmt));}static int vf_open(vf_instance_t *vf, char* args){    vf->config=config;    vf->control=control;    vf->query_format=query_format;    vf->start_slice=start_slice;    vf->draw_slice=draw_slice;    vf->get_image=get_image;    vf->put_image=put_image;    mp_msg(MSGT_VFILTER, MSGL_INFO, "Expand: %d x %d, %d ; %d, osd: %d, aspect: %lf, round: %d\n",    vf->priv->exp_w,    vf->priv->exp_h,    vf->priv->exp_x,    vf->priv->exp_y,    vf->priv->osd,    vf->priv->aspect,    vf->priv->round);    return 1;}#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)static m_option_t vf_opts_fields[] = {  {"w", ST_OFF(exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL},  {"h", ST_OFF(exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL},  {"x", ST_OFF(exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},  {"y", ST_OFF(exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL},  {"osd", ST_OFF(osd), CONF_TYPE_FLAG, 0 , 0, 1, NULL},  {"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL},  {"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL},  { NULL, NULL, 0, 0, 0, 0,  NULL }};static m_struct_t vf_opts = {  "expand",  sizeof(struct vf_priv_s),  &vf_priv_dflt,  vf_opts_fields};vf_info_t vf_info_expand = {#ifdef OSD_SUPPORT    "expanding & osd",#else    "expanding",#endif    "expand",    "A'rpi",    "",    vf_open,    &vf_opts};//===========================================================================//

⌨️ 快捷键说明

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