1
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 06:03:45 +01:00

better planar support, chroma subsampling support and Y8/Y800 support

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6540 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
alex 2002-06-23 21:08:31 +00:00
parent 846f4abc18
commit c20f4d0b42
7 changed files with 39 additions and 68 deletions

View File

@ -58,8 +58,8 @@ typedef struct mp_image_s {
/* 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 @@ static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
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 @@ static inline void mp_image_setfmt(mp_image_t* mpi,unsigned int out_fmt){
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:

View File

@ -72,19 +72,18 @@ static vf_info_t* filter_list[]={
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 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
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 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
(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;
}

View File

@ -199,20 +199,10 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
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 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
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),

View File

@ -34,10 +34,10 @@ static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
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 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
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];
}

View File

@ -56,10 +56,10 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
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],

View File

@ -74,10 +74,10 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
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],

View File

@ -279,8 +279,8 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
// 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)
{