mirror of
https://github.com/mpv-player/mpv
synced 2025-04-25 21:01:48 +00:00
draw_slice support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9492 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
0020d4b05c
commit
2074da4092
@ -20,6 +20,7 @@ struct vf_priv_s {
|
|||||||
unsigned int fmt;
|
unsigned int fmt;
|
||||||
SwsContext *ctx;
|
SwsContext *ctx;
|
||||||
unsigned char* palette;
|
unsigned char* palette;
|
||||||
|
mp_image_t *dmpi;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int opt_screen_size_x;
|
extern int opt_screen_size_x;
|
||||||
@ -199,15 +200,43 @@ static int config(struct vf_instance_s* vf,
|
|||||||
return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best);
|
return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,best);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||||
mp_image_t *dmpi;
|
// printf("start_slice called! flag=%d\n",mpi->flags&MP_IMGFLAG_DRAW_CALLBACK);
|
||||||
|
if(!(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)) return; // shouldn't happen
|
||||||
|
// they want slices!!! allocate the buffer.
|
||||||
|
mpi->priv=vf->priv->dmpi=vf_get_image(vf->next,vf->priv->fmt,
|
||||||
|
// mpi->type, mpi->flags & (~MP_IMGFLAG_DRAW_CALLBACK),
|
||||||
|
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
|
||||||
|
vf->priv->w, vf->priv->h);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_slice(struct vf_instance_s* vf,
|
||||||
|
unsigned char** src, int* stride, int w,int h, int x, int y){
|
||||||
|
mp_image_t *dmpi=vf->priv->dmpi;
|
||||||
|
if(!dmpi){
|
||||||
|
mp_msg(MSGT_VFILTER,MSGL_FATAL,"vf_scale: draw_slice() called with dmpi=NULL (no get_image??)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// printf("vf_scale::draw_slice() y=%d h=%d\n",y,h);
|
||||||
|
vf->priv->ctx->swScale(vf->priv->ctx,src,stride,y,h,dmpi->planes,dmpi->stride);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
|
||||||
|
mp_image_t *dmpi=mpi->priv;
|
||||||
|
|
||||||
|
// printf("vf_scale::put_image(): processing whole frame! dmpi=%p flag=%d\n",
|
||||||
|
// dmpi, (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK));
|
||||||
|
|
||||||
|
if(!(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK && dmpi)){
|
||||||
|
|
||||||
// hope we'll get DR buffer:
|
// hope we'll get DR buffer:
|
||||||
dmpi=vf_get_image(vf->next,vf->priv->fmt,
|
dmpi=vf_get_image(vf->next,vf->priv->fmt,
|
||||||
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
|
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
|
||||||
vf->priv->w, vf->priv->h);
|
vf->priv->w, vf->priv->h);
|
||||||
vf->priv->ctx->swScale(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride);
|
vf->priv->ctx->swScale(vf->priv->ctx,mpi->planes,mpi->stride,0,mpi->h,dmpi->planes,dmpi->stride);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(vf->priv->w==mpi->w && vf->priv->h==mpi->h){
|
if(vf->priv->w==mpi->w && vf->priv->h==mpi->h){
|
||||||
// just conversion, no scaling -> keep postprocessing data
|
// just conversion, no scaling -> keep postprocessing data
|
||||||
// this way we can apply pp filter to non-yv12 source using scaler
|
// this way we can apply pp filter to non-yv12 source using scaler
|
||||||
@ -314,6 +343,8 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
|
|||||||
|
|
||||||
static int open(vf_instance_t *vf, char* args){
|
static int open(vf_instance_t *vf, char* args){
|
||||||
vf->config=config;
|
vf->config=config;
|
||||||
|
vf->start_slice=start_slice;
|
||||||
|
vf->draw_slice=draw_slice;
|
||||||
vf->put_image=put_image;
|
vf->put_image=put_image;
|
||||||
vf->query_format=query_format;
|
vf->query_format=query_format;
|
||||||
vf->control= control;
|
vf->control= control;
|
||||||
|
Loading…
Reference in New Issue
Block a user