jcmarker.c
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:16k
源码类别:

浏览器

开发平台:

Unix_Linux

  1. /*
  2.  * jcmarker.c
  3.  *
  4.  * Copyright (C) 1991-1995, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This file contains routines to write JPEG datastream markers.
  9.  */
  10. #define JPEG_INTERNALS
  11. #include "jinclude.h"
  12. #include "jpeglib.h"
  13. typedef enum { /* JPEG marker codes */
  14.   M_SOF0  = 0xc0,
  15.   M_SOF1  = 0xc1,
  16.   M_SOF2  = 0xc2,
  17.   M_SOF3  = 0xc3,
  18.   
  19.   M_SOF5  = 0xc5,
  20.   M_SOF6  = 0xc6,
  21.   M_SOF7  = 0xc7,
  22.   
  23.   M_JPG   = 0xc8,
  24.   M_SOF9  = 0xc9,
  25.   M_SOF10 = 0xca,
  26.   M_SOF11 = 0xcb,
  27.   
  28.   M_SOF13 = 0xcd,
  29.   M_SOF14 = 0xce,
  30.   M_SOF15 = 0xcf,
  31.   
  32.   M_DHT   = 0xc4,
  33.   
  34.   M_DAC   = 0xcc,
  35.   
  36.   M_RST0  = 0xd0,
  37.   M_RST1  = 0xd1,
  38.   M_RST2  = 0xd2,
  39.   M_RST3  = 0xd3,
  40.   M_RST4  = 0xd4,
  41.   M_RST5  = 0xd5,
  42.   M_RST6  = 0xd6,
  43.   M_RST7  = 0xd7,
  44.   
  45.   M_SOI   = 0xd8,
  46.   M_EOI   = 0xd9,
  47.   M_SOS   = 0xda,
  48.   M_DQT   = 0xdb,
  49.   M_DNL   = 0xdc,
  50.   M_DRI   = 0xdd,
  51.   M_DHP   = 0xde,
  52.   M_EXP   = 0xdf,
  53.   
  54.   M_APP0  = 0xe0,
  55.   M_APP1  = 0xe1,
  56.   M_APP2  = 0xe2,
  57.   M_APP3  = 0xe3,
  58.   M_APP4  = 0xe4,
  59.   M_APP5  = 0xe5,
  60.   M_APP6  = 0xe6,
  61.   M_APP7  = 0xe7,
  62.   M_APP8  = 0xe8,
  63.   M_APP9  = 0xe9,
  64.   M_APP10 = 0xea,
  65.   M_APP11 = 0xeb,
  66.   M_APP12 = 0xec,
  67.   M_APP13 = 0xed,
  68.   M_APP14 = 0xee,
  69.   M_APP15 = 0xef,
  70.   
  71.   M_JPG0  = 0xf0,
  72.   M_JPG13 = 0xfd,
  73.   M_COM   = 0xfe,
  74.   
  75.   M_TEM   = 0x01,
  76.   
  77.   M_ERROR = 0x100
  78. } JPEG_MARKER;
  79. /*
  80.  * Basic output routines.
  81.  *
  82.  * Note that we do not support suspension while writing a marker.
  83.  * Therefore, an application using suspension must ensure that there is
  84.  * enough buffer space for the initial markers (typ. 600-700 bytes) before
  85.  * calling jpeg_start_compress, and enough space to write the trailing EOI
  86.  * (a few bytes) before calling jpeg_finish_compress.  Multipass compression
  87.  * modes are not supported at all with suspension, so those two are the only
  88.  * points where markers will be written.
  89.  */
  90. LOCAL void
  91. emit_byte (j_compress_ptr cinfo, int val)
  92. /* Emit a byte */
  93. {
  94.   struct jpeg_destination_mgr * dest = cinfo->dest;
  95.   *(dest->next_output_byte)++ = (JOCTET) val;
  96.   if (--dest->free_in_buffer == 0) {
  97.     if (! (*dest->empty_output_buffer) (cinfo))
  98.       ERREXIT(cinfo, JERR_CANT_SUSPEND);
  99.   }
  100. }
  101. LOCAL void
  102. emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark)
  103. /* Emit a marker code */
  104. {
  105.   emit_byte(cinfo, 0xFF);
  106.   emit_byte(cinfo, (int) mark);
  107. }
  108. LOCAL void
  109. emit_2bytes (j_compress_ptr cinfo, int value)
  110. /* Emit a 2-byte integer; these are always MSB first in JPEG files */
  111. {
  112.   emit_byte(cinfo, (value >> 8) & 0xFF);
  113.   emit_byte(cinfo, value & 0xFF);
  114. }
  115. /*
  116.  * Routines to write specific marker types.
  117.  */
  118. LOCAL int
  119. emit_dqt (j_compress_ptr cinfo, int index)
  120. /* Emit a DQT marker */
  121. /* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
  122. {
  123.   JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index];
  124.   int prec;
  125.   int i;
  126.   if (qtbl == NULL)
  127.     ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
  128.   prec = 0;
  129.   for (i = 0; i < DCTSIZE2; i++) {
  130.     if (qtbl->quantval[i] > 255)
  131.       prec = 1;
  132.   }
  133.   if (! qtbl->sent_table) {
  134.     emit_marker(cinfo, M_DQT);
  135.     emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2);
  136.     emit_byte(cinfo, index + (prec<<4));
  137.     for (i = 0; i < DCTSIZE2; i++) {
  138.       if (prec)
  139. emit_byte(cinfo, qtbl->quantval[i] >> 8);
  140.       emit_byte(cinfo, qtbl->quantval[i] & 0xFF);
  141.     }
  142.     qtbl->sent_table = TRUE;
  143.   }
  144.   return prec;
  145. }
  146. LOCAL void
  147. emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
  148. /* Emit a DHT marker */
  149. {
  150.   JHUFF_TBL * htbl;
  151.   int length, i;
  152.   
  153.   if (is_ac) {
  154.     htbl = cinfo->ac_huff_tbl_ptrs[index];
  155.     index += 0x10; /* output index has AC bit set */
  156.   } else {
  157.     htbl = cinfo->dc_huff_tbl_ptrs[index];
  158.   }
  159.   if (htbl == NULL)
  160.     ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
  161.   
  162.   if (! htbl->sent_table) {
  163.     emit_marker(cinfo, M_DHT);
  164.     
  165.     length = 0;
  166.     for (i = 1; i <= 16; i++)
  167.       length += htbl->bits[i];
  168.     
  169.     emit_2bytes(cinfo, length + 2 + 1 + 16);
  170.     emit_byte(cinfo, index);
  171.     
  172.     for (i = 1; i <= 16; i++)
  173.       emit_byte(cinfo, htbl->bits[i]);
  174.     
  175.     for (i = 0; i < length; i++)
  176.       emit_byte(cinfo, htbl->huffval[i]);
  177.     
  178.     htbl->sent_table = TRUE;
  179.   }
  180. }
  181. LOCAL void
  182. emit_dac (j_compress_ptr cinfo)
  183. /* Emit a DAC marker */
  184. /* Since the useful info is so small, we want to emit all the tables in */
  185. /* one DAC marker.  Therefore this routine does its own scan of the table. */
  186. {
  187. #ifdef C_ARITH_CODING_SUPPORTED
  188.   char dc_in_use[NUM_ARITH_TBLS];
  189.   char ac_in_use[NUM_ARITH_TBLS];
  190.   int length, i;
  191.   jpeg_component_info *compptr;
  192.   
  193.   for (i = 0; i < NUM_ARITH_TBLS; i++)
  194.     dc_in_use[i] = ac_in_use[i] = 0;
  195.   
  196.   for (i = 0; i < cinfo->comps_in_scan; i++) {
  197.     compptr = cinfo->cur_comp_info[i];
  198.     dc_in_use[compptr->dc_tbl_no] = 1;
  199.     ac_in_use[compptr->ac_tbl_no] = 1;
  200.   }
  201.   
  202.   length = 0;
  203.   for (i = 0; i < NUM_ARITH_TBLS; i++)
  204.     length += dc_in_use[i] + ac_in_use[i];
  205.   
  206.   emit_marker(cinfo, M_DAC);
  207.   
  208.   emit_2bytes(cinfo, length*2 + 2);
  209.   
  210.   for (i = 0; i < NUM_ARITH_TBLS; i++) {
  211.     if (dc_in_use[i]) {
  212.       emit_byte(cinfo, i);
  213.       emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
  214.     }
  215.     if (ac_in_use[i]) {
  216.       emit_byte(cinfo, i + 0x10);
  217.       emit_byte(cinfo, cinfo->arith_ac_K[i]);
  218.     }
  219.   }
  220. #endif /* C_ARITH_CODING_SUPPORTED */
  221. }
  222. LOCAL void
  223. emit_dri (j_compress_ptr cinfo)
  224. /* Emit a DRI marker */
  225. {
  226.   emit_marker(cinfo, M_DRI);
  227.   
  228.   emit_2bytes(cinfo, 4); /* fixed length */
  229.   emit_2bytes(cinfo, (int) cinfo->restart_interval);
  230. }
  231. LOCAL void
  232. emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
  233. /* Emit a SOF marker */
  234. {
  235.   int ci;
  236.   jpeg_component_info *compptr;
  237.   
  238.   emit_marker(cinfo, code);
  239.   
  240.   emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
  241.   /* Make sure image isn't bigger than SOF field can handle */
  242.   if ((long) cinfo->image_height > 65535L ||
  243.       (long) cinfo->image_width > 65535L)
  244.     ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
  245.   emit_byte(cinfo, cinfo->data_precision);
  246.   emit_2bytes(cinfo, (int) cinfo->image_height);
  247.   emit_2bytes(cinfo, (int) cinfo->image_width);
  248.   emit_byte(cinfo, cinfo->num_components);
  249.   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  250.        ci++, compptr++) {
  251.     emit_byte(cinfo, compptr->component_id);
  252.     emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
  253.     emit_byte(cinfo, compptr->quant_tbl_no);
  254.   }
  255. }
  256. LOCAL void
  257. emit_sos (j_compress_ptr cinfo)
  258. /* Emit a SOS marker */
  259. {
  260.   int i, td, ta;
  261.   jpeg_component_info *compptr;
  262.   
  263.   emit_marker(cinfo, M_SOS);
  264.   
  265.   emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
  266.   
  267.   emit_byte(cinfo, cinfo->comps_in_scan);
  268.   
  269.   for (i = 0; i < cinfo->comps_in_scan; i++) {
  270.     compptr = cinfo->cur_comp_info[i];
  271.     emit_byte(cinfo, compptr->component_id);
  272.     td = compptr->dc_tbl_no;
  273.     ta = compptr->ac_tbl_no;
  274.     if (cinfo->progressive_mode) {
  275.       /* Progressive mode: only DC or only AC tables are used in one scan;
  276.        * furthermore, Huffman coding of DC refinement uses no table at all.
  277.        * We emit 0 for unused field(s); this is recommended by the P&M text
  278.        * but does not seem to be specified in the standard.
  279.        */
  280.       if (cinfo->Ss == 0) {
  281. ta = 0; /* DC scan */
  282. if (cinfo->Ah != 0 && !cinfo->arith_code)
  283.   td = 0; /* no DC table either */
  284.       } else {
  285. td = 0; /* AC scan */
  286.       }
  287.     }
  288.     emit_byte(cinfo, (td << 4) + ta);
  289.   }
  290.   emit_byte(cinfo, cinfo->Ss);
  291.   emit_byte(cinfo, cinfo->Se);
  292.   emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
  293. }
  294. LOCAL void
  295. emit_jfif_app0 (j_compress_ptr cinfo)
  296. /* Emit a JFIF-compliant APP0 marker */
  297. {
  298.   /*
  299.    * Length of APP0 block (2 bytes)
  300.    * Block ID (4 bytes - ASCII "JFIF")
  301.    * Zero byte (1 byte to terminate the ID string)
  302.    * Version Major, Minor (2 bytes - 0x01, 0x01)
  303.    * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
  304.    * Xdpu (2 bytes - dots per unit horizontal)
  305.    * Ydpu (2 bytes - dots per unit vertical)
  306.    * Thumbnail X size (1 byte)
  307.    * Thumbnail Y size (1 byte)
  308.    */
  309.   
  310.   emit_marker(cinfo, M_APP0);
  311.   
  312.   emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
  313.   emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
  314.   emit_byte(cinfo, 0x46);
  315.   emit_byte(cinfo, 0x49);
  316.   emit_byte(cinfo, 0x46);
  317.   emit_byte(cinfo, 0);
  318.   /* We currently emit version code 1.01 since we use no 1.02 features.
  319.    * This may avoid complaints from some older decoders.
  320.    */
  321.   emit_byte(cinfo, 1); /* Major version */
  322.   emit_byte(cinfo, 1); /* Minor version */
  323.   emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
  324.   emit_2bytes(cinfo, (int) cinfo->X_density);
  325.   emit_2bytes(cinfo, (int) cinfo->Y_density);
  326.   emit_byte(cinfo, 0); /* No thumbnail image */
  327.   emit_byte(cinfo, 0);
  328. }
  329. LOCAL void
  330. emit_adobe_app14 (j_compress_ptr cinfo)
  331. /* Emit an Adobe APP14 marker */
  332. {
  333.   /*
  334.    * Length of APP14 block (2 bytes)
  335.    * Block ID (5 bytes - ASCII "Adobe")
  336.    * Version Number (2 bytes - currently 100)
  337.    * Flags0 (2 bytes - currently 0)
  338.    * Flags1 (2 bytes - currently 0)
  339.    * Color transform (1 byte)
  340.    *
  341.    * Although Adobe TN 5116 mentions Version = 101, all the Adobe files
  342.    * now in circulation seem to use Version = 100, so that's what we write.
  343.    *
  344.    * We write the color transform byte as 1 if the JPEG color space is
  345.    * YCbCr, 2 if it's YCCK, 0 otherwise.  Adobe's definition has to do with
  346.    * whether the encoder performed a transformation, which is pretty useless.
  347.    */
  348.   
  349.   emit_marker(cinfo, M_APP14);
  350.   
  351.   emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
  352.   emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
  353.   emit_byte(cinfo, 0x64);
  354.   emit_byte(cinfo, 0x6F);
  355.   emit_byte(cinfo, 0x62);
  356.   emit_byte(cinfo, 0x65);
  357.   emit_2bytes(cinfo, 100); /* Version */
  358.   emit_2bytes(cinfo, 0); /* Flags0 */
  359.   emit_2bytes(cinfo, 0); /* Flags1 */
  360.   switch (cinfo->jpeg_color_space) {
  361.   case JCS_YCbCr:
  362.     emit_byte(cinfo, 1); /* Color transform = 1 */
  363.     break;
  364.   case JCS_YCCK:
  365.     emit_byte(cinfo, 2); /* Color transform = 2 */
  366.     break;
  367.   default:
  368.     emit_byte(cinfo, 0); /* Color transform = 0 */
  369.     break;
  370.   }
  371. }
  372. /*
  373.  * This routine is exported for possible use by applications.
  374.  * The intended use is to emit COM or APPn markers after calling
  375.  * jpeg_start_compress() and before the first jpeg_write_scanlines() call
  376.  * (hence, after write_file_header but before write_frame_header).
  377.  * Other uses are not guaranteed to produce desirable results.
  378.  */
  379. METHODDEF void
  380. write_any_marker (j_compress_ptr cinfo, int marker,
  381.   const JOCTET *dataptr, unsigned int datalen)
  382. /* Emit an arbitrary marker with parameters */
  383. {
  384.   if (datalen <= (unsigned int) 65533) { /* safety check */
  385.     emit_marker(cinfo, (JPEG_MARKER) marker);
  386.   
  387.     emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
  388.     while (datalen--) {
  389.       emit_byte(cinfo, *dataptr);
  390.       dataptr++;
  391.     }
  392.   }
  393. }
  394. /*
  395.  * Write datastream header.
  396.  * This consists of an SOI and optional APPn markers.
  397.  * We recommend use of the JFIF marker, but not the Adobe marker,
  398.  * when using YCbCr or grayscale data.  The JFIF marker should NOT
  399.  * be used for any other JPEG colorspace.  The Adobe marker is helpful
  400.  * to distinguish RGB, CMYK, and YCCK colorspaces.
  401.  * Note that an application can write additional header markers after
  402.  * jpeg_start_compress returns.
  403.  */
  404. METHODDEF void
  405. write_file_header (j_compress_ptr cinfo)
  406. {
  407.   emit_marker(cinfo, M_SOI); /* first the SOI */
  408.   if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
  409.     emit_jfif_app0(cinfo);
  410.   if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
  411.     emit_adobe_app14(cinfo);
  412. }
  413. /*
  414.  * Write frame header.
  415.  * This consists of DQT and SOFn markers.
  416.  * Note that we do not emit the SOF until we have emitted the DQT(s).
  417.  * This avoids compatibility problems with incorrect implementations that
  418.  * try to error-check the quant table numbers as soon as they see the SOF.
  419.  */
  420. METHODDEF void
  421. write_frame_header (j_compress_ptr cinfo)
  422. {
  423.   int ci, prec;
  424.   boolean is_baseline;
  425.   jpeg_component_info *compptr;
  426.   
  427.   /* Emit DQT for each quantization table.
  428.    * Note that emit_dqt() suppresses any duplicate tables.
  429.    */
  430.   prec = 0;
  431.   for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  432.        ci++, compptr++) {
  433.     prec += emit_dqt(cinfo, compptr->quant_tbl_no);
  434.   }
  435.   /* now prec is nonzero iff there are any 16-bit quant tables. */
  436.   /* Check for a non-baseline specification.
  437.    * Note we assume that Huffman table numbers won't be changed later.
  438.    */
  439.   if (cinfo->arith_code || cinfo->progressive_mode ||
  440.       cinfo->data_precision != 8) {
  441.     is_baseline = FALSE;
  442.   } else {
  443.     is_baseline = TRUE;
  444.     for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  445.  ci++, compptr++) {
  446.       if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
  447. is_baseline = FALSE;
  448.     }
  449.     if (prec && is_baseline) {
  450.       is_baseline = FALSE;
  451.       /* If it's baseline except for quantizer size, warn the user */
  452.       TRACEMS(cinfo, 0, JTRC_16BIT_TABLES);
  453.     }
  454.   }
  455.   /* Emit the proper SOF marker */
  456.   if (cinfo->arith_code) {
  457.     emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */
  458.   } else {
  459.     if (cinfo->progressive_mode)
  460.       emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
  461.     else if (is_baseline)
  462.       emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
  463.     else
  464.       emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
  465.   }
  466. }
  467. /*
  468.  * Write scan header.
  469.  * This consists of DHT or DAC markers, optional DRI, and SOS.
  470.  * Compressed data will be written following the SOS.
  471.  */
  472. METHODDEF void
  473. write_scan_header (j_compress_ptr cinfo)
  474. {
  475.   int i;
  476.   jpeg_component_info *compptr;
  477.   if (cinfo->arith_code) {
  478.     /* Emit arith conditioning info.  We may have some duplication
  479.      * if the file has multiple scans, but it's so small it's hardly
  480.      * worth worrying about.
  481.      */
  482.     emit_dac(cinfo);
  483.   } else {
  484.     /* Emit Huffman tables.
  485.      * Note that emit_dht() suppresses any duplicate tables.
  486.      */
  487.     for (i = 0; i < cinfo->comps_in_scan; i++) {
  488.       compptr = cinfo->cur_comp_info[i];
  489.       if (cinfo->progressive_mode) {
  490. /* Progressive mode: only DC or only AC tables are used in one scan */
  491. if (cinfo->Ss == 0) {
  492.   if (cinfo->Ah == 0) /* DC needs no table for refinement scan */
  493.     emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
  494. } else {
  495.   emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
  496. }
  497.       } else {
  498. /* Sequential mode: need both DC and AC tables */
  499. emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
  500. emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
  501.       }
  502.     }
  503.   }
  504.   /* Emit DRI if required --- note that DRI value could change for each scan.
  505.    * If it doesn't, a tiny amount of space is wasted in multiple-scan files.
  506.    * We assume DRI will never be nonzero for one scan and zero for a later one.
  507.    */
  508.   if (cinfo->restart_interval)
  509.     emit_dri(cinfo);
  510.   emit_sos(cinfo);
  511. }
  512. /*
  513.  * Write datastream trailer.
  514.  */
  515. METHODDEF void
  516. write_file_trailer (j_compress_ptr cinfo)
  517. {
  518.   emit_marker(cinfo, M_EOI);
  519. }
  520. /*
  521.  * Write an abbreviated table-specification datastream.
  522.  * This consists of SOI, DQT and DHT tables, and EOI.
  523.  * Any table that is defined and not marked sent_table = TRUE will be
  524.  * emitted.  Note that all tables will be marked sent_table = TRUE at exit.
  525.  */
  526. METHODDEF void
  527. write_tables_only (j_compress_ptr cinfo)
  528. {
  529.   int i;
  530.   emit_marker(cinfo, M_SOI);
  531.   for (i = 0; i < NUM_QUANT_TBLS; i++) {
  532.     if (cinfo->quant_tbl_ptrs[i] != NULL)
  533.       (void) emit_dqt(cinfo, i);
  534.   }
  535.   if (! cinfo->arith_code) {
  536.     for (i = 0; i < NUM_HUFF_TBLS; i++) {
  537.       if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
  538. emit_dht(cinfo, i, FALSE);
  539.       if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
  540. emit_dht(cinfo, i, TRUE);
  541.     }
  542.   }
  543.   emit_marker(cinfo, M_EOI);
  544. }
  545. /*
  546.  * Initialize the marker writer module.
  547.  */
  548. GLOBAL void
  549. jinit_marker_writer (j_compress_ptr cinfo)
  550. {
  551.   /* Create the subobject */
  552.   cinfo->marker = (struct jpeg_marker_writer *)
  553.     (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
  554. SIZEOF(struct jpeg_marker_writer));
  555.   /* Initialize method pointers */
  556.   cinfo->marker->write_any_marker = write_any_marker;
  557.   cinfo->marker->write_file_header = write_file_header;
  558.   cinfo->marker->write_frame_header = write_frame_header;
  559.   cinfo->marker->write_scan_header = write_scan_header;
  560.   cinfo->marker->write_file_trailer = write_file_trailer;
  561.   cinfo->marker->write_tables_only = write_tables_only;
  562. }