Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenjcmarker.c
Go to the documentation of this file.
00001 /* 00002 * jcmarker.c 00003 * 00004 * Copyright (C) 1991-1998, Thomas G. Lane. 00005 * Modified 2003-2010 by Guido Vollbeding. 00006 * This file is part of the Independent JPEG Group's software. 00007 * For conditions of distribution and use, see the accompanying README file. 00008 * 00009 * This file contains routines to write JPEG datastream markers. 00010 */ 00011 00012 #define JPEG_INTERNALS 00013 #include "jinclude.h" 00014 #include "jpeglib.h" 00015 00016 00017 typedef enum { /* JPEG marker codes */ 00018 M_SOF0 = 0xc0, 00019 M_SOF1 = 0xc1, 00020 M_SOF2 = 0xc2, 00021 M_SOF3 = 0xc3, 00022 00023 M_SOF5 = 0xc5, 00024 M_SOF6 = 0xc6, 00025 M_SOF7 = 0xc7, 00026 00027 M_JPG = 0xc8, 00028 M_SOF9 = 0xc9, 00029 M_SOF10 = 0xca, 00030 M_SOF11 = 0xcb, 00031 00032 M_SOF13 = 0xcd, 00033 M_SOF14 = 0xce, 00034 M_SOF15 = 0xcf, 00035 00036 M_DHT = 0xc4, 00037 00038 M_DAC = 0xcc, 00039 00040 M_RST0 = 0xd0, 00041 M_RST1 = 0xd1, 00042 M_RST2 = 0xd2, 00043 M_RST3 = 0xd3, 00044 M_RST4 = 0xd4, 00045 M_RST5 = 0xd5, 00046 M_RST6 = 0xd6, 00047 M_RST7 = 0xd7, 00048 00049 M_SOI = 0xd8, 00050 M_EOI = 0xd9, 00051 M_SOS = 0xda, 00052 M_DQT = 0xdb, 00053 M_DNL = 0xdc, 00054 M_DRI = 0xdd, 00055 M_DHP = 0xde, 00056 M_EXP = 0xdf, 00057 00058 M_APP0 = 0xe0, 00059 M_APP1 = 0xe1, 00060 M_APP2 = 0xe2, 00061 M_APP3 = 0xe3, 00062 M_APP4 = 0xe4, 00063 M_APP5 = 0xe5, 00064 M_APP6 = 0xe6, 00065 M_APP7 = 0xe7, 00066 M_APP8 = 0xe8, 00067 M_APP9 = 0xe9, 00068 M_APP10 = 0xea, 00069 M_APP11 = 0xeb, 00070 M_APP12 = 0xec, 00071 M_APP13 = 0xed, 00072 M_APP14 = 0xee, 00073 M_APP15 = 0xef, 00074 00075 M_JPG0 = 0xf0, 00076 M_JPG13 = 0xfd, 00077 M_COM = 0xfe, 00078 00079 M_TEM = 0x01, 00080 00081 M_ERROR = 0x100 00082 } JPEG_MARKER; 00083 00084 00085 /* Private state */ 00086 00087 typedef struct { 00088 struct jpeg_marker_writer pub; /* public fields */ 00089 00090 unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ 00091 } my_marker_writer; 00092 00093 typedef my_marker_writer * my_marker_ptr; 00094 00095 00096 /* 00097 * Basic output routines. 00098 * 00099 * Note that we do not support suspension while writing a marker. 00100 * Therefore, an application using suspension must ensure that there is 00101 * enough buffer space for the initial markers (typ. 600-700 bytes) before 00102 * calling jpeg_start_compress, and enough space to write the trailing EOI 00103 * (a few bytes) before calling jpeg_finish_compress. Multipass compression 00104 * modes are not supported at all with suspension, so those two are the only 00105 * points where markers will be written. 00106 */ 00107 00108 LOCAL(void) 00109 emit_byte (j_compress_ptr cinfo, int val) 00110 /* Emit a byte */ 00111 { 00112 struct jpeg_destination_mgr * dest = cinfo->dest; 00113 00114 *(dest->next_output_byte)++ = (JOCTET) val; 00115 if (--dest->free_in_buffer == 0) { 00116 if (! (*dest->empty_output_buffer) (cinfo)) 00117 ERREXIT(cinfo, JERR_CANT_SUSPEND); 00118 } 00119 } 00120 00121 00122 LOCAL(void) 00123 emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) 00124 /* Emit a marker code */ 00125 { 00126 emit_byte(cinfo, 0xFF); 00127 emit_byte(cinfo, (int) mark); 00128 } 00129 00130 00131 LOCAL(void) 00132 emit_2bytes (j_compress_ptr cinfo, int value) 00133 /* Emit a 2-byte integer; these are always MSB first in JPEG files */ 00134 { 00135 emit_byte(cinfo, (value >> 8) & 0xFF); 00136 emit_byte(cinfo, value & 0xFF); 00137 } 00138 00139 00140 /* 00141 * Routines to write specific marker types. 00142 */ 00143 00144 LOCAL(int) 00145 emit_dqt (j_compress_ptr cinfo, int index) 00146 /* Emit a DQT marker */ 00147 /* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ 00148 { 00149 JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; 00150 int prec; 00151 int i; 00152 00153 if (qtbl == NULL) 00154 ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); 00155 00156 prec = 0; 00157 for (i = 0; i <= cinfo->lim_Se; i++) { 00158 if (qtbl->quantval[cinfo->natural_order[i]] > 255) 00159 prec = 1; 00160 } 00161 00162 if (! qtbl->sent_table) { 00163 emit_marker(cinfo, M_DQT); 00164 00165 emit_2bytes(cinfo, 00166 prec ? cinfo->lim_Se * 2 + 2 + 1 + 2 : cinfo->lim_Se + 1 + 1 + 2); 00167 00168 emit_byte(cinfo, index + (prec<<4)); 00169 00170 for (i = 0; i <= cinfo->lim_Se; i++) { 00171 /* The table entries must be emitted in zigzag order. */ 00172 unsigned int qval = qtbl->quantval[cinfo->natural_order[i]]; 00173 if (prec) 00174 emit_byte(cinfo, (int) (qval >> 8)); 00175 emit_byte(cinfo, (int) (qval & 0xFF)); 00176 } 00177 00178 qtbl->sent_table = TRUE; 00179 } 00180 00181 return prec; 00182 } 00183 00184 00185 LOCAL(void) 00186 emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) 00187 /* Emit a DHT marker */ 00188 { 00189 JHUFF_TBL * htbl; 00190 int length, i; 00191 00192 if (is_ac) { 00193 htbl = cinfo->ac_huff_tbl_ptrs[index]; 00194 index += 0x10; /* output index has AC bit set */ 00195 } else { 00196 htbl = cinfo->dc_huff_tbl_ptrs[index]; 00197 } 00198 00199 if (htbl == NULL) 00200 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); 00201 00202 if (! htbl->sent_table) { 00203 emit_marker(cinfo, M_DHT); 00204 00205 length = 0; 00206 for (i = 1; i <= 16; i++) 00207 length += htbl->bits[i]; 00208 00209 emit_2bytes(cinfo, length + 2 + 1 + 16); 00210 emit_byte(cinfo, index); 00211 00212 for (i = 1; i <= 16; i++) 00213 emit_byte(cinfo, htbl->bits[i]); 00214 00215 for (i = 0; i < length; i++) 00216 emit_byte(cinfo, htbl->huffval[i]); 00217 00218 htbl->sent_table = TRUE; 00219 } 00220 } 00221 00222 00223 LOCAL(void) 00224 emit_dac (j_compress_ptr cinfo) 00225 /* Emit a DAC marker */ 00226 /* Since the useful info is so small, we want to emit all the tables in */ 00227 /* one DAC marker. Therefore this routine does its own scan of the table. */ 00228 { 00229 #ifdef C_ARITH_CODING_SUPPORTED 00230 char dc_in_use[NUM_ARITH_TBLS]; 00231 char ac_in_use[NUM_ARITH_TBLS]; 00232 int length, i; 00233 jpeg_component_info *compptr; 00234 00235 for (i = 0; i < NUM_ARITH_TBLS; i++) 00236 dc_in_use[i] = ac_in_use[i] = 0; 00237 00238 for (i = 0; i < cinfo->comps_in_scan; i++) { 00239 compptr = cinfo->cur_comp_info[i]; 00240 /* DC needs no table for refinement scan */ 00241 if (cinfo->Ss == 0 && cinfo->Ah == 0) 00242 dc_in_use[compptr->dc_tbl_no] = 1; 00243 /* AC needs no table when not present */ 00244 if (cinfo->Se) 00245 ac_in_use[compptr->ac_tbl_no] = 1; 00246 } 00247 00248 length = 0; 00249 for (i = 0; i < NUM_ARITH_TBLS; i++) 00250 length += dc_in_use[i] + ac_in_use[i]; 00251 00252 if (length) { 00253 emit_marker(cinfo, M_DAC); 00254 00255 emit_2bytes(cinfo, length*2 + 2); 00256 00257 for (i = 0; i < NUM_ARITH_TBLS; i++) { 00258 if (dc_in_use[i]) { 00259 emit_byte(cinfo, i); 00260 emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); 00261 } 00262 if (ac_in_use[i]) { 00263 emit_byte(cinfo, i + 0x10); 00264 emit_byte(cinfo, cinfo->arith_ac_K[i]); 00265 } 00266 } 00267 } 00268 #endif /* C_ARITH_CODING_SUPPORTED */ 00269 } 00270 00271 00272 LOCAL(void) 00273 emit_dri (j_compress_ptr cinfo) 00274 /* Emit a DRI marker */ 00275 { 00276 emit_marker(cinfo, M_DRI); 00277 00278 emit_2bytes(cinfo, 4); /* fixed length */ 00279 00280 emit_2bytes(cinfo, (int) cinfo->restart_interval); 00281 } 00282 00283 00284 LOCAL(void) 00285 emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) 00286 /* Emit a SOF marker */ 00287 { 00288 int ci; 00289 jpeg_component_info *compptr; 00290 00291 emit_marker(cinfo, code); 00292 00293 emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ 00294 00295 /* Make sure image isn't bigger than SOF field can handle */ 00296 if ((long) cinfo->jpeg_height > 65535L || 00297 (long) cinfo->jpeg_width > 65535L) 00298 ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); 00299 00300 emit_byte(cinfo, cinfo->data_precision); 00301 emit_2bytes(cinfo, (int) cinfo->jpeg_height); 00302 emit_2bytes(cinfo, (int) cinfo->jpeg_width); 00303 00304 emit_byte(cinfo, cinfo->num_components); 00305 00306 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00307 ci++, compptr++) { 00308 emit_byte(cinfo, compptr->component_id); 00309 emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); 00310 emit_byte(cinfo, compptr->quant_tbl_no); 00311 } 00312 } 00313 00314 00315 LOCAL(void) 00316 emit_sos (j_compress_ptr cinfo) 00317 /* Emit a SOS marker */ 00318 { 00319 int i, td, ta; 00320 jpeg_component_info *compptr; 00321 00322 emit_marker(cinfo, M_SOS); 00323 00324 emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ 00325 00326 emit_byte(cinfo, cinfo->comps_in_scan); 00327 00328 for (i = 0; i < cinfo->comps_in_scan; i++) { 00329 compptr = cinfo->cur_comp_info[i]; 00330 emit_byte(cinfo, compptr->component_id); 00331 00332 /* We emit 0 for unused field(s); this is recommended by the P&M text 00333 * but does not seem to be specified in the standard. 00334 */ 00335 00336 /* DC needs no table for refinement scan */ 00337 td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0; 00338 /* AC needs no table when not present */ 00339 ta = cinfo->Se ? compptr->ac_tbl_no : 0; 00340 00341 emit_byte(cinfo, (td << 4) + ta); 00342 } 00343 00344 emit_byte(cinfo, cinfo->Ss); 00345 emit_byte(cinfo, cinfo->Se); 00346 emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); 00347 } 00348 00349 00350 LOCAL(void) 00351 emit_pseudo_sos (j_compress_ptr cinfo) 00352 /* Emit a pseudo SOS marker */ 00353 { 00354 emit_marker(cinfo, M_SOS); 00355 00356 emit_2bytes(cinfo, 2 + 1 + 3); /* length */ 00357 00358 emit_byte(cinfo, 0); /* Ns */ 00359 00360 emit_byte(cinfo, 0); /* Ss */ 00361 emit_byte(cinfo, cinfo->block_size * cinfo->block_size - 1); /* Se */ 00362 emit_byte(cinfo, 0); /* Ah/Al */ 00363 } 00364 00365 00366 LOCAL(void) 00367 emit_jfif_app0 (j_compress_ptr cinfo) 00368 /* Emit a JFIF-compliant APP0 marker */ 00369 { 00370 /* 00371 * Length of APP0 block (2 bytes) 00372 * Block ID (4 bytes - ASCII "JFIF") 00373 * Zero byte (1 byte to terminate the ID string) 00374 * Version Major, Minor (2 bytes - major first) 00375 * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) 00376 * Xdpu (2 bytes - dots per unit horizontal) 00377 * Ydpu (2 bytes - dots per unit vertical) 00378 * Thumbnail X size (1 byte) 00379 * Thumbnail Y size (1 byte) 00380 */ 00381 00382 emit_marker(cinfo, M_APP0); 00383 00384 emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ 00385 00386 emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ 00387 emit_byte(cinfo, 0x46); 00388 emit_byte(cinfo, 0x49); 00389 emit_byte(cinfo, 0x46); 00390 emit_byte(cinfo, 0); 00391 emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ 00392 emit_byte(cinfo, cinfo->JFIF_minor_version); 00393 emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ 00394 emit_2bytes(cinfo, (int) cinfo->X_density); 00395 emit_2bytes(cinfo, (int) cinfo->Y_density); 00396 emit_byte(cinfo, 0); /* No thumbnail image */ 00397 emit_byte(cinfo, 0); 00398 } 00399 00400 00401 LOCAL(void) 00402 emit_adobe_app14 (j_compress_ptr cinfo) 00403 /* Emit an Adobe APP14 marker */ 00404 { 00405 /* 00406 * Length of APP14 block (2 bytes) 00407 * Block ID (5 bytes - ASCII "Adobe") 00408 * Version Number (2 bytes - currently 100) 00409 * Flags0 (2 bytes - currently 0) 00410 * Flags1 (2 bytes - currently 0) 00411 * Color transform (1 byte) 00412 * 00413 * Although Adobe TN 5116 mentions Version = 101, all the Adobe files 00414 * now in circulation seem to use Version = 100, so that's what we write. 00415 * 00416 * We write the color transform byte as 1 if the JPEG color space is 00417 * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with 00418 * whether the encoder performed a transformation, which is pretty useless. 00419 */ 00420 00421 emit_marker(cinfo, M_APP14); 00422 00423 emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ 00424 00425 emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ 00426 emit_byte(cinfo, 0x64); 00427 emit_byte(cinfo, 0x6F); 00428 emit_byte(cinfo, 0x62); 00429 emit_byte(cinfo, 0x65); 00430 emit_2bytes(cinfo, 100); /* Version */ 00431 emit_2bytes(cinfo, 0); /* Flags0 */ 00432 emit_2bytes(cinfo, 0); /* Flags1 */ 00433 switch (cinfo->jpeg_color_space) { 00434 case JCS_YCbCr: 00435 emit_byte(cinfo, 1); /* Color transform = 1 */ 00436 break; 00437 case JCS_YCCK: 00438 emit_byte(cinfo, 2); /* Color transform = 2 */ 00439 break; 00440 default: 00441 emit_byte(cinfo, 0); /* Color transform = 0 */ 00442 break; 00443 } 00444 } 00445 00446 00447 /* 00448 * These routines allow writing an arbitrary marker with parameters. 00449 * The only intended use is to emit COM or APPn markers after calling 00450 * write_file_header and before calling write_frame_header. 00451 * Other uses are not guaranteed to produce desirable results. 00452 * Counting the parameter bytes properly is the caller's responsibility. 00453 */ 00454 00455 METHODDEF(void) 00456 write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) 00457 /* Emit an arbitrary marker header */ 00458 { 00459 if (datalen > (unsigned int) 65533) /* safety check */ 00460 ERREXIT(cinfo, JERR_BAD_LENGTH); 00461 00462 emit_marker(cinfo, (JPEG_MARKER) marker); 00463 00464 emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ 00465 } 00466 00467 METHODDEF(void) 00468 write_marker_byte (j_compress_ptr cinfo, int val) 00469 /* Emit one byte of marker parameters following write_marker_header */ 00470 { 00471 emit_byte(cinfo, val); 00472 } 00473 00474 00475 /* 00476 * Write datastream header. 00477 * This consists of an SOI and optional APPn markers. 00478 * We recommend use of the JFIF marker, but not the Adobe marker, 00479 * when using YCbCr or grayscale data. The JFIF marker should NOT 00480 * be used for any other JPEG colorspace. The Adobe marker is helpful 00481 * to distinguish RGB, CMYK, and YCCK colorspaces. 00482 * Note that an application can write additional header markers after 00483 * jpeg_start_compress returns. 00484 */ 00485 00486 METHODDEF(void) 00487 write_file_header (j_compress_ptr cinfo) 00488 { 00489 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; 00490 00491 emit_marker(cinfo, M_SOI); /* first the SOI */ 00492 00493 /* SOI is defined to reset restart interval to 0 */ 00494 marker->last_restart_interval = 0; 00495 00496 if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ 00497 emit_jfif_app0(cinfo); 00498 if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ 00499 emit_adobe_app14(cinfo); 00500 } 00501 00502 00503 /* 00504 * Write frame header. 00505 * This consists of DQT and SOFn markers, and a conditional pseudo SOS marker. 00506 * Note that we do not emit the SOF until we have emitted the DQT(s). 00507 * This avoids compatibility problems with incorrect implementations that 00508 * try to error-check the quant table numbers as soon as they see the SOF. 00509 */ 00510 00511 METHODDEF(void) 00512 write_frame_header (j_compress_ptr cinfo) 00513 { 00514 int ci, prec; 00515 boolean is_baseline; 00516 jpeg_component_info *compptr; 00517 00518 /* Emit DQT for each quantization table. 00519 * Note that emit_dqt() suppresses any duplicate tables. 00520 */ 00521 prec = 0; 00522 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00523 ci++, compptr++) { 00524 prec += emit_dqt(cinfo, compptr->quant_tbl_no); 00525 } 00526 /* now prec is nonzero iff there are any 16-bit quant tables. */ 00527 00528 /* Check for a non-baseline specification. 00529 * Note we assume that Huffman table numbers won't be changed later. 00530 */ 00531 if (cinfo->arith_code || cinfo->progressive_mode || 00532 cinfo->data_precision != 8 || cinfo->block_size != DCTSIZE) { 00533 is_baseline = FALSE; 00534 } else { 00535 is_baseline = TRUE; 00536 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 00537 ci++, compptr++) { 00538 if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) 00539 is_baseline = FALSE; 00540 } 00541 if (prec && is_baseline) { 00542 is_baseline = FALSE; 00543 /* If it's baseline except for quantizer size, warn the user */ 00544 TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); 00545 } 00546 } 00547 00548 /* Emit the proper SOF marker */ 00549 if (cinfo->arith_code) { 00550 if (cinfo->progressive_mode) 00551 emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */ 00552 else 00553 emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */ 00554 } else { 00555 if (cinfo->progressive_mode) 00556 emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ 00557 else if (is_baseline) 00558 emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ 00559 else 00560 emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ 00561 } 00562 00563 /* Check to emit pseudo SOS marker */ 00564 if (cinfo->progressive_mode && cinfo->block_size != DCTSIZE) 00565 emit_pseudo_sos(cinfo); 00566 } 00567 00568 00569 /* 00570 * Write scan header. 00571 * This consists of DHT or DAC markers, optional DRI, and SOS. 00572 * Compressed data will be written following the SOS. 00573 */ 00574 00575 METHODDEF(void) 00576 write_scan_header (j_compress_ptr cinfo) 00577 { 00578 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; 00579 int i; 00580 jpeg_component_info *compptr; 00581 00582 if (cinfo->arith_code) { 00583 /* Emit arith conditioning info. We may have some duplication 00584 * if the file has multiple scans, but it's so small it's hardly 00585 * worth worrying about. 00586 */ 00587 emit_dac(cinfo); 00588 } else { 00589 /* Emit Huffman tables. 00590 * Note that emit_dht() suppresses any duplicate tables. 00591 */ 00592 for (i = 0; i < cinfo->comps_in_scan; i++) { 00593 compptr = cinfo->cur_comp_info[i]; 00594 /* DC needs no table for refinement scan */ 00595 if (cinfo->Ss == 0 && cinfo->Ah == 0) 00596 emit_dht(cinfo, compptr->dc_tbl_no, FALSE); 00597 /* AC needs no table when not present */ 00598 if (cinfo->Se) 00599 emit_dht(cinfo, compptr->ac_tbl_no, TRUE); 00600 } 00601 } 00602 00603 /* Emit DRI if required --- note that DRI value could change for each scan. 00604 * We avoid wasting space with unnecessary DRIs, however. 00605 */ 00606 if (cinfo->restart_interval != marker->last_restart_interval) { 00607 emit_dri(cinfo); 00608 marker->last_restart_interval = cinfo->restart_interval; 00609 } 00610 00611 emit_sos(cinfo); 00612 } 00613 00614 00615 /* 00616 * Write datastream trailer. 00617 */ 00618 00619 METHODDEF(void) 00620 write_file_trailer (j_compress_ptr cinfo) 00621 { 00622 emit_marker(cinfo, M_EOI); 00623 } 00624 00625 00626 /* 00627 * Write an abbreviated table-specification datastream. 00628 * This consists of SOI, DQT and DHT tables, and EOI. 00629 * Any table that is defined and not marked sent_table = TRUE will be 00630 * emitted. Note that all tables will be marked sent_table = TRUE at exit. 00631 */ 00632 00633 METHODDEF(void) 00634 write_tables_only (j_compress_ptr cinfo) 00635 { 00636 int i; 00637 00638 emit_marker(cinfo, M_SOI); 00639 00640 for (i = 0; i < NUM_QUANT_TBLS; i++) { 00641 if (cinfo->quant_tbl_ptrs[i] != NULL) 00642 (void) emit_dqt(cinfo, i); 00643 } 00644 00645 if (! cinfo->arith_code) { 00646 for (i = 0; i < NUM_HUFF_TBLS; i++) { 00647 if (cinfo->dc_huff_tbl_ptrs[i] != NULL) 00648 emit_dht(cinfo, i, FALSE); 00649 if (cinfo->ac_huff_tbl_ptrs[i] != NULL) 00650 emit_dht(cinfo, i, TRUE); 00651 } 00652 } 00653 00654 emit_marker(cinfo, M_EOI); 00655 } 00656 00657 00658 /* 00659 * Initialize the marker writer module. 00660 */ 00661 00662 GLOBAL(void) 00663 jinit_marker_writer (j_compress_ptr cinfo) 00664 { 00665 my_marker_ptr marker; 00666 00667 /* Create the subobject */ 00668 marker = (my_marker_ptr) 00669 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, 00670 SIZEOF(my_marker_writer)); 00671 cinfo->marker = (struct jpeg_marker_writer *) marker; 00672 /* Initialize method pointers */ 00673 marker->pub.write_file_header = write_file_header; 00674 marker->pub.write_frame_header = write_frame_header; 00675 marker->pub.write_scan_header = write_scan_header; 00676 marker->pub.write_file_trailer = write_file_trailer; 00677 marker->pub.write_tables_only = write_tables_only; 00678 marker->pub.write_marker_header = write_marker_header; 00679 marker->pub.write_marker_byte = write_marker_byte; 00680 /* Initialize private state */ 00681 marker->last_restart_interval = 0; 00682 } Generated on Mon May 28 2012 04:19:08 for ReactOS by
1.7.6.1
|