[MPlayer-cvslog] CVS: main/libvo gl_common.c, 1.36, 1.37 gl_common.h, 1.23, 1.24 vo_gl.c, 1.112, 1.113 vo_gl2.c, 1.85, 1.86

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sun Dec 18 13:04:10 CET 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libvo
In directory mail:/var2/tmp/cvs-serv24917

Modified Files:
	gl_common.c gl_common.h vo_gl.c vo_gl2.c 
Log Message:
support negative stride (flipping) in vo_gl.


Index: gl_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/gl_common.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- gl_common.c	6 Dec 2005 22:23:06 -0000	1.36
+++ gl_common.c	18 Dec 2005 12:04:08 -0000	1.37
@@ -493,6 +493,10 @@
   if (w <= 0 || h <= 0) return;
   if (slice <= 0)
     slice = h;
+  if (stride < 0) {
+    data += h * stride;
+    stride = -stride;
+  }
   // this is not always correct, but should work for MPlayer
   glAdjustAlignment(stride);
   glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / glFmt2bpp(format, type));
@@ -910,16 +914,21 @@
  * \param sy height of texture in pixels
  * \param rect_tex whether this texture uses texture_rectangle extension
  * \param is_yv12 if set, also draw the textures from units 1 and 2
+ * \param flip flip the texture upside down
  * \ingroup gltexture
  */
 void glDrawTex(GLfloat x, GLfloat y, GLfloat w, GLfloat h,
                GLfloat tx, GLfloat ty, GLfloat tw, GLfloat th,
-               int sx, int sy, int rect_tex, int is_yv12) {
+               int sx, int sy, int rect_tex, int is_yv12, int flip) {
   GLfloat tx2 = tx / 2, ty2 = ty / 2, tw2 = tw / 2, th2 = th / 2;
   if (!rect_tex) {
     tx /= sx; ty /= sy; tw /= sx; th /= sy;
     tx2 = tx, ty2 = ty, tw2 = tw, th2 = th;
   }
+  if (flip) {
+    y += h;
+    h = -h;
+  }
   glBegin(GL_QUADS);
   glTexCoord2f(tx, ty);
   if (is_yv12) {

Index: gl_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/gl_common.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- gl_common.h	6 Dec 2005 22:23:06 -0000	1.23
+++ gl_common.h	18 Dec 2005 12:04:08 -0000	1.24
@@ -196,7 +196,7 @@
                  int x, int y, int w, int h, int slice);
 void glDrawTex(GLfloat x, GLfloat y, GLfloat w, GLfloat h,
                GLfloat tx, GLfloat ty, GLfloat tw, GLfloat th,
-               int sx, int sy, int rect_tex, int is_yv12);
+               int sx, int sy, int rect_tex, int is_yv12, int flip);
 
 /** \addtogroup glconversion
   * \{ */

Index: vo_gl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -r1.112 -r1.113
--- vo_gl.c	7 Dec 2005 15:56:27 -0000	1.112
+++ vo_gl.c	18 Dec 2005 12:04:08 -0000	1.113
@@ -90,6 +90,7 @@
 
 static int texture_width;
 static int texture_height;
+static int mpi_flipped;
 
 static unsigned int slice_height = 1;
 
@@ -473,12 +474,12 @@
   // render alpha
   glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
   BindTexture(gl_target, osdatex[osdtexCnt]);
-  glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0);
+  glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
 #endif
   // render OSD
   glBlendFunc (GL_ONE, GL_ONE);
   BindTexture(gl_target, osdtex[osdtexCnt]);
-  glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0);
+  glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
   glEndList();
 
   osdtexCnt++;
@@ -508,7 +509,7 @@
   glDrawTex(0, 0, image_width, image_height,
             0, 0, image_width, image_height,
             texture_width, texture_height,
-            use_rectangle == 1, image_format == IMGFMT_YV12);
+            use_rectangle == 1, image_format == IMGFMT_YV12, mpi_flipped);
   if (image_format == IMGFMT_YV12)
     glDisableYUVConversion(gl_target, use_yuv);
 
@@ -544,6 +545,7 @@
 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
 static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
 {
+  mpi_flipped = (stride[0] < 0);
   glUploadTex(gl_target, gl_format, gl_type, src[0], stride[0],
               x, y, w, h, slice_height);
   if (image_format == IMGFMT_YV12) {
@@ -612,6 +614,7 @@
     UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
     slice = 0; // always "upload" full texture
   }
+  mpi_flipped = (mpi->stride[0] < 0);
   glUploadTex(gl_target, gl_format, gl_type, data, mpi->stride[0],
               mpi->x, mpi->y, mpi->w, mpi->h, slice);
   if (mpi->imgfmt == IMGFMT_YV12) {

Index: vo_gl2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl2.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- vo_gl2.c	7 Dec 2005 15:56:27 -0000	1.85
+++ vo_gl2.c	18 Dec 2005 12:04:08 -0000	1.86
@@ -531,7 +531,8 @@
 
       glDrawTex(square->fx, square->fy, square->fw, square->fh,
                 0, 0, texture_width, texture_height,
-                texture_width, texture_height, 0, image_format == IMGFMT_YV12);
+                texture_width, texture_height,
+                0, image_format == IMGFMT_YV12, 0);
       square++;
     } /* for all texnumx */
   } /* for all texnumy */




More information about the MPlayer-cvslog mailing list