• Home
  • Raw
  • Download

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()
734 sp->decoder_ok = 1; in OJPEGPreDecode()
741 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPreDecodeSkipRaw() local
743 m=sp->lines_per_strile; in OJPEGPreDecodeSkipRaw()
744 if (sp->subsampling_convert_state!=0) in OJPEGPreDecodeSkipRaw()
746 if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m) in OJPEGPreDecodeSkipRaw()
748 sp->subsampling_convert_state+=m; in OJPEGPreDecodeSkipRaw()
749 if (sp->subsampling_convert_state==sp->subsampling_convert_clines) in OJPEGPreDecodeSkipRaw()
750 sp->subsampling_convert_state=0; in OJPEGPreDecodeSkipRaw()
753 m-=sp->subsampling_convert_clines-sp->subsampling_convert_state; in OJPEGPreDecodeSkipRaw()
754 sp->subsampling_convert_state=0; in OJPEGPreDecodeSkipRaw()
755 sp->error_in_raw_data_decoding=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->error_in_raw_data_decoding ) in OJPEGDecode()
810 if (sp->libjpeg_jpeg_query_style==0) in OJPEGDecode()
827 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecodeRaw() local
837 if (cc%sp->bytes_per_line!=0) in OJPEGDecodeRaw()
847 if (sp->subsampling_convert_state==0) in OJPEGDecodeRaw()
849 const jpeg_decompress_struct* cinfo = &sp->libjpeg_jpeg_decompress_struct; in OJPEGDecodeRaw()
857 sp->error_in_raw_data_decoding = 1; in OJPEGDecodeRaw()
872 expected_bytes = sp->subsampling_convert_clinelenout * sp->subsampling_ver * sp->subsampling_hor; in OJPEGDecodeRaw()
876 sp->error_in_raw_data_decoding = 1; in OJPEGDecodeRaw()
879 …if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbc… in OJPEGDecodeRaw()
881 sp->error_in_raw_data_decoding = 1; in OJPEGDecodeRaw()
885 …oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_… in OJPEGDecodeRaw()
886 ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; in OJPEGDecodeRaw()
887 ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; in OJPEGDecodeRaw()
889 for (q=0; q<sp->subsampling_convert_clinelenout; q++) in OJPEGDecodeRaw()
892 for (sy=0; sy<sp->subsampling_ver; sy++) in OJPEGDecodeRaw()
894 for (sx=0; sx<sp->subsampling_hor; sx++) in OJPEGDecodeRaw()
896 r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor; in OJPEGDecodeRaw()
898 oy+=sp->subsampling_hor; in OJPEGDecodeRaw()
902 sp->subsampling_convert_state++; in OJPEGDecodeRaw()
903 if (sp->subsampling_convert_state==sp->subsampling_convert_clines) in OJPEGDecodeRaw()
904 sp->subsampling_convert_state=0; in OJPEGDecodeRaw()
905 m+=sp->bytes_per_line; in OJPEGDecodeRaw()
906 n-=sp->bytes_per_line; in OJPEGDecodeRaw()
915 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGDecodeScanlines() local
918 if (cc%sp->bytes_per_line!=0) in OJPEGDecodeScanlines()
928 if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0) in OJPEGDecodeScanlines()
930 m+=sp->bytes_per_line; in OJPEGDecodeScanlines()
931 n-=sp->bytes_per_line; in OJPEGDecodeScanlines()
939 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGPostDecode() local
942 sp->write_curstrile++; in OJPEGPostDecode()
943 if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) in OJPEGPostDecode()
945 assert(sp->libjpeg_session_active!=0); in OJPEGPostDecode()
947 sp->writeheader_done=0; in OJPEGPostDecode()
990 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGCleanup() local
991 if (sp!=0) in OJPEGCleanup()
993 tif->tif_tagmethods.vgetfield=sp->vgetparent; in OJPEGCleanup()
994 tif->tif_tagmethods.vsetfield=sp->vsetparent; in OJPEGCleanup()
995 tif->tif_tagmethods.printdir=sp->printdir; in OJPEGCleanup()
996 if (sp->qtable[0]!=0) in OJPEGCleanup()
997 _TIFFfree(sp->qtable[0]); in OJPEGCleanup()
998 if (sp->qtable[1]!=0) in OJPEGCleanup()
999 _TIFFfree(sp->qtable[1]); in OJPEGCleanup()
1000 if (sp->qtable[2]!=0) in OJPEGCleanup()
1001 _TIFFfree(sp->qtable[2]); in OJPEGCleanup()
1002 if (sp->qtable[3]!=0) in OJPEGCleanup()
1003 _TIFFfree(sp->qtable[3]); in OJPEGCleanup()
1004 if (sp->dctable[0]!=0) in OJPEGCleanup()
1005 _TIFFfree(sp->dctable[0]); in OJPEGCleanup()
1006 if (sp->dctable[1]!=0) in OJPEGCleanup()
1007 _TIFFfree(sp->dctable[1]); in OJPEGCleanup()
1008 if (sp->dctable[2]!=0) in OJPEGCleanup()
1009 _TIFFfree(sp->dctable[2]); in OJPEGCleanup()
1010 if (sp->dctable[3]!=0) in OJPEGCleanup()
1011 _TIFFfree(sp->dctable[3]); in OJPEGCleanup()
1012 if (sp->actable[0]!=0) in OJPEGCleanup()
1013 _TIFFfree(sp->actable[0]); in OJPEGCleanup()
1014 if (sp->actable[1]!=0) in OJPEGCleanup()
1015 _TIFFfree(sp->actable[1]); in OJPEGCleanup()
1016 if (sp->actable[2]!=0) in OJPEGCleanup()
1017 _TIFFfree(sp->actable[2]); in OJPEGCleanup()
1018 if (sp->actable[3]!=0) in OJPEGCleanup()
1019 _TIFFfree(sp->actable[3]); in OJPEGCleanup()
1020 if (sp->libjpeg_session_active!=0) in OJPEGCleanup()
1022 if (sp->subsampling_convert_ycbcrbuf!=0) in OJPEGCleanup()
1023 _TIFFfree(sp->subsampling_convert_ycbcrbuf); in OJPEGCleanup()
1024 if (sp->subsampling_convert_ycbcrimage!=0) in OJPEGCleanup()
1025 _TIFFfree(sp->subsampling_convert_ycbcrimage); in OJPEGCleanup()
1026 if (sp->skip_buffer!=0) in OJPEGCleanup()
1027 _TIFFfree(sp->skip_buffer); in OJPEGCleanup()
1028 _TIFFfree(sp); in OJPEGCleanup()
1038 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGSubsamplingCorrect() local
1042 assert(sp->subsamplingcorrect_done==0); in OJPEGSubsamplingCorrect()
1046 if (sp->subsampling_tag!=0) in OJPEGSubsamplingCorrect()
1048 sp->subsampling_hor=1; in OJPEGSubsamplingCorrect()
1049 sp->subsampling_ver=1; in OJPEGSubsamplingCorrect()
1050 sp->subsampling_force_desubsampling_inside_decompression=0; in OJPEGSubsamplingCorrect()
1054 sp->subsamplingcorrect_done=1; in OJPEGSubsamplingCorrect()
1055 mh=sp->subsampling_hor; in OJPEGSubsamplingCorrect()
1056 mv=sp->subsampling_ver; in OJPEGSubsamplingCorrect()
1057 sp->subsamplingcorrect=1; in OJPEGSubsamplingCorrect()
1059 if (sp->subsampling_force_desubsampling_inside_decompression!=0) in OJPEGSubsamplingCorrect()
1061 sp->subsampling_hor=1; in OJPEGSubsamplingCorrect()
1062 sp->subsampling_ver=1; in OJPEGSubsamplingCorrect()
1064 sp->subsamplingcorrect=0; in OJPEGSubsamplingCorrect()
1065 …if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampli… in OJPEGSubsamplingCorrect()
1067 if (sp->subsampling_tag==0) in OJPEGSubsamplingCorrect()
1068 … values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1070 …alues [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1072 if (sp->subsampling_force_desubsampling_inside_decompression!=0) in OJPEGSubsamplingCorrect()
1074 if (sp->subsampling_tag==0) in OJPEGSubsamplingCorrect()
1079 if (sp->subsampling_force_desubsampling_inside_decompression==0) in OJPEGSubsamplingCorrect()
1081 if (sp->subsampling_hor<sp->subsampling_ver) in OJPEGSubsamplingCorrect()
1082 …data,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampli… in OJPEGSubsamplingCorrect()
1085 sp->subsamplingcorrect_done=1; in OJPEGSubsamplingCorrect()
1092 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfo() local
1093 assert(sp->readheader_done==0); in OJPEGReadHeaderInfo()
1094 sp->image_width=tif->tif_dir.td_imagewidth; in OJPEGReadHeaderInfo()
1095 sp->image_length=tif->tif_dir.td_imagelength; in OJPEGReadHeaderInfo()
1098 sp->strile_width=tif->tif_dir.td_tilewidth; in OJPEGReadHeaderInfo()
1099 sp->strile_length=tif->tif_dir.td_tilelength; in OJPEGReadHeaderInfo()
1100sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_leng… in OJPEGReadHeaderInfo()
1104 sp->strile_width=sp->image_width; in OJPEGReadHeaderInfo()
1105 sp->strile_length=tif->tif_dir.td_rowsperstrip; in OJPEGReadHeaderInfo()
1106 sp->strile_length_total=sp->image_length; in OJPEGReadHeaderInfo()
1110 sp->samples_per_pixel=1; in OJPEGReadHeaderInfo()
1111 sp->plane_sample_offset=0; in OJPEGReadHeaderInfo()
1112 sp->samples_per_pixel_per_plane=sp->samples_per_pixel; in OJPEGReadHeaderInfo()
1113 sp->subsampling_hor=1; in OJPEGReadHeaderInfo()
1114 sp->subsampling_ver=1; in OJPEGReadHeaderInfo()
1120 …tdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); in OJPEGReadHeaderInfo()
1123 sp->samples_per_pixel=3; in OJPEGReadHeaderInfo()
1124 sp->plane_sample_offset=0; in OJPEGReadHeaderInfo()
1126 sp->samples_per_pixel_per_plane=3; in OJPEGReadHeaderInfo()
1128 sp->samples_per_pixel_per_plane=1; in OJPEGReadHeaderInfo()
1130 if (sp->strile_length<sp->image_length) in OJPEGReadHeaderInfo()
1132 if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || in OJPEGReadHeaderInfo()
1133 ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) in OJPEGReadHeaderInfo()
1138 if (sp->strile_length%(sp->subsampling_ver*8)!=0) in OJPEGReadHeaderInfo()
1143sp->restart_interval=(uint16)(((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8))… in OJPEGReadHeaderInfo()
1147 sp->sos_end[0].log=1; in OJPEGReadHeaderInfo()
1148 sp->sos_end[0].in_buffer_source=sp->in_buffer_source; in OJPEGReadHeaderInfo()
1149 sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile; in OJPEGReadHeaderInfo()
1150 sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; in OJPEGReadHeaderInfo()
1151 sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; in OJPEGReadHeaderInfo()
1152 sp->readheader_done=1; in OJPEGReadHeaderInfo()
1159 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadSecondarySos() local
1163 assert(sp->sos_end[0].log!=0); in OJPEGReadSecondarySos()
1164 assert(sp->sos_end[s].log==0); in OJPEGReadSecondarySos()
1165 sp->plane_sample_offset=(uint8)(s-1); in OJPEGReadSecondarySos()
1166 while(sp->sos_end[sp->plane_sample_offset].log==0) in OJPEGReadSecondarySos()
1167 sp->plane_sample_offset--; in OJPEGReadSecondarySos()
1168 sp->in_buffer_source=sp->sos_end[sp->plane_sample_offset].in_buffer_source; in OJPEGReadSecondarySos()
1169 sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; in OJPEGReadSecondarySos()
1170 sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; in OJPEGReadSecondarySos()
1171 sp->in_buffer_file_pos_log=0; in OJPEGReadSecondarySos()
1172 sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; in OJPEGReadSecondarySos()
1173 sp->in_buffer_togo=0; in OJPEGReadSecondarySos()
1174 sp->in_buffer_cur=0; in OJPEGReadSecondarySos()
1175 while(sp->plane_sample_offset<s) in OJPEGReadSecondarySos()
1179 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadSecondarySos()
1185 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadSecondarySos()
1194 sp->plane_sample_offset++; in OJPEGReadSecondarySos()
1197 sp->sos_end[sp->plane_sample_offset].log=1; in OJPEGReadSecondarySos()
1198 sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source; in OJPEGReadSecondarySos()
1199 sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile; in OJPEGReadSecondarySos()
1200 sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; in OJPEGReadSecondarySos()
1201sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_tog… in OJPEGReadSecondarySos()
1210 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteHeaderInfo() local
1214 if (sp->libjpeg_session_active != 0) in OJPEGWriteHeaderInfo()
1216 sp->out_state=ososSoi; in OJPEGWriteHeaderInfo()
1217 sp->restart_index=0; in OJPEGWriteHeaderInfo()
1218 jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); in OJPEGWriteHeaderInfo()
1219 sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage; in OJPEGWriteHeaderInfo()
1220 sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit; in OJPEGWriteHeaderInfo()
1221 sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr); in OJPEGWriteHeaderInfo()
1222 sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif; in OJPEGWriteHeaderInfo()
1223 if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) in OJPEGWriteHeaderInfo()
1225 sp->libjpeg_session_active=1; in OJPEGWriteHeaderInfo()
1226 sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0; in OJPEGWriteHeaderInfo()
1227 sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource; in OJPEGWriteHeaderInfo()
1228 sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer; in OJPEGWriteHeaderInfo()
1229 sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData; in OJPEGWriteHeaderInfo()
1230 sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart; in OJPEGWriteHeaderInfo()
1231 sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource; in OJPEGWriteHeaderInfo()
1232 sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr); in OJPEGWriteHeaderInfo()
1233 if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0) in OJPEGWriteHeaderInfo()
1235 …if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_pl… in OJPEGWriteHeaderInfo()
1237 sp->libjpeg_jpeg_decompress_struct.raw_data_out=1; in OJPEGWriteHeaderInfo()
1239 sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; in OJPEGWriteHeaderInfo()
1241 sp->libjpeg_jpeg_query_style=0; in OJPEGWriteHeaderInfo()
1242 if (sp->subsampling_convert_log==0) in OJPEGWriteHeaderInfo()
1244 assert(sp->subsampling_convert_ycbcrbuf==0); in OJPEGWriteHeaderInfo()
1245 assert(sp->subsampling_convert_ycbcrimage==0); in OJPEGWriteHeaderInfo()
1246sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*… in OJPEGWriteHeaderInfo()
1247 sp->subsampling_convert_ylines=sp->subsampling_ver*8; in OJPEGWriteHeaderInfo()
1248 sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor; in OJPEGWriteHeaderInfo()
1249 sp->subsampling_convert_clines=8; in OJPEGWriteHeaderInfo()
1250 sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines; in OJPEGWriteHeaderInfo()
1251 sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines; in OJPEGWriteHeaderInfo()
1252sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuf… in OJPEGWriteHeaderInfo()
1259 sp->subsampling_convert_ycbcrbuf=_TIFFcalloc(1, sp->subsampling_convert_ycbcrbuflen); in OJPEGWriteHeaderInfo()
1260 if (sp->subsampling_convert_ycbcrbuf==0) in OJPEGWriteHeaderInfo()
1265 sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf; in OJPEGWriteHeaderInfo()
1266 sp->subsampling_convert_cbbuf=sp->subsampling_convert_ybuf+sp->subsampling_convert_ybuflen; in OJPEGWriteHeaderInfo()
1267 sp->subsampling_convert_crbuf=sp->subsampling_convert_cbbuf+sp->subsampling_convert_cbuflen; in OJPEGWriteHeaderInfo()
1268sp->subsampling_convert_ycbcrimagelen=3+sp->subsampling_convert_ylines+2*sp->subsampling_convert_c… in OJPEGWriteHeaderInfo()
1269sp->subsampling_convert_ycbcrimage=_TIFFmalloc(sp->subsampling_convert_ycbcrimagelen*sizeof(uint8*… in OJPEGWriteHeaderInfo()
1270 if (sp->subsampling_convert_ycbcrimage==0) in OJPEGWriteHeaderInfo()
1275 m=sp->subsampling_convert_ycbcrimage; in OJPEGWriteHeaderInfo()
1276 *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3); in OJPEGWriteHeaderInfo()
1277 *m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines); in OJPEGWriteHeaderInfo()
1278 …*m++=(uint8*)(sp->subsampling_convert_ycbcrimage+3+sp->subsampling_convert_ylines+sp->subsampling_… in OJPEGWriteHeaderInfo()
1279 for (n=0; n<sp->subsampling_convert_ylines; n++) in OJPEGWriteHeaderInfo()
1280 *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; in OJPEGWriteHeaderInfo()
1281 for (n=0; n<sp->subsampling_convert_clines; n++) in OJPEGWriteHeaderInfo()
1282 *m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen; in OJPEGWriteHeaderInfo()
1283 for (n=0; n<sp->subsampling_convert_clines; n++) in OJPEGWriteHeaderInfo()
1284 *m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen; in OJPEGWriteHeaderInfo()
1285sp->subsampling_convert_clinelenout=sp->strile_width/sp->subsampling_hor + ((sp->strile_width % sp in OJPEGWriteHeaderInfo()
1286 sp->subsampling_convert_state=0; in OJPEGWriteHeaderInfo()
1287 sp->error_in_raw_data_decoding=0; in OJPEGWriteHeaderInfo()
1288sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2); in OJPEGWriteHeaderInfo()
1289sp->lines_per_strile=sp->strile_length/sp->subsampling_ver + ((sp->strile_length % sp->subsampling… in OJPEGWriteHeaderInfo()
1290 sp->subsampling_convert_log=1; in OJPEGWriteHeaderInfo()
1295 sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN; in OJPEGWriteHeaderInfo()
1296 sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN; in OJPEGWriteHeaderInfo()
1297 sp->libjpeg_jpeg_query_style=1; in OJPEGWriteHeaderInfo()
1298 sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width; in OJPEGWriteHeaderInfo()
1299 sp->lines_per_strile=sp->strile_length; in OJPEGWriteHeaderInfo()
1301 if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) in OJPEGWriteHeaderInfo()
1303 sp->writeheader_done=1; in OJPEGWriteHeaderInfo()
1310 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGLibjpegSessionAbort() local
1311 assert(sp->libjpeg_session_active!=0); in OJPEGLibjpegSessionAbort()
1312 jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct))); in OJPEGLibjpegSessionAbort()
1313 sp->libjpeg_session_active=0; in OJPEGLibjpegSessionAbort()
1320 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSec() local
1324 if (sp->file_size==0) in OJPEGReadHeaderInfoSec()
1325 sp->file_size=TIFFGetFileSize(tif); in OJPEGReadHeaderInfoSec()
1326 if (sp->jpeg_interchange_format!=0) in OJPEGReadHeaderInfoSec()
1328 if (sp->jpeg_interchange_format>=sp->file_size) in OJPEGReadHeaderInfoSec()
1330 sp->jpeg_interchange_format=0; in OJPEGReadHeaderInfoSec()
1331 sp->jpeg_interchange_format_length=0; in OJPEGReadHeaderInfoSec()
1335 if ((sp->jpeg_interchange_format_length==0) || in OJPEGReadHeaderInfoSec()
1336 … (sp->jpeg_interchange_format > TIFF_UINT64_MAX - sp->jpeg_interchange_format_length) || in OJPEGReadHeaderInfoSec()
1337 … (sp->jpeg_interchange_format+sp->jpeg_interchange_format_length>sp->file_size)) in OJPEGReadHeaderInfoSec()
1338 sp->jpeg_interchange_format_length=sp->file_size-sp->jpeg_interchange_format; in OJPEGReadHeaderInfoSec()
1341 sp->in_buffer_source=osibsNotSetYet; in OJPEGReadHeaderInfoSec()
1342 sp->in_buffer_next_strile=0; in OJPEGReadHeaderInfoSec()
1343 sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; in OJPEGReadHeaderInfoSec()
1344 sp->in_buffer_file_togo=0; in OJPEGReadHeaderInfoSec()
1345 sp->in_buffer_togo=0; in OJPEGReadHeaderInfoSec()
1348 if (OJPEGReadBytePeek(sp,&m)==0) in OJPEGReadHeaderInfoSec()
1352 OJPEGReadByteAdvance(sp); in OJPEGReadHeaderInfoSec()
1355 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadHeaderInfoSec()
1381 if (OJPEGReadWord(sp,&n)==0) in OJPEGReadHeaderInfoSec()
1385 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSec()
1390 OJPEGReadSkip(sp,n-2); in OJPEGReadHeaderInfoSec()
1409 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSec()
1413 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSec()
1415 assert(sp->plane_sample_offset==0); in OJPEGReadHeaderInfoSec()
1424 if (sp->subsamplingcorrect) in OJPEGReadHeaderInfoSec()
1426 if (sp->sof_log==0) in OJPEGReadHeaderInfoSec()
1430 sp->sof_marker_id=JPEG_MARKER_SOF0; in OJPEGReadHeaderInfoSec()
1431 for (o=0; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1432 sp->sof_c[o]=o; in OJPEGReadHeaderInfoSec()
1433 sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); in OJPEGReadHeaderInfoSec()
1434 for (o=1; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1435 sp->sof_hv[o]=17; in OJPEGReadHeaderInfoSec()
1436 sp->sof_x=sp->strile_width; in OJPEGReadHeaderInfoSec()
1437 sp->sof_y=sp->strile_length_total; in OJPEGReadHeaderInfoSec()
1438 sp->sof_log=1; in OJPEGReadHeaderInfoSec()
1443 for (o=1; o<sp->samples_per_pixel; o++) in OJPEGReadHeaderInfoSec()
1444 sp->sos_cs[o]=o; in OJPEGReadHeaderInfoSec()
1455 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDri() local
1457 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDri()
1464 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDri()
1466 sp->restart_interval=m; in OJPEGReadHeaderInfoSecStreamDri()
1475 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDqt() local
1480 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDqt()
1484 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamDqt()
1488 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamDqt()
1489 OJPEGReadSkip(sp,m-2); in OJPEGReadHeaderInfoSecStreamDqt()
1512 if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0) { in OJPEGReadHeaderInfoSecStreamDqt()
1523 if (sp->qtable[o]!=0) in OJPEGReadHeaderInfoSecStreamDqt()
1524 _TIFFfree(sp->qtable[o]); in OJPEGReadHeaderInfoSecStreamDqt()
1525 sp->qtable[o]=nb; in OJPEGReadHeaderInfoSecStreamDqt()
1538 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamDht() local
1543 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamDht()
1547 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamDht()
1551 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamDht()
1553 OJPEGReadSkip(sp,m-2); in OJPEGReadHeaderInfoSecStreamDht()
1569 if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0) { in OJPEGReadHeaderInfoSecStreamDht()
1582 if (sp->dctable[o]!=0) in OJPEGReadHeaderInfoSecStreamDht()
1583 _TIFFfree(sp->dctable[o]); in OJPEGReadHeaderInfoSecStreamDht()
1584 sp->dctable[o]=nb; in OJPEGReadHeaderInfoSecStreamDht()
1601 if (sp->actable[o]!=0) in OJPEGReadHeaderInfoSecStreamDht()
1602 _TIFFfree(sp->actable[o]); in OJPEGReadHeaderInfoSecStreamDht()
1603 sp->actable[o]=nb; in OJPEGReadHeaderInfoSecStreamDht()
1614 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamSof() local
1620 if (sp->sof_log!=0) in OJPEGReadHeaderInfoSecStreamSof()
1625 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1626 sp->sof_marker_id=marker_id; in OJPEGReadHeaderInfoSecStreamSof()
1628 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamSof()
1632 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1639 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1644 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1646 if (n!=sp->samples_per_pixel) in OJPEGReadHeaderInfoSecStreamSof()
1653 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1657 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1662 if (sp->subsamplingcorrect) in OJPEGReadHeaderInfoSecStreamSof()
1663 OJPEGReadSkip(sp,4); in OJPEGReadHeaderInfoSecStreamSof()
1667 if (OJPEGReadWord(sp,&p)==0) in OJPEGReadHeaderInfoSecStreamSof()
1669 if (((uint32)p<sp->image_length) && ((uint32)p<sp->strile_length_total)) in OJPEGReadHeaderInfoSecStreamSof()
1674 sp->sof_y=p; in OJPEGReadHeaderInfoSecStreamSof()
1676 if (OJPEGReadWord(sp,&p)==0) in OJPEGReadHeaderInfoSecStreamSof()
1678 if (((uint32)p<sp->image_width) && ((uint32)p<sp->strile_width)) in OJPEGReadHeaderInfoSecStreamSof()
1683 if ((uint32)p>sp->strile_width) in OJPEGReadHeaderInfoSecStreamSof()
1688 sp->sof_x=p; in OJPEGReadHeaderInfoSecStreamSof()
1691 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1695 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1704 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1706 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1707 sp->sof_c[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1709 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1711 if (sp->subsamplingcorrect!=0) in OJPEGReadHeaderInfoSecStreamSof()
1715 sp->subsampling_hor=(o>>4); in OJPEGReadHeaderInfoSecStreamSof()
1716 sp->subsampling_ver=(o&15); in OJPEGReadHeaderInfoSecStreamSof()
1717 if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || in OJPEGReadHeaderInfoSecStreamSof()
1718 ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) in OJPEGReadHeaderInfoSecStreamSof()
1719 sp->subsampling_force_desubsampling_inside_decompression=1; in OJPEGReadHeaderInfoSecStreamSof()
1724 sp->subsampling_force_desubsampling_inside_decompression=1; in OJPEGReadHeaderInfoSecStreamSof()
1729 sp->sof_hv[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1730 if (sp->subsampling_force_desubsampling_inside_decompression==0) in OJPEGReadHeaderInfoSecStreamSof()
1734 if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver)) in OJPEGReadHeaderInfoSecStreamSof()
1751 if (OJPEGReadByte(sp,&o)==0) in OJPEGReadHeaderInfoSecStreamSof()
1753 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1754 sp->sof_tq[q]=o; in OJPEGReadHeaderInfoSecStreamSof()
1756 if (sp->subsamplingcorrect==0) in OJPEGReadHeaderInfoSecStreamSof()
1757 sp->sof_log=1; in OJPEGReadHeaderInfoSecStreamSof()
1766 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecStreamSos() local
1770 assert(sp->subsamplingcorrect==0); in OJPEGReadHeaderInfoSecStreamSos()
1771 if (sp->sof_log==0) in OJPEGReadHeaderInfoSecStreamSos()
1777 if (OJPEGReadWord(sp,&m)==0) in OJPEGReadHeaderInfoSecStreamSos()
1779 if (m!=6+sp->samples_per_pixel_per_plane*2) in OJPEGReadHeaderInfoSecStreamSos()
1785 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1787 if (n!=sp->samples_per_pixel_per_plane) in OJPEGReadHeaderInfoSecStreamSos()
1793 for (o=0; o<sp->samples_per_pixel_per_plane; o++) in OJPEGReadHeaderInfoSecStreamSos()
1796 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1798 sp->sos_cs[sp->plane_sample_offset+o]=n; in OJPEGReadHeaderInfoSecStreamSos()
1800 if (OJPEGReadByte(sp,&n)==0) in OJPEGReadHeaderInfoSecStreamSos()
1802 sp->sos_tda[sp->plane_sample_offset+o]=n; in OJPEGReadHeaderInfoSecStreamSos()
1805 OJPEGReadSkip(sp,3); in OJPEGReadHeaderInfoSecStreamSos()
1813 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesQTable() local
1819 if (sp->qtable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesQTable()
1824 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesQTable()
1825 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesQTable()
1827 if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesQTable()
1831 if (sp->qtable_offset[m]==sp->qtable_offset[n]) in OJPEGReadHeaderInfoSecTablesQTable()
1850 TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesQTable()
1857 if (sp->qtable[m]!=0) in OJPEGReadHeaderInfoSecTablesQTable()
1858 _TIFFfree(sp->qtable[m]); in OJPEGReadHeaderInfoSecTablesQTable()
1859 sp->qtable[m]=ob; in OJPEGReadHeaderInfoSecTablesQTable()
1860 sp->sof_tq[m]=m; in OJPEGReadHeaderInfoSecTablesQTable()
1863 sp->sof_tq[m]=sp->sof_tq[m-1]; in OJPEGReadHeaderInfoSecTablesQTable()
1872 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesDcTable() local
1880 if (sp->dctable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesDcTable()
1885 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesDcTable()
1886 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesDcTable()
1888 if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesDcTable()
1892 if (sp->dctable_offset[m]==sp->dctable_offset[n]) in OJPEGReadHeaderInfoSecTablesDcTable()
1898 TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesDcTable()
1926 if (sp->dctable[m]!=0) in OJPEGReadHeaderInfoSecTablesDcTable()
1927 _TIFFfree(sp->dctable[m]); in OJPEGReadHeaderInfoSecTablesDcTable()
1928 sp->dctable[m]=rb; in OJPEGReadHeaderInfoSecTablesDcTable()
1929 sp->sos_tda[m]=(m<<4); in OJPEGReadHeaderInfoSecTablesDcTable()
1932 sp->sos_tda[m]=sp->sos_tda[m-1]; in OJPEGReadHeaderInfoSecTablesDcTable()
1941 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGReadHeaderInfoSecTablesAcTable() local
1949 if (sp->actable_offset[0]==0) in OJPEGReadHeaderInfoSecTablesAcTable()
1954 sp->in_buffer_file_pos_log=0; in OJPEGReadHeaderInfoSecTablesAcTable()
1955 for (m=0; m<sp->samples_per_pixel; m++) in OJPEGReadHeaderInfoSecTablesAcTable()
1957 if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1]))) in OJPEGReadHeaderInfoSecTablesAcTable()
1961 if (sp->actable_offset[m]==sp->actable_offset[n]) in OJPEGReadHeaderInfoSecTablesAcTable()
1967 TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); in OJPEGReadHeaderInfoSecTablesAcTable()
1995 if (sp->actable[m]!=0) in OJPEGReadHeaderInfoSecTablesAcTable()
1996 _TIFFfree(sp->actable[m]); in OJPEGReadHeaderInfoSecTablesAcTable()
1997 sp->actable[m]=rb; in OJPEGReadHeaderInfoSecTablesAcTable()
1998 sp->sos_tda[m]=(sp->sos_tda[m]|m); in OJPEGReadHeaderInfoSecTablesAcTable()
2001 sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15)); in OJPEGReadHeaderInfoSecTablesAcTable()
2007 OJPEGReadBufferFill(OJPEGState* sp) in OJPEGReadBufferFill() argument
2015 if (sp->in_buffer_file_togo!=0) in OJPEGReadBufferFill()
2017 if (sp->in_buffer_file_pos_log==0) in OJPEGReadBufferFill()
2019 TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET); in OJPEGReadBufferFill()
2020 sp->in_buffer_file_pos_log=1; in OJPEGReadBufferFill()
2023 if ((uint64)m>sp->in_buffer_file_togo) in OJPEGReadBufferFill()
2024 m=(uint16)sp->in_buffer_file_togo; in OJPEGReadBufferFill()
2025 n=TIFFReadFile(sp->tif,sp->in_buffer,(tmsize_t)m); in OJPEGReadBufferFill()
2031 assert((uint64)n<=sp->in_buffer_file_togo); in OJPEGReadBufferFill()
2033 sp->in_buffer_togo=m; in OJPEGReadBufferFill()
2034 sp->in_buffer_cur=sp->in_buffer; in OJPEGReadBufferFill()
2035 sp->in_buffer_file_togo-=m; in OJPEGReadBufferFill()
2036 sp->in_buffer_file_pos+=m; in OJPEGReadBufferFill()
2039 sp->in_buffer_file_pos_log=0; in OJPEGReadBufferFill()
2040 switch(sp->in_buffer_source) in OJPEGReadBufferFill()
2043 if (sp->jpeg_interchange_format!=0) in OJPEGReadBufferFill()
2045 sp->in_buffer_file_pos=sp->jpeg_interchange_format; in OJPEGReadBufferFill()
2046 sp->in_buffer_file_togo=sp->jpeg_interchange_format_length; in OJPEGReadBufferFill()
2048 sp->in_buffer_source=osibsJpegInterchangeFormat; in OJPEGReadBufferFill()
2051 sp->in_buffer_source=osibsStrile; in OJPEGReadBufferFill()
2054 if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) in OJPEGReadBufferFill()
2055 sp->in_buffer_source=osibsEof; in OJPEGReadBufferFill()
2059 sp->in_buffer_file_pos=TIFFGetStrileOffsetWithErr(sp->tif, sp->in_buffer_next_strile, &err); in OJPEGReadBufferFill()
2062 if (sp->in_buffer_file_pos!=0) in OJPEGReadBufferFill()
2064 uint64 bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err); in OJPEGReadBufferFill()
2067 if (sp->in_buffer_file_pos>=sp->file_size) in OJPEGReadBufferFill()
2068 sp->in_buffer_file_pos=0; in OJPEGReadBufferFill()
2070 sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; in OJPEGReadBufferFill()
2073 sp->in_buffer_file_togo=bytecount; in OJPEGReadBufferFill()
2074 if (sp->in_buffer_file_togo==0) in OJPEGReadBufferFill()
2075 sp->in_buffer_file_pos=0; in OJPEGReadBufferFill()
2076 else if (sp->in_buffer_file_pos > TIFF_UINT64_MAX - sp->in_buffer_file_togo || in OJPEGReadBufferFill()
2077sp->in_buffer_file_pos+sp->in_buffer_file_togo>sp->file_size) in OJPEGReadBufferFill()
2078 sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; in OJPEGReadBufferFill()
2081 sp->in_buffer_next_strile++; in OJPEGReadBufferFill()
2092 OJPEGReadByte(OJPEGState* sp, uint8* byte) in OJPEGReadByte() argument
2094 if (sp->in_buffer_togo==0) in OJPEGReadByte()
2096 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadByte()
2098 assert(sp->in_buffer_togo>0); in OJPEGReadByte()
2100 *byte=*(sp->in_buffer_cur); in OJPEGReadByte()
2101 sp->in_buffer_cur++; in OJPEGReadByte()
2102 sp->in_buffer_togo--; in OJPEGReadByte()
2107 OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) in OJPEGReadBytePeek() argument
2109 if (sp->in_buffer_togo==0) in OJPEGReadBytePeek()
2111 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadBytePeek()
2113 assert(sp->in_buffer_togo>0); in OJPEGReadBytePeek()
2115 *byte=*(sp->in_buffer_cur); in OJPEGReadBytePeek()
2120 OJPEGReadByteAdvance(OJPEGState* sp) in OJPEGReadByteAdvance() argument
2122 assert(sp->in_buffer_togo>0); in OJPEGReadByteAdvance()
2123 sp->in_buffer_cur++; in OJPEGReadByteAdvance()
2124 sp->in_buffer_togo--; in OJPEGReadByteAdvance()
2128 OJPEGReadWord(OJPEGState* sp, uint16* word) in OJPEGReadWord() argument
2131 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadWord()
2134 if (OJPEGReadByte(sp,&m)==0) in OJPEGReadWord()
2141 OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) in OJPEGReadBlock() argument
2151 if (sp->in_buffer_togo==0) in OJPEGReadBlock()
2153 if (OJPEGReadBufferFill(sp)==0) in OJPEGReadBlock()
2155 assert(sp->in_buffer_togo>0); in OJPEGReadBlock()
2158 if (n>sp->in_buffer_togo) in OJPEGReadBlock()
2159 n=sp->in_buffer_togo; in OJPEGReadBlock()
2160 _TIFFmemcpy(mmem,sp->in_buffer_cur,n); in OJPEGReadBlock()
2161 sp->in_buffer_cur+=n; in OJPEGReadBlock()
2162 sp->in_buffer_togo-=n; in OJPEGReadBlock()
2170 OJPEGReadSkip(OJPEGState* sp, uint16 len) in OJPEGReadSkip() argument
2176 if (n>sp->in_buffer_togo) in OJPEGReadSkip()
2177 n=sp->in_buffer_togo; in OJPEGReadSkip()
2178 sp->in_buffer_cur+=n; in OJPEGReadSkip()
2179 sp->in_buffer_togo-=n; in OJPEGReadSkip()
2183 assert(sp->in_buffer_togo==0); in OJPEGReadSkip()
2185 if ((uint64)n>sp->in_buffer_file_togo) in OJPEGReadSkip()
2186 n=(uint16)sp->in_buffer_file_togo; in OJPEGReadSkip()
2187 sp->in_buffer_file_pos+=n; in OJPEGReadSkip()
2188 sp->in_buffer_file_togo-=n; in OJPEGReadSkip()
2189 sp->in_buffer_file_pos_log=0; in OJPEGReadSkip()
2202 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStream() local
2206 assert(sp->out_state<=ososEoi); in OJPEGWriteStream()
2207 switch(sp->out_state) in OJPEGWriteStream()
2275 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSoi() local
2277 sp->out_buffer[0]=255; in OJPEGWriteStreamSoi()
2278 sp->out_buffer[1]=JPEG_MARKER_SOI; in OJPEGWriteStreamSoi()
2280 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSoi()
2281 sp->out_state++; in OJPEGWriteStreamSoi()
2287 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamQTable() local
2288 if (sp->qtable[table_index]!=0) in OJPEGWriteStreamQTable()
2290 *mem=(void*)(sp->qtable[table_index]+sizeof(uint32)); in OJPEGWriteStreamQTable()
2291 *len=*((uint32*)sp->qtable[table_index])-sizeof(uint32); in OJPEGWriteStreamQTable()
2293 sp->out_state++; in OJPEGWriteStreamQTable()
2299 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamDcTable() local
2300 if (sp->dctable[table_index]!=0) in OJPEGWriteStreamDcTable()
2302 *mem=(void*)(sp->dctable[table_index]+sizeof(uint32)); in OJPEGWriteStreamDcTable()
2303 *len=*((uint32*)sp->dctable[table_index])-sizeof(uint32); in OJPEGWriteStreamDcTable()
2305 sp->out_state++; in OJPEGWriteStreamDcTable()
2311 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamAcTable() local
2312 if (sp->actable[table_index]!=0) in OJPEGWriteStreamAcTable()
2314 *mem=(void*)(sp->actable[table_index]+sizeof(uint32)); in OJPEGWriteStreamAcTable()
2315 *len=*((uint32*)sp->actable[table_index])-sizeof(uint32); in OJPEGWriteStreamAcTable()
2317 sp->out_state++; in OJPEGWriteStreamAcTable()
2323 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamDri() local
2325 if (sp->restart_interval!=0) in OJPEGWriteStreamDri()
2327 sp->out_buffer[0]=255; in OJPEGWriteStreamDri()
2328 sp->out_buffer[1]=JPEG_MARKER_DRI; in OJPEGWriteStreamDri()
2329 sp->out_buffer[2]=0; in OJPEGWriteStreamDri()
2330 sp->out_buffer[3]=4; in OJPEGWriteStreamDri()
2331 sp->out_buffer[4]=(sp->restart_interval>>8); in OJPEGWriteStreamDri()
2332 sp->out_buffer[5]=(sp->restart_interval&255); in OJPEGWriteStreamDri()
2334 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamDri()
2336 sp->out_state++; in OJPEGWriteStreamDri()
2342 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSof() local
2344 assert(OJPEG_BUFFER>=2+8+sp->samples_per_pixel_per_plane*3); in OJPEGWriteStreamSof()
2345 assert(255>=8+sp->samples_per_pixel_per_plane*3); in OJPEGWriteStreamSof()
2346 sp->out_buffer[0]=255; in OJPEGWriteStreamSof()
2347 sp->out_buffer[1]=sp->sof_marker_id; in OJPEGWriteStreamSof()
2349 sp->out_buffer[2]=0; in OJPEGWriteStreamSof()
2350 sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3; in OJPEGWriteStreamSof()
2352 sp->out_buffer[4]=8; in OJPEGWriteStreamSof()
2354 sp->out_buffer[5]=(uint8)(sp->sof_y>>8); in OJPEGWriteStreamSof()
2355 sp->out_buffer[6]=(sp->sof_y&255); in OJPEGWriteStreamSof()
2357 sp->out_buffer[7]=(uint8)(sp->sof_x>>8); in OJPEGWriteStreamSof()
2358 sp->out_buffer[8]=(sp->sof_x&255); in OJPEGWriteStreamSof()
2360 sp->out_buffer[9]=sp->samples_per_pixel_per_plane; in OJPEGWriteStreamSof()
2361 for (m=0; m<sp->samples_per_pixel_per_plane; m++) in OJPEGWriteStreamSof()
2364 sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2366 sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2368 sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m]; in OJPEGWriteStreamSof()
2370 *len=10+sp->samples_per_pixel_per_plane*3; in OJPEGWriteStreamSof()
2371 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSof()
2372 sp->out_state++; in OJPEGWriteStreamSof()
2378 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamSos() local
2380 assert(OJPEG_BUFFER>=2+6+sp->samples_per_pixel_per_plane*2); in OJPEGWriteStreamSos()
2381 assert(255>=6+sp->samples_per_pixel_per_plane*2); in OJPEGWriteStreamSos()
2382 sp->out_buffer[0]=255; in OJPEGWriteStreamSos()
2383 sp->out_buffer[1]=JPEG_MARKER_SOS; in OJPEGWriteStreamSos()
2385 sp->out_buffer[2]=0; in OJPEGWriteStreamSos()
2386 sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2; in OJPEGWriteStreamSos()
2388 sp->out_buffer[4]=sp->samples_per_pixel_per_plane; in OJPEGWriteStreamSos()
2389 for (m=0; m<sp->samples_per_pixel_per_plane; m++) in OJPEGWriteStreamSos()
2392 sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m]; in OJPEGWriteStreamSos()
2394 sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m]; in OJPEGWriteStreamSos()
2397 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0; in OJPEGWriteStreamSos()
2399 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63; in OJPEGWriteStreamSos()
2401 sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0; in OJPEGWriteStreamSos()
2402 *len=8+sp->samples_per_pixel_per_plane*2; in OJPEGWriteStreamSos()
2403 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamSos()
2404 sp->out_state++; in OJPEGWriteStreamSos()
2410 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamCompressed() local
2411 if (sp->in_buffer_togo==0) in OJPEGWriteStreamCompressed()
2413 if (OJPEGReadBufferFill(sp)==0) in OJPEGWriteStreamCompressed()
2415 assert(sp->in_buffer_togo>0); in OJPEGWriteStreamCompressed()
2417 *len=sp->in_buffer_togo; in OJPEGWriteStreamCompressed()
2418 *mem=(void*)sp->in_buffer_cur; in OJPEGWriteStreamCompressed()
2419 sp->in_buffer_togo=0; in OJPEGWriteStreamCompressed()
2420 if (sp->in_buffer_file_togo==0) in OJPEGWriteStreamCompressed()
2422 switch(sp->in_buffer_source) in OJPEGWriteStreamCompressed()
2425 if (sp->in_buffer_next_strile<sp->in_buffer_strile_count) in OJPEGWriteStreamCompressed()
2426 sp->out_state=ososRst; in OJPEGWriteStreamCompressed()
2428 sp->out_state=ososEoi; in OJPEGWriteStreamCompressed()
2431 sp->out_state=ososEoi; in OJPEGWriteStreamCompressed()
2443 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamRst() local
2445 sp->out_buffer[0]=255; in OJPEGWriteStreamRst()
2446 sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index; in OJPEGWriteStreamRst()
2447 sp->restart_index++; in OJPEGWriteStreamRst()
2448 if (sp->restart_index==8) in OJPEGWriteStreamRst()
2449 sp->restart_index=0; in OJPEGWriteStreamRst()
2451 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamRst()
2452 sp->out_state=ososCompressed; in OJPEGWriteStreamRst()
2458 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGWriteStreamEoi() local
2460 sp->out_buffer[0]=255; in OJPEGWriteStreamEoi()
2461 sp->out_buffer[1]=JPEG_MARKER_EOI; in OJPEGWriteStreamEoi()
2463 *mem=(void*)sp->out_buffer; in OJPEGWriteStreamEoi()
2468 jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) in jpeg_create_decompress_encap() argument
2470 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_create_decompress_encap()
2481 jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) in jpeg_read_header_encap() argument
2483 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_read_header_encap()
2494 jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) in jpeg_start_decompress_encap() argument
2496 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_start_decompress_encap()
2507 jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 ma… in jpeg_read_scanlines_encap() argument
2509 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_read_scanlines_encap()
2520 jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_line… in jpeg_read_raw_data_encap() argument
2522 if( SETJMP(sp->exit_jmpbuf) ) in jpeg_read_raw_data_encap()
2535 OJPEGState* sp=(OJPEGState*)tif->tif_data; in jpeg_encap_unwind() local
2536 LONGJMP(sp->exit_jmpbuf,1); in jpeg_encap_unwind()
2567 OJPEGState* sp=(OJPEGState*)tif->tif_data; in OJPEGLibjpegJpegSourceMgrFillInputBuffer() local
2575 sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len; in OJPEGLibjpegJpegSourceMgrFillInputBuffer()
2576 sp->libjpeg_jpeg_source_mgr.next_input_byte=mem; in OJPEGLibjpegJpegSourceMgrFillInputBuffer()