X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2Fjpeg%2Flibijg%2Fjcmarker.c;h=6f089d573cffec3c84319f7acd19e3bdebc5bbb5;hb=ac11759a2c7fcb32a6e0d2efdc8bb03982ae349e;hp=3d1e6c6d524850e0d401fcec9f590d5648d13ee7;hpb=a26e6f06a76ec85504cf65288e7c47f2cd728641;p=gdcm.git diff --git a/src/jpeg/libijg/jcmarker.c b/src/jpeg/libijg/jcmarker.c index 3d1e6c6d..6f089d57 100644 --- a/src/jpeg/libijg/jcmarker.c +++ b/src/jpeg/libijg/jcmarker.c @@ -13,7 +13,7 @@ #include "jpeglib.h" -typedef enum { /* JPEG marker codes */ +typedef enum { /* JPEG marker codes */ M_SOF0 = 0xc0, M_SOF1 = 0xc1, M_SOF2 = 0xc2, @@ -169,7 +169,7 @@ emit_dqt (j_compress_ptr cinfo, int index) /* The table entries must be emitted in zigzag order. */ unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; if (prec) - emit_byte(cinfo, (int) (qval >> 8)); + emit_byte(cinfo, (int) (qval >> 8)); emit_byte(cinfo, (int) (qval & 0xFF)); } @@ -189,7 +189,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) if (is_ac) { htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ + index += 0x10; /* output index has AC bit set */ } else { htbl = cinfo->dc_huff_tbl_ptrs[index]; } @@ -258,6 +258,7 @@ emit_dac (j_compress_ptr cinfo) } } #endif /* C_ARITH_CODING_SUPPORTED */ + cinfo = 0; } @@ -267,7 +268,7 @@ emit_dri (j_compress_ptr cinfo) { emit_marker(cinfo, M_DRI); - emit_2bytes(cinfo, 4); /* fixed length */ + emit_2bytes(cinfo, 4); /* fixed length */ emit_2bytes(cinfo, (int) cinfo->restart_interval); } @@ -329,11 +330,11 @@ emit_sos (j_compress_ptr cinfo) * but does not seem to be specified in the standard. */ if (cinfo->Ss == 0) { - ta = 0; /* DC scan */ - if (cinfo->Ah != 0 && !cinfo->arith_code) - td = 0; /* no DC table either */ + ta = 0; /* DC scan */ + if (cinfo->Ah != 0 && !cinfo->arith_code) + td = 0; /* no DC table either */ } else { - td = 0; /* AC scan */ + td = 0; /* AC scan */ } } emit_byte(cinfo, (td << 4) + ta); @@ -350,22 +351,22 @@ emit_jfif_app0 (j_compress_ptr cinfo) /* 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) + * 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) */ emit_marker(cinfo, M_APP0); emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ - emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ + emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ emit_byte(cinfo, 0x46); emit_byte(cinfo, 0x49); emit_byte(cinfo, 0x46); @@ -375,7 +376,7 @@ emit_jfif_app0 (j_compress_ptr cinfo) emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ emit_2bytes(cinfo, (int) cinfo->X_density); emit_2bytes(cinfo, (int) cinfo->Y_density); - emit_byte(cinfo, 0); /* No thumbnail image */ + emit_byte(cinfo, 0); /* No thumbnail image */ emit_byte(cinfo, 0); } @@ -385,12 +386,12 @@ emit_adobe_app14 (j_compress_ptr cinfo) /* 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) + * 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. @@ -404,23 +405,23 @@ emit_adobe_app14 (j_compress_ptr cinfo) emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ - emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ + emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ emit_byte(cinfo, 0x64); emit_byte(cinfo, 0x6F); emit_byte(cinfo, 0x62); emit_byte(cinfo, 0x65); - emit_2bytes(cinfo, 100); /* Version */ - emit_2bytes(cinfo, 0); /* Flags0 */ - emit_2bytes(cinfo, 0); /* Flags1 */ + emit_2bytes(cinfo, 100); /* Version */ + emit_2bytes(cinfo, 0); /* Flags0 */ + emit_2bytes(cinfo, 0); /* Flags1 */ switch (cinfo->jpeg_color_space) { case JCS_YCbCr: - emit_byte(cinfo, 1); /* Color transform = 1 */ + emit_byte(cinfo, 1); /* Color transform = 1 */ break; case JCS_YCCK: - emit_byte(cinfo, 2); /* Color transform = 2 */ + emit_byte(cinfo, 2); /* Color transform = 2 */ break; default: - emit_byte(cinfo, 0); /* Color transform = 0 */ + emit_byte(cinfo, 0); /* Color transform = 0 */ break; } } @@ -438,12 +439,12 @@ METHODDEF(void) write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) /* Emit an arbitrary marker header */ { - if (datalen > (unsigned int) 65533) /* safety check */ + if (datalen > (unsigned int) 65533) /* safety check */ ERREXIT(cinfo, JERR_BAD_LENGTH); emit_marker(cinfo, (JPEG_MARKER) marker); - emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ + emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ } METHODDEF(void) @@ -470,12 +471,12 @@ write_file_header (j_compress_ptr cinfo) { my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - emit_marker(cinfo, M_SOI); /* first the SOI */ + emit_marker(cinfo, M_SOI); /* first the SOI */ /* SOI is defined to reset restart interval to 0 */ marker->last_restart_interval = 0; - if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ + if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ emit_jfif_app0(cinfo); if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ emit_adobe_app14(cinfo); @@ -516,9 +517,9 @@ write_frame_header (j_compress_ptr cinfo) } else { is_baseline = TRUE; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { + ci++, compptr++) { if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) - is_baseline = FALSE; + is_baseline = FALSE; } if (prec && is_baseline) { is_baseline = FALSE; @@ -529,14 +530,14 @@ write_frame_header (j_compress_ptr cinfo) /* Emit the proper SOF marker */ if (cinfo->arith_code) { - emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ + emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ } else { if (cinfo->progressive_mode) - emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ + emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ else if (is_baseline) - emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ + emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ else - emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ + emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ } } @@ -567,17 +568,17 @@ write_scan_header (j_compress_ptr cinfo) for (i = 0; i < cinfo->comps_in_scan; i++) { compptr = cinfo->cur_comp_info[i]; if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan */ - if (cinfo->Ss == 0) { - if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - } else { - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } + /* Progressive mode: only DC or only AC tables are used in one scan */ + if (cinfo->Ss == 0) { + if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + } else { + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + } } else { - /* Sequential mode: need both DC and AC tables */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); + /* Sequential mode: need both DC and AC tables */ + emit_dht(cinfo, compptr->dc_tbl_no, FALSE); + emit_dht(cinfo, compptr->ac_tbl_no, TRUE); } } } @@ -627,9 +628,9 @@ write_tables_only (j_compress_ptr cinfo) if (! cinfo->arith_code) { for (i = 0; i < NUM_HUFF_TBLS; i++) { if (cinfo->dc_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, FALSE); + emit_dht(cinfo, i, FALSE); if (cinfo->ac_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, TRUE); + emit_dht(cinfo, i, TRUE); } } @@ -649,7 +650,7 @@ jinit_marker_writer (j_compress_ptr cinfo) /* Create the subobject */ marker = (my_marker_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_marker_writer)); + SIZEOF(my_marker_writer)); cinfo->marker = (struct jpeg_marker_writer *) marker; /* Initialize method pointers */ marker->pub.write_file_header = write_file_header;