Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

673 lines
17 KiB

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