MagickCore  7.0.9
Convert, Edit, Or Compose Bitmap Images
quantum-private.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License. You may
6  obtain a copy of the License at
7 
8  https://imagemagick.org/script/license.php
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  MagickCore quantum inline methods.
17 */
18 #ifndef MAGICKCORE_QUANTUM_PRIVATE_H
19 #define MAGICKCORE_QUANTUM_PRIVATE_H
20 
21 #include "MagickCore/memory_.h"
22 #include "MagickCore/cache.h"
25 
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29 
30 typedef struct _QuantumState
31 {
32  double
34 
35  unsigned int
37 
38  size_t
40 
41  const unsigned int
42  *mask;
43 } QuantumState;
44 
46 {
47  size_t
49  quantum;
50 
53 
54  double
56  maximum,
57  scale;
58 
59  size_t
60  pad;
61 
64  pack;
65 
68 
69  size_t
71 
73  **pixels;
74 
75  size_t
77 
80 
83 
86 
87  size_t
89 };
90 
91 extern MagickPrivate void
93 
94 static inline MagickSizeType GetQuantumRange(const size_t depth)
95 {
97  one;
98 
99  size_t
100  max_depth;
101 
102  if (depth == 0)
103  return(0);
104  one=1;
105  max_depth=8*sizeof(MagickSizeType);
106  return((MagickSizeType) ((one << (MagickMin(depth,max_depth)-1))+
107  ((one << (MagickMin(depth,max_depth)-1))-1)));
108 }
109 
110 static inline float HalfToSinglePrecision(const unsigned short half)
111 {
112 #define ExponentBias (127-15)
113 #define ExponentMask 0x7c00
114 #define ExponentShift 23
115 #define SignBitShift 31
116 #define SignificandShift 13
117 #define SignificandMask 0x00000400
118 
119  typedef union _SinglePrecision
120  {
121  unsigned int
122  fixed_point;
123 
124  float
125  single_precision;
126  } SinglePrecision;
127 
128  register unsigned int
129  exponent,
130  significand,
131  sign_bit;
132 
133  SinglePrecision
134  map;
135 
136  unsigned int
137  value;
138 
139  /*
140  The IEEE 754 standard specifies half precision as having:
141 
142  Sign bit: 1 bit
143  Exponent width: 5 bits
144  Significand precision: 11 (10 explicitly stored)
145  */
146  sign_bit=(unsigned int) ((half >> 15) & 0x00000001);
147  exponent=(unsigned int) ((half >> 10) & 0x0000001f);
148  significand=(unsigned int) (half & 0x000003ff);
149  if (exponent == 0)
150  {
151  if (significand == 0)
152  value=sign_bit << SignBitShift;
153  else
154  {
155  while ((significand & SignificandMask) == 0)
156  {
157  significand<<=1;
158  exponent--;
159  }
160  exponent++;
161  significand&=(~SignificandMask);
162  exponent+=ExponentBias;
163  value=(sign_bit << SignBitShift) | (exponent << ExponentShift) |
164  (significand << SignificandShift);
165  }
166  }
167  else
168  if (exponent == SignBitShift)
169  {
170  value=(sign_bit << SignBitShift) | 0x7f800000;
171  if (significand != 0)
172  value|=(significand << SignificandShift);
173  }
174  else
175  {
176  exponent+=ExponentBias;
177  significand<<=SignificandShift;
178  value=(sign_bit << SignBitShift) | (exponent << ExponentShift) |
179  significand;
180  }
181  map.fixed_point=value;
182  return(map.single_precision);
183 }
184 
185 static inline unsigned char *PopCharPixel(const unsigned char pixel,
186  unsigned char *pixels)
187 {
188  *pixels++=pixel;
189  return(pixels);
190 }
191 
192 static inline unsigned char *PopLongPixel(const EndianType endian,
193  const unsigned int pixel,unsigned char *pixels)
194 {
195  register unsigned int
196  quantum;
197 
198  quantum=(unsigned int) pixel;
199  if (endian == LSBEndian)
200  {
201  *pixels++=(unsigned char) (quantum);
202  *pixels++=(unsigned char) (quantum >> 8);
203  *pixels++=(unsigned char) (quantum >> 16);
204  *pixels++=(unsigned char) (quantum >> 24);
205  return(pixels);
206  }
207  *pixels++=(unsigned char) (quantum >> 24);
208  *pixels++=(unsigned char) (quantum >> 16);
209  *pixels++=(unsigned char) (quantum >> 8);
210  *pixels++=(unsigned char) (quantum);
211  return(pixels);
212 }
213 
214 static inline unsigned char *PopShortPixel(const EndianType endian,
215  const unsigned short pixel,unsigned char *pixels)
216 {
217  register unsigned int
218  quantum;
219 
220  quantum=pixel;
221  if (endian == LSBEndian)
222  {
223  *pixels++=(unsigned char) (quantum);
224  *pixels++=(unsigned char) (quantum >> 8);
225  return(pixels);
226  }
227  *pixels++=(unsigned char) (quantum >> 8);
228  *pixels++=(unsigned char) (quantum);
229  return(pixels);
230 }
231 
232 static inline const unsigned char *PushCharPixel(const unsigned char *pixels,
233  unsigned char *pixel)
234 {
235  *pixel=(*pixels++);
236  return(pixels);
237 }
238 
239 static inline const unsigned char *PushLongPixel(const EndianType endian,
240  const unsigned char *pixels,unsigned int *pixel)
241 {
242  register unsigned int
243  quantum;
244 
245  if (endian == LSBEndian)
246  {
247  quantum=((unsigned int) *pixels++);
248  quantum|=((unsigned int) *pixels++ << 8);
249  quantum|=((unsigned int) *pixels++ << 16);
250  quantum|=((unsigned int) *pixels++ << 24);
251  *pixel=quantum;
252  return(pixels);
253  }
254  quantum=((unsigned int) *pixels++ << 24);
255  quantum|=((unsigned int) *pixels++ << 16);
256  quantum|=((unsigned int) *pixels++ << 8);
257  quantum|=((unsigned int) *pixels++);
258  *pixel=quantum;
259  return(pixels);
260 }
261 
262 static inline const unsigned char *PushShortPixel(const EndianType endian,
263  const unsigned char *pixels,unsigned short *pixel)
264 {
265  register unsigned int
266  quantum;
267 
268  if (endian == LSBEndian)
269  {
270  quantum=(unsigned int) *pixels++;
271  quantum|=(unsigned int) (*pixels++ << 8);
272  *pixel=(unsigned short) (quantum & 0xffff);
273  return(pixels);
274  }
275  quantum=(unsigned int) (*pixels++ << 8);
276  quantum|=(unsigned int) *pixels++;
277  *pixel=(unsigned short) (quantum & 0xffff);
278  return(pixels);
279 }
280 
281 static inline const unsigned char *PushFloatPixel(const EndianType endian,
282  const unsigned char *pixels,MagickFloatType *pixel)
283 {
284  union
285  {
286  unsigned int
287  unsigned_value;
288 
290  float_value;
291  } quantum;
292 
293  if (endian == LSBEndian)
294  {
295  quantum.unsigned_value=((unsigned int) *pixels++);
296  quantum.unsigned_value|=((unsigned int) *pixels++ << 8);
297  quantum.unsigned_value|=((unsigned int) *pixels++ << 16);
298  quantum.unsigned_value|=((unsigned int) *pixels++ << 24);
299  *pixel=quantum.float_value;
300  return(pixels);
301  }
302  quantum.unsigned_value=((unsigned int) *pixels++ << 24);
303  quantum.unsigned_value|=((unsigned int) *pixels++ << 16);
304  quantum.unsigned_value|=((unsigned int) *pixels++ << 8);
305  quantum.unsigned_value|=((unsigned int) *pixels++);
306  *pixel=quantum.float_value;
307  return(pixels);
308 }
309 
310 static inline Quantum ScaleAnyToQuantum(const QuantumAny quantum,
311  const QuantumAny range)
312 {
313  if (quantum > range)
314  return(QuantumRange);
315 #if !defined(MAGICKCORE_HDRI_SUPPORT)
316  return((Quantum) (((double) QuantumRange*quantum)*
317  PerceptibleReciprocal((double) range)+0.5));
318 #else
319  return((Quantum) (((double) QuantumRange*quantum)*
320  PerceptibleReciprocal((double) range)));
321 #endif
322 }
323 
324 static inline QuantumAny ScaleQuantumToAny(const Quantum quantum,
325  const QuantumAny range)
326 {
327 #if !defined(MAGICKCORE_HDRI_SUPPORT)
328  return((QuantumAny) ((double) range*quantum/QuantumRange));
329 #else
330  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
331  return((QuantumAny) 0UL);
332  if (((double) range*quantum/QuantumRange) >= 18446744073709551615.0)
333  return((QuantumAny) MagickULLConstant(18446744073709551615));
334  return((QuantumAny) ((double) range*quantum/QuantumRange+0.5));
335 #endif
336 }
337 
338 #if (MAGICKCORE_QUANTUM_DEPTH == 8)
339 static inline Quantum ScaleCharToQuantum(const unsigned char value)
340 {
341  return((Quantum) value);
342 }
343 
344 static inline Quantum ScaleLongToQuantum(const unsigned int value)
345 {
346 #if !defined(MAGICKCORE_HDRI_SUPPORT)
347  return((Quantum) ((value)/16843009UL));
348 #else
349  return((Quantum) (value/16843009.0));
350 #endif
351 }
352 
353 static inline Quantum ScaleLongLongToQuantum(const MagickSizeType value)
354 {
355 #if !defined(MAGICKCORE_HDRI_SUPPORT)
356  return((Quantum) (value/MagickULLConstant(72340172838076673)));
357 #else
358  return((Quantum) (value/72340172838076673.0));
359 #endif
360 }
361 
362 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
363 {
364  if (value <= 0.0)
365  return((Quantum) 0);
366  if (value >= MaxMap)
367  return(QuantumRange);
368 #if !defined(MAGICKCORE_HDRI_SUPPORT)
369  return((Quantum) (value+0.5));
370 #else
371  return((Quantum) value);
372 #endif
373 }
374 
375 static inline unsigned int ScaleQuantumToLong(const Quantum quantum)
376 {
377 #if !defined(MAGICKCORE_HDRI_SUPPORT)
378  return((unsigned int) (16843009UL*quantum));
379 #else
380  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
381  return(0U);
382  if ((16843009.0*quantum) >= 4294967295.0)
383  return(4294967295UL);
384  return((unsigned int) (16843009.0*quantum+0.5));
385 #endif
386 }
387 
388 static inline MagickSizeType ScaleQuantumToLongLong(const Quantum quantum)
389 {
390 #if !defined(MAGICKCORE_HDRI_SUPPORT)
391  return((MagickSizeType) (MagickULLConstant(72340172838076673)*quantum));
392 #else
393  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
394  return(0UL);
395  if ((72340172838076673.0*quantum) >= 18446744073709551615.0)
396  return(MagickULLConstant(18446744073709551615));
397  return((MagickSizeType) (72340172838076673*quantum+0.5));
398 #endif
399 }
400 
401 static inline unsigned int ScaleQuantumToMap(const Quantum quantum)
402 {
403  if (quantum >= (Quantum) MaxMap)
404  return((unsigned int) MaxMap);
405 #if !defined(MAGICKCORE_HDRI_SUPPORT)
406  return((unsigned int) quantum);
407 #else
408  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
409  return(0U);
410  return((unsigned int) (quantum+0.5));
411 #endif
412 }
413 
414 static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
415 {
416 #if !defined(MAGICKCORE_HDRI_SUPPORT)
417  return((unsigned short) (257UL*quantum));
418 #else
419  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
420  return(0);
421  if ((257.0*quantum) >= 65535.0)
422  return(65535);
423  return((unsigned short) (257.0*quantum+0.5));
424 #endif
425 }
426 
427 static inline Quantum ScaleShortToQuantum(const unsigned short value)
428 {
429 #if !defined(MAGICKCORE_HDRI_SUPPORT)
430  return((Quantum) ((value+128U)/257U));
431 #else
432  return((Quantum) (value/257.0));
433 #endif
434 }
435 #elif (MAGICKCORE_QUANTUM_DEPTH == 16)
436 static inline Quantum ScaleCharToQuantum(const unsigned char value)
437 {
438 #if !defined(MAGICKCORE_HDRI_SUPPORT)
439  return((Quantum) (257U*value));
440 #else
441  return((Quantum) (257.0*value));
442 #endif
443 }
444 
445 static inline Quantum ScaleLongToQuantum(const unsigned int value)
446 {
447 #if !defined(MAGICKCORE_HDRI_SUPPORT)
448  return((Quantum) ((value)/MagickULLConstant(65537)));
449 #else
450  return((Quantum) (value/65537.0));
451 #endif
452 }
453 
454 static inline Quantum ScaleLongLongToQuantum(const MagickSizeType value)
455 {
456 #if !defined(MAGICKCORE_HDRI_SUPPORT)
457  return((Quantum) ((value)/MagickULLConstant(281479271743489)));
458 #else
459  return((Quantum) (value/281479271743489.0));
460 #endif
461 }
462 
463 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
464 {
465  if (value <= 0.0)
466  return((Quantum) 0);
467  if (value >= MaxMap)
468  return(QuantumRange);
469 #if !defined(MAGICKCORE_HDRI_SUPPORT)
470  return((Quantum) (value+0.5));
471 #else
472  return((Quantum) value);
473 #endif
474 }
475 
476 static inline unsigned int ScaleQuantumToLong(const Quantum quantum)
477 {
478 #if !defined(MAGICKCORE_HDRI_SUPPORT)
479  return((unsigned int) (65537UL*quantum));
480 #else
481  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
482  return(0U);
483  if ((65537.0*quantum) >= 4294967295.0)
484  return(4294967295U);
485  return((unsigned int) (65537.0*quantum+0.5));
486 #endif
487 }
488 
489 static inline MagickSizeType ScaleQuantumToLongLong(const Quantum quantum)
490 {
491 #if !defined(MAGICKCORE_HDRI_SUPPORT)
492  return((MagickSizeType) (MagickULLConstant(281479271743489)*quantum));
493 #else
494  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
495  return(0UL);
496  if ((281479271743489.0*quantum) >= 18446744073709551615.0)
497  return(MagickULLConstant(18446744073709551615));
498  return((MagickSizeType) (281479271743489.0*quantum+0.5));
499 #endif
500 }
501 
502 static inline unsigned int ScaleQuantumToMap(const Quantum quantum)
503 {
504  if (quantum >= (Quantum) MaxMap)
505  return((unsigned int) MaxMap);
506 #if !defined(MAGICKCORE_HDRI_SUPPORT)
507  return((unsigned int) quantum);
508 #else
509  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
510  return(0U);
511  return((unsigned int) (quantum+0.5));
512 #endif
513 }
514 
515 static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
516 {
517 #if !defined(MAGICKCORE_HDRI_SUPPORT)
518  return((unsigned short) quantum);
519 #else
520  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
521  return(0);
522  if (quantum >= 65535.0)
523  return(65535);
524  return((unsigned short) (quantum+0.5));
525 #endif
526 }
527 
528 static inline Quantum ScaleShortToQuantum(const unsigned short value)
529 {
530  return((Quantum) value);
531 }
532 #elif (MAGICKCORE_QUANTUM_DEPTH == 32)
533 static inline Quantum ScaleCharToQuantum(const unsigned char value)
534 {
535 #if !defined(MAGICKCORE_HDRI_SUPPORT)
536  return((Quantum) (16843009UL*value));
537 #else
538  return((Quantum) (16843009.0*value));
539 #endif
540 }
541 
542 static inline Quantum ScaleLongToQuantum(const unsigned int value)
543 {
544  return((Quantum) value);
545 }
546 
547 static inline Quantum ScaleLongLongToQuantum(const MagickSizeType value)
548 {
549 #if !defined(MAGICKCORE_HDRI_SUPPORT)
550  return((Quantum) ((value)/MagickULLConstant(4294967297)));
551 #else
552  return((Quantum) (value/4294967297.0));
553 #endif
554 }
555 
556 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
557 {
558  if (value <= 0.0)
559  return((Quantum) 0);
560  if (value >= (Quantum) MaxMap)
561  return(QuantumRange);
562 #if !defined(MAGICKCORE_HDRI_SUPPORT)
563  return((Quantum) (65537.0*value+0.5));
564 #else
565  return((Quantum) (65537.0*value));
566 #endif
567 }
568 
569 static inline unsigned int ScaleQuantumToLong(const Quantum quantum)
570 {
571 #if !defined(MAGICKCORE_HDRI_SUPPORT)
572  return((unsigned int) quantum);
573 #else
574  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
575  return(0U);
576  if ((quantum) >= 4294967295.0)
577  return(4294967295);
578  return((unsigned int) (quantum+0.5));
579 #endif
580 }
581 
582 static inline MagickSizeType ScaleQuantumToLongLong(const Quantum quantum)
583 {
584 #if !defined(MAGICKCORE_HDRI_SUPPORT)
585  return((MagickSizeType) (MagickULLConstant(4294967297)*quantum));
586 #else
587  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
588  return(0UL);
589  if ((4294967297.0*quantum) >= 18446744073709551615.0)
590  return(MagickULLConstant(18446744073709551615));
591  return((MagickSizeType) (4294967297.0*quantum+0.5));
592 #endif
593 }
594 
595 static inline unsigned int ScaleQuantumToMap(const Quantum quantum)
596 {
597  if ((quantum/65537) >= (Quantum) MaxMap)
598  return((unsigned int) MaxMap);
599 #if !defined(MAGICKCORE_HDRI_SUPPORT)
600  return((unsigned int) ((quantum+MagickULLConstant(32768))/
601  MagickULLConstant(65537)));
602 #else
603  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
604  return(0U);
605  return((unsigned int) (quantum/65537.0+0.5));
606 #endif
607 }
608 
609 static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
610 {
611 #if !defined(MAGICKCORE_HDRI_SUPPORT)
612  return((unsigned short) ((quantum+MagickULLConstant(32768))/
613  MagickULLConstant(65537)));
614 #else
615  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
616  return(0);
617  if ((quantum/65537.0) >= 65535.0)
618  return(65535);
619  return((unsigned short) (quantum/65537.0+0.5));
620 #endif
621 }
622 
623 static inline Quantum ScaleShortToQuantum(const unsigned short value)
624 {
625 #if !defined(MAGICKCORE_HDRI_SUPPORT)
626  return((Quantum) (65537UL*value));
627 #else
628  return((Quantum) (65537.0*value));
629 #endif
630 }
631 #elif (MAGICKCORE_QUANTUM_DEPTH == 64)
632 static inline Quantum ScaleCharToQuantum(const unsigned char value)
633 {
634  return((Quantum) (72340172838076673.0*value));
635 }
636 
637 static inline Quantum ScaleLongToQuantum(const unsigned int value)
638 {
639  return((Quantum) (4294967297.0*value));
640 }
641 
642 static inline Quantum ScaleLongLongToQuantum(const MagickSizeType value)
643 {
644  return((Quantum) (value));
645 }
646 
647 static inline Quantum ScaleMapToQuantum(const MagickRealType value)
648 {
649  if (value <= 0.0)
650  return((Quantum) 0);
651  if (value >= MaxMap)
652  return(QuantumRange);
653  return((Quantum) (281479271743489.0*value));
654 }
655 
656 static inline unsigned int ScaleQuantumToLong(const Quantum quantum)
657 {
658  return((unsigned int) (quantum/4294967297.0+0.5));
659 }
660 
661 static inline MagickSizeType ScaleQuantumToLongLong(const Quantum quantum)
662 {
663 #if !defined(MAGICKCORE_HDRI_SUPPORT)
664  return((MagickSizeType) quantum);
665 #else
666  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
667  return(0UL);
668  if (quantum >= 18446744073709551615.0)
669  return(MagickULLConstant(18446744073709551615));
670  return((MagickSizeType) (quantum+0.5));
671 #endif
672 }
673 
674 static inline unsigned int ScaleQuantumToMap(const Quantum quantum)
675 {
676  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
677  return(0U);
678  if ((quantum/281479271743489.0) >= MaxMap)
679  return((unsigned int) MaxMap);
680  return((unsigned int) (quantum/281479271743489.0+0.5));
681 }
682 
683 static inline unsigned short ScaleQuantumToShort(const Quantum quantum)
684 {
685  if ((IsNaN(quantum) != MagickFalse) || (quantum <= 0.0))
686  return(0);
687  if ((quantum/281479271743489.0) >= 65535.0)
688  return(65535);
689  return((unsigned short) (quantum/281479271743489.0+0.5));
690 }
691 
692 static inline Quantum ScaleShortToQuantum(const unsigned short value)
693 {
694  return((Quantum) (281479271743489.0*value));
695 }
696 #endif
697 
698 static inline unsigned short SinglePrecisionToHalf(const float value)
699 {
700  typedef union _SinglePrecision
701  {
702  unsigned int
703  fixed_point;
704 
705  float
706  single_precision;
707  } SinglePrecision;
708 
709  register int
710  exponent;
711 
712  register unsigned int
713  significand,
714  sign_bit;
715 
716  SinglePrecision
717  map;
718 
719  unsigned short
720  half;
721 
722  /*
723  The IEEE 754 standard specifies half precision as having:
724 
725  Sign bit: 1 bit
726  Exponent width: 5 bits
727  Significand precision: 11 (10 explicitly stored)
728  */
729  map.single_precision=value;
730  sign_bit=(map.fixed_point >> 16) & 0x00008000;
731  exponent=(int) ((map.fixed_point >> ExponentShift) & 0x000000ff)-ExponentBias;
732  significand=map.fixed_point & 0x007fffff;
733  if (exponent <= 0)
734  {
735  int
736  shift;
737 
738  if (exponent < -10)
739  return((unsigned short) sign_bit);
740  significand=significand | 0x00800000;
741  shift=(int) (14-exponent);
742  significand=(unsigned int) ((significand+((1 << (shift-1))-1)+
743  ((significand >> shift) & 0x01)) >> shift);
744  return((unsigned short) (sign_bit | significand));
745  }
746  else
747  if (exponent == (0xff-ExponentBias))
748  {
749  if (significand == 0)
750  return((unsigned short) (sign_bit | ExponentMask));
751  else
752  {
753  significand>>=SignificandShift;
754  half=(unsigned short) (sign_bit | significand |
755  (significand == 0) | ExponentMask);
756  return(half);
757  }
758  }
759  significand=significand+((significand >> SignificandShift) & 0x01)+0x00000fff;
760  if ((significand & 0x00800000) != 0)
761  {
762  significand=0;
763  exponent++;
764  }
765  if (exponent > 30)
766  {
767  float
768  alpha;
769 
770  register int
771  i;
772 
773  /*
774  Float overflow.
775  */
776  alpha=1.0e10;
777  for (i=0; i < 10; i++)
778  alpha*=alpha;
779  return((unsigned short) (sign_bit | ExponentMask));
780  }
781  half=(unsigned short) (sign_bit | (exponent << 10) |
782  (significand >> SignificandShift));
783  return(half);
784 }
785 
786 #if defined(__cplusplus) || defined(c_plusplus)
787 }
788 #endif
789 
790 #endif
MagickDoubleType MagickRealType
Definition: magick-type.h:120
QuantumFormatType
Definition: quantum.h:43
QuantumFormatType format
Definition: quantum-private.h:52
static MagickSizeType GetQuantumRange(const size_t depth)
Definition: quantum-private.h:94
MemoryInfo ** pixels
Definition: quantum-private.h:73
#define ExponentMask
QuantumAlphaType alpha_type
Definition: quantum-private.h:67
size_t signature
Definition: quantum-private.h:88
#define MagickULLConstant(c)
Definition: magick-type.h:36
Definition: quantum.h:32
MagickPrivate void ResetQuantumState(QuantumInfo *)
Definition: quantum.c:579
#define SignBitShift
#define SignificandMask
QuantumState state
Definition: quantum-private.h:82
size_t depth
Definition: quantum-private.h:48
float MagickFloatType
Definition: magick-type.h:40
double minimum
Definition: quantum-private.h:55
Definition: memory.c:137
EndianType
Definition: quantum.h:29
size_t quantum
Definition: quantum-private.h:48
EndianType endian
Definition: quantum-private.h:79
static const unsigned char * PushShortPixel(const EndianType endian, const unsigned char *pixels, unsigned short *pixel)
Definition: quantum-private.h:262
MagickBooleanType pack
Definition: quantum-private.h:63
static const unsigned char * PushCharPixel(const unsigned char *pixels, unsigned char *pixel)
Definition: quantum-private.h:232
MagickBooleanType
Definition: magick-type.h:158
static double PerceptibleReciprocal(const double x)
Definition: pixel-accessor.h:224
static Quantum ScaleAnyToQuantum(const QuantumAny quantum, const QuantumAny range)
Definition: quantum-private.h:310
static unsigned char * PopLongPixel(const EndianType endian, const unsigned int pixel, unsigned char *pixels)
Definition: quantum-private.h:192
unsigned int pixel
Definition: quantum-private.h:36
size_t MagickSizeType
Definition: magick-type.h:130
static const unsigned char * PushLongPixel(const EndianType endian, const unsigned char *pixels, unsigned int *pixel)
Definition: quantum-private.h:239
SemaphoreInfo * semaphore
Definition: quantum-private.h:85
#define SignificandShift
#define ExponentShift
#define MaxMap
Definition: magick-type.h:75
Definition: quantum-private.h:45
size_t pad
Definition: quantum-private.h:60
#define IsNaN(a)
Definition: magick-type.h:181
static float HalfToSinglePrecision(const unsigned short half)
Definition: quantum-private.h:110
size_t number_threads
Definition: quantum-private.h:70
double scale
Definition: quantum-private.h:55
Definition: magick-type.h:160
const unsigned int * mask
Definition: quantum-private.h:42
unsigned short Quantum
Definition: magick-type.h:82
#define ExponentBias
size_t bits
Definition: quantum-private.h:39
size_t extent
Definition: quantum-private.h:76
static unsigned char * PopCharPixel(const unsigned char pixel, unsigned char *pixels)
Definition: quantum-private.h:185
static unsigned char * PopShortPixel(const EndianType endian, const unsigned short pixel, unsigned char *pixels)
Definition: quantum-private.h:214
#define MagickMin(x, y)
Definition: image-private.h:27
double inverse_scale
Definition: quantum-private.h:33
static unsigned short SinglePrecisionToHalf(const float value)
Definition: quantum-private.h:698
#define MagickPrivate
Definition: method-attribute.h:81
struct _QuantumState QuantumState
double maximum
Definition: quantum-private.h:55
static QuantumAny ScaleQuantumToAny(const Quantum quantum, const QuantumAny range)
Definition: quantum-private.h:324
MagickBooleanType min_is_white
Definition: quantum-private.h:63
Definition: quantum-private.h:30
MagickSizeType QuantumAny
Definition: magick-type.h:144
QuantumAlphaType
Definition: quantum.h:36
Definition: semaphore.c:59
#define QuantumRange
Definition: magick-type.h:83
static const unsigned char * PushFloatPixel(const EndianType endian, const unsigned char *pixels, MagickFloatType *pixel)
Definition: quantum-private.h:281