Coverage Report

Created: 2026-09-28 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dcmtk/dcmjpeg/libijg12/jclossy.c
Line
Count
Source
1
/*
2
 * jclossy.c
3
 *
4
 * Copyright (C) 1998, Thomas G. Lane.
5
 * This file is part of the Independent JPEG Group's software.
6
 * For conditions of distribution and use, see the accompanying README file.
7
 *
8
 * This file contains the control logic for the lossy JPEG compressor.
9
 */
10
11
#define JPEG_INTERNALS
12
#include "jinclude12.h"
13
#include "jpeglib12.h"
14
#include "jlossy12.h"
15
16
17
/*
18
 * Initialize for a processing pass.
19
 */
20
21
METHODDEF(void)
22
start_pass (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
23
{
24
  j_lossy_c_ptr lossyc = (j_lossy_c_ptr) cinfo->codec;
25
26
  (*lossyc->fdct_start_pass) (cinfo);
27
  (*lossyc->coef_start_pass) (cinfo, pass_mode);
28
}
29
30
31
/*
32
 * Initialize the lossy compression codec.
33
 * This is called only once, during master selection.
34
 */
35
36
GLOBAL(void)
37
jinit_lossy_c_codec (j_compress_ptr cinfo)
38
0
{
39
0
  j_lossy_c_ptr lossyc;
40
41
  /* Create subobject in permanent pool */
42
0
  lossyc = (j_lossy_c_ptr)
43
0
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
44
0
        SIZEOF(jpeg_lossy_c_codec));
45
0
  cinfo->codec = (struct jpeg_c_codec *) lossyc;
46
47
  /* Initialize sub-modules */
48
49
  /* Forward DCT */
50
0
  jinit_forward_dct(cinfo);
51
  /* Entropy encoding: either Huffman or arithmetic coding. */
52
0
  if (cinfo->arith_code) {
53
0
    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);
54
0
  } else {
55
0
    if (cinfo->process == JPROC_PROGRESSIVE) {
56
0
#ifdef C_PROGRESSIVE_SUPPORTED
57
0
      jinit_phuff_encoder(cinfo);
58
#else
59
      ERREXIT(cinfo, JERR_NOT_COMPILED);
60
#endif
61
0
    } else
62
0
      jinit_shuff_encoder(cinfo);
63
0
  }
64
65
  /* Need a full-image coefficient buffer in any multi-pass mode. */
66
0
  jinit_c_coef_controller(cinfo,
67
0
        (boolean) (cinfo->num_scans > 1 ||
68
0
             cinfo->optimize_coding));
69
70
  /* Initialize method pointers.
71
   *
72
   * Note: entropy_start_pass and entropy_finish_pass are assigned in
73
   * jcshuff.c or jcphuff.c and compress_data is assigned in jccoefct.c.
74
   */
75
0
  lossyc->pub.start_pass = start_pass;
76
0
}