Exemple #1
0
void mp_image_alloc_planes(mp_image_t *mpi)
{
    // IF09 - allocate space for 4. plane delta info - unused
    if (mpi->imgfmt == IMGFMT_IF09)
    {
        mpi->planes[0] = av_malloc(mpi->bpp * mpi->width * (mpi->height + 2) / 8 +
                                   mpi->chroma_width * mpi->chroma_height);
    }
    else
        mpi->planes[0] = av_malloc(mpi->bpp * mpi->width * (mpi->height + 2) / 8);
    if (mpi->flags & MP_IMGFLAG_PLANAR)
    {
        int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt) ? 2 : 1;
        // YV12/I420/YVU9/IF09. feel free to add other planar formats here...
        mpi->stride[0] = mpi->stride[3] = bpp * mpi->width;
        if(mpi->num_planes > 2)
        {
            mpi->stride[1] = mpi->stride[2] = bpp * mpi->chroma_width;
            if(mpi->flags & MP_IMGFLAG_SWAPPED)
            {
                // I420/IYUV  (Y,U,V)
                mpi->planes[1] = mpi->planes[0] + mpi->stride[0] * mpi->height;
                mpi->planes[2] = mpi->planes[1] + mpi->stride[1] * mpi->chroma_height;
                if (mpi->num_planes > 3)
                    mpi->planes[3] = mpi->planes[2] + mpi->stride[2] * mpi->chroma_height;
            }
            else
            {
                // YV12,YVU9,IF09  (Y,V,U)
                mpi->planes[2] = mpi->planes[0] + mpi->stride[0] * mpi->height;
                mpi->planes[1] = mpi->planes[2] + mpi->stride[1] * mpi->chroma_height;
                if (mpi->num_planes > 3)
                    mpi->planes[3] = mpi->planes[1] + mpi->stride[1] * mpi->chroma_height;
            }
        }
        else
        {
            // NV12/NV21
            mpi->stride[1] = mpi->chroma_width;
            mpi->planes[1] = mpi->planes[0] + mpi->stride[0] * mpi->height;
        }
    }
    else
    {
        mpi->stride[0] = mpi->width * mpi->bpp / 8;
        if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
            mpi->planes[1] = av_malloc(1024);
    }
    mpi->flags |= MP_IMGFLAG_ALLOCATED;
}
Exemple #2
0
static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts)
{
    mp_image_t *dmpi;
    int ret;
    int w            = (IMGFMT_IS_YUVP16(mpi->imgfmt) ? 2 : 1) * mpi->w;
    int chroma_width = (IMGFMT_IS_YUVP16(mpi->imgfmt) ? 2 : 1) * mpi->chroma_width;

    vf->priv->frame = (vf->priv->frame+1)%4;

    dmpi = vf_get_image(vf->next, mpi->imgfmt,
                        MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE |
                        MP_IMGFLAG_PRESERVE, mpi->width, mpi->height);

    ret = 0;
    //    0/0  1/1  2/2  2/3  3/0
    switch (vf->priv->frame) {
    case 0:
        my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
                      mpi->planes[0]+mpi->stride[0], w, mpi->h/2,
                      dmpi->stride[0]*2, mpi->stride[0]*2);
        if (mpi->flags & MP_IMGFLAG_PLANAR) {
            my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
                          mpi->planes[1]+mpi->stride[1],
                          chroma_width, mpi->chroma_height/2,
                          dmpi->stride[1]*2, mpi->stride[1]*2);
            my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
                          mpi->planes[2]+mpi->stride[2],
                          chroma_width, mpi->chroma_height/2,
                          dmpi->stride[2]*2, mpi->stride[2]*2);
        }
        ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
    /* Fallthrough */
    case 1:
    case 2:
        memcpy_pic(dmpi->planes[0], mpi->planes[0], w, mpi->h,
                   dmpi->stride[0], mpi->stride[0]);
        if (mpi->flags & MP_IMGFLAG_PLANAR) {
            memcpy_pic(dmpi->planes[1], mpi->planes[1],
                       chroma_width, mpi->chroma_height,
                       dmpi->stride[1], mpi->stride[1]);
            memcpy_pic(dmpi->planes[2], mpi->planes[2],
                       chroma_width, mpi->chroma_height,
                       dmpi->stride[2], mpi->stride[2]);
        }
        return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE) || ret;
    case 3:
        my_memcpy_pic(dmpi->planes[0]+dmpi->stride[0],
                      mpi->planes[0]+mpi->stride[0], w, mpi->h/2,
                      dmpi->stride[0]*2, mpi->stride[0]*2);
        if (mpi->flags & MP_IMGFLAG_PLANAR) {
            my_memcpy_pic(dmpi->planes[1]+dmpi->stride[1],
                          mpi->planes[1]+mpi->stride[1],
                          chroma_width, mpi->chroma_height/2,
                          dmpi->stride[1]*2, mpi->stride[1]*2);
            my_memcpy_pic(dmpi->planes[2]+dmpi->stride[2],
                          mpi->planes[2]+mpi->stride[2],
                          chroma_width, mpi->chroma_height/2,
                          dmpi->stride[2]*2, mpi->stride[2]*2);
        }
        ret = vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
        my_memcpy_pic(dmpi->planes[0], mpi->planes[0], w, mpi->h/2,
                      dmpi->stride[0]*2, mpi->stride[0]*2);
        if (mpi->flags & MP_IMGFLAG_PLANAR) {
            my_memcpy_pic(dmpi->planes[1], mpi->planes[1],
                          chroma_width, mpi->chroma_height/2,
                          dmpi->stride[1]*2, mpi->stride[1]*2);
            my_memcpy_pic(dmpi->planes[2], mpi->planes[2],
                          chroma_width, mpi->chroma_height/2,
                          dmpi->stride[2]*2, mpi->stride[2]*2);
        }
        return ret;
    }
    return 0;
}
void mp_image_alloc_planes(mp_image_t *mpi) {
  // IF09 - allocate space for 4. plane delta info - unused
  unsigned char* data;
  int w,h,cw,ch,size;  
  w = mpi->width + 2*EDGE_WIDTH;
  h = mpi->height + 2*EDGE_WIDTH;
  cw = mpi->chroma_width + 2*EDGE_WIDTH;
  ch = mpi->chroma_height + 2*EDGE_WIDTH;

  int w_aln;
  int blk_w;
  blk_w = (w + 15)>>4;
  w_aln = blk_w*256;

  if(use_jz_buf)
    if (mpi->imgfmt == IMGFMT_IF09) {
#ifdef JZ_LINUX_OS
      mpi->planes[0]=jz4740_alloc_frame(NULL,256,mpi->bpp*mpi->width*(mpi->height+2)/8+
					mpi->chroma_width*mpi->chroma_height);
#else
      mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8+
			       mpi->chroma_width*mpi->chroma_height);
#endif
    }else{
#ifdef JZ_LINUX_OS
      data = jz4740_alloc_frame(NULL,256,mpi->bpp*w*(h+2)/8);
      mpi->planes[0]=data + (w/16)*256*(EDGE_WIDTH/16) + 256*(EDGE_WIDTH/16); 
#else
      mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8);
#endif
    }else
    if (mpi->imgfmt == IMGFMT_IF09) {
#ifdef JZ_LINUX_OS
      mpi->planes[0]=jz4740_alloc_frame(NULL,256,mpi->bpp*mpi->width*(mpi->height+2)/8+
					mpi->chroma_width*mpi->chroma_height);
#else
      mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8+
			       mpi->chroma_width*mpi->chroma_height);
#endif
    }else{
#ifdef JZ_LINUX_OS
      data = jz4740_alloc_frame(NULL,256,mpi->bpp*w*(h+2)/8);
      mpi->planes[0]=data + (w/16)*256*(EDGE_WIDTH/16) + 256*(EDGE_WIDTH/16); 
#else
      mpi->planes[0]=av_malloc(mpi->bpp*mpi->width*(mpi->height+2)/8);
#endif
    }

  if (mpi->flags&MP_IMGFLAG_PLANAR) {
    if(use_jz_buf){
      int bpp = IMGFMT_IS_YUVP16(mpi->imgfmt)? 2 : 1;
      // YV12/I420/YVU9/IF09. feel free to add other planar formats here...
      mpi->stride[0]=bpp*w_aln;
      mpi->stride[3]=bpp*mpi->chroma_width;
      if(mpi->num_planes > 2){
	mpi->stride[1]=(mpi->stride[0])>>1;
	mpi->stride[2]=bpp*mpi->width;
	if(mpi->flags&MP_IMGFLAG_SWAPPED){
	  // I420/IYUV  (Y,U,V)
	  mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
	  mpi->planes[2]=mpi->planes[1]+mpi->stride[1]*mpi->chroma_height;
	  if (mpi->num_planes > 3)
            mpi->planes[3]=mpi->planes[2]+mpi->stride[2]*mpi->chroma_height;
	} else {
	  mpi->planes[1] =((int)((mpi->planes[0] + w*h) + 256) & ~(256-1));
	
	  mpi->planes[2] = ((int)(mpi->planes[1] +w*(ch-EDGE_WIDTH)-256*(EDGE_WIDTH/16) + 256) & ~(256-1));
	  //if (mpi->num_planes > 3)
	  mpi->planes[3]=((int)((mpi->planes[2]+mpi->width*mpi->height)+256) & ~(256-1));
	}
      } else {
	// NV12/NV21
	mpi->stride[1]=mpi->chroma_width;
	mpi->planes[1]=mpi->planes[0]+mpi->stride[0]*mpi->height;
      }
    }else{