Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * jcinit.c |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1991-1997, Thomas G. Lane. |
michael@0 | 5 | * This file is part of the Independent JPEG Group's software. |
michael@0 | 6 | * For conditions of distribution and use, see the accompanying README file. |
michael@0 | 7 | * |
michael@0 | 8 | * This file contains initialization logic for the JPEG compressor. |
michael@0 | 9 | * This routine is in charge of selecting the modules to be executed and |
michael@0 | 10 | * making an initialization call to each one. |
michael@0 | 11 | * |
michael@0 | 12 | * Logically, this code belongs in jcmaster.c. It's split out because |
michael@0 | 13 | * linking this routine implies linking the entire compression library. |
michael@0 | 14 | * For a transcoding-only application, we want to be able to use jcmaster.c |
michael@0 | 15 | * without linking in the whole library. |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | #define JPEG_INTERNALS |
michael@0 | 19 | #include "jinclude.h" |
michael@0 | 20 | #include "jpeglib.h" |
michael@0 | 21 | |
michael@0 | 22 | |
michael@0 | 23 | /* |
michael@0 | 24 | * Master selection of compression modules. |
michael@0 | 25 | * This is done once at the start of processing an image. We determine |
michael@0 | 26 | * which modules will be used and give them appropriate initialization calls. |
michael@0 | 27 | */ |
michael@0 | 28 | |
michael@0 | 29 | GLOBAL(void) |
michael@0 | 30 | jinit_compress_master (j_compress_ptr cinfo) |
michael@0 | 31 | { |
michael@0 | 32 | /* Initialize master control (includes parameter checking/processing) */ |
michael@0 | 33 | jinit_c_master_control(cinfo, FALSE /* full compression */); |
michael@0 | 34 | |
michael@0 | 35 | /* Preprocessing */ |
michael@0 | 36 | if (! cinfo->raw_data_in) { |
michael@0 | 37 | jinit_color_converter(cinfo); |
michael@0 | 38 | jinit_downsampler(cinfo); |
michael@0 | 39 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); |
michael@0 | 40 | } |
michael@0 | 41 | /* Forward DCT */ |
michael@0 | 42 | jinit_forward_dct(cinfo); |
michael@0 | 43 | /* Entropy encoding: either Huffman or arithmetic coding. */ |
michael@0 | 44 | if (cinfo->arith_code) { |
michael@0 | 45 | #ifdef C_ARITH_CODING_SUPPORTED |
michael@0 | 46 | jinit_arith_encoder(cinfo); |
michael@0 | 47 | #else |
michael@0 | 48 | ERREXIT(cinfo, JERR_ARITH_NOTIMPL); |
michael@0 | 49 | #endif |
michael@0 | 50 | } else { |
michael@0 | 51 | if (cinfo->progressive_mode) { |
michael@0 | 52 | #ifdef C_PROGRESSIVE_SUPPORTED |
michael@0 | 53 | jinit_phuff_encoder(cinfo); |
michael@0 | 54 | #else |
michael@0 | 55 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
michael@0 | 56 | #endif |
michael@0 | 57 | } else |
michael@0 | 58 | jinit_huff_encoder(cinfo); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | /* Need a full-image coefficient buffer in any multi-pass mode. */ |
michael@0 | 62 | jinit_c_coef_controller(cinfo, |
michael@0 | 63 | (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); |
michael@0 | 64 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); |
michael@0 | 65 | |
michael@0 | 66 | jinit_marker_writer(cinfo); |
michael@0 | 67 | |
michael@0 | 68 | /* We can now tell the memory manager to allocate virtual arrays. */ |
michael@0 | 69 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); |
michael@0 | 70 | |
michael@0 | 71 | /* Write the datastream header (SOI) immediately. |
michael@0 | 72 | * Frame and scan headers are postponed till later. |
michael@0 | 73 | * This lets application insert special markers after the SOI. |
michael@0 | 74 | */ |
michael@0 | 75 | (*cinfo->marker->write_file_header) (cinfo); |
michael@0 | 76 | } |