0N/A * reserved comment block 0N/A * DO NOT REMOVE OR ALTER! 0N/A * Copyright (C) 1994-1998, Thomas G. Lane. 0N/A * This file is part of the Independent JPEG Group's software. 0N/A * For conditions of distribution and use, see the accompanying README file. 0N/A * This file contains application interface code for the compression half 0N/A * of the JPEG library. These are the "minimum" API routines that may be 0N/A * needed in either the normal full-compression case or the transcoding-only 0N/A * Most of the routines intended to be called directly by an application 0N/A * parameter-setup helper routines, jcomapi.c for routines shared by 0N/A * compression and decompression, and jctrans.c for the transcoding case. 0N/A * Initialization of a JPEG compression object. 0N/A * The error manager must already be set up (in case memory manager fails). 0N/A /* Guard against version mismatches between library and caller. */ 0N/A /* For debugging purposes, we zero the whole master structure. 0N/A * But the application has already set the err pointer, and may have set 0N/A * client_data, so we have to save and restore those fields. 0N/A * Note: if application hasn't set client_data, tools like Purify may 0N/A /* Initialize a memory manager instance for this object */ 0N/A /* Zero out pointers to permanent structures. */ 0N/A * Destruction of a JPEG compression object 0N/A * Abort processing of a JPEG compression operation, 0N/A * but don't destroy the object itself. 0N/A * Forcibly suppress or un-suppress all quantization and Huffman tables. 0N/A * Marks all currently defined tables as already written (if suppress) 0N/A * or not written (if !suppress). This will control whether they get emitted 0N/A * by a subsequent jpeg_start_compress call. 0N/A * This routine is exported for use by applications that want to produce 0N/A * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but 0N/A * since it is called by jpeg_start_compress, we put it here --- otherwise 0N/A * jcparam.o would be linked whether the application used it or not. 0N/A * Finish JPEG compression. 0N/A * If a multipass operating mode was selected, this may do a great deal of 0N/A * work including most of the actual output. 0N/A /* Terminate first pass */ 0N/A /* Perform any remaining passes */ 0N/A /* We bypass the main controller and invoke coef controller directly; 0N/A * all work is being done from the coefficient buffer. 0N/A /* Write EOI, do final cleanup */ 0N/A /* We can use jpeg_abort to release memory and reset global_state */ 0N/A * Write a special marker. 0N/A * This is only recommended for writing COM or APPn markers. 0N/A * Must be called after jpeg_start_compress() and before 0N/A * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). 0N/A/* Same, but piecemeal. */ 0N/A * Alternate compression function: just write an abbreviated table file. 0N/A * Before calling this, all parameters and a data destination must be set up. 0N/A * To produce a pair of files containing abbreviated tables and abbreviated 0N/A * image data, one would proceed as follows: 0N/A * initialize JPEG object 0N/A * set JPEG parameters 0N/A * set destination to table file 0N/A * jpeg_write_tables(cinfo); 0N/A * set destination to image file 0N/A * jpeg_start_compress(cinfo, FALSE); 0N/A * jpeg_finish_compress(cinfo); 0N/A * jpeg_write_tables has the side effect of marking all tables written 0N/A * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress 0N/A * will not re-emit the tables unless it is passed write_all_tables=TRUE. 0N/A /* (Re)initialize error mgr and destination modules */ 0N/A /* Initialize the marker writer ... bit of a crock to do it here. */ 0N/A /* Write them tables! */ 0N/A * In library releases up through v6a, we called jpeg_abort() here to free 0N/A * any working memory allocated by the destination manager and marker 0N/A * writer. Some applications had a problem with that: they allocated space 0N/A * of their own from the library memory manager, and didn't want it to go 0N/A * away during write_tables. So now we do nothing. This will cause a 0N/A * memory leak if an app calls write_tables repeatedly without doing a full 0N/A * compression cycle or otherwise resetting the JPEG object. However, that 0N/A * seems less bad than unexpectedly freeing memory in the normal case. 0N/A * An app that prefers the old behavior can call jpeg_abort for itself after 0N/A * each call to jpeg_write_tables().