transencode_codec (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) { j_lossy_c_ptr lossyc; /* Create subobject in permanent pool */ lossyc = (j_lossy_c_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(jpeg_lossy_c_codec)); cinfo->codec = (struct jpeg_c_codec *) lossyc; /* Initialize sub-modules */ /* Entropy encoding: either Huffman or arithmetic coding. */ if (cinfo->arith_code) { jinit_arith_encoder(cinfo); } else { if (cinfo->process == JPROC_PROGRESSIVE) { #ifdef C_PROGRESSIVE_SUPPORTED jinit_phuff_encoder(cinfo); #else ERREXIT(cinfo, JERR_NOT_COMPILED); #endif } else jinit_shuff_encoder(cinfo); } /* We need a special coefficient buffer controller. */ transencode_coef_controller(cinfo, coef_arrays); /* Initialize method pointers */ lossyc->pub.start_pass = start_pass_coef; lossyc->pub.compress_data = compress_output; }
jinit_compress_master (j_compress_ptr cinfo) { /* Initialize master control (includes parameter checking/processing) */ jinit_c_master_control(cinfo, FALSE /* full compression */); /* Preprocessing */ if (! cinfo->raw_data_in) { jinit_color_converter(cinfo); jinit_downsampler(cinfo); jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); } /* Forward DCT */ jinit_forward_dct(cinfo); /* Entropy encoding: either Huffman or arithmetic coding. */ if (cinfo->arith_code) { #ifdef C_ARITH_CODING_SUPPORTED jinit_arith_encoder(cinfo); #else ERREXIT(cinfo, JERR_ARITH_NOTIMPL); #endif } else { if (cinfo->progressive_mode) { #ifdef C_PROGRESSIVE_SUPPORTED jinit_phuff_encoder(cinfo); #else ERREXIT(cinfo, JERR_NOT_COMPILED); #endif } else jinit_huff_encoder(cinfo); } /* Need a full-image coefficient buffer in any multi-pass mode. */ jinit_c_coef_controller(cinfo, (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); jinit_marker_writer(cinfo); /* We can now tell the memory manager to allocate virtual arrays. */ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); /* Write the datastream header (SOI) immediately. * Frame and scan headers are postponed till later. * This lets application insert special markers after the SOI. */ (*cinfo->marker->write_file_header) (cinfo); }
jinit_lossy_c_codec (j_compress_ptr cinfo) { j_lossy_c_ptr lossyc; /* Create subobject in permanent pool */ lossyc = (j_lossy_c_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(jpeg_lossy_c_codec)); cinfo->codec = (struct jpeg_c_codec *) lossyc; /* Initialize sub-modules */ /* Forward DCT */ jinit_forward_dct(cinfo); /* Entropy encoding: either Huffman or arithmetic coding. */ if (cinfo->arith_code) { #ifdef WITH_ARITHMETIC_PATCH jinit_arith_encoder(cinfo); #else ERREXIT(cinfo, JERR_ARITH_NOTIMPL); #endif } else { if (cinfo->process == JPROC_PROGRESSIVE) { #ifdef C_PROGRESSIVE_SUPPORTED jinit_phuff_encoder(cinfo); #else ERREXIT(cinfo, JERR_NOT_COMPILED); #endif } else jinit_shuff_encoder(cinfo); } /* Need a full-image coefficient buffer in any multi-pass mode. */ jinit_c_coef_controller(cinfo, (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); /* Initialize method pointers. * * Note: entropy_start_pass and entropy_finish_pass are assigned in * jcshuff.c or jcphuff.c and compress_data is assigned in jccoefct.c. */ lossyc->pub.start_pass = start_pass; }
transencode_master_selection (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) { /* Although we don't actually use input_components for transcoding, * jcmaster.c's initial_setup will complain if input_components is 0. */ cinfo->input_components = 1; /* Initialize master control (includes parameter checking/processing) */ jinit_c_master_control(cinfo, TRUE /* transcode only */); /* Entropy encoding: either Huffman or arithmetic coding. */ if (cinfo->arith_code) { ERREXIT(cinfo, JERR_ARITH_NOTIMPL); } else { if (cinfo->progressive_mode) { #ifdef C_PROGRESSIVE_SUPPORTED jinit_phuff_encoder(cinfo); #else ERREXIT(cinfo, JERR_NOT_COMPILED); #endif } else jinit_huff_encoder(cinfo); } /* We need a special coefficient buffer controller. */ transencode_coef_controller(cinfo, coef_arrays); jinit_marker_writer(cinfo); /* We can now tell the memory manager to allocate virtual arrays. */ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); /* Write the datastream header (SOI, JFIF) immediately. * Frame and scan headers are postponed till later. * This lets application insert special markers after the SOI. */ (*cinfo->marker->write_file_header) (cinfo); }