• Home
  • Raw
  • Download

Lines Matching refs:sp

384 static int OJPEGReadBufferFill(OJPEGState* sp);
385 static int OJPEGReadByte(OJPEGState* sp, uint8* byte);
386 static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte);
387 static void OJPEGReadByteAdvance(OJPEGState* sp);
388 static int OJPEGReadWord(OJPEGState* sp, uint16* word);
389 static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem);
390 static void OJPEGReadSkip(OJPEGState* sp, uint16 len);
405 extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
406 extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_imag…
407 extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
408 extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines…
409 extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint…
412 static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j);
413 static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_imag…
414 static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
415 static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines…
416 static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint…
432 OJPEGState* sp; in TIFFInitOJPEG() local
446 sp=_TIFFmalloc(sizeof(OJPEGState)); in TIFFInitOJPEG()
447 if (sp==NULL) in TIFFInitOJPEG()
452 _TIFFmemset(sp,0,sizeof(OJPEGState)); in TIFFInitOJPEG()
453 sp->tif=tif; in TIFFInitOJPEG()
454 sp->jpeg_proc=1; in TIFFInitOJPEG()
455 sp->subsampling_hor=2; in TIFFInitOJPEG()
456 sp->subsampling_ver=2; in TIFFInitOJPEG()
473 tif->tif_data=(uint8*)sp; in TIFFInitOJPEG()
475 sp->vgetparent=tif->tif_tagmethods.vgetfield; in TIFFInitOJPEG()
477 sp->vsetparent=tif->tif_tagmethods.vsetfield; in TIFFInitOJPEG()
479 sp->printdir=tif->tif_tagmethods.printdir; in TIFFInitOJPEG()
494 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGVGetField() local
498 *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format; in OJPEGVGetField()
501 *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format_length; in OJPEGVGetField()
504 if (sp->subsamplingcorrect_done==0) in OJPEGVGetField()
506 *va_arg(ap,uint16*)=(uint16)sp->subsampling_hor; in OJPEGVGetField()
507 *va_arg(ap,uint16*)=(uint16)sp->subsampling_ver; in OJPEGVGetField()
510 *va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count; in OJPEGVGetField()
511 *va_arg(ap,void**)=(void*)sp->qtable_offset; in OJPEGVGetField()
514 *va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count; in OJPEGVGetField()
515 *va_arg(ap,void**)=(void*)sp->dctable_offset; in OJPEGVGetField()
518 *va_arg(ap,uint32*)=(uint32)sp->actable_offset_count; in OJPEGVGetField()
519 *va_arg(ap,void**)=(void*)sp->actable_offset; in OJPEGVGetField()
522 *va_arg(ap,uint16*)=(uint16)sp->jpeg_proc; in OJPEGVGetField()
525 *va_arg(ap,uint16*)=sp->restart_interval; in OJPEGVGetField()
528 return (*sp->vgetparent)(tif,tag,ap); in OJPEGVGetField()
537 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGVSetField() local
546 sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64); in OJPEGVSetField()
549 sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64); in OJPEGVSetField()
552 sp->subsampling_tag=1; in OJPEGVSetField()
553 sp->subsampling_hor=(uint8)va_arg(ap,uint16_vap); in OJPEGVSetField()
554 sp->subsampling_ver=(uint8)va_arg(ap,uint16_vap); in OJPEGVSetField()
555 tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor; in OJPEGVSetField()
556 tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver; in OJPEGVSetField()
567 sp->qtable_offset_count=(uint8)ma; in OJPEGVSetField()
570 sp->qtable_offset[n]=mb[n]; in OJPEGVSetField()
582 sp->dctable_offset_count=(uint8)ma; in OJPEGVSetField()
585 sp->dctable_offset[n]=mb[n]; in OJPEGVSetField()
597 sp->actable_offset_count=(uint8)ma; in OJPEGVSetField()
600 sp->actable_offset[n]=mb[n]; in OJPEGVSetField()
604 sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap); in OJPEGVSetField()
607 sp->restart_interval=(uint16)va_arg(ap,uint16_vap); in OJPEGVSetField()
610 return (*sp->vsetparent)(tif,tag,ap); in OJPEGVSetField()
623 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPrintDir() local
626 assert(sp!=NULL); in OJPEGPrintDir()
628 …fprintf(fd," JpegInterchangeFormat: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange… in OJPEGPrintDir()
630 …fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_inter… in OJPEGPrintDir()
634 for (m=0; m<sp->qtable_offset_count; m++) in OJPEGPrintDir()
635 fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]); in OJPEGPrintDir()
641 for (m=0; m<sp->dctable_offset_count; m++) in OJPEGPrintDir()
642 fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]); in OJPEGPrintDir()
648 for (m=0; m<sp->actable_offset_count; m++) in OJPEGPrintDir()
649 fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->actable_offset[m]); in OJPEGPrintDir()
653 fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); in OJPEGPrintDir()
655 fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); in OJPEGPrintDir()
656 if (sp->printdir) in OJPEGPrintDir()
657 (*sp->printdir)(tif, fd, flags); in OJPEGPrintDir()
678 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecode() local
680 if (sp->subsamplingcorrect_done==0) in OJPEGPreDecode()
682 if (sp->readheader_done==0) in OJPEGPreDecode()
687 if (sp->sos_end[s].log==0) in OJPEGPreDecode()
696 if ((sp->writeheader_done!=0) && ((sp->write_cursample!=s) || (sp->write_curstrile>m))) in OJPEGPreDecode()
698 if (sp->libjpeg_session_active!=0) in OJPEGPreDecode()
700 sp->writeheader_done=0; in OJPEGPreDecode()
702 if (sp->writeheader_done==0) in OJPEGPreDecode()
704 sp->plane_sample_offset=(uint8)s; in OJPEGPreDecode()
705 sp->write_cursample=s; in OJPEGPreDecode()
706 sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; in OJPEGPreDecode()
707 if ((sp->in_buffer_file_pos_log==0) || in OJPEGPreDecode()
708 (sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos)) in OJPEGPreDecode()
710 sp->in_buffer_source=sp->sos_end[s].in_buffer_source; in OJPEGPreDecode()
711 sp->in_buffer_next_strile=sp->sos_end[s].in_buffer_next_strile; in OJPEGPreDecode()
712 sp->in_buffer_file_pos=sp->sos_end[s].in_buffer_file_pos; in OJPEGPreDecode()
713 sp->in_buffer_file_pos_log=0; in OJPEGPreDecode()
714 sp->in_buffer_file_togo=sp->sos_end[s].in_buffer_file_togo; in OJPEGPreDecode()
715 sp->in_buffer_togo=0; in OJPEGPreDecode()
716 sp->in_buffer_cur=0; in OJPEGPreDecode()
721 while (sp->write_curstrile<m) in OJPEGPreDecode()
723 if (sp->libjpeg_jpeg_query_style==0) in OJPEGPreDecode()
733 sp->write_curstrile++; in OJPEGPreDecode()
735 sp->decoder_ok = 1; in OJPEGPreDecode()
742 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecodeSkipRaw() local
744 m=sp->lines_per_strile; in OJPEGPreDecodeSkipRaw()
745 if (sp->subsampling_convert_state!=0) in OJPEGPreDecodeSkipRaw()
747 if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m) in OJPEGPreDecodeSkipRaw()
749 sp->subsampling_convert_state+=m; in OJPEGPreDecodeSkipRaw()
750 if (sp->subsampling_convert_state==sp->subsampling_convert_clines) in OJPEGPreDecodeSkipRaw()
751 sp->subsampling_convert_state=0; in OJPEGPreDecodeSkipRaw()
754 m-=sp->subsampling_convert_clines-sp->subsampling_convert_state; in OJPEGPreDecodeSkipRaw()
755 sp->subsampling_convert_state=0; in OJPEGPreDecodeSkipRaw()
757 while (m>=sp->subsampling_convert_clines) in OJPEGPreDecodeSkipRaw()
759 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGPreDecodeSkipRaw()
761 m-=sp->subsampling_convert_clines; in OJPEGPreDecodeSkipRaw()
765 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGPreDecodeSkipRaw()
767 sp->subsampling_convert_state=m; in OJPEGPreDecodeSkipRaw()
776 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecodeSkipScanlines() local
778 if (sp->skip_buffer==NULL) in OJPEGPreDecodeSkipScanlines()
780 sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); in OJPEGPreDecodeSkipScanlines()
781 if (sp->skip_buffer==NULL) in OJPEGPreDecodeSkipScanlines()
787 for (m=0; m<sp->lines_per_strile; m++) in OJPEGPreDecodeSkipScanlines()
789 if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&sp->skip_buffer,1)==0) in OJPEGPreDecodeSkipScanlines()
799 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecode() local
801 if( !sp->decoder_ok ) in OJPEGDecode()
806 if (sp->libjpeg_jpeg_query_style==0) in OJPEGDecode()
823 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecodeRaw() local
833 if (cc%sp->bytes_per_line!=0) in OJPEGDecodeRaw()
843 if (sp->subsampling_convert_state==0) in OJPEGDecodeRaw()
845 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGDecodeRaw()
848 …oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_… in OJPEGDecodeRaw()
849 ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; in OJPEGDecodeRaw()
850 ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; in OJPEGDecodeRaw()
852 for (q=0; q<sp->subsampling_convert_clinelenout; q++) in OJPEGDecodeRaw()
855 for (sy=0; sy<sp->subsampling_ver; sy++) in OJPEGDecodeRaw()
857 for (sx=0; sx<sp->subsampling_hor; sx++) in OJPEGDecodeRaw()
859 r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor; in OJPEGDecodeRaw()
861 oy+=sp->subsampling_hor; in OJPEGDecodeRaw()
865 sp->subsampling_convert_state++; in OJPEGDecodeRaw()
866 if (sp->subsampling_convert_state==sp->subsampling_convert_clines) in OJPEGDecodeRaw()
867 sp->subsampling_convert_state=0; in OJPEGDecodeRaw()
868 m+=sp->bytes_per_line; in OJPEGDecodeRaw()
869 n-=sp->bytes_per_line; in OJPEGDecodeRaw()
878 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecodeScanlines() local
881 if (cc%sp->bytes_per_line!=0) in OJPEGDecodeScanlines()
891 if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0) in OJPEGDecodeScanlines()
893 m+=sp->bytes_per_line; in OJPEGDecodeScanlines()
894 n-=sp->bytes_per_line; in OJPEGDecodeScanlines()
902 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPostDecode() local
905 sp->write_curstrile++; in OJPEGPostDecode()
906 if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) in OJPEGPostDecode()
908 assert(sp->libjpeg_session_active!=0); in OJPEGPostDecode()
910 sp->writeheader_done=0; in OJPEGPostDecode()
953 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGCleanup() local
954 if (sp!=0) in OJPEGCleanup()
956 tif->tif_tagmethods.vgetfield=sp->vgetparent; in OJPEGCleanup()
957 tif->tif_tagmethods.vsetfield=sp->vsetparent; in OJPEGCleanup()
958 tif->tif_tagmethods.printdir=sp->printdir; in OJPEGCleanup()
959 if (sp->qtable[0]!=0) in OJPEGCleanup()
960 _TIFFfree(sp->qtable[0]); in OJPEGCleanup()
961 if (sp->qtable[1]!=0) in OJPEGCleanup()
962 _TIFFfree(sp->qtable[1]); in OJPEGCleanup()
963 if (sp->qtable[2]!=0) in OJPEGCleanup()
964 _TIFFfree(sp->qtable[2]); in OJPEGCleanup()
965 if (sp->qtable[3]!=0) in OJPEGCleanup()
966 _TIFFfree(sp->qtable[3]); in OJPEGCleanup()
967 if (sp->dctable[0]!=0) in OJPEGCleanup()
968 _TIFFfree(sp->dctable[0]); in OJPEGCleanup()
969 if (sp->dctable[1]!=0) in OJPEGCleanup()
970 _TIFFfree(sp->dctable[1]); in OJPEGCleanup()
971 if (sp->dctable[2]!=0) in OJPEGCleanup()
972 _TIFFfree(sp->dctable[2]); in OJPEGCleanup()
973 if (sp->dctable[3]!=0) in OJPEGCleanup()
974 _TIFFfree(sp->dctable[3]); in OJPEGCleanup()
975 if (sp->actable[0]!=0) in OJPEGCleanup()
976 _TIFFfree(sp->actable[0]); in OJPEGCleanup()
977 if (sp->actable[1]!=0) in OJPEGCleanup()
978 _TIFFfree(sp->actable[1]); in OJPEGCleanup()
979 if (sp->actable[2]!=0) in OJPEGCleanup()
980 _TIFFfree(sp->actable[2]); in OJPEGCleanup()
981 if (sp->actable[3]!=0) in OJPEGCleanup()
982 _TIFFfree(sp->actable[3]); in OJPEGCleanup()
983 if (sp->libjpeg_session_active!=0) in OJPEGCleanup()
985 if (sp->subsampling_convert_ycbcrbuf!=0) in OJPEGCleanup()
986 _TIFFfree(sp->subsampling_convert_ycbcrbuf); in OJPEGCleanup()
987 if (sp->subsampling_convert_ycbcrimage!=0) in OJPEGCleanup()
988 _TIFFfree(sp->subsampling_convert_ycbcrimage); in OJPEGCleanup()
989 if (sp->skip_buffer!=0) in OJPEGCleanup()
990 _TIFFfree(sp->skip_buffer); in OJPEGCleanup()
991 _TIFFfree(sp); in OJPEGCleanup()
1001 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGSubsamplingCorrect() local
1006 assert(sp->subsamplingcorrect_done==0); in OJPEGSubsamplingCorrect()
1010 if (sp->subsampling_tag!=0) in OJPEGSubsamplingCorrect()
1012 sp->subsampling_hor=1; in OJPEGSubsamplingCorrect()
1013 sp->subsampling_ver=1; in OJPEGSubsamplingCorrect()
1014 sp->subsampling_force_desubsampling_inside_decompression=0; in OJPEGSubsamplingCorrect()
1018 sp->subsamplingcorrect_done=1; in OJPEGSubsamplingCorrect()
1019 mh=sp->subsampling_hor; in OJPEGSubsamplingCorrect()
1020 mv=sp->subsampling_ver; in OJPEGSubsamplingCorrect()
1021 sp->subsamplingcorrect=1; in OJPEGSubsamplingCorrect()
1023 if (sp->subsampling_force_desubsampling_inside_decompression!=0) in OJPEGSubsamplingCorrect()
1025 sp->subsampling_hor=1; in OJPEGSubsamplingCorrect()
1026 sp->subsampling_ver=1; in OJPEGSubsamplingCorrect()
1028 sp->subsamplingcorrect=0; in OJPEGSubsamplingCorrect()
1029 …if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampli… in OJPEGSubsamplingCorrect()
1031 if (sp->subsampling_tag==0) in OJPEGSubsamplingCorrect()
1032 … values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1034 …alues [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1036 if (sp->subsampling_force_desubsampling_inside_decompression!=0) in OJPEGSubsamplingCorrect()
1038 if (sp->subsampling_tag==0) in OJPEGSubsamplingCorrect()
1043 if (sp->subsampling_force_desubsampling_inside_decompression==0) in OJPEGSubsamplingCorrect()
1045 if (sp->subsampling_hor<sp->subsampling_ver) in OJPEGSubsamplingCorrect()
1046 …data,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1049 sp->subsamplingcorrect_done=1; in OJPEGSubsamplingCorrect()
1056 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfo() local
1057 assert(sp->readheader_done==0); in OJPEGReadHeaderInfo()
1058 sp->image_width=tif->tif_dir.td_imagewidth; in OJPEGReadHeaderInfo()
1059 sp->image_length=tif->tif_dir.td_imagelength; in OJPEGReadHeaderInfo()
1062 sp->strile_width=tif->tif_dir.td_tilewidth; in OJPEGReadHeaderInfo()
1063 sp->strile_length=tif->tif_dir.td_tilelength; in OJPEGReadHeaderInfo()
1064sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_leng… in OJPEGReadHeaderInfo()
1068 sp->strile_width=sp->image_width; in OJPEGReadHeaderInfo()
1069 sp->strile_length=tif->tif_dir.td_rowsperstrip; in OJPEGReadHeaderInfo()
1070 sp->strile_length_total=sp->image_length; in OJPEGReadHeaderInfo()
1074 sp->samples_per_pixel=1; in OJPEGReadHeaderInfo()
1075 sp->plane_sample_offset=0; in OJPEGReadHeaderInfo()
1076 sp->samples_per_pixel_per_plane=sp->samples_per_pixel; in OJPEGReadHeaderInfo()
1077 sp->subsampling_hor=1; in OJPEGReadHeaderInfo()
1078 sp->subsampling_ver=1; in OJPEGReadHeaderInfo()
1084 …tdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); in OJPEGReadHeaderInfo()
1087 sp->samples_per_pixel=3; in OJPEGReadHeaderInfo()
1088 sp->plane_sample_offset=0; in OJPEGReadHeaderInfo()
1090 sp->samples_per_pixel_per_plane=3; in OJPEGReadHeaderInfo()
1092 sp->samples_per_pixel_per_plane=1; in OJPEGReadHeaderInfo()
1094 if (sp->strile_length<sp->image_length) in OJPEGReadHeaderInfo()
1096 if (sp->strile_length%(sp->subsampling_ver*8)!=0) in OJPEGReadHeaderInfo()
1101sp->restart_interval=(uint16)(((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))… in OJPEGReadHeaderInfo()
1105 sp->sos_end[0].log=1; in OJPEGReadHeaderInfo()
1106 sp->sos_end[0].in_buffer_source=sp->in_buffer_source; in OJPEGReadHeaderInfo()
1107 sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile; in OJPEGReadHeaderInfo()
1108 sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; in OJPEGReadHeaderInfo()
1109 sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; in OJPEGReadHeaderInfo()
1110 sp->readheader_done=1; in OJPEGReadHeaderInfo()
1117 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadSecondarySos() local
1121 assert(sp->sos_end[0].log!=0); in OJPEGReadSecondarySos()
1122 assert(sp->sos_end[s].log==0); in OJPEGReadSecondarySos()
1123 sp->plane_sample_offset=(uint8)(s-1); in OJPEGReadSecondarySos()
1124 while(sp->sos_end[sp->plane_sample_offset].log==0) in OJPEGReadSecondarySos()
1125 sp->plane_sample_offset--; in OJPEGReadSecondarySos()
1126 sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; in OJPEGReadSecondarySos()
1127 sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; in OJPEGReadSecondarySos()
1128 sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; in OJPEGReadSecondarySos()
1129 sp->in_buffer_file_pos_log=0; in OJPEGReadSecondarySos()
1130 sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; in OJPEGReadSecondarySos()
1131 sp->in_buffer_togo=0; in OJPEGReadSecondarySos()
1132 sp->in_buffer_cur=0; in OJPEGReadSecondarySos()
1133 while(sp->plane_sample_offset<s) in OJPEGReadSecondarySos()
1137 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadSecondarySos()
1143 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadSecondarySos()
1152 sp->plane_sample_offset++; in OJPEGReadSecondarySos()
1155 sp->sos_end[sp->plane_sample_offset].log=1; in OJPEGReadSecondarySos()
1156 sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source; in OJPEGReadSecondarySos()
1157 sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile; in OJPEGReadSecondarySos()
1158 sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; in OJPEGReadSecondarySos()
1159sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_tog… in OJPEGReadSecondarySos()
1168 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteHeaderInfo() local
1172 if (sp->libjpeg_session_active != 0) in OJPEGWriteHeaderInfo()
1174 sp->out_state=ososSoi; in OJPEGWriteHeaderInfo()
1175 sp->restart_index=0; in OJPEGWriteHeaderInfo()
1176 jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); in OJPEGWriteHeaderInfo()
1177 sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage; in OJPEGWriteHeaderInfo()
1178 sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit; in OJPEGWriteHeaderInfo()
1179 sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr); in OJPEGWriteHeaderInfo()
1180 sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif; in OJPEGWriteHeaderInfo()
1181 if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) in OJPEGWriteHeaderInfo()
1183 sp->libjpeg_session_active=1; in OJPEGWriteHeaderInfo()
1184 sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0; in OJPEGWriteHeaderInfo()
1185 sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource; in OJPEGWriteHeaderInfo()
1186 sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer; in OJPEGWriteHeaderInfo()
1187 sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData; in OJPEGWriteHeaderInfo()
1188 sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart; in OJPEGWriteHeaderInfo()
1189 sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource; in OJPEGWriteHeaderInfo()
1190 sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr); in OJPEGWriteHeaderInfo()
1191 if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0) in OJPEGWriteHeaderInfo()
1193 …if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_pl… in OJPEGWriteHeaderInfo()
1195 sp->libjpeg_jpeg_decompress_struct.raw_data_out=1; in OJPEGWriteHeaderInfo()
1197 sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; in OJPEGWriteHeaderInfo()
1199 sp->libjpeg_jpeg_query_style=0; in OJPEGWriteHeaderInfo()
1200 if (sp->subsampling_convert_log==0) in OJPEGWriteHeaderInfo()
1202 assert(sp->subsampling_convert_ycbcrbuf==0); in OJPEGWriteHeaderInfo()
1203 assert(sp->subsampling_convert_ycbcrimage==0); in OJPEGWriteHeaderInfo()
1204sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*… in OJPEGWriteHeaderInfo()
1205 sp->subsampling_convert_ylines=sp->subsampling_ver*8; in OJPEGWriteHeaderInfo()
1206 sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor; in OJPEGWriteHeaderInfo()
1207 sp->subsampling_convert_clines=8; in OJPEGWriteHeaderInfo()
1208 sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines; in OJPEGWriteHeaderInfo()
1209 sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines; in OJPEGWriteHeaderInfo()
1210sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuf… in OJPEGWriteHeaderInfo()
1211 sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen); in OJPEGWriteHeaderInfo()
1212 if (sp->subsampling_convert_ycbcrbuf==0) in OJPEGWriteHeaderInfo()
1217 sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf; in OJPEGWriteHeaderInfo()
1218 sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; in OJPEGWriteHeaderInfo()
1219 sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; in OJPEGWriteHeaderInfo()
1220sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_c… in OJPEGWriteHeaderInfo()
1221sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*… in OJPEGWriteHeaderInfo()
1222 if (sp->subsampling_convert_ycbcrimage==0) in OJPEGWriteHeaderInfo()
1227 m=sp->subsampling_convert_ycbcrimage; in OJPEGWriteHeaderInfo()
1228 *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); in OJPEGWriteHeaderInfo()
1229 *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); in OJPEGWriteHeaderInfo()
1230 …*m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_… in OJPEGWriteHeaderInfo()
1231 for (n=0; n<sp->subsampling_convert_ylines; n++) in OJPEGWriteHeaderInfo()
1232 *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; in OJPEGWriteHeaderInfo()
1233 for (n=0; n<sp->subsampling_convert_clines; n++) in OJPEGWriteHeaderInfo()
1234 *m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen; in OJPEGWriteHeaderInfo()
1235 for (n=0; n<sp->subsampling_convert_clines; n++) in OJPEGWriteHeaderInfo()
1236 *m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen; in OJPEGWriteHeaderInfo()
1237sp->subsampling_convert_clinelenout=((sp->strile_width+sp->subsampling_hor-1)/sp->subsampling_hor); in OJPEGWriteHeaderInfo()
1238 sp->subsampling_convert_state=0; in OJPEGWriteHeaderInfo()
1239sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2); in OJPEGWriteHeaderInfo()
1240 sp->lines_per_strile=((sp->strile_length+sp->subsampling_ver-1)/sp->subsampling_ver); in OJPEGWriteHeaderInfo()
1241 sp->subsampling_convert_log=1; in OJPEGWriteHeaderInfo()
1246 sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN; in OJPEGWriteHeaderInfo()
1247 sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN; in OJPEGWriteHeaderInfo()
1248 sp->libjpeg_jpeg_query_style=1; in OJPEGWriteHeaderInfo()
1249 sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width; in OJPEGWriteHeaderInfo()
1250 sp->lines_per_strile=sp->strile_length; in OJPEGWriteHeaderInfo()
1252 if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) in OJPEGWriteHeaderInfo()
1254 sp->writeheader_done=1; in OJPEGWriteHeaderInfo()
1261 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGLibjpegSessionAbort() local
1262 assert(sp->libjpeg_session_active!=0); in OJPEGLibjpegSessionAbort()
1263 jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct))); in OJPEGLibjpegSessionAbort()
1264 sp->libjpeg_session_active=0; in OJPEGLibjpegSessionAbort()
1271 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSec() local
1275 if (sp->file_size==0) in OJPEGReadHeaderInfoSec()
1276 sp->file_size=TIFFGetFileSize(tif); in OJPEGReadHeaderInfoSec()
1277 if (sp->jpeg_interchange_format!=0) in OJPEGReadHeaderInfoSec()
1279 if (sp->jpeg_interchange_format>=sp->file_size) in OJPEGReadHeaderInfoSec()
1281 sp->jpeg_interchange_format=0; in OJPEGReadHeaderInfoSec()
1282 sp->jpeg_interchange_format_length=0; in OJPEGReadHeaderInfoSec()
1286 …if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_f… in OJPEGReadHeaderInfoSec()
1287 sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; in OJPEGReadHeaderInfoSec()
1290 sp->in_buffer_source=osibsNotSetYet; in OJPEGReadHeaderInfoSec()
1291 sp->in_buffer_next_strile=0; in OJPEGReadHeaderInfoSec()
1292 sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; in OJPEGReadHeaderInfoSec()
1293 sp->in_buffer_file_togo=0; in OJPEGReadHeaderInfoSec()
1294 sp->in_buffer_togo=0; in OJPEGReadHeaderInfoSec()
1297 if (OJPEGReadBytePeek(sp,&m)==0) in OJPEGReadHeaderInfoSec()
1301 OJPEGReadByteAdvance(sp); in OJPEGReadHeaderInfoSec()
1304 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadHeaderInfoSec()
1330 if (OJPEGReadWord(sp,&n)==0) in OJPEGReadHeaderInfoSec()
1334 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSec()
1339 OJPEGReadSkip(sp,n-2); in OJPEGReadHeaderInfoSec()
1358 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSec()
1362 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSec()
1364 assert(sp->plane_sample_offset==0); in OJPEGReadHeaderInfoSec()
1373 if (sp->subsamplingcorrect) in OJPEGReadHeaderInfoSec()
1375 if (sp->sof_log==0) in OJPEGReadHeaderInfoSec()
1379 sp->sof_marker_id=JPEG_MARKER_SOF0; in OJPEGReadHeaderInfoSec()
1380 for (o=0; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1381 sp->sof_c[o]=o; in OJPEGReadHeaderInfoSec()
1382 sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); in OJPEGReadHeaderInfoSec()
1383 for (o=1; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1384 sp->sof_hv[o]=17; in OJPEGReadHeaderInfoSec()
1385 sp->sof_x=sp->strile_width; in OJPEGReadHeaderInfoSec()
1386 sp->sof_y=sp->strile_length_total; in OJPEGReadHeaderInfoSec()
1387 sp->sof_log=1; in OJPEGReadHeaderInfoSec()
1392 for (o=1; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1393 sp->sos_cs[o]=o; in OJPEGReadHeaderInfoSec()
1404 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDri() local
1406 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDri()
1413 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDri()
1415 sp->restart_interval=m; in OJPEGReadHeaderInfoSecStreamDri()
1424 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDqt() local
1429 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDqt()
1433 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamDqt()
1437 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamDqt()
1438 OJPEGReadSkip(sp,m-2); in OJPEGReadHeaderInfoSecStreamDqt()
1461 if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { in OJPEGReadHeaderInfoSecStreamDqt()
1472 if (sp->qtable[o]!=0) in OJPEGReadHeaderInfoSecStreamDqt()
1473 _TIFFfree(sp->qtable[o]); in OJPEGReadHeaderInfoSecStreamDqt()
1474 sp->qtable[o]=nb; in OJPEGReadHeaderInfoSecStreamDqt()
1487 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDht() local
1492 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDht()
1496 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamDht()
1500 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamDht()
1502 OJPEGReadSkip(sp,m-2); in OJPEGReadHeaderInfoSecStreamDht()
1518 if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) { in OJPEGReadHeaderInfoSecStreamDht()
1531 if (sp->dctable[o]!=0) in OJPEGReadHeaderInfoSecStreamDht()
1532 _TIFFfree(sp->dctable[o]); in OJPEGReadHeaderInfoSecStreamDht()
1533 sp->dctable[o]=nb; in OJPEGReadHeaderInfoSecStreamDht()
1550 if (sp->actable[o]!=0) in OJPEGReadHeaderInfoSecStreamDht()
1551 _TIFFfree(sp->actable[o]); in OJPEGReadHeaderInfoSecStreamDht()
1552 sp->actable[o]=nb; in OJPEGReadHeaderInfoSecStreamDht()
1563 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamSof() local
1569 if (sp->sof_log!=0) in OJPEGReadHeaderInfoSecStreamSof()
1574 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1575 sp->sof_marker_id=marker_id; in OJPEGReadHeaderInfoSecStreamSof()
1577 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamSof()
1581 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1588 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1593 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1595 if (n!=sp->samples_per_pixel) in OJPEGReadHeaderInfoSecStreamSof()
1602 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1606 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1611 if (sp->subsamplingcorrect) in OJPEGReadHeaderInfoSecStreamSof()
1612 OJPEGReadSkip(sp,4); in OJPEGReadHeaderInfoSecStreamSof()
1616 if (OJPEGReadWord(sp,&p)==0) in OJPEGReadHeaderInfoSecStreamSof()
1618 if (((uint32)p<sp->image_length) && ((uint32)p<sp->strile_length_total)) in OJPEGReadHeaderInfoSecStreamSof()
1623 sp->sof_y=p; in OJPEGReadHeaderInfoSecStreamSof()
1625 if (OJPEGReadWord(sp,&p)==0) in OJPEGReadHeaderInfoSecStreamSof()
1627 if (((uint32)p<sp->image_width) && ((uint32)p<sp->strile_width)) in OJPEGReadHeaderInfoSecStreamSof()
1632 if ((uint32)p>sp->strile_width) in OJPEGReadHeaderInfoSecStreamSof()
1637 sp->sof_x=p; in OJPEGReadHeaderInfoSecStreamSof()
1640 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1644 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1653 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1655 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1656 sp->sof_c[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1658 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1660 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamSof()
1664 sp->subsampling_hor=(o>>4); in OJPEGReadHeaderInfoSecStreamSof()
1665 sp->subsampling_ver=(o&15); in OJPEGReadHeaderInfoSecStreamSof()
1666 if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || in OJPEGReadHeaderInfoSecStreamSof()
1667 ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) in OJPEGReadHeaderInfoSecStreamSof()
1668 sp->subsampling_force_desubsampling_inside_decompression=1; in OJPEGReadHeaderInfoSecStreamSof()
1673 sp->subsampling_force_desubsampling_inside_decompression=1; in OJPEGReadHeaderInfoSecStreamSof()
1678 sp->sof_hv[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1679 if (sp->subsampling_force_desubsampling_inside_decompression==0) in OJPEGReadHeaderInfoSecStreamSof()
1683 if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver)) in OJPEGReadHeaderInfoSecStreamSof()
1700 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1702 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1703 sp->sof_tq[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1705 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1706 sp->sof_log=1; in OJPEGReadHeaderInfoSecStreamSof()
1715 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamSos() local
1719 assert(sp->subsamplingcorrect==0); in OJPEGReadHeaderInfoSecStreamSos()
1720 if (sp->sof_log==0) in OJPEGReadHeaderInfoSecStreamSos()
1726 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamSos()
1728 if (m!=6+sp->samples_per_pixel_per_plane*2) in OJPEGReadHeaderInfoSecStreamSos()
1734 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1736 if (n!=sp->samples_per_pixel_per_plane) in OJPEGReadHeaderInfoSecStreamSos()
1742 for (o=0; o<sp->samples_per_pixel_per_plane; o++) in OJPEGReadHeaderInfoSecStreamSos()
1745 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1747 sp->sos_cs[sp->plane_sample_offset+o]=n; in OJPEGReadHeaderInfoSecStreamSos()
1749 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1751 sp->sos_tda[sp->plane_sample_offset+o]=n; in OJPEGReadHeaderInfoSecStreamSos()
1754 OJPEGReadSkip(sp,3); in OJPEGReadHeaderInfoSecStreamSos()
1762 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesQTable() local
1768 if (sp->qtable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesQTable()
1773 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesQTable()
1774 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesQTable()
1776 if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesQTable()
1780 if (sp->qtable_offset[m]==sp->qtable_offset[n]) in OJPEGReadHeaderInfoSecTablesQTable()
1799 TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesQTable()
1806 if (sp->qtable[m]!=0) in OJPEGReadHeaderInfoSecTablesQTable()
1807 _TIFFfree(sp->qtable[m]); in OJPEGReadHeaderInfoSecTablesQTable()
1808 sp->qtable[m]=ob; in OJPEGReadHeaderInfoSecTablesQTable()
1809 sp->sof_tq[m]=m; in OJPEGReadHeaderInfoSecTablesQTable()
1812 sp->sof_tq[m]=sp->sof_tq[m-1]; in OJPEGReadHeaderInfoSecTablesQTable()
1821 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesDcTable() local
1829 if (sp->dctable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesDcTable()
1834 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesDcTable()
1835 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesDcTable()
1837 if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesDcTable()
1841 if (sp->dctable_offset[m]==sp->dctable_offset[n]) in OJPEGReadHeaderInfoSecTablesDcTable()
1847 TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesDcTable()
1875 if (sp->dctable[m]!=0) in OJPEGReadHeaderInfoSecTablesDcTable()
1876 _TIFFfree(sp->dctable[m]); in OJPEGReadHeaderInfoSecTablesDcTable()
1877 sp->dctable[m]=rb; in OJPEGReadHeaderInfoSecTablesDcTable()
1878 sp->sos_tda[m]=(m<<4); in OJPEGReadHeaderInfoSecTablesDcTable()
1881 sp->sos_tda[m]=sp->sos_tda[m-1]; in OJPEGReadHeaderInfoSecTablesDcTable()
1890 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesAcTable() local
1898 if (sp->actable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesAcTable()
1903 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesAcTable()
1904 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesAcTable()
1906 if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesAcTable()
1910 if (sp->actable_offset[m]==sp->actable_offset[n]) in OJPEGReadHeaderInfoSecTablesAcTable()
1916 TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesAcTable()
1944 if (sp->actable[m]!=0) in OJPEGReadHeaderInfoSecTablesAcTable()
1945 _TIFFfree(sp->actable[m]); in OJPEGReadHeaderInfoSecTablesAcTable()
1946 sp->actable[m]=rb; in OJPEGReadHeaderInfoSecTablesAcTable()
1947 sp->sos_tda[m]=(sp->sos_tda[m]|m); in OJPEGReadHeaderInfoSecTablesAcTable()
1950 sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15)); in OJPEGReadHeaderInfoSecTablesAcTable()
1956 OJPEGReadBufferFill(OJPEGState* sp) in OJPEGReadBufferFill() argument
1964 if (sp->in_buffer_file_togo!=0) in OJPEGReadBufferFill()
1966 if (sp->in_buffer_file_pos_log==0) in OJPEGReadBufferFill()
1968 TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET); in OJPEGReadBufferFill()
1969 sp->in_buffer_file_pos_log=1; in OJPEGReadBufferFill()
1972 if ((uint64)m>sp->in_buffer_file_togo) in OJPEGReadBufferFill()
1973 m=(uint16)sp->in_buffer_file_togo; in OJPEGReadBufferFill()
1974 n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m); in OJPEGReadBufferFill()
1980 assert((uint64)n<=sp->in_buffer_file_togo); in OJPEGReadBufferFill()
1982 sp->in_buffer_togo=m; in OJPEGReadBufferFill()
1983 sp->in_buffer_cur=sp->in_buffer; in OJPEGReadBufferFill()
1984 sp->in_buffer_file_togo-=m; in OJPEGReadBufferFill()
1985 sp->in_buffer_file_pos+=m; in OJPEGReadBufferFill()
1988 sp->in_buffer_file_pos_log=0; in OJPEGReadBufferFill()
1989 switch(sp->in_buffer_source) in OJPEGReadBufferFill()
1992 if (sp->jpeg_interchange_format!=0) in OJPEGReadBufferFill()
1994 sp->in_buffer_file_pos=sp->jpeg_interchange_format; in OJPEGReadBufferFill()
1995 sp->in_buffer_file_togo=sp->jpeg_interchange_format_length; in OJPEGReadBufferFill()
1997 sp->in_buffer_source=osibsJpegInterchangeFormat; in OJPEGReadBufferFill()
2000 sp->in_buffer_source=osibsStrile; in OJPEGReadBufferFill()
2003 if (!_TIFFFillStriles( sp->tif ) in OJPEGReadBufferFill()
2004 || sp->tif->tif_dir.td_stripoffset == NULL in OJPEGReadBufferFill()
2005 || sp->tif->tif_dir.td_stripbytecount == NULL) in OJPEGReadBufferFill()
2008 if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) in OJPEGReadBufferFill()
2009 sp->in_buffer_source=osibsEof; in OJPEGReadBufferFill()
2012 sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; in OJPEGReadBufferFill()
2013 if (sp->in_buffer_file_pos!=0) in OJPEGReadBufferFill()
2015 if (sp->in_buffer_file_pos>=sp->file_size) in OJPEGReadBufferFill()
2016 sp->in_buffer_file_pos=0; in OJPEGReadBufferFill()
2017 else if (sp->tif->tif_dir.td_stripbytecount==NULL) in OJPEGReadBufferFill()
2018 sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; in OJPEGReadBufferFill()
2021 if (sp->tif->tif_dir.td_stripbytecount == 0) { in OJPEGReadBufferFill()
2022 TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing"); in OJPEGReadBufferFill()
2025 sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; in OJPEGReadBufferFill()
2026 if (sp->in_buffer_file_togo==0) in OJPEGReadBufferFill()
2027 sp->in_buffer_file_pos=0; in OJPEGReadBufferFill()
2028 else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) in OJPEGReadBufferFill()
2029 sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; in OJPEGReadBufferFill()
2032 sp->in_buffer_next_strile++; in OJPEGReadBufferFill()
2043 OJPEGReadByte(OJPEGState* sp, uint8* byte) in OJPEGReadByte() argument
2045 if (sp->in_buffer_togo==0) in OJPEGReadByte()
2047 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadByte()
2049 assert(sp->in_buffer_togo>0); in OJPEGReadByte()
2051 *byte=*(sp->in_buffer_cur); in OJPEGReadByte()
2052 sp->in_buffer_cur++; in OJPEGReadByte()
2053 sp->in_buffer_togo--; in OJPEGReadByte()
2058 OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) in OJPEGReadBytePeek() argument
2060 if (sp->in_buffer_togo==0) in OJPEGReadBytePeek()
2062 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadBytePeek()
2064 assert(sp->in_buffer_togo>0); in OJPEGReadBytePeek()
2066 *byte=*(sp->in_buffer_cur); in OJPEGReadBytePeek()
2071 OJPEGReadByteAdvance(OJPEGState* sp) in OJPEGReadByteAdvance() argument
2073 assert(sp->in_buffer_togo>0); in OJPEGReadByteAdvance()
2074 sp->in_buffer_cur++; in OJPEGReadByteAdvance()
2075 sp->in_buffer_togo--; in OJPEGReadByteAdvance()
2079 OJPEGReadWord(OJPEGState* sp, uint16* word) in OJPEGReadWord() argument
2082 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadWord()
2085 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadWord()
2092 OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) in OJPEGReadBlock() argument
2102 if (sp->in_buffer_togo==0) in OJPEGReadBlock()
2104 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadBlock()
2106 assert(sp->in_buffer_togo>0); in OJPEGReadBlock()
2109 if (n>sp->in_buffer_togo) in OJPEGReadBlock()
2110 n=sp->in_buffer_togo; in OJPEGReadBlock()
2111 _TIFFmemcpy(mmem,sp->in_buffer_cur,n); in OJPEGReadBlock()
2112 sp->in_buffer_cur+=n; in OJPEGReadBlock()
2113 sp->in_buffer_togo-=n; in OJPEGReadBlock()
2121 OJPEGReadSkip(OJPEGState* sp, uint16 len) in OJPEGReadSkip() argument
2127 if (n>sp->in_buffer_togo) in OJPEGReadSkip()
2128 n=sp->in_buffer_togo; in OJPEGReadSkip()
2129 sp->in_buffer_cur+=n; in OJPEGReadSkip()
2130 sp->in_buffer_togo-=n; in OJPEGReadSkip()
2134 assert(sp->in_buffer_togo==0); in OJPEGReadSkip()
2136 if ((uint64)n>sp->in_buffer_file_togo) in OJPEGReadSkip()
2137 n=(uint16)sp->in_buffer_file_togo; in OJPEGReadSkip()
2138 sp->in_buffer_file_pos+=n; in OJPEGReadSkip()
2139 sp->in_buffer_file_togo-=n; in OJPEGReadSkip()
2140 sp->in_buffer_file_pos_log=0; in OJPEGReadSkip()
2153 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStream() local
2157 assert(sp->out_state<=ososEoi); in OJPEGWriteStream()
2158 switch(sp->out_state) in OJPEGWriteStream()
2226 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSoi() local
2228 sp->out_buffer[0]=255; in OJPEGWriteStreamSoi()
2229 sp->out_buffer[1]=JPEG_MARKER_SOI; in OJPEGWriteStreamSoi()
2231 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSoi()
2232 sp->out_state++; in OJPEGWriteStreamSoi()
2238 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamQTable() local
2239 if (sp->qtable[table_index]!=0) in OJPEGWriteStreamQTable()
2241 *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); in OJPEGWriteStreamQTable()
2242 *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); in OJPEGWriteStreamQTable()
2244 sp->out_state++; in OJPEGWriteStreamQTable()
2250 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamDcTable() local
2251 if (sp->dctable[table_index]!=0) in OJPEGWriteStreamDcTable()
2253 *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); in OJPEGWriteStreamDcTable()
2254 *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); in OJPEGWriteStreamDcTable()
2256 sp->out_state++; in OJPEGWriteStreamDcTable()
2262 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamAcTable() local
2263 if (sp->actable[table_index]!=0) in OJPEGWriteStreamAcTable()
2265 *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); in OJPEGWriteStreamAcTable()
2266 *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); in OJPEGWriteStreamAcTable()
2268 sp->out_state++; in OJPEGWriteStreamAcTable()
2274 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamDri() local
2276 if (sp->restart_interval!=0) in OJPEGWriteStreamDri()
2278 sp->out_buffer[0]=255; in OJPEGWriteStreamDri()
2279 sp->out_buffer[1]=JPEG_MARKER_DRI; in OJPEGWriteStreamDri()
2280 sp->out_buffer[2]=0; in OJPEGWriteStreamDri()
2281 sp->out_buffer[3]=4; in OJPEGWriteStreamDri()
2282 sp->out_buffer[4]=(sp->restart_interval>>8); in OJPEGWriteStreamDri()
2283 sp->out_buffer[5]=(sp->restart_interval&255); in OJPEGWriteStreamDri()
2285 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamDri()
2287 sp->out_state++; in OJPEGWriteStreamDri()
2293 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSof() local
2295 assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); in OJPEGWriteStreamSof()
2296 assert(255>=8+sp->samples_per_pixel_per_plane*3); in OJPEGWriteStreamSof()
2297 sp->out_buffer[0]=255; in OJPEGWriteStreamSof()
2298 sp->out_buffer[1]=sp->sof_marker_id; in OJPEGWriteStreamSof()
2300 sp->out_buffer[2]=0; in OJPEGWriteStreamSof()
2301 sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3; in OJPEGWriteStreamSof()
2303 sp->out_buffer[4]=8; in OJPEGWriteStreamSof()
2305 sp->out_buffer[5]=(uint8)(sp->sof_y>>8); in OJPEGWriteStreamSof()
2306 sp->out_buffer[6]=(sp->sof_y&255); in OJPEGWriteStreamSof()
2308 sp->out_buffer[7]=(uint8)(sp->sof_x>>8); in OJPEGWriteStreamSof()
2309 sp->out_buffer[8]=(sp->sof_x&255); in OJPEGWriteStreamSof()
2311 sp->out_buffer[9]=sp->samples_per_pixel_per_plane; in OJPEGWriteStreamSof()
2312 for (m=0; m<sp->samples_per_pixel_per_plane; m++) in OJPEGWriteStreamSof()
2315 sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2317 sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2319 sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2321 *len=10+sp->samples_per_pixel_per_plane*3; in OJPEGWriteStreamSof()
2322 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSof()
2323 sp->out_state++; in OJPEGWriteStreamSof()
2329 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSos() local
2331 assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); in OJPEGWriteStreamSos()
2332 assert(255>=6+sp->samples_per_pixel_per_plane*2); in OJPEGWriteStreamSos()
2333 sp->out_buffer[0]=255; in OJPEGWriteStreamSos()
2334 sp->out_buffer[1]=JPEG_MARKER_SOS; in OJPEGWriteStreamSos()
2336 sp->out_buffer[2]=0; in OJPEGWriteStreamSos()
2337 sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2; in OJPEGWriteStreamSos()
2339 sp->out_buffer[4]=sp->samples_per_pixel_per_plane; in OJPEGWriteStreamSos()
2340 for (m=0; m<sp->samples_per_pixel_per_plane; m++) in OJPEGWriteStreamSos()
2343 sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m]; in OJPEGWriteStreamSos()
2345 sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m]; in OJPEGWriteStreamSos()
2348 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0; in OJPEGWriteStreamSos()
2350 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63; in OJPEGWriteStreamSos()
2352 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0; in OJPEGWriteStreamSos()
2353 *len=8+sp->samples_per_pixel_per_plane*2; in OJPEGWriteStreamSos()
2354 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSos()
2355 sp->out_state++; in OJPEGWriteStreamSos()
2361 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamCompressed() local
2362 if (sp->in_buffer_togo==0) in OJPEGWriteStreamCompressed()
2364 if (OJPEGReadBufferFill(sp)==0) in OJPEGWriteStreamCompressed()
2366 assert(sp->in_buffer_togo>0); in OJPEGWriteStreamCompressed()
2368 *len=sp->in_buffer_togo; in OJPEGWriteStreamCompressed()
2369 *mem=(void*)sp->in_buffer_cur; in OJPEGWriteStreamCompressed()
2370 sp->in_buffer_togo=0; in OJPEGWriteStreamCompressed()
2371 if (sp->in_buffer_file_togo==0) in OJPEGWriteStreamCompressed()
2373 switch(sp->in_buffer_source) in OJPEGWriteStreamCompressed()
2376 if (sp->in_buffer_next_strile<sp->in_buffer_strile_count) in OJPEGWriteStreamCompressed()
2377 sp->out_state=ososRst; in OJPEGWriteStreamCompressed()
2379 sp->out_state=ososEoi; in OJPEGWriteStreamCompressed()
2382 sp->out_state=ososEoi; in OJPEGWriteStreamCompressed()
2394 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamRst() local
2396 sp->out_buffer[0]=255; in OJPEGWriteStreamRst()
2397 sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index; in OJPEGWriteStreamRst()
2398 sp->restart_index++; in OJPEGWriteStreamRst()
2399 if (sp->restart_index==8) in OJPEGWriteStreamRst()
2400 sp->restart_index=0; in OJPEGWriteStreamRst()
2402 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamRst()
2403 sp->out_state=ososCompressed; in OJPEGWriteStreamRst()
2409 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamEoi() local
2411 sp->out_buffer[0]=255; in OJPEGWriteStreamEoi()
2412 sp->out_buffer[1]=JPEG_MARKER_EOI; in OJPEGWriteStreamEoi()
2414 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamEoi()
2419 jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) in jpeg_create_decompress_encap() argument
2421 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_create_decompress_encap()
2432 jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) in jpeg_read_header_encap() argument
2434 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_read_header_encap()
2445 jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) in jpeg_start_decompress_encap() argument
2447 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_start_decompress_encap()
2458 jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 ma… in jpeg_read_scanlines_encap() argument
2460 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_read_scanlines_encap()
2471 jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_line… in jpeg_read_raw_data_encap() argument
2473 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_read_raw_data_encap()
2486 OJPEGState* sp=(OJPEGState*)tif->tif_data; in jpeg_encap_unwind() local
2487 LONGJMP(sp->exit_jmpbuf,1); in jpeg_encap_unwind()
2518 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGLibjpegJpegSourceMgrFillInputBuffer() local
2526 sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len; in OJPEGLibjpegJpegSourceMgrFillInputBuffer()
2527 sp->libjpeg_jpeg_source_mgr.next_input_byte=mem; in OJPEGLibjpegJpegSourceMgrFillInputBuffer()