Final 350 project
Dependencies: uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed
includes/jcinit.c@0:791a779d6220, 2017-07-31 (annotated)
- Committer:
- shoaib_ahmed
- Date:
- Mon Jul 31 09:16:35 2017 +0000
- Revision:
- 0:791a779d6220
final project;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shoaib_ahmed | 0:791a779d6220 | 1 | /* |
shoaib_ahmed | 0:791a779d6220 | 2 | * jcinit.c |
shoaib_ahmed | 0:791a779d6220 | 3 | * |
shoaib_ahmed | 0:791a779d6220 | 4 | * Copyright (C) 1991-1997, Thomas G. Lane. |
shoaib_ahmed | 0:791a779d6220 | 5 | * Modified 2003-2013 by Guido Vollbeding. |
shoaib_ahmed | 0:791a779d6220 | 6 | * This file is part of the Independent JPEG Group's software. |
shoaib_ahmed | 0:791a779d6220 | 7 | * For conditions of distribution and use, see the accompanying README file. |
shoaib_ahmed | 0:791a779d6220 | 8 | * |
shoaib_ahmed | 0:791a779d6220 | 9 | * This file contains initialization logic for the JPEG compressor. |
shoaib_ahmed | 0:791a779d6220 | 10 | * This routine is in charge of selecting the modules to be executed and |
shoaib_ahmed | 0:791a779d6220 | 11 | * making an initialization call to each one. |
shoaib_ahmed | 0:791a779d6220 | 12 | * |
shoaib_ahmed | 0:791a779d6220 | 13 | * Logically, this code belongs in jcmaster.c. It's split out because |
shoaib_ahmed | 0:791a779d6220 | 14 | * linking this routine implies linking the entire compression library. |
shoaib_ahmed | 0:791a779d6220 | 15 | * For a transcoding-only application, we want to be able to use jcmaster.c |
shoaib_ahmed | 0:791a779d6220 | 16 | * without linking in the whole library. |
shoaib_ahmed | 0:791a779d6220 | 17 | */ |
shoaib_ahmed | 0:791a779d6220 | 18 | |
shoaib_ahmed | 0:791a779d6220 | 19 | #define JPEG_INTERNALS |
shoaib_ahmed | 0:791a779d6220 | 20 | #include "jinclude.h" |
shoaib_ahmed | 0:791a779d6220 | 21 | #include "jpeglib.h" |
shoaib_ahmed | 0:791a779d6220 | 22 | |
shoaib_ahmed | 0:791a779d6220 | 23 | |
shoaib_ahmed | 0:791a779d6220 | 24 | /* |
shoaib_ahmed | 0:791a779d6220 | 25 | * Master selection of compression modules. |
shoaib_ahmed | 0:791a779d6220 | 26 | * This is done once at the start of processing an image. We determine |
shoaib_ahmed | 0:791a779d6220 | 27 | * which modules will be used and give them appropriate initialization calls. |
shoaib_ahmed | 0:791a779d6220 | 28 | */ |
shoaib_ahmed | 0:791a779d6220 | 29 | |
shoaib_ahmed | 0:791a779d6220 | 30 | GLOBAL(void) |
shoaib_ahmed | 0:791a779d6220 | 31 | jinit_compress_master (j_compress_ptr cinfo) |
shoaib_ahmed | 0:791a779d6220 | 32 | { |
shoaib_ahmed | 0:791a779d6220 | 33 | long samplesperrow; |
shoaib_ahmed | 0:791a779d6220 | 34 | JDIMENSION jd_samplesperrow; |
shoaib_ahmed | 0:791a779d6220 | 35 | |
shoaib_ahmed | 0:791a779d6220 | 36 | /* For now, precision must match compiled-in value... */ |
shoaib_ahmed | 0:791a779d6220 | 37 | if (cinfo->data_precision != BITS_IN_JSAMPLE) |
shoaib_ahmed | 0:791a779d6220 | 38 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
shoaib_ahmed | 0:791a779d6220 | 39 | |
shoaib_ahmed | 0:791a779d6220 | 40 | /* Sanity check on image dimensions */ |
shoaib_ahmed | 0:791a779d6220 | 41 | if (cinfo->image_height <= 0 || cinfo->image_width <= 0 || |
shoaib_ahmed | 0:791a779d6220 | 42 | cinfo->input_components <= 0) |
shoaib_ahmed | 0:791a779d6220 | 43 | ERREXIT(cinfo, JERR_EMPTY_IMAGE); |
shoaib_ahmed | 0:791a779d6220 | 44 | |
shoaib_ahmed | 0:791a779d6220 | 45 | /* Width of an input scanline must be representable as JDIMENSION. */ |
shoaib_ahmed | 0:791a779d6220 | 46 | samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; |
shoaib_ahmed | 0:791a779d6220 | 47 | jd_samplesperrow = (JDIMENSION) samplesperrow; |
shoaib_ahmed | 0:791a779d6220 | 48 | if ((long) jd_samplesperrow != samplesperrow) |
shoaib_ahmed | 0:791a779d6220 | 49 | ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); |
shoaib_ahmed | 0:791a779d6220 | 50 | |
shoaib_ahmed | 0:791a779d6220 | 51 | /* Initialize master control (includes parameter checking/processing) */ |
shoaib_ahmed | 0:791a779d6220 | 52 | jinit_c_master_control(cinfo, FALSE /* full compression */); |
shoaib_ahmed | 0:791a779d6220 | 53 | |
shoaib_ahmed | 0:791a779d6220 | 54 | /* Preprocessing */ |
shoaib_ahmed | 0:791a779d6220 | 55 | if (! cinfo->raw_data_in) { |
shoaib_ahmed | 0:791a779d6220 | 56 | jinit_color_converter(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 57 | jinit_downsampler(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 58 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); |
shoaib_ahmed | 0:791a779d6220 | 59 | } |
shoaib_ahmed | 0:791a779d6220 | 60 | /* Forward DCT */ |
shoaib_ahmed | 0:791a779d6220 | 61 | jinit_forward_dct(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 62 | /* Entropy encoding: either Huffman or arithmetic coding. */ |
shoaib_ahmed | 0:791a779d6220 | 63 | if (cinfo->arith_code) |
shoaib_ahmed | 0:791a779d6220 | 64 | jinit_arith_encoder(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 65 | else { |
shoaib_ahmed | 0:791a779d6220 | 66 | jinit_huff_encoder(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 67 | } |
shoaib_ahmed | 0:791a779d6220 | 68 | |
shoaib_ahmed | 0:791a779d6220 | 69 | /* Need a full-image coefficient buffer in any multi-pass mode. */ |
shoaib_ahmed | 0:791a779d6220 | 70 | jinit_c_coef_controller(cinfo, |
shoaib_ahmed | 0:791a779d6220 | 71 | (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); |
shoaib_ahmed | 0:791a779d6220 | 72 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); |
shoaib_ahmed | 0:791a779d6220 | 73 | |
shoaib_ahmed | 0:791a779d6220 | 74 | jinit_marker_writer(cinfo); |
shoaib_ahmed | 0:791a779d6220 | 75 | |
shoaib_ahmed | 0:791a779d6220 | 76 | /* We can now tell the memory manager to allocate virtual arrays. */ |
shoaib_ahmed | 0:791a779d6220 | 77 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); |
shoaib_ahmed | 0:791a779d6220 | 78 | |
shoaib_ahmed | 0:791a779d6220 | 79 | /* Write the datastream header (SOI) immediately. |
shoaib_ahmed | 0:791a779d6220 | 80 | * Frame and scan headers are postponed till later. |
shoaib_ahmed | 0:791a779d6220 | 81 | * This lets application insert special markers after the SOI. |
shoaib_ahmed | 0:791a779d6220 | 82 | */ |
shoaib_ahmed | 0:791a779d6220 | 83 | (*cinfo->marker->write_file_header) (cinfo); |
shoaib_ahmed | 0:791a779d6220 | 84 | } |