Mercurial > mplayer.hg
changeset 6539:79b536a37e40
better planar support, chroma subsampling support and Y8/Y800 support
author | alex |
---|---|
date | Sun, 23 Jun 2002 21:08:31 +0000 |
parents | afb4f3c107e7 |
children | 5b3cace64e9d |
files | libmpcodecs/mp_image.h libmpcodecs/vf.c libmpcodecs/vf_expand.c libmpcodecs/vf_flip.c libmpcodecs/vf_mirror.c libmpcodecs/vf_rotate.c libmpcodecs/vf_test.c |
diffstat | 7 files changed, 39 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/mp_image.h Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/mp_image.h Sun Jun 23 21:08:31 2002 +0000 @@ -58,8 +58,8 @@ /* these are only used by planar formats Y,U(Cb),V(Cr) */ int chroma_width; int chroma_height; - int chroma_h_shift; - int chroma_v_shift; + int chroma_x_shift; // horizontal + int chroma_y_shift; // vertical } mp_image_t; #ifdef IMGFMT_YUY2 @@ -91,8 +91,8 @@ mpi->bpp=12; mpi->chroma_width=(mpi->width>>1); mpi->chroma_height=(mpi->height>>1); - mpi->chroma_h_shift=1; - mpi->chroma_v_shift=1; + mpi->chroma_x_shift=1; + mpi->chroma_y_shift=1; return; case IMGFMT_IF09: mpi->num_planes=4; @@ -101,8 +101,8 @@ mpi->bpp=9; mpi->chroma_width=(mpi->width>>2); mpi->chroma_height=(mpi->height>>2); - mpi->chroma_h_shift=2; - mpi->chroma_v_shift=2; + mpi->chroma_x_shift=2; + mpi->chroma_y_shift=2; return; case IMGFMT_Y800: case IMGFMT_Y8:
--- a/libmpcodecs/vf.c Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/vf.c Sun Jun 23 21:08:31 2002 +0000 @@ -72,19 +72,18 @@ void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){ int y; if(mpi->flags&MP_IMGFLAG_PLANAR){ - int div = (mpi->imgfmt == IMGFMT_YVU9 || mpi->imgfmt == IMGFMT_IF09) ? 2 : 1; y0&=~1;h+=h&1; if(x0==0 && w==mpi->width){ // full width clear: memset(mpi->planes[0]+mpi->stride[0]*y0,0,mpi->stride[0]*h); - memset(mpi->planes[1]+mpi->stride[1]*(y0>>div),128,mpi->stride[1]*(h>>div)); - memset(mpi->planes[2]+mpi->stride[2]*(y0>>div),128,mpi->stride[2]*(h>>div)); + memset(mpi->planes[1]+mpi->stride[1]*(y0>>mpi->chroma_y_shift),128,mpi->stride[1]*(h>>mpi->chroma_y_shift)); + memset(mpi->planes[2]+mpi->stride[2]*(y0>>mpi->chroma_y_shift),128,mpi->stride[2]*(h>>mpi->chroma_y_shift)); } else for(y=y0;y<y0+h;y+=2){ memset(mpi->planes[0]+x0+mpi->stride[0]*y,0,w); memset(mpi->planes[0]+x0+mpi->stride[0]*(y+1),0,w); - memset(mpi->planes[1]+(x0>>div)+mpi->stride[1]*(y>>div),128,(w>>div)); - memset(mpi->planes[2]+(x0>>div)+mpi->stride[2]*(y>>div),128,(w>>div)); + memset(mpi->planes[1]+(x0>>mpi->chroma_x_shift)+mpi->stride[1]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift)); + memset(mpi->planes[2]+(x0>>mpi->chroma_x_shift)+mpi->stride[2]*(y>>mpi->chroma_y_shift),128,(w>>mpi->chroma_x_shift)); } return; } @@ -166,32 +165,27 @@ if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ // non-direct and not yet allocated image. allocate it! // IF09 - allocate space for 4. plane delta info - unused - if (mpi->imgfmt == IMGFMT_IF09) + if (mpi->imgfmt == IMGFMT_IF09) + { mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8+ - (mpi->width>>2)*(mpi->height>>2)); + mpi->chroma_width*mpi->chroma_height); + /* delta table, just for fun ;) */ + mpi->planes[3]=mpi->planes[0]+2*(mpi->chroma_width*mpi->chroma_height); + } else mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*(mpi->height+2)/8); if(mpi->flags&MP_IMGFLAG_PLANAR){ // YV12/I420/YVU9/IF09. feel free to add other planar formats here... if(!mpi->stride[0]) mpi->stride[0]=mpi->width; - if (!mpi->stride[1]) - { - if (mpi->imgfmt == IMGFMT_YVU9 || mpi->imgfmt == IMGFMT_IF09) - mpi->stride[1]=mpi->stride[2]=mpi->width/4; - else - mpi->stride[1]=mpi->stride[2]=mpi->width/2; - } + if(!mpi->stride[1]) mpi->stride[1]=mpi->stride[2]=mpi->chroma_width; if(mpi->flags&MP_IMGFLAG_SWAPPED){ // I420/IYUV (Y,U,V) mpi->planes[1]=mpi->planes[0]+mpi->width*mpi->height; - mpi->planes[2]=mpi->planes[1]+(mpi->width>>1)*(mpi->height>>1); + mpi->planes[2]=mpi->planes[1]+mpi->chroma_width*mpi->chroma_height; } else { - // YV12,YVU9 (Y,V,U) + // YV12,YVU9,IF09 (Y,V,U) mpi->planes[2]=mpi->planes[0]+mpi->width*mpi->height; - if (mpi->imgfmt == IMGFMT_YVU9 || mpi->imgfmt == IMGFMT_IF09) - mpi->planes[1]=mpi->planes[2]+(mpi->width>>2)*(mpi->height>>2); - else - mpi->planes[1]=mpi->planes[2]+(mpi->width>>1)*(mpi->height>>1); + mpi->planes[1]=mpi->planes[2]+mpi->chroma_width*mpi->chroma_height; } } else { if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8; @@ -209,9 +203,10 @@ (mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB", (mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed", mpi->bpp*mpi->width*mpi->height/8); - mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %x,%x,%x strides: %d,%d,%d)\n", + mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"(imgfmt: %x, planes: %x,%x,%x strides: %d,%d,%d, chroma: %dx%d, shift: h:%d,v:%d)\n", mpi->imgfmt, mpi->planes[0], mpi->planes[1], mpi->planes[2], - mpi->stride[0], mpi->stride[1], mpi->stride[2]); + mpi->stride[0], mpi->stride[1], mpi->stride[2], + mpi->chroma_width, mpi->chroma_height, mpi->chroma_x_shift, mpi->chroma_y_shift); mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED; }
--- a/libmpcodecs/vf_expand.c Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/vf_expand.c Sun Jun 23 21:08:31 2002 +0000 @@ -199,20 +199,10 @@ if(mpi->flags&MP_IMGFLAG_PLANAR){ mpi->planes[0]=vf->priv->dmpi->planes[0]+ vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x; - if (mpi->imgfmt == IMGFMT_YVU9) - { mpi->planes[1]=vf->priv->dmpi->planes[1]+ - (vf->priv->exp_y>>2)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>2); + (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift); mpi->planes[2]=vf->priv->dmpi->planes[2]+ - (vf->priv->exp_y>>2)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>2); - } - else - { - mpi->planes[1]=vf->priv->dmpi->planes[1]+ - (vf->priv->exp_y>>1)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>1); - mpi->planes[2]=vf->priv->dmpi->planes[2]+ - (vf->priv->exp_y>>1)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>1); - } + (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift); mpi->stride[1]=vf->priv->dmpi->stride[1]; mpi->stride[2]=vf->priv->dmpi->stride[2]; } else { @@ -246,28 +236,14 @@ vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x, mpi->planes[0], mpi->w, mpi->h, vf->priv->dmpi->stride[0],mpi->stride[0]); - if (mpi->imgfmt == IMGFMT_YVU9) - { memcpy_pic(vf->priv->dmpi->planes[1]+ - (vf->priv->exp_y>>2)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>2), - mpi->planes[1], mpi->w>>2, mpi->h>>2, + (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>mpi->chroma_x_shift), + mpi->planes[1], mpi->chroma_width, mpi->chroma_height, vf->priv->dmpi->stride[1],mpi->stride[1]); memcpy_pic(vf->priv->dmpi->planes[2]+ - (vf->priv->exp_y>>2)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>2), - mpi->planes[2], mpi->w>>2, mpi->h>>2, + (vf->priv->exp_y>>mpi->chroma_y_shift)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>mpi->chroma_x_shift), + mpi->planes[2], mpi->chroma_width, mpi->chroma_height, vf->priv->dmpi->stride[2],mpi->stride[2]); - } - else - { - memcpy_pic(vf->priv->dmpi->planes[1]+ - (vf->priv->exp_y>>1)*vf->priv->dmpi->stride[1]+(vf->priv->exp_x>>1), - mpi->planes[1], mpi->w>>1, mpi->h>>1, - vf->priv->dmpi->stride[1],mpi->stride[1]); - memcpy_pic(vf->priv->dmpi->planes[2]+ - (vf->priv->exp_y>>1)*vf->priv->dmpi->stride[2]+(vf->priv->exp_x>>1), - mpi->planes[2], mpi->w>>1, mpi->h>>1, - vf->priv->dmpi->stride[2],mpi->stride[2]); - } } else { memcpy_pic(vf->priv->dmpi->planes[0]+ vf->priv->exp_y*vf->priv->dmpi->stride[0]+vf->priv->exp_x*(vf->priv->dmpi->bpp/8),
--- a/libmpcodecs/vf_flip.c Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/vf_flip.c Sun Jun 23 21:08:31 2002 +0000 @@ -34,10 +34,10 @@ mpi->stride[0]=-vf->priv->dmpi->stride[0]; if(mpi->flags&MP_IMGFLAG_PLANAR){ mpi->planes[1]=vf->priv->dmpi->planes[1]+ - vf->priv->dmpi->stride[1]*((vf->priv->dmpi->height>>1)-1); + vf->priv->dmpi->stride[1]*((vf->priv->dmpi->height>>mpi->chroma_y_shift)-1); mpi->stride[1]=-vf->priv->dmpi->stride[1]; mpi->planes[2]=vf->priv->dmpi->planes[2]+ - vf->priv->dmpi->stride[2]*((vf->priv->dmpi->height>>1)-1); + vf->priv->dmpi->stride[2]*((vf->priv->dmpi->height>>mpi->chroma_y_shift)-1); mpi->stride[2]=-vf->priv->dmpi->stride[2]; } mpi->flags|=MP_IMGFLAG_DIRECT; @@ -60,10 +60,10 @@ vf->priv->dmpi->stride[0]=-mpi->stride[0]; if(vf->priv->dmpi->flags&MP_IMGFLAG_PLANAR){ vf->priv->dmpi->planes[1]=mpi->planes[1]+ - mpi->stride[1]*((mpi->height>>1)-1); + mpi->stride[1]*((mpi->height>>mpi->chroma_y_shift)-1); vf->priv->dmpi->stride[1]=-mpi->stride[1]; vf->priv->dmpi->planes[2]=mpi->planes[2]+ - mpi->stride[2]*((mpi->height>>1)-1); + mpi->stride[2]*((mpi->height>>mpi->chroma_y_shift)-1); vf->priv->dmpi->stride[2]=-mpi->stride[2]; }
--- a/libmpcodecs/vf_mirror.c Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/vf_mirror.c Sun Jun 23 21:08:31 2002 +0000 @@ -56,10 +56,10 @@ dmpi->w,dmpi->h,1); mirror(dmpi->planes[1],mpi->planes[1], dmpi->stride[1],mpi->stride[1], - dmpi->w>>1,dmpi->h>>1,1); + dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1); mirror(dmpi->planes[2],mpi->planes[2], dmpi->stride[2],mpi->stride[2], - dmpi->w>>1,dmpi->h>>1,1); + dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1); } else { mirror(dmpi->planes[0],mpi->planes[0], dmpi->stride[0],mpi->stride[0],
--- a/libmpcodecs/vf_rotate.c Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/vf_rotate.c Sun Jun 23 21:08:31 2002 +0000 @@ -74,10 +74,10 @@ dmpi->w,dmpi->h,1,vf->priv->direction); rotate(dmpi->planes[1],mpi->planes[1], dmpi->stride[1],mpi->stride[1], - dmpi->w>>1,dmpi->h>>1,1,vf->priv->direction); + dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,vf->priv->direction); rotate(dmpi->planes[2],mpi->planes[2], dmpi->stride[2],mpi->stride[2], - dmpi->w>>1,dmpi->h>>1,1,vf->priv->direction); + dmpi->w>>mpi->chroma_x_shift,dmpi->h>>mpi->chroma_y_shift,1,vf->priv->direction); } else { rotate(dmpi->planes[0],mpi->planes[0], dmpi->stride[0],mpi->stride[0],
--- a/libmpcodecs/vf_test.c Sun Jun 23 20:42:19 2002 +0000 +++ b/libmpcodecs/vf_test.c Sun Jun 23 21:08:31 2002 +0000 @@ -279,8 +279,8 @@ // clean memset(dmpi->planes[0], 0, dmpi->stride[0]*dmpi->h); - memset(dmpi->planes[1], 128, dmpi->stride[1]*dmpi->h>>1); - memset(dmpi->planes[2], 128, dmpi->stride[2]*dmpi->h>>1); + 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) {