/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains routines to write JPEG datastream markers.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
typedef enum { /* JPEG marker codes */
} JPEG_MARKER;
/* Private state */
typedef struct {
/*
* Basic output routines.
*
* Note that we do not support suspension while writing a marker.
* Therefore, an application using suspension must ensure that there is
* enough buffer space for the initial markers (typ. 600-700 bytes) before
* calling jpeg_start_compress, and enough space to write the trailing EOI
* (a few bytes) before calling jpeg_finish_compress. Multipass compression
* modes are not supported at all with suspension, so those two are the only
* points where markers will be written.
*/
LOCAL(void)
/* Emit a byte */
{
if (--dest->free_in_buffer == 0) {
}
}
LOCAL(void)
/* Emit a marker code */
{
}
LOCAL(void)
/* Emit a 2-byte integer; these are always MSB first in JPEG files */
{
}
/*
* Routines to write specific marker types.
*/
LOCAL(int)
/* Emit a DQT marker */
/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
{
int prec;
int i;
prec = 0;
for (i = 0; i < DCTSIZE2; i++) {
prec = 1;
}
if (! qtbl->sent_table) {
for (i = 0; i < DCTSIZE2; i++) {
/* The table entries must be emitted in zigzag order. */
if (prec)
}
}
return prec;
}
LOCAL(void)
/* Emit a DHT marker */
{
int length, i;
if (is_ac) {
} else {
}
if (! htbl->sent_table) {
length = 0;
for (i = 1; i <= 16; i++)
for (i = 1; i <= 16; i++)
for (i = 0; i < length; i++)
}
}
LOCAL(void)
/* Emit a DAC marker */
/* Since the useful info is so small, we want to emit all the tables in */
/* one DAC marker. Therefore this routine does its own scan of the table. */
{
#ifdef C_ARITH_CODING_SUPPORTED
int length, i;
for (i = 0; i < NUM_ARITH_TBLS; i++)
for (i = 0; i < cinfo->comps_in_scan; i++) {
}
length = 0;
for (i = 0; i < NUM_ARITH_TBLS; i++)
for (i = 0; i < NUM_ARITH_TBLS; i++) {
if (dc_in_use[i]) {
}
if (ac_in_use[i]) {
}
}
#endif /* C_ARITH_CODING_SUPPORTED */
}
LOCAL(void)
/* Emit a DRI marker */
{
}
LOCAL(void)
/* Emit a SOF marker */
{
int ci;
/* Make sure image isn't bigger than SOF field can handle */
}
}
LOCAL(void)
/* Emit a SOS marker */
{
for (i = 0; i < cinfo->comps_in_scan; i++) {
if (cinfo->progressive_mode) {
/* Progressive mode: only DC or only AC tables are used in one scan;
* furthermore, Huffman coding of DC refinement uses no table at all.
* We emit 0 for unused field(s); this is recommended by the P&M text
* but does not seem to be specified in the standard.
*/
ta = 0; /* DC scan */
td = 0; /* no DC table either */
} else {
td = 0; /* AC scan */
}
}
}
}
LOCAL(void)
/* Emit a JFIF-compliant APP0 marker */
{
/*
* Length of APP0 block (2 bytes)
* Block ID (4 bytes - ASCII "JFIF")
* Zero byte (1 byte to terminate the ID string)
* Version Major, Minor (2 bytes - major first)
* Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
* Xdpu (2 bytes - dots per unit horizontal)
* Ydpu (2 bytes - dots per unit vertical)
* Thumbnail X size (1 byte)
* Thumbnail Y size (1 byte)
*/
}
LOCAL(void)
/* Emit an Adobe APP14 marker */
{
/*
* Length of APP14 block (2 bytes)
* Block ID (5 bytes - ASCII "Adobe")
* Version Number (2 bytes - currently 100)
* Flags0 (2 bytes - currently 0)
* Flags1 (2 bytes - currently 0)
* Color transform (1 byte)
*
* Although Adobe TN 5116 mentions Version = 101, all the Adobe files
* now in circulation seem to use Version = 100, so that's what we write.
*
* We write the color transform byte as 1 if the JPEG color space is
* YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
* whether the encoder performed a transformation, which is pretty useless.
*/
switch (cinfo->jpeg_color_space) {
case JCS_YCbCr:
break;
case JCS_YCCK:
break;
default:
break;
}
}
/*
* These routines allow writing an arbitrary marker with parameters.
* The only intended use is to emit COM or APPn markers after calling
* write_file_header and before calling write_frame_header.
* Other uses are not guaranteed to produce desirable results.
* Counting the parameter bytes properly is the caller's responsibility.
*/
METHODDEF(void)
/* Emit an arbitrary marker header */
{
}
METHODDEF(void)
/* Emit one byte of marker parameters following write_marker_header */
{
}
/*
* Write datastream header.
* This consists of an SOI and optional APPn markers.
* We recommend use of the JFIF marker, but not the Adobe marker,
* when using YCbCr or grayscale data. The JFIF marker should NOT
* be used for any other JPEG colorspace. The Adobe marker is helpful
* to distinguish RGB, CMYK, and YCCK colorspaces.
* Note that an application can write additional header markers after
* jpeg_start_compress returns.
*/
METHODDEF(void)
{
/* SOI is defined to reset restart interval to 0 */
marker->last_restart_interval = 0;
}
/*
* Write frame header.
* This consists of DQT and SOFn markers.
* Note that we do not emit the SOF until we have emitted the DQT(s).
* This avoids compatibility problems with incorrect implementations that
* try to error-check the quant table numbers as soon as they see the SOF.
*/
METHODDEF(void)
{
/* Emit DQT for each quantization table.
* Note that emit_dqt() suppresses any duplicate tables.
*/
prec = 0;
}
/* now prec is nonzero iff there are any 16-bit quant tables. */
/* Check for a non-baseline specification.
* Note we assume that Huffman table numbers won't be changed later.
*/
is_baseline = FALSE;
} else {
is_baseline = TRUE;
is_baseline = FALSE;
}
if (prec && is_baseline) {
is_baseline = FALSE;
/* If it's baseline except for quantizer size, warn the user */
}
}
/* Emit the proper SOF marker */
if (cinfo->arith_code) {
} else {
if (cinfo->progressive_mode)
else if (is_baseline)
else
}
}
/*
* Write scan header.
* This consists of DHT or DAC markers, optional DRI, and SOS.
* Compressed data will be written following the SOS.
*/
METHODDEF(void)
{
int i;
if (cinfo->arith_code) {
/* Emit arith conditioning info. We may have some duplication
* if the file has multiple scans, but it's so small it's hardly
* worth worrying about.
*/
} else {
/* Emit Huffman tables.
* Note that emit_dht() suppresses any duplicate tables.
*/
for (i = 0; i < cinfo->comps_in_scan; i++) {
if (cinfo->progressive_mode) {
/* Progressive mode: only DC or only AC tables are used in one scan */
} else {
}
} else {
/* Sequential mode: need both DC and AC tables */
}
}
}
/* Emit DRI if required --- note that DRI value could change for each scan.
* We avoid wasting space with unnecessary DRIs, however.
*/
}
}
/*
* Write datastream trailer.
*/
METHODDEF(void)
{
}
/*
* Write an abbreviated table-specification datastream.
* This consists of SOI, DQT and DHT tables, and EOI.
* Any table that is defined and not marked sent_table = TRUE will be
* emitted. Note that all tables will be marked sent_table = TRUE at exit.
*/
METHODDEF(void)
{
int i;
/* Emit DQT for each quantization table.
* Only emit those tables that are actually associated with image components,
* if there are any image components, which will usually not be the case.
* Note that emit_dqt() suppresses any duplicate tables.
*/
if (cinfo->num_components > 0) {
int ci;
}
} else {
for (i = 0; i < NUM_QUANT_TBLS; i++) {
}
}
if (! cinfo->arith_code) {
for (i = 0; i < NUM_HUFF_TBLS; i++) {
}
}
}
/*
* Initialize the marker writer module.
*/
GLOBAL(void)
{
/* Create the subobject */
marker = (my_marker_ptr)
/* Initialize method pointers */
/* Initialize private state */
marker->last_restart_interval = 0;
}