File ffmpeg-x86-mathops.patch of Package A_tw-ffmpeg-3
60
1
diff -rup a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
2
--- a/libavcodec/x86/mathops.h 2023-10-01 13:02:26.829463017 +0200
3
+++ b/libavcodec/x86/mathops.h 2023-10-01 13:05:19.219502582 +0200
4
5
static av_always_inline av_const int MULL(int a, int b, unsigned shift)
6
{
7
int rt, dummy;
8
+ if (__builtin_constant_p(shift))
9
__asm__ (
10
"imull %3 \n\t"
11
"shrdl %4, %%edx, %%eax \n\t"
12
:"=a"(rt), "=d"(dummy)
13
- :"a"(a), "rm"(b), "ci"((uint8_t)shift)
14
+ :"a"(a), "rm"(b), "i"(shift & 0x1F)
15
);
16
+ else
17
+ __asm__ (
18
+ "imull %3 \n\t"
19
+ "shrdl %4, %%edx, %%eax \n\t"
20
+ :"=a"(rt), "=d"(dummy)
21
+ :"a"(a), "rm"(b), "c"((uint8_t)shift)
22
+ );
23
return rt;
24
}
25
26
27
// avoid +32 for shift optimization (gcc should do that ...)
28
#define NEG_SSR32 NEG_SSR32
29
static inline int32_t NEG_SSR32( int32_t a, int8_t s){
30
+ if (__builtin_constant_p(s))
31
__asm__ ("sarl %1, %0\n\t"
32
: "+r" (a)
33
- : "ic" ((uint8_t)(-s))
34
+ : "i" (-s & 0x1F)
35
);
36
+ else
37
+ __asm__ ("sarl %1, %0\n\t"
38
+ : "+r" (a)
39
+ : "c" ((uint8_t)(-s))
40
+ );
41
return a;
42
}
43
44
#define NEG_USR32 NEG_USR32
45
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
46
+ if (__builtin_constant_p(s))
47
__asm__ ("shrl %1, %0\n\t"
48
: "+r" (a)
49
- : "ic" ((uint8_t)(-s))
50
+ : "i" (-s & 0x1F)
51
);
52
+ else
53
+ __asm__ ("shrl %1, %0\n\t"
54
+ : "+r" (a)
55
+ : "c" ((uint8_t)(-s))
56
+ );
57
return a;
58
}
59
60