Mercurial > mplayer.hg
changeset 6875:255b150a75a5
- some reorder/cleanup of mp_image flags
- support for _ACCEPT_ALIGNED_STRIDE && _PREFER_ALIGNED_STRIDE
author | arpi |
---|---|
date | Fri, 02 Aug 2002 22:55:54 +0000 |
parents | 58e730c20213 |
children | 49485d9f0d47 |
files | libmpcodecs/mp_image.h libmpcodecs/vd_ffmpeg.c libmpcodecs/vf.c libmpcodecs/vf_pp.c |
diffstat | 4 files changed, 59 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/mp_image.h Fri Aug 02 19:39:37 2002 +0000 +++ b/libmpcodecs/mp_image.h Fri Aug 02 22:55:54 2002 +0000 @@ -1,33 +1,54 @@ #ifndef __MP_IMAGE_H #define __MP_IMAGE_H 1 +//--------- codec's requirements (filled by the codec/vf) --------- + +//--- buffer content restrictions: // set if buffer content shouldn't be modified: #define MP_IMGFLAG_PRESERVE 0x01 // set if buffer content will be READ for next frame's MC: (I/P mpeg frames) #define MP_IMGFLAG_READABLE 0x02 -// set if buffer is allocated (used in destination images): -#define MP_IMGFLAG_ALLOCATED 0x04 -// set if it's in video buffer/memory: -#define MP_IMGFLAG_DIRECT 0x08 + +//--- buffer width/stride/plane restrictions: (used for direct rendering) +// stride _have_to_ be aligned to MB boundary: [for DR restrictions] +#define MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE 0x4 +// stride should be aligned to MB boundary: [for buffer allocation] +#define MP_IMGFLAG_PREFER_ALIGNED_STRIDE 0x8 // codec accept any stride (>=width): #define MP_IMGFLAG_ACCEPT_STRIDE 0x10 -// codec accept any width (width*bpp=stride) (>=width): +// codec accept any width (width*bpp=stride -> stride%bpp==0) (>=width): #define MP_IMGFLAG_ACCEPT_WIDTH 0x20 -// stride should be aligned to 16-byte (MB) boundary: -#define MP_IMGFLAG_ALIGNED_STRIDE 0x40 -// codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2) -#define MP_IMGFLAG_DRAW_CALLBACK 0x80 +//--- for planar formats only: +// uses only stride[0], and stride[1]=stride[2]=stride[0]>>mpi->chroma_x_shift +#define MP_IMGFLAG_COMMON_STRIDE 0x40 +// uses only planes[0], and calculates planes[1,2] from width,height,imgfmt +#define MP_IMGFLAG_COMMON_PLANE 0x80 +#define MP_IMGFLAGMASK_RESTRICTIONS 0xFF + +//--------- color info (filled by mp_image_setfmt() ) ----------- // set if number of planes > 1 #define MP_IMGFLAG_PLANAR 0x100 // set if it's YUV colorspace #define MP_IMGFLAG_YUV 0x200 -// set if it's swapped plane/byteorder +// set if it's swapped (BGR or YVU) plane/byteorder #define MP_IMGFLAG_SWAPPED 0x400 -// type displayed (do not set this flag - it's for internal use!) -#define MP_IMGFLAG_TYPE_DISPLAYED 0x800 // using palette for RGB data -#define MP_IMGFLAG_TYPE_RGB_PALETTE 0x1000 +#define MP_IMGFLAG_RGB_PALETTE 0x800 + +#define MP_IMGFLAGMASK_COLORS 0xF00 + +// codec uses drawing/rendering callbacks (draw_slice()-like thing, DR method 2) +// [the codec will set this flag if it supports callbacks, and the vo _may_ +// clear it in get_image() if draw_slice() not implemented] +#define MP_IMGFLAG_DRAW_CALLBACK 0x1000 +// set if it's in video buffer/memory: [set by vo/vf's get_image() !!!] +#define MP_IMGFLAG_DIRECT 0x2000 +// set if buffer is allocated (used in destination images): +#define MP_IMGFLAG_ALLOCATED 0x4000 + +// buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!) +#define MP_IMGFLAG_TYPE_DISPLAYED 0x8000 // codec doesn't support any form of direct rendering - it has own buffer // allocation. so we just export its buffer pointers:
--- a/libmpcodecs/vd_ffmpeg.c Fri Aug 02 19:39:37 2002 +0000 +++ b/libmpcodecs/vd_ffmpeg.c Fri Aug 02 22:55:54 2002 +0000 @@ -302,8 +302,7 @@ sh_video_t * sh = avctx->opaque; vd_ffmpeg_ctx *ctx = sh->context; mp_image_t* mpi=NULL; -// int flags= MP_IMGFLAG_ALIGNED_STRIDE; - int flags= MP_IMGFLAG_ACCEPT_STRIDE; + int flags= MP_IMGFLAG_ACCEPT_STRIDE | MP_IMGFLAG_PREFER_ALIGNED_STRIDE; int type= MP_IMGTYPE_IPB; int align=15;
--- a/libmpcodecs/vf.c Fri Aug 02 19:39:37 2002 +0000 +++ b/libmpcodecs/vf.c Fri Aug 02 22:55:54 2002 +0000 @@ -112,7 +112,7 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){ mp_image_t* mpi=NULL; - int w2=w; //(mp_imgflag&MP_IMGFLAG_ACCEPT_STRIDE)?((w+15)&(~15)):w; + int w2=(mp_imgflag&MP_IMGFLAG_ACCEPT_ALIGNED_STRIDE)?((w+15)&(~15)):w; if(vf->put_image==vf_next_put_image){ // passthru mode, if the plugin uses the fallback/default put_image() code @@ -148,12 +148,15 @@ } if(mpi){ mpi->type=mp_imgtype; - mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT); - mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH|MP_IMGFLAG_ALIGNED_STRIDE|MP_IMGFLAG_DRAW_CALLBACK); + // keep buffer allocation status & color flags only: +// mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT); + mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS; + // accept restrictions & draw_slice flags only: + mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK); if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK; if((mpi->width!=w2 || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){ - mpi->width=w2; - mpi->height=h; + mpi->width=w2; mpi->chroma_width=w2>>mpi->chroma_x_shift; + mpi->height=h; mpi->chroma_height=h>>mpi->chroma_y_shift; if(mpi->flags&MP_IMGFLAG_ALLOCATED){ // need to re-allocate buffer memory: free(mpi->planes[0]); @@ -168,6 +171,16 @@ if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ // non-direct and not yet allocated image. allocate it! + + // check if codec prefer aligned stride: + if(mp_imgflag&MP_IMGFLAG_PREFER_ALIGNED_STRIDE){ + int align=(mpi->flags&MP_IMGFLAG_PLANAR && + mpi->flags&MP_IMGFLAG_YUV) ? + (8<<mpi->chroma_x_shift)-1 : 15; // -- maybe FIXME + mpi->width=w2=((w+align)&(~align)); + mpi->chroma_width=w2>>mpi->chroma_x_shift; + } + // IF09 - allocate space for 4. plane delta info - unused if (mpi->imgfmt == IMGFMT_IF09) {
--- a/libmpcodecs/vf_pp.c Fri Aug 02 19:39:37 2002 +0000 +++ b/libmpcodecs/vf_pp.c Fri Aug 02 22:55:54 2002 +0000 @@ -71,15 +71,18 @@ if(!(mpi->flags&MP_IMGFLAG_DIRECT)){ // no DR, so get a new image! hope we'll get DR buffer: vf->priv->dmpi=vf_get_image(vf->next,vf->priv->outfmt, - MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ALIGNED_STRIDE, - mpi->w,mpi->h); + MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE, +// MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, +// mpi->w,mpi->h); + (mpi->w+7)&(~7),(mpi->h+7)&(~7)); + vf->priv->dmpi->w=mpi->w; vf->priv->dmpi->h=mpi->h; // display w;h } if(vf->priv->pp || !(mpi->flags&MP_IMGFLAG_DIRECT)){ // do the postprocessing! (or copy if no DR) postprocess(mpi->planes,mpi->stride[0], vf->priv->dmpi->planes,vf->priv->dmpi->stride[0], - mpi->w,mpi->h, + (mpi->w+7)&(~7),mpi->h, mpi->qscale, mpi->qstride, vf->priv->pp); }