changeset 14896:9ddae5897422

Make nuv files work on bigendian (but old nuv files created with mencoder wont play anymore - before they would have worked with mplayer on be)
author reimar
date Thu, 03 Mar 2005 10:19:56 +0000
parents 7515d2e33076
children cc02417dbf22
files libmpcodecs/native/RTjpegN.c libmpcodecs/native/nuppelvideo.c libmpcodecs/ve_nuv.c libmpdemux/demux_nuv.c libmpdemux/nuppelvideo.h
diffstat 5 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/native/RTjpegN.c	Thu Mar 03 07:54:50 2005 +0000
+++ b/libmpcodecs/native/RTjpegN.c	Thu Mar 03 10:19:56 2005 +0000
@@ -31,6 +31,7 @@
 #define MMX
 #endif
 
+#include "bswap.h"
 #include "RTjpegN.h"
 
 #ifdef MMX
@@ -2820,9 +2821,9 @@
  RTjpeg_quant_init();
 
  for(i=0; i<64; i++)
-  buf[i]=RTjpeg_liqt[i];
+  buf[i]=le2me_32(RTjpeg_liqt[i]);
  for(i=0; i<64; i++)
-  buf[64+i]=RTjpeg_ciqt[i];
+  buf[64+i]=le2me_32(RTjpeg_ciqt[i]);
 }
 
 void RTjpeg_init_decompress(__u32 *buf, int width, int height)
@@ -2840,8 +2841,8 @@
 
  for(i=0; i<64; i++)
  {
-  RTjpeg_liqt[i]=buf[i];
-  RTjpeg_ciqt[i]=buf[i+64];
+  RTjpeg_liqt[i]=le2me_32(buf[i]);
+  RTjpeg_ciqt[i]=le2me_32(buf[i+64]);
  }
 
  RTjpeg_lb8=0;
--- a/libmpcodecs/native/nuppelvideo.c	Thu Mar 03 07:54:50 2005 +0000
+++ b/libmpcodecs/native/nuppelvideo.c	Thu Mar 03 10:19:56 2005 +0000
@@ -13,6 +13,7 @@
 
 #include "config.h"
 #include "mp_msg.h"
+#include "bswap.h"
 
 #include "../../libvo/fastmemcpy.h"
 
@@ -37,6 +38,7 @@
 //	printf("frametype: %c, comtype: %c, encoded_size: %d, width: %d, height: %d\n",
 //	    encodedh->frametype, encodedh->comptype, encoded_size, width, height);
 
+	le2me_rtframeheader(encodedh);
 	switch(encodedh->frametype)
 	{
 	    case 'D':	/* additional data for compressors */
--- a/libmpcodecs/ve_nuv.c	Thu Mar 03 07:54:50 2005 +0000
+++ b/libmpcodecs/ve_nuv.c	Thu Mar 03 10:19:56 2005 +0000
@@ -116,6 +116,7 @@
     ench->comptype  = 'R'; // compressor data for RTjpeg
     ench->packetlength = 128*sizeof(long int);
   
+    le2me_rtframeheader(ench);
     mux_v->buffer=vf->priv->buffer;
     muxer_write_chunk(mux_v,FRAMEHEADERSIZE + 128*sizeof(long int), 0x10);
     vf->priv->tbl_wrote = 1;
@@ -172,6 +173,7 @@
     
   ench->frametype = 'V'; // video frame
   ench->packetlength = len;
+  le2me_rtframeheader(ench);
   mux_v->buffer=(void*)ench;
   muxer_write_chunk(mux_v, len + FRAMEHEADERSIZE, 0x10);
   return 1;
--- a/libmpdemux/demux_nuv.c	Thu Mar 03 07:54:50 2005 +0000
+++ b/libmpdemux/demux_nuv.c	Thu Mar 03 10:19:56 2005 +0000
@@ -69,6 +69,7 @@
 		{	
 			if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader))
 				return; /* EOF */
+			le2me_rtframeheader(&rtjpeg_frameheader);
 
 			if ( rtjpeg_frameheader.frametype == 'V' ) 
 			{
@@ -145,6 +146,7 @@
 	demuxer->filepos = orig_pos = stream_tell ( demuxer->stream );
 	if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader))
 	    return 0; /* EOF */
+	le2me_rtframeheader(&rtjpeg_frameheader);
 
 #if 0
 	printf("NUV frame: frametype: %c, comptype: %c, packetlength: %d\n",
@@ -218,6 +220,7 @@
 	stream_seek(demuxer->stream, 0);
 
 	stream_read ( demuxer->stream, (char*)& rtjpeg_fileheader, sizeof(rtjpeg_fileheader) );
+	le2me_rtfileheader(&rtjpeg_fileheader);
 
 	/* no video */
 	if (rtjpeg_fileheader.videoblocks == 0)
--- a/libmpdemux/nuppelvideo.h	Thu Mar 03 07:54:50 2005 +0000
+++ b/libmpdemux/nuppelvideo.h	Thu Mar 03 10:19:56 2005 +0000
@@ -90,3 +90,23 @@
     unsigned char *buffer_offset;
 } audbuffertyp;
 
+#ifdef WORDS_BIGENDIAN
+#define le2me_rtfileheader(h) {					\
+    (h)->width = le2me_32((h)->width);				\
+    (h)->height = le2me_32((h)->height);			\
+    (h)->desiredwidth = le2me_32((h)->desiredwidth);		\
+    (h)->desiredheight = le2me_32((h)->desiredheight);		\
+    (h)->videoblocks = le2me_32((h)->videoblocks);		\
+    (h)->audioblocks = le2me_32((h)->audioblocks);		\
+    (h)->textsblocks = le2me_32((h)->textsblocks);		\
+    (h)->keyframedist = le2me_32((h)->keyframedist);		\
+  }
+#define le2me_rtframeheader(h) {				\
+    (h)->timecode = le2me_32((h)->timecode);			\
+    (h)->packetlength = le2me_32((h)->packetlength);		\
+  }
+#else
+#define le2me_rtfileheader(h) /**/
+#define le2me_rtframeheader(h) /**/
+#endif
+