[FFmpeg-devel] [PATCH] swscale: add workaround for building 32 bit shared libs with gcc4.2 on 64 bit Mac OS X

Michael Bradshaw mbradshaw at sorensonmedia.com
Mon Jun 4 19:24:21 CEST 2012


On Mon, Jun 4, 2012 at 10:55 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Jun 04, 2012 at 10:49:14AM -0600, Michael Bradshaw wrote:
>> On Sat, Jun 2, 2012 at 8:42 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
>> > On Fri, Jun 01, 2012 at 02:15:53PM -0600, Michael Bradshaw wrote:
>> >> Hi,
>> >>
>> >> Attached patch allows shared 32 bit ffmpeg to be built with gcc4.2 on
>> >> 64 bit Mac OS X. Without this, --disable-asm must be passed to
>> >> configure.
>> >>
>> >> I expect this patch will be a bit controversial, and if anyone has a
>> >> better solution I'd be happy to see it.
>> >>
>> >> See discussion here:
>> >> http://ffmpeg.org/pipermail/ffmpeg-user/2012-May/006851.html (and
>> >> continued here:
>> >> http://ffmpeg.org/pipermail/ffmpeg-user/2012-June/006854.html) for
>> >> more information relating to this.
>> >
>> > does replacing some of the problemtic "m" cases by MANGLE() work ?
>>
>> I'm not exactly sure what the "m" cases are, but I took a shot in the
>> dark and tried:
>>
>> @@ -884,7 +884,7 @@ static inline void RENAME(rgb15tobgr24)(const
>> uint8_t *src, uint8_t *dst, int sr
>>              "por        %%mm5, %%mm3    \n\t"
>>
>>              :"=m"(*d)
>> -            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r),"m"(mmx_null),"m"(mul15_mid),"m"(mul15_hi)
>> +            :"m"(*s),""(MANGLE(mask15b)),""(MANGLE(mask15g)),""(MANGLE(mask15r)),""(MANGLE(mmx_null)),""(MANGLE(mul15_mid)),""(MANGLE(mul15_hi))
>>              :"memory");
>>          /* borrowed 32 to 24 */
>>          __asm__ volatile(
>>
>>
>> Which just resulted in:
>>
>> libswscale/x86/rgb2rgb_template.c: In function ‘rgb15tobgr24_MMX’:
>> libswscale/x86/rgb2rgb_template.c:825: warning: asm operand 2 probably
>> doesn’t match constraints
>> libswscale/x86/rgb2rgb_template.c:825: warning: asm operand 3 probably
>> doesn’t match constraints
>> libswscale/x86/rgb2rgb_template.c:825: warning: asm operand 4 probably
>> doesn’t match constraints
>> libswscale/x86/rgb2rgb_template.c:825: warning: asm operand 5 probably
>> doesn’t match constraints
>> libswscale/x86/rgb2rgb_template.c:825: warning: asm operand 6 probably
>> doesn’t match constraints
>> libswscale/x86/rgb2rgb_template.c:825: warning: asm operand 7 probably
>> doesn’t match constraints
>> libswscale/x86/rgb2rgb_template.c:825: error: impossible constraint in ‘asm’
>>
>>
>> That's probably not what you meant to try though. If not, I'm going to
>> need your help in understanding what to try...
>
> sure sorry
> it should look something like this:
>
> -"foo     %5, bar \n\t"
> +"foo  "MANGLE(this)",bar \n\t"
> ...
> -            :"m"(that), "m"(this)
> +            :"m"(that)
>
> see the existing code on how MANGLE() is used
> also keep in mind that if you remove a "m" (or any other argument)
> the numbers used to access the later ones will decrease by 1

Great, thanks! That *seems* to have worked (it compiles without any
complaints at least). Here's what I did for one function:

@@ -831,9 +831,9 @@ static inline void RENAME(rgb15tobgr24)(const
uint8_t *src, uint8_t *dst, int sr
             "pand          %3, %%mm1    \n\t"
             "pand          %4, %%mm2    \n\t"
             "psllq         $5, %%mm0    \n\t"
-            "pmulhw        %6, %%mm0    \n\t"
-            "pmulhw        %6, %%mm1    \n\t"
-            "pmulhw        %7, %%mm2    \n\t"
+            "pmulhw        "MANGLE(mul15_mid)", %%mm0    \n\t"
+            "pmulhw        "MANGLE(mul15_mid)", %%mm1    \n\t"
+            "pmulhw        "MANGLE(mul15_hi)", %%mm2    \n\t"
             "movq       %%mm0, %%mm3    \n\t"
             "movq       %%mm1, %%mm4    \n\t"
             "movq       %%mm2, %%mm5    \n\t"
@@ -862,9 +862,9 @@ static inline void RENAME(rgb15tobgr24)(const
uint8_t *src, uint8_t *dst, int sr
             "pand          %3, %%mm1    \n\t"
             "pand          %4, %%mm2    \n\t"
             "psllq         $5, %%mm0    \n\t"
-            "pmulhw        %6, %%mm0    \n\t"
-            "pmulhw        %6, %%mm1    \n\t"
-            "pmulhw        %7, %%mm2    \n\t"
+            "pmulhw        "MANGLE(mul15_mid)", %%mm0    \n\t"
+            "pmulhw        "MANGLE(mul15_mid)", %%mm1    \n\t"
+            "pmulhw        "MANGLE(mul15_hi)", %%mm2    \n\t"
             "movq       %%mm0, %%mm3    \n\t"
             "movq       %%mm1, %%mm4    \n\t"
             "movq       %%mm2, %%mm5    \n\t"
@@ -884,7 +884,7 @@ static inline void RENAME(rgb15tobgr24)(const
uint8_t *src, uint8_t *dst, int sr
             "por        %%mm5, %%mm3    \n\t"

             :"=m"(*d)
-            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r),"m"(mmx_null),"m"(mul15_mid),"m"(mul15_hi)
+            :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r),"m"(mmx_null)//%6
= ,"m"(mul15_mid)//%7 = ,"m"(mul15_hi)
             :"memory");
         /* borrowed 32 to 24 */
         __asm__ volatile(


If that looks okay in general, I'll work on proper patch a patch.

Thanks,

Michael


More information about the ffmpeg-devel mailing list