summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-08-02 22:55:54 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-08-02 22:55:54 +0000
commitd010698e430fd93744e560799a51b15abf14247e (patch)
treedff1f2de823bf1135fa83a406e1c600da3477f8b /libmpcodecs
parent9e7622c09fe572ced34d47650231029a34e0d70a (diff)
downloadmpv-d010698e430fd93744e560799a51b15abf14247e.tar.bz2
mpv-d010698e430fd93744e560799a51b15abf14247e.tar.xz
- some reorder/cleanup of mp_image flags
- support for _ACCEPT_ALIGNED_STRIDE && _PREFER_ALIGNED_STRIDE git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6876 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/mp_image.h47
-rw-r--r--libmpcodecs/vd_ffmpeg.c3
-rw-r--r--libmpcodecs/vf.c23
-rw-r--r--libmpcodecs/vf_pp.c9
4 files changed, 59 insertions, 23 deletions
diff --git a/libmpcodecs/mp_image.h b/libmpcodecs/mp_image.h
index df7ae7e1e9..40ee57d57b 100644
--- a/libmpcodecs/mp_image.h
+++ b/libmpcodecs/mp_image.h
@@ -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:
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 61c3856ddd..c210b2c517 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -302,8 +302,7 @@ static void get_buffer(struct AVCodecContext *avctx, int width, int height, int
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;
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index 51aed0f4da..6c26f82103 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -112,7 +112,7 @@ void vf_mpi_clear(mp_image_t* mpi,int x0,int y0,int w,int h){
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 @@ mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype,
}
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 @@ 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!
+
+ // 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)
{
diff --git a/libmpcodecs/vf_pp.c b/libmpcodecs/vf_pp.c
index b1b1d81e8f..3e5e01ec34 100644
--- a/libmpcodecs/vf_pp.c
+++ b/libmpcodecs/vf_pp.c
@@ -71,15 +71,18 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
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);
}