• Home
  • Raw
  • Download

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()
708 JPEGState* sp = JState(tif); in JPEGFixupTags() local
712 !sp->ycbcrsampling_fetched) in JPEGFixupTags()
972 JPEGState* sp = JState(tif); in JPEGSetupDecode() local
982 assert(sp != NULL); in JPEGSetupDecode()
983 assert(sp->cinfo.comm.is_decompressor); in JPEGSetupDecode()
987 TIFFjpeg_tables_src(sp, tif); in JPEGSetupDecode()
988 if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) { in JPEGSetupDecode()
995 sp->photometric = td->td_photometric; in JPEGSetupDecode()
996 switch (sp->photometric) { in JPEGSetupDecode()
998 sp->h_sampling = td->td_ycbcrsubsampling[0]; in JPEGSetupDecode()
999 sp->v_sampling = td->td_ycbcrsubsampling[1]; in JPEGSetupDecode()
1003 sp->h_sampling = 1; in JPEGSetupDecode()
1004 sp->v_sampling = 1; in JPEGSetupDecode()
1009 TIFFjpeg_data_src(sp, tif); in JPEGSetupDecode()
1020 JPEGState *sp = JState(tif); in JPEGPreDecode() local
1027 assert(sp != NULL); in JPEGPreDecode()
1029 if (sp->cinfo.comm.is_decompressor == 0) in JPEGPreDecode()
1034 assert(sp->cinfo.comm.is_decompressor); in JPEGPreDecode()
1039 if (!TIFFjpeg_abort(sp)) in JPEGPreDecode()
1045 if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) in JPEGPreDecode()
1048 tif->tif_rawcp = (uint8*) sp->src.next_input_byte; in JPEGPreDecode()
1049 tif->tif_rawcc = sp->src.bytes_in_buffer; in JPEGPreDecode()
1059 sp->bytesperline = TIFFTileRowSize(tif); in JPEGPreDecode()
1063 sp->bytesperline = TIFFScanlineSize(tif); in JPEGPreDecode()
1070 segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); in JPEGPreDecode()
1071 segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); in JPEGPreDecode()
1073 if (sp->cinfo.d.image_width < segment_width || in JPEGPreDecode()
1074 sp->cinfo.d.image_height < segment_height) { in JPEGPreDecode()
1079 sp->cinfo.d.image_width, in JPEGPreDecode()
1080 sp->cinfo.d.image_height); in JPEGPreDecode()
1082 if (sp->cinfo.d.image_width > segment_width || in JPEGPreDecode()
1083 sp->cinfo.d.image_height > segment_height) { in JPEGPreDecode()
1094 sp->cinfo.d.image_width, sp->cinfo.d.image_height); in JPEGPreDecode()
1097 if (sp->cinfo.d.num_components != in JPEGPreDecode()
1108 sp->cinfo.d.data_precision = td->td_bitspersample; in JPEGPreDecode()
1109 sp->cinfo.d.bits_in_jsample = td->td_bitspersample; in JPEGPreDecode()
1111 if (sp->cinfo.d.data_precision != td->td_bitspersample) { in JPEGPreDecode()
1118 if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || in JPEGPreDecode()
1119 sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { in JPEGPreDecode()
1123 sp->cinfo.d.comp_info[0].h_samp_factor, in JPEGPreDecode()
1124 sp->cinfo.d.comp_info[0].v_samp_factor, in JPEGPreDecode()
1125 sp->h_sampling, sp->v_sampling); in JPEGPreDecode()
1129 for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { in JPEGPreDecode()
1130 if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || in JPEGPreDecode()
1131 sp->cinfo.d.comp_info[ci].v_samp_factor != 1) { in JPEGPreDecode()
1138 if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || in JPEGPreDecode()
1139 sp->cinfo.d.comp_info[0].v_samp_factor != 1) { in JPEGPreDecode()
1146 sp->photometric == PHOTOMETRIC_YCBCR && in JPEGPreDecode()
1147 sp->jpegcolormode == JPEGCOLORMODE_RGB) { in JPEGPreDecode()
1149 sp->cinfo.d.jpeg_color_space = JCS_YCbCr; in JPEGPreDecode()
1150 sp->cinfo.d.out_color_space = JCS_RGB; in JPEGPreDecode()
1153 sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; in JPEGPreDecode()
1154 sp->cinfo.d.out_color_space = JCS_UNKNOWN; in JPEGPreDecode()
1156 (sp->h_sampling != 1 || sp->v_sampling != 1)) in JPEGPreDecode()
1162 sp->cinfo.d.raw_data_out = TRUE; in JPEGPreDecode()
1164 sp->cinfo.d.do_fancy_upsampling = FALSE; in JPEGPreDecode()
1171 sp->cinfo.d.raw_data_out = FALSE; in JPEGPreDecode()
1177 if (!TIFFjpeg_start_decompress(sp)) in JPEGPreDecode()
1181 if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, in JPEGPreDecode()
1182 sp->cinfo.d.num_components)) in JPEGPreDecode()
1184 sp->scancount = DCTSIZE; /* mark buffer empty */ in JPEGPreDecode()
1197 JPEGState *sp = JState(tif); in JPEGDecode() local
1205 sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; in JPEGDecode()
1206 sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; in JPEGDecode()
1208 if( sp->bytesperline == 0 ) in JPEGDecode()
1211 nrows = cc / sp->bytesperline; in JPEGDecode()
1212 if (cc % sp->bytesperline) in JPEGDecode()
1216 if( nrows > (tmsize_t) sp->cinfo.d.image_height ) in JPEGDecode()
1217 nrows = sp->cinfo.d.image_height; in JPEGDecode()
1230 if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) in JPEGDecode()
1234 buf += sp->bytesperline; in JPEGDecode()
1235 cc -= sp->bytesperline; in JPEGDecode()
1240 tif->tif_rawcp = (uint8*) sp->src.next_input_byte; in JPEGDecode()
1241 tif->tif_rawcc = sp->src.bytes_in_buffer; in JPEGDecode()
1244 return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height in JPEGDecode()
1245 || TIFFjpeg_finish_decompress(sp); in JPEGDecode()
1253 JPEGState *sp = JState(tif); in JPEGDecode() local
1261 sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; in JPEGDecode()
1262 sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; in JPEGDecode()
1264 if( sp->bytesperline == 0 ) in JPEGDecode()
1267 nrows = cc / sp->bytesperline; in JPEGDecode()
1268 if (cc % sp->bytesperline) in JPEGDecode()
1272 if( nrows > (tmsize_t) sp->cinfo.d.image_height ) in JPEGDecode()
1273 nrows = sp->cinfo.d.image_height; in JPEGDecode()
1284 if( sp->cinfo.d.data_precision == 12 ) in JPEGDecode()
1287 _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width in JPEGDecode()
1288 * sp->cinfo.d.num_components ); in JPEGDecode()
1301 if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) in JPEGDecode()
1304 if( sp->cinfo.d.data_precision == 12 ) in JPEGDecode()
1306 int value_pairs = (sp->cinfo.d.output_width in JPEGDecode()
1307 * sp->cinfo.d.num_components) / 2; in JPEGDecode()
1322 else if( sp->cinfo.d.data_precision == 8 ) in JPEGDecode()
1324 int value_count = (sp->cinfo.d.output_width in JPEGDecode()
1325 * sp->cinfo.d.num_components); in JPEGDecode()
1337 buf += sp->bytesperline; in JPEGDecode()
1338 cc -= sp->bytesperline; in JPEGDecode()
1346 tif->tif_rawcp = (uint8*) sp->src.next_input_byte; in JPEGDecode()
1347 tif->tif_rawcc = sp->src.bytes_in_buffer; in JPEGDecode()
1350 return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height in JPEGDecode()
1351 || TIFFjpeg_finish_decompress(sp); in JPEGDecode()
1375 JPEGState *sp = JState(tif); in JPEGDecodeRaw() local
1380 if ( (nrows = sp->cinfo.d.image_height) != 0 ) { in JPEGDecodeRaw()
1383 JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; in JPEGDecodeRaw()
1384 int samples_per_clump = sp->samplesperclump; in JPEGDecodeRaw()
1388 sp->cinfo.d.output_width * in JPEGDecodeRaw()
1389 sp->cinfo.d.num_components); in JPEGDecodeRaw()
1401 if( cc < sp->bytesperline ) { in JPEGDecodeRaw()
1408 if (sp->scancount >= DCTSIZE) { in JPEGDecodeRaw()
1409 int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; in JPEGDecodeRaw()
1410 if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) in JPEGDecodeRaw()
1412 sp->scancount = 0; in JPEGDecodeRaw()
1419 for (ci = 0, compptr = sp->cinfo.d.comp_info; in JPEGDecodeRaw()
1420 ci < sp->cinfo.d.num_components; in JPEGDecodeRaw()
1427 JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; in JPEGDecodeRaw()
1462 if (sp->cinfo.d.data_precision == 8) in JPEGDecodeRaw()
1465 int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components; in JPEGDecodeRaw()
1473 int value_pairs = (sp->cinfo.d.output_width in JPEGDecodeRaw()
1474 * sp->cinfo.d.num_components) / 2; in JPEGDecodeRaw()
1489 sp->scancount ++; in JPEGDecodeRaw()
1490 tif->tif_row += sp->v_sampling; in JPEGDecodeRaw()
1492 buf += sp->bytesperline; in JPEGDecodeRaw()
1493 cc -= sp->bytesperline; in JPEGDecodeRaw()
1495 nrows -= sp->v_sampling; in JPEGDecodeRaw()
1505 return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height in JPEGDecodeRaw()
1506 || TIFFjpeg_finish_decompress(sp); in JPEGDecodeRaw()
1515 unsuppress_quant_table (JPEGState* sp, int tblno) in unsuppress_quant_table() argument
1519 if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) in unsuppress_quant_table()
1524 suppress_quant_table (JPEGState* sp, int tblno) in suppress_quant_table() argument
1528 if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) in suppress_quant_table()
1533 unsuppress_huff_table (JPEGState* sp, int tblno) in unsuppress_huff_table() argument
1537 if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) in unsuppress_huff_table()
1539 if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) in unsuppress_huff_table()
1544 suppress_huff_table (JPEGState* sp, int tblno) in suppress_huff_table() argument
1548 if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) in suppress_huff_table()
1550 if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) in suppress_huff_table()
1557 JPEGState* sp = JState(tif); in prepare_JPEGTables() local
1560 if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) in prepare_JPEGTables()
1564 if (!TIFFjpeg_suppress_tables(sp, TRUE)) in prepare_JPEGTables()
1566 if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { in prepare_JPEGTables()
1567 unsuppress_quant_table(sp, 0); in prepare_JPEGTables()
1568 if (sp->photometric == PHOTOMETRIC_YCBCR) in prepare_JPEGTables()
1569 unsuppress_quant_table(sp, 1); in prepare_JPEGTables()
1571 if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) { in prepare_JPEGTables()
1572 unsuppress_huff_table(sp, 0); in prepare_JPEGTables()
1573 if (sp->photometric == PHOTOMETRIC_YCBCR) in prepare_JPEGTables()
1574 unsuppress_huff_table(sp, 1); in prepare_JPEGTables()
1577 if (!TIFFjpeg_tables_dest(sp, tif)) in prepare_JPEGTables()
1580 if (!TIFFjpeg_write_tables(sp)) in prepare_JPEGTables()
1589 JPEGState* sp = JState(tif); in JPEGSetupEncode() local
1600 assert(sp != NULL); in JPEGSetupEncode()
1601 assert(!sp->cinfo.comm.is_decompressor); in JPEGSetupEncode()
1603 sp->photometric = td->td_photometric; in JPEGSetupEncode()
1611 sp->cinfo.c.input_components = td->td_samplesperpixel; in JPEGSetupEncode()
1612 if (sp->photometric == PHOTOMETRIC_YCBCR) { in JPEGSetupEncode()
1613 if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { in JPEGSetupEncode()
1614 sp->cinfo.c.in_color_space = JCS_RGB; in JPEGSetupEncode()
1616 sp->cinfo.c.in_color_space = JCS_YCbCr; in JPEGSetupEncode()
1620 sp->cinfo.c.in_color_space = JCS_GRAYSCALE; in JPEGSetupEncode()
1622 sp->cinfo.c.in_color_space = JCS_RGB; in JPEGSetupEncode()
1624 sp->cinfo.c.in_color_space = JCS_CMYK; in JPEGSetupEncode()
1626 sp->cinfo.c.in_color_space = JCS_UNKNOWN; in JPEGSetupEncode()
1629 sp->cinfo.c.input_components = 1; in JPEGSetupEncode()
1630 sp->cinfo.c.in_color_space = JCS_UNKNOWN; in JPEGSetupEncode()
1632 if (!TIFFjpeg_set_defaults(sp)) in JPEGSetupEncode()
1635 switch (sp->photometric) { in JPEGSetupEncode()
1637 sp->h_sampling = td->td_ycbcrsubsampling[0]; in JPEGSetupEncode()
1638 sp->v_sampling = td->td_ycbcrsubsampling[1]; in JPEGSetupEncode()
1639 if( sp->h_sampling == 0 || sp->v_sampling == 0 ) in JPEGSetupEncode()
1679 (int) sp->photometric); in JPEGSetupEncode()
1683 sp->h_sampling = 1; in JPEGSetupEncode()
1684 sp->v_sampling = 1; in JPEGSetupEncode()
1706 sp->cinfo.c.data_precision = td->td_bitspersample; in JPEGSetupEncode()
1708 sp->cinfo.c.bits_in_jsample = td->td_bitspersample; in JPEGSetupEncode()
1711 if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) { in JPEGSetupEncode()
1714 sp->v_sampling * DCTSIZE); in JPEGSetupEncode()
1717 if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) { in JPEGSetupEncode()
1720 sp->h_sampling * DCTSIZE); in JPEGSetupEncode()
1725 (td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) { in JPEGSetupEncode()
1728 sp->v_sampling * DCTSIZE); in JPEGSetupEncode()
1734 if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { in JPEGSetupEncode()
1735 if( sp->jpegtables == NULL in JPEGSetupEncode()
1736 || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) in JPEGSetupEncode()
1752 TIFFjpeg_data_dest(sp, tif); in JPEGSetupEncode()
1763 JPEGState *sp = JState(tif); in JPEGPreEncode() local
1769 assert(sp != NULL); in JPEGPreEncode()
1771 if (sp->cinfo.comm.is_decompressor == 1) in JPEGPreEncode()
1776 assert(!sp->cinfo.comm.is_decompressor); in JPEGPreEncode()
1783 sp->bytesperline = TIFFTileRowSize(tif); in JPEGPreEncode()
1789 sp->bytesperline = TIFFScanlineSize(tif); in JPEGPreEncode()
1795 segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); in JPEGPreEncode()
1796 segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); in JPEGPreEncode()
1802 sp->cinfo.c.image_width = segment_width; in JPEGPreEncode()
1803 sp->cinfo.c.image_height = segment_height; in JPEGPreEncode()
1806 sp->cinfo.c.input_components = td->td_samplesperpixel; in JPEGPreEncode()
1807 if (sp->photometric == PHOTOMETRIC_YCBCR) { in JPEGPreEncode()
1808 if (sp->jpegcolormode != JPEGCOLORMODE_RGB) { in JPEGPreEncode()
1809 if (sp->h_sampling != 1 || sp->v_sampling != 1) in JPEGPreEncode()
1812 if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) in JPEGPreEncode()
1818 sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; in JPEGPreEncode()
1819 sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; in JPEGPreEncode()
1821 if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space)) in JPEGPreEncode()
1826 if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) in JPEGPreEncode()
1828 sp->cinfo.c.comp_info[0].component_id = s; in JPEGPreEncode()
1830 if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) { in JPEGPreEncode()
1831 sp->cinfo.c.comp_info[0].quant_tbl_no = 1; in JPEGPreEncode()
1832 sp->cinfo.c.comp_info[0].dc_tbl_no = 1; in JPEGPreEncode()
1833 sp->cinfo.c.comp_info[0].ac_tbl_no = 1; in JPEGPreEncode()
1837 sp->cinfo.c.write_JFIF_header = FALSE; in JPEGPreEncode()
1838 sp->cinfo.c.write_Adobe_marker = FALSE; in JPEGPreEncode()
1845 if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) in JPEGPreEncode()
1847 if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { in JPEGPreEncode()
1848 suppress_quant_table(sp, 0); in JPEGPreEncode()
1849 suppress_quant_table(sp, 1); in JPEGPreEncode()
1852 unsuppress_quant_table(sp, 0); in JPEGPreEncode()
1853 unsuppress_quant_table(sp, 1); in JPEGPreEncode()
1855 if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) in JPEGPreEncode()
1860 suppress_huff_table(sp, 0); in JPEGPreEncode()
1861 suppress_huff_table(sp, 1); in JPEGPreEncode()
1862 sp->cinfo.c.optimize_coding = FALSE; in JPEGPreEncode()
1865 sp->cinfo.c.optimize_coding = TRUE; in JPEGPreEncode()
1868 sp->cinfo.c.raw_data_in = TRUE; in JPEGPreEncode()
1874 sp->cinfo.c.raw_data_in = FALSE; in JPEGPreEncode()
1880 if (!TIFFjpeg_start_compress(sp, FALSE)) in JPEGPreEncode()
1884 if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, in JPEGPreEncode()
1885 sp->cinfo.c.num_components)) in JPEGPreEncode()
1888 sp->scancount = 0; in JPEGPreEncode()
1900 JPEGState *sp = JState(tif); in JPEGEncode() local
1907 assert(sp != NULL); in JPEGEncode()
1909 nrows = cc / sp->bytesperline; in JPEGEncode()
1910 if (cc % sp->bytesperline) in JPEGEncode()
1918 if( sp->cinfo.c.data_precision == 12 ) in JPEGEncode()
1920 line16_count = (int)((sp->bytesperline * 2) / 3); in JPEGEncode()
1934 if( sp->cinfo.c.data_precision == 12 ) in JPEGEncode()
1956 if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) in JPEGEncode()
1960 buf += sp->bytesperline; in JPEGEncode()
1963 if( sp->cinfo.c.data_precision == 12 ) in JPEGEncode()
1978 JPEGState *sp = JState(tif); in JPEGEncodeRaw() local
1985 int samples_per_clump = sp->samplesperclump; in JPEGEncodeRaw()
1989 assert(sp != NULL); in JPEGEncodeRaw()
1993 bytesperclumpline = (((sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling) in JPEGEncodeRaw()
1994 *(sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7) in JPEGEncodeRaw()
1997 nrows = ( cc / bytesperclumpline ) * sp->v_sampling; in JPEGEncodeRaw()
2002 clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; in JPEGEncodeRaw()
2010 for (ci = 0, compptr = sp->cinfo.c.comp_info; in JPEGEncodeRaw()
2011 ci < sp->cinfo.c.num_components; in JPEGEncodeRaw()
2019 outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; in JPEGEncodeRaw()
2042 sp->scancount++; in JPEGEncodeRaw()
2043 if (sp->scancount >= DCTSIZE) { in JPEGEncodeRaw()
2044 int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; in JPEGEncodeRaw()
2045 if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) in JPEGEncodeRaw()
2047 sp->scancount = 0; in JPEGEncodeRaw()
2049 tif->tif_row += sp->v_sampling; in JPEGEncodeRaw()
2051 nrows -= sp->v_sampling; in JPEGEncodeRaw()
2062 JPEGState *sp = JState(tif); in JPEGPostEncode() local
2064 if (sp->scancount > 0) { in JPEGPostEncode()
2072 for (ci = 0, compptr = sp->cinfo.c.comp_info; in JPEGPostEncode()
2073 ci < sp->cinfo.c.num_components; in JPEGPostEncode()
2078 for (ypos = sp->scancount * vsamp; in JPEGPostEncode()
2080 _TIFFmemcpy((void*)sp->ds_buffer[ci][ypos], in JPEGPostEncode()
2081 (void*)sp->ds_buffer[ci][ypos-1], in JPEGPostEncode()
2086 n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; in JPEGPostEncode()
2087 if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) in JPEGPostEncode()
2097 JPEGState *sp = JState(tif); in JPEGCleanup() local
2099 assert(sp != 0); in JPEGCleanup()
2101 tif->tif_tagmethods.vgetfield = sp->vgetparent; in JPEGCleanup()
2102 tif->tif_tagmethods.vsetfield = sp->vsetparent; in JPEGCleanup()
2103 tif->tif_tagmethods.printdir = sp->printdir; in JPEGCleanup()
2104 if( sp->cinfo_initialized ) in JPEGCleanup()
2105 TIFFjpeg_destroy(sp); /* release libjpeg resources */ in JPEGCleanup()
2106 if (sp->jpegtables) /* tag value */ in JPEGCleanup()
2107 _TIFFfree(sp->jpegtables); in JPEGCleanup()
2117 JPEGState* sp = JState(tif); in JPEGResetUpsampled() local
2128 sp->jpegcolormode == JPEGCOLORMODE_RGB) { in JPEGResetUpsampled()
2152 JPEGState* sp = JState(tif); in JPEGVSetField() local
2156 assert(sp != NULL); in JPEGVSetField()
2165 _TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*), v32); in JPEGVSetField()
2166 sp->jpegtables_length = v32; in JPEGVSetField()
2170 sp->jpegquality = (int) va_arg(ap, int); in JPEGVSetField()
2173 sp->jpegcolormode = (int) va_arg(ap, int); in JPEGVSetField()
2178 int ret_value = (*sp->vsetparent)(tif, tag, ap); in JPEGVSetField()
2183 sp->jpegtablesmode = (int) va_arg(ap, int); in JPEGVSetField()
2187 sp->ycbcrsampling_fetched = 1; in JPEGVSetField()
2189 return (*sp->vsetparent)(tif, tag, ap); in JPEGVSetField()
2191 return (*sp->vsetparent)(tif, tag, ap); in JPEGVSetField()
2207 JPEGState* sp = JState(tif); in JPEGVGetField() local
2209 assert(sp != NULL); in JPEGVGetField()
2213 *va_arg(ap, uint32*) = sp->jpegtables_length; in JPEGVGetField()
2214 *va_arg(ap, void**) = sp->jpegtables; in JPEGVGetField()
2217 *va_arg(ap, int*) = sp->jpegquality; in JPEGVGetField()
2220 *va_arg(ap, int*) = sp->jpegcolormode; in JPEGVGetField()
2223 *va_arg(ap, int*) = sp->jpegtablesmode; in JPEGVGetField()
2226 return (*sp->vgetparent)(tif, tag, ap); in JPEGVGetField()
2234 JPEGState* sp = JState(tif); in JPEGPrintDir() local
2236 assert(sp != NULL); in JPEGPrintDir()
2239 if( sp != NULL ) { in JPEGPrintDir()
2242 (unsigned long) sp->jpegtables_length); in JPEGPrintDir()
2243 if (sp->printdir) in JPEGPrintDir()
2244 (*sp->printdir)(tif, fd, flags); in JPEGPrintDir()
2251 JPEGState* sp = JState(tif); in JPEGDefaultStripSize() local
2254 s = (*sp->defsparent)(tif, s); in JPEGDefaultStripSize()
2263 JPEGState* sp = JState(tif); in JPEGDefaultTileSize() local
2266 (*sp->deftparent)(tif, tw, th); in JPEGDefaultTileSize()
2295 JPEGState* sp = JState(tif); in JPEGInitializeLibJPEG() local
2297 if(sp->cinfo_initialized) in JPEGInitializeLibJPEG()
2299 if( !decompress && sp->cinfo.comm.is_decompressor ) in JPEGInitializeLibJPEG()
2300 TIFFjpeg_destroy( sp ); in JPEGInitializeLibJPEG()
2301 else if( decompress && !sp->cinfo.comm.is_decompressor ) in JPEGInitializeLibJPEG()
2302 TIFFjpeg_destroy( sp ); in JPEGInitializeLibJPEG()
2306 sp->cinfo_initialized = 0; in JPEGInitializeLibJPEG()
2313 if (!TIFFjpeg_create_decompress(sp)) in JPEGInitializeLibJPEG()
2316 if (!TIFFjpeg_create_compress(sp)) in JPEGInitializeLibJPEG()
2325 if( sp->cinfo.c.mem->max_memory_to_use < TIFF_JPEG_MAX_MEMORY_TO_USE ) in JPEGInitializeLibJPEG()
2326 sp->cinfo.c.mem->max_memory_to_use = TIFF_JPEG_MAX_MEMORY_TO_USE; in JPEGInitializeLibJPEG()
2329 sp->cinfo_initialized = TRUE; in JPEGInitializeLibJPEG()
2337 JPEGState* sp; in TIFFInitJPEG() local
2363 sp = JState(tif); in TIFFInitJPEG()
2364 sp->tif = tif; /* back link */ in TIFFInitJPEG()
2369 sp->vgetparent = tif->tif_tagmethods.vgetfield; in TIFFInitJPEG()
2371 sp->vsetparent = tif->tif_tagmethods.vsetfield; in TIFFInitJPEG()
2373 sp->printdir = tif->tif_tagmethods.printdir; in TIFFInitJPEG()
2377 sp->jpegtables = NULL; in TIFFInitJPEG()
2378 sp->jpegtables_length = 0; in TIFFInitJPEG()
2379 sp->jpegquality = 75; /* Default IJG quality */ in TIFFInitJPEG()
2380 sp->jpegcolormode = JPEGCOLORMODE_RAW; in TIFFInitJPEG()
2381 sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; in TIFFInitJPEG()
2382 sp->ycbcrsampling_fetched = 0; in TIFFInitJPEG()
2400 sp->defsparent = tif->tif_defstripsize; in TIFFInitJPEG()
2402 sp->deftparent = tif->tif_deftilesize; in TIFFInitJPEG()
2406 sp->cinfo_initialized = FALSE; in TIFFInitJPEG()
2425 sp->jpegtables_length = SIZE_OF_JPEGTABLES; in TIFFInitJPEG()
2426 sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); in TIFFInitJPEG()
2427 if (sp->jpegtables) in TIFFInitJPEG()
2429 _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); in TIFFInitJPEG()