/src/libjpeg-turbo.2.0.x/jcinit.c
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | /* | 
| 2 |  |  * jcinit.c | 
| 3 |  |  * | 
| 4 |  |  * This file was part of the Independent JPEG Group's software: | 
| 5 |  |  * Copyright (C) 1991-1997, Thomas G. Lane. | 
| 6 |  |  * libjpeg-turbo Modifications: | 
| 7 |  |  * Copyright (C) 2020, D. R. Commander. | 
| 8 |  |  * For conditions of distribution and use, see the accompanying README.ijg | 
| 9 |  |  * file. | 
| 10 |  |  * | 
| 11 |  |  * This file contains initialization logic for the JPEG compressor. | 
| 12 |  |  * This routine is in charge of selecting the modules to be executed and | 
| 13 |  |  * making an initialization call to each one. | 
| 14 |  |  * | 
| 15 |  |  * Logically, this code belongs in jcmaster.c.  It's split out because | 
| 16 |  |  * linking this routine implies linking the entire compression library. | 
| 17 |  |  * For a transcoding-only application, we want to be able to use jcmaster.c | 
| 18 |  |  * without linking in the whole library. | 
| 19 |  |  */ | 
| 20 |  |  | 
| 21 |  | #define JPEG_INTERNALS | 
| 22 |  | #include "jinclude.h" | 
| 23 |  | #include "jpeglib.h" | 
| 24 |  | #include "jpegcomp.h" | 
| 25 |  |  | 
| 26 |  |  | 
| 27 |  | /* | 
| 28 |  |  * Master selection of compression modules. | 
| 29 |  |  * This is done once at the start of processing an image.  We determine | 
| 30 |  |  * which modules will be used and give them appropriate initialization calls. | 
| 31 |  |  */ | 
| 32 |  |  | 
| 33 |  | GLOBAL(void) | 
| 34 |  | jinit_compress_master(j_compress_ptr cinfo) | 
| 35 | 5.66k | { | 
| 36 |  |   /* Initialize master control (includes parameter checking/processing) */ | 
| 37 | 5.66k |   jinit_c_master_control(cinfo, FALSE /* full compression */); | 
| 38 |  |  | 
| 39 |  |   /* Preprocessing */ | 
| 40 | 5.66k |   if (!cinfo->raw_data_in) { | 
| 41 | 5.61k |     jinit_color_converter(cinfo); | 
| 42 | 5.61k |     jinit_downsampler(cinfo); | 
| 43 | 5.61k |     jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); | 
| 44 | 5.61k |   } | 
| 45 |  |   /* Forward DCT */ | 
| 46 | 5.66k |   jinit_forward_dct(cinfo); | 
| 47 |  |   /* Entropy encoding: either Huffman or arithmetic coding. */ | 
| 48 | 5.66k |   if (cinfo->arith_code) { | 
| 49 | 2.08k | #ifdef C_ARITH_CODING_SUPPORTED | 
| 50 | 2.08k |     jinit_arith_encoder(cinfo); | 
| 51 |  | #else | 
| 52 |  |     ERREXIT(cinfo, JERR_ARITH_NOTIMPL); | 
| 53 |  | #endif | 
| 54 | 3.58k |   } else { | 
| 55 | 3.58k |     if (cinfo->progressive_mode) { | 
| 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 | 3.58k |       jinit_huff_encoder(cinfo); | 
| 63 | 3.58k |   } | 
| 64 |  |  | 
| 65 |  |   /* Need a full-image coefficient buffer in any multi-pass mode. */ | 
| 66 | 5.66k |   jinit_c_coef_controller(cinfo, (boolean)(cinfo->num_scans > 1 || | 
| 67 | 5.66k |                                            cinfo->optimize_coding)); | 
| 68 | 5.66k |   jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); | 
| 69 |  |  | 
| 70 | 5.66k |   jinit_marker_writer(cinfo); | 
| 71 |  |  | 
| 72 |  |   /* We can now tell the memory manager to allocate virtual arrays. */ | 
| 73 | 5.66k |   (*cinfo->mem->realize_virt_arrays) ((j_common_ptr)cinfo); | 
| 74 |  |  | 
| 75 |  |   /* Write the datastream header (SOI) immediately. | 
| 76 |  |    * Frame and scan headers are postponed till later. | 
| 77 |  |    * This lets application insert special markers after the SOI. | 
| 78 |  |    */ | 
| 79 | 5.66k |   (*cinfo->marker->write_file_header) (cinfo); | 
| 80 | 5.66k | } |