[MPlayer-dev-eng] [PATCH] nuv on bigendian

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Wed Mar 2 12:21:33 CET 2005


Hi,
On Mon, Feb 21, 2005 at 01:40:09PM +0100, Reimar Döffinger wrote:
> can somebody please test this patch on bigendian and/or comment on it?
> See also http://bugzilla.mplayerhq.hu/show_bug.cgi?id=237

Here's and updated version, I intend to apply tomorrow. It has the
disadvantage that nuv files created with mencoder on bigendian will no longer play - I
hope this wont affect a lot of people, whereas the fact that "normal"
nuv files will also work on bigendian seems more important (also files
created on bigendian with this patch should now play on both big- and
littlendian, but I didn't test that...)
Unfortunately you will still have to use the -fps option on most
bigendian systems, as fps is stored as float and the endianness
conversion routines and the detection whether it is necessary are not
yet in MPlayer...

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/ve_nuv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ve_nuv.c,v
retrieving revision 1.4
diff -u -r1.4 ve_nuv.c
--- libmpcodecs/ve_nuv.c	20 Jan 2005 22:53:37 -0000	1.4
+++ libmpcodecs/ve_nuv.c	22 Feb 2005 14:15:02 -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;
Index: libmpcodecs/native/RTjpegN.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/native/RTjpegN.c,v
retrieving revision 1.8
diff -u -r1.8 RTjpegN.c
--- libmpcodecs/native/RTjpegN.c	4 Feb 2005 18:31:03 -0000	1.8
+++ libmpcodecs/native/RTjpegN.c	22 Feb 2005 14:15:08 -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;
Index: libmpcodecs/native/nuppelvideo.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/native/nuppelvideo.c,v
retrieving revision 1.9
diff -u -r1.9 nuppelvideo.c
--- libmpcodecs/native/nuppelvideo.c	28 Aug 2002 22:45:45 -0000	1.9
+++ libmpcodecs/native/nuppelvideo.c	22 Feb 2005 14:15:18 -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 */
Index: libmpdemux/demux_nuv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_nuv.c,v
retrieving revision 1.11
diff -u -r1.11 demux_nuv.c
--- libmpdemux/demux_nuv.c	30 Sep 2002 21:10:41 -0000	1.11
+++ libmpdemux/demux_nuv.c	22 Feb 2005 14:15:42 -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)
Index: libmpdemux/nuppelvideo.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/nuppelvideo.h,v
retrieving revision 1.1
diff -u -r1.1 nuppelvideo.h
--- libmpdemux/nuppelvideo.h	27 Dec 2001 22:20:15 -0000	1.1
+++ libmpdemux/nuppelvideo.h	22 Feb 2005 14:15:43 -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
+


More information about the MPlayer-dev-eng mailing list