Example #1
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
	// no DR, so get a new image! hope we'll get DR buffer:
	vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
	    MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
	    MP_IMGFLAG_PREFER_ALIGNED_STRIDE | MP_IMGFLAG_READABLE,
//	    MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
//	    mpi->w,mpi->h);
	    (mpi->width+7)&(~7),(mpi->height+7)&(~7));
	vf->dmpi->w=mpi->w; vf->dmpi->h=mpi->h; // display w;h
    }

    if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){
	// do the postprocessing! (or copy if no DR)
	pp_postprocess(mpi->planes           ,mpi->stride,
		    vf->dmpi->planes,vf->dmpi->stride,
		    (mpi->w+7)&(~7),mpi->h,
		    mpi->qscale, mpi->qstride,
		    vf->priv->ppMode[ vf->priv->pp ], vf->priv->context,
#ifdef PP_PICT_TYPE_QP2
		    mpi->pict_type | (mpi->qscale_type ? PP_PICT_TYPE_QP2 : 0));
#else
		    mpi->pict_type);
#endif
    }
Example #2
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;

    // hope we'll get DR buffer:
    dmpi=vf_get_image(vf->next,vf->priv->fmt,
	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
	mpi->w, mpi->h);

    if(mpi->stride[0]!=dmpi->stride[0] || mpi->stride[0]!=mpi->w*(mpi->bpp/8)){
	int y;
	unsigned char* src=mpi->planes[0];
	unsigned char* dst=dmpi->planes[0];
	int srcsize=mpi->w*mpi->bpp/8;
	for(y=0;y<mpi->h;y++){
	    if(mpi->bpp==32)
		rgb32tobgr32(src,dst,srcsize);
	    else
		rgb24tobgr24(src,dst,srcsize);
	    src+=mpi->stride[0];
	    dst+=dmpi->stride[0];
	}
    } else {
	if(mpi->bpp==32)
	    rgb32tobgr32(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*4);
	else
	    rgb24tobgr24(mpi->planes[0],dmpi->planes[0],mpi->w*mpi->h*3);
    }

    return vf_next_put_image(vf,dmpi, pts);
}
Example #3
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
    mp_image_t* dmpi;
    int out_size;
    AVFrame *pic= vf->priv->pic;

    pic->data[0]=mpi->planes[0];
    pic->data[1]=mpi->planes[1];
    pic->data[2]=mpi->planes[2];
    pic->linesize[0]=mpi->stride[0];
    pic->linesize[1]=mpi->stride[1];
    pic->linesize[2]=mpi->stride[2];

    out_size = avcodec_encode_video(&lavc_venc_context,
	vf->priv->outbuf, vf->priv->outbuf_size, pic);

    if(out_size<=0) return 1;

    dmpi=vf_get_image(vf->next,IMGFMT_MPEGPES,
	MP_IMGTYPE_EXPORT, 0,
	mpi->w, mpi->h);

    vf->priv->pes.data=vf->priv->outbuf;
    vf->priv->pes.size=out_size;
    vf->priv->pes.id=0x1E0;
    vf->priv->pes.timestamp=-1; // dunno

    dmpi->planes[0]=(unsigned char*)&vf->priv->pes;

    return vf_next_put_image(vf,dmpi, MP_NOPTS_VALUE);
}
Example #4
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
    AVFilterBufferRef *buf;
    mp_image_t *cmpi = NULL;

    if (!(mpi->flags & MP_IMGFLAG_DIRECT)) {
        cmpi = vf_get_image(vf, mpi->imgfmt, MP_IMGTYPE_TEMP,
                            MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
                            mpi->w, mpi->h);
        copy_mpi(cmpi, mpi);
        buf = cmpi->priv;
    } else {
        buf = mpi->priv;
    }
    buf->video->key_frame = mpi->pict_type == 1;
    buf->video->pict_type = mpi->pict_type; /* seems to be the same code */
    buf->video->interlaced = !!(mpi->fields & MP_IMGFIELD_INTERLACED);
    buf->video->top_field_first = !!(mpi->fields & MP_IMGFIELD_TOP_FIRST);
    vf->priv->in_buf = buf;
    if (pts != MP_NOPTS_VALUE)
        buf->pts = pts * AV_TIME_BASE;
    while (avfilter_poll_frame(vf->priv->out->inputs[0])) {
        if (avfilter_request_frame(vf->priv->out->inputs[0]))
            break;
    }
    return 1;
}
Example #5
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    int i,j;
    uint8_t *y_in, *cb_in, *cr_in;
    uint8_t *y_out, *cb_out, *cr_out;

    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
	mpi->width, mpi->height);
    
    y_in = mpi->planes[0];
    cb_in = mpi->planes[1];
    cr_in = mpi->planes[2];

    y_out = vf->dmpi->planes[0];
    cb_out = vf->dmpi->planes[1];
    cr_out = vf->dmpi->planes[2];
    
    for (i = 0; i < mpi->height; i++)
	for (j = 0; j < mpi->width; j++)
	    y_out[i*vf->dmpi->stride[0]+j] = clamp_y(y_in[i*mpi->stride[0]+j]);

    for (i = 0; i < mpi->chroma_height; i++)
	for (j = 0; j < mpi->chroma_width; j++)
	{
	    cb_out[i*vf->dmpi->stride[1]+j] = clamp_c(cb_in[i*mpi->stride[1]+j]);
	    cr_out[i*vf->dmpi->stride[2]+j] = clamp_c(cr_in[i*mpi->stride[2]+j]);
	}
    
    return vf_next_put_image(vf,vf->dmpi, pts);
}
Example #6
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
    mp_image_t *dmpi = (mp_image_t *)mpi->priv;

    if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){
        dmpi=vf_get_image(vf->next,mpi->imgfmt,
                                    MP_IMGTYPE_EXPORT, 0,
                                    mpi->width, mpi->height);
        vf_clone_mpi_attributes(dmpi, mpi);
        dmpi->planes[0]=mpi->planes[0];
        dmpi->planes[1]=mpi->planes[1];
        dmpi->planes[2]=mpi->planes[2];
        dmpi->stride[0]=mpi->stride[0];
        dmpi->stride[1]=mpi->stride[1];
        dmpi->stride[2]=mpi->stride[2];
        dmpi->width=mpi->width;
        dmpi->height=mpi->height;
    }

    if(vf->priv->shot) {
        if (vf->priv->shot==1)
            vf->priv->shot=0;
        gen_fname(vf->priv);
        if (vf->priv->fname[0]) {
            if (!vf->priv->store_slices)
              scale_image(vf->priv, dmpi);
            write_png(vf->priv);
        }
        vf->priv->store_slices = 0;
    }

    return vf_next_put_image(vf, dmpi, pts);
}
Example #7
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) {
    mp_image_t *dmpi;

    if(!(mpi->flags&MP_IMGFLAG_DIRECT)) {
        // no DR, so get a new image! hope we'll get DR buffer:
        vf->dmpi=vf_get_image(vf->next,vf->priv->outfmt,
                              MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
                              mpi->w,mpi->h);
    }
    dmpi= vf->dmpi;

    delogo(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h,
           vf->priv->xoff, vf->priv->yoff, vf->priv->lw, vf->priv->lh, vf->priv->band, vf->priv->show,
           mpi->flags&MP_IMGFLAG_DIRECT);
    delogo(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2,
           vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
           mpi->flags&MP_IMGFLAG_DIRECT);
    delogo(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2,
           vf->priv->xoff/2, vf->priv->yoff/2, vf->priv->lw/2, vf->priv->lh/2, vf->priv->band/2, vf->priv->show,
           mpi->flags&MP_IMGFLAG_DIRECT);

    vf_clone_mpi_attributes(dmpi, mpi);

    return vf_next_put_image(vf,dmpi, pts);
}
Example #8
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;
    int frame= vf->priv->frame_num;

    // hope we'll get DR buffer:
    dmpi=vf_get_image(vf->next,IMGFMT_YV12,
        MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
        WIDTH, HEIGHT);

    // clean
    memset(dmpi->planes[0], 0, dmpi->stride[0]*dmpi->h);
    memset(dmpi->planes[1], 128, dmpi->stride[1]*dmpi->h>>dmpi->chroma_y_shift);
    memset(dmpi->planes[2], 128, dmpi->stride[2]*dmpi->h>>dmpi->chroma_y_shift);

    if(frame%30)
    {
        switch(frame/30)
        {
        case 0:   dc1Test(dmpi->planes[0], dmpi->stride[0], 256, 256, frame%30); break;
        case 1:   dc1Test(dmpi->planes[1], dmpi->stride[1], 256, 256, frame%30); break;
        case 2: freq1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break;
        case 3: freq1Test(dmpi->planes[1], dmpi->stride[1], frame%30); break;
        case 4:  amp1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break;
        case 5:  amp1Test(dmpi->planes[1], dmpi->stride[1], frame%30); break;
        case 6:  cbp1Test(dmpi->planes   , dmpi->stride   , frame%30); break;
        case 7:   mv1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break;
        case 8: ring1Test(dmpi->planes[0], dmpi->stride[0], frame%30); break;
        case 9: ring2Test(dmpi->planes[0], dmpi->stride[0], frame%30); break;
        }
    }

    frame++;
    vf->priv->frame_num= frame;
    return vf_next_put_image(vf,dmpi, pts);
}
Example #9
0
static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts){
	int cw= mpi->w >> mpi->chroma_x_shift;
	int ch= mpi->h >> mpi->chroma_y_shift;

	mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
		MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_READABLE,
		mpi->w,mpi->h);

	assert(mpi->flags&MP_IMGFLAG_PLANAR);

	hBlur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h,
		dmpi->stride[0], mpi->stride[0], vf->priv->lumaParam.radius, vf->priv->lumaParam.power);
	hBlur(dmpi->planes[1], mpi->planes[1], cw,ch,
		dmpi->stride[1], mpi->stride[1], vf->priv->chromaParam.radius, vf->priv->chromaParam.power);
	hBlur(dmpi->planes[2], mpi->planes[2], cw,ch,
		dmpi->stride[2], mpi->stride[2], vf->priv->chromaParam.radius, vf->priv->chromaParam.power);

	vBlur(dmpi->planes[0], dmpi->planes[0], mpi->w,mpi->h,
		dmpi->stride[0], dmpi->stride[0], vf->priv->lumaParam.radius, vf->priv->lumaParam.power);
	vBlur(dmpi->planes[1], dmpi->planes[1], cw,ch,
		dmpi->stride[1], dmpi->stride[1], vf->priv->chromaParam.radius, vf->priv->chromaParam.power);
	vBlur(dmpi->planes[2], dmpi->planes[2], cw,ch,
		dmpi->stride[2], dmpi->stride[2], vf->priv->chromaParam.radius, vf->priv->chromaParam.power);

	return vf_next_put_image(vf,dmpi, pts);
}
Example #10
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;

    if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
        // no DR, so get a new image! hope we'll get DR buffer:
        dmpi=vf_get_image(vf->next,mpi->imgfmt,
            MP_IMGTYPE_TEMP,
            MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
            mpi->width,mpi->height);
        vf_clone_mpi_attributes(dmpi, mpi);
    }else{
        dmpi=vf->dmpi;
    }

    vf->priv->mpeg2= mpi->qscale_type;
    if(vf->priv->log2_count || !(mpi->flags&MP_IMGFLAG_DIRECT)){
        if(mpi->qscale || vf->priv->qp){
            filter(vf->priv, dmpi->planes, mpi->planes, dmpi->stride, mpi->stride, mpi->w, mpi->h, mpi->qscale, mpi->qstride);
        }else{
            memcpy_pic(dmpi->planes[0], mpi->planes[0], mpi->w, mpi->h, dmpi->stride[0], mpi->stride[0]);
            memcpy_pic(dmpi->planes[1], mpi->planes[1], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[1], mpi->stride[1]);
            memcpy_pic(dmpi->planes[2], mpi->planes[2], mpi->w>>mpi->chroma_x_shift, mpi->h>>mpi->chroma_y_shift, dmpi->stride[2], mpi->stride[2]);
        }
    }

#ifdef HAVE_MMX
    if(gCpuCaps.hasMMX) asm volatile ("emms\n\t");
#endif
#ifdef HAVE_MMX2
    if(gCpuCaps.hasMMX2) asm volatile ("sfence\n\t");
#endif

    return vf_next_put_image(vf,dmpi, pts);
}
Example #11
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;
    int y,w,h;

    // hope we'll get DR buffer:
    dmpi=vf_get_image(vf->next,IMGFMT_YV12,
	MP_IMGTYPE_TEMP, 0/*MP_IMGFLAG_ACCEPT_STRIDE*/,
	mpi->w, mpi->h);

    for(y=0;y<mpi->h;y++)
	memcpy(dmpi->planes[0]+dmpi->stride[0]*y,
	       mpi->planes[0]+mpi->stride[0]*y,
	       mpi->w);

    w=mpi->w/4; h=mpi->h/2;
    for(y=0;y<h;y++){
	unsigned char* s=mpi->planes[1]+mpi->stride[1]*(y>>1);
	unsigned char* d=dmpi->planes[1]+dmpi->stride[1]*y;
	int x;
	for(x=0;x<w;x++) d[2*x]=d[2*x+1]=s[x];
    }
    for(y=0;y<h;y++){
	unsigned char* s=mpi->planes[2]+mpi->stride[2]*(y>>1);
	unsigned char* d=dmpi->planes[2]+dmpi->stride[2]*y;
	int x;
	for(x=0;x<w;x++) d[2*x]=d[2*x+1]=s[x];
    }

    vf_clone_mpi_attributes(dmpi, mpi);
    
    return vf_next_put_image(vf,dmpi, pts);
}
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
	int cw= mpi->w >> mpi->chroma_x_shift;
	int ch= mpi->h >> mpi->chroma_y_shift;
        int W = mpi->w, H = mpi->h;

	mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
		MP_IMGTYPE_IP, MP_IMGFLAG_ACCEPT_STRIDE |
		MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE,
                mpi->w,mpi->h);

	if(!dmpi) return 0;
        if (!vf->priv->pmpi) vf->priv->pmpi=mpi;

        deNoise(mpi->planes[0], vf->priv->pmpi->planes[0], dmpi->planes[0],
		vf->priv->Line, W, H,
                mpi->stride[0], vf->priv->pmpi->stride[0], dmpi->stride[0],
                vf->priv->Coefs[0] + 256,
                vf->priv->Coefs[0] + 256,
                vf->priv->Coefs[1] + 256);
        deNoise(mpi->planes[1], vf->priv->pmpi->planes[1], dmpi->planes[1],
		vf->priv->Line, cw, ch,
                mpi->stride[1], vf->priv->pmpi->stride[1], dmpi->stride[1],
                vf->priv->Coefs[2] + 256,
                vf->priv->Coefs[2] + 256,
                vf->priv->Coefs[3] + 256);
        deNoise(mpi->planes[2], vf->priv->pmpi->planes[2], dmpi->planes[2],
		vf->priv->Line, cw, ch,
                mpi->stride[2], vf->priv->pmpi->stride[2], dmpi->stride[2],
                vf->priv->Coefs[2] + 256,
                vf->priv->Coefs[2] + 256,
                vf->priv->Coefs[3] + 256);

	vf->priv->pmpi=dmpi; // save reference image
	return vf_next_put_image(vf,dmpi, pts);
}
static int
put_image (struct vf_instance *vf, mp_image_t *mpi, double pts)
{
  struct vf_priv_s *priv = vf->priv;
  mp_image_t* dmpi;
  AVPicture pic;
  AVPicture lavc_picture;

  lavc_picture.data[0]     = mpi->planes[0];
  lavc_picture.data[1]     = mpi->planes[1];
  lavc_picture.data[2]     = mpi->planes[2];
  lavc_picture.linesize[0] = mpi->stride[0];
  lavc_picture.linesize[1] = mpi->stride[1];
  lavc_picture.linesize[2] = mpi->stride[2];

  dmpi = vf_get_image(vf->next, mpi->imgfmt,
		      MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
		      priv->width, priv->height);

  pic.data[0]     = dmpi->planes[0];
  pic.data[1]     = dmpi->planes[1];
  pic.data[2]     = dmpi->planes[2];
  pic.linesize[0] = dmpi->stride[0];
  pic.linesize[1] = dmpi->stride[1];
  pic.linesize[2] = dmpi->stride[2];

  if (avpicture_deinterlace(&pic, &lavc_picture,
			    priv->pix_fmt, priv->width, priv->height) < 0)
    {
      /* This should not happen -- see config() */
      return 0;
    }

  return vf_next_put_image(vf, dmpi, pts);
}
Example #14
0
static void get_image(struct vf_instance* vf, mp_image_t *mpi){
//    if(mpi->type==MP_IMGTYPE_IPB) return; // not yet working
#ifdef OSD_SUPPORT
    if(vf->priv->osd_enabled && (mpi->flags&MP_IMGFLAG_PRESERVE)){
	// check if we have to render osd!
	osd_update(vf->priv->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,
            FFMAX(vf->priv->exp_w, mpi->width +vf->priv->exp_x),
            FFMAX(vf->priv->exp_h, mpi->height+vf->priv->exp_y));
	if((vf->dmpi->flags & MP_IMGFLAG_DRAW_CALLBACK) &&
	  !(vf->dmpi->flags & MP_IMGFLAG_DIRECT)){
	    mp_tmsg(MSGT_VFILTER, MSGL_INFO, "Full DR not possible, trying SLICES instead!\n");
	    return;
	}
	// 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 {
/* Filter handler */
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
    mp_image_t        *dmpi;
    struct vf_priv_s  *priv;
    int               skip;

    priv = vf->priv;

    /* Print the 'I' if is a intra frame. The \n advance the current line so you got the
     * current file time (in second) and the frame number on the console ;-)
     */
    if (priv->dump_iframe) {
        if (mpi->pict_type == 1) {
            mp_msg(MSGT_VFILTER, MSGL_INFO, "I!\n");
        }
    }

    /* decide if frame must be shown */
    if (priv->dump_iframe == 2) {
        /* Only key frame */
        skip = mpi->pict_type == 1 ? 0 : 1;
    }
    else {
        /* Only 1 every frame_step */
        skip = 0;
        if ((priv->frame_step != 0) && ((priv->frame_cur % priv->frame_step) != 0)) {
            skip = 1;
        }
    }
    /* Increment current frame */
    ++priv->frame_cur;

    if (skip == 0) {
	/* Get image, export type (we don't modify tghe image) */
	dmpi=vf_get_image(vf->next, mpi->imgfmt,
                      MP_IMGTYPE_EXPORT, 0,
	              mpi->w, mpi->h);
        /* Copy only the pointer ( MP_IMGTYPE_EXPORT ! ) */
        dmpi->planes[0] = mpi->planes[0];
        dmpi->planes[1] = mpi->planes[1];
        dmpi->planes[2] = mpi->planes[2];

        dmpi->stride[0] = mpi->stride[0];
        dmpi->stride[1] = mpi->stride[1];
        dmpi->stride[2] = mpi->stride[2];

        dmpi->width     = mpi->width;
        dmpi->height    = mpi->height;

        /* Chain to next filter / output ... */
        return vf_next_put_image(vf, dmpi, pts);
    }

    /* Skip the frame */
    return 0;
}
Example #16
0
File: vd.c Project: sherpya/MPlayer
// mp_imgtype: buffering type, see mp_image.h
// mp_imgflag: buffer requirements (read/write, preserve, stride limits), see mp_image.h
// returns NULL or allocated mp_image_t*
// Note: buffer allocation may be moved to mpcodecs_config_vo() later...
mp_image_t *mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag,
                               int w, int h)
{
    mp_image_t *mpi =
        vf_get_image(sh->vfilter, sh->codec->outfmt[sh->outfmtidx], mp_imgtype,
                     mp_imgflag, w, h);
    if (mpi)
        mpi->x = mpi->y = 0;
    return mpi;
}
static void start_slice(struct vf_instance_s* vf, mp_image_t *mpi){
    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
	mpi->type, mpi->flags, mpi->width, mpi->height);
    if (vf->priv->shot) {
	vf->priv->store_slices = 1;
	if (!vf->priv->buffer)
	    vf->priv->buffer = (uint8_t*)memalign(16, vf->priv->stride*vf->priv->dh);
    }
    
}
Example #18
0
static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
  mp_image_t *dmpi;

  if(mpi->type == MP_IMGTYPE_TEMP && (!(mpi->flags&MP_IMGFLAG_PRESERVE)) ) {
    dmpi = vf_get_image(vf->next,mpi->imgfmt,mpi->type, mpi->flags, mpi->w, mpi->h);
    memcpy(mpi->planes,dmpi->planes,MP_MAX_PLANES*sizeof(unsigned char*));
    memcpy(mpi->stride,dmpi->stride,MP_MAX_PLANES*sizeof(unsigned int));
    mpi->flags|=MP_IMGFLAG_DIRECT;
    mpi->priv=(void*)dmpi;
    return;
  }
}
Example #19
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;

    // hope we'll get DR buffer:
    dmpi=vf_get_image(vf->next,vf->priv->fmt,
	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
	mpi->w, mpi->h);

    switch(dmpi->imgfmt){
    case IMGFMT_Y800:
    case IMGFMT_Y8:
    case IMGFMT_BGR8:
    case IMGFMT_RGB8:
	convert(mpi,dmpi,0,255,1);
	break;
    case IMGFMT_YVU9:
    case IMGFMT_411P:
    case IMGFMT_YV12:
    case IMGFMT_I420:
    case IMGFMT_IYUV:
    case IMGFMT_422P:
    case IMGFMT_444P:
	convert(mpi,dmpi,0,255,1);
	memset(dmpi->planes[1],128,dmpi->stride[1]*dmpi->chroma_height);
	memset(dmpi->planes[2],128,dmpi->stride[2]*dmpi->chroma_height);
	break;
    case IMGFMT_YUY2:
	convert(mpi,dmpi,0x8000,0x80ff,2);
	break;
    case IMGFMT_BGR12:
    case IMGFMT_RGB12:
        convert(mpi,dmpi,0,0x0fff,2);
        break;
    case IMGFMT_BGR15:
    case IMGFMT_RGB15:
	convert(mpi,dmpi,0,0x7fff,2);
	break;
    case IMGFMT_BGR16:
    case IMGFMT_RGB16:
	convert(mpi,dmpi,0,0xffff,2);
	break;
    case IMGFMT_BGR32:
    case IMGFMT_RGB32:
	convert(mpi,dmpi,0,0x00ffffff,4);
	break;
    default:
	mp_msg(MSGT_VFILTER,MSGL_ERR,"Unhandled format: 0x%X\n",dmpi->imgfmt);
	return 0;
    }

    return vf_next_put_image(vf,dmpi, pts);
}
Example #20
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;

    // hope we'll get DR buffer:
    dmpi=vf_get_image(vf->next,mpi->imgfmt,
	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
	2*mpi->w, 2*mpi->h);

    Super2xSaI_ex(mpi->planes[0], mpi->stride[0],
		  dmpi->planes[0], dmpi->stride[0],
		  mpi->w, mpi->h, mpi->bpp/8);
    
    return vf_next_put_image(vf,dmpi, pts);
}
Example #21
0
static void get_image(struct vf_instance *vf, mp_image_t *mpi){
    mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt,
        mpi->type, mpi->flags, mpi->w, mpi->h);

    mpi->planes[0]=dmpi->planes[0];
    mpi->planes[1]=dmpi->planes[2];
    mpi->planes[2]=dmpi->planes[1];
    mpi->stride[0]=dmpi->stride[0];
    mpi->stride[1]=dmpi->stride[2];
    mpi->stride[2]=dmpi->stride[1];
    mpi->width=dmpi->width;

    mpi->flags|=MP_IMGFLAG_DIRECT;
    mpi->priv=(void*)dmpi;
}
Example #22
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts) {
    mp_image_t *dmpi;
    int x,y, plane;

    if(!(mpi->flags&MP_IMGFLAG_DIRECT)) {
        // no DR, so get a new image! hope we'll get DR buffer:
        vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, MP_IMGTYPE_TEMP,
                              MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
                              mpi->w,mpi->h);
    }

    dmpi= vf->dmpi;
    vf->priv->mpi= mpi;

    vf_clone_mpi_attributes(dmpi, mpi);

    for(plane=0; plane<3; plane++) {
        int w= mpi->w >> (plane ? mpi->chroma_x_shift : 0);
        int h= mpi->h >> (plane ? mpi->chroma_y_shift : 0);
        uint8_t *dst  = dmpi->planes[plane];
        int dst_stride= dmpi->stride[plane];
        double const_values[]= {
            M_PI,
            M_E,
            0,
            0,
            w,
            h,
            vf->priv->framenum,
            w/(double)mpi->w,
            h/(double)mpi->h,
            0
        };
        if (!vf->priv->e[plane]) continue;
        for(y=0; y<h; y++) {
            const_values[3]=y;
            for(x=0; x<w; x++) {
                const_values[2]=x;
                dst[x + y * dst_stride] = av_expr_eval(vf->priv->e[plane],
                                                       const_values, vf);
            }
        }
    }

    vf->priv->framenum++;

    return vf_next_put_image(vf,dmpi, pts);
}
Example #23
0
static int put_image(struct vf_instance* vf, mp_image_t *mpi, double pts)
{
	mp_image_t *dmpi;

	// hope we'll get DR buffer:
	dmpi=vf_get_image(vf->next, IMGFMT_YV12,
			  MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE |
			  (vf->priv->scaleh == 1) ? MP_IMGFLAG_READABLE : 0,
			  mpi->w * vf->priv->scalew,
			  mpi->h / vf->priv->scaleh - vf->priv->skipline);

	toright(dmpi->planes, mpi->planes, dmpi->stride,
		mpi->stride, mpi->w, mpi->h, vf->priv);

	return vf_next_put_image(vf,dmpi, pts);
}
Example #24
0
static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
    if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
    // ok, we can do pp in-place (or pp disabled):
    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
        mpi->type, mpi->flags | MP_IMGFLAG_READABLE, mpi->width, mpi->height);
    mpi->planes[0]=vf->dmpi->planes[0];
    mpi->stride[0]=vf->dmpi->stride[0];
    mpi->width=vf->dmpi->width;
    if(mpi->flags&MP_IMGFLAG_PLANAR){
        mpi->planes[1]=vf->dmpi->planes[1];
        mpi->planes[2]=vf->dmpi->planes[2];
	mpi->stride[1]=vf->dmpi->stride[1];
	mpi->stride[2]=vf->dmpi->stride[2];
    }
    mpi->flags|=MP_IMGFLAG_DIRECT;
}
Example #25
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;
    
    // hope we'll get DR buffer:
    dmpi=vf_get_image(vf->next,vf->priv->fmt,
	MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
	mpi->w, mpi->h);

    if (!mpi->planes[1])
    {
	if(!vf->priv->pal_msg){
	    mp_msg(MSGT_VFILTER,MSGL_V,"[%s] no palette given, assuming builtin grayscale one\n",vf->info->name);
	    vf->priv->pal_msg=1;
	}
	mpi->planes[1] = (unsigned char*)gray_pal;
    }

    if(mpi->w==mpi->stride[0] && dmpi->w*(dmpi->bpp>>3)==dmpi->stride[0]){
	// no stride conversion needed
	switch(IMGFMT_RGB_DEPTH(dmpi->imgfmt)){
	case 15:
	    if (IMGFMT_IS_BGR(dmpi->imgfmt))
		palette8tobgr15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    else
		palette8torgb15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    break;
	case 16:
	    if (IMGFMT_IS_BGR(dmpi->imgfmt))
		palette8tobgr16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    else
		palette8torgb16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    break;
	case 24:
	    if (IMGFMT_IS_BGR(dmpi->imgfmt))
		palette8tobgr24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    else
		palette8torgb24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    break;
	case 32:
	    if (IMGFMT_IS_BGR(dmpi->imgfmt))
		palette8tobgr32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    else
		palette8torgb32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
	    break;
	}
    } else {
Example #26
0
static void get_image(struct vf_instance_s* vf, mp_image_t *mpi) {
    if(mpi->flags&MP_IMGFLAG_PRESERVE) return; // don't change
    if(mpi->imgfmt!=vf->priv->outfmt) return; // colorspace differ
    // ok, we can do pp in-place (or pp disabled):
    vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
                          mpi->type, mpi->flags, mpi->w, mpi->h);
    mpi->planes[0]=vf->dmpi->planes[0];
    mpi->stride[0]=vf->dmpi->stride[0];
    mpi->width=vf->dmpi->width;
    if(mpi->flags&MP_IMGFLAG_PLANAR) {
        mpi->planes[1]=vf->dmpi->planes[1];
        mpi->planes[2]=vf->dmpi->planes[2];
        mpi->stride[1]=vf->dmpi->stride[1];
        mpi->stride[2]=vf->dmpi->stride[2];
    }
    mpi->flags|=MP_IMGFLAG_DIRECT;
}
Example #27
0
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
    mp_image_t *dmpi;
    if (mpi->flags&MP_IMGFLAG_DRAW_CALLBACK)
	return vf_next_put_image(vf,vf->dmpi, pts);
    dmpi=vf_get_image(vf->next,mpi->imgfmt,
	MP_IMGTYPE_EXPORT, 0,
	vf->priv->crop_w, vf->priv->crop_h);
    if(mpi->flags&MP_IMGFLAG_PLANAR){
	dmpi->planes[0]=mpi->planes[0]+
	    vf->priv->crop_y*mpi->stride[0]+vf->priv->crop_x;
	dmpi->planes[1]=mpi->planes[1]+
	    (vf->priv->crop_y>>mpi->chroma_y_shift)*mpi->stride[1]+(vf->priv->crop_x>>mpi->chroma_x_shift);
	dmpi->planes[2]=mpi->planes[2]+
	    (vf->priv->crop_y>>mpi->chroma_y_shift)*mpi->stride[2]+(vf->priv->crop_x>>mpi->chroma_x_shift);
	dmpi->stride[1]=mpi->stride[1];
	dmpi->stride[2]=mpi->stride[2];
    } else {
Example #28
0
static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
    if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){
	// try full DR !
	vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
	    mpi->type, mpi->flags, mpi->width, mpi->height);
	// set up mpi as a upside-down image of dmpi:
	mpi->planes[0]=vf->dmpi->planes[0]+
		    vf->dmpi->stride[0]*(vf->dmpi->height-1);
	mpi->stride[0]=-vf->dmpi->stride[0];
	if(mpi->flags&MP_IMGFLAG_PLANAR){
	    mpi->planes[1]=vf->dmpi->planes[1]+
		    vf->dmpi->stride[1]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
	    mpi->stride[1]=-vf->dmpi->stride[1];
	    mpi->planes[2]=vf->dmpi->planes[2]+
		    vf->dmpi->stride[2]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
	    mpi->stride[2]=-vf->dmpi->stride[2];
	}
Example #29
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
    int cw= mpi->w >> mpi->chroma_x_shift;
    int ch= mpi->h >> mpi->chroma_y_shift;
    int threshold = vf->priv->luma.threshold || vf->priv->chroma.threshold;

    mp_image_t *dmpi=vf_get_image(vf->next,mpi->imgfmt,
        MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|
        (threshold ? MP_IMGFLAG_READABLE : 0),
        mpi->w,mpi->h);

    assert(mpi->flags&MP_IMGFLAG_PLANAR);

    blur(dmpi->planes[0], mpi->planes[0], mpi->w,mpi->h, dmpi->stride[0], mpi->stride[0], &vf->priv->luma);
    blur(dmpi->planes[1], mpi->planes[1], cw    , ch   , dmpi->stride[1], mpi->stride[1], &vf->priv->chroma);
    blur(dmpi->planes[2], mpi->planes[2], cw    , ch   , dmpi->stride[2], mpi->stride[2], &vf->priv->chroma);

    return vf_next_put_image(vf,dmpi, pts);
}
Example #30
0
/***
 * \param vf pointer to vf_instance
 * \param mpi pointer to mp_image_t structure
 * \param pts
 */
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
	struct vf_priv_s *priv = vf->priv;
	int size = 0;
	int i;
	mp_image_t* dmpi;
	for (i = 0; i < priv->fields; i++)
		size += jpeg_enc_frame(priv->j,
				mpi->planes[0] + i*priv->y_stride,
				mpi->planes[1] + i*priv->c_stride,
				mpi->planes[2] + i*priv->c_stride,
				priv->buf + size);

	dmpi = vf_get_image(vf->next, IMGFMT_ZRMJPEGNI,
			MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
	dmpi->planes[0] = (uint8_t*)priv->buf;
	dmpi->planes[1] = (uint8_t*)size;
	return vf_next_put_image(vf,dmpi, pts);
}