~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to packages/base/pasjpeg/jdmaster.pas

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
  my_decomp_master = record
63
63
    pub : jpeg_decomp_master; { public fields }
64
64
 
65
 
    pass_number : int;          { # of passes completed }
 
65
    pass_number : int;          { # of passes completed }
66
66
 
67
67
    using_merged_upsample : boolean; { TRUE if using merged upsample/cconvert }
68
68
 
119
119
    exit;
120
120
  end;
121
121
  { ??? also need to test for upsample-time rescaling, when & if supported }
122
 
  use_merged_upsample := TRUE;                  { by golly, it'll work... }
 
122
  use_merged_upsample := TRUE;                  { by golly, it'll work... }
123
123
{$else}
124
124
  use_merged_upsample := FALSE;
125
125
{$endif}
195
195
  begin
196
196
    ssize := cinfo^.min_DCT_scaled_size;
197
197
    while (ssize < DCTSIZE) and
198
 
          ((compptr^.h_samp_factor * ssize * 2 <=
199
 
            cinfo^.max_h_samp_factor * cinfo^.min_DCT_scaled_size) and
200
 
           (compptr^.v_samp_factor * ssize * 2 <=
201
 
            cinfo^.max_v_samp_factor * cinfo^.min_DCT_scaled_size)) do
 
198
          ((compptr^.h_samp_factor * ssize * 2 <=
 
199
            cinfo^.max_h_samp_factor * cinfo^.min_DCT_scaled_size) and
 
200
           (compptr^.v_samp_factor * ssize * 2 <=
 
201
            cinfo^.max_v_samp_factor * cinfo^.min_DCT_scaled_size)) do
202
202
    begin
203
203
      ssize := ssize * 2;
204
204
    end;
215
215
    { Size in samples, after IDCT scaling }
216
216
    compptr^.downsampled_width := JDIMENSION (
217
217
      jdiv_round_up(long (cinfo^.image_width) *
218
 
                    long (compptr^.h_samp_factor * compptr^.DCT_scaled_size),
219
 
                    long (cinfo^.max_h_samp_factor * DCTSIZE)) );
 
218
                    long (compptr^.h_samp_factor * compptr^.DCT_scaled_size),
 
219
                    long (cinfo^.max_h_samp_factor * DCTSIZE)) );
220
220
    compptr^.downsampled_height := JDIMENSION (
221
221
      jdiv_round_up(long (cinfo^.image_height) *
222
 
                    long (compptr^.v_samp_factor * compptr^.DCT_scaled_size),
223
 
                    long (cinfo^.max_v_samp_factor * DCTSIZE)) );
 
222
                    long (compptr^.v_samp_factor * compptr^.DCT_scaled_size),
 
223
                    long (cinfo^.max_v_samp_factor * DCTSIZE)) );
224
224
    Inc(compptr);
225
225
  end;
226
226
 
250
250
  JCS_CMYK,
251
251
  JCS_YCCK:
252
252
    cinfo^.out_color_components := 4;
253
 
  else                  { else must be same colorspace as in file }
 
253
  else                  { else must be same colorspace as in file }
254
254
    cinfo^.out_color_components := cinfo^.num_components;
255
255
  end;
256
256
  if (cinfo^.quantize_colors) then
272
272
  processes are inner loops and need to be as fast as possible.  On most
273
273
  machines, particularly CPUs with pipelines or instruction prefetch,
274
274
  a (subscript-check-less) C table lookup
275
 
                x := sample_range_limit[x];
 
275
                x := sample_range_limit[x];
276
276
  is faster than explicit tests
277
 
                if (x < 0)  x := 0;
278
 
                else if (x > MAXJSAMPLE)  x := MAXJSAMPLE;
 
277
                if (x < 0)  x := 0;
 
278
                else if (x > MAXJSAMPLE)  x := MAXJSAMPLE;
279
279
  These processes all use a common table prepared by the routine below.
280
280
 
281
281
  For most steps we can mathematically guarantee that the initial value
285
285
  possible if the input data is corrupt.  To avoid any chance of indexing
286
286
  off the end of memory and getting a bad-pointer trap, we perform the
287
287
  post-IDCT limiting thus:
288
 
                x := range_limit[x & MASK];
 
288
                x := range_limit[x & MASK];
289
289
  where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
290
290
  samples.  Under normal circumstances this is more than enough range and
291
291
  a correct output will be generated; with bogus input data the mask will
317
317
begin
318
318
  table := range_limit_table_ptr (
319
319
    cinfo^.mem^.alloc_small (j_common_ptr(cinfo), JPOOL_IMAGE,
320
 
                (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)) );
 
320
                (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)) );
321
321
 
322
322
  { First segment of "simple" table: limit[x] := 0 for x < 0 }
323
323
  MEMZERO(table, (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
335
335
    idct_table^[i] := MAXJSAMPLE;
336
336
  { Second half of post-IDCT table }
337
337
  MEMZERO(@(idct_table^[2 * (MAXJSAMPLE+1)]),
338
 
          (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
 
338
          (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
339
339
  MEMCOPY(@(idct_table^[(4 * (MAXJSAMPLE+1) - CENTERJSAMPLE)]),
340
 
          @cinfo^.sample_range_limit^[0], CENTERJSAMPLE * SIZEOF(JSAMPLE));
 
340
          @cinfo^.sample_range_limit^[0], CENTERJSAMPLE * SIZEOF(JSAMPLE));
341
341
 
342
342
end;
343
343
 
557
557
      { Select new quantization method }
558
558
      if (cinfo^.two_pass_quantize) and (cinfo^.enable_2pass_quant) then
559
559
      begin
560
 
        cinfo^.cquantize := master^.quantizer_2pass;
561
 
        master^.pub.is_dummy_pass := TRUE;
 
560
        cinfo^.cquantize := master^.quantizer_2pass;
 
561
        master^.pub.is_dummy_pass := TRUE;
562
562
      end
563
563
      else
564
564
        if (cinfo^.enable_1pass_quant) then
565
565
        begin
566
 
          cinfo^.cquantize := master^.quantizer_1pass;
 
566
          cinfo^.cquantize := master^.quantizer_1pass;
567
567
        end
568
568
        else
569
569
        begin
570
 
          ERREXIT(j_common_ptr(cinfo), JERR_MODE_CHANGE);
 
570
          ERREXIT(j_common_ptr(cinfo), JERR_MODE_CHANGE);
571
571
        end;
572
572
    end;
573
573
    cinfo^.idct^.start_pass (cinfo);
575
575
    if (not cinfo^.raw_data_out) then
576
576
    begin
577
577
      if (not master^.using_merged_upsample) then
578
 
        cinfo^.cconvert^.start_pass (cinfo);
 
578
        cinfo^.cconvert^.start_pass (cinfo);
579
579
      cinfo^.upsample^.start_pass (cinfo);
580
580
      if (cinfo^.quantize_colors) then
581
 
        cinfo^.cquantize^.start_pass (cinfo, master^.pub.is_dummy_pass);
 
581
        cinfo^.cquantize^.start_pass (cinfo, master^.pub.is_dummy_pass);
582
582
      if master^.pub.is_dummy_pass  then
583
583
        cinfo^.post^.start_pass (cinfo, JBUF_SAVE_AND_PASS)
584
584
      else
665
665
begin
666
666
  master := my_master_ptr (
667
667
      cinfo^.mem^.alloc_small (j_common_ptr(cinfo), JPOOL_IMAGE,
668
 
                                  SIZEOF(my_decomp_master)) );
 
668
                                  SIZEOF(my_decomp_master)) );
669
669
  cinfo^.master := jpeg_decomp_master_ptr(master);
670
670
  master^.pub.prepare_for_output_pass := prepare_for_output_pass;
671
671
  master^.pub.finish_output_pass := finish_output_pass;
675
675
  master_selection(cinfo);
676
676
end;
677
677
 
678
 
end.
 
 
b'\\ No newline at end of file'
 
678
end.