[MPlayer-dev-eng] dr2 implementation thoughts

D Richard Felker III dalias at aerifal.cx
Wed Jul 17 01:55:31 CEST 2002


On Wed, Jul 17, 2002 at 01:20:50AM +0200, Arpi wrote:
> draw_frame() is used for packed formats, like yuy2 and rgb
> 
> anyway, there is put_image() to replace old draw_slice/draw_image pair,
> using mpi struct, but it is not used by vo drivers yet (it's optional, if
> implemented then it's called instead of draw_*)

DOCS/tech/libvo.txt still says draw_slice is mandatory even with
put_image. Is it just outdated, or do some things still depend on
draw_slice?

> > that some filters could be added that do nothing *but* change the mask
> > to mark some macroblocks unconditionally changed. This might (??) be
> > faster than -vop crop for reducing wasted memory bandwidth when there
> hmm
> 
> > are silly black borders to remove -- from my experience the crop
> > filter makes things slower if anything.
> why?

I haven't been able to figure that out -- it doesn't make any sense.
Using libmpeg2 to decode dvds, with mga_vid and -vop crop...

Also, I have something rather strange to report. Earlier today, I
tried hacking mga_common.c to support 'dr method 1' even on g200 by
making fake U/V buffers in memory and interleaving them at page flip
time, but still exporting the real Y buffer. It worked, and libmpeg2
was using it every couple frames (I assume for B frames), but it was
much slower than expected. Even when I disabled the U/V interleaving
at page flip time (so those planes just wouldn't get refreshed on B
frames), it was taking almost twice as much cpu time as without -dr.
I'm attaching the patch in case you or anyone wants to comment on some
stupid mistake I made, but please don't anyone go applying this now,
as it's just experimental!

Rich

-------------- next part --------------
Index: libvo/mga_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/mga_common.c,v
retrieving revision 1.37
diff -u -r1.37 mga_common.c
--- libvo/mga_common.c	10 Jun 2002 18:40:19 -0000	1.37
+++ libvo/mga_common.c	16 Jul 2002 16:48:14 -0000
@@ -14,6 +14,10 @@
 static uint8_t *vid_data, *frames[4];
 static int f = -1;
 
+static int g200hack;
+static uint8_t *fake_dr_buf;
+static uint8_t *fake_dr_p[3];
+
 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){
     int x,y;
     uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31;
@@ -148,6 +152,16 @@
 vo_mga_flip_page(void)
 {
 
+	if (0&&g200hack)
+	{
+		uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31;
+		interleaveBytes(fake_dr_p[1],fake_dr_p[2],
+				vid_data + bespitch*mga_vid_config.src_height,
+				mga_vid_config.src_width/2,
+				mga_vid_config.src_height/2,
+				bespitch/2, bespitch/2, bespitch);
+		g200hack = 0;
+	}
 //    printf("-- flip to %d --\n",mga_next_frame);
 
 #if 1
@@ -183,23 +197,36 @@
 get_image(mp_image_t *mpi){
     uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31;
     uint32_t bespitch2 = bespitch/2;
+    uint8_t *uvbase;
 //    printf("mga: get_image() called\n");
     if(mpi->type==MP_IMGTYPE_STATIC && mga_vid_config.num_frames>1) return VO_FALSE; // it is not static
     if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
-    if(mga_vid_config.card_type == MGA_G200 && mpi->flags&MP_IMGFLAG_PLANAR) return VO_FALSE;
+//    if(mga_vid_config.card_type == MGA_G200 && mpi->flags&MP_IMGFLAG_PLANAR) return VO_FALSE;
 //    printf("width=%d vs. bespitch=%d, flags=0x%X  \n",mpi->width,bespitch,mpi->flags);
     if((mpi->width==bespitch) ||
        (mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){
        // we're lucky or codec accepts stride => ok, let's go!
        if(mpi->flags&MP_IMGFLAG_PLANAR){
 	   mpi->planes[0]=vid_data;
+	   if (mga_vid_config.card_type == MGA_G200) {
+	       uvbase = fake_dr_buf;
+	       g200hack = 1;
+	   } else {
+	       uvbase = vid_data;
+	       g200hack = 0;
+	   }
 	   if(mpi->flags&MP_IMGFLAG_SWAPPED){
-	       mpi->planes[1]=vid_data + bespitch*mga_vid_config.src_height;
+	       mpi->planes[1]=uvbase + bespitch*mga_vid_config.src_height;
 	       mpi->planes[2]=mpi->planes[1] + bespitch2*mga_vid_config.src_height/2;
 	   } else {
-	       mpi->planes[2]=vid_data + bespitch*mga_vid_config.src_height;
+	       mpi->planes[2]=uvbase + bespitch*mga_vid_config.src_height;
 	       mpi->planes[1]=mpi->planes[2] + bespitch2*mga_vid_config.src_height/2;
 	   }
+	   if (g200hack)
+	   {
+	       fake_dr_p[1] = mpi->planes[1];
+	       fake_dr_p[2] = mpi->planes[2];
+	   }
 	   mpi->width=mpi->stride[0]=bespitch;
 	   mpi->stride[1]=mpi->stride[2]=bespitch2;
        } else {
@@ -328,6 +355,7 @@
 	frames[3] = frames[0] + 3*mga_vid_config.frame_size;
 	mga_next_frame = 0;
 	vid_data = frames[mga_next_frame];
+	fake_dr_buf = malloc(mga_vid_config.frame_size); /* FIXME - leak */
 
 	//clear the buffer
 	memset(frames[0],0x80,mga_vid_config.frame_size*mga_vid_config.num_frames);
@@ -339,6 +367,8 @@
 static int mga_uninit(){
 	ioctl( f,MGA_VID_OFF,0 );
 	munmap(frames[0],mga_vid_config.frame_size*mga_vid_config.num_frames);
+	free(fake_dr_buf);
+	fake_dr_buf = 0;
 	close(f);
 	f = -1;
 }


More information about the MPlayer-dev-eng mailing list