4
4
* Copyright (C) 1994-1998, Thomas G. Lane.
5
* Modified 2009 by Guido Vollbeding.
5
6
* This file is part of the Independent JPEG Group's software.
6
7
* For conditions of distribution and use, see the accompanying README file.
44
#ifdef HAVE_MMX_INTEL_MNEMONICS
45
static int cpuidDetected = 0;
49
MMXAvailable = mmxsupport();
51
#ifdef HAVE_SSE2_INTEL_MNEMONICS
52
/* only do the sse2 support check if mmx is supported (so
53
we know the processor supports cpuid) */
55
SSE2Available = sse2support();
62
/* For debugging purposes, zero the whole master structure.
63
* But error manager pointer is already there, so save and restore it.
66
35
/* Guard against version mismatches between library and caller. */
67
36
cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
68
37
if (version != JPEG_LIB_VERSION)
218
188
/* Set defaults for other decompression parameters. */
219
cinfo->scale_num = 1; /* 1:1 scaling */
220
cinfo->scale_denom = 1;
189
cinfo->scale_num = DCTSIZE; /* 1:1 scaling */
190
cinfo->scale_denom = DCTSIZE;
221
191
cinfo->output_gamma = 1.0;
222
192
cinfo->buffered_image = FALSE;
223
193
cinfo->raw_data_out = FALSE;
424
394
jpeg_abort((j_common_ptr) cinfo);
429
#ifdef HAVE_MMX_INTEL_MNEMONICS
432
static int mmxsupport()
434
int mmx_supported = 0;
437
pushfd //Save Eflag to stack
438
pop eax //Get Eflag from stack into eax
439
mov ecx, eax //Make another copy of Eflag in ecx
440
xor eax, 0x200000 //Toggle ID bit in Eflag [i.e. bit(21)]
441
push eax //Save modified Eflag back to stack
443
popfd //Restored modified value back to Eflag reg
444
pushfd //Save Eflag to stack
445
pop eax //Get Eflag from stack
446
xor eax, ecx //Compare the new Eflag with the original Eflag
447
jz NOT_SUPPORTED //If the same, CPUID instruction is not supported,
448
//skip following instructions and jump to
449
//NOT_SUPPORTED label
451
xor eax, eax //Set eax to zero
455
cmp eax, 1 //make sure eax return non-zero value
456
jl NOT_SUPPORTED //If eax is zero, mmx not supported
458
xor eax, eax //set eax to zero
459
inc eax //Now increment eax to 1. This instruction is
460
//faster than the instruction "mov eax, 1"
464
and edx, 0x00800000 //mask out all bits but mmx bit(24)
465
cmp edx, 0 // 0 = mmx not supported
466
jz NOT_SUPPORTED // non-zero = Yes, mmx IS supported
468
mov mmx_supported, 1 //set return value to 1
471
mov eax, mmx_supported //move return value to eax
475
return mmx_supported;
479
#ifdef HAVE_SSE2_INTEL_MNEMONICS
481
static int sse2support()
483
int sse2available = 0;
491
if (my_edx & (0x1 << 26))
493
else sse2available = 2;
495
return sse2available;