Mercurial > mplayer.hg
changeset 7355:04df35721744
- some cleanup, unused code removed
- some debug messages moved dbg3->dbg2
- mpi allocation moved to the codec callback func, exporting instead of
memcpy whenever it's possible
- indeo3 colors somehow got fixed :)
author | arpi |
---|---|
date | Tue, 10 Sep 2002 20:03:04 +0000 |
parents | 10c1cfc92981 |
children | 12c25243426c |
files | libmpcodecs/vd_xanim.c |
diffstat | 1 files changed, 81 insertions(+), 103 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/vd_xanim.c Tue Sep 10 17:33:38 2002 +0000 +++ b/libmpcodecs/vd_xanim.c Tue Sep 10 20:03:04 2002 +0000 @@ -4,8 +4,8 @@ It partly emulates the Xanim codebase. You need the -rdynamic flag to use this with gcc. - (C) 2001 Alex Beregszaszi <alex@naxine.org> - and Arpad Gereoffy <arpi@thot.banki.hu> + (C) 2001-2002 Alex Beregszaszi <alex@naxine.org> + and Arpad Gereoffy <arpi@thot.banki.hu> */ #include <stdio.h> @@ -43,6 +43,8 @@ #include "linux/timer.h" #include "libvo/fastmemcpy.h" +#define mp_dbg(mod,lev, args... ) mp_msg_c((mod<<8)|lev, ## args ) + #if 0 /* this should be removed */ #ifndef RTLD_NOW @@ -166,6 +168,7 @@ long (*iq_func)(XA_CODEC_HDR *codec_hdr); unsigned int (*dec_func)(unsigned char *image, unsigned char *delta, unsigned int dsize, XA_DEC_INFO *dec_info); + mp_image_t *mpi; } vd_xanim_ctx; #if 0 @@ -439,7 +442,7 @@ void *YUV2x2_Blk_Func(unsigned int image_type, int blks, unsigned int dith_flag) { - mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUV2x2_Blk_Func(image_type=%d, blks=%d, dith_flag=%d)\n", + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "YUV2x2_Blk_Func(image_type=%d, blks=%d, dith_flag=%d)\n", image_type, blks, dith_flag); switch(blks){ case 1: @@ -473,7 +476,7 @@ void *YUV2x2_Map_Func(unsigned int image_type, unsigned int dith_type) { - mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUV2x2_Map_Func('image_type: %d', 'dith_type: %d')", + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "YUV2x2_Map_Func('image_type: %d', 'dith_type: %d')", image_type, dith_type); return((void*)XA_YUV_2x2_clr); } @@ -510,10 +513,12 @@ unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag, unsigned int *map, XA_CHDR *chdr) { - mp_image_t *mpi = (mp_image_t *)image_p; - mp_image_t *image = (mp_image_t *)image_p; + sh_video_t *sh = (sh_video_t*)image_p; + vd_xanim_ctx *priv = sh->context; + mp_image_t *mpi; int y; - int uvstride; + int ystride=(yuv->y_w)?yuv->y_w:imagex; + int uvstride=(yuv->uv_w)?yuv->uv_w:(imagex/4); mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUVTabs: %d %p %p %p %p %p\n",yuv_tabs->Uskip_mask, yuv_tabs->YUV_Y_tab, @@ -529,67 +534,56 @@ yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size, yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h); - if(mpi->imgfmt == IMGFMT_YVU9 && !yuv_tabs->YUV_Y_tab) - { - if(((int)i_x==mpi->width) && ((int)i_y==mpi->height)){ - mpi->planes[0]=yuv->Ybuf; - mpi->planes[1]=yuv->Ubuf; - mpi->planes[2]=yuv->Vbuf; - mpi->stride[0]=i_x; // yuv->y_w - mpi->stride[1]=mpi->stride[2]=i_x/4; // yuv->uv_w - } else { - int y; - for(y=0;y<(int)i_y;y++) - memcpy(mpi->planes[0]+y*mpi->stride[0],yuv->Ybuf+y*i_x,i_x); - i_x>>=2; i_y>>=2; - for(y=0;y<(int)i_y;y++){ - memcpy(mpi->planes[1]+y*mpi->stride[1],yuv->Ubuf+y*i_x,i_x); - memcpy(mpi->planes[2]+y*mpi->stride[2],yuv->Vbuf+y*i_x,i_x); - } - } + if(!yuv_tabs->YUV_Y_tab){ + // standard YVU9 - simply export it! + mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, + sh->disp_w, sh->disp_h); + priv->mpi=mpi; if(!mpi) return; // ERROR! + mpi->planes[0]=yuv->Ybuf; + mpi->planes[1]=yuv->Ubuf; + mpi->planes[2]=yuv->Vbuf; + mpi->width=imagex; + mpi->stride[0]=ystride; //i_x; // yuv->y_w + mpi->stride[1]=mpi->stride[2]=uvstride; //i_x/4; // yuv->uv_w return; } - // copy Y plane: - if(yuv_tabs->YUV_Y_tab){ // dirty hack to detect iv32: - for(y=0;y<(int)(imagey*imagex);y++) - mpi->planes[0][y]=yuv->Ybuf[y]<<1; - } else - memcpy(mpi->planes[0],yuv->Ybuf,imagex*imagey); + // allocate TEMP buffer and convert the image: + mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, + sh->disp_w, sh->disp_h); + priv->mpi=mpi; if(!mpi) return; // ERROR! - // scale U,V planes by 2: + // convert the Y plane: + for(y=0;y<(int)imagey;y++){ + unsigned int x; + unsigned char* s=yuv->Ybuf+ystride*y; + unsigned char* d=mpi->planes[0]+mpi->stride[0]*y; + for(x=0;x<imagex;x++) d[x]=s[x]<<1; + } + imagex>>=2; imagey>>=2; - - uvstride=(yuv->uv_w)?yuv->uv_w:imagex; + // convert the U plane: for(y=0;y<(int)imagey;y++){ - unsigned char *su=yuv->Ubuf+uvstride*y; - unsigned char *sv=yuv->Vbuf+uvstride*y; - unsigned int strideu=mpi->stride[1]; - unsigned int stridev=mpi->stride[2]; - unsigned char *du=mpi->planes[1]+2*y*strideu; - unsigned char *dv=mpi->planes[2]+2*y*stridev; - int x; - if(yuv_tabs->YUV_Y_tab){ // dirty hack to detect iv32: - for(x=0;x<(int)imagex;x++){ - du[2*x]=du[2*x+1]=du[2*x+strideu]=du[2*x+strideu+1]=su[x]*2; - dv[2*x]=dv[2*x+1]=dv[2*x+stridev]=dv[2*x+stridev+1]=sv[x]*2; - } - } else { - for(x=0;x<(int)imagex;x++){ - du[2*x]=du[2*x+1]=du[2*x+strideu]=du[2*x+strideu+1]=su[x]; - dv[2*x]=dv[2*x+1]=dv[2*x+stridev]=dv[2*x+stridev+1]=sv[x]; - } - } + unsigned int x; + unsigned char* s=yuv->Ubuf+uvstride*y; + unsigned char* d=mpi->planes[1]+mpi->stride[1]*y; + for(x=0;x<imagex;x++) d[x]=s[x]<<1; } - return; + // convert the V plane: + for(y=0;y<(int)imagey;y++){ + unsigned int x; + unsigned char* s=yuv->Vbuf+uvstride*y; + unsigned char* d=mpi->planes[2]+mpi->stride[2]*y; + for(x=0;x<imagex;x++) d[x]=s[x]<<1; + } } void *XA_YUV1611_Func(unsigned int image_type) { - mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV1611_Func('image_type: %d')", image_type); + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "XA_YUV1611_Func('image_type: %d')", image_type); return((void *)XA_YUV1611_Convert); } @@ -609,7 +603,7 @@ void *XA_YUV411111_Func(unsigned int image_type) { - mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV411111_Func('image_type: %d')", image_type); + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "XA_YUV411111_Func('image_type: %d')", image_type); return((void*)XA_YUV411111_Convert); } #endif @@ -620,7 +614,13 @@ unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag, unsigned int *map, XA_CHDR *chdr) { - mp_image_t *mpi = (mp_image_t *)image_p; +#if 1 + sh_video_t *sh = (sh_video_t*)image_p; + vd_xanim_ctx *priv = sh->context; + mp_image_t *mpi; + // note: 3ivX codec doesn't set y_w, uv_w, they are random junk :( + int ystride=imagex; //(yuv->y_w)?yuv->y_w:imagex; + int uvstride=imagex/2; //(yuv->uv_w)?yuv->uv_w:(imagex/2); mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV221111_Convert(%p %dx%d %d;%d [%dx%d] %p %p %d %p %p)\n", image_p,imagex,imagey,i_x,i_y, mpi->width,mpi->height, @@ -630,33 +630,21 @@ yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size, yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h); -if(((int)i_x==mpi->width) && ((int)i_y==mpi->height)){ + // standard YV12 - simply export it! + mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h); + priv->mpi=mpi; if(!mpi) return; // ERROR! mpi->planes[0]=yuv->Ybuf; - if(mpi->imgfmt==IMGFMT_YV12){ - mpi->planes[1]=yuv->Ubuf; - mpi->planes[2]=yuv->Vbuf; - } else { - mpi->planes[1]=yuv->Vbuf; - mpi->planes[2]=yuv->Ubuf; - } - mpi->stride[0]=i_x; // yuv->y_w - mpi->stride[1]=mpi->stride[2]=i_x/2; // yuv->uv_w -} else { - int y; - for(y=0;y<(int)i_y;y++) - memcpy(mpi->planes[0]+y*mpi->stride[0],yuv->Ybuf+y*i_x,i_x); - i_x>>=1; i_y>>=1; - for(y=0;y<(int)i_y;y++){ - memcpy(mpi->planes[1]+y*mpi->stride[1],yuv->Ubuf+y*i_x,i_x); - memcpy(mpi->planes[2]+y*mpi->stride[2],yuv->Vbuf+y*i_x,i_x); - } -} - return; + mpi->planes[1]=yuv->Ubuf; + mpi->planes[2]=yuv->Vbuf; + mpi->width=imagex; + mpi->stride[0]=ystride; //i_x; // yuv->y_w + mpi->stride[1]=mpi->stride[2]=uvstride; //=i_x/4; // yuv->uv_w +#endif } void *XA_YUV221111_Func(unsigned int image_type) { - mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV221111_Func('image_type: %d')\n",image_type); + mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "XA_YUV221111_Func('image_type: %d')\n",image_type); return((void *)XA_YUV221111_Convert); } @@ -667,9 +655,6 @@ return CONTROL_UNKNOWN; } -//int xacodec_init_video(sh_video_t *vidinfo, int out_format); -/* out_format = sh->codec->outfmt[sh->codec->outfmtidx]; */ - // init driver static int init(sh_video_t *sh) { @@ -726,16 +711,6 @@ codec_hdr.depth = 12; break; case IMGFMT_YVU9: -#if 0 - if (sh->bih->biCompression == mmioFOURCC('I','V','3','2') || - sh->bih->biCompression == mmioFOURCC('i','v','3','2') || - sh->bih->biCompression == mmioFOURCC('I','V','3','1') || - sh->bih->biCompression == mmioFOURCC('i','v','3','2')) - { - mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supporting YVU9 output with Indeo3\n"); - return(0); - } -#endif codec_hdr.depth = 9; break; default: @@ -794,8 +769,6 @@ free(priv); } -//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); - // unsigned int (*dec_func)(unsigned char *image, unsigned char *delta, // unsigned int dsize, XA_DEC_INFO *dec_info); @@ -803,23 +776,28 @@ static mp_image_t* decode(sh_video_t *sh, void *data, int len, int flags) { vd_xanim_ctx *priv = sh->context; - mp_image_t *mpi; unsigned int ret; if (len <= 0) return NULL; // skipped frame - mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0, - sh->disp_w, sh->disp_h); - if (!mpi) - return NULL; - priv->decinfo->skip_flag = (flags&3)?1:0; - ret = priv->dec_func((uint8_t*)mpi, data, len, priv->decinfo); + if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC){ + // allocate static buffer for cvid-like codecs: + priv->mpi = mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, + MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, + (sh->disp_w+3)&(~3), (sh->disp_h+3)&(~3)); + if (!priv->mpi) return NULL; + ret = priv->dec_func((uint8_t*)priv->mpi, data, len, priv->decinfo); + } else { + // left the buffer allocation to the codecs, pass sh_video && priv + priv->mpi=NULL; + ret = priv->dec_func((uint8_t*)sh, data, len, priv->decinfo); + } if (ret == ACT_DLTA_NORM) - return mpi; + return priv->mpi; if (ret & ACT_DLTA_MAPD) mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "mapd\n"); @@ -836,7 +814,7 @@ if (ret & ACT_DLTA_XOR) { mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "xor\n"); - return mpi; + return priv->mpi; } /* nothing changed */ @@ -866,6 +844,6 @@ return NULL; } - return mpi; + return priv->mpi; } #endif