Mercurial > sdl-ios-xcode
comparison src/video/SDL_yuv_sw.c @ 1965:a788656ca29a
SDL constants are all uppercase.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 05 Aug 2006 17:09:42 +0000 |
parents | 8a162bfdc838 |
children | 07f084fe97d0 |
comparison
equal
deleted
inserted
replaced
1964:071b6598d48f | 1965:a788656ca29a |
---|---|
973 b_2_pix_alloc[i + 512] = b_2_pix_alloc[511]; | 973 b_2_pix_alloc[i + 512] = b_2_pix_alloc[511]; |
974 } | 974 } |
975 | 975 |
976 /* You have chosen wisely... */ | 976 /* You have chosen wisely... */ |
977 switch (swdata->texture->format) { | 977 switch (swdata->texture->format) { |
978 case SDL_PixelFormat_YV12: | 978 case SDL_PIXELFORMAT_YV12: |
979 case SDL_PixelFormat_IYUV: | 979 case SDL_PIXELFORMAT_IYUV: |
980 if (SDL_BYTESPERPIXEL(target_format) == 2) { | 980 if (SDL_BYTESPERPIXEL(target_format) == 2) { |
981 #if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */ | 981 #if 0 /*defined(__GNUC__) && defined(__i386__) && SDL_ASSEMBLY_ROUTINES */ |
982 /* inline assembly functions */ | 982 /* inline assembly functions */ |
983 if (SDL_HasMMX() && (Rmask == 0xF800) && | 983 if (SDL_HasMMX() && (Rmask == 0xF800) && |
984 (Gmask == 0x07E0) && (Bmask == 0x001F) && (width & 15) == 0) { | 984 (Gmask == 0x07E0) && (Bmask == 0x001F) && (width & 15) == 0) { |
1013 swdata->Display1X = Color32DitherYV12Mod1X; | 1013 swdata->Display1X = Color32DitherYV12Mod1X; |
1014 #endif | 1014 #endif |
1015 swdata->Display2X = Color32DitherYV12Mod2X; | 1015 swdata->Display2X = Color32DitherYV12Mod2X; |
1016 } | 1016 } |
1017 break; | 1017 break; |
1018 case SDL_PixelFormat_YUY2: | 1018 case SDL_PIXELFORMAT_YUY2: |
1019 case SDL_PixelFormat_UYVY: | 1019 case SDL_PIXELFORMAT_UYVY: |
1020 case SDL_PixelFormat_YVYU: | 1020 case SDL_PIXELFORMAT_YVYU: |
1021 if (SDL_BYTESPERPIXEL(target_format) == 2) { | 1021 if (SDL_BYTESPERPIXEL(target_format) == 2) { |
1022 swdata->Display1X = Color16DitherYUY2Mod1X; | 1022 swdata->Display1X = Color16DitherYUY2Mod1X; |
1023 swdata->Display2X = Color16DitherYUY2Mod2X; | 1023 swdata->Display2X = Color16DitherYUY2Mod2X; |
1024 } | 1024 } |
1025 if (SDL_BYTESPERPIXEL(target_format) == 3) { | 1025 if (SDL_BYTESPERPIXEL(target_format) == 3) { |
1059 SDL_OutOfMemory(); | 1059 SDL_OutOfMemory(); |
1060 return NULL; | 1060 return NULL; |
1061 } | 1061 } |
1062 | 1062 |
1063 switch (texture->format) { | 1063 switch (texture->format) { |
1064 case SDL_PixelFormat_YV12: | 1064 case SDL_PIXELFORMAT_YV12: |
1065 case SDL_PixelFormat_IYUV: | 1065 case SDL_PIXELFORMAT_IYUV: |
1066 case SDL_PixelFormat_YUY2: | 1066 case SDL_PIXELFORMAT_YUY2: |
1067 case SDL_PixelFormat_UYVY: | 1067 case SDL_PIXELFORMAT_UYVY: |
1068 case SDL_PixelFormat_YVYU: | 1068 case SDL_PIXELFORMAT_YVYU: |
1069 break; | 1069 break; |
1070 default: | 1070 default: |
1071 SDL_SetError("Unsupported YUV format"); | 1071 SDL_SetError("Unsupported YUV format"); |
1072 return NULL; | 1072 return NULL; |
1073 } | 1073 } |
1074 | 1074 |
1075 swdata->texture = texture; | 1075 swdata->texture = texture; |
1076 swdata->target_format = SDL_PixelFormat_Unknown; | 1076 swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; |
1077 swdata->pixels = (Uint8 *) SDL_malloc(texture->w * texture->h * 2); | 1077 swdata->pixels = (Uint8 *) SDL_malloc(texture->w * texture->h * 2); |
1078 swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int)); | 1078 swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int)); |
1079 swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32)); | 1079 swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32)); |
1080 if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) { | 1080 if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) { |
1081 SDL_OutOfMemory(); | 1081 SDL_OutOfMemory(); |
1099 Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB); | 1099 Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB); |
1100 } | 1100 } |
1101 | 1101 |
1102 /* Find the pitch and offset values for the overlay */ | 1102 /* Find the pitch and offset values for the overlay */ |
1103 switch (texture->format) { | 1103 switch (texture->format) { |
1104 case SDL_PixelFormat_YV12: | 1104 case SDL_PIXELFORMAT_YV12: |
1105 case SDL_PixelFormat_IYUV: | 1105 case SDL_PIXELFORMAT_IYUV: |
1106 swdata->pitches[0] = texture->w; | 1106 swdata->pitches[0] = texture->w; |
1107 swdata->pitches[1] = swdata->pitches[0] / 2; | 1107 swdata->pitches[1] = swdata->pitches[0] / 2; |
1108 swdata->pitches[2] = swdata->pitches[0] / 2; | 1108 swdata->pitches[2] = swdata->pitches[0] / 2; |
1109 swdata->planes[0] = swdata->pixels; | 1109 swdata->planes[0] = swdata->pixels; |
1110 swdata->planes[1] = | 1110 swdata->planes[1] = |
1111 swdata->planes[0] + swdata->pitches[0] * texture->h; | 1111 swdata->planes[0] + swdata->pitches[0] * texture->h; |
1112 swdata->planes[2] = | 1112 swdata->planes[2] = |
1113 swdata->planes[1] + swdata->pitches[1] * texture->h / 2; | 1113 swdata->planes[1] + swdata->pitches[1] * texture->h / 2; |
1114 break; | 1114 break; |
1115 case SDL_PixelFormat_YUY2: | 1115 case SDL_PIXELFORMAT_YUY2: |
1116 case SDL_PixelFormat_UYVY: | 1116 case SDL_PIXELFORMAT_UYVY: |
1117 case SDL_PixelFormat_YVYU: | 1117 case SDL_PIXELFORMAT_YVYU: |
1118 swdata->pitches[0] = texture->w * 2; | 1118 swdata->pitches[0] = texture->w * 2; |
1119 swdata->planes[0] = swdata->pixels; | 1119 swdata->planes[0] = swdata->pixels; |
1120 break; | 1120 break; |
1121 default: | 1121 default: |
1122 /* We should never get here (caught above) */ | 1122 /* We should never get here (caught above) */ |
1141 const void *pixels, int pitch) | 1141 const void *pixels, int pitch) |
1142 { | 1142 { |
1143 SDL_Texture *texture = swdata->texture; | 1143 SDL_Texture *texture = swdata->texture; |
1144 | 1144 |
1145 switch (texture->format) { | 1145 switch (texture->format) { |
1146 case SDL_PixelFormat_YV12: | 1146 case SDL_PIXELFORMAT_YV12: |
1147 case SDL_PixelFormat_IYUV: | 1147 case SDL_PIXELFORMAT_IYUV: |
1148 if (rect | 1148 if (rect |
1149 && (rect->x != 0 || rect->y != 0 || rect->w != texture->w | 1149 && (rect->x != 0 || rect->y != 0 || rect->w != texture->w |
1150 || rect->h != texture->h)) { | 1150 || rect->h != texture->h)) { |
1151 SDL_SetError | 1151 SDL_SetError |
1152 ("YV12 and IYUV textures only support full surface updates"); | 1152 ("YV12 and IYUV textures only support full surface updates"); |
1153 return -1; | 1153 return -1; |
1154 } | 1154 } |
1155 SDL_memcpy(swdata->pixels, pixels, texture->h * texture->w * 2); | 1155 SDL_memcpy(swdata->pixels, pixels, texture->h * texture->w * 2); |
1156 break; | 1156 break; |
1157 case SDL_PixelFormat_YUY2: | 1157 case SDL_PIXELFORMAT_YUY2: |
1158 case SDL_PixelFormat_UYVY: | 1158 case SDL_PIXELFORMAT_UYVY: |
1159 case SDL_PixelFormat_YVYU: | 1159 case SDL_PIXELFORMAT_YVYU: |
1160 { | 1160 { |
1161 Uint8 *src, *dst; | 1161 Uint8 *src, *dst; |
1162 int row; | 1162 int row; |
1163 size_t length; | 1163 size_t length; |
1164 | 1164 |
1183 int markDirty, void **pixels, int *pitch) | 1183 int markDirty, void **pixels, int *pitch) |
1184 { | 1184 { |
1185 SDL_Texture *texture = swdata->texture; | 1185 SDL_Texture *texture = swdata->texture; |
1186 | 1186 |
1187 switch (texture->format) { | 1187 switch (texture->format) { |
1188 case SDL_PixelFormat_YV12: | 1188 case SDL_PIXELFORMAT_YV12: |
1189 case SDL_PixelFormat_IYUV: | 1189 case SDL_PIXELFORMAT_IYUV: |
1190 if (rect | 1190 if (rect |
1191 && (rect->x != 0 || rect->y != 0 || rect->w != texture->w | 1191 && (rect->x != 0 || rect->y != 0 || rect->w != texture->w |
1192 || rect->h != texture->h)) { | 1192 || rect->h != texture->h)) { |
1193 SDL_SetError | 1193 SDL_SetError |
1194 ("YV12 and IYUV textures only support full surface locks"); | 1194 ("YV12 and IYUV textures only support full surface locks"); |
1275 } | 1275 } |
1276 pixels = swdata->stretch->pixels; | 1276 pixels = swdata->stretch->pixels; |
1277 pitch = swdata->stretch->pitch; | 1277 pitch = swdata->stretch->pitch; |
1278 } | 1278 } |
1279 switch (texture->format) { | 1279 switch (texture->format) { |
1280 case SDL_PixelFormat_YV12: | 1280 case SDL_PIXELFORMAT_YV12: |
1281 lum = swdata->planes[0]; | 1281 lum = swdata->planes[0]; |
1282 Cr = swdata->planes[1]; | 1282 Cr = swdata->planes[1]; |
1283 Cb = swdata->planes[2]; | 1283 Cb = swdata->planes[2]; |
1284 break; | 1284 break; |
1285 case SDL_PixelFormat_IYUV: | 1285 case SDL_PIXELFORMAT_IYUV: |
1286 lum = swdata->planes[0]; | 1286 lum = swdata->planes[0]; |
1287 Cr = swdata->planes[2]; | 1287 Cr = swdata->planes[2]; |
1288 Cb = swdata->planes[1]; | 1288 Cb = swdata->planes[1]; |
1289 break; | 1289 break; |
1290 case SDL_PixelFormat_YUY2: | 1290 case SDL_PIXELFORMAT_YUY2: |
1291 lum = swdata->planes[0]; | 1291 lum = swdata->planes[0]; |
1292 Cr = lum + 3; | 1292 Cr = lum + 3; |
1293 Cb = lum + 1; | 1293 Cb = lum + 1; |
1294 break; | 1294 break; |
1295 case SDL_PixelFormat_UYVY: | 1295 case SDL_PIXELFORMAT_UYVY: |
1296 lum = swdata->planes[0] + 1; | 1296 lum = swdata->planes[0] + 1; |
1297 Cr = lum + 1; | 1297 Cr = lum + 1; |
1298 Cb = lum - 1; | 1298 Cb = lum - 1; |
1299 break; | 1299 break; |
1300 case SDL_PixelFormat_YVYU: | 1300 case SDL_PIXELFORMAT_YVYU: |
1301 lum = swdata->planes[0]; | 1301 lum = swdata->planes[0]; |
1302 Cr = lum + 1; | 1302 Cr = lum + 1; |
1303 Cb = lum + 3; | 1303 Cb = lum + 3; |
1304 break; | 1304 break; |
1305 default: | 1305 default: |