# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/mplayer/hotfix-x86-mathops.patch # Copyright (C) 2006 - 2024 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- Mplayer 1.5 is not using updated versions of FFmpeg where x86 assembly macros (__asm) of mathops.h used therein are outdated & those were already fixed (in Jul 20, 2023) - see: - https://github.com/FFmpeg/FFmpeg/commit/effadce6c756247ea8bae32dc13bb3e6f464f0eb Building without this patch results in the below error message during `make`: ./libavcodec/x86/mathops.h: Assembler messages: ./libavcodec/x86/mathops.h:125: Error: operand type mismatch for `shr' ^^^^ // REPEATS A FEW TIMES THEN: ./libavcodec/x86/mathops.h:125: Error: operand type mismatch for `shr' make[1]: *** [ffbuild/common.mak:78: libavformat/adtsenc.o] Error 1 - Mehdi Ahmadi --- ./ffmpeg/libavcodec/x86/mathops.h 2022-02-27 16:52:31.000000000 +0100 +++ ./ffmpeg/libavcodec/x86/mathops.h.new 2024-04-15 20:21:35.372349371 +0200 @@ -35,12 +35,20 @@ static av_always_inline av_const int MULL(int a, int b, unsigned shift) { int rt, dummy; + if (__builtin_constant_p(shift)) __asm__ ( "imull %3 \n\t" "shrdl %4, %%edx, %%eax \n\t" :"=a"(rt), "=d"(dummy) - :"a"(a), "rm"(b), "ci"((uint8_t)shift) + :"a"(a), "rm"(b), "i"(shift & 0x1F) ); + else + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) + :"a"(a), "rm"(b), "c"((uint8_t)shift) + ); return rt; } @@ -113,19 +121,31 @@ // avoid +32 for shift optimization (gcc should do that ...) #define NEG_SSR32 NEG_SSR32 static inline int32_t NEG_SSR32( int32_t a, int8_t s){ + if (__builtin_constant_p(s)) __asm__ ("sarl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "i" (-s & 0x1F) ); + else + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) + : "c" ((uint8_t)(-s)) + ); return a; } #define NEG_USR32 NEG_USR32 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ + if (__builtin_constant_p(s)) __asm__ ("shrl %1, %0\n\t" : "+r" (a) - : "ic" ((uint8_t)(-s)) + : "i" (-s & 0x1F) ); + else + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) + : "c" ((uint8_t)(-s)) + ); return a; }