You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	Protect code that uses CMOV instructions with HAVE_CMOV,
Make configure set CMOV_IS_FAST on arches on which cmov has a low latency (typically non-Netburst based processor) Originally committed as revision 6749 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		
							
								
								
									
										15
									
								
								configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								configure
									
									
									
									
										vendored
									
									
								
							| @@ -347,6 +347,7 @@ cpu="generic" | |||||||
| powerpc_perf="no" | powerpc_perf="no" | ||||||
| mmx="default" | mmx="default" | ||||||
| cmov="no" | cmov="no" | ||||||
|  | cmov_is_fast="no" | ||||||
| armv5te="default" | armv5te="default" | ||||||
| iwmmxt="default" | iwmmxt="default" | ||||||
| altivec="default" | altivec="default" | ||||||
| @@ -1107,9 +1108,16 @@ if test $cpu != "generic"; then | |||||||
|             cmov="no" |             cmov="no" | ||||||
|         ;; |         ;; | ||||||
|         # targets that do support conditional mov (cmov) |         # targets that do support conditional mov (cmov) | ||||||
|         i686|pentiumpro|pentium[234]|pentium-m|prescott|athlon|athlon-tbird|athlon-4|athlon-[mx]p|nocona|athlon64|k8|opteron|athlon-fx) |         i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx) | ||||||
|             add_cflags "-march=$cpu" |             add_cflags "-march=$cpu" | ||||||
|             cmov="yes" |             cmov="yes" | ||||||
|  |             cmov_is_fast="yes" | ||||||
|  |         ;; | ||||||
|  |         # targets that do support conditional mov but on which it's slow | ||||||
|  |         pentium4|prescott|nocona) | ||||||
|  |             add_cflags "-march=$cpu" | ||||||
|  |             cmov="yes" | ||||||
|  |             cmov_is_fast="no" | ||||||
|         ;; |         ;; | ||||||
|         sparc64) |         sparc64) | ||||||
|             add_cflags "-mcpu=v9" |             add_cflags "-mcpu=v9" | ||||||
| @@ -1559,6 +1567,7 @@ echo "broken inttypes.h $emu_fast_int" | |||||||
| if test $arch = "x86" -o $arch = "x86_64"; then | if test $arch = "x86" -o $arch = "x86_64"; then | ||||||
|     echo "MMX enabled      $mmx" |     echo "MMX enabled      $mmx" | ||||||
|     echo "CMOV enabled     $cmov" |     echo "CMOV enabled     $cmov" | ||||||
|  |     echo "CMOV is fast     $cmov_is_fast" | ||||||
| fi | fi | ||||||
| if test $arch = "armv4l"; then | if test $arch = "armv4l"; then | ||||||
|     echo "ARMv5TE enabled  $armv5te" |     echo "ARMv5TE enabled  $armv5te" | ||||||
| @@ -1745,6 +1754,10 @@ if test "$cmov" = "yes" ; then | |||||||
|   echo "TARGET_CMOV=yes" >> config.mak |   echo "TARGET_CMOV=yes" >> config.mak | ||||||
|   echo "#define HAVE_CMOV 1" >> $TMPH |   echo "#define HAVE_CMOV 1" >> $TMPH | ||||||
| fi | fi | ||||||
|  | if test "$cmov_is_fast" = "yes" ; then | ||||||
|  |   echo "TARGET_CMOV_IS_FAST=yes" >> config.mak | ||||||
|  |   echo "#define CMOV_IS_FAST 1" >> $TMPH | ||||||
|  | fi | ||||||
| if test "$armv5te" = "yes" ; then | if test "$armv5te" = "yes" ; then | ||||||
|   echo "TARGET_ARMV5TE=yes" >> config.mak |   echo "TARGET_ARMV5TE=yes" >> config.mak | ||||||
|   echo "#define HAVE_ARMV5TE 1" >> $TMPH |   echo "#define HAVE_ARMV5TE 1" >> $TMPH | ||||||
|   | |||||||
| @@ -32,7 +32,6 @@ | |||||||
| #define CABAC_BITS 16 | #define CABAC_BITS 16 | ||||||
| #define CABAC_MASK ((1<<CABAC_BITS)-1) | #define CABAC_MASK ((1<<CABAC_BITS)-1) | ||||||
| #define BRANCHLESS_CABAC_DECODER 1 | #define BRANCHLESS_CABAC_DECODER 1 | ||||||
| #define CMOV_IS_FAST 1 |  | ||||||
| //#define ARCH_X86_DISABLED 1 | //#define ARCH_X86_DISABLED 1 | ||||||
|  |  | ||||||
| typedef struct CABACContext{ | typedef struct CABACContext{ | ||||||
| @@ -454,7 +453,7 @@ static int always_inline get_cabac_inline(CABACContext *c, uint8_t * const state | |||||||
| #else /* BRANCHLESS_CABAC_DECODER */ | #else /* BRANCHLESS_CABAC_DECODER */ | ||||||
|  |  | ||||||
|  |  | ||||||
| #if (defined CMOV_IS_FAST  && __CPU__ >= 686) | #if defined CMOV_IS_FAST | ||||||
| #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ | #define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\ | ||||||
|         "mov    "tmp"       , %%ecx                                     \n\t"\ |         "mov    "tmp"       , %%ecx                                     \n\t"\ | ||||||
|         "shl    $17         , "tmp"                                     \n\t"\ |         "shl    $17         , "tmp"                                     \n\t"\ | ||||||
|   | |||||||
| @@ -238,7 +238,7 @@ static inline int av_log2_16bit(unsigned int v) | |||||||
| /* median of 3 */ | /* median of 3 */ | ||||||
| static inline int mid_pred(int a, int b, int c) | static inline int mid_pred(int a, int b, int c) | ||||||
| { | { | ||||||
| #if (defined(ARCH_X86) && __CPU__ >= 686 || defined(ARCH_X86_64)) && !defined(RUNTIME_CPUDETECT) | #if HAVE_CMOV | ||||||
|     int i=b; |     int i=b; | ||||||
|     asm volatile( |     asm volatile( | ||||||
|         "cmp    %2, %1 \n\t" |         "cmp    %2, %1 \n\t" | ||||||
|   | |||||||
| @@ -168,7 +168,7 @@ static inline int ff_sqrt(int a) | |||||||
|             level= (level^mask)-mask; |             level= (level^mask)-mask; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT) | #ifdef HAVE_CMOV | ||||||
| #define COPY3_IF_LT(x,y,a,b,c,d)\ | #define COPY3_IF_LT(x,y,a,b,c,d)\ | ||||||
| asm volatile (\ | asm volatile (\ | ||||||
|     "cmpl %0, %3        \n\t"\ |     "cmpl %0, %3        \n\t"\ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user