| OLD | NEW |
| 1 /* | 1 /* |
| 2 * jsimd_i386.c | 2 * jsimd_i386.c |
| 3 * | 3 * |
| 4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB | 4 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
| 5 * Copyright 2009-2011 D. R. Commander | 5 * Copyright 2009-2011 D. R. Commander |
| 6 * | 6 * |
| 7 * Based on the x86 SIMD extension for IJG JPEG library, | 7 * Based on the x86 SIMD extension for IJG JPEG library, |
| 8 * Copyright (C) 1999-2006, MIYASAKA Masaru. | 8 * Copyright (C) 1999-2006, MIYASAKA Masaru. |
| 9 * For conditions of distribution and use, see copyright notice in jsimdext.inc | 9 * For conditions of distribution and use, see copyright notice in jsimdext.inc |
| 10 * | 10 * |
| 11 * This file contains the interface between the "normal" portions | 11 * This file contains the interface between the "normal" portions |
| 12 * of the library and the SIMD implementations when running on a | 12 * of the library and the SIMD implementations when running on a |
| 13 * 32-bit x86 architecture. | 13 * 32-bit x86 architecture. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #define JPEG_INTERNALS | 16 #define JPEG_INTERNALS |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 /* | 34 /* |
| 35 * Check what SIMD accelerations are supported. | 35 * Check what SIMD accelerations are supported. |
| 36 * | 36 * |
| 37 * FIXME: This code is racy under a multi-threaded environment. | 37 * FIXME: This code is racy under a multi-threaded environment. |
| 38 */ | 38 */ |
| 39 LOCAL(void) | 39 LOCAL(void) |
| 40 init_simd (void) | 40 init_simd (void) |
| 41 { | 41 { |
| 42 char *env = NULL; | 42 char *env = NULL; |
| 43 | 43 |
| 44 if (simd_support != ~0) | 44 if (simd_support != ~0U) |
| 45 return; | 45 return; |
| 46 | 46 |
| 47 simd_support = jpeg_simd_cpu_support(); | 47 simd_support = jpeg_simd_cpu_support(); |
| 48 | 48 |
| 49 /* Force different settings through environment variables */ | 49 /* Force different settings through environment variables */ |
| 50 env = getenv("JSIMD_FORCEMMX"); | 50 env = getenv("JSIMD_FORCEMMX"); |
| 51 if ((env != NULL) && (strcmp(env, "1") == 0)) | 51 if ((env != NULL) && (strcmp(env, "1") == 0)) |
| 52 simd_support &= JSIMD_MMX; | 52 simd_support &= JSIMD_MMX; |
| 53 env = getenv("JSIMD_FORCE3DNOW"); | 53 env = getenv("JSIMD_FORCE3DNOW"); |
| 54 if ((env != NULL) && (strcmp(env, "1") == 0)) | 54 if ((env != NULL) && (strcmp(env, "1") == 0)) |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 if (simd_support & JSIMD_SSE2) | 391 if (simd_support & JSIMD_SSE2) |
| 392 return 1; | 392 return 1; |
| 393 if (simd_support & JSIMD_MMX) | 393 if (simd_support & JSIMD_MMX) |
| 394 return 1; | 394 return 1; |
| 395 | 395 |
| 396 return 0; | 396 return 0; |
| 397 } | 397 } |
| 398 | 398 |
| 399 GLOBAL(void) | 399 GLOBAL(void) |
| 400 jsimd_h2v2_upsample (j_decompress_ptr cinfo, | 400 jsimd_h2v2_upsample (j_decompress_ptr cinfo, |
| 401 jpeg_component_info * compptr, | 401 jpeg_component_info * compptr, |
| 402 JSAMPARRAY input_data, | 402 JSAMPARRAY input_data, |
| 403 JSAMPARRAY * output_data_ptr) | 403 JSAMPARRAY * output_data_ptr) |
| 404 { | 404 { |
| 405 if (simd_support & JSIMD_SSE2) | 405 if (simd_support & JSIMD_SSE2) |
| 406 jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, | 406 jsimd_h2v2_upsample_sse2(cinfo->max_v_samp_factor, |
| 407 cinfo->output_width, input_data, output_data_ptr); | 407 cinfo->output_width, input_data, output_data_ptr); |
| 408 else if (simd_support & JSIMD_MMX) | 408 else if (simd_support & JSIMD_MMX) |
| 409 jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, | 409 jsimd_h2v2_upsample_mmx(cinfo->max_v_samp_factor, |
| 410 cinfo->output_width, input_data, output_data_ptr); | 410 cinfo->output_width, input_data, output_data_ptr); |
| 411 } | 411 } |
| 412 | 412 |
| 413 GLOBAL(void) | 413 GLOBAL(void) |
| 414 jsimd_h2v1_upsample (j_decompress_ptr cinfo, | 414 jsimd_h2v1_upsample (j_decompress_ptr cinfo, |
| 415 jpeg_component_info * compptr, | 415 jpeg_component_info * compptr, |
| 416 JSAMPARRAY input_data, | 416 JSAMPARRAY input_data, |
| 417 JSAMPARRAY * output_data_ptr) | 417 JSAMPARRAY * output_data_ptr) |
| 418 { | 418 { |
| 419 if (simd_support & JSIMD_SSE2) | 419 if (simd_support & JSIMD_SSE2) |
| 420 jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, | 420 jsimd_h2v1_upsample_sse2(cinfo->max_v_samp_factor, |
| 421 cinfo->output_width, input_data, output_data_ptr); | 421 cinfo->output_width, input_data, output_data_ptr); |
| 422 else if (simd_support & JSIMD_MMX) | 422 else if (simd_support & JSIMD_MMX) |
| 423 jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, | 423 jsimd_h2v1_upsample_mmx(cinfo->max_v_samp_factor, |
| 424 cinfo->output_width, input_data, output_data_ptr); | 424 cinfo->output_width, input_data, output_data_ptr); |
| 425 } | 425 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) | 459 IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 460 return 1; | 460 return 1; |
| 461 if (simd_support & JSIMD_MMX) | 461 if (simd_support & JSIMD_MMX) |
| 462 return 1; | 462 return 1; |
| 463 | 463 |
| 464 return 0; | 464 return 0; |
| 465 } | 465 } |
| 466 | 466 |
| 467 GLOBAL(void) | 467 GLOBAL(void) |
| 468 jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, | 468 jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo, |
| 469 jpeg_component_info * compptr, | 469 jpeg_component_info * compptr, |
| 470 JSAMPARRAY input_data, | 470 JSAMPARRAY input_data, |
| 471 JSAMPARRAY * output_data_ptr) | 471 JSAMPARRAY * output_data_ptr) |
| 472 { | 472 { |
| 473 if ((simd_support & JSIMD_SSE2) && | 473 if ((simd_support & JSIMD_SSE2) && |
| 474 IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) | 474 IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 475 jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor, | 475 jsimd_h2v2_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
| 476 compptr->downsampled_width, input_data, output_data_ptr); | 476 compptr->downsampled_width, input_data, output_data_ptr); |
| 477 else if (simd_support & JSIMD_MMX) | 477 else if (simd_support & JSIMD_MMX) |
| 478 jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, | 478 jsimd_h2v2_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 479 compptr->downsampled_width, input_data, output_data_ptr); | 479 compptr->downsampled_width, input_data, output_data_ptr); |
| 480 } | 480 } |
| 481 | 481 |
| 482 GLOBAL(void) | 482 GLOBAL(void) |
| 483 jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, | 483 jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo, |
| 484 jpeg_component_info * compptr, | 484 jpeg_component_info * compptr, |
| 485 JSAMPARRAY input_data, | 485 JSAMPARRAY input_data, |
| 486 JSAMPARRAY * output_data_ptr) | 486 JSAMPARRAY * output_data_ptr) |
| 487 { | 487 { |
| 488 if ((simd_support & JSIMD_SSE2) && | 488 if ((simd_support & JSIMD_SSE2) && |
| 489 IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) | 489 IS_ALIGNED_SSE(jconst_fancy_upsample_sse2)) |
| 490 jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, | 490 jsimd_h2v1_fancy_upsample_sse2(cinfo->max_v_samp_factor, |
| 491 compptr->downsampled_width, input_data, output_data_ptr); | 491 compptr->downsampled_width, input_data, output_data_ptr); |
| 492 else if (simd_support & JSIMD_MMX) | 492 else if (simd_support & JSIMD_MMX) |
| 493 jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, | 493 jsimd_h2v1_fancy_upsample_mmx(cinfo->max_v_samp_factor, |
| 494 compptr->downsampled_width, input_data, output_data_ptr); | 494 compptr->downsampled_width, input_data, output_data_ptr); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) | 1046 if ((simd_support & JSIMD_SSE2) && IS_ALIGNED_SSE(jconst_idct_float_sse2)) |
| 1047 jsimd_idct_float_sse2(compptr->dct_table, coef_block, | 1047 jsimd_idct_float_sse2(compptr->dct_table, coef_block, |
| 1048 output_buf, output_col); | 1048 output_buf, output_col); |
| 1049 else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) | 1049 else if ((simd_support & JSIMD_SSE) && IS_ALIGNED_SSE(jconst_idct_float_sse)) |
| 1050 jsimd_idct_float_sse(compptr->dct_table, coef_block, | 1050 jsimd_idct_float_sse(compptr->dct_table, coef_block, |
| 1051 output_buf, output_col); | 1051 output_buf, output_col); |
| 1052 else if (simd_support & JSIMD_3DNOW) | 1052 else if (simd_support & JSIMD_3DNOW) |
| 1053 jsimd_idct_float_3dnow(compptr->dct_table, coef_block, | 1053 jsimd_idct_float_3dnow(compptr->dct_table, coef_block, |
| 1054 output_buf, output_col); | 1054 output_buf, output_col); |
| 1055 } | 1055 } |
| 1056 | |
| OLD | NEW |