[xiph-cvs] cvs commit: theora/lib toplevel.c

Ralph Giles giles at xiph.org
Sun Oct 26 09:42:21 PST 2003



giles       03/10/26 12:42:21

  Modified:    lib      toplevel.c
  Log:
  Quick implementation of the image flip required for lossless transcode
  compatibility with VP3. THIS IS AN INCOMPATIBLE BITSTREAM CHANGE. Not
  really, but alpha 2 theora players and encoders will see the video as
  upside down.
  
  In theora_encode_YUVin() we invert the image as we copy it to our
  internal buffer. However, in theora_decode_YUVout() I've just inverted
  the row pointer. If there's a better way to do this, please let me know;
  I'd be much happier returning an inverted buffer. Perhaps this can be
  done as part of the post-process step, at the expense of always
  requiring at least one pp pass?

Revision  Changes    Path
1.30      +16 -5     theora/lib/toplevel.c

Index: toplevel.c
===================================================================
RCS file: /usr/local/cvsroot/theora/lib/toplevel.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- toplevel.c	21 Oct 2003 22:12:37 -0000	1.29
+++ toplevel.c	26 Oct 2003 17:42:20 -0000	1.30
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function:
-  last mod: $Id: toplevel.c,v 1.29 2003/10/21 22:12:37 giles Exp $
+  last mod: $Id: toplevel.c,v 1.30 2003/10/26 17:42:20 giles Exp $
 
  ********************************************************************/
 
@@ -934,31 +934,34 @@
 
 
   /* Copy over input YUV to internal YUV buffers. */
+  /* we invert the image for backward compatibility with VP3 */
   /* First copy over the Y data */
-  LocalDataPtr = cpi->yuv1ptr;
+  LocalDataPtr = cpi->yuv1ptr + yuv->y_width*(yuv->y_height - 1);
   InputDataPtr = yuv->y;
   for ( i = 0; i < yuv->y_height; i++ ){
     memcpy( LocalDataPtr, InputDataPtr, yuv->y_width );
-    LocalDataPtr += yuv->y_width;
+    LocalDataPtr -= yuv->y_width;
     InputDataPtr += yuv->y_stride;
   }
 
   /* Now copy over the U data */
   LocalDataPtr = &cpi->yuv1ptr[(yuv->y_height * yuv->y_width)];
+  LocalDataPtr += yuv->uv_width*(yuv->uv_height - 1);
   InputDataPtr = yuv->u;
   for ( i = 0; i < yuv->uv_height; i++ ){
     memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
-    LocalDataPtr += yuv->uv_width;
+    LocalDataPtr -= yuv->uv_width;
     InputDataPtr += yuv->uv_stride;
   }
 
   /* Now copy over the V data */
   LocalDataPtr =
     &cpi->yuv1ptr[((yuv->y_height*yuv->y_width)*5)/4];
+  LocalDataPtr += yuv->uv_width*(yuv->uv_height - 1);
   InputDataPtr = yuv->v;
   for ( i = 0; i < yuv->uv_height; i++ ){
     memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
-    LocalDataPtr += yuv->uv_width;
+    LocalDataPtr -= yuv->uv_width;
     InputDataPtr += yuv->uv_stride;
   }
 
@@ -1408,6 +1411,14 @@
     yuv->u = &pbi->LastFrameRecon[pbi->ReconUDataOffset];
     yuv->v = &pbi->LastFrameRecon[pbi->ReconVDataOffset];
   }
+  
+  /* we must flip the internal representation,
+     so make the stride negative and start at the end */
+  yuv->y += yuv->y_stride * (yuv->y_height - 1);
+  yuv->u += yuv->uv_stride * (yuv->uv_height - 1);
+  yuv->v += yuv->uv_stride * (yuv->uv_height - 1);
+  yuv->y_stride = - yuv->y_stride;
+  yuv->uv_stride = - yuv->uv_stride;
 
   return 0;
 }

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list