comparison src/video/SDL_yuv_sw.c @ 739:22dbf364c017

Added SDL_HasMMX(), SDL_Has3DNow(), SDL_HasSSE() in SDL_cpuinfo.h
author Sam Lantinga <slouken@libsdl.org>
date Tue, 18 Nov 2003 01:27:06 +0000
parents c94b390687d2
children b8d311d90021
comparison
equal deleted inserted replaced
738:82b85b731fe3 739:22dbf364c017
90 #include <stdlib.h> 90 #include <stdlib.h>
91 #include <string.h> 91 #include <string.h>
92 92
93 #include "SDL_error.h" 93 #include "SDL_error.h"
94 #include "SDL_video.h" 94 #include "SDL_video.h"
95 #include "SDL_cpuinfo.h"
95 #include "SDL_stretch_c.h" 96 #include "SDL_stretch_c.h"
96 #include "SDL_yuvfuncs.h" 97 #include "SDL_yuvfuncs.h"
97 #include "SDL_yuv_sw_c.h" 98 #include "SDL_yuv_sw_c.h"
98
99 /* Function to check the CPU flags */
100 #define MMX_CPU 0x800000
101 #ifdef USE_ASMBLIT
102 #define CPU_Flags() Hermes_X86_CPU()
103 #else
104 #define CPU_Flags() 0L
105 #endif
106
107 #ifdef USE_ASMBLIT
108 #define X86_ASSEMBLER
109 #define HermesConverterInterface void
110 #define HermesClearInterface void
111 #define STACKCALL
112
113 #include "HeadX86.h"
114 #endif
115 99
116 /* The functions used to manipulate software video overlays */ 100 /* The functions used to manipulate software video overlays */
117 static struct private_yuvhwfuncs sw_yuvfuncs = { 101 static struct private_yuvhwfuncs sw_yuvfuncs = {
118 SDL_LockYUV_SW, 102 SDL_LockYUV_SW,
119 SDL_UnlockYUV_SW, 103 SDL_UnlockYUV_SW,
954 int *Cb_g_tab; 938 int *Cb_g_tab;
955 int *Cb_b_tab; 939 int *Cb_b_tab;
956 Uint32 *r_2_pix_alloc; 940 Uint32 *r_2_pix_alloc;
957 Uint32 *g_2_pix_alloc; 941 Uint32 *g_2_pix_alloc;
958 Uint32 *b_2_pix_alloc; 942 Uint32 *b_2_pix_alloc;
959 int i, cpu_mmx; 943 int i;
960 int CR, CB; 944 int CR, CB;
961 Uint32 Rmask, Gmask, Bmask; 945 Uint32 Rmask, Gmask, Bmask;
962 946
963 /* Only RGB packed pixel conversion supported */ 947 /* Only RGB packed pixel conversion supported */
964 if ( (display->format->BytesPerPixel != 2) && 948 if ( (display->format->BytesPerPixel != 2) &&
1080 1064
1081 /* You have chosen wisely... */ 1065 /* You have chosen wisely... */
1082 switch (format) { 1066 switch (format) {
1083 case SDL_YV12_OVERLAY: 1067 case SDL_YV12_OVERLAY:
1084 case SDL_IYUV_OVERLAY: 1068 case SDL_IYUV_OVERLAY:
1085 cpu_mmx = CPU_Flags() & MMX_CPU;
1086 if ( display->format->BytesPerPixel == 2 ) { 1069 if ( display->format->BytesPerPixel == 2 ) {
1087 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 1070 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
1088 /* inline assembly functions */ 1071 /* inline assembly functions */
1089 if ( cpu_mmx && (Rmask == 0xF800) && 1072 if ( SDL_HasMMX() && (Rmask == 0xF800) &&
1090 (Gmask == 0x07E0) && 1073 (Gmask == 0x07E0) &&
1091 (Bmask == 0x001F) && 1074 (Bmask == 0x001F) &&
1092 (width & 15) == 0) { 1075 (width & 15) == 0) {
1093 /*printf("Using MMX 16-bit 565 dither\n");*/ 1076 /*printf("Using MMX 16-bit 565 dither\n");*/
1094 swdata->Display1X = Color565DitherYV12MMX1X; 1077 swdata->Display1X = Color565DitherYV12MMX1X;
1095 } else { 1078 } else {
1096 /*printf("Using C 16-bit dither\n");*/ 1079 /*printf("Using C 16-bit dither\n");*/
1097 swdata->Display1X = Color16DitherYV12Mod1X; 1080 swdata->Display1X = Color16DitherYV12Mod1X;
1106 swdata->Display2X = Color24DitherYV12Mod2X; 1089 swdata->Display2X = Color24DitherYV12Mod2X;
1107 } 1090 }
1108 if ( display->format->BytesPerPixel == 4 ) { 1091 if ( display->format->BytesPerPixel == 4 ) {
1109 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT) 1092 #if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
1110 /* inline assembly functions */ 1093 /* inline assembly functions */
1111 if ( cpu_mmx && (Rmask == 0x00FF0000) && 1094 if ( SDL_HasMMX() && (Rmask == 0x00FF0000) &&
1112 (Gmask == 0x0000FF00) && 1095 (Gmask == 0x0000FF00) &&
1113 (Bmask == 0x000000FF) && 1096 (Bmask == 0x000000FF) &&
1114 (width & 15) == 0) { 1097 (width & 15) == 0) {
1115 /*printf("Using MMX 32-bit dither\n");*/ 1098 /*printf("Using MMX 32-bit dither\n");*/
1116 swdata->Display1X = ColorRGBDitherYV12MMX1X; 1099 swdata->Display1X = ColorRGBDitherYV12MMX1X;
1117 } else { 1100 } else {
1118 /*printf("Using C 32-bit dither\n");*/ 1101 /*printf("Using C 32-bit dither\n");*/
1119 swdata->Display1X = Color32DitherYV12Mod1X; 1102 swdata->Display1X = Color32DitherYV12Mod1X;