[Mplayer-cvslog] CVS: main/libmpcodecs mp_image.h,1.17,1.18 vd_ffmpeg.c,1.41,1.42 vf.c,1.40,1.41 vf_pp.c,1.7,1.8

Arpi of Ize arpi at mplayerhq.hu
Sat Aug 3 00:56:09 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv19280

Modified Files:
	mp_image.h vd_ffmpeg.c vf.c vf_pp.c 
Log Message:
- some reorder/cleanup of mp_image flags
- support for _ACCEPT_ALIGNED_STRIDE && _PREFER_ALIGNED_STRIDE


Index: mp_image.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/mp_image.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- mp_image.h	1 Aug 2002 12:39:07 -0000	1.17
+++ mp_image.h	2 Aug 2002 22:55:53 -0000	1.18
@@ -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:

Index: vd_ffmpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vd_ffmpeg.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- vd_ffmpeg.c	2 Aug 2002 19:38:59 -0000	1.41
+++ vd_ffmpeg.c	2 Aug 2002 22:55:53 -0000	1.42
@@ -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;
 

Index: vf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- vf.c	31 Jul 2002 19:50:42 -0000	1.40
+++ vf.c	2 Aug 2002 22:55:54 -0000	1.41
@@ -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)
 	  {

Index: vf_pp.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_pp.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- vf_pp.c	13 Apr 2002 19:14:31 -0000	1.7
+++ vf_pp.c	2 Aug 2002 22:55:54 -0000	1.8
@@ -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);
     }




More information about the MPlayer-cvslog mailing list