Lines Matching refs:sp
223 JPEGState *sp = (JPEGState *) cinfo; /* NB: cinfo assumed first */ in TIFFjpeg_error_exit() local
227 TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", "%s", buffer); /* display the error message */ in TIFFjpeg_error_exit()
229 LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ in TIFFjpeg_error_exit()
252 #define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op)) argument
253 #define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op),1)) argument
256 TIFFjpeg_create_compress(JPEGState* sp) in TIFFjpeg_create_compress() argument
259 sp->cinfo.c.err = jpeg_std_error(&sp->err); in TIFFjpeg_create_compress()
260 sp->err.error_exit = TIFFjpeg_error_exit; in TIFFjpeg_create_compress()
261 sp->err.output_message = TIFFjpeg_output_message; in TIFFjpeg_create_compress()
264 sp->cinfo.c.client_data = NULL; in TIFFjpeg_create_compress()
266 return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c)); in TIFFjpeg_create_compress()
270 TIFFjpeg_create_decompress(JPEGState* sp) in TIFFjpeg_create_decompress() argument
273 sp->cinfo.d.err = jpeg_std_error(&sp->err); in TIFFjpeg_create_decompress()
274 sp->err.error_exit = TIFFjpeg_error_exit; in TIFFjpeg_create_decompress()
275 sp->err.output_message = TIFFjpeg_output_message; in TIFFjpeg_create_decompress()
278 sp->cinfo.d.client_data = NULL; in TIFFjpeg_create_decompress()
280 return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d)); in TIFFjpeg_create_decompress()
284 TIFFjpeg_set_defaults(JPEGState* sp) in TIFFjpeg_set_defaults() argument
286 return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c)); in TIFFjpeg_set_defaults()
290 TIFFjpeg_set_colorspace(JPEGState* sp, J_COLOR_SPACE colorspace) in TIFFjpeg_set_colorspace() argument
292 return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace)); in TIFFjpeg_set_colorspace()
296 TIFFjpeg_set_quality(JPEGState* sp, int quality, boolean force_baseline) in TIFFjpeg_set_quality() argument
298 return CALLVJPEG(sp, in TIFFjpeg_set_quality()
299 jpeg_set_quality(&sp->cinfo.c, quality, force_baseline)); in TIFFjpeg_set_quality()
303 TIFFjpeg_suppress_tables(JPEGState* sp, boolean suppress) in TIFFjpeg_suppress_tables() argument
305 return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress)); in TIFFjpeg_suppress_tables()
309 TIFFjpeg_start_compress(JPEGState* sp, boolean write_all_tables) in TIFFjpeg_start_compress() argument
311 return CALLVJPEG(sp, in TIFFjpeg_start_compress()
312 jpeg_start_compress(&sp->cinfo.c, write_all_tables)); in TIFFjpeg_start_compress()
316 TIFFjpeg_write_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int num_lines) in TIFFjpeg_write_scanlines() argument
318 return CALLJPEG(sp, -1, (int) jpeg_write_scanlines(&sp->cinfo.c, in TIFFjpeg_write_scanlines()
323 TIFFjpeg_write_raw_data(JPEGState* sp, JSAMPIMAGE data, int num_lines) in TIFFjpeg_write_raw_data() argument
325 return CALLJPEG(sp, -1, (int) jpeg_write_raw_data(&sp->cinfo.c, in TIFFjpeg_write_raw_data()
330 TIFFjpeg_finish_compress(JPEGState* sp) in TIFFjpeg_finish_compress() argument
332 return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c)); in TIFFjpeg_finish_compress()
336 TIFFjpeg_write_tables(JPEGState* sp) in TIFFjpeg_write_tables() argument
338 return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c)); in TIFFjpeg_write_tables()
342 TIFFjpeg_read_header(JPEGState* sp, boolean require_image) in TIFFjpeg_read_header() argument
344 return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image)); in TIFFjpeg_read_header()
348 TIFFjpeg_start_decompress(JPEGState* sp) in TIFFjpeg_start_decompress() argument
350 return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d)); in TIFFjpeg_start_decompress()
354 TIFFjpeg_read_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int max_lines) in TIFFjpeg_read_scanlines() argument
356 return CALLJPEG(sp, -1, (int) jpeg_read_scanlines(&sp->cinfo.d, in TIFFjpeg_read_scanlines()
361 TIFFjpeg_read_raw_data(JPEGState* sp, JSAMPIMAGE data, int max_lines) in TIFFjpeg_read_raw_data() argument
363 return CALLJPEG(sp, -1, (int) jpeg_read_raw_data(&sp->cinfo.d, in TIFFjpeg_read_raw_data()
368 TIFFjpeg_finish_decompress(JPEGState* sp) in TIFFjpeg_finish_decompress() argument
370 return CALLJPEG(sp, -1, (int) jpeg_finish_decompress(&sp->cinfo.d)); in TIFFjpeg_finish_decompress()
374 TIFFjpeg_abort(JPEGState* sp) in TIFFjpeg_abort() argument
376 return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm)); in TIFFjpeg_abort()
380 TIFFjpeg_destroy(JPEGState* sp) in TIFFjpeg_destroy() argument
382 return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm)); in TIFFjpeg_destroy()
386 TIFFjpeg_alloc_sarray(JPEGState* sp, int pool_id, in TIFFjpeg_alloc_sarray() argument
389 return CALLJPEG(sp, (JSAMPARRAY) NULL, in TIFFjpeg_alloc_sarray()
390 (*sp->cinfo.comm.mem->alloc_sarray) in TIFFjpeg_alloc_sarray()
391 (&sp->cinfo.comm, pool_id, samplesperrow, numrows)); in TIFFjpeg_alloc_sarray()
403 JPEGState* sp = (JPEGState*) cinfo; in std_init_destination() local
404 TIFF* tif = sp->tif; in std_init_destination()
406 sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; in std_init_destination()
407 sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; in std_init_destination()
413 JPEGState* sp = (JPEGState*) cinfo; in std_empty_output_buffer() local
414 TIFF* tif = sp->tif; in std_empty_output_buffer()
426 if ( sp->dest.free_in_buffer >= 0 ) { in std_empty_output_buffer()
427 tif->tif_rawcc = tif->tif_rawdatasize - sp->dest.free_in_buffer; in std_empty_output_buffer()
432 sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; in std_empty_output_buffer()
433 sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; in std_empty_output_buffer()
441 JPEGState* sp = (JPEGState*) cinfo; in std_term_destination() local
442 TIFF* tif = sp->tif; in std_term_destination()
444 tif->tif_rawcp = (uint8*) sp->dest.next_output_byte; in std_term_destination()
446 tif->tif_rawdatasize - (tmsize_t) sp->dest.free_in_buffer; in std_term_destination()
451 TIFFjpeg_data_dest(JPEGState* sp, TIFF* tif) in TIFFjpeg_data_dest() argument
454 sp->cinfo.c.dest = &sp->dest; in TIFFjpeg_data_dest()
455 sp->dest.init_destination = std_init_destination; in TIFFjpeg_data_dest()
456 sp->dest.empty_output_buffer = std_empty_output_buffer; in TIFFjpeg_data_dest()
457 sp->dest.term_destination = std_term_destination; in TIFFjpeg_data_dest()
467 JPEGState* sp = (JPEGState*) cinfo; in tables_init_destination() local
470 sp->dest.next_output_byte = (JOCTET*) sp->jpegtables; in tables_init_destination()
471 sp->dest.free_in_buffer = (size_t) sp->jpegtables_length; in tables_init_destination()
477 JPEGState* sp = (JPEGState*) cinfo; in tables_empty_output_buffer() local
481 newbuf = _TIFFrealloc((void*) sp->jpegtables, in tables_empty_output_buffer()
482 (tmsize_t) (sp->jpegtables_length + 1000)); in tables_empty_output_buffer()
485 sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length; in tables_empty_output_buffer()
486 sp->dest.free_in_buffer = (size_t) 1000; in tables_empty_output_buffer()
487 sp->jpegtables = newbuf; in tables_empty_output_buffer()
488 sp->jpegtables_length += 1000; in tables_empty_output_buffer()
495 JPEGState* sp = (JPEGState*) cinfo; in tables_term_destination() local
498 sp->jpegtables_length -= (uint32) sp->dest.free_in_buffer; in tables_term_destination()
502 TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif) in TIFFjpeg_tables_dest() argument
509 if (sp->jpegtables) in TIFFjpeg_tables_dest()
510 _TIFFfree(sp->jpegtables); in TIFFjpeg_tables_dest()
511 sp->jpegtables_length = 1000; in TIFFjpeg_tables_dest()
512 sp->jpegtables = (void*) _TIFFmalloc((tmsize_t) sp->jpegtables_length); in TIFFjpeg_tables_dest()
513 if (sp->jpegtables == NULL) { in TIFFjpeg_tables_dest()
514 sp->jpegtables_length = 0; in TIFFjpeg_tables_dest()
515 TIFFErrorExt(sp->tif->tif_clientdata, "TIFFjpeg_tables_dest", "No space for JPEGTables"); in TIFFjpeg_tables_dest()
518 sp->cinfo.c.dest = &sp->dest; in TIFFjpeg_tables_dest()
519 sp->dest.init_destination = tables_init_destination; in TIFFjpeg_tables_dest()
520 sp->dest.empty_output_buffer = tables_empty_output_buffer; in TIFFjpeg_tables_dest()
521 sp->dest.term_destination = tables_term_destination; in TIFFjpeg_tables_dest()
533 JPEGState* sp = (JPEGState*) cinfo; in std_init_source() local
534 TIFF* tif = sp->tif; in std_init_source()
536 sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata; in std_init_source()
537 sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; in std_init_source()
543 JPEGState* sp = (JPEGState* ) cinfo; in std_fill_input_buffer() local
556 if( sp->src.bytes_in_buffer > 0 ) { in std_fill_input_buffer()
571 sp->src.next_input_byte = dummy_EOI; in std_fill_input_buffer()
572 sp->src.bytes_in_buffer = 2; in std_fill_input_buffer()
579 JPEGState* sp = (JPEGState*) cinfo; in std_skip_input_data() local
582 if ((size_t)num_bytes > sp->src.bytes_in_buffer) { in std_skip_input_data()
586 sp->src.next_input_byte += (size_t) num_bytes; in std_skip_input_data()
587 sp->src.bytes_in_buffer -= (size_t) num_bytes; in std_skip_input_data()
600 TIFFjpeg_data_src(JPEGState* sp, TIFF* tif) in TIFFjpeg_data_src() argument
603 sp->cinfo.d.src = &sp->src; in TIFFjpeg_data_src()
604 sp->src.init_source = std_init_source; in TIFFjpeg_data_src()
605 sp->src.fill_input_buffer = std_fill_input_buffer; in TIFFjpeg_data_src()
606 sp->src.skip_input_data = std_skip_input_data; in TIFFjpeg_data_src()
607 sp->src.resync_to_restart = jpeg_resync_to_restart; in TIFFjpeg_data_src()
608 sp->src.term_source = std_term_source; in TIFFjpeg_data_src()
609 sp->src.bytes_in_buffer = 0; /* for safety */ in TIFFjpeg_data_src()
610 sp->src.next_input_byte = NULL; in TIFFjpeg_data_src()
621 JPEGState* sp = (JPEGState*) cinfo; in tables_init_source() local
623 sp->src.next_input_byte = (const JOCTET*) sp->jpegtables; in tables_init_source()
624 sp->src.bytes_in_buffer = (size_t) sp->jpegtables_length; in tables_init_source()
628 TIFFjpeg_tables_src(JPEGState* sp, TIFF* tif) in TIFFjpeg_tables_src() argument
630 TIFFjpeg_data_src(sp, tif); in TIFFjpeg_tables_src()
631 sp->src.init_source = tables_init_source; in TIFFjpeg_tables_src()
645 JPEGState* sp = JState(tif); in alloc_downsampled_buffers() local
655 buf = TIFFjpeg_alloc_sarray(sp, JPOOL_IMAGE, in alloc_downsampled_buffers()
660 sp->ds_buffer[ci] = buf; in alloc_downsampled_buffers()
662 sp->samplesperclump = samples_per_clump; in alloc_downsampled_buffers()
970 JPEGState* sp = JState(tif); in JPEGSetupDecode() local
980 assert(sp != NULL); in JPEGSetupDecode()
981 assert(sp->cinfo.comm.is_decompressor); in JPEGSetupDecode()
985 TIFFjpeg_tables_src(sp, tif); in JPEGSetupDecode()
986 if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) { in JPEGSetupDecode()
993 sp->photometric = td->td_photometric; in JPEGSetupDecode()
994 switch (sp->photometric) { in JPEGSetupDecode()
996 sp->h_sampling = td->td_ycbcrsubsampling[0]; in JPEGSetupDecode()
997 sp->v_sampling = td->td_ycbcrsubsampling[1]; in JPEGSetupDecode()
1001 sp->h_sampling = 1; in JPEGSetupDecode()
1002 sp->v_sampling = 1; in JPEGSetupDecode()
1007 TIFFjpeg_data_src(sp, tif); in JPEGSetupDecode()
1018 JPEGState *sp = JState(tif); in JPEGPreDecode() local
1025 assert(sp != NULL); in JPEGPreDecode()
1027 if (sp->cinfo.comm.is_decompressor == 0) in JPEGPreDecode()
1032 assert(sp->cinfo.comm.is_decompressor); in JPEGPreDecode()
1037 if (!TIFFjpeg_abort(sp)) in JPEGPreDecode()
1043 if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) in JPEGPreDecode()
1046 tif->tif_rawcp = (uint8*) sp->src.next_input_byte; in JPEGPreDecode()
1047 tif->tif_rawcc = sp->src.bytes_in_buffer; in JPEGPreDecode()
1057 sp->bytesperline = TIFFTileRowSize(tif); in JPEGPreDecode()
1061 sp->bytesperline = TIFFScanlineSize(tif); in JPEGPreDecode()
1068 segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); in JPEGPreDecode()
1069 segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); in JPEGPreDecode()
1071 if (sp->cinfo.d.image_width < segment_width || in JPEGPreDecode()
1072 sp->cinfo.d.image_height < segment_height) { in JPEGPreDecode()
1077 sp->cinfo.d.image_width, in JPEGPreDecode()
1078 sp->cinfo.d.image_height); in JPEGPreDecode()
1080 if (sp->cinfo.d.image_width > segment_width || in JPEGPreDecode()
1081 sp->cinfo.d.image_height > segment_height) { in JPEGPreDecode()
1092 sp->cinfo.d.image_width, sp->cinfo.d.image_height); in JPEGPreDecode()
1095 if (sp->cinfo.d.num_components != in JPEGPreDecode()
1106 sp->cinfo.d.data_precision = td->td_bitspersample; in JPEGPreDecode()
1107 sp->cinfo.d.bits_in_jsample = td->td_bitspersample; in JPEGPreDecode()
1109 if (sp->cinfo.d.data_precision != td->td_bitspersample) { in JPEGPreDecode()
1116 if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || in JPEGPreDecode()
1117 sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { in JPEGPreDecode()
1121 sp->cinfo.d.comp_info[0].h_samp_factor, in JPEGPreDecode()
1122 sp->cinfo.d.comp_info[0].v_samp_factor, in JPEGPreDecode()
1123 sp->h_sampling, sp->v_sampling); in JPEGPreDecode()
1127 for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { in JPEGPreDecode()
1128 if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || in JPEGPreDecode()
1129 sp->cinfo.d.comp_info[ci].v_samp_factor != 1) { in JPEGPreDecode()
1136 if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || in JPEGPreDecode()
1137 sp->cinfo.d.comp_info[0].v_samp_factor != 1) { in JPEGPreDecode()
1144 sp->photometric == PHOTOMETRIC_YCBCR && in JPEGPreDecode()
1145 sp->jpegcolormode == JPEGCOLORMODE_RGB) { in JPEGPreDecode()
1147 sp->cinfo.d.jpeg_color_space = JCS_YCbCr; in JPEGPreDecode()
1148 sp->cinfo.d.out_color_space = JCS_RGB; in JPEGPreDecode()
1151 sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; in JPEGPreDecode()
1152 sp->cinfo.d.out_color_space = JCS_UNKNOWN; in JPEGPreDecode()
1154 (sp->h_sampling != 1 || sp->v_sampling != 1)) in JPEGPreDecode()
1160 sp->cinfo.d.raw_data_out = TRUE; in JPEGPreDecode()
1162 sp->cinfo.d.do_fancy_upsampling = FALSE; in JPEGPreDecode()
1169 sp->cinfo.d.raw_data_out = FALSE; in JPEGPreDecode()
1175 if (!TIFFjpeg_start_decompress(sp)) in JPEGPreDecode()
1179 if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, in JPEGPreDecode()
1180 sp->cinfo.d.num_components)) in JPEGPreDecode()
1182 sp->scancount = DCTSIZE; /* mark buffer empty */ in JPEGPreDecode()
1195 JPEGState *sp = JState(tif); in JPEGDecode() local
1203 sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; in JPEGDecode()
1204 sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; in JPEGDecode()
1206 if( sp->bytesperline == 0 ) in JPEGDecode()
1209 nrows = cc / sp->bytesperline; in JPEGDecode()
1210 if (cc % sp->bytesperline) in JPEGDecode()
1214 if( nrows > (tmsize_t) sp->cinfo.d.image_height ) in JPEGDecode()
1215 nrows = sp->cinfo.d.image_height; in JPEGDecode()
1228 if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) in JPEGDecode()
1232 buf += sp->bytesperline; in JPEGDecode()
1233 cc -= sp->bytesperline; in JPEGDecode()
1238 tif->tif_rawcp = (uint8*) sp->src.next_input_byte; in JPEGDecode()
1239 tif->tif_rawcc = sp->src.bytes_in_buffer; in JPEGDecode()
1242 return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height in JPEGDecode()
1243 || TIFFjpeg_finish_decompress(sp); in JPEGDecode()
1251 JPEGState *sp = JState(tif); in JPEGDecode() local
1259 sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; in JPEGDecode()
1260 sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; in JPEGDecode()
1262 if( sp->bytesperline == 0 ) in JPEGDecode()
1265 nrows = cc / sp->bytesperline; in JPEGDecode()
1266 if (cc % sp->bytesperline) in JPEGDecode()
1270 if( nrows > (tmsize_t) sp->cinfo.d.image_height ) in JPEGDecode()
1271 nrows = sp->cinfo.d.image_height; in JPEGDecode()
1282 if( sp->cinfo.d.data_precision == 12 ) in JPEGDecode()
1285 _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width in JPEGDecode()
1286 * sp->cinfo.d.num_components ); in JPEGDecode()
1299 if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) in JPEGDecode()
1302 if( sp->cinfo.d.data_precision == 12 ) in JPEGDecode()
1304 int value_pairs = (sp->cinfo.d.output_width in JPEGDecode()
1305 * sp->cinfo.d.num_components) / 2; in JPEGDecode()
1320 else if( sp->cinfo.d.data_precision == 8 ) in JPEGDecode()
1322 int value_count = (sp->cinfo.d.output_width in JPEGDecode()
1323 * sp->cinfo.d.num_components); in JPEGDecode()
1335 buf += sp->bytesperline; in JPEGDecode()
1336 cc -= sp->bytesperline; in JPEGDecode()
1344 tif->tif_rawcp = (uint8*) sp->src.next_input_byte; in JPEGDecode()
1345 tif->tif_rawcc = sp->src.bytes_in_buffer; in JPEGDecode()
1348 return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height in JPEGDecode()
1349 || TIFFjpeg_finish_decompress(sp); in JPEGDecode()
1373 JPEGState *sp = JState(tif); in JPEGDecodeRaw() local
1378 if ( (nrows = sp->cinfo.d.image_height) ) { in JPEGDecodeRaw()
1381 JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; in JPEGDecodeRaw()
1382 int samples_per_clump = sp->samplesperclump; in JPEGDecodeRaw()
1386 sp->cinfo.d.output_width * in JPEGDecodeRaw()
1387 sp->cinfo.d.num_components); in JPEGDecodeRaw()
1399 if( cc < sp->bytesperline ) { in JPEGDecodeRaw()
1406 if (sp->scancount >= DCTSIZE) { in JPEGDecodeRaw()
1407 int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; in JPEGDecodeRaw()
1408 if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) in JPEGDecodeRaw()
1410 sp->scancount = 0; in JPEGDecodeRaw()
1417 for (ci = 0, compptr = sp->cinfo.d.comp_info; in JPEGDecodeRaw()
1418 ci < sp->cinfo.d.num_components; in JPEGDecodeRaw()
1425 JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; in JPEGDecodeRaw()
1460 if (sp->cinfo.d.data_precision == 8) in JPEGDecodeRaw()
1463 int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components; in JPEGDecodeRaw()
1471 int value_pairs = (sp->cinfo.d.output_width in JPEGDecodeRaw()
1472 * sp->cinfo.d.num_components) / 2; in JPEGDecodeRaw()
1487 sp->scancount ++; in JPEGDecodeRaw()
1488 tif->tif_row += sp->v_sampling; in JPEGDecodeRaw()
1490 buf += sp->bytesperline; in JPEGDecodeRaw()
1491 cc -= sp->bytesperline; in JPEGDecodeRaw()
1493 nrows -= sp->v_sampling; in JPEGDecodeRaw()
1503 return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height in JPEGDecodeRaw()
1504 || TIFFjpeg_finish_decompress(sp); in JPEGDecodeRaw()
1513 unsuppress_quant_table (JPEGState* sp, int tblno) in unsuppress_quant_table() argument
1517 if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) in unsuppress_quant_table()
1522 suppress_quant_table (JPEGState* sp, int tblno) in suppress_quant_table() argument
1526 if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) in suppress_quant_table()
1531 unsuppress_huff_table (JPEGState* sp, int tblno) in unsuppress_huff_table() argument
1535 if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) in unsuppress_huff_table()
1537 if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) in unsuppress_huff_table()
1542 suppress_huff_table (JPEGState* sp, int tblno) in suppress_huff_table() argument
1546 if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) in suppress_huff_table()
1548 if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) in suppress_huff_table()
1555 JPEGState* sp = JState(tif); in prepare_JPEGTables() local
1558 if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) in prepare_JPEGTables()
1562 if (!TIFFjpeg_suppress_tables(sp, TRUE)) in prepare_JPEGTables()
1564 if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { in prepare_JPEGTables()
1565 unsuppress_quant_table(sp, 0); in prepare_JPEGTables()
1566 if (sp->photometric == PHOTOMETRIC_YCBCR) in prepare_JPEGTables()
1567 unsuppress_quant_table(sp, 1); in prepare_JPEGTables()
1569 if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) { in prepare_JPEGTables()
1570 unsuppress_huff_table(sp, 0); in prepare_JPEGTables()
1571 if (sp->photometric == PHOTOMETRIC_YCBCR) in prepare_JPEGTables()
1572 unsuppress_huff_table(sp, 1); in prepare_JPEGTables()
1575 if (!TIFFjpeg_tables_dest(sp, tif)) in prepare_JPEGTables()
1578 if (!TIFFjpeg_write_tables(sp)) in prepare_JPEGTables()
1587 JPEGState* sp = JState(tif); in JPEGSetupEncode() local
1598 assert(sp != NULL); in JPEGSetupEncode()
1599 assert(!sp->cinfo.comm.is_decompressor); in JPEGSetupEncode()
1601 sp->photometric = td->td_photometric; in JPEGSetupEncode()
1609 sp->cinfo.c.input_components = td->td_samplesperpixel; in JPEGSetupEncode()
1610 if (sp->photometric == PHOTOMETRIC_YCBCR) { in JPEGSetupEncode()
1611 if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { in JPEGSetupEncode()
1612 sp->cinfo.c.in_color_space = JCS_RGB; in JPEGSetupEncode()
1614 sp->cinfo.c.in_color_space = JCS_YCbCr; in JPEGSetupEncode()
1618 sp->cinfo.c.in_color_space = JCS_GRAYSCALE; in JPEGSetupEncode()
1620 sp->cinfo.c.in_color_space = JCS_RGB; in JPEGSetupEncode()
1622 sp->cinfo.c.in_color_space = JCS_CMYK; in JPEGSetupEncode()
1624 sp->cinfo.c.in_color_space = JCS_UNKNOWN; in JPEGSetupEncode()
1627 sp->cinfo.c.input_components = 1; in JPEGSetupEncode()
1628 sp->cinfo.c.in_color_space = JCS_UNKNOWN; in JPEGSetupEncode()
1630 if (!TIFFjpeg_set_defaults(sp)) in JPEGSetupEncode()
1633 switch (sp->photometric) { in JPEGSetupEncode()
1635 sp->h_sampling = td->td_ycbcrsubsampling[0]; in JPEGSetupEncode()
1636 sp->v_sampling = td->td_ycbcrsubsampling[1]; in JPEGSetupEncode()
1663 (int) sp->photometric); in JPEGSetupEncode()
1667 sp->h_sampling = 1; in JPEGSetupEncode()
1668 sp->v_sampling = 1; in JPEGSetupEncode()
1690 sp->cinfo.c.data_precision = td->td_bitspersample; in JPEGSetupEncode()
1692 sp->cinfo.c.bits_in_jsample = td->td_bitspersample; in JPEGSetupEncode()
1695 if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { in JPEGSetupEncode()
1698 sp->v_sampling * DCTSIZE); in JPEGSetupEncode()
1701 if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { in JPEGSetupEncode()
1704 sp->h_sampling * DCTSIZE); in JPEGSetupEncode()
1709 (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { in JPEGSetupEncode()
1712 sp->v_sampling * DCTSIZE); in JPEGSetupEncode()
1718 if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { in JPEGSetupEncode()
1719 if( sp->jpegtables == NULL in JPEGSetupEncode()
1720 || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) in JPEGSetupEncode()
1736 TIFFjpeg_data_dest(sp, tif); in JPEGSetupEncode()
1747 JPEGState *sp = JState(tif); in JPEGPreEncode() local
1753 assert(sp != NULL); in JPEGPreEncode()
1755 if (sp->cinfo.comm.is_decompressor == 1) in JPEGPreEncode()
1760 assert(!sp->cinfo.comm.is_decompressor); in JPEGPreEncode()
1767 sp->bytesperline = TIFFTileRowSize(tif); in JPEGPreEncode()
1773 sp->bytesperline = TIFFScanlineSize(tif); in JPEGPreEncode()
1779 segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); in JPEGPreEncode()
1780 segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); in JPEGPreEncode()
1786 sp->cinfo.c.image_width = segment_width; in JPEGPreEncode()
1787 sp->cinfo.c.image_height = segment_height; in JPEGPreEncode()
1790 sp->cinfo.c.input_components = td->td_samplesperpixel; in JPEGPreEncode()
1791 if (sp->photometric == PHOTOMETRIC_YCBCR) { in JPEGPreEncode()
1792 if (sp->jpegcolormode != JPEGCOLORMODE_RGB) { in JPEGPreEncode()
1793 if (sp->h_sampling != 1 || sp->v_sampling != 1) in JPEGPreEncode()
1796 if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) in JPEGPreEncode()
1802 sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; in JPEGPreEncode()
1803 sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; in JPEGPreEncode()
1805 if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space)) in JPEGPreEncode()
1810 if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) in JPEGPreEncode()
1812 sp->cinfo.c.comp_info[0].component_id = s; in JPEGPreEncode()
1814 if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) { in JPEGPreEncode()
1815 sp->cinfo.c.comp_info[0].quant_tbl_no = 1; in JPEGPreEncode()
1816 sp->cinfo.c.comp_info[0].dc_tbl_no = 1; in JPEGPreEncode()
1817 sp->cinfo.c.comp_info[0].ac_tbl_no = 1; in JPEGPreEncode()
1821 sp->cinfo.c.write_JFIF_header = FALSE; in JPEGPreEncode()
1822 sp->cinfo.c.write_Adobe_marker = FALSE; in JPEGPreEncode()
1829 if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) in JPEGPreEncode()
1831 if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { in JPEGPreEncode()
1832 suppress_quant_table(sp, 0); in JPEGPreEncode()
1833 suppress_quant_table(sp, 1); in JPEGPreEncode()
1836 unsuppress_quant_table(sp, 0); in JPEGPreEncode()
1837 unsuppress_quant_table(sp, 1); in JPEGPreEncode()
1839 if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) in JPEGPreEncode()
1844 suppress_huff_table(sp, 0); in JPEGPreEncode()
1845 suppress_huff_table(sp, 1); in JPEGPreEncode()
1846 sp->cinfo.c.optimize_coding = FALSE; in JPEGPreEncode()
1849 sp->cinfo.c.optimize_coding = TRUE; in JPEGPreEncode()
1852 sp->cinfo.c.raw_data_in = TRUE; in JPEGPreEncode()
1858 sp->cinfo.c.raw_data_in = FALSE; in JPEGPreEncode()
1864 if (!TIFFjpeg_start_compress(sp, FALSE)) in JPEGPreEncode()
1868 if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, in JPEGPreEncode()
1869 sp->cinfo.c.num_components)) in JPEGPreEncode()
1872 sp->scancount = 0; in JPEGPreEncode()
1884 JPEGState *sp = JState(tif); in JPEGEncode() local
1891 assert(sp != NULL); in JPEGEncode()
1893 nrows = cc / sp->bytesperline; in JPEGEncode()
1894 if (cc % sp->bytesperline) in JPEGEncode()
1902 if( sp->cinfo.c.data_precision == 12 ) in JPEGEncode()
1904 line16_count = (sp->bytesperline * 2) / 3; in JPEGEncode()
1918 if( sp->cinfo.c.data_precision == 12 ) in JPEGEncode()
1940 if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) in JPEGEncode()
1944 buf += sp->bytesperline; in JPEGEncode()
1947 if( sp->cinfo.c.data_precision == 12 ) in JPEGEncode()
1962 JPEGState *sp = JState(tif); in JPEGEncodeRaw() local
1969 int samples_per_clump = sp->samplesperclump; in JPEGEncodeRaw()
1973 assert(sp != NULL); in JPEGEncodeRaw()
1977 bytesperclumpline = (((sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling) in JPEGEncodeRaw()
1978 *(sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7) in JPEGEncodeRaw()
1981 nrows = ( cc / bytesperclumpline ) * sp->v_sampling; in JPEGEncodeRaw()
1986 clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; in JPEGEncodeRaw()
1994 for (ci = 0, compptr = sp->cinfo.c.comp_info; in JPEGEncodeRaw()
1995 ci < sp->cinfo.c.num_components; in JPEGEncodeRaw()
2003 outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; in JPEGEncodeRaw()
2026 sp->scancount++; in JPEGEncodeRaw()
2027 if (sp->scancount >= DCTSIZE) { in JPEGEncodeRaw()
2028 int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; in JPEGEncodeRaw()
2029 if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) in JPEGEncodeRaw()
2031 sp->scancount = 0; in JPEGEncodeRaw()
2033 tif->tif_row += sp->v_sampling; in JPEGEncodeRaw()
2035 nrows -= sp->v_sampling; in JPEGEncodeRaw()
2046 JPEGState *sp = JState(tif); in JPEGPostEncode() local
2048 if (sp->scancount > 0) { in JPEGPostEncode()
2056 for (ci = 0, compptr = sp->cinfo.c.comp_info; in JPEGPostEncode()
2057 ci < sp->cinfo.c.num_components; in JPEGPostEncode()
2062 for (ypos = sp->scancount * vsamp; in JPEGPostEncode()
2064 _TIFFmemcpy((void*)sp->ds_buffer[ci][ypos], in JPEGPostEncode()
2065 (void*)sp->ds_buffer[ci][ypos-1], in JPEGPostEncode()
2070 n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; in JPEGPostEncode()
2071 if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) in JPEGPostEncode()
2081 JPEGState *sp = JState(tif); in JPEGCleanup() local
2083 assert(sp != 0); in JPEGCleanup()
2085 tif->tif_tagmethods.vgetfield = sp->vgetparent; in JPEGCleanup()
2086 tif->tif_tagmethods.vsetfield = sp->vsetparent; in JPEGCleanup()
2087 tif->tif_tagmethods.printdir = sp->printdir; in JPEGCleanup()
2088 if( sp->cinfo_initialized ) in JPEGCleanup()
2089 TIFFjpeg_destroy(sp); /* release libjpeg resources */ in JPEGCleanup()
2090 if (sp->jpegtables) /* tag value */ in JPEGCleanup()
2091 _TIFFfree(sp->jpegtables); in JPEGCleanup()
2101 JPEGState* sp = JState(tif); in JPEGResetUpsampled() local
2112 sp->jpegcolormode == JPEGCOLORMODE_RGB) { in JPEGResetUpsampled()
2136 JPEGState* sp = JState(tif); in JPEGVSetField() local
2140 assert(sp != NULL); in JPEGVSetField()
2149 _TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*), in JPEGVSetField()
2151 sp->jpegtables_length = v32; in JPEGVSetField()
2155 sp->jpegquality = (int) va_arg(ap, int); in JPEGVSetField()
2158 sp->jpegcolormode = (int) va_arg(ap, int); in JPEGVSetField()
2163 int ret_value = (*sp->vsetparent)(tif, tag, ap); in JPEGVSetField()
2168 sp->jpegtablesmode = (int) va_arg(ap, int); in JPEGVSetField()
2172 sp->ycbcrsampling_fetched = 1; in JPEGVSetField()
2174 return (*sp->vsetparent)(tif, tag, ap); in JPEGVSetField()
2176 return (*sp->vsetparent)(tif, tag, ap); in JPEGVSetField()
2192 JPEGState* sp = JState(tif); in JPEGVGetField() local
2194 assert(sp != NULL); in JPEGVGetField()
2198 *va_arg(ap, uint32*) = sp->jpegtables_length; in JPEGVGetField()
2199 *va_arg(ap, void**) = sp->jpegtables; in JPEGVGetField()
2202 *va_arg(ap, int*) = sp->jpegquality; in JPEGVGetField()
2205 *va_arg(ap, int*) = sp->jpegcolormode; in JPEGVGetField()
2208 *va_arg(ap, int*) = sp->jpegtablesmode; in JPEGVGetField()
2211 return (*sp->vgetparent)(tif, tag, ap); in JPEGVGetField()
2219 JPEGState* sp = JState(tif); in JPEGPrintDir() local
2221 assert(sp != NULL); in JPEGPrintDir()
2224 if( sp != NULL ) { in JPEGPrintDir()
2227 (unsigned long) sp->jpegtables_length); in JPEGPrintDir()
2228 if (sp->printdir) in JPEGPrintDir()
2229 (*sp->printdir)(tif, fd, flags); in JPEGPrintDir()
2236 JPEGState* sp = JState(tif); in JPEGDefaultStripSize() local
2239 s = (*sp->defsparent)(tif, s); in JPEGDefaultStripSize()
2248 JPEGState* sp = JState(tif); in JPEGDefaultTileSize() local
2251 (*sp->deftparent)(tif, tw, th); in JPEGDefaultTileSize()
2280 JPEGState* sp = JState(tif); in JPEGInitializeLibJPEG() local
2282 if(sp->cinfo_initialized) in JPEGInitializeLibJPEG()
2284 if( !decompress && sp->cinfo.comm.is_decompressor ) in JPEGInitializeLibJPEG()
2285 TIFFjpeg_destroy( sp ); in JPEGInitializeLibJPEG()
2286 else if( decompress && !sp->cinfo.comm.is_decompressor ) in JPEGInitializeLibJPEG()
2287 TIFFjpeg_destroy( sp ); in JPEGInitializeLibJPEG()
2291 sp->cinfo_initialized = 0; in JPEGInitializeLibJPEG()
2298 if (!TIFFjpeg_create_decompress(sp)) in JPEGInitializeLibJPEG()
2301 if (!TIFFjpeg_create_compress(sp)) in JPEGInitializeLibJPEG()
2305 sp->cinfo_initialized = TRUE; in JPEGInitializeLibJPEG()
2313 JPEGState* sp; in TIFFInitJPEG() local
2339 sp = JState(tif); in TIFFInitJPEG()
2340 sp->tif = tif; /* back link */ in TIFFInitJPEG()
2345 sp->vgetparent = tif->tif_tagmethods.vgetfield; in TIFFInitJPEG()
2347 sp->vsetparent = tif->tif_tagmethods.vsetfield; in TIFFInitJPEG()
2349 sp->printdir = tif->tif_tagmethods.printdir; in TIFFInitJPEG()
2353 sp->jpegtables = NULL; in TIFFInitJPEG()
2354 sp->jpegtables_length = 0; in TIFFInitJPEG()
2355 sp->jpegquality = 75; /* Default IJG quality */ in TIFFInitJPEG()
2356 sp->jpegcolormode = JPEGCOLORMODE_RAW; in TIFFInitJPEG()
2357 sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; in TIFFInitJPEG()
2358 sp->ycbcrsampling_fetched = 0; in TIFFInitJPEG()
2376 sp->defsparent = tif->tif_defstripsize; in TIFFInitJPEG()
2378 sp->deftparent = tif->tif_deftilesize; in TIFFInitJPEG()
2382 sp->cinfo_initialized = FALSE; in TIFFInitJPEG()
2401 sp->jpegtables_length = SIZE_OF_JPEGTABLES; in TIFFInitJPEG()
2402 sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); in TIFFInitJPEG()
2403 if (sp->jpegtables) in TIFFInitJPEG()
2405 _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); in TIFFInitJPEG()