[MPlayer-dev-eng] [PATCH] fixes for gcc4

Gianluigi Tiesi mplayer at netfarm.it
Thu Feb 24 19:15:49 CET 2005


I've added some fixes to compile mplayer with gcc4, anyway they are even
nonsenses like asm memory addressing of a binary operation of two vars.
There are some stuff should be fixed like includes in libavcodec,
gcc4 seams to not like struct AVOption without a type if used not as
pointer (also this seams reasonable to me).
The patch is splitted in two part, libavcodec and mplayer.
I don't like much the way I've patched common.h and avcodec.h, feel free
to find a better way.

I'm also in doubt with:
extern struct STRTAB chanlist_names[];
that I've changed in:
extern struct CHANLISTS   chanlist_names[];

I cannot found STRTAB anyway in the source ;(
I've no clue to compile libmpcodecs/native/RTjpegN.c with gcc4, it
complains for a wrong operand in mmx (?) instructions.

Bye
-- 
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
-------------- next part --------------
Index: avcodec.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/avcodec.h,v
retrieving revision 1.377
diff -u -r1.377 avcodec.h
--- avcodec.h	24 Feb 2005 15:18:02 -0000	1.377
+++ avcodec.h	24 Feb 2005 18:07:14 -0000
@@ -11,6 +11,42 @@
 extern "C" {
 #endif
 
+#include <inttypes.h>
+/**
+ * AVOption.
+ */
+typedef struct AVOption {
+    /** options' name */
+    const char *name; /* if name is NULL, it indicates a link to next */
+    /** short English text help or const struct AVOption* subpointer */
+    const char *help; //        const struct AVOption* sub;
+    /** offset to context structure where the parsed value should be stored */
+    int offset;
+    /** options' type */
+    int type;
+#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
+#define FF_OPT_TYPE_DOUBLE 2    ///< double
+#define FF_OPT_TYPE_INT 3       ///< integer
+#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
+#define FF_OPT_TYPE_MASK 0x1f   ///< mask for types - upper bits are various flags
+//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
+#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
+#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
+    /** min value  (min == max   ->  no limits) */
+    double min;
+    /** maximum value for double/int */
+    double max;
+    /** default boo [0,1]l/double/int value */
+    double defval;
+    /**
+     * default string value (with optional semicolon delimited extra option-list
+     * i.e.   option1;option2;option3
+     * defval might select other then first argument as default
+     */
+    const char *defstr;
+#define FF_OPT_MAX_DEPTH 10
+} AVOption;
+
 #include "common.h"
 #include "rational.h"
 #include <sys/types.h> /* size_t */
@@ -1781,41 +1817,6 @@
 
 
 /**
- * AVOption.
- */
-typedef struct AVOption {
-    /** options' name */
-    const char *name; /* if name is NULL, it indicates a link to next */
-    /** short English text help or const struct AVOption* subpointer */
-    const char *help; //	const struct AVOption* sub;
-    /** offset to context structure where the parsed value should be stored */
-    int offset;
-    /** options' type */
-    int type;
-#define FF_OPT_TYPE_BOOL 1      ///< boolean - true,1,on  (or simply presence)
-#define FF_OPT_TYPE_DOUBLE 2    ///< double
-#define FF_OPT_TYPE_INT 3       ///< integer
-#define FF_OPT_TYPE_STRING 4    ///< string (finished with \0)
-#define FF_OPT_TYPE_MASK 0x1f	///< mask for types - upper bits are various flags
-//#define FF_OPT_TYPE_EXPERT 0x20 // flag for expert option
-#define FF_OPT_TYPE_FLAG (FF_OPT_TYPE_BOOL | 0x40)
-#define FF_OPT_TYPE_RCOVERRIDE (FF_OPT_TYPE_STRING | 0x80)
-    /** min value  (min == max   ->  no limits) */
-    double min;
-    /** maximum value for double/int */
-    double max;
-    /** default boo [0,1]l/double/int value */
-    double defval;
-    /**
-     * default string value (with optional semicolon delimited extra option-list
-     * i.e.   option1;option2;option3
-     * defval might select other then first argument as default
-     */
-    const char *defstr;
-#define FF_OPT_MAX_DEPTH 10
-} AVOption;
-
-/**
  * Parse option(s) and sets fields in passed structure
  * @param strct	structure where the parsed results will be written
  * @param list  list with AVOptions
Index: common.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/common.h,v
retrieving revision 1.145
diff -u -r1.145 common.h
--- common.h	12 Jan 2005 01:44:01 -0000	1.145
+++ common.h	24 Feb 2005 18:07:14 -0000
@@ -6,6 +6,8 @@
 #ifndef COMMON_H
 #define COMMON_H
 
+#include "avcodec.h"
+
 #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
 #    define CONFIG_WIN32
 #endif
@@ -54,7 +56,6 @@
 #define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
 #define AVOPTION_END() AVOPTION_SUB(NULL)
 
-struct AVOption;
 #ifdef HAVE_MMX
 extern const struct AVOption avoptions_common[3 + 5];
 #else
Index: libpostproc/postprocess_template.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/libpostproc/postprocess_template.c,v
retrieving revision 1.92
diff -u -r1.92 postprocess_template.c
--- libpostproc/postprocess_template.c	12 Oct 2004 07:16:14 -0000	1.92
+++ libpostproc/postprocess_template.c	24 Feb 2005 18:07:14 -0000
@@ -2646,7 +2646,7 @@
  * accurate deblock filter
  */
 static always_inline void RENAME(do_a_deblock)(uint8_t *src, int step, int stride, PPContext *c){
-	int64_t dc_mask, eq_mask;
+	int64_t dc_mask, eq_mask, mask;
 	int64_t sums[10*8*2];
 	src+= step*3; // src points to begin of the 8x8 Block
 //START_TIMER
@@ -2897,6 +2897,7 @@
 		);
 
 		src+= step; // src points to begin of the 8x8 Block
+		mask = dc_mask & eq_mask;
 
 		asm volatile(
 		"movq %4, %%mm6					\n\t"
@@ -2930,7 +2931,7 @@
 		" js 1b						\n\t"
 
 		: "+r"(offset), "+r"(temp_sums)
-		: "r" ((long)step), "r"(src - offset), "m"(dc_mask & eq_mask)
+		: "r" ((long)step), "r"(src - offset), "m"(mask)
 		);
 	}else
 		src+= step; // src points to begin of the 8x8 Block
-------------- next part --------------
Index: liba52/imdct.c
===================================================================
RCS file: /cvsroot/mplayer/main/liba52/imdct.c,v
retrieving revision 1.25
diff -u -r1.25 imdct.c
--- liba52/imdct.c	26 Apr 2004 19:47:50 -0000	1.25
+++ liba52/imdct.c	24 Feb 2005 18:08:23 -0000
@@ -931,9 +931,13 @@
 	);
 
     /* 4-7. iterations */
+    static complex_t *buf2;
+    static two_m_plus_one_sh;
     for (m=3; m < 7; m++) {
 	two_m = (1 << m);
 	two_m_plus_one = two_m<<1;
+	buf2 = buf+128;
+	two_m_plus_one_sh = two_m_plus_one<<3;
 	asm volatile(
 		"movl %0, %%esi				\n\t"
 		".balign 16				\n\t"
@@ -959,7 +963,7 @@
 		"addl %2, %%esi				\n\t"
 		"cmpl %1, %%esi				\n\t"
 		" jb 1b					\n\t"
-		:: "g" (buf), "m" (buf+128), "m" (two_m_plus_one<<3), "r" (two_m<<3),
+		:: "g" (buf), "m" (buf2), "m" (two_m_plus_one_sh), "r" (two_m<<3),
 		   "r" (sseW[m])
 		: "%esi", "%edi", "%edx"
 	);
Index: libmpdemux/frequencies.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/frequencies.h,v
retrieving revision 1.1
diff -u -r1.1 frequencies.h
--- libmpdemux/frequencies.h	16 Nov 2001 22:06:48 -0000	1.1
+++ libmpdemux/frequencies.h	24 Feb 2005 18:08:23 -0000
@@ -104,7 +104,7 @@
 /* --------------------------------------------------------------------- */
 
 extern struct CHANLISTS   chanlists[];
-extern struct STRTAB chanlist_names[];
+extern struct CHANLISTS   chanlist_names[];
 
 extern int                chantab;
 extern struct CHANLIST   *chanlist;
Index: libvo/vo_jpeg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_jpeg.c,v
retrieving revision 1.25
diff -u -r1.25 vo_jpeg.c
--- libvo/vo_jpeg.c	19 Jan 2005 17:10:20 -0000	1.25
+++ libvo/vo_jpeg.c	24 Feb 2005 18:08:23 -0000
@@ -316,7 +316,7 @@
 /** \brief Validation function for maxfiles > 0
  */
 
-static int int_pos(int *mf)
+static int jpeg_int_pos(int *mf)
 {
     if ( *mf > 0 )
         return 1;
@@ -336,7 +336,7 @@
                                                 (opt_test_f)int_zero_hundred},
         {"outdir",      OPT_ARG_MSTRZ,  &jpeg_outdir,           NULL},
         {"subdirs",     OPT_ARG_MSTRZ,  &jpeg_subdirs,          NULL},
-        {"maxfiles",    OPT_ARG_INT,    &jpeg_maxfiles, (opt_test_f)int_pos},
+        {"maxfiles",    OPT_ARG_INT,    &jpeg_maxfiles, (opt_test_f)jpeg_int_pos},
         {NULL}
     };
     const char *info_message = NULL;
Index: postproc/swscale_template.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale_template.c,v
retrieving revision 1.112
diff -u -r1.112 swscale_template.c
--- postproc/swscale_template.c	16 Feb 2005 23:47:00 -0000	1.112
+++ postproc/swscale_template.c	24 Feb 2005 18:08:23 -0000
@@ -2045,6 +2045,7 @@
 {
 #ifdef HAVE_MMX
 	assert(filterSize % 4 == 0 && filterSize>0);
+	int ptr;
 	if(filterSize==4) // allways true for upscaling, sometimes for down too
 	{
 		long counter= -2*dstW;
@@ -2139,6 +2140,7 @@
 //		filter-= counter*filterSize/2;
 		filterPos-= counter/2;
 		dst-= counter/2;
+		ptr = src+filterSize;
 		asm volatile(
 			"pxor %%mm7, %%mm7		\n\t"
 			"movq "MANGLE(w02)", %%mm6	\n\t"
@@ -2177,7 +2179,7 @@
 			" jnc 1b			\n\t"
 
 			: "+r" (counter), "+r" (filter)
-			: "m" (filterPos), "m" (dst), "m"(src+filterSize),
+			: "m" (filterPos), "m" (dst), "m"(ptr),
 			  "m" (src), "r" ((long)filterSize*2)
 			: "%"REG_b, "%"REG_a, "%"REG_c
 		);
@@ -2319,6 +2321,8 @@
 	else
 	{
 #endif
+	int x1 = xInc>>16;
+	int x2 = xInc&0xffff;
 	//NO MMX just normal asm ...
 	asm volatile(
 		"xor %%"REG_a", %%"REG_a"	\n\t" // i
@@ -2356,7 +2360,7 @@
 		" jb 1b				\n\t"
 
 
-		:: "r" (src), "m" (dst), "m" (dstWidth), "m" (xInc>>16), "m" (xInc&0xFFFF)
+		:: "r" (src), "m" (dst), "m" (dstWidth), "m" (x1), "m" (x2)
 		: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
 		);
 #ifdef HAVE_MMX2
@@ -2515,6 +2519,8 @@
 	else
 	{
 #endif
+	long x1 = (long)(xInc>>16);
+	int x2 = xInc&0xffff;
 	asm volatile(
 		"xor %%"REG_a", %%"REG_a"	\n\t" // i
 		"xor %%"REG_b", %%"REG_b"		\n\t" // xx
@@ -2548,7 +2554,7 @@
 		"cmp %2, %%"REG_a"		\n\t"
 		" jb 1b				\n\t"
 
-		:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" ((long)(xInc>>16)), "m" ((xInc&0xFFFF)),
+		:: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (x1), "m" (x2),
 		"r" (src2)
 		: "%"REG_a, "%"REG_b, "%ecx", "%"REG_D, "%esi"
 		);


More information about the MPlayer-dev-eng mailing list