Coverage Report

Created: 2025-10-12 07:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/imagemagick/MagickCore/quantum.c
Line
Count
Source
1
/*
2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3
%                                                                             %
4
%                                                                             %
5
%                                                                             %
6
%                QQQ   U   U   AAA   N   N  TTTTT  U   U  M   M               %
7
%               Q   Q  U   U  A   A  NN  N    T    U   U  MM MM               %
8
%               Q   Q  U   U  AAAAA  N N N    T    U   U  M M M               %
9
%               Q  QQ  U   U  A   A  N  NN    T    U   U  M   M               %
10
%                QQQQ   UUU   A   A  N   N    T     UUU   M   M               %
11
%                                                                             %
12
%             MagicCore Methods to Acquire / Destroy Quantum Pixels           %
13
%                                                                             %
14
%                             Software Design                                 %
15
%                                  Cristy                                     %
16
%                               October 1998                                  %
17
%                                                                             %
18
%                                                                             %
19
%  Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization         %
20
%  dedicated to making software imaging solutions freely available.           %
21
%                                                                             %
22
%  You may not use this file except in compliance with the License.  You may  %
23
%  obtain a copy of the License at                                            %
24
%                                                                             %
25
%    https://imagemagick.org/script/license.php                               %
26
%                                                                             %
27
%  Unless required by applicable law or agreed to in writing, software        %
28
%  distributed under the License is distributed on an "AS IS" BASIS,          %
29
%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
30
%  See the License for the specific language governing permissions and        %
31
%  limitations under the License.                                             %
32
%                                                                             %
33
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
%
35
%
36
*/
37

38
/*
39
  Include declarations.
40
*/
41
#include "MagickCore/studio.h"
42
#include "MagickCore/attribute.h"
43
#include "MagickCore/blob.h"
44
#include "MagickCore/blob-private.h"
45
#include "MagickCore/color-private.h"
46
#include "MagickCore/exception.h"
47
#include "MagickCore/exception-private.h"
48
#include "MagickCore/cache.h"
49
#include "MagickCore/cache-private.h"
50
#include "MagickCore/colorspace.h"
51
#include "MagickCore/colorspace-private.h"
52
#include "MagickCore/constitute.h"
53
#include "MagickCore/delegate.h"
54
#include "MagickCore/geometry.h"
55
#include "MagickCore/list.h"
56
#include "MagickCore/magick.h"
57
#include "MagickCore/memory_.h"
58
#include "MagickCore/memory-private.h"
59
#include "MagickCore/monitor.h"
60
#include "MagickCore/option.h"
61
#include "MagickCore/pixel.h"
62
#include "MagickCore/pixel-accessor.h"
63
#include "MagickCore/property.h"
64
#include "MagickCore/quantum.h"
65
#include "MagickCore/quantum-private.h"
66
#include "MagickCore/resource_.h"
67
#include "MagickCore/semaphore.h"
68
#include "MagickCore/statistic.h"
69
#include "MagickCore/stream.h"
70
#include "MagickCore/string_.h"
71
#include "MagickCore/string-private.h"
72
#include "MagickCore/thread-private.h"
73
#include "MagickCore/utility.h"
74

75
/*
76
  Define declarations.
77
*/
78
222k
#define QuantumSignature  0xab
79

80
/*
81
  Forward declarations.
82
*/
83
static void
84
  DestroyQuantumPixels(QuantumInfo *);
85

86
/*
87
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88
%                                                                             %
89
%                                                                             %
90
%                                                                             %
91
%   A c q u i r e Q u a n t u m I n f o                                       %
92
%                                                                             %
93
%                                                                             %
94
%                                                                             %
95
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
96
%
97
%  AcquireQuantumInfo() allocates the QuantumInfo structure.
98
%
99
%  The format of the AcquireQuantumInfo method is:
100
%
101
%      QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,Image *image)
102
%
103
%  A description of each parameter follows:
104
%
105
%    o image_info: the image info.
106
%
107
%    o image: the image.
108
%
109
*/
110
MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info,
111
  Image *image)
112
196k
{
113
196k
  MagickBooleanType
114
196k
    status;
115
116
196k
  QuantumInfo
117
196k
    *quantum_info;
118
119
196k
  quantum_info=(QuantumInfo *) AcquireCriticalMemory(sizeof(*quantum_info));
120
196k
  quantum_info->signature=MagickCoreSignature;
121
196k
  GetQuantumInfo(image_info,quantum_info);
122
196k
  if (image == (const Image *) NULL)
123
0
    return(quantum_info);
124
196k
  status=SetQuantumDepth(image,quantum_info,image->depth);
125
196k
  quantum_info->endian=image->endian;
126
196k
  if (status == MagickFalse)
127
0
    quantum_info=DestroyQuantumInfo(quantum_info);
128
196k
  return(quantum_info);
129
196k
}
130

131
/*
132
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133
%                                                                             %
134
%                                                                             %
135
%                                                                             %
136
+   A c q u i r e Q u a n t u m P i x e l s                                   %
137
%                                                                             %
138
%                                                                             %
139
%                                                                             %
140
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
%
142
%  AcquireQuantumPixels() allocates the pixel staging areas.
143
%
144
%  The format of the AcquireQuantumPixels method is:
145
%
146
%      MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
147
%        const size_t extent)
148
%
149
%  A description of each parameter follows:
150
%
151
%    o quantum_info: the quantum info.
152
%
153
%    o extent: the quantum info.
154
%
155
*/
156
static MagickBooleanType AcquireQuantumPixels(QuantumInfo *quantum_info,
157
  const size_t extent)
158
222k
{
159
222k
  ssize_t
160
222k
    i;
161
162
222k
  assert(quantum_info != (QuantumInfo *) NULL);
163
222k
  assert(quantum_info->signature == MagickCoreSignature);
164
222k
  quantum_info->number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
165
222k
  quantum_info->pixels=(MemoryInfo **) AcquireQuantumMemory(
166
222k
    quantum_info->number_threads,sizeof(*quantum_info->pixels));
167
222k
  if (quantum_info->pixels == (MemoryInfo **) NULL)
168
0
    return(MagickFalse);
169
222k
  quantum_info->extent=extent;
170
222k
  (void) memset(quantum_info->pixels,0,quantum_info->number_threads*
171
222k
    sizeof(*quantum_info->pixels));
172
445k
  for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
173
222k
  {
174
222k
    unsigned char
175
222k
      *pixels;
176
177
222k
    quantum_info->pixels[i]=AcquireVirtualMemory(extent+1,sizeof(*pixels));
178
222k
    if (quantum_info->pixels[i] == (MemoryInfo *) NULL)
179
0
      {
180
0
        DestroyQuantumPixels(quantum_info);
181
0
        return(MagickFalse);
182
0
      }
183
222k
    pixels=(unsigned char *)  GetVirtualMemoryBlob(quantum_info->pixels[i]);
184
222k
    (void) memset(pixels,0,(extent+1)*sizeof(*pixels));
185
222k
    pixels[extent]=QuantumSignature;
186
222k
  }
187
222k
  return(MagickTrue);
188
222k
}
189

190
/*
191
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192
%                                                                             %
193
%                                                                             %
194
%                                                                             %
195
%   D e s t r o y Q u a n t u m I n f o                                       %
196
%                                                                             %
197
%                                                                             %
198
%                                                                             %
199
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200
%
201
%  DestroyQuantumInfo() deallocates memory associated with the QuantumInfo
202
%  structure.
203
%
204
%  The format of the DestroyQuantumInfo method is:
205
%
206
%      QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
207
%
208
%  A description of each parameter follows:
209
%
210
%    o quantum_info: the quantum info.
211
%
212
*/
213
MagickExport QuantumInfo *DestroyQuantumInfo(QuantumInfo *quantum_info)
214
196k
{
215
196k
  assert(quantum_info != (QuantumInfo *) NULL);
216
196k
  assert(quantum_info->signature == MagickCoreSignature);
217
196k
  if (quantum_info->pixels != (MemoryInfo **) NULL)
218
196k
    DestroyQuantumPixels(quantum_info);
219
196k
  if (quantum_info->semaphore != (SemaphoreInfo *) NULL)
220
196k
    RelinquishSemaphoreInfo(&quantum_info->semaphore);
221
196k
  quantum_info->signature=(~MagickCoreSignature);
222
196k
  quantum_info=(QuantumInfo *) RelinquishMagickMemory(quantum_info);
223
196k
  return(quantum_info);
224
196k
}
225

226
/*
227
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228
%                                                                             %
229
%                                                                             %
230
%                                                                             %
231
+   D e s t r o y Q u a n t u m P i x e l s                                   %
232
%                                                                             %
233
%                                                                             %
234
%                                                                             %
235
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236
%
237
%  DestroyQuantumPixels() destroys the quantum pixels.
238
%
239
%  The format of the DestroyQuantumPixels() method is:
240
%
241
%      void DestroyQuantumPixels(QuantumInfo *quantum_info)
242
%
243
%  A description of each parameter follows:
244
%
245
%    o quantum_info: the quantum info.
246
%
247
*/
248
static void DestroyQuantumPixels(QuantumInfo *quantum_info)
249
222k
{
250
222k
  ssize_t
251
222k
    i;
252
253
222k
  assert(quantum_info != (QuantumInfo *) NULL);
254
222k
  assert(quantum_info->signature == MagickCoreSignature);
255
222k
  assert(quantum_info->pixels != (MemoryInfo **) NULL);
256
445k
  for (i=0; i < (ssize_t) quantum_info->number_threads; i++)
257
222k
    if (quantum_info->pixels[i] != (MemoryInfo *) NULL)
258
222k
      {
259
222k
#ifndef NDEBUG
260
222k
        ssize_t
261
222k
          extent;
262
263
222k
        unsigned char
264
222k
          *pixels;
265
266
        /*
267
          Did we overrun our quantum buffer?
268
        */
269
222k
        extent=(ssize_t) quantum_info->extent;
270
222k
        pixels=(unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[i]);
271
222k
        assert(pixels[extent] == QuantumSignature);
272
222k
#endif
273
222k
        quantum_info->pixels[i]=RelinquishVirtualMemory(
274
222k
          quantum_info->pixels[i]);
275
222k
      }
276
222k
  quantum_info->pixels=(MemoryInfo **) RelinquishMagickMemory(
277
222k
    quantum_info->pixels);
278
222k
}
279

280
/*
281
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
282
%                                                                             %
283
%                                                                             %
284
%                                                                             %
285
%   G e t Q u a n t u m E x t e n t                                           %
286
%                                                                             %
287
%                                                                             %
288
%                                                                             %
289
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290
%
291
%  GetQuantumExtent() returns the quantum pixel buffer extent.
292
%
293
%  The format of the GetQuantumExtent method is:
294
%
295
%      size_t GetQuantumExtent(Image *image,const QuantumInfo *quantum_info,
296
%        const QuantumType quantum_type)
297
%
298
%  A description of each parameter follows:
299
%
300
%    o image: the image.
301
%
302
%    o quantum_info: the quantum info.
303
%
304
%    o quantum_type: Declare which pixel components to transfer (red, green,
305
%      blue, opacity, RGB, or RGBA).
306
%
307
*/
308
MagickExport size_t GetQuantumExtent(const Image *image,
309
  const QuantumInfo *quantum_info,const QuantumType quantum_type)
310
14.0M
{
311
14.0M
  size_t
312
14.0M
    channels;
313
314
14.0M
  assert(quantum_info != (QuantumInfo *) NULL);
315
14.0M
  assert(quantum_info->signature == MagickCoreSignature);
316
14.0M
  channels=1;
317
14.0M
  switch (quantum_type)
318
14.0M
  {
319
121k
    case GrayAlphaQuantum: channels=2; break;
320
28.0k
    case IndexAlphaQuantum: channels=2; break;
321
987k
    case RGBQuantum: channels=3; break;
322
0
    case BGRQuantum: channels=3; break;
323
242k
    case RGBAQuantum: channels=4; break;
324
0
    case RGBOQuantum: channels=4; break;
325
0
    case BGRAQuantum: channels=4; break;
326
107k
    case CMYKQuantum: channels=4; break;
327
130k
    case CMYKAQuantum: channels=5; break;
328
200k
    case MultispectralQuantum: channels=GetImageChannels(image); break;
329
552
    case CbYCrAQuantum: channels=4; break;
330
3.83k
    case CbYCrQuantum: channels=3; break;
331
3.73k
    case CbYCrYQuantum: channels=4; break;
332
12.2M
    default: break;
333
14.0M
  }
334
14.0M
  if (quantum_info->pack == MagickFalse)
335
114k
    return((size_t) (channels*image->columns*((quantum_info->depth+7)/8))+
336
114k
      (quantum_info->pad*image->columns));
337
13.9M
  return((size_t) ((channels*image->columns*quantum_info->depth+7)/8)+
338
13.9M
    (quantum_info->pad*image->columns));
339
14.0M
}
340

341
/*
342
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
343
%                                                                             %
344
%                                                                             %
345
%                                                                             %
346
%   G e t Q u a n t u m E n d i a n                                           %
347
%                                                                             %
348
%                                                                             %
349
%                                                                             %
350
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
351
%
352
%  GetQuantumEndian() returns the quantum endian of the image.
353
%
354
%  The endian of the GetQuantumEndian method is:
355
%
356
%      EndianType GetQuantumEndian(const QuantumInfo *quantum_info)
357
%
358
%  A description of each parameter follows:
359
%
360
%    o quantum_info: the quantum info.
361
%
362
*/
363
MagickExport EndianType GetQuantumEndian(const QuantumInfo *quantum_info)
364
0
{
365
0
  assert(quantum_info != (QuantumInfo *) NULL);
366
0
  assert(quantum_info->signature == MagickCoreSignature);
367
0
  return(quantum_info->endian);
368
0
}
369

370
/*
371
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
372
%                                                                             %
373
%                                                                             %
374
%                                                                             %
375
%   G e t Q u a n t u m F o r m a t                                           %
376
%                                                                             %
377
%                                                                             %
378
%                                                                             %
379
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
%
381
%  GetQuantumFormat() returns the quantum format of the image.
382
%
383
%  The format of the GetQuantumFormat method is:
384
%
385
%      QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info)
386
%
387
%  A description of each parameter follows:
388
%
389
%    o quantum_info: the quantum info.
390
%
391
*/
392
MagickExport QuantumFormatType GetQuantumFormat(const QuantumInfo *quantum_info)
393
883
{
394
883
  assert(quantum_info != (QuantumInfo *) NULL);
395
883
  assert(quantum_info->signature == MagickCoreSignature);
396
883
  return(quantum_info->format);
397
883
}
398

399
/*
400
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401
%                                                                             %
402
%                                                                             %
403
%                                                                             %
404
%   G e t Q u a n t u m I n f o                                               %
405
%                                                                             %
406
%                                                                             %
407
%                                                                             %
408
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409
%
410
%  GetQuantumInfo() initializes the QuantumInfo structure to default values.
411
%
412
%  The format of the GetQuantumInfo method is:
413
%
414
%      GetQuantumInfo(const ImageInfo *image_info,QuantumInfo *quantum_info)
415
%
416
%  A description of each parameter follows:
417
%
418
%    o image_info: the image info.
419
%
420
%    o quantum_info: the quantum info.
421
%
422
*/
423
MagickExport void GetQuantumInfo(const ImageInfo *image_info,
424
  QuantumInfo *quantum_info)
425
196k
{
426
196k
  const char
427
196k
    *option;
428
429
196k
  assert(quantum_info != (QuantumInfo *) NULL);
430
196k
  (void) memset(quantum_info,0,sizeof(*quantum_info));
431
196k
  quantum_info->quantum=8;
432
196k
  quantum_info->maximum=1.0;
433
196k
  quantum_info->scale=QuantumRange;
434
196k
  quantum_info->pack=MagickTrue;
435
196k
  quantum_info->semaphore=AcquireSemaphoreInfo();
436
196k
  quantum_info->signature=MagickCoreSignature;
437
196k
  if (image_info == (const ImageInfo *) NULL)
438
0
    return;
439
196k
  option=GetImageOption(image_info,"quantum:format");
440
196k
  if (option != (char *) NULL)
441
2.65k
    quantum_info->format=(QuantumFormatType) ParseCommandOption(
442
2.65k
      MagickQuantumFormatOptions,MagickFalse,option);
443
196k
  option=GetImageOption(image_info,"quantum:minimum");
444
196k
  if (option != (char *) NULL)
445
0
    quantum_info->minimum=StringToDouble(option,(char **) NULL);
446
196k
  option=GetImageOption(image_info,"quantum:maximum");
447
196k
  if (option != (char *) NULL)
448
0
    quantum_info->maximum=StringToDouble(option,(char **) NULL);
449
196k
  if ((quantum_info->minimum == 0.0) && (quantum_info->maximum == 0.0))
450
0
    quantum_info->scale=0.0;
451
196k
  else
452
196k
    if (quantum_info->minimum == quantum_info->maximum)
453
0
      {
454
0
        quantum_info->scale=(double) QuantumRange/quantum_info->minimum;
455
0
        quantum_info->minimum=0.0;
456
0
      }
457
196k
    else
458
196k
      quantum_info->scale=(double) QuantumRange/(quantum_info->maximum-
459
196k
        quantum_info->minimum);
460
196k
  option=GetImageOption(image_info,"quantum:scale");
461
196k
  if (option != (char *) NULL)
462
0
    quantum_info->scale=StringToDouble(option,(char **) NULL);
463
196k
  option=GetImageOption(image_info,"quantum:polarity");
464
196k
  if (option != (char *) NULL)
465
0
    quantum_info->min_is_white=LocaleCompare(option,"min-is-white") == 0 ?
466
0
      MagickTrue : MagickFalse;
467
196k
  quantum_info->endian=image_info->endian;
468
196k
  ResetQuantumState(quantum_info);
469
196k
}
470

471
/*
472
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
473
%                                                                             %
474
%                                                                             %
475
%                                                                             %
476
%   G e t Q u a n t u m P i x e l s                                           %
477
%                                                                             %
478
%                                                                             %
479
%                                                                             %
480
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
481
%
482
%  GetQuantumPixels() returns the quantum pixels.
483
%
484
%  The format of the GetQuantumPixels method is:
485
%
486
%      unsigned char *QuantumPixels GetQuantumPixels(
487
%        const QuantumInfo *quantum_info)
488
%
489
%  A description of each parameter follows:
490
%
491
%    o image: the image.
492
%
493
*/
494
MagickExport unsigned char *GetQuantumPixels(const QuantumInfo *quantum_info)
495
73.8k
{
496
73.8k
  const int
497
73.8k
    id = GetOpenMPThreadId();
498
499
73.8k
  assert(quantum_info != (QuantumInfo *) NULL);
500
73.8k
  assert(quantum_info->signature == MagickCoreSignature);
501
73.8k
  return((unsigned char *) GetVirtualMemoryBlob(quantum_info->pixels[id]));
502
73.8k
}
503

504
/*
505
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
506
%                                                                             %
507
%                                                                             %
508
%                                                                             %
509
%   G e t Q u a n t u m T y p e                                               %
510
%                                                                             %
511
%                                                                             %
512
%                                                                             %
513
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
514
%
515
%  GetQuantumType() returns the quantum type of the image.
516
%
517
%  The format of the GetQuantumType method is:
518
%
519
%      QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
520
%
521
%  A description of each parameter follows:
522
%
523
%    o image: the image.
524
%
525
%    o exception: return any errors or warnings in this structure.
526
%
527
*/
528
MagickExport QuantumType GetQuantumType(Image *image,ExceptionInfo *exception)
529
10.4k
{
530
10.4k
  QuantumType
531
10.4k
    quantum_type;
532
533
10.4k
  assert(image != (Image *) NULL);
534
10.4k
  assert(image->signature == MagickCoreSignature);
535
10.4k
  if (IsEventLogging() != MagickFalse)
536
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
537
10.4k
  (void) exception;
538
10.4k
  quantum_type=RGBQuantum;
539
10.4k
  if (image->alpha_trait != UndefinedPixelTrait)
540
1.18k
    quantum_type=RGBAQuantum;
541
10.4k
  if (image->colorspace == CMYKColorspace)
542
1.79k
    {
543
1.79k
      quantum_type=CMYKQuantum;
544
1.79k
      if (image->alpha_trait != UndefinedPixelTrait)
545
327
        quantum_type=CMYKAQuantum;
546
1.79k
    }
547
10.4k
  if (IsGrayColorspace(image->colorspace) != MagickFalse)
548
2.96k
    {
549
2.96k
      quantum_type=GrayQuantum;
550
2.96k
      if (image->alpha_trait != UndefinedPixelTrait)
551
230
        quantum_type=GrayAlphaQuantum;
552
2.96k
    }
553
10.4k
  if (image->storage_class == PseudoClass)
554
351
    {
555
351
      quantum_type=IndexQuantum;
556
351
      if (image->alpha_trait != UndefinedPixelTrait)
557
128
        quantum_type=IndexAlphaQuantum;
558
351
    }
559
10.4k
  if (image->number_meta_channels != 0)
560
321
    quantum_type=MultispectralQuantum;
561
10.4k
  return(quantum_type);
562
10.4k
}
563

564
/*
565
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
566
%                                                                             %
567
%                                                                             %
568
%                                                                             %
569
+   R e s e t Q u a n t u m S t a t e                                         %
570
%                                                                             %
571
%                                                                             %
572
%                                                                             %
573
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
574
%
575
%  ResetQuantumState() resets the quantum state.
576
%
577
%  The format of the ResetQuantumState method is:
578
%
579
%      void ResetQuantumState(QuantumInfo *quantum_info)
580
%
581
%  A description of each parameter follows:
582
%
583
%    o quantum_info: the quantum info.
584
%
585
*/
586
MagickPrivate void ResetQuantumState(QuantumInfo *quantum_info)
587
14.2M
{
588
14.2M
  static const unsigned int mask[32] =
589
14.2M
  {
590
14.2M
    0x00000000U, 0x00000001U, 0x00000003U, 0x00000007U, 0x0000000fU,
591
14.2M
    0x0000001fU, 0x0000003fU, 0x0000007fU, 0x000000ffU, 0x000001ffU,
592
14.2M
    0x000003ffU, 0x000007ffU, 0x00000fffU, 0x00001fffU, 0x00003fffU,
593
14.2M
    0x00007fffU, 0x0000ffffU, 0x0001ffffU, 0x0003ffffU, 0x0007ffffU,
594
14.2M
    0x000fffffU, 0x001fffffU, 0x003fffffU, 0x007fffffU, 0x00ffffffU,
595
14.2M
    0x01ffffffU, 0x03ffffffU, 0x07ffffffU, 0x0fffffffU, 0x1fffffffU,
596
14.2M
    0x3fffffffU, 0x7fffffffU
597
14.2M
  };
598
599
14.2M
  assert(quantum_info != (QuantumInfo *) NULL);
600
14.2M
  assert(quantum_info->signature == MagickCoreSignature);
601
14.2M
  quantum_info->state.inverse_scale=1.0;
602
14.2M
  if (fabs(quantum_info->scale) >= MagickEpsilon)
603
14.2M
    quantum_info->state.inverse_scale/=quantum_info->scale;
604
14.2M
  quantum_info->state.pixel=0U;
605
14.2M
  quantum_info->state.bits=0U;
606
14.2M
  quantum_info->state.mask=mask;
607
14.2M
}
608

609
/*
610
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611
%                                                                             %
612
%                                                                             %
613
%                                                                             %
614
%   S e t Q u a n t u m F o r m a t                                           %
615
%                                                                             %
616
%                                                                             %
617
%                                                                             %
618
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619
%
620
%  SetQuantumAlphaType() sets the quantum format.
621
%
622
%  The format of the SetQuantumAlphaType method is:
623
%
624
%      void SetQuantumAlphaType(QuantumInfo *quantum_info,
625
%        const QuantumAlphaType type)
626
%
627
%  A description of each parameter follows:
628
%
629
%    o quantum_info: the quantum info.
630
%
631
%    o type: the alpha type (e.g. associate).
632
%
633
*/
634
MagickExport void SetQuantumAlphaType(QuantumInfo *quantum_info,
635
  const QuantumAlphaType type)
636
7.01k
{
637
7.01k
  assert(quantum_info != (QuantumInfo *) NULL);
638
7.01k
  assert(quantum_info->signature == MagickCoreSignature);
639
7.01k
  quantum_info->alpha_type=type;
640
7.01k
}
641

642
/*
643
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
644
%                                                                             %
645
%                                                                             %
646
%                                                                             %
647
%   S e t Q u a n t u m D e p t h                                             %
648
%                                                                             %
649
%                                                                             %
650
%                                                                             %
651
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652
%
653
%  SetQuantumDepth() sets the quantum depth.
654
%
655
%  The format of the SetQuantumDepth method is:
656
%
657
%      MagickBooleanType SetQuantumDepth(const Image *image,
658
%        QuantumInfo *quantum_info,const size_t depth)
659
%
660
%  A description of each parameter follows:
661
%
662
%    o image: the image.
663
%
664
%    o quantum_info: the quantum info.
665
%
666
%    o depth: the quantum depth.
667
%
668
*/
669
MagickExport MagickBooleanType SetQuantumDepth(const Image *image,
670
  QuantumInfo *quantum_info,const size_t depth)
671
459k
{
672
459k
  size_t
673
459k
    extent,
674
459k
    quantum;
675
676
  /*
677
    Allocate the quantum pixel buffer.
678
  */
679
459k
  assert(image != (Image *) NULL);
680
459k
  assert(image->signature == MagickCoreSignature);
681
459k
  assert(quantum_info != (QuantumInfo *) NULL);
682
459k
  assert(quantum_info->signature == MagickCoreSignature);
683
459k
  if (IsEventLogging() != MagickFalse)
684
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
685
459k
  quantum_info->depth=MagickMin(depth,64);
686
459k
  if (quantum_info->format == FloatingPointQuantumFormat)
687
35.6k
    {
688
35.6k
      if (quantum_info->depth > 32)
689
6.23k
        quantum_info->depth=64;
690
29.4k
      else
691
29.4k
        if (quantum_info->depth > 24)
692
11.2k
          quantum_info->depth=32;
693
18.2k
        else
694
18.2k
          if (quantum_info->depth > 16)
695
3.01k
            quantum_info->depth=24;
696
15.1k
          else
697
15.1k
            quantum_info->depth=16;
698
35.6k
    }
699
  /*
700
    Speculative allocation since we don't yet know the quantum type.
701
  */
702
459k
  quantum=(GetPixelChannels(image)+quantum_info->pad+3)*
703
459k
    ((quantum_info->depth+7)/8)*sizeof(double);
704
459k
  extent=MagickMax(image->columns,image->rows)*quantum;
705
459k
  if ((MagickMax(image->columns,image->rows) != 0) &&
706
459k
      (quantum != (extent/MagickMax(image->columns,image->rows))))
707
0
    return(MagickFalse);
708
459k
  if (quantum_info->pixels != (MemoryInfo **) NULL)
709
262k
    {
710
262k
      if (extent <= quantum_info->extent)
711
236k
        return(MagickTrue);
712
26.2k
      DestroyQuantumPixels(quantum_info);
713
26.2k
    }
714
222k
  return(AcquireQuantumPixels(quantum_info,extent));
715
459k
}
716

717
/*
718
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
719
%                                                                             %
720
%                                                                             %
721
%                                                                             %
722
%   S e t Q u a n t u m E n d i a n                                           %
723
%                                                                             %
724
%                                                                             %
725
%                                                                             %
726
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
727
%
728
%  SetQuantumEndian() sets the quantum endian.
729
%
730
%  The endian of the SetQuantumEndian method is:
731
%
732
%      MagickBooleanType SetQuantumEndian(const Image *image,
733
%        QuantumInfo *quantum_info,const EndianType endian)
734
%
735
%  A description of each parameter follows:
736
%
737
%    o image: the image.
738
%
739
%    o quantum_info: the quantum info.
740
%
741
%    o endian: the quantum endian.
742
%
743
*/
744
MagickExport MagickBooleanType SetQuantumEndian(const Image *image,
745
  QuantumInfo *quantum_info,const EndianType endian)
746
137k
{
747
137k
  assert(image != (Image *) NULL);
748
137k
  assert(image->signature == MagickCoreSignature);
749
137k
  assert(quantum_info != (QuantumInfo *) NULL);
750
137k
  assert(quantum_info->signature == MagickCoreSignature);
751
137k
  if (IsEventLogging() != MagickFalse)
752
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
753
137k
  quantum_info->endian=endian;
754
137k
  return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
755
137k
}
756

757
/*
758
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
759
%                                                                             %
760
%                                                                             %
761
%                                                                             %
762
%   S e t Q u a n t u m F o r m a t                                           %
763
%                                                                             %
764
%                                                                             %
765
%                                                                             %
766
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
767
%
768
%  SetQuantumFormat() sets the quantum format.
769
%
770
%  The format of the SetQuantumFormat method is:
771
%
772
%      MagickBooleanType SetQuantumFormat(const Image *image,
773
%        QuantumInfo *quantum_info,const QuantumFormatType format)
774
%
775
%  A description of each parameter follows:
776
%
777
%    o image: the image.
778
%
779
%    o quantum_info: the quantum info.
780
%
781
%    o format: the quantum format.
782
%
783
*/
784
MagickExport MagickBooleanType SetQuantumFormat(const Image *image,
785
  QuantumInfo *quantum_info,const QuantumFormatType format)
786
87.9k
{
787
87.9k
  assert(image != (Image *) NULL);
788
87.9k
  assert(image->signature == MagickCoreSignature);
789
87.9k
  assert(quantum_info != (QuantumInfo *) NULL);
790
87.9k
  assert(quantum_info->signature == MagickCoreSignature);
791
87.9k
  if (IsEventLogging() != MagickFalse)
792
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
793
87.9k
  quantum_info->format=format;
794
87.9k
  return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
795
87.9k
}
796

797
/*
798
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
799
%                                                                             %
800
%                                                                             %
801
%                                                                             %
802
%   S e t Q u a n t u m I m a g e T y p e                                     %
803
%                                                                             %
804
%                                                                             %
805
%                                                                             %
806
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807
%
808
%  SetQuantumImageType() sets the image type based on the quantum type.
809
%
810
%  The format of the SetQuantumImageType method is:
811
%
812
%      void ImageType SetQuantumImageType(Image *image,
813
%        const QuantumType quantum_type)
814
%
815
%  A description of each parameter follows:
816
%
817
%    o image: the image.
818
%
819
%    o quantum_type: Declare which pixel components to transfer (red, green,
820
%      blue, opacity, RGB, or RGBA).
821
%
822
*/
823
MagickExport void SetQuantumImageType(Image *image,
824
  const QuantumType quantum_type)
825
113k
{
826
113k
  assert(image != (Image *) NULL);
827
113k
  assert(image->signature == MagickCoreSignature);
828
113k
  if (IsEventLogging() != MagickFalse)
829
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
830
113k
  switch (quantum_type)
831
113k
  {
832
1.77k
    case IndexQuantum:
833
2.30k
    case IndexAlphaQuantum:
834
2.30k
    {
835
2.30k
      image->type=PaletteType;
836
2.30k
      break;
837
1.77k
    }
838
52.4k
    case GrayQuantum:
839
55.0k
    case GrayAlphaQuantum:
840
55.0k
    {
841
55.0k
      image->type=GrayscaleType;
842
55.0k
      if (image->depth == 1)
843
32.1k
        image->type=BilevelType;
844
55.0k
      break;
845
52.4k
    }
846
0
    case CyanQuantum:
847
0
    case MagentaQuantum:
848
0
    case YellowQuantum:
849
0
    case BlackQuantum:
850
4.66k
    case CMYKQuantum:
851
6.88k
    case CMYKAQuantum:
852
18.0k
    case MultispectralQuantum:
853
18.0k
    {
854
18.0k
      image->type=ColorSeparationType;
855
18.0k
      break;
856
6.88k
    }
857
37.8k
    default:
858
37.8k
    {
859
37.8k
      image->type=TrueColorType;
860
37.8k
      break;
861
6.88k
    }
862
113k
  }
863
113k
}
864

865
/*
866
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
867
%                                                                             %
868
%                                                                             %
869
%                                                                             %
870
%   S e t Q u a n t u m M e t a C h a n n e l                                 %
871
%                                                                             %
872
%                                                                             %
873
%                                                                             %
874
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
875
%
876
%  SetQuantumMetaChannel() sets the quantum meta-channel that will exported or
877
%  imported when the quantum type is MultispectralQuantum. To unset the
878
%  meta-channel, set the meta-channel to -1.
879
%
880
%  The format of the SetQuantumMetaChannel method is:
881
%
882
%      void SetQuantumMetaChannel(const Image *image,QuantumInfo *quantum_info,
883
%        const ssize_t meta_channel)
884
%
885
%  A description of each parameter follows:
886
%
887
%    o image: the image.
888
%
889
%    o quantum_info: the quantum info.
890
%
891
%    o meta_channel: the meta channel.
892
%
893
*/
894
MagickExport MagickBooleanType SetQuantumMetaChannel(const Image *image,
895
  QuantumInfo *quantum_info, const ssize_t meta_channel) 
896
32.9k
{
897
32.9k
  assert(quantum_info != (QuantumInfo *) NULL);
898
32.9k
  assert(quantum_info->signature == MagickCoreSignature);
899
32.9k
  if ((meta_channel < -1) ||
900
32.9k
      (meta_channel >= (ssize_t) image->number_meta_channels))
901
127
    return(MagickFalse);
902
32.8k
  quantum_info->meta_channel=meta_channel+1;
903
32.8k
  return(MagickTrue);
904
32.9k
}
905

906
/*
907
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
908
%                                                                             %
909
%                                                                             %
910
%                                                                             %
911
%   S e t Q u a n t u m P a c k                                               %
912
%                                                                             %
913
%                                                                             %
914
%                                                                             %
915
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
916
%
917
%  SetQuantumPack() sets the quantum pack flag.
918
%
919
%  The format of the SetQuantumPack method is:
920
%
921
%      void SetQuantumPack(QuantumInfo *quantum_info,
922
%        const MagickBooleanType pack)
923
%
924
%  A description of each parameter follows:
925
%
926
%    o quantum_info: the quantum info.
927
%
928
%    o pack: the pack flag.
929
%
930
*/
931
MagickExport void SetQuantumPack(QuantumInfo *quantum_info,
932
  const MagickBooleanType pack)
933
7.25k
{
934
7.25k
  assert(quantum_info != (QuantumInfo *) NULL);
935
7.25k
  assert(quantum_info->signature == MagickCoreSignature);
936
7.25k
  quantum_info->pack=pack;
937
7.25k
}
938

939
/*
940
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
941
%                                                                             %
942
%                                                                             %
943
%                                                                             %
944
%   S e t Q u a n t u m P a d                                                 %
945
%                                                                             %
946
%                                                                             %
947
%                                                                             %
948
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
949
%
950
%  SetQuantumPad() sets the quantum pad.
951
%
952
%  The format of the SetQuantumPad method is:
953
%
954
%      MagickBooleanType SetQuantumPad(const Image *image,
955
%        QuantumInfo *quantum_info,const size_t pad)
956
%
957
%  A description of each parameter follows:
958
%
959
%    o image: the image.
960
%
961
%    o quantum_info: the quantum info.
962
%
963
%    o pad: the quantum pad.
964
%
965
*/
966
MagickExport MagickBooleanType SetQuantumPad(const Image *image,
967
  QuantumInfo *quantum_info,const size_t pad)
968
16.3k
{
969
16.3k
  assert(image != (Image *) NULL);
970
16.3k
  assert(image->signature == MagickCoreSignature);
971
16.3k
  assert(quantum_info != (QuantumInfo *) NULL);
972
16.3k
  assert(quantum_info->signature == MagickCoreSignature);
973
16.3k
  if (IsEventLogging() != MagickFalse)
974
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
975
16.3k
  if (pad >= (MAGICK_SSIZE_MAX/GetImageChannels(image)))
976
0
    return(MagickFalse);
977
16.3k
  quantum_info->pad=pad;
978
16.3k
  return(SetQuantumDepth(image,quantum_info,quantum_info->depth));
979
16.3k
}
980

981
/*
982
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
983
%                                                                             %
984
%                                                                             %
985
%                                                                             %
986
%   S e t Q u a n t u m M i n I s W h i t e                                   %
987
%                                                                             %
988
%                                                                             %
989
%                                                                             %
990
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
991
%
992
%  SetQuantumMinIsWhite() sets the quantum min-is-white flag.
993
%
994
%  The format of the SetQuantumMinIsWhite method is:
995
%
996
%      void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
997
%        const MagickBooleanType min_is_white)
998
%
999
%  A description of each parameter follows:
1000
%
1001
%    o quantum_info: the quantum info.
1002
%
1003
%    o min_is_white: the min-is-white flag.
1004
%
1005
*/
1006
MagickExport void SetQuantumMinIsWhite(QuantumInfo *quantum_info,
1007
  const MagickBooleanType min_is_white)
1008
27.5k
{
1009
27.5k
  assert(quantum_info != (QuantumInfo *) NULL);
1010
27.5k
  assert(quantum_info->signature == MagickCoreSignature);
1011
27.5k
  quantum_info->min_is_white=min_is_white;
1012
27.5k
}
1013

1014
/*
1015
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1016
%                                                                             %
1017
%                                                                             %
1018
%                                                                             %
1019
%   S e t Q u a n t u m Q u a n t u m                                         %
1020
%                                                                             %
1021
%                                                                             %
1022
%                                                                             %
1023
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1024
%
1025
%  SetQuantumQuantum() sets the quantum quantum.
1026
%
1027
%  The format of the SetQuantumQuantum method is:
1028
%
1029
%      void SetQuantumQuantum(QuantumInfo *quantum_info,const size_t quantum)
1030
%
1031
%  A description of each parameter follows:
1032
%
1033
%    o quantum_info: the quantum info.
1034
%
1035
%    o quantum: the quantum quantum.
1036
%
1037
*/
1038
MagickExport void SetQuantumQuantum(QuantumInfo *quantum_info,
1039
  const size_t quantum)
1040
7.25k
{
1041
7.25k
  assert(quantum_info != (QuantumInfo *) NULL);
1042
7.25k
  assert(quantum_info->signature == MagickCoreSignature);
1043
7.25k
  quantum_info->quantum=quantum;
1044
7.25k
}
1045

1046
/*
1047
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1048
%                                                                             %
1049
%                                                                             %
1050
%                                                                             %
1051
%   S e t Q u a n t u m S c a l e                                             %
1052
%                                                                             %
1053
%                                                                             %
1054
%                                                                             %
1055
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1056
%
1057
%  SetQuantumScale() sets the quantum scale.
1058
%
1059
%  The format of the SetQuantumScale method is:
1060
%
1061
%      void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
1062
%
1063
%  A description of each parameter follows:
1064
%
1065
%    o quantum_info: the quantum info.
1066
%
1067
%    o scale: the quantum scale.
1068
%
1069
*/
1070
MagickExport void SetQuantumScale(QuantumInfo *quantum_info,const double scale)
1071
4.25k
{
1072
4.25k
  assert(quantum_info != (QuantumInfo *) NULL);
1073
4.25k
  assert(quantum_info->signature == MagickCoreSignature);
1074
4.25k
  quantum_info->scale=scale;
1075
4.25k
}