Index: libmpcodecs/vf_vo.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_vo.c,v retrieving revision 1.26 diff -u -r1.26 vf_vo.c --- libmpcodecs/vf_vo.c 18 Nov 2005 14:39:25 -0000 1.26 +++ libmpcodecs/vf_vo.c 12 Dec 2005 22:23:17 -0000 @@ -9,10 +9,16 @@ #include "vf.h" #include "libvo/video_out.h" +#include "libvo/fastmemcpy.h" //===========================================================================// -#define video_out ((vo_functions_t*)(vf->priv)) +struct vf_priv_s { + vo_functions_t* args; + mp_image_t* timg; +}; +#define video_out (vf->priv->args) +#define timg (vf->priv->timg) static int query_format(struct vf_instance_s* vf, unsigned int fmt); /* forward declaration */ @@ -26,6 +32,10 @@ return 0; } + /* Allocate a buffer for a temproary image. */ + timg = vf_get_image(vf, outfmt, MP_IMGTYPE_TEMP, 0, width, height); + if(!timg) return 0; + if(video_out->info) { const vo_info_t *info = video_out->info; mp_msg(MSGT_CPLAYER,MSGL_INFO,"VO: [%s] %dx%d => %dx%d %s %s%s%s%s\n",info->short_name, @@ -86,9 +96,12 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){ int flags=video_out->control(VOCTRL_QUERY_FORMAT,&fmt); - // draw_slice() accepts stride, draw_frame() doesn't: + // RGB/BGR formats are handled by the libvo's draw_frame interface, which + // does not support strides. This filter wraps that interface to provide + // stride support. if(flags) - if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV) + if(fmt==IMGFMT_YV12 || fmt==IMGFMT_I420 || fmt==IMGFMT_IYUV + || IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt)) flags|=VFCAP_ACCEPT_STRIDE; return flags; } @@ -107,11 +120,17 @@ // nope, fallback to old draw_frame/draw_slice: if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){ // blit frame: -// if(mpi->flags&MP_IMGFLAG_PLANAR) - if(vf->default_caps&VFCAP_ACCEPT_STRIDE) + if(mpi->flags&MP_IMGFLAG_PLANAR) +// if(vf->default_caps&VFCAP_ACCEPT_STRIDE) video_out->draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y); - else - video_out->draw_frame(mpi->planes); + else { + if(timg->stride[0] != mpi->stride[0]) { + memcpy_pic(timg->planes[0], mpi->planes[0], timg->stride[0], timg->h, + timg->stride[0], mpi->stride[0]); + video_out->draw_frame(timg->planes); + } else + video_out->draw_frame(mpi->planes); + } } return 1; } @@ -138,7 +157,9 @@ vf->put_image=put_image; vf->draw_slice=draw_slice; vf->start_slice=start_slice; - vf->priv=(void*)args; // video_out + vf->priv = malloc(sizeof(struct vf_priv_s)); + memset(vf->priv, 0, sizeof(struct vf_priv_s)); + video_out = args; if(!video_out) return 0; // no vo ? // if(video_out->preinit(args)) return 0; // preinit failed return 1;