~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/LibJPEG/jdapimin.c

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-07-20 13:42:15 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100720134215-xt1454zaedv3b604
Tags: 3.13.1-0ubuntu1
* New upstream release. Closes: (LP: #607800)
 - Updated debian/freeimage-get-orig-source script.
 - Removing no longer necessary debian/patches/* and
   the patch system in debian/rules.
 - Updated debian/rules to work with the new Makefiles.
 - Drop from -O3 to -O2 and use lzma compression saves
   ~10 MB of free space. 
* lintian stuff
 - fixed debhelper-but-no-misc-depends
 - fixed ldconfig-symlink-missing-for-shlib

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * jdapimin.c
3
3
 *
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.
7
8
 *
20
21
#include "jinclude.h"
21
22
#include "jpeglib.h"
22
23
 
23
 
#ifdef HAVE_MMX_INTEL_MNEMONICS
24
 
int MMXAvailable;
25
 
static int mmxsupport();
26
 
#endif
27
 
 
28
 
#ifdef HAVE_SSE2_INTEL_MNEMONICS
29
 
int SSE2Available = 0;
30
 
static int sse2support();
31
 
#endif
32
 
 
33
24
 
34
25
/*
35
26
 * Initialization of a JPEG decompression object.
41
32
{
42
33
  int i;
43
34
 
44
 
#ifdef HAVE_MMX_INTEL_MNEMONICS
45
 
  static int cpuidDetected = 0;
46
 
 
47
 
  if(!cpuidDetected)
48
 
  {
49
 
        MMXAvailable = mmxsupport();
50
 
 
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) */
54
 
        if (MMXAvailable)
55
 
            SSE2Available = sse2support();
56
 
#endif
57
 
 
58
 
        cpuidDetected = 1;
59
 
  }
60
 
#endif
61
 
 
62
 
  /* For debugging purposes, zero the whole master structure.
63
 
   * But error manager pointer is already there, so save and restore it.
64
 
   */
65
 
 
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)
137
106
  jpeg_abort((j_common_ptr) cinfo); /* use common routine */
138
107
}
139
108
 
 
109
 
140
110
/*
141
111
 * Set default decompression parameters.
142
112
 */
216
186
  }
217
187
 
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);
425
395
  return TRUE;
426
396
}
427
 
 
428
 
 
429
 
#ifdef HAVE_MMX_INTEL_MNEMONICS
430
 
 
431
 
 
432
 
static int mmxsupport()
433
 
{
434
 
        int mmx_supported = 0;
435
 
 
436
 
        _asm {
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
442
 
 
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
450
 
 
451
 
                xor eax, eax                    //Set eax to zero
452
 
                                        
453
 
                cpuid
454
 
                
455
 
                cmp eax, 1                              //make sure eax return non-zero value
456
 
                jl NOT_SUPPORTED                //If eax is zero, mmx not supported
457
 
 
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"
461
 
                
462
 
                cpuid
463
 
 
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
467
 
 
468
 
                mov     mmx_supported, 1        //set return value to 1
469
 
 
470
 
NOT_SUPPORTED:
471
 
                mov     eax, mmx_supported      //move return value to eax      
472
 
 
473
 
        }
474
 
 
475
 
        return mmx_supported;           
476
 
}
477
 
#endif
478
 
 
479
 
#ifdef HAVE_SSE2_INTEL_MNEMONICS
480
 
 
481
 
static int sse2support()
482
 
{
483
 
        int sse2available = 0;
484
 
        int my_edx;
485
 
        _asm
486
 
        {
487
 
                mov eax, 01                       
488
 
                cpuid                                    
489
 
                mov my_edx, edx    
490
 
        }
491
 
        if (my_edx & (0x1 << 26)) 
492
 
                sse2available = 1; 
493
 
        else sse2available = 2;
494
 
 
495
 
        return sse2available;
496
 
}
497
 
 
498
 
#endif
499