Re: mjpegtools patch for better support of Solaris and Sun Studio

Milan Jurik <[email protected]> Fri, 18 Sep 2009 19:36:53 +0200
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <1253295413.2478.71.camel@localhost>
Hi,

Gernot Ziegler píše v pá 18. 09. 2009 v 19:25 +0200:
> Hej Milan,
> 
> thank you for your contribution! I am not actively participating in the 
> developement anymore, but have forwarded your patch to the developer 
> mailing list. :-)
> 

It seems the patches were lost during forward, so I attached them. Thank
you info :-)

Bets regards,

Milan

> /Gernot
> 
> > Hi,
> >
> > based on my limited set of C++, I created attached set of patches which
> > enables Solaris/Sun Studio support.
> >
> > mjpegtools-01-progname.diff - no ideal support for missing __progname
> > mjpegtools-02-alloca.diff - <alloca.h> missing
> >
> > mjpegtools-04-suncc.diff
> > - std:: used for std namespace functions
> > - sizeof with non-constant array size is not supported
> > - const char * were needed
> > - SetRegion2D was not visible in some templates
> >
> > I know these patches are not ideal but it can be inspiration for better
> > Solaris support and nothing is in collision with GCC.
> >
> > Best regards,
> >
> > Milan
> >
> 
> Servus,
>    Gernot
> 
> GPU. 3D Vision. Europe. Future. Now.
> Drop by: www.mpi-sb.mpg.de/~gziegler - www.geofront.eu
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf

_______________________________________________
Mjpeg-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mjpeg-developer
mjpegtools-01-progname.diff (text/x-patch, 2.7 KB)
diff -Nar -U1 mjpegtools-1.9.0/lavtools/y4mstabilizer.c mjpegtools-1.9.0-patch/lavtools/y4mstabilizer.c
--- mjpegtools-1.9.0/lavtools/y4mstabilizer.c	2009-09-09 12:30:22.756035743 +0200
+++ mjpegtools-1.9.0-patch/lavtools/y4mstabilizer.c	2009-09-09 12:32:45.316513341 +0200
@@ -60,3 +60,7 @@
 
+#ifdef HAVE___PROGNAME
 extern  char    *__progname;
+#else
+char    *__progname="y4mstabilizer";
+#endif
 
diff -Nar -U1 mjpegtools-1.9.0/y4munsharp/y4munsharp.c mjpegtools-1.9.0-patch/y4munsharp/y4munsharp.c
--- mjpegtools-1.9.0/y4munsharp/y4munsharp.c	2009-09-09 12:30:22.551732672 +0200
+++ mjpegtools-1.9.0-patch/y4munsharp/y4munsharp.c	2009-09-09 12:36:33.040539836 +0200
@@ -48,3 +48,7 @@
 
+#ifdef HAVE___PROGNAME
 extern char *__progname;
+#else
+char    *__progname="y4munsharp";
+#endif
 
diff -Nar -U1 mjpegtools-1.9.0/y4mutils/yuv4mpeg.c mjpegtools-1.9.0-patch/y4mutils/yuv4mpeg.c
--- mjpegtools-1.9.0/y4mutils/yuv4mpeg.c	2009-09-09 12:30:22.848960405 +0200
+++ mjpegtools-1.9.0-patch/y4mutils/yuv4mpeg.c	2009-09-09 12:43:30.526280051 +0200
@@ -58,3 +58,7 @@
 
+#ifdef HAVE___PROGNAME
 extern	char	*__progname;
+#else
+char    *__progname="yuv4mpeg";
+#endif
 
diff -Nar -U1 mjpegtools-1.9.0/y4mutils/yuyvtoy4m.c mjpegtools-1.9.0-patch/y4mutils/yuyvtoy4m.c
--- mjpegtools-1.9.0/y4mutils/yuyvtoy4m.c	2009-09-09 12:30:22.840808078 +0200
+++ mjpegtools-1.9.0-patch/y4mutils/yuyvtoy4m.c	2009-09-09 12:37:28.137731562 +0200
@@ -40,3 +40,7 @@
 
+#ifdef HAVE___PROGNAME
 extern	char	*__progname;
+#else
+char    *__progname="yuyvtoy4m";
+#endif
 
diff -Nar -U1 mjpegtools-1.9.0/y4mutils/y4mblack.c mjpegtools-1.9.0-patch/y4mutils/y4mblack.c
--- mjpegtools-1.9.0/y4mutils/y4mblack.c	2009-09-09 12:30:22.847414530 +0200
+++ mjpegtools-1.9.0-patch/y4mutils/y4mblack.c	2009-09-09 12:41:38.603770141 +0200
@@ -17,3 +17,7 @@
 
+#ifdef HAVE___PROGNAME
 extern	char	*__progname;
+#else
+char   *__progname="y4mblack";
+#endif
 
diff -Nar -U1 mjpegtools-1.9.0/y4mutils/y4mshift.c mjpegtools-1.9.0-patch/y4mutils/y4mshift.c
--- mjpegtools-1.9.0/y4mutils/y4mshift.c	2009-09-09 12:30:22.841383810 +0200
+++ mjpegtools-1.9.0-patch/y4mutils/y4mshift.c	2009-09-09 12:38:22.767292691 +0200
@@ -24,3 +24,7 @@
 
+#ifdef HAVE___PROGNAME
 extern  char    *__progname;
+#else
+char    *__progname="y4mshift";
+#endif
 
diff -Nar -U1 mjpegtools-1.9.0/y4mutils/y4mspatialfilter.c mjpegtools-1.9.0-patch/y4mutils/y4mspatialfilter.c
--- mjpegtools-1.9.0/y4mutils/y4mspatialfilter.c	2009-09-09 12:30:22.848053200 +0200
+++ mjpegtools-1.9.0-patch/y4mutils/y4mspatialfilter.c	2009-09-09 12:42:21.205860714 +0200
@@ -23,3 +23,7 @@
 
+#ifdef HAVE___PROGNAME
 extern  char    *__progname;
+#else
+char    *__progname="y4mspatialfilter";
+#endif
mjpegtools-02-alloca.diff (text/x-patch, 479 B)
diff -ur mjpegtools-1.8.0-orig/y4mdenoise/SearchBorder.hh mjpegtools-1.8.0/y4mdenoise/SearchBorder.hh
--- mjpegtools-1.8.0-orig/y4mdenoise/SearchBorder.hh	2004-04-28 03:45:56.000000000 +0700
+++ mjpegtools-1.8.0/y4mdenoise/SearchBorder.hh	2006-11-24 13:51:30.479482271 +0700
@@ -12,6 +12,9 @@
 #include "Limits.hh"
 #include "DoublyLinkedList.hh"
 #include "SetRegion2D.hh"
+#ifdef sun
+#include <alloca.h>
+#endif
 
 // HACK: for development error messages.
 #include <stdio.h>
mjpegtools-04-suncc.diff (text/x-patch, 4 KB)
--- mjpegtools-1.9.0/mpeg2enc/elemstrmwriter.cc	2009-09-09 14:55:48.227859416 +0200
+++ mjpegtools-1.9.0-patch/mpeg2enc/elemstrmwriter.cc	2009-09-09 14:58:10.536534281 +0200
@@ -77,7 +77,7 @@
 void ElemStrmFragBuf::AdjustBuffer()
 {
 	buffer_size *= 2;
-	buffer = static_cast<uint8_t *>(realloc( buffer, sizeof(uint8_t[buffer_size])));
+	buffer = static_cast<uint8_t *>(realloc( buffer, sizeof(uint8_t) * buffer_size));
 	if( !buffer )
 		mjpeg_error_exit1( "output buffer memory allocation: out of memory" );
 }
--- mjpegtools-1.9.0/mplex/lpcmstrm_in.cpp	Wed Sep  9 15:04:35 2009
+++ mjpegtools-1.9.0-patch/mplex/lpcmstrm_in.cpp	Wed Sep  9 15:04:59 2009
@@ -53,7 +53,7 @@
 
 bool LPCMStream::Probe(IBitStream &bs )
 {
-    char *last_dot = strrchr( bs.StreamName(), '.' );
+    const char *last_dot = strrchr( bs.StreamName(), '.' );
     return 
         last_dot != NULL 
         && strcmp( last_dot+1, "lpcm") == 0;
--- mjpegtools-1.9.0/yuvdeinterlace/yuvdeinterlace.cc	Wed Sep  9 16:28:34 2009
+++ mjpegtools-1.9.0-patch/yuvdeinterlace/yuvdeinterlace.cc	Wed Sep  9 16:33:18 2009
@@ -169,2 +169,2 @@
-    memcpy (in0 - w, in + w, w);
-    memcpy (in0 + (w * h), in + (w * h) - 2 * w, w);
+    std::memcpy (in0 - w, in + w, w);
+    std::memcpy (in0 + (w * h), in + (w * h) - 2 * w, w);
@@ -282,1 +282,1 @@
-      memcpy (scratch + w * (h - 1), in0 + w * (h - 1), w);
+      std::memcpy (scratch + w * (h - 1), in0 + w * (h - 1), w);
@@ -294,3 +294,3 @@
-    memcpy (out - w, out, w);
-    memcpy (out - w * 2, out, w);
-    memcpy (out - w * 3, out, w);
+    std::memcpy (out - w, out, w);
+    std::memcpy (out - w * 2, out, w);
+    std::memcpy (out - w * 3, out, w);
@@ -298,4 +298,4 @@
-    memcpy (out + (w * h), out + (w * h) - w, w);
-    memcpy (out + (w * h) + w, out + (w * h) - w, w);
-    memcpy (out + (w * h) + w * 2, out + (w * h) - w, w);
-    memcpy (out + (w * h) + w * 3, out + (w * h) - w, w);
+    std::memcpy (out + (w * h), out + (w * h) - w, w);
+    std::memcpy (out + (w * h) + w, out + (w * h) - w, w);
+    std::memcpy (out + (w * h) + w * 2, out + (w * h) - w, w);
+    std::memcpy (out + (w * h) + w * 3, out + (w * h) - w, w);
@@ -303,5 +303,5 @@
-    memcpy (scratch - w, scratch, w);
-    memcpy (scratch - w * 2, scratch, w);
-    memcpy (scratch - w * 3, scratch, w);
-    memcpy (scratch - w * 4, scratch, w);
-    memset (scratch - w * 4 - 4, scratch[0], 4);
+    std::memcpy (scratch - w, scratch, w);
+    std::memcpy (scratch - w * 2, scratch, w);
+    std::memcpy (scratch - w * 3, scratch, w);
+    std::memcpy (scratch - w * 4, scratch, w);
+    std::memset (scratch - w * 4 - 4, scratch[0], 4);
@@ -309,5 +309,5 @@
-    memcpy (scratch + (w * h), scratch + (w * h) - w, w);
-    memcpy (scratch + (w * h) + w, scratch + (w * h) - w, w);
-    memcpy (scratch + (w * h) + w * 2, scratch + (w * h) - w, w);
-    memcpy (scratch + (w * h) + w * 3, scratch + (w * h) - w, w);
-    memset (scratch + (w * h) + w * 4, scratch[w * h - 1], 11);
+    std::memcpy (scratch + (w * h), scratch + (w * h) - w, w);
+    std::memcpy (scratch + (w * h) + w, scratch + (w * h) - w, w);
+    std::memcpy (scratch + (w * h) + w * 2, scratch + (w * h) - w, w);
+    std::memcpy (scratch + (w * h) + w * 3, scratch + (w * h) - w, w);
+    std::memset (scratch + (w * h) + w * 4, scratch[w * h - 1], 11);
@@ -677,1 +677,1 @@
-    memcpy (out, scratch, w * h);
+    std::memcpy (out, scratch, w * h);
--- mjpegtools-1.9.0/y4mdenoise/Allocator.hh	2009-09-09 17:07:52.073523962 +0200
+++ mjpegtools-1.9.0-patch/y4mdenoise/Allocator.hh	2009-09-09 17:08:44.516680971 +0200
@@ -40,7 +40,7 @@
 	public:
 		Chunk *m_pNext;
 			// The next allocated chunk.
-		char m_aSpace[];
+		char *m_aSpace;
 			// The memory to divide up.
 	};
 
--- mjpegtools-1.9.0/y4mdenoise/SetRegion2D.hh	2009-09-09 17:15:28.800215909 +0200
+++ mjpegtools-1.9.0-patch/y4mdenoise/SetRegion2D.hh	2009-09-09 17:14:32.849631594 +0200
@@ -212,7 +212,7 @@
 template <class INDEX, class SIZE>
 class SetRegion2D<INDEX,SIZE>::FloodFillControl
 {
-private:
+public:
 	typedef SetRegion2D<INDEX,SIZE> Region_t;
 		// Keep track of our region class.
 public: