File: jdlossls.c

package info (click to toggle)
gdcm 3.0.21-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 26,880 kB
  • sloc: cpp: 203,477; ansic: 78,582; xml: 48,129; python: 3,459; cs: 2,308; java: 1,629; lex: 1,290; sh: 334; php: 128; makefile: 117
file content (98 lines) | stat: -rw-r--r-- 2,408 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * jdlossls.c
 *
 * Copyright (C) 1998, Thomas G. Lane.
 * This file is part of the Independent JPEG Group's software.
 * For conditions of distribution and use, see the accompanying README file.
 *
 * This file contains the control logic for the lossless JPEG decompressor.
 */

#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jlossls.h"


#ifdef D_LOSSLESS_SUPPORTED

/*
 * Compute output image dimensions and related values.
 */

METHODDEF(void)
calc_output_dimensions (j_decompress_ptr cinfo)
{
  /* Hardwire it to "no scaling" */
  cinfo->output_width = cinfo->image_width;
  cinfo->output_height = cinfo->image_height;
  /* jdinput.c has already initialized codec_data_unit to 1,
   * and has computed unscaled downsampled_width and downsampled_height.
   */
}


/*
 * Initialize for an input processing pass.
 */

METHODDEF(void)
start_input_pass (j_decompress_ptr cinfo)
{
  j_lossless_d_ptr losslsd = (j_lossless_d_ptr) cinfo->codec;

  (*losslsd->entropy_start_pass) (cinfo);
  (*losslsd->predict_start_pass) (cinfo);
  (*losslsd->scaler_start_pass) (cinfo);
  (*losslsd->diff_start_input_pass) (cinfo);
}


/*
 * Initialize the lossless decompression codec.
 * This is called only once, during master selection.
 */

GLOBAL(void)
jinit_lossless_d_codec(j_decompress_ptr cinfo)
{
  j_lossless_d_ptr losslsd;
  boolean use_c_buffer;

  /* Create subobject in permanent pool */
  losslsd = (j_lossless_d_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
        SIZEOF(jpeg_lossless_d_codec));
  cinfo->codec = (struct jpeg_d_codec *) losslsd;

  /* Initialize sub-modules */
  /* Entropy decoding: either Huffman or arithmetic coding. */
  if (cinfo->arith_code) {
#ifdef WITH_ARITHMETIC_PATCH
    jinit_arith_decoder(cinfo);
#else
    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
#endif
  } else {
    jinit_lhuff_decoder(cinfo);
  }

  /* Undifferencer */
  jinit_undifferencer(cinfo);

  /* Scaler */
  jinit_d_scaler(cinfo);

  use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
  jinit_d_diff_controller(cinfo, use_c_buffer);

  /* Initialize method pointers.
   *
   * Note: consume_data, start_output_pass and decompress_data are
   * assigned in jddiffct.c.
   */
  losslsd->pub.calc_output_dimensions = calc_output_dimensions;
  losslsd->pub.start_input_pass = start_input_pass;
}

#endif /* D_LOSSLESS_SUPPORTED */