Lines Matching refs:sp
383 static int OJPEGReadBufferFill(OJPEGState* sp);
384 static int OJPEGReadByte(OJPEGState* sp, uint8* byte);
385 static int OJPEGReadBytePeek(OJPEGState* sp, uint8* byte);
386 static void OJPEGReadByteAdvance(OJPEGState* sp);
387 static int OJPEGReadWord(OJPEGState* sp, uint16* word);
388 static int OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem);
389 static void OJPEGReadSkip(OJPEGState* sp, uint16 len);
404 extern int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
405 extern int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_imag…
406 extern int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
407 extern int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines…
408 extern int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint…
411 static int jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* j);
412 static int jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_imag…
413 static int jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo);
414 static int jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines…
415 static int jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint…
431 OJPEGState* sp; in TIFFInitOJPEG() local
445 sp=_TIFFmalloc(sizeof(OJPEGState)); in TIFFInitOJPEG()
446 if (sp==NULL) in TIFFInitOJPEG()
451 _TIFFmemset(sp,0,sizeof(OJPEGState)); in TIFFInitOJPEG()
452 sp->tif=tif; in TIFFInitOJPEG()
453 sp->jpeg_proc=1; in TIFFInitOJPEG()
454 sp->subsampling_hor=2; in TIFFInitOJPEG()
455 sp->subsampling_ver=2; in TIFFInitOJPEG()
472 tif->tif_data=(uint8*)sp; in TIFFInitOJPEG()
474 sp->vgetparent=tif->tif_tagmethods.vgetfield; in TIFFInitOJPEG()
476 sp->vsetparent=tif->tif_tagmethods.vsetfield; in TIFFInitOJPEG()
478 sp->printdir=tif->tif_tagmethods.printdir; in TIFFInitOJPEG()
493 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGVGetField() local
497 *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format; in OJPEGVGetField()
500 *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format_length; in OJPEGVGetField()
503 if (sp->subsamplingcorrect_done==0) in OJPEGVGetField()
505 *va_arg(ap,uint16*)=(uint16)sp->subsampling_hor; in OJPEGVGetField()
506 *va_arg(ap,uint16*)=(uint16)sp->subsampling_ver; in OJPEGVGetField()
509 *va_arg(ap,uint32*)=(uint32)sp->qtable_offset_count; in OJPEGVGetField()
510 *va_arg(ap,void**)=(void*)sp->qtable_offset; in OJPEGVGetField()
513 *va_arg(ap,uint32*)=(uint32)sp->dctable_offset_count; in OJPEGVGetField()
514 *va_arg(ap,void**)=(void*)sp->dctable_offset; in OJPEGVGetField()
517 *va_arg(ap,uint32*)=(uint32)sp->actable_offset_count; in OJPEGVGetField()
518 *va_arg(ap,void**)=(void*)sp->actable_offset; in OJPEGVGetField()
521 *va_arg(ap,uint16*)=(uint16)sp->jpeg_proc; in OJPEGVGetField()
524 *va_arg(ap,uint16*)=sp->restart_interval; in OJPEGVGetField()
527 return (*sp->vgetparent)(tif,tag,ap); in OJPEGVGetField()
536 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGVSetField() local
545 sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64); in OJPEGVSetField()
548 sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64); in OJPEGVSetField()
551 sp->subsampling_tag=1; in OJPEGVSetField()
552 sp->subsampling_hor=(uint8)va_arg(ap,uint16_vap); in OJPEGVSetField()
553 sp->subsampling_ver=(uint8)va_arg(ap,uint16_vap); in OJPEGVSetField()
554 tif->tif_dir.td_ycbcrsubsampling[0]=sp->subsampling_hor; in OJPEGVSetField()
555 tif->tif_dir.td_ycbcrsubsampling[1]=sp->subsampling_ver; in OJPEGVSetField()
566 sp->qtable_offset_count=(uint8)ma; in OJPEGVSetField()
569 sp->qtable_offset[n]=mb[n]; in OJPEGVSetField()
581 sp->dctable_offset_count=(uint8)ma; in OJPEGVSetField()
584 sp->dctable_offset[n]=mb[n]; in OJPEGVSetField()
596 sp->actable_offset_count=(uint8)ma; in OJPEGVSetField()
599 sp->actable_offset[n]=mb[n]; in OJPEGVSetField()
603 sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap); in OJPEGVSetField()
606 sp->restart_interval=(uint16)va_arg(ap,uint16_vap); in OJPEGVSetField()
609 return (*sp->vsetparent)(tif,tag,ap); in OJPEGVSetField()
622 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPrintDir() local
625 assert(sp!=NULL); in OJPEGPrintDir()
627 …fprintf(fd," JpegInterchangeFormat: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange… in OJPEGPrintDir()
629 …fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_inter… in OJPEGPrintDir()
633 for (m=0; m<sp->qtable_offset_count; m++) in OJPEGPrintDir()
634 fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]); in OJPEGPrintDir()
640 for (m=0; m<sp->dctable_offset_count; m++) in OJPEGPrintDir()
641 fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]); in OJPEGPrintDir()
647 for (m=0; m<sp->actable_offset_count; m++) in OJPEGPrintDir()
648 fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->actable_offset[m]); in OJPEGPrintDir()
652 fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc); in OJPEGPrintDir()
654 fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); in OJPEGPrintDir()
655 if (sp->printdir) in OJPEGPrintDir()
656 (*sp->printdir)(tif, fd, flags); in OJPEGPrintDir()
677 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecode() local
679 if (sp->subsamplingcorrect_done==0) in OJPEGPreDecode()
681 if (sp->readheader_done==0) in OJPEGPreDecode()
686 if (sp->sos_end[s].log==0) in OJPEGPreDecode()
695 if ((sp->writeheader_done!=0) && ((sp->write_cursample!=s) || (sp->write_curstrile>m))) in OJPEGPreDecode()
697 if (sp->libjpeg_session_active!=0) in OJPEGPreDecode()
699 sp->writeheader_done=0; in OJPEGPreDecode()
701 if (sp->writeheader_done==0) in OJPEGPreDecode()
703 sp->plane_sample_offset=(uint8)s; in OJPEGPreDecode()
704 sp->write_cursample=s; in OJPEGPreDecode()
705 sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; in OJPEGPreDecode()
706 if ((sp->in_buffer_file_pos_log==0) || in OJPEGPreDecode()
707 (sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos)) in OJPEGPreDecode()
709 sp->in_buffer_source=sp->sos_end[s].in_buffer_source; in OJPEGPreDecode()
710 sp->in_buffer_next_strile=sp->sos_end[s].in_buffer_next_strile; in OJPEGPreDecode()
711 sp->in_buffer_file_pos=sp->sos_end[s].in_buffer_file_pos; in OJPEGPreDecode()
712 sp->in_buffer_file_pos_log=0; in OJPEGPreDecode()
713 sp->in_buffer_file_togo=sp->sos_end[s].in_buffer_file_togo; in OJPEGPreDecode()
714 sp->in_buffer_togo=0; in OJPEGPreDecode()
715 sp->in_buffer_cur=0; in OJPEGPreDecode()
720 while (sp->write_curstrile<m) in OJPEGPreDecode()
722 if (sp->libjpeg_jpeg_query_style==0) in OJPEGPreDecode()
732 sp->write_curstrile++; in OJPEGPreDecode()
740 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecodeSkipRaw() local
742 m=sp->lines_per_strile; in OJPEGPreDecodeSkipRaw()
743 if (sp->subsampling_convert_state!=0) in OJPEGPreDecodeSkipRaw()
745 if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m) in OJPEGPreDecodeSkipRaw()
747 sp->subsampling_convert_state+=m; in OJPEGPreDecodeSkipRaw()
748 if (sp->subsampling_convert_state==sp->subsampling_convert_clines) in OJPEGPreDecodeSkipRaw()
749 sp->subsampling_convert_state=0; in OJPEGPreDecodeSkipRaw()
752 m-=sp->subsampling_convert_clines-sp->subsampling_convert_state; in OJPEGPreDecodeSkipRaw()
753 sp->subsampling_convert_state=0; in OJPEGPreDecodeSkipRaw()
755 while (m>=sp->subsampling_convert_clines) in OJPEGPreDecodeSkipRaw()
757 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGPreDecodeSkipRaw()
759 m-=sp->subsampling_convert_clines; in OJPEGPreDecodeSkipRaw()
763 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGPreDecodeSkipRaw()
765 sp->subsampling_convert_state=m; in OJPEGPreDecodeSkipRaw()
774 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecodeSkipScanlines() local
776 if (sp->skip_buffer==NULL) in OJPEGPreDecodeSkipScanlines()
778 sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); in OJPEGPreDecodeSkipScanlines()
779 if (sp->skip_buffer==NULL) in OJPEGPreDecodeSkipScanlines()
785 for (m=0; m<sp->lines_per_strile; m++) in OJPEGPreDecodeSkipScanlines()
787 if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&sp->skip_buffer,1)==0) in OJPEGPreDecodeSkipScanlines()
796 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecode() local
798 if (sp->libjpeg_jpeg_query_style==0) in OJPEGDecode()
815 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecodeRaw() local
825 if (cc%sp->bytes_per_line!=0) in OJPEGDecodeRaw()
835 if (sp->subsampling_convert_state==0) in OJPEGDecodeRaw()
837 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGDecodeRaw()
840 …oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_… in OJPEGDecodeRaw()
841 ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; in OJPEGDecodeRaw()
842 ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; in OJPEGDecodeRaw()
844 for (q=0; q<sp->subsampling_convert_clinelenout; q++) in OJPEGDecodeRaw()
847 for (sy=0; sy<sp->subsampling_ver; sy++) in OJPEGDecodeRaw()
849 for (sx=0; sx<sp->subsampling_hor; sx++) in OJPEGDecodeRaw()
851 r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor; in OJPEGDecodeRaw()
853 oy+=sp->subsampling_hor; in OJPEGDecodeRaw()
857 sp->subsampling_convert_state++; in OJPEGDecodeRaw()
858 if (sp->subsampling_convert_state==sp->subsampling_convert_clines) in OJPEGDecodeRaw()
859 sp->subsampling_convert_state=0; in OJPEGDecodeRaw()
860 m+=sp->bytes_per_line; in OJPEGDecodeRaw()
861 n-=sp->bytes_per_line; in OJPEGDecodeRaw()
870 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecodeScanlines() local
873 if (cc%sp->bytes_per_line!=0) in OJPEGDecodeScanlines()
883 if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0) in OJPEGDecodeScanlines()
885 m+=sp->bytes_per_line; in OJPEGDecodeScanlines()
886 n-=sp->bytes_per_line; in OJPEGDecodeScanlines()
894 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPostDecode() local
897 sp->write_curstrile++; in OJPEGPostDecode()
898 if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) in OJPEGPostDecode()
900 assert(sp->libjpeg_session_active!=0); in OJPEGPostDecode()
902 sp->writeheader_done=0; in OJPEGPostDecode()
945 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGCleanup() local
946 if (sp!=0) in OJPEGCleanup()
948 tif->tif_tagmethods.vgetfield=sp->vgetparent; in OJPEGCleanup()
949 tif->tif_tagmethods.vsetfield=sp->vsetparent; in OJPEGCleanup()
950 tif->tif_tagmethods.printdir=sp->printdir; in OJPEGCleanup()
951 if (sp->qtable[0]!=0) in OJPEGCleanup()
952 _TIFFfree(sp->qtable[0]); in OJPEGCleanup()
953 if (sp->qtable[1]!=0) in OJPEGCleanup()
954 _TIFFfree(sp->qtable[1]); in OJPEGCleanup()
955 if (sp->qtable[2]!=0) in OJPEGCleanup()
956 _TIFFfree(sp->qtable[2]); in OJPEGCleanup()
957 if (sp->qtable[3]!=0) in OJPEGCleanup()
958 _TIFFfree(sp->qtable[3]); in OJPEGCleanup()
959 if (sp->dctable[0]!=0) in OJPEGCleanup()
960 _TIFFfree(sp->dctable[0]); in OJPEGCleanup()
961 if (sp->dctable[1]!=0) in OJPEGCleanup()
962 _TIFFfree(sp->dctable[1]); in OJPEGCleanup()
963 if (sp->dctable[2]!=0) in OJPEGCleanup()
964 _TIFFfree(sp->dctable[2]); in OJPEGCleanup()
965 if (sp->dctable[3]!=0) in OJPEGCleanup()
966 _TIFFfree(sp->dctable[3]); in OJPEGCleanup()
967 if (sp->actable[0]!=0) in OJPEGCleanup()
968 _TIFFfree(sp->actable[0]); in OJPEGCleanup()
969 if (sp->actable[1]!=0) in OJPEGCleanup()
970 _TIFFfree(sp->actable[1]); in OJPEGCleanup()
971 if (sp->actable[2]!=0) in OJPEGCleanup()
972 _TIFFfree(sp->actable[2]); in OJPEGCleanup()
973 if (sp->actable[3]!=0) in OJPEGCleanup()
974 _TIFFfree(sp->actable[3]); in OJPEGCleanup()
975 if (sp->libjpeg_session_active!=0) in OJPEGCleanup()
977 if (sp->subsampling_convert_ycbcrbuf!=0) in OJPEGCleanup()
978 _TIFFfree(sp->subsampling_convert_ycbcrbuf); in OJPEGCleanup()
979 if (sp->subsampling_convert_ycbcrimage!=0) in OJPEGCleanup()
980 _TIFFfree(sp->subsampling_convert_ycbcrimage); in OJPEGCleanup()
981 if (sp->skip_buffer!=0) in OJPEGCleanup()
982 _TIFFfree(sp->skip_buffer); in OJPEGCleanup()
983 _TIFFfree(sp); in OJPEGCleanup()
993 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGSubsamplingCorrect() local
998 assert(sp->subsamplingcorrect_done==0); in OJPEGSubsamplingCorrect()
1002 if (sp->subsampling_tag!=0) in OJPEGSubsamplingCorrect()
1004 sp->subsampling_hor=1; in OJPEGSubsamplingCorrect()
1005 sp->subsampling_ver=1; in OJPEGSubsamplingCorrect()
1006 sp->subsampling_force_desubsampling_inside_decompression=0; in OJPEGSubsamplingCorrect()
1010 sp->subsamplingcorrect_done=1; in OJPEGSubsamplingCorrect()
1011 mh=sp->subsampling_hor; in OJPEGSubsamplingCorrect()
1012 mv=sp->subsampling_ver; in OJPEGSubsamplingCorrect()
1013 sp->subsamplingcorrect=1; in OJPEGSubsamplingCorrect()
1015 if (sp->subsampling_force_desubsampling_inside_decompression!=0) in OJPEGSubsamplingCorrect()
1017 sp->subsampling_hor=1; in OJPEGSubsamplingCorrect()
1018 sp->subsampling_ver=1; in OJPEGSubsamplingCorrect()
1020 sp->subsamplingcorrect=0; in OJPEGSubsamplingCorrect()
1021 …if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampli… in OJPEGSubsamplingCorrect()
1023 if (sp->subsampling_tag==0) in OJPEGSubsamplingCorrect()
1024 … values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1026 …alues [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1028 if (sp->subsampling_force_desubsampling_inside_decompression!=0) in OJPEGSubsamplingCorrect()
1030 if (sp->subsampling_tag==0) in OJPEGSubsamplingCorrect()
1035 if (sp->subsampling_force_desubsampling_inside_decompression==0) in OJPEGSubsamplingCorrect()
1037 if (sp->subsampling_hor<sp->subsampling_ver) in OJPEGSubsamplingCorrect()
1038 …data,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1041 sp->subsamplingcorrect_done=1; in OJPEGSubsamplingCorrect()
1048 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfo() local
1049 assert(sp->readheader_done==0); in OJPEGReadHeaderInfo()
1050 sp->image_width=tif->tif_dir.td_imagewidth; in OJPEGReadHeaderInfo()
1051 sp->image_length=tif->tif_dir.td_imagelength; in OJPEGReadHeaderInfo()
1054 sp->strile_width=tif->tif_dir.td_tilewidth; in OJPEGReadHeaderInfo()
1055 sp->strile_length=tif->tif_dir.td_tilelength; in OJPEGReadHeaderInfo()
1056 …sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_leng… in OJPEGReadHeaderInfo()
1060 sp->strile_width=sp->image_width; in OJPEGReadHeaderInfo()
1061 sp->strile_length=tif->tif_dir.td_rowsperstrip; in OJPEGReadHeaderInfo()
1062 sp->strile_length_total=sp->image_length; in OJPEGReadHeaderInfo()
1066 sp->samples_per_pixel=1; in OJPEGReadHeaderInfo()
1067 sp->plane_sample_offset=0; in OJPEGReadHeaderInfo()
1068 sp->samples_per_pixel_per_plane=sp->samples_per_pixel; in OJPEGReadHeaderInfo()
1069 sp->subsampling_hor=1; in OJPEGReadHeaderInfo()
1070 sp->subsampling_ver=1; in OJPEGReadHeaderInfo()
1076 …tdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); in OJPEGReadHeaderInfo()
1079 sp->samples_per_pixel=3; in OJPEGReadHeaderInfo()
1080 sp->plane_sample_offset=0; in OJPEGReadHeaderInfo()
1082 sp->samples_per_pixel_per_plane=3; in OJPEGReadHeaderInfo()
1084 sp->samples_per_pixel_per_plane=1; in OJPEGReadHeaderInfo()
1086 if (sp->strile_length<sp->image_length) in OJPEGReadHeaderInfo()
1088 if (sp->strile_length%(sp->subsampling_ver*8)!=0) in OJPEGReadHeaderInfo()
1093 …sp->restart_interval=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))*(sp->str… in OJPEGReadHeaderInfo()
1097 sp->sos_end[0].log=1; in OJPEGReadHeaderInfo()
1098 sp->sos_end[0].in_buffer_source=sp->in_buffer_source; in OJPEGReadHeaderInfo()
1099 sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile; in OJPEGReadHeaderInfo()
1100 sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; in OJPEGReadHeaderInfo()
1101 sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; in OJPEGReadHeaderInfo()
1102 sp->readheader_done=1; in OJPEGReadHeaderInfo()
1109 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadSecondarySos() local
1113 assert(sp->sos_end[0].log!=0); in OJPEGReadSecondarySos()
1114 assert(sp->sos_end[s].log==0); in OJPEGReadSecondarySos()
1115 sp->plane_sample_offset=s-1; in OJPEGReadSecondarySos()
1116 while(sp->sos_end[sp->plane_sample_offset].log==0) in OJPEGReadSecondarySos()
1117 sp->plane_sample_offset--; in OJPEGReadSecondarySos()
1118 sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; in OJPEGReadSecondarySos()
1119 sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; in OJPEGReadSecondarySos()
1120 sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; in OJPEGReadSecondarySos()
1121 sp->in_buffer_file_pos_log=0; in OJPEGReadSecondarySos()
1122 sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; in OJPEGReadSecondarySos()
1123 sp->in_buffer_togo=0; in OJPEGReadSecondarySos()
1124 sp->in_buffer_cur=0; in OJPEGReadSecondarySos()
1125 while(sp->plane_sample_offset<s) in OJPEGReadSecondarySos()
1129 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadSecondarySos()
1135 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadSecondarySos()
1144 sp->plane_sample_offset++; in OJPEGReadSecondarySos()
1147 sp->sos_end[sp->plane_sample_offset].log=1; in OJPEGReadSecondarySos()
1148 sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source; in OJPEGReadSecondarySos()
1149 sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile; in OJPEGReadSecondarySos()
1150 sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; in OJPEGReadSecondarySos()
1151 …sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_tog… in OJPEGReadSecondarySos()
1160 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteHeaderInfo() local
1164 if (sp->libjpeg_session_active != 0) in OJPEGWriteHeaderInfo()
1166 sp->out_state=ososSoi; in OJPEGWriteHeaderInfo()
1167 sp->restart_index=0; in OJPEGWriteHeaderInfo()
1168 jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); in OJPEGWriteHeaderInfo()
1169 sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage; in OJPEGWriteHeaderInfo()
1170 sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit; in OJPEGWriteHeaderInfo()
1171 sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr); in OJPEGWriteHeaderInfo()
1172 sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif; in OJPEGWriteHeaderInfo()
1173 if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) in OJPEGWriteHeaderInfo()
1175 sp->libjpeg_session_active=1; in OJPEGWriteHeaderInfo()
1176 sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0; in OJPEGWriteHeaderInfo()
1177 sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource; in OJPEGWriteHeaderInfo()
1178 sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer; in OJPEGWriteHeaderInfo()
1179 sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData; in OJPEGWriteHeaderInfo()
1180 sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart; in OJPEGWriteHeaderInfo()
1181 sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource; in OJPEGWriteHeaderInfo()
1182 sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr); in OJPEGWriteHeaderInfo()
1183 if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0) in OJPEGWriteHeaderInfo()
1185 …if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_pl… in OJPEGWriteHeaderInfo()
1187 sp->libjpeg_jpeg_decompress_struct.raw_data_out=1; in OJPEGWriteHeaderInfo()
1189 sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; in OJPEGWriteHeaderInfo()
1191 sp->libjpeg_jpeg_query_style=0; in OJPEGWriteHeaderInfo()
1192 if (sp->subsampling_convert_log==0) in OJPEGWriteHeaderInfo()
1194 assert(sp->subsampling_convert_ycbcrbuf==0); in OJPEGWriteHeaderInfo()
1195 assert(sp->subsampling_convert_ycbcrimage==0); in OJPEGWriteHeaderInfo()
1196 …sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*… in OJPEGWriteHeaderInfo()
1197 sp->subsampling_convert_ylines=sp->subsampling_ver*8; in OJPEGWriteHeaderInfo()
1198 sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor; in OJPEGWriteHeaderInfo()
1199 sp->subsampling_convert_clines=8; in OJPEGWriteHeaderInfo()
1200 sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines; in OJPEGWriteHeaderInfo()
1201 sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines; in OJPEGWriteHeaderInfo()
1202 …sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuf… in OJPEGWriteHeaderInfo()
1203 sp->subsampling_convert_ycbcrbuf=_TIFFmalloc(sp->subsampling_convert_ycbcrbuflen); in OJPEGWriteHeaderInfo()
1204 if (sp->subsampling_convert_ycbcrbuf==0) in OJPEGWriteHeaderInfo()
1209 sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf; in OJPEGWriteHeaderInfo()
1210 sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; in OJPEGWriteHeaderInfo()
1211 sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; in OJPEGWriteHeaderInfo()
1212 …sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_c… in OJPEGWriteHeaderInfo()
1213 …sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*… in OJPEGWriteHeaderInfo()
1214 if (sp->subsampling_convert_ycbcrimage==0) in OJPEGWriteHeaderInfo()
1219 m=sp->subsampling_convert_ycbcrimage; in OJPEGWriteHeaderInfo()
1220 *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); in OJPEGWriteHeaderInfo()
1221 *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); in OJPEGWriteHeaderInfo()
1222 …*m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_… in OJPEGWriteHeaderInfo()
1223 for (n=0; n<sp->subsampling_convert_ylines; n++) in OJPEGWriteHeaderInfo()
1224 *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; in OJPEGWriteHeaderInfo()
1225 for (n=0; n<sp->subsampling_convert_clines; n++) in OJPEGWriteHeaderInfo()
1226 *m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen; in OJPEGWriteHeaderInfo()
1227 for (n=0; n<sp->subsampling_convert_clines; n++) in OJPEGWriteHeaderInfo()
1228 *m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen; in OJPEGWriteHeaderInfo()
1229 …sp->subsampling_convert_clinelenout=((sp->strile_width+sp->subsampling_hor-1)/sp->subsampling_hor); in OJPEGWriteHeaderInfo()
1230 sp->subsampling_convert_state=0; in OJPEGWriteHeaderInfo()
1231 …sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2); in OJPEGWriteHeaderInfo()
1232 sp->lines_per_strile=((sp->strile_length+sp->subsampling_ver-1)/sp->subsampling_ver); in OJPEGWriteHeaderInfo()
1233 sp->subsampling_convert_log=1; in OJPEGWriteHeaderInfo()
1238 sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN; in OJPEGWriteHeaderInfo()
1239 sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN; in OJPEGWriteHeaderInfo()
1240 sp->libjpeg_jpeg_query_style=1; in OJPEGWriteHeaderInfo()
1241 sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width; in OJPEGWriteHeaderInfo()
1242 sp->lines_per_strile=sp->strile_length; in OJPEGWriteHeaderInfo()
1244 if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) in OJPEGWriteHeaderInfo()
1246 sp->writeheader_done=1; in OJPEGWriteHeaderInfo()
1253 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGLibjpegSessionAbort() local
1254 assert(sp->libjpeg_session_active!=0); in OJPEGLibjpegSessionAbort()
1255 jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct))); in OJPEGLibjpegSessionAbort()
1256 sp->libjpeg_session_active=0; in OJPEGLibjpegSessionAbort()
1263 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSec() local
1267 if (sp->file_size==0) in OJPEGReadHeaderInfoSec()
1268 sp->file_size=TIFFGetFileSize(tif); in OJPEGReadHeaderInfoSec()
1269 if (sp->jpeg_interchange_format!=0) in OJPEGReadHeaderInfoSec()
1271 if (sp->jpeg_interchange_format>=sp->file_size) in OJPEGReadHeaderInfoSec()
1273 sp->jpeg_interchange_format=0; in OJPEGReadHeaderInfoSec()
1274 sp->jpeg_interchange_format_length=0; in OJPEGReadHeaderInfoSec()
1278 …if ((sp->jpeg_interchange_format_length==0) || (sp->jpeg_interchange_format+sp->jpeg_interchange_f… in OJPEGReadHeaderInfoSec()
1279 sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; in OJPEGReadHeaderInfoSec()
1282 sp->in_buffer_source=osibsNotSetYet; in OJPEGReadHeaderInfoSec()
1283 sp->in_buffer_next_strile=0; in OJPEGReadHeaderInfoSec()
1284 sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; in OJPEGReadHeaderInfoSec()
1285 sp->in_buffer_file_togo=0; in OJPEGReadHeaderInfoSec()
1286 sp->in_buffer_togo=0; in OJPEGReadHeaderInfoSec()
1289 if (OJPEGReadBytePeek(sp,&m)==0) in OJPEGReadHeaderInfoSec()
1293 OJPEGReadByteAdvance(sp); in OJPEGReadHeaderInfoSec()
1296 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadHeaderInfoSec()
1322 if (OJPEGReadWord(sp,&n)==0) in OJPEGReadHeaderInfoSec()
1326 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSec()
1331 OJPEGReadSkip(sp,n-2); in OJPEGReadHeaderInfoSec()
1350 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSec()
1354 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSec()
1356 assert(sp->plane_sample_offset==0); in OJPEGReadHeaderInfoSec()
1365 if (sp->subsamplingcorrect) in OJPEGReadHeaderInfoSec()
1367 if (sp->sof_log==0) in OJPEGReadHeaderInfoSec()
1371 sp->sof_marker_id=JPEG_MARKER_SOF0; in OJPEGReadHeaderInfoSec()
1372 for (o=0; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1373 sp->sof_c[o]=o; in OJPEGReadHeaderInfoSec()
1374 sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); in OJPEGReadHeaderInfoSec()
1375 for (o=1; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1376 sp->sof_hv[o]=17; in OJPEGReadHeaderInfoSec()
1377 sp->sof_x=sp->strile_width; in OJPEGReadHeaderInfoSec()
1378 sp->sof_y=sp->strile_length_total; in OJPEGReadHeaderInfoSec()
1379 sp->sof_log=1; in OJPEGReadHeaderInfoSec()
1384 for (o=1; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1385 sp->sos_cs[o]=o; in OJPEGReadHeaderInfoSec()
1395 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDri() local
1397 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDri()
1404 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDri()
1406 sp->restart_interval=m; in OJPEGReadHeaderInfoSecStreamDri()
1415 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDqt() local
1420 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDqt()
1424 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamDqt()
1428 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamDqt()
1429 OJPEGReadSkip(sp,m-2); in OJPEGReadHeaderInfoSecStreamDqt()
1452 if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { in OJPEGReadHeaderInfoSecStreamDqt()
1463 if (sp->qtable[o]!=0) in OJPEGReadHeaderInfoSecStreamDqt()
1464 _TIFFfree(sp->qtable[o]); in OJPEGReadHeaderInfoSecStreamDqt()
1465 sp->qtable[o]=nb; in OJPEGReadHeaderInfoSecStreamDqt()
1478 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDht() local
1483 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDht()
1487 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamDht()
1491 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamDht()
1493 OJPEGReadSkip(sp,m-2); in OJPEGReadHeaderInfoSecStreamDht()
1509 if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) { in OJPEGReadHeaderInfoSecStreamDht()
1522 if (sp->dctable[o]!=0) in OJPEGReadHeaderInfoSecStreamDht()
1523 _TIFFfree(sp->dctable[o]); in OJPEGReadHeaderInfoSecStreamDht()
1524 sp->dctable[o]=nb; in OJPEGReadHeaderInfoSecStreamDht()
1541 if (sp->actable[o]!=0) in OJPEGReadHeaderInfoSecStreamDht()
1542 _TIFFfree(sp->actable[o]); in OJPEGReadHeaderInfoSecStreamDht()
1543 sp->actable[o]=nb; in OJPEGReadHeaderInfoSecStreamDht()
1554 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamSof() local
1560 if (sp->sof_log!=0) in OJPEGReadHeaderInfoSecStreamSof()
1565 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1566 sp->sof_marker_id=marker_id; in OJPEGReadHeaderInfoSecStreamSof()
1568 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamSof()
1572 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1579 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1584 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1586 if (n!=sp->samples_per_pixel) in OJPEGReadHeaderInfoSecStreamSof()
1593 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1597 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1602 if (sp->subsamplingcorrect) in OJPEGReadHeaderInfoSecStreamSof()
1603 OJPEGReadSkip(sp,4); in OJPEGReadHeaderInfoSecStreamSof()
1607 if (OJPEGReadWord(sp,&p)==0) in OJPEGReadHeaderInfoSecStreamSof()
1609 if (((uint32)p<sp->image_length) && ((uint32)p<sp->strile_length_total)) in OJPEGReadHeaderInfoSecStreamSof()
1614 sp->sof_y=p; in OJPEGReadHeaderInfoSecStreamSof()
1616 if (OJPEGReadWord(sp,&p)==0) in OJPEGReadHeaderInfoSecStreamSof()
1618 if (((uint32)p<sp->image_width) && ((uint32)p<sp->strile_width)) in OJPEGReadHeaderInfoSecStreamSof()
1623 if ((uint32)p>sp->strile_width) in OJPEGReadHeaderInfoSecStreamSof()
1628 sp->sof_x=p; in OJPEGReadHeaderInfoSecStreamSof()
1631 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1635 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1644 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1646 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1647 sp->sof_c[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1649 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1651 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamSof()
1655 sp->subsampling_hor=(o>>4); in OJPEGReadHeaderInfoSecStreamSof()
1656 sp->subsampling_ver=(o&15); in OJPEGReadHeaderInfoSecStreamSof()
1657 if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || in OJPEGReadHeaderInfoSecStreamSof()
1658 ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) in OJPEGReadHeaderInfoSecStreamSof()
1659 sp->subsampling_force_desubsampling_inside_decompression=1; in OJPEGReadHeaderInfoSecStreamSof()
1664 sp->subsampling_force_desubsampling_inside_decompression=1; in OJPEGReadHeaderInfoSecStreamSof()
1669 sp->sof_hv[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1670 if (sp->subsampling_force_desubsampling_inside_decompression==0) in OJPEGReadHeaderInfoSecStreamSof()
1674 if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver)) in OJPEGReadHeaderInfoSecStreamSof()
1691 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1693 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1694 sp->sof_tq[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1696 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1697 sp->sof_log=1; in OJPEGReadHeaderInfoSecStreamSof()
1706 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamSos() local
1710 assert(sp->subsamplingcorrect==0); in OJPEGReadHeaderInfoSecStreamSos()
1711 if (sp->sof_log==0) in OJPEGReadHeaderInfoSecStreamSos()
1717 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamSos()
1719 if (m!=6+sp->samples_per_pixel_per_plane*2) in OJPEGReadHeaderInfoSecStreamSos()
1725 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1727 if (n!=sp->samples_per_pixel_per_plane) in OJPEGReadHeaderInfoSecStreamSos()
1733 for (o=0; o<sp->samples_per_pixel_per_plane; o++) in OJPEGReadHeaderInfoSecStreamSos()
1736 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1738 sp->sos_cs[sp->plane_sample_offset+o]=n; in OJPEGReadHeaderInfoSecStreamSos()
1740 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1742 sp->sos_tda[sp->plane_sample_offset+o]=n; in OJPEGReadHeaderInfoSecStreamSos()
1745 OJPEGReadSkip(sp,3); in OJPEGReadHeaderInfoSecStreamSos()
1753 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesQTable() local
1759 if (sp->qtable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesQTable()
1764 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesQTable()
1765 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesQTable()
1767 if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesQTable()
1771 if (sp->qtable_offset[m]==sp->qtable_offset[n]) in OJPEGReadHeaderInfoSecTablesQTable()
1790 TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesQTable()
1797 if (sp->qtable[m]!=0) in OJPEGReadHeaderInfoSecTablesQTable()
1798 _TIFFfree(sp->qtable[m]); in OJPEGReadHeaderInfoSecTablesQTable()
1799 sp->qtable[m]=ob; in OJPEGReadHeaderInfoSecTablesQTable()
1800 sp->sof_tq[m]=m; in OJPEGReadHeaderInfoSecTablesQTable()
1803 sp->sof_tq[m]=sp->sof_tq[m-1]; in OJPEGReadHeaderInfoSecTablesQTable()
1812 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesDcTable() local
1820 if (sp->dctable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesDcTable()
1825 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesDcTable()
1826 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesDcTable()
1828 if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesDcTable()
1832 if (sp->dctable_offset[m]==sp->dctable_offset[n]) in OJPEGReadHeaderInfoSecTablesDcTable()
1838 TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesDcTable()
1866 if (sp->dctable[m]!=0) in OJPEGReadHeaderInfoSecTablesDcTable()
1867 _TIFFfree(sp->dctable[m]); in OJPEGReadHeaderInfoSecTablesDcTable()
1868 sp->dctable[m]=rb; in OJPEGReadHeaderInfoSecTablesDcTable()
1869 sp->sos_tda[m]=(m<<4); in OJPEGReadHeaderInfoSecTablesDcTable()
1872 sp->sos_tda[m]=sp->sos_tda[m-1]; in OJPEGReadHeaderInfoSecTablesDcTable()
1881 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesAcTable() local
1889 if (sp->actable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesAcTable()
1894 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesAcTable()
1895 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesAcTable()
1897 if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesAcTable()
1901 if (sp->actable_offset[m]==sp->actable_offset[n]) in OJPEGReadHeaderInfoSecTablesAcTable()
1907 TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesAcTable()
1935 if (sp->actable[m]) in OJPEGReadHeaderInfoSecTablesAcTable()
1936 _TIFFfree(sp->actable[m]); in OJPEGReadHeaderInfoSecTablesAcTable()
1937 sp->actable[m]=rb; in OJPEGReadHeaderInfoSecTablesAcTable()
1938 sp->sos_tda[m]=(sp->sos_tda[m]|m); in OJPEGReadHeaderInfoSecTablesAcTable()
1941 sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15)); in OJPEGReadHeaderInfoSecTablesAcTable()
1947 OJPEGReadBufferFill(OJPEGState* sp) in OJPEGReadBufferFill() argument
1955 if (sp->in_buffer_file_togo!=0) in OJPEGReadBufferFill()
1957 if (sp->in_buffer_file_pos_log==0) in OJPEGReadBufferFill()
1959 TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET); in OJPEGReadBufferFill()
1960 sp->in_buffer_file_pos_log=1; in OJPEGReadBufferFill()
1963 if ((uint64)m>sp->in_buffer_file_togo) in OJPEGReadBufferFill()
1964 m=(uint16)sp->in_buffer_file_togo; in OJPEGReadBufferFill()
1965 n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m); in OJPEGReadBufferFill()
1971 assert((uint64)n<=sp->in_buffer_file_togo); in OJPEGReadBufferFill()
1973 sp->in_buffer_togo=m; in OJPEGReadBufferFill()
1974 sp->in_buffer_cur=sp->in_buffer; in OJPEGReadBufferFill()
1975 sp->in_buffer_file_togo-=m; in OJPEGReadBufferFill()
1976 sp->in_buffer_file_pos+=m; in OJPEGReadBufferFill()
1979 sp->in_buffer_file_pos_log=0; in OJPEGReadBufferFill()
1980 switch(sp->in_buffer_source) in OJPEGReadBufferFill()
1983 if (sp->jpeg_interchange_format!=0) in OJPEGReadBufferFill()
1985 sp->in_buffer_file_pos=sp->jpeg_interchange_format; in OJPEGReadBufferFill()
1986 sp->in_buffer_file_togo=sp->jpeg_interchange_format_length; in OJPEGReadBufferFill()
1988 sp->in_buffer_source=osibsJpegInterchangeFormat; in OJPEGReadBufferFill()
1991 sp->in_buffer_source=osibsStrile; in OJPEGReadBufferFill()
1994 if (!_TIFFFillStriles( sp->tif ) in OJPEGReadBufferFill()
1995 || sp->tif->tif_dir.td_stripoffset == NULL in OJPEGReadBufferFill()
1996 || sp->tif->tif_dir.td_stripbytecount == NULL) in OJPEGReadBufferFill()
1999 if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) in OJPEGReadBufferFill()
2000 sp->in_buffer_source=osibsEof; in OJPEGReadBufferFill()
2003 sp->in_buffer_file_pos=sp->tif->tif_dir.td_stripoffset[sp->in_buffer_next_strile]; in OJPEGReadBufferFill()
2004 if (sp->in_buffer_file_pos!=0) in OJPEGReadBufferFill()
2006 if (sp->in_buffer_file_pos>=sp->file_size) in OJPEGReadBufferFill()
2007 sp->in_buffer_file_pos=0; in OJPEGReadBufferFill()
2008 else if (sp->tif->tif_dir.td_stripbytecount==NULL) in OJPEGReadBufferFill()
2009 sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; in OJPEGReadBufferFill()
2012 if (sp->tif->tif_dir.td_stripbytecount == 0) { in OJPEGReadBufferFill()
2013 TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing"); in OJPEGReadBufferFill()
2016 sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; in OJPEGReadBufferFill()
2017 if (sp->in_buffer_file_togo==0) in OJPEGReadBufferFill()
2018 sp->in_buffer_file_pos=0; in OJPEGReadBufferFill()
2019 else if (sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) in OJPEGReadBufferFill()
2020 sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; in OJPEGReadBufferFill()
2023 sp->in_buffer_next_strile++; in OJPEGReadBufferFill()
2034 OJPEGReadByte(OJPEGState* sp, uint8* byte) in OJPEGReadByte() argument
2036 if (sp->in_buffer_togo==0) in OJPEGReadByte()
2038 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadByte()
2040 assert(sp->in_buffer_togo>0); in OJPEGReadByte()
2042 *byte=*(sp->in_buffer_cur); in OJPEGReadByte()
2043 sp->in_buffer_cur++; in OJPEGReadByte()
2044 sp->in_buffer_togo--; in OJPEGReadByte()
2049 OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) in OJPEGReadBytePeek() argument
2051 if (sp->in_buffer_togo==0) in OJPEGReadBytePeek()
2053 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadBytePeek()
2055 assert(sp->in_buffer_togo>0); in OJPEGReadBytePeek()
2057 *byte=*(sp->in_buffer_cur); in OJPEGReadBytePeek()
2062 OJPEGReadByteAdvance(OJPEGState* sp) in OJPEGReadByteAdvance() argument
2064 assert(sp->in_buffer_togo>0); in OJPEGReadByteAdvance()
2065 sp->in_buffer_cur++; in OJPEGReadByteAdvance()
2066 sp->in_buffer_togo--; in OJPEGReadByteAdvance()
2070 OJPEGReadWord(OJPEGState* sp, uint16* word) in OJPEGReadWord() argument
2073 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadWord()
2076 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadWord()
2083 OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) in OJPEGReadBlock() argument
2093 if (sp->in_buffer_togo==0) in OJPEGReadBlock()
2095 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadBlock()
2097 assert(sp->in_buffer_togo>0); in OJPEGReadBlock()
2100 if (n>sp->in_buffer_togo) in OJPEGReadBlock()
2101 n=sp->in_buffer_togo; in OJPEGReadBlock()
2102 _TIFFmemcpy(mmem,sp->in_buffer_cur,n); in OJPEGReadBlock()
2103 sp->in_buffer_cur+=n; in OJPEGReadBlock()
2104 sp->in_buffer_togo-=n; in OJPEGReadBlock()
2112 OJPEGReadSkip(OJPEGState* sp, uint16 len) in OJPEGReadSkip() argument
2118 if (n>sp->in_buffer_togo) in OJPEGReadSkip()
2119 n=sp->in_buffer_togo; in OJPEGReadSkip()
2120 sp->in_buffer_cur+=n; in OJPEGReadSkip()
2121 sp->in_buffer_togo-=n; in OJPEGReadSkip()
2125 assert(sp->in_buffer_togo==0); in OJPEGReadSkip()
2127 if ((uint64)n>sp->in_buffer_file_togo) in OJPEGReadSkip()
2128 n=(uint16)sp->in_buffer_file_togo; in OJPEGReadSkip()
2129 sp->in_buffer_file_pos+=n; in OJPEGReadSkip()
2130 sp->in_buffer_file_togo-=n; in OJPEGReadSkip()
2131 sp->in_buffer_file_pos_log=0; in OJPEGReadSkip()
2144 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStream() local
2148 assert(sp->out_state<=ososEoi); in OJPEGWriteStream()
2149 switch(sp->out_state) in OJPEGWriteStream()
2217 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSoi() local
2219 sp->out_buffer[0]=255; in OJPEGWriteStreamSoi()
2220 sp->out_buffer[1]=JPEG_MARKER_SOI; in OJPEGWriteStreamSoi()
2222 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSoi()
2223 sp->out_state++; in OJPEGWriteStreamSoi()
2229 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamQTable() local
2230 if (sp->qtable[table_index]!=0) in OJPEGWriteStreamQTable()
2232 *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); in OJPEGWriteStreamQTable()
2233 *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); in OJPEGWriteStreamQTable()
2235 sp->out_state++; in OJPEGWriteStreamQTable()
2241 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamDcTable() local
2242 if (sp->dctable[table_index]!=0) in OJPEGWriteStreamDcTable()
2244 *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); in OJPEGWriteStreamDcTable()
2245 *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); in OJPEGWriteStreamDcTable()
2247 sp->out_state++; in OJPEGWriteStreamDcTable()
2253 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamAcTable() local
2254 if (sp->actable[table_index]!=0) in OJPEGWriteStreamAcTable()
2256 *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); in OJPEGWriteStreamAcTable()
2257 *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); in OJPEGWriteStreamAcTable()
2259 sp->out_state++; in OJPEGWriteStreamAcTable()
2265 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamDri() local
2267 if (sp->restart_interval!=0) in OJPEGWriteStreamDri()
2269 sp->out_buffer[0]=255; in OJPEGWriteStreamDri()
2270 sp->out_buffer[1]=JPEG_MARKER_DRI; in OJPEGWriteStreamDri()
2271 sp->out_buffer[2]=0; in OJPEGWriteStreamDri()
2272 sp->out_buffer[3]=4; in OJPEGWriteStreamDri()
2273 sp->out_buffer[4]=(sp->restart_interval>>8); in OJPEGWriteStreamDri()
2274 sp->out_buffer[5]=(sp->restart_interval&255); in OJPEGWriteStreamDri()
2276 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamDri()
2278 sp->out_state++; in OJPEGWriteStreamDri()
2284 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSof() local
2286 assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); in OJPEGWriteStreamSof()
2287 assert(255>=8+sp->samples_per_pixel_per_plane*3); in OJPEGWriteStreamSof()
2288 sp->out_buffer[0]=255; in OJPEGWriteStreamSof()
2289 sp->out_buffer[1]=sp->sof_marker_id; in OJPEGWriteStreamSof()
2291 sp->out_buffer[2]=0; in OJPEGWriteStreamSof()
2292 sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3; in OJPEGWriteStreamSof()
2294 sp->out_buffer[4]=8; in OJPEGWriteStreamSof()
2296 sp->out_buffer[5]=(sp->sof_y>>8); in OJPEGWriteStreamSof()
2297 sp->out_buffer[6]=(sp->sof_y&255); in OJPEGWriteStreamSof()
2299 sp->out_buffer[7]=(sp->sof_x>>8); in OJPEGWriteStreamSof()
2300 sp->out_buffer[8]=(sp->sof_x&255); in OJPEGWriteStreamSof()
2302 sp->out_buffer[9]=sp->samples_per_pixel_per_plane; in OJPEGWriteStreamSof()
2303 for (m=0; m<sp->samples_per_pixel_per_plane; m++) in OJPEGWriteStreamSof()
2306 sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2308 sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2310 sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2312 *len=10+sp->samples_per_pixel_per_plane*3; in OJPEGWriteStreamSof()
2313 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSof()
2314 sp->out_state++; in OJPEGWriteStreamSof()
2320 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSos() local
2322 assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); in OJPEGWriteStreamSos()
2323 assert(255>=6+sp->samples_per_pixel_per_plane*2); in OJPEGWriteStreamSos()
2324 sp->out_buffer[0]=255; in OJPEGWriteStreamSos()
2325 sp->out_buffer[1]=JPEG_MARKER_SOS; in OJPEGWriteStreamSos()
2327 sp->out_buffer[2]=0; in OJPEGWriteStreamSos()
2328 sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2; in OJPEGWriteStreamSos()
2330 sp->out_buffer[4]=sp->samples_per_pixel_per_plane; in OJPEGWriteStreamSos()
2331 for (m=0; m<sp->samples_per_pixel_per_plane; m++) in OJPEGWriteStreamSos()
2334 sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m]; in OJPEGWriteStreamSos()
2336 sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m]; in OJPEGWriteStreamSos()
2339 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0; in OJPEGWriteStreamSos()
2341 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63; in OJPEGWriteStreamSos()
2343 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0; in OJPEGWriteStreamSos()
2344 *len=8+sp->samples_per_pixel_per_plane*2; in OJPEGWriteStreamSos()
2345 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSos()
2346 sp->out_state++; in OJPEGWriteStreamSos()
2352 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamCompressed() local
2353 if (sp->in_buffer_togo==0) in OJPEGWriteStreamCompressed()
2355 if (OJPEGReadBufferFill(sp)==0) in OJPEGWriteStreamCompressed()
2357 assert(sp->in_buffer_togo>0); in OJPEGWriteStreamCompressed()
2359 *len=sp->in_buffer_togo; in OJPEGWriteStreamCompressed()
2360 *mem=(void*)sp->in_buffer_cur; in OJPEGWriteStreamCompressed()
2361 sp->in_buffer_togo=0; in OJPEGWriteStreamCompressed()
2362 if (sp->in_buffer_file_togo==0) in OJPEGWriteStreamCompressed()
2364 switch(sp->in_buffer_source) in OJPEGWriteStreamCompressed()
2367 if (sp->in_buffer_next_strile<sp->in_buffer_strile_count) in OJPEGWriteStreamCompressed()
2368 sp->out_state=ososRst; in OJPEGWriteStreamCompressed()
2370 sp->out_state=ososEoi; in OJPEGWriteStreamCompressed()
2373 sp->out_state=ososEoi; in OJPEGWriteStreamCompressed()
2385 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamRst() local
2387 sp->out_buffer[0]=255; in OJPEGWriteStreamRst()
2388 sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index; in OJPEGWriteStreamRst()
2389 sp->restart_index++; in OJPEGWriteStreamRst()
2390 if (sp->restart_index==8) in OJPEGWriteStreamRst()
2391 sp->restart_index=0; in OJPEGWriteStreamRst()
2393 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamRst()
2394 sp->out_state=ososCompressed; in OJPEGWriteStreamRst()
2400 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamEoi() local
2402 sp->out_buffer[0]=255; in OJPEGWriteStreamEoi()
2403 sp->out_buffer[1]=JPEG_MARKER_EOI; in OJPEGWriteStreamEoi()
2405 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamEoi()
2410 jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) in jpeg_create_decompress_encap() argument
2412 return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_create_decompress(cinfo),1)); in jpeg_create_decompress_encap()
2418 jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) in jpeg_read_header_encap() argument
2420 return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_header(cinfo,require_image),1)); in jpeg_read_header_encap()
2426 jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) in jpeg_start_decompress_encap() argument
2428 return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_start_decompress(cinfo),1)); in jpeg_start_decompress_encap()
2434 jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 ma… in jpeg_read_scanlines_encap() argument
2436 return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_scanlines(cinfo,scanlines,max_lines),1)); in jpeg_read_scanlines_encap()
2442 jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_line… in jpeg_read_raw_data_encap() argument
2444 return(SETJMP(sp->exit_jmpbuf)?0:(jpeg_read_raw_data(cinfo,data,max_lines),1)); in jpeg_read_raw_data_encap()
2452 OJPEGState* sp=(OJPEGState*)tif->tif_data; in jpeg_encap_unwind() local
2453 LONGJMP(sp->exit_jmpbuf,1); in jpeg_encap_unwind()
2484 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGLibjpegJpegSourceMgrFillInputBuffer() local
2492 sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len; in OJPEGLibjpegJpegSourceMgrFillInputBuffer()
2493 sp->libjpeg_jpeg_source_mgr.next_input_byte=mem; in OJPEGLibjpegJpegSourceMgrFillInputBuffer()