1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Graphics: Import JPEG library code

This commit is contained in:
Oli 2025-06-12 11:37:39 +01:00 committed by Oliver James
parent 7f00a8bcb4
commit 34c8704a25
91 changed files with 19041 additions and 7044 deletions

View file

@ -1890,14 +1890,16 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -1905,25 +1907,24 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -1935,7 +1936,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -1947,8 +1947,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"
@ -4553,14 +4551,16 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -4568,25 +4568,24 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -4598,7 +4597,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -4610,8 +4608,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"

View file

@ -2202,12 +2202,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2238,9 +2244,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2256,6 +2259,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2286,9 +2295,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2319,9 +2325,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2337,9 +2340,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -4406,10 +4406,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -4417,7 +4416,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2965,12 +2965,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3001,9 +3007,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3019,6 +3022,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3049,9 +3058,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3082,9 +3088,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3100,9 +3103,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -7512,7 +7512,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -7521,9 +7521,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -7545,9 +7542,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -2202,12 +2202,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2238,9 +2244,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2256,6 +2259,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2286,9 +2295,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2319,9 +2325,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2337,9 +2340,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -4406,10 +4406,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -4417,7 +4416,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2965,12 +2965,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3001,9 +3007,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3019,6 +3022,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3049,9 +3058,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3082,9 +3088,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -3100,9 +3103,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -7512,7 +7512,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -7521,9 +7521,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -7545,9 +7542,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1652,14 +1652,16 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -1667,25 +1669,24 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -1697,7 +1698,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -1709,8 +1709,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"
@ -3929,14 +3927,16 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -3944,25 +3944,24 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -3974,7 +3973,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -3986,8 +3984,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"

View file

@ -1893,12 +1893,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1929,9 +1935,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1947,6 +1950,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1977,9 +1986,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2010,9 +2016,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2028,9 +2031,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -3819,10 +3819,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -3830,7 +3829,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2473,12 +2473,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2509,9 +2515,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2527,6 +2530,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2557,9 +2566,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2590,9 +2596,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2608,9 +2611,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -6471,7 +6471,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -6480,9 +6480,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -6504,9 +6501,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1782,14 +1782,16 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -1797,25 +1799,24 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -1827,7 +1828,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -1839,8 +1839,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"
@ -4212,14 +4210,16 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -4227,25 +4227,24 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -4257,7 +4256,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -4269,8 +4267,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"

View file

@ -2027,12 +2027,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2063,9 +2069,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2081,6 +2084,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2111,9 +2120,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2144,9 +2150,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2162,9 +2165,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -4052,10 +4052,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -4063,7 +4062,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2680,12 +2680,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2716,9 +2722,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2734,6 +2737,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2764,9 +2773,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2797,9 +2803,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2815,9 +2818,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -6906,7 +6906,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -6915,9 +6915,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -6939,9 +6936,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -2027,12 +2027,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2063,9 +2069,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2081,6 +2084,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2111,9 +2120,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2144,9 +2150,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2162,9 +2165,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -4052,10 +4052,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -4063,7 +4062,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2680,12 +2680,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2716,9 +2722,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2734,6 +2737,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2764,9 +2773,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2797,9 +2803,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2815,9 +2818,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -6906,7 +6906,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -6915,9 +6915,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -6939,9 +6936,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1671,14 +1671,16 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -1686,25 +1688,24 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -1716,7 +1717,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -1728,8 +1728,6 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"
@ -4028,14 +4026,16 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp" "../../../../../modules/juce_graphics/geometry/juce_Rectangle_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_RectangleList.h" "../../../../../modules/juce_graphics/geometry/juce_RectangleList.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h" "../../../../../modules/juce_graphics/image_formats/jpglib/cderror.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/cdjpeg.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt" "../../../../../modules/juce_graphics/image_formats/jpglib/changes to libjpeg for JUCE.txt"
"../../../../../modules/juce_graphics/image_formats/jpglib/jaricom.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jccolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcdctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jchuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcinit.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcmarker.c"
@ -4043,25 +4043,24 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcomapi.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jconfig.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcparam.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcprepct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jcsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jctrans.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapimin.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdapistd.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdarith.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatadst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdatasrc.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcoefct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdcolor.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jdct.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jddctmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdhuff.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdinput.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmainct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmarker.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmaster.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdmerge.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdphuff.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdpostct.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdsample.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jdtrans.c"
@ -4073,7 +4072,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctflt.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctfst.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jidctint.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jidctred.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jinclude.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemmgr.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jmemnobs.c"
@ -4085,8 +4083,6 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jquant2.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c" "../../../../../modules/juce_graphics/image_formats/jpglib/jutils.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h" "../../../../../modules/juce_graphics/image_formats/jpglib/jversion.h"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.c"
"../../../../../modules/juce_graphics/image_formats/jpglib/transupp.h"
"../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt" "../../../../../modules/juce_graphics/image_formats/pnglib/libpng_readme.txt"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.c" "../../../../../modules/juce_graphics/image_formats/pnglib/png.c"
"../../../../../modules/juce_graphics/image_formats/pnglib/png.h" "../../../../../modules/juce_graphics/image_formats/pnglib/png.h"

View file

@ -1914,12 +1914,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1950,9 +1956,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1968,6 +1971,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1998,9 +2007,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2031,9 +2037,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2049,9 +2052,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -3917,10 +3917,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -3928,7 +3927,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2527,12 +2527,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2563,9 +2569,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2581,6 +2584,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2611,9 +2620,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2644,9 +2650,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2662,9 +2665,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -6633,7 +6633,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -6642,9 +6642,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -6666,9 +6663,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1059,12 +1059,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1095,9 +1101,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1113,6 +1116,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1143,9 +1152,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1176,9 +1182,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1194,9 +1197,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2617,10 +2617,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -2628,7 +2627,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -1381,12 +1381,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1417,9 +1423,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1435,6 +1438,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1465,9 +1474,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1498,9 +1504,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1516,9 +1519,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -4281,7 +4281,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -4290,9 +4290,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -4314,9 +4311,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1059,12 +1059,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1095,9 +1101,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1113,6 +1116,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1143,9 +1152,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1176,9 +1182,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1194,9 +1197,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2617,10 +2617,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -2628,7 +2627,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -1381,12 +1381,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1417,9 +1423,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1435,6 +1438,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1465,9 +1474,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1498,9 +1504,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -1516,9 +1519,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -4281,7 +4281,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -4290,9 +4290,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -4314,9 +4311,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -2035,12 +2035,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2071,9 +2077,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2089,6 +2092,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2119,9 +2128,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2152,9 +2158,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2170,9 +2173,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -4164,10 +4164,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -4175,7 +4174,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2728,12 +2728,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2764,9 +2770,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2782,6 +2785,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2812,9 +2821,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2845,9 +2851,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2863,9 +2866,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -7065,7 +7065,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -7074,9 +7074,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -7098,9 +7095,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -2035,12 +2035,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2071,9 +2077,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2089,6 +2092,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2119,9 +2128,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2152,9 +2158,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2170,9 +2173,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -4164,10 +4164,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -4175,7 +4174,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2728,12 +2728,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2764,9 +2770,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2782,6 +2785,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2812,9 +2821,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2845,9 +2851,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2863,9 +2866,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -7065,7 +7065,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -7074,9 +7074,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -7098,9 +7095,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1913,12 +1913,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1949,9 +1955,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1967,6 +1970,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -1997,9 +2006,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2030,9 +2036,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -2048,9 +2051,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<ExcludedFromBuild>true</ExcludedFromBuild> <ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile> </ClCompile>
@ -3893,10 +3893,9 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\geometry\juce_RectangleList.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jinclude.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemsys.h"/>
@ -3904,7 +3903,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpegint.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jpeglib.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngconf.h"/>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\pngdebug.h"/>

View file

@ -2524,12 +2524,18 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp"> <ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Rectangle_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter> <Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jaricom.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapimin.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jccoefct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2560,9 +2566,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcparam.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jcprepct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2578,6 +2581,12 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdapistd.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdarith.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatadst.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdatasrc.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2608,9 +2617,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdmerge.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdphuff.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdpostct.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2641,9 +2647,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctint.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jidctred.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jmemmgr.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
@ -2659,9 +2662,6 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jutils.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.c">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c"> <ClCompile Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.c">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClCompile> </ClCompile>
@ -6600,7 +6600,7 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cderror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jchuff.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\cdjpeg.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jconfig.h">
@ -6609,9 +6609,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdct.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jdhuff.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jerror.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
@ -6633,9 +6630,6 @@
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\jversion.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\jpglib\transupp.h">
<Filter>JUCE Modules\juce_graphics\image_formats\jpglib</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h"> <ClInclude Include="..\..\..\..\modules\juce_graphics\image_formats\pnglib\png.h">
<Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter> <Filter>JUCE Modules\juce_graphics\image_formats\pnglib</Filter>
</ClInclude> </ClInclude>

View file

@ -1,385 +1,374 @@
The Independent JPEG Group's JPEG software The Independent JPEG Group's JPEG software
========================================== ==========================================
README for release 6b of 27-Mar-1998 README for release 9f of 14-Jan-2024
==================================== ====================================
This distribution contains the sixth public release of the Independent JPEG This distribution contains the ninth public release of the Independent JPEG
Group's free JPEG software. You are welcome to redistribute this software and Group's free JPEG software. You are welcome to redistribute this software and
to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. to use it for any purpose, subject to the conditions under LEGAL ISSUES, below.
Serious users of this software (particularly those incorporating it into This software is the work of Tom Lane, Guido Vollbeding, Philip Gladstone,
larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to Bill Allombert, Jim Boucher, Lee Crocker, Bob Friesenhahn, Ben Jackson,
our electronic mailing list. Mailing list members are notified of updates John Korejwa, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi,
and have a chance to participate in technical discussions, etc. Ge' Weijers, and other members of the Independent JPEG Group.
This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, IJG is not affiliated with the ISO/IEC JTC1/SC29/WG1 standards committee
Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, (previously known as JPEG, together with ITU-T SG16).
Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG
Group.
DOCUMENTATION ROADMAP
IJG is not affiliated with the official ISO JPEG standards committee. =====================
This file contains the following sections:
DOCUMENTATION ROADMAP
===================== OVERVIEW General description of JPEG and the IJG software.
LEGAL ISSUES Copyright, lack of warranty, terms of distribution.
This file contains the following sections: REFERENCES Where to learn more about JPEG.
ARCHIVE LOCATIONS Where to find newer versions of this software.
OVERVIEW General description of JPEG and the IJG software. ACKNOWLEDGMENTS Special thanks.
LEGAL ISSUES Copyright, lack of warranty, terms of distribution. FILE FORMAT WARS Software *not* to get.
REFERENCES Where to learn more about JPEG. TO DO Plans for future IJG releases.
ARCHIVE LOCATIONS Where to find newer versions of this software.
RELATED SOFTWARE Other stuff you should get. Other documentation files in the distribution are:
FILE FORMAT WARS Software *not* to get.
TO DO Plans for future IJG releases. User documentation:
install.txt How to configure and install the IJG software.
Other documentation files in the distribution are: usage.txt Usage instructions for cjpeg, djpeg, jpegtran,
rdjpgcom, and wrjpgcom.
User documentation: *.1 Unix-style man pages for programs (same info as usage.txt).
install.doc How to configure and install the IJG software. wizard.txt Advanced usage instructions for JPEG wizards only.
usage.doc Usage instructions for cjpeg, djpeg, jpegtran, cdaltui.txt Description of alternate user interface for cjpeg/djpeg.
rdjpgcom, and wrjpgcom. change.log Version-to-version change highlights.
*.1 Unix-style man pages for programs (same info as usage.doc). Programmer and internal documentation:
wizard.doc Advanced usage instructions for JPEG wizards only. libjpeg.txt How to use the JPEG library in your own programs.
change.log Version-to-version change highlights. example.c Sample code for calling the JPEG library.
Programmer and internal documentation: structure.txt Overview of the JPEG library's internal structure.
libjpeg.doc How to use the JPEG library in your own programs. filelist.txt Road map of IJG files.
example.c Sample code for calling the JPEG library. coderules.txt Coding style rules --- please read if you contribute code.
structure.doc Overview of the JPEG library's internal structure.
filelist.doc Road map of IJG files. Please read at least the files install.txt and usage.txt. Some information
coderules.doc Coding style rules --- please read if you contribute code. can also be found in the JPEG FAQ (Frequently Asked Questions) article. See
ARCHIVE LOCATIONS below to find out where to obtain the FAQ article.
Please read at least the files install.doc and usage.doc. Useful information
can also be found in the JPEG FAQ (Frequently Asked Questions) article. See If you want to understand how the JPEG code works, we suggest reading one or
ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. more of the REFERENCES, then looking at the documentation files (in roughly
the order listed) before diving into the code.
If you want to understand how the JPEG code works, we suggest reading one or
more of the REFERENCES, then looking at the documentation files (in roughly
the order listed) before diving into the code. OVERVIEW
========
OVERVIEW This package contains C software to implement JPEG image encoding, decoding,
======== and transcoding. JPEG (pronounced "jay-peg") is a standardized compression
method for full-color and grayscale images.
This package contains C software to implement JPEG image compression and
decompression. JPEG (pronounced "jay-peg") is a standardized compression This software implements JPEG baseline, extended-sequential, and progressive
method for full-color and gray-scale images. JPEG is intended for compressing compression processes. Provision is made for supporting all variants of these
"real-world" scenes; line drawings, cartoons and other non-realistic images processes, although some uncommon parameter settings aren't implemented yet.
are not its strong suit. JPEG is lossy, meaning that the output image is not We have made no provision for supporting the hierarchical or lossless
exactly identical to the input image. Hence you must not use JPEG if you processes defined in the standard.
have to have identical output bits. However, on typical photographic images,
very good compression levels can be obtained with no visible change, and We provide a set of library routines for reading and writing JPEG image files,
remarkably high compression levels are possible if you can tolerate a plus two sample applications "cjpeg" and "djpeg", which use the library to
low-quality image. For more details, see the references, or just experiment perform conversion between JPEG and some other popular image file formats.
with various compression settings. The library is intended to be reused in other applications.
This software implements JPEG baseline, extended-sequential, and progressive In order to support file conversion and viewing software, we have included
compression processes. Provision is made for supporting all variants of these considerable functionality beyond the bare JPEG coding/decoding capability;
processes, although some uncommon parameter settings aren't implemented yet. for example, the color quantization modules are not strictly part of JPEG
For legal reasons, we are not distributing code for the arithmetic-coding decoding, but they are essential for output to colormapped file formats or
variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting colormapped displays. These extra functions can be compiled out of the
the hierarchical or lossless processes defined in the standard. library if not required for a particular application.
We provide a set of library routines for reading and writing JPEG image files, We have also included "jpegtran", a utility for lossless transcoding between
plus two sample applications "cjpeg" and "djpeg", which use the library to different JPEG processes, and "rdjpgcom" and "wrjpgcom", two simple
perform conversion between JPEG and some other popular image file formats. applications for inserting and extracting textual comments in JFIF files.
The library is intended to be reused in other applications.
The emphasis in designing this software has been on achieving portability and
In order to support file conversion and viewing software, we have included flexibility, while also making it fast enough to be useful. In particular,
considerable functionality beyond the bare JPEG coding/decoding capability; the software is not intended to be read as a tutorial on JPEG. (See the
for example, the color quantization modules are not strictly part of JPEG REFERENCES section for introductory material.) Rather, it is intended to
decoding, but they are essential for output to colormapped file formats or be reliable, portable, industrial-strength code. We do not claim to have
colormapped displays. These extra functions can be compiled out of the achieved that goal in every aspect of the software, but we strive for it.
library if not required for a particular application. We have also included
"jpegtran", a utility for lossless transcoding between different JPEG We welcome the use of this software as a component of commercial products.
processes, and "rdjpgcom" and "wrjpgcom", two simple applications for No royalty is required, but we do ask for an acknowledgement in product
inserting and extracting textual comments in JFIF files. documentation, as described under LEGAL ISSUES.
The emphasis in designing this software has been on achieving portability and
flexibility, while also making it fast enough to be useful. In particular, LEGAL ISSUES
the software is not intended to be read as a tutorial on JPEG. (See the ============
REFERENCES section for introductory material.) Rather, it is intended to
be reliable, portable, industrial-strength code. We do not claim to have In plain English:
achieved that goal in every aspect of the software, but we strive for it.
1. We don't promise that this software works. (But if you find any bugs,
We welcome the use of this software as a component of commercial products. please let us know!)
No royalty is required, but we do ask for an acknowledgement in product 2. You can use this software for whatever you want. You don't have to pay us.
documentation, as described under LEGAL ISSUES. 3. You may not pretend that you wrote this software. If you use it in a
program, you must acknowledge somewhere in your documentation that
you've used the IJG code.
LEGAL ISSUES
============ In legalese:
In plain English: The authors make NO WARRANTY or representation, either express or implied,
with respect to this software, its quality, accuracy, merchantability, or
1. We don't promise that this software works. (But if you find any bugs, fitness for a particular purpose. This software is provided "AS IS", and you,
please let us know!) its user, assume the entire risk as to its quality and accuracy.
2. You can use this software for whatever you want. You don't have to pay us.
3. You may not pretend that you wrote this software. If you use it in a This software is copyright (C) 1991-2024, Thomas G. Lane, Guido Vollbeding.
program, you must acknowledge somewhere in your documentation that All Rights Reserved except as specified below.
you've used the IJG code.
Permission is hereby granted to use, copy, modify, and distribute this
In legalese: software (or portions thereof) for any purpose, without fee, subject to these
conditions:
The authors make NO WARRANTY or representation, either express or implied, (1) If any part of the source code for this software is distributed, then this
with respect to this software, its quality, accuracy, merchantability, or README file must be included, with this copyright and no-warranty notice
fitness for a particular purpose. This software is provided "AS IS", and you, unaltered; and any additions, deletions, or changes to the original files
its user, assume the entire risk as to its quality and accuracy. must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying
This software is copyright (C) 1991-1998, Thomas G. Lane. documentation must state that "this software is based in part on the work of
All Rights Reserved except as specified below. the Independent JPEG Group".
(3) Permission for use of this software is granted only if the user accepts
Permission is hereby granted to use, copy, modify, and distribute this full responsibility for any undesirable consequences; the authors accept
software (or portions thereof) for any purpose, without fee, subject to these NO LIABILITY for damages of any kind.
conditions:
(1) If any part of the source code for this software is distributed, then this These conditions apply to any software derived from or based on the IJG code,
README file must be included, with this copyright and no-warranty notice not just to the unmodified library. If you use our work, you ought to
unaltered; and any additions, deletions, or changes to the original files acknowledge us.
must be clearly indicated in accompanying documentation.
(2) If only executable code is distributed, then the accompanying Permission is NOT granted for the use of any IJG author's name or company name
documentation must state that "this software is based in part on the work of in advertising or publicity relating to this software or products derived from
the Independent JPEG Group". it. This software may be referred to only as "the Independent JPEG Group's
(3) Permission for use of this software is granted only if the user accepts software".
full responsibility for any undesirable consequences; the authors accept
NO LIABILITY for damages of any kind. We specifically permit and encourage the use of this software as the basis of
commercial products, provided that all warranty or liability claims are
These conditions apply to any software derived from or based on the IJG code, assumed by the product vendor.
not just to the unmodified library. If you use our work, you ought to
acknowledge us.
The Unix configuration script "configure" was produced with GNU Autoconf.
Permission is NOT granted for the use of any IJG author's name or company name It is copyright by the Free Software Foundation but is freely distributable.
in advertising or publicity relating to this software or products derived from The same holds for its supporting scripts (config.guess, config.sub,
it. This software may be referred to only as "the Independent JPEG Group's ltmain.sh). Another support script, install-sh, is copyright by X Consortium
software". but is also freely distributable.
We specifically permit and encourage the use of this software as the basis of
commercial products, provided that all warranty or liability claims are REFERENCES
assumed by the product vendor. ==========
We recommend reading one or more of these references before trying to
ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, understand the innards of the JPEG software.
sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA.
ansi2knr.c is NOT covered by the above copyright and conditions, but instead The best short technical introduction to the JPEG compression algorithm is
by the usual distribution terms of the Free Software Foundation; principally, Wallace, Gregory K. "The JPEG Still Picture Compression Standard",
that you must include source code if you redistribute it. (See the file Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44.
ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part (Adjacent articles in that issue discuss MPEG motion picture compression,
of any program generated from the IJG code, this does not limit you more than applications of JPEG, and related topics.) If you don't have the CACM issue
the foregoing paragraphs do. handy, a PDF file containing a revised version of Wallace's article is
available at https://www.ijg.org/files/Wallace.JPEG.pdf. The file (actually
The Unix configuration script "configure" was produced with GNU Autoconf. a preprint for an article that appeared in IEEE Trans. Consumer Electronics)
It is copyright by the Free Software Foundation but is freely distributable. omits the sample images that appeared in CACM, but it includes corrections
The same holds for its supporting scripts (config.guess, config.sub, and some added material. Note: the Wallace article is copyright ACM and IEEE,
ltconfig, ltmain.sh). Another support script, install-sh, is copyright and it may not be used for commercial purposes.
by M.I.T. but is also freely distributable.
A somewhat less technical, more leisurely introduction to JPEG can be found in
It appears that the arithmetic coding option of the JPEG spec is covered by "The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by
patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides
legally be used without obtaining one or more licenses. For this reason, good explanations and example C code for a multitude of compression methods
support for arithmetic coding has been removed from the free JPEG software. including JPEG. It is an excellent source if you are comfortable reading C
(Since arithmetic coding provides only a marginal gain over the unpatented code but don't know much about data compression in general. The book's JPEG
Huffman mode, it is unlikely that very many implementations will support it.) sample code is far from industrial-strength, but when you are ready to look
So far as we are aware, there are no patent restrictions on the remaining at a full implementation, you've got one here...
code.
The best currently available description of JPEG is the textbook "JPEG Still
The IJG distribution formerly included code to read and write GIF files. Image Data Compression Standard" by William B. Pennebaker and Joan L.
To avoid entanglement with the Unisys LZW patent, GIF reading support has Mitchell, published by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1.
been removed altogether, and the GIF writer has been simplified to produce Price US$59.95, 638 pp. The book includes the complete text of the ISO JPEG
"uncompressed GIFs". This technique does not use the LZW algorithm; the standards (DIS 10918-1 and draft DIS 10918-2).
resulting GIF files are larger than usual, but are readable by all standard Although this is by far the most detailed and comprehensive exposition of
GIF decoders. JPEG publicly available, we point out that it is still missing an explanation
of the most essential properties and algorithms of the underlying DCT
We are required to state that technology.
"The Graphics Interchange Format(c) is the Copyright property of If you think that you know about DCT-based JPEG after reading this book,
CompuServe Incorporated. GIF(sm) is a Service Mark property of then you are in delusion. The real fundamentals and corresponding potential
CompuServe Incorporated." of DCT-based JPEG are not publicly known so far, and that is the reason for
all the mistaken developments taking place in the image coding domain.
REFERENCES The original JPEG standard is divided into two parts, Part 1 being the actual
========== specification, while Part 2 covers compliance testing methods. Part 1 is
titled "Digital Compression and Coding of Continuous-tone Still Images,
We highly recommend reading one or more of these references before trying to Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS
understand the innards of the JPEG software. 10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of
Continuous-tone Still Images, Part 2: Compliance testing" and has document
The best short technical introduction to the JPEG compression algorithm is numbers ISO/IEC IS 10918-2, ITU-T T.83.
Wallace, Gregory K. "The JPEG Still Picture Compression Standard", IJG JPEG 8 introduced an implementation of the JPEG SmartScale extension
Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. which is specified in two documents: A contributed document at ITU and ISO
(Adjacent articles in that issue discuss MPEG motion picture compression, with title "ITU-T JPEG-Plus Proposal for Extending ITU-T T.81 for Advanced
applications of JPEG, and related topics.) If you don't have the CACM issue Image Coding", April 2006, Geneva, Switzerland. The latest version of this
handy, a PostScript file containing a revised version of Wallace's article is document is Revision 3. And a contributed document ISO/IEC JTC1/SC29/WG1 N
available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually 5799 with title "Evolution of JPEG", June/July 2011, Berlin, Germany.
a preprint for an article that appeared in IEEE Trans. Consumer Electronics) IJG JPEG 9 introduces a reversible color transform for improved lossless
omits the sample images that appeared in CACM, but it includes corrections compression which is described in a contributed document ISO/IEC JTC1/SC29/
and some added material. Note: the Wallace article is copyright ACM and IEEE, WG1 N 6080 with title "JPEG 9 Lossless Coding", June/July 2012, Paris, France.
and it may not be used for commercial purposes.
The JPEG standard does not specify all details of an interchangeable file
A somewhat less technical, more leisurely introduction to JPEG can be found in format. For the omitted details we follow the "JFIF" conventions, version 2.
"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by JFIF version 1 has been adopted as Recommendation ITU-T T.871 (05/2011) :
M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides Information technology - Digital compression and coding of continuous-tone
good explanations and example C code for a multitude of compression methods still images: JPEG File Interchange Format (JFIF). It is available as a
including JPEG. It is an excellent source if you are comfortable reading C free download in PDF file format from https://www.itu.int/rec/T-REC-T.871.
code but don't know much about data compression in general. The book's JPEG A PDF file of the older JFIF document is available at
sample code is far from industrial-strength, but when you are ready to look https://www.w3.org/Graphics/JPEG/jfif3.pdf.
at a full implementation, you've got one here...
The TIFF 6.0 file format specification can be obtained by FTP from
The best full description of JPEG is the textbook "JPEG Still Image Data ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme
Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6).
The book includes the complete text of the ISO JPEG standards (DIS 10918-1 Instead, we recommend the JPEG design proposed by TIFF Technical Note #2
and draft DIS 10918-2). This is by far the most complete exposition of JPEG (Compression tag 7). Copies of this Note can be obtained from
in existence, and we highly recommend it. https://www.ijg.org/files/. It is expected that the next revision
of the TIFF spec will replace the 6.0 JPEG design with the Note's design.
The JPEG standard itself is not available electronically; you must order a Although IJG's own code does not support TIFF/JPEG, the free libtiff library
paper copy through ISO or ITU. (Unless you feel a need to own a certified uses our library to implement TIFF/JPEG per the Note.
official copy, we recommend buying the Pennebaker and Mitchell book instead;
it's much cheaper and includes a great deal of useful explanatory material.)
In the USA, copies of the standard may be ordered from ANSI Sales at (212) ARCHIVE LOCATIONS
642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI =================
doesn't take credit card orders, but Global does.) It's not cheap: as of
1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% The "official" archive site for this software is www.ijg.org.
shipping/handling. The standard is divided into two parts, Part 1 being the The most recent released version can always be found there in
actual specification, while Part 2 covers compliance testing methods. Part 1 directory "files". This particular version will be archived
is titled "Digital Compression and Coding of Continuous-tone Still Images, in Windows-compatible "zip" archive format as
Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS https://www.ijg.org/files/jpegsr9f.zip, and
10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of in Unix-compatible "tar.gz" archive format as
Continuous-tone Still Images, Part 2: Compliance testing" and has document https://www.ijg.org/files/jpegsrc.v9f.tar.gz.
numbers ISO/IEC IS 10918-2, ITU-T T.83.
The JPEG FAQ (Frequently Asked Questions) article is a source of some
Some extensions to the original JPEG standard are defined in JPEG Part 3, general information about JPEG.
a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
currently does not support any Part 3 extensions. and other news.answers archive sites, including the official news.answers
archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/.
The JPEG standard does not specify all details of an interchangeable file If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu
format. For the omitted details we follow the "JFIF" conventions, revision with body
1.02. A copy of the JFIF spec is available from: send usenet/news.answers/jpeg-faq/part1
Literature Department send usenet/news.answers/jpeg-faq/part2
C-Cube Microsystems, Inc.
1778 McCarthy Blvd.
Milpitas, CA 95035 ACKNOWLEDGMENTS
phone (408) 944-6300, fax (408) 944-6314 ===============
A PostScript version of this document is available by FTP at
ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text Thank to Juergen Bruder for providing me with a copy of the common DCT
version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing algorithm article, only to find out that I had come to the same result
the figures. in a more direct and comprehensible way with a more generative approach.
The TIFF 6.0 file format specification can be obtained by FTP from Thank to Istvan Sebestyen and Joan L. Mitchell for inviting me to the
ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme ITU JPEG (Study Group 16) meeting in Geneva, Switzerland.
found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems.
IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). Thank to Thomas Wiegand and Gary Sullivan for inviting me to the
Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 Joint Video Team (MPEG & ITU) meeting in Geneva, Switzerland.
(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or
from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision Thank to Thomas Richter and Daniel Lee for inviting me to the
of the TIFF spec will replace the 6.0 JPEG design with the Note's design. ISO/IEC JTC1/SC29/WG1 (previously known as JPEG, together with ITU-T SG16)
Although IJG's own code does not support TIFF/JPEG, the free libtiff library meeting in Berlin, Germany.
uses our library to implement TIFF/JPEG per the Note. libtiff is available
from ftp://ftp.sgi.com/graphics/tiff/. Thank to John Korejwa and Massimo Ballerini for inviting me to
fruitful consultations in Boston, MA and Milan, Italy.
ARCHIVE LOCATIONS Thank to Hendrik Elstner, Roland Fassauer, Simone Zuck, Guenther
================= Maier-Gerber, Walter Stoeber, Fred Schmitz, and Norbert Braunagel
for corresponding business development.
The "official" archive site for this software is ftp.uu.net (Internet
address 192.48.96.9). The most recent released version can always be found Thank to Nico Zschach and Dirk Stelling of the technical support team
there in directory graphics/jpeg. This particular version will be archived at the Digital Images company in Halle for providing me with extra
as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have equipment for configuration tests.
direct Internet access, UUNET's archives are also available via UUCP; contact
help@uunet.uu.net for information on retrieving files that way. Thank to Richard F. Lyon (then of Foveon Inc.) for fruitful
communication about JPEG configuration in Sigma Photo Pro software.
Numerous Internet sites maintain copies of the UUNET files. However, only
ftp.uu.net is guaranteed to have the latest official version. Thank to Andrew Finkenstadt for hosting the ijg.org site.
You can also obtain this software in DOS-compatible "zip" archive format from Thank to Thomas G. Lane for the original design and development
the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or of this singular software package.
on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12
"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net Thank to Lars Goehler, Andreas Heinecke, Sebastian Fuss,
release. Yvonne Roebert, Andrej Werner, Ulf-Dietrich Braumann,
and Nina Ssymank for support and public relations.
The JPEG FAQ (Frequently Asked Questions) article is a useful source of
general information about JPEG. It is updated constantly and therefore is
not included in this distribution. The FAQ is posted every two weeks to FILE FORMAT WARS
Usenet newsgroups comp.graphics.misc, news.answers, and other groups. ================
It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/
and other news.answers archive sites, including the official news.answers The ISO/IEC JTC1/SC29/WG1 standards committee (previously known as JPEG,
archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. together with ITU-T SG16) currently promotes different formats containing
If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu the name "JPEG" which is misleading because these formats are incompatible
with body with original DCT-based JPEG and are based on faulty technologies.
send usenet/news.answers/jpeg-faq/part1 IJG therefore does not and will not support such momentary mistakes
send usenet/news.answers/jpeg-faq/part2 (see REFERENCES).
There exist also distributions under the name "OpenJPEG" promoting such
kind of formats which is misleading because they don't support original
RELATED SOFTWARE JPEG images.
================ We have no sympathy for the promotion of inferior formats. Indeed, one of
the original reasons for developing this free software was to help force
Numerous viewing and image manipulation programs now support JPEG. (Quite a convergence on common, interoperable format standards for JPEG files.
few of them use this library to do so.) The JPEG FAQ described above lists Don't use an incompatible file format!
some of the more popular free and shareware viewers, and tells where to (In any case, our decoder will remain capable of reading existing JPEG
obtain them on Internet. image files indefinitely.)
If you are on a Unix machine, we highly recommend Jef Poskanzer's free The ISO committee pretends to be "responsible for the popular JPEG" in their
PBMPLUS software, which provides many useful operations on PPM-format image public reports which is not true because they don't respond to actual
files. In particular, it can convert PPM images to and from a wide range of requirements for the maintenance of the original JPEG specification.
other formats, thus making cjpeg/djpeg considerably more useful. The latest Furthermore, the ISO committee pretends to "ensure interoperability" with
version is distributed by the NetPBM group, and is available from numerous their standards which is not true because their "standards" support only
sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. application-specific and proprietary use cases and contain mathematically
Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; incorrect code.
you are likely to have difficulty making it work on any non-Unix machine.
There are currently different distributions in circulation containing the
A different free JPEG implementation, written by the PVRG group at Stanford, name "libjpeg" which is misleading because they don't have the features and
is available from ftp://havefun.stanford.edu/pub/jpeg/. This program are incompatible with formats supported by actual IJG libjpeg distributions.
is designed for research and experimentation rather than production use; One of those fakes is released by members of the ISO committee and just uses
it is slower, harder to use, and less portable than the IJG code, but it the name of libjpeg for misdirection of people, similar to the abuse of the
is easier to read and modify. Also, the PVRG code supports lossless JPEG, name JPEG as described above, while having nothing in common with actual IJG
which we do not. (On the other hand, it doesn't do progressive JPEG.) libjpeg distributions and containing mathematically incorrect code.
The other one claims to be a "derivative" or "fork" of the original libjpeg,
but violates the license conditions as described under LEGAL ISSUES above
FILE FORMAT WARS and violates basic C programming properties.
================ We have no sympathy for the release of misleading, incorrect and illegal
distributions derived from obsolete code bases.
Some JPEG programs produce files that are not compatible with our library. Don't use an obsolete code base!
The root of the problem is that the ISO JPEG committee failed to specify a
concrete file format. Some vendors "filled in the blanks" on their own, According to the UCC (Uniform Commercial Code) law, IJG has the lawful and
creating proprietary formats that no one else could read. (For example, none legal right to foreclose on certain standardization bodies and other
of the early commercial JPEG implementations for the Macintosh were able to institutions or corporations that knowingly perform substantial and
exchange compressed files.) systematic deceptive acts and practices, fraud, theft, and damaging of the
value of the people of this planet without their knowing, willing and
The file format we have adopted is called JFIF (see REFERENCES). This format intentional consent.
has been agreed to by a number of major commercial JPEG vendors, and it has The titles, ownership, and rights of these institutions and all their assets
become the de facto standard. JFIF is a minimal or "low end" representation. are now duly secured and held in trust for the free people of this planet.
We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF People of the planet, on every country, may have a financial interest in
Technical Note #2) for "high end" applications that need to record a lot of the assets of these former principals, agents, and beneficiaries of the
additional data about an image. TIFF/JPEG is fairly new and not yet widely foreclosed institutions and corporations.
supported, unfortunately. IJG asserts what is: that each man, woman, and child has unalienable value
and rights granted and deposited in them by the Creator and not any one of
The upcoming JPEG Part 3 standard defines a file format called SPIFF. the people is subordinate to any artificial principality, corporate fiction
SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should or the special interest of another without their appropriate knowing,
be able to read the most common variant of SPIFF. SPIFF has some technical willing and intentional consent made by contract or accommodation agreement.
advantages over JFIF, but its major claim to fame is simply that it is an IJG expresses that which already was.
official standard rather than an informal one. At this point it is unclear The people have already determined and demanded that public administration
whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto entities, national governments, and their supporting judicial systems must
standard. IJG intends to support SPIFF once the standard is frozen, but we be fully transparent, accountable, and liable.
have not decided whether it should become our default output format or not. IJG has secured the value for all concerned free people of the planet.
(In any case, our decoder will remain capable of reading JFIF indefinitely.)
A partial list of foreclosed institutions and corporations ("Hall of Shame")
Various proprietary file formats incorporating JPEG compression also exist. is currently prepared and will be published later.
We have little or no sympathy for the existence of these formats. Indeed,
one of the original reasons for developing this free software was to help
force convergence on common, open format standards for JPEG files. Don't TO DO
use a proprietary file format! =====
Version 9 is the second release of a new generation JPEG standard
TO DO to overcome the limitations of the original JPEG specification,
===== and is the first true source reference JPEG codec.
More features are being prepared for coming releases...
The major thrust for v7 will probably be improvement of visual quality.
The current method for scaling the quantization tables is known not to be Please send bug reports, offers of help, etc. to jpeg-info@ijg.org.
very good at low Q values. We also intend to investigate block boundary
smoothing, "poor man's variable quantization", and other means of improving
quality-vs-file-size performance without sacrificing compatibility.
In future versions, we are considering supporting some of the upcoming JPEG
Part 3 extensions --- principally, variable quantization and the SPIFF file
format.
As always, speeding things up is of great interest.
Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net.

View file

@ -2,6 +2,7 @@
* cderror.h * cderror.h
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2009-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -40,15 +41,16 @@ JMESSAGE(JMSG_FIRSTADDONCODE=1000, NULL) /* Must be first entry! */
#ifdef BMP_SUPPORTED #ifdef BMP_SUPPORTED
JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format") JMESSAGE(JERR_BMP_BADCMAP, "Unsupported BMP colormap format")
JMESSAGE(JERR_BMP_BADDEPTH, "Only 8- and 24-bit BMP files are supported") JMESSAGE(JERR_BMP_BADDEPTH, "Only 8-, 24-, and 32-bit BMP files are supported")
JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length") JMESSAGE(JERR_BMP_BADHEADER, "Invalid BMP file: bad header length")
JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1") JMESSAGE(JERR_BMP_BADPLANES, "Invalid BMP file: biPlanes not equal to 1")
JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB") JMESSAGE(JERR_BMP_COLORSPACE, "BMP output must be grayscale or RGB")
JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported") JMESSAGE(JERR_BMP_COMPRESSED, "Sorry, compressed BMPs not yet supported")
JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM") JMESSAGE(JERR_BMP_NOT, "Not a BMP file - does not start with BM")
JMESSAGE(JTRC_BMP, "%ux%u 24-bit BMP image") JMESSAGE(JERR_BMP_OUTOFRANGE, "Numeric value out of range in BMP file")
JMESSAGE(JTRC_BMP, "%ux%u %d-bit BMP image")
JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image") JMESSAGE(JTRC_BMP_MAPPED, "%ux%u 8-bit colormapped BMP image")
JMESSAGE(JTRC_BMP_OS2, "%ux%u 24-bit OS2 BMP image") JMESSAGE(JTRC_BMP_OS2, "%ux%u %d-bit OS2 BMP image")
JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image") JMESSAGE(JTRC_BMP_OS2_MAPPED, "%ux%u 8-bit colormapped OS2 BMP image")
#endif /* BMP_SUPPORTED */ #endif /* BMP_SUPPORTED */
@ -58,6 +60,7 @@ JMESSAGE(JERR_GIF_CODESIZE, "Bogus GIF codesize %d")
JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB") JMESSAGE(JERR_GIF_COLORSPACE, "GIF output must be grayscale or RGB")
JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file") JMESSAGE(JERR_GIF_IMAGENOTFOUND, "Too few images in GIF file")
JMESSAGE(JERR_GIF_NOT, "Not a GIF file") JMESSAGE(JERR_GIF_NOT, "Not a GIF file")
JMESSAGE(JERR_GIF_OUTOFRANGE, "Numeric value out of range in GIF file")
JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image") JMESSAGE(JTRC_GIF, "%ux%ux%d GIF image")
JMESSAGE(JTRC_GIF_BADVERSION, JMESSAGE(JTRC_GIF_BADVERSION,
"Warning: unexpected GIF version number '%c%c%c'") "Warning: unexpected GIF version number '%c%c%c'")
@ -73,6 +76,7 @@ JMESSAGE(JWRN_GIF_NOMOREDATA, "Ran out of GIF bits")
JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB") JMESSAGE(JERR_PPM_COLORSPACE, "PPM output must be grayscale or RGB")
JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file") JMESSAGE(JERR_PPM_NONNUMERIC, "Nonnumeric data in PPM file")
JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file") JMESSAGE(JERR_PPM_NOT, "Not a PPM/PGM file")
JMESSAGE(JERR_PPM_OUTOFRANGE, "Numeric value out of range in PPM file")
JMESSAGE(JTRC_PGM, "%ux%u PGM image") JMESSAGE(JTRC_PGM, "%ux%u PGM image")
JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image") JMESSAGE(JTRC_PGM_TEXT, "%ux%u text PGM image")
JMESSAGE(JTRC_PPM, "%ux%u PPM image") JMESSAGE(JTRC_PPM, "%ux%u PPM image")

View file

@ -0,0 +1,189 @@
/*
* cdjpeg.h
*
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains common declarations for the sample applications
* cjpeg and djpeg. It is NOT used by the core JPEG library.
*/
#define JPEG_CJPEG_DJPEG /* define proper options in jconfig.h */
#define JPEG_INTERNAL_OPTIONS /* cjpeg.c,djpeg.c need to see xxx_SUPPORTED */
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h" /* get library error codes too */
#include "cderror.h" /* get application-specific error codes */
/*
* Object interface for cjpeg's source file decoding modules
*/
typedef struct cjpeg_source_struct * cjpeg_source_ptr;
struct cjpeg_source_struct {
JMETHOD(void, start_input, (j_compress_ptr cinfo,
cjpeg_source_ptr sinfo));
JMETHOD(JDIMENSION, get_pixel_rows, (j_compress_ptr cinfo,
cjpeg_source_ptr sinfo));
JMETHOD(void, finish_input, (j_compress_ptr cinfo,
cjpeg_source_ptr sinfo));
FILE *input_file;
JSAMPARRAY buffer;
JDIMENSION buffer_height;
};
/*
* Object interface for djpeg's output file encoding modules
*/
typedef struct djpeg_dest_struct * djpeg_dest_ptr;
struct djpeg_dest_struct {
/* start_output is called after jpeg_start_decompress finishes.
* The color map will be ready at this time, if one is needed.
*/
JMETHOD(void, start_output, (j_decompress_ptr cinfo,
djpeg_dest_ptr dinfo));
/* Emit the specified number of pixel rows from the buffer. */
JMETHOD(void, put_pixel_rows, (j_decompress_ptr cinfo,
djpeg_dest_ptr dinfo,
JDIMENSION rows_supplied));
/* Finish up at the end of the image. */
JMETHOD(void, finish_output, (j_decompress_ptr cinfo,
djpeg_dest_ptr dinfo));
/* Target file spec; filled in by djpeg.c after object is created. */
FILE * output_file;
/* Output pixel-row buffer. Created by module init or start_output.
* Width is cinfo->output_width * cinfo->output_components;
* height is buffer_height.
*/
JSAMPARRAY buffer;
JDIMENSION buffer_height;
};
/*
* cjpeg/djpeg may need to perform extra passes to convert to or from
* the source/destination file format. The JPEG library does not know
* about these passes, but we'd like them to be counted by the progress
* monitor. We use an expanded progress monitor object to hold the
* additional pass count.
*/
struct cdjpeg_progress_mgr {
struct jpeg_progress_mgr pub; /* fields known to JPEG library */
int completed_extra_passes; /* extra passes completed */
int total_extra_passes; /* total extra */
/* last printed percentage stored here to avoid multiple printouts */
int percent_done;
};
typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jinit_read_bmp jIRdBMP
#define jinit_write_bmp jIWrBMP
#define jinit_read_gif jIRdGIF
#define jinit_write_gif jIWrGIF
#define jinit_read_ppm jIRdPPM
#define jinit_write_ppm jIWrPPM
#define jinit_read_rle jIRdRLE
#define jinit_write_rle jIWrRLE
#define jinit_read_targa jIRdTarga
#define jinit_write_targa jIWrTarga
#define read_quant_tables RdQTables
#define read_scan_script RdScnScript
#define set_quality_ratings SetQRates
#define set_quant_slots SetQSlots
#define set_sample_factors SetSFacts
#define read_color_map RdCMap
#define enable_signal_catcher EnSigCatcher
#define start_progress_monitor StProgMon
#define end_progress_monitor EnProgMon
#define read_stdin RdStdin
#define write_stdout WrStdout
#endif /* NEED_SHORT_EXTERNAL_NAMES */
/* Module selection routines for I/O modules. */
EXTERN(cjpeg_source_ptr) jinit_read_bmp JPP((j_compress_ptr cinfo));
EXTERN(djpeg_dest_ptr) jinit_write_bmp JPP((j_decompress_ptr cinfo,
boolean is_os2));
EXTERN(cjpeg_source_ptr) jinit_read_gif JPP((j_compress_ptr cinfo));
EXTERN(djpeg_dest_ptr) jinit_write_gif JPP((j_decompress_ptr cinfo,
boolean is_lzw));
EXTERN(cjpeg_source_ptr) jinit_read_ppm JPP((j_compress_ptr cinfo));
EXTERN(djpeg_dest_ptr) jinit_write_ppm JPP((j_decompress_ptr cinfo));
EXTERN(cjpeg_source_ptr) jinit_read_rle JPP((j_compress_ptr cinfo));
EXTERN(djpeg_dest_ptr) jinit_write_rle JPP((j_decompress_ptr cinfo));
EXTERN(cjpeg_source_ptr) jinit_read_targa JPP((j_compress_ptr cinfo));
EXTERN(djpeg_dest_ptr) jinit_write_targa JPP((j_decompress_ptr cinfo));
/* cjpeg support routines (in rdswitch.c) */
EXTERN(boolean) read_quant_tables JPP((j_compress_ptr cinfo, char * filename,
boolean force_baseline));
EXTERN(boolean) read_scan_script JPP((j_compress_ptr cinfo, char * filename));
EXTERN(boolean) set_quality_ratings JPP((j_compress_ptr cinfo, char *arg,
boolean force_baseline));
EXTERN(boolean) set_quant_slots JPP((j_compress_ptr cinfo, char *arg));
EXTERN(boolean) set_sample_factors JPP((j_compress_ptr cinfo, char *arg));
/* djpeg support routines (in rdcolmap.c) */
EXTERN(void) read_color_map JPP((j_decompress_ptr cinfo, FILE * infile));
/* common support routines (in cdjpeg.c) */
EXTERN(void) enable_signal_catcher JPP((j_common_ptr cinfo));
EXTERN(void) start_progress_monitor JPP((j_common_ptr cinfo,
cd_progress_ptr progress));
EXTERN(void) end_progress_monitor JPP((j_common_ptr cinfo));
EXTERN(boolean) keymatch JPP((char * arg, const char * keyword, int minchars));
EXTERN(FILE *) read_stdin JPP((void));
EXTERN(FILE *) write_stdout JPP((void));
/* miscellaneous useful macros */
#ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
#define READ_BINARY "r"
#define WRITE_BINARY "w"
#else
#ifdef VMS /* VMS is very nonstandard */
#define READ_BINARY "rb", "ctx=stm"
#define WRITE_BINARY "wb", "ctx=stm"
#else /* standard ANSI-compliant case */
#define READ_BINARY "rb"
#define WRITE_BINARY "wb"
#endif
#endif
#ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1
#endif
#ifndef EXIT_SUCCESS
#ifdef VMS
#define EXIT_SUCCESS 1 /* VMS is very nonstandard */
#else
#define EXIT_SUCCESS 0
#endif
#endif
#ifndef EXIT_WARNING
#ifdef VMS
#define EXIT_WARNING 1 /* VMS is very nonstandard */
#else
#define EXIT_WARNING 2
#endif
#endif

View file

@ -0,0 +1,153 @@
/*
* jaricom.c
*
* Developed 1997-2011 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains probability estimation tables for common use in
* arithmetic entropy encoding and decoding routines.
*
* This data represents Table D.3 in the JPEG spec (D.2 in the draft),
* ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81, and Table 24
* in the JBIG spec, ISO/IEC IS 11544 and CCITT Recommendation ITU-T T.82.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* The following #define specifies the packing of the four components
* into the compact INT32 representation.
* Note that this formula must match the actual arithmetic encoder
* and decoder implementation. The implementation has to be changed
* if this formula is changed.
* The current organization is leaned on Markus Kuhn's JBIG
* implementation (jbig_tab.c).
*/
#define V(i,a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b)
const INT32 jpeg_aritab[113+1] = {
/*
* Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
*/
V( 0, 0x5a1d, 1, 1, 1 ),
V( 1, 0x2586, 14, 2, 0 ),
V( 2, 0x1114, 16, 3, 0 ),
V( 3, 0x080b, 18, 4, 0 ),
V( 4, 0x03d8, 20, 5, 0 ),
V( 5, 0x01da, 23, 6, 0 ),
V( 6, 0x00e5, 25, 7, 0 ),
V( 7, 0x006f, 28, 8, 0 ),
V( 8, 0x0036, 30, 9, 0 ),
V( 9, 0x001a, 33, 10, 0 ),
V( 10, 0x000d, 35, 11, 0 ),
V( 11, 0x0006, 9, 12, 0 ),
V( 12, 0x0003, 10, 13, 0 ),
V( 13, 0x0001, 12, 13, 0 ),
V( 14, 0x5a7f, 15, 15, 1 ),
V( 15, 0x3f25, 36, 16, 0 ),
V( 16, 0x2cf2, 38, 17, 0 ),
V( 17, 0x207c, 39, 18, 0 ),
V( 18, 0x17b9, 40, 19, 0 ),
V( 19, 0x1182, 42, 20, 0 ),
V( 20, 0x0cef, 43, 21, 0 ),
V( 21, 0x09a1, 45, 22, 0 ),
V( 22, 0x072f, 46, 23, 0 ),
V( 23, 0x055c, 48, 24, 0 ),
V( 24, 0x0406, 49, 25, 0 ),
V( 25, 0x0303, 51, 26, 0 ),
V( 26, 0x0240, 52, 27, 0 ),
V( 27, 0x01b1, 54, 28, 0 ),
V( 28, 0x0144, 56, 29, 0 ),
V( 29, 0x00f5, 57, 30, 0 ),
V( 30, 0x00b7, 59, 31, 0 ),
V( 31, 0x008a, 60, 32, 0 ),
V( 32, 0x0068, 62, 33, 0 ),
V( 33, 0x004e, 63, 34, 0 ),
V( 34, 0x003b, 32, 35, 0 ),
V( 35, 0x002c, 33, 9, 0 ),
V( 36, 0x5ae1, 37, 37, 1 ),
V( 37, 0x484c, 64, 38, 0 ),
V( 38, 0x3a0d, 65, 39, 0 ),
V( 39, 0x2ef1, 67, 40, 0 ),
V( 40, 0x261f, 68, 41, 0 ),
V( 41, 0x1f33, 69, 42, 0 ),
V( 42, 0x19a8, 70, 43, 0 ),
V( 43, 0x1518, 72, 44, 0 ),
V( 44, 0x1177, 73, 45, 0 ),
V( 45, 0x0e74, 74, 46, 0 ),
V( 46, 0x0bfb, 75, 47, 0 ),
V( 47, 0x09f8, 77, 48, 0 ),
V( 48, 0x0861, 78, 49, 0 ),
V( 49, 0x0706, 79, 50, 0 ),
V( 50, 0x05cd, 48, 51, 0 ),
V( 51, 0x04de, 50, 52, 0 ),
V( 52, 0x040f, 50, 53, 0 ),
V( 53, 0x0363, 51, 54, 0 ),
V( 54, 0x02d4, 52, 55, 0 ),
V( 55, 0x025c, 53, 56, 0 ),
V( 56, 0x01f8, 54, 57, 0 ),
V( 57, 0x01a4, 55, 58, 0 ),
V( 58, 0x0160, 56, 59, 0 ),
V( 59, 0x0125, 57, 60, 0 ),
V( 60, 0x00f6, 58, 61, 0 ),
V( 61, 0x00cb, 59, 62, 0 ),
V( 62, 0x00ab, 61, 63, 0 ),
V( 63, 0x008f, 61, 32, 0 ),
V( 64, 0x5b12, 65, 65, 1 ),
V( 65, 0x4d04, 80, 66, 0 ),
V( 66, 0x412c, 81, 67, 0 ),
V( 67, 0x37d8, 82, 68, 0 ),
V( 68, 0x2fe8, 83, 69, 0 ),
V( 69, 0x293c, 84, 70, 0 ),
V( 70, 0x2379, 86, 71, 0 ),
V( 71, 0x1edf, 87, 72, 0 ),
V( 72, 0x1aa9, 87, 73, 0 ),
V( 73, 0x174e, 72, 74, 0 ),
V( 74, 0x1424, 72, 75, 0 ),
V( 75, 0x119c, 74, 76, 0 ),
V( 76, 0x0f6b, 74, 77, 0 ),
V( 77, 0x0d51, 75, 78, 0 ),
V( 78, 0x0bb6, 77, 79, 0 ),
V( 79, 0x0a40, 77, 48, 0 ),
V( 80, 0x5832, 80, 81, 1 ),
V( 81, 0x4d1c, 88, 82, 0 ),
V( 82, 0x438e, 89, 83, 0 ),
V( 83, 0x3bdd, 90, 84, 0 ),
V( 84, 0x34ee, 91, 85, 0 ),
V( 85, 0x2eae, 92, 86, 0 ),
V( 86, 0x299a, 93, 87, 0 ),
V( 87, 0x2516, 86, 71, 0 ),
V( 88, 0x5570, 88, 89, 1 ),
V( 89, 0x4ca9, 95, 90, 0 ),
V( 90, 0x44d9, 96, 91, 0 ),
V( 91, 0x3e22, 97, 92, 0 ),
V( 92, 0x3824, 99, 93, 0 ),
V( 93, 0x32b4, 99, 94, 0 ),
V( 94, 0x2e17, 93, 86, 0 ),
V( 95, 0x56a8, 95, 96, 1 ),
V( 96, 0x4f46, 101, 97, 0 ),
V( 97, 0x47e5, 102, 98, 0 ),
V( 98, 0x41cf, 103, 99, 0 ),
V( 99, 0x3c3d, 104, 100, 0 ),
V( 100, 0x375e, 99, 93, 0 ),
V( 101, 0x5231, 105, 102, 0 ),
V( 102, 0x4c0f, 106, 103, 0 ),
V( 103, 0x4639, 107, 104, 0 ),
V( 104, 0x415e, 103, 99, 0 ),
V( 105, 0x5627, 105, 106, 1 ),
V( 106, 0x50e7, 108, 107, 0 ),
V( 107, 0x4b85, 109, 103, 0 ),
V( 108, 0x5597, 110, 109, 0 ),
V( 109, 0x504f, 111, 107, 0 ),
V( 110, 0x5a10, 110, 111, 1 ),
V( 111, 0x5522, 112, 109, 0 ),
V( 112, 0x59eb, 112, 111, 1 ),
/*
* This last entry is used for fixed probability estimate of 0.5
* as suggested in Section 10.3 Table 5 of ITU-T Rec. T.851.
*/
V( 113, 0x5a1d, 113, 113, 0 )
};

View file

@ -2,6 +2,7 @@
* jcapimin.c * jcapimin.c
* *
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -36,7 +37,7 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
if (version != JPEG_LIB_VERSION) if (version != JPEG_LIB_VERSION)
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
if (structsize != SIZEOF(struct jpeg_compress_struct)) if (structsize != SIZEOF(struct jpeg_compress_struct))
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
(int) SIZEOF(struct jpeg_compress_struct), (int) structsize); (int) SIZEOF(struct jpeg_compress_struct), (int) structsize);
/* For debugging purposes, we zero the whole master structure. /* For debugging purposes, we zero the whole master structure.
@ -63,14 +64,21 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
cinfo->comp_info = NULL; cinfo->comp_info = NULL;
for (i = 0; i < NUM_QUANT_TBLS; i++) for (i = 0; i < NUM_QUANT_TBLS; i++) {
cinfo->quant_tbl_ptrs[i] = NULL; cinfo->quant_tbl_ptrs[i] = NULL;
cinfo->q_scale_factor[i] = 100;
}
for (i = 0; i < NUM_HUFF_TBLS; i++) { for (i = 0; i < NUM_HUFF_TBLS; i++) {
cinfo->dc_huff_tbl_ptrs[i] = NULL; cinfo->dc_huff_tbl_ptrs[i] = NULL;
cinfo->ac_huff_tbl_ptrs[i] = NULL; cinfo->ac_huff_tbl_ptrs[i] = NULL;
} }
/* Must do it here for emit_dqt in case jpeg_write_tables is used */
cinfo->block_size = DCTSIZE;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
cinfo->script_space = NULL; cinfo->script_space = NULL;
cinfo->input_gamma = 1.0; /* in case application forgets */ cinfo->input_gamma = 1.0; /* in case application forgets */

View file

@ -2,6 +2,7 @@
* jcapistd.c * jcapistd.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -145,7 +146,7 @@ jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data,
(*cinfo->master->pass_startup) (cinfo); (*cinfo->master->pass_startup) (cinfo);
/* Verify that at least one iMCU row has been passed. */ /* Verify that at least one iMCU row has been passed. */
lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
if (num_lines < lines_per_iMCU_row) if (num_lines < lines_per_iMCU_row)
ERREXIT(cinfo, JERR_BUFFER_SIZE); ERREXIT(cinfo, JERR_BUFFER_SIZE);

View file

@ -0,0 +1,945 @@
/*
* jcarith.c
*
* Developed 1997-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains portable arithmetic entropy encoding routines for JPEG
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
*
* Both sequential and progressive modes are supported in this single module.
*
* Suspension is not currently supported in this module.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* Expanded entropy encoder object for arithmetic encoding. */
typedef struct {
struct jpeg_entropy_encoder pub; /* public fields */
INT32 c; /* C register, base of coding interval, layout as in sec. D.1.3 */
INT32 a; /* A register, normalized size of coding interval */
INT32 sc; /* counter for stacked 0xFF values which might overflow */
INT32 zc; /* counter for pending 0x00 output values which might *
* be discarded at the end ("Pacman" termination) */
int ct; /* bit shift counter, determines when next byte will be written */
int buffer; /* buffer for most recent output byte != 0xFF */
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */
unsigned int restarts_to_go; /* MCUs left in this restart interval */
int next_restart_num; /* next restart number to write (0-7) */
/* Pointers to statistics areas (these workspaces have image lifespan) */
unsigned char * dc_stats[NUM_ARITH_TBLS];
unsigned char * ac_stats[NUM_ARITH_TBLS];
/* Statistics bin for coding with fixed probability 0.5 */
unsigned char fixed_bin[4];
} arith_entropy_encoder;
typedef arith_entropy_encoder * arith_entropy_ptr;
/* The following two definitions specify the allocation chunk size
* for the statistics area.
* According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
* 49 statistics bins for DC, and 245 statistics bins for AC coding.
*
* We use a compact representation with 1 byte per statistics bin,
* thus the numbers directly represent byte sizes.
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/
#define DC_STAT_BINS 64
#define AC_STAT_BINS 256
/* NOTE: Uncomment the following #define if you want to use the
* given formula for calculating the AC conditioning parameter Kx
* for spectral selection progressive coding in section G.1.3.2
* of the spec (Kx = Kmin + SRL (8 + Se - Kmin) 4).
* Although the spec and P&M authors claim that this "has proven
* to give good results for 8 bit precision samples", I'm not
* convinced yet that this is really beneficial.
* Early tests gave only very marginal compression enhancements
* (a few - around 5 or so - bytes even for very large files),
* which would turn out rather negative if we'd suppress the
* DAC (Define Arithmetic Conditioning) marker segments for
* the default parameters in the future.
* Note that currently the marker writing module emits 12-byte
* DAC segments for a full-component scan in a color image.
* This is not worth worrying about IMHO. However, since the
* spec defines the default values to be used if the tables
* are omitted (unlike Huffman tables, which are required
* anyway), one might optimize this behaviour in the future,
* and then it would be disadvantageous to use custom tables if
* they don't provide sufficient gain to exceed the DAC size.
*
* On the other hand, I'd consider it as a reasonable result
* that the conditioning has no significant influence on the
* compression performance. This means that the basic
* statistical model is already rather stable.
*
* Thus, at the moment, we use the default conditioning values
* anyway, and do not use the custom formula.
*
#define CALCULATE_SPECTRAL_CONDITIONING
*/
/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.
* We assume that int right shift is unsigned if INT32 right shift is,
* which should be safe.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define ISHIFT_TEMPS int ishift_temp;
#define IRIGHT_SHIFT(x,shft) \
((ishift_temp = (x)) < 0 ? \
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
(ishift_temp >> (shft)))
#else
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
LOCAL(void)
emit_byte (int val, j_compress_ptr cinfo)
/* Write next output byte; we do not support suspension in this module. */
{
struct jpeg_destination_mgr * dest = cinfo->dest;
*dest->next_output_byte++ = (JOCTET) val;
if (--dest->free_in_buffer == 0)
if (! (*dest->empty_output_buffer) (cinfo))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
}
/*
* Finish up at the end of an arithmetic-compressed scan.
*/
METHODDEF(void)
finish_pass (j_compress_ptr cinfo)
{
arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
INT32 temp;
/* Section D.1.8: Termination of encoding */
/* Find the e->c in the coding interval with the largest
* number of trailing zero bits */
if ((temp = (e->a - 1 + e->c) & 0xFFFF0000L) < e->c)
e->c = temp + 0x8000L;
else
e->c = temp;
/* Send remaining bytes to output */
e->c <<= e->ct;
if (e->c & 0xF8000000L) {
/* One final overflow has to be handled */
if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer + 1, cinfo);
if (e->buffer + 1 == 0xFF)
emit_byte(0x00, cinfo);
}
e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */
e->sc = 0;
} else {
if (e->buffer == 0)
++e->zc;
else if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer, cinfo);
}
if (e->sc) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
do {
emit_byte(0xFF, cinfo);
emit_byte(0x00, cinfo);
} while (--e->sc);
}
}
/* Output final bytes only if they are not 0x00 */
if (e->c & 0x7FFF800L) {
if (e->zc) /* output final pending zero bytes */
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte((int) ((e->c >> 19) & 0xFF), cinfo);
if (((e->c >> 19) & 0xFF) == 0xFF)
emit_byte(0x00, cinfo);
if (e->c & 0x7F800L) {
emit_byte((int) ((e->c >> 11) & 0xFF), cinfo);
if (((e->c >> 11) & 0xFF) == 0xFF)
emit_byte(0x00, cinfo);
}
}
}
/*
* The core arithmetic encoding routine (common in JPEG and JBIG).
* This needs to go as fast as possible.
* Machine-dependent optimization facilities
* are not utilized in this portable implementation.
* However, this code should be fairly efficient and
* may be a good base for further optimizations anyway.
*
* Parameter 'val' to be encoded may be 0 or 1 (binary decision).
*
* Note: I've added full "Pacman" termination support to the
* byte output routines, which is equivalent to the optional
* Discard_final_zeros procedure (Figure D.15) in the spec.
* Thus, we always produce the shortest possible output
* stream compliant to the spec (no trailing zero bytes,
* except for FF stuffing).
*
* I've also introduced a new scheme for accessing
* the probability estimation state machine table,
* derived from Markus Kuhn's JBIG implementation.
*/
LOCAL(void)
arith_encode (j_compress_ptr cinfo, unsigned char *st, int val)
{
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
register unsigned char nl, nm;
register INT32 qe, temp;
register int sv;
/* Fetch values from our compact representation of Table D.3(D.2):
* Qe values and probability estimation state machine
*/
sv = *st;
qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
/* Encode & estimation procedures per sections D.1.4 & D.1.5 */
e->a -= qe;
if (val != (sv >> 7)) {
/* Encode the less probable symbol */
if (e->a >= qe) {
/* If the interval size (qe) for the less probable symbol (LPS)
* is larger than the interval size for the MPS, then exchange
* the two symbols for coding efficiency, otherwise code the LPS
* as usual: */
e->c += e->a;
e->a = qe;
}
*st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
} else {
/* Encode the more probable symbol */
if (e->a >= 0x8000L)
return; /* A >= 0x8000 -> ready, no renormalization required */
if (e->a < qe) {
/* If the interval size (qe) for the less probable symbol (LPS)
* is larger than the interval size for the MPS, then exchange
* the two symbols for coding efficiency: */
e->c += e->a;
e->a = qe;
}
*st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
}
/* Renormalization & data output per section D.1.6 */
do {
e->a <<= 1;
e->c <<= 1;
if (--e->ct == 0) {
/* Another byte is ready for output */
temp = e->c >> 19;
if (temp > 0xFF) {
/* Handle overflow over all stacked 0xFF bytes */
if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer + 1, cinfo);
if (e->buffer + 1 == 0xFF)
emit_byte(0x00, cinfo);
}
e->zc += e->sc; /* carry-over converts stacked 0xFF bytes to 0x00 */
e->sc = 0;
/* Note: The 3 spacer bits in the C register guarantee
* that the new buffer byte can't be 0xFF here
* (see page 160 in the P&M JPEG book). */
/* New output byte, might overflow later */
e->buffer = (int) (temp & 0xFF);
} else if (temp == 0xFF) {
++e->sc; /* stack 0xFF byte (which might overflow later) */
} else {
/* Output all stacked 0xFF bytes, they will not overflow any more */
if (e->buffer == 0)
++e->zc;
else if (e->buffer >= 0) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
emit_byte(e->buffer, cinfo);
}
if (e->sc) {
if (e->zc)
do emit_byte(0x00, cinfo);
while (--e->zc);
do {
emit_byte(0xFF, cinfo);
emit_byte(0x00, cinfo);
} while (--e->sc);
}
/* New output byte (can still overflow) */
e->buffer = (int) (temp & 0xFF);
}
e->c &= 0x7FFFFL;
e->ct += 8;
}
} while (e->a < 0x8000L);
}
/*
* Emit a restart marker & resynchronize predictions.
*/
LOCAL(void)
emit_restart (j_compress_ptr cinfo, int restart_num)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci;
jpeg_component_info * compptr;
finish_pass(cinfo);
emit_byte(0xFF, cinfo);
emit_byte(JPEG_RST0 + restart_num, cinfo);
/* Re-initialize statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* DC needs no table for refinement scan */
if (cinfo->Ss == 0 && cinfo->Ah == 0) {
MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS);
/* Reset DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
/* AC needs no table when not present */
if (cinfo->Se) {
MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS);
}
}
/* Reset arithmetic encoding variables */
entropy->c = 0;
entropy->a = 0x10000L;
entropy->sc = 0;
entropy->zc = 0;
entropy->ct = 11;
entropy->buffer = -1; /* empty */
}
/*
* MCU encoding for DC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
unsigned char *st;
int blkn, ci, tbl;
int v, v2, m;
ISHIFT_TEMPS
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
/* Encode the MCU data blocks */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
ci = cinfo->MCU_membership[blkn];
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
/* Compute the DC value after the required point transform by Al.
* This is simply an arithmetic right shift.
*/
m = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.4: Encode_DC_DIFF */
if ((v = m - entropy->last_dc_val[ci]) == 0) {
arith_encode(cinfo, st, 0);
entropy->dc_context[ci] = 0; /* zero diff category */
} else {
entropy->last_dc_val[ci] = m;
arith_encode(cinfo, st, 1);
/* Figure F.6: Encoding nonzero value v */
/* Figure F.7: Encoding the sign of v */
if (v > 0) {
arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
st += 2; /* Table F.4: SP = S0 + 2 */
entropy->dc_context[ci] = 4; /* small positive diff category */
} else {
v = -v;
arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
st += 3; /* Table F.4: SN = S0 + 3 */
entropy->dc_context[ci] = 8; /* small negative diff category */
}
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
arith_encode(cinfo, st, 0);
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] += 8; /* large diff category */
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
}
return TRUE;
}
/*
* MCU encoding for AC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
const int * natural_order;
JBLOCKROW block;
unsigned char *st;
int tbl, k, ke;
int v, v2, m;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
natural_order = cinfo->natural_order;
/* Encode the MCU data block */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
/* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
/* Establish EOB (end-of-block) index */
ke = cinfo->Se;
do {
/* We must apply the point transform by Al. For AC coefficients this
* is an integer division with rounding towards 0. To do this portably
* in C, we shift after obtaining the absolute value.
*/
if ((v = (*block)[natural_order[ke]]) >= 0) {
if (v >>= cinfo->Al) break;
} else {
v = -v;
if (v >>= cinfo->Al) break;
}
} while (--ke);
/* Figure F.5: Encode_AC_Coefficients */
for (k = cinfo->Ss - 1; k < ke;) {
st = entropy->ac_stats[tbl] + 3 * k;
arith_encode(cinfo, st, 0); /* EOB decision */
for (;;) {
if ((v = (*block)[natural_order[++k]]) >= 0) {
if (v >>= cinfo->Al) {
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 0);
break;
}
} else {
v = -v;
if (v >>= cinfo->Al) {
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 1);
break;
}
}
arith_encode(cinfo, st + 1, 0);
st += 3;
}
st += 2;
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
if (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
}
arith_encode(cinfo, st, 0);
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
/* Encode EOB decision only if k < cinfo->Se */
if (k < cinfo->Se) {
st = entropy->ac_stats[tbl] + 3 * k;
arith_encode(cinfo, st, 1);
}
return TRUE;
}
/*
* MCU encoding for DC successive approximation refinement scan.
* Note: we assume such scans can be multi-component,
* although the spec is not very clear on the point.
*/
METHODDEF(boolean)
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
unsigned char *st;
int Al, blkn;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
st = entropy->fixed_bin; /* use fixed probability estimation */
Al = cinfo->Al;
/* Encode the MCU data blocks */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
/* We simply emit the Al'th bit of the DC coefficient value. */
arith_encode(cinfo, st, (MCU_data[blkn][0][0] >> Al) & 1);
}
return TRUE;
}
/*
* MCU encoding for AC successive approximation refinement scan.
*/
METHODDEF(boolean)
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
const int * natural_order;
JBLOCKROW block;
unsigned char *st;
int tbl, k, ke, kex;
int v;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
natural_order = cinfo->natural_order;
/* Encode the MCU data block */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
/* Section G.1.3.3: Encoding of AC coefficients */
/* Establish EOB (end-of-block) index */
ke = cinfo->Se;
do {
/* We must apply the point transform by Al. For AC coefficients this
* is an integer division with rounding towards 0. To do this portably
* in C, we shift after obtaining the absolute value.
*/
if ((v = (*block)[natural_order[ke]]) >= 0) {
if (v >>= cinfo->Al) break;
} else {
v = -v;
if (v >>= cinfo->Al) break;
}
} while (--ke);
/* Establish EOBx (previous stage end-of-block) index */
for (kex = ke; kex > 0; kex--)
if ((v = (*block)[natural_order[kex]]) >= 0) {
if (v >>= cinfo->Ah) break;
} else {
v = -v;
if (v >>= cinfo->Ah) break;
}
/* Figure G.10: Encode_AC_Coefficients_SA */
for (k = cinfo->Ss - 1; k < ke;) {
st = entropy->ac_stats[tbl] + 3 * k;
if (k >= kex)
arith_encode(cinfo, st, 0); /* EOB decision */
for (;;) {
if ((v = (*block)[natural_order[++k]]) >= 0) {
if (v >>= cinfo->Al) {
if (v >> 1) /* previously nonzero coef */
arith_encode(cinfo, st + 2, (v & 1));
else { /* newly nonzero coef */
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 0);
}
break;
}
} else {
v = -v;
if (v >>= cinfo->Al) {
if (v >> 1) /* previously nonzero coef */
arith_encode(cinfo, st + 2, (v & 1));
else { /* newly nonzero coef */
arith_encode(cinfo, st + 1, 1);
arith_encode(cinfo, entropy->fixed_bin, 1);
}
break;
}
}
arith_encode(cinfo, st + 1, 0);
st += 3;
}
}
/* Encode EOB decision only if k < cinfo->Se */
if (k < cinfo->Se) {
st = entropy->ac_stats[tbl] + 3 * k;
arith_encode(cinfo, st, 1);
}
return TRUE;
}
/*
* Encode and output one MCU's worth of arithmetic-compressed coefficients.
*/
METHODDEF(boolean)
encode_mcu (j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
const int * natural_order;
JBLOCKROW block;
unsigned char *st;
int tbl, k, ke;
int v, v2, m;
int blkn, ci;
jpeg_component_info * compptr;
/* Emit restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
emit_restart(cinfo, entropy->next_restart_num);
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
natural_order = cinfo->natural_order;
/* Encode the MCU data blocks */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
ci = cinfo->MCU_membership[blkn];
compptr = cinfo->cur_comp_info[ci];
/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
tbl = compptr->dc_tbl_no;
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.4: Encode_DC_DIFF */
if ((v = (*block)[0] - entropy->last_dc_val[ci]) == 0) {
arith_encode(cinfo, st, 0);
entropy->dc_context[ci] = 0; /* zero diff category */
} else {
entropy->last_dc_val[ci] = (*block)[0];
arith_encode(cinfo, st, 1);
/* Figure F.6: Encoding nonzero value v */
/* Figure F.7: Encoding the sign of v */
if (v > 0) {
arith_encode(cinfo, st + 1, 0); /* Table F.4: SS = S0 + 1 */
st += 2; /* Table F.4: SP = S0 + 2 */
entropy->dc_context[ci] = 4; /* small positive diff category */
} else {
v = -v;
arith_encode(cinfo, st + 1, 1); /* Table F.4: SS = S0 + 1 */
st += 3; /* Table F.4: SN = S0 + 3 */
entropy->dc_context[ci] = 8; /* small negative diff category */
}
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
arith_encode(cinfo, st, 0);
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] += 8; /* large diff category */
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
/* Sections F.1.4.2 & F.1.4.4.2: Encoding of AC coefficients */
if ((ke = cinfo->lim_Se) == 0) continue;
tbl = compptr->ac_tbl_no;
/* Establish EOB (end-of-block) index */
do {
if ((*block)[natural_order[ke]]) break;
} while (--ke);
/* Figure F.5: Encode_AC_Coefficients */
for (k = 0; k < ke;) {
st = entropy->ac_stats[tbl] + 3 * k;
arith_encode(cinfo, st, 0); /* EOB decision */
while ((v = (*block)[natural_order[++k]]) == 0) {
arith_encode(cinfo, st + 1, 0);
st += 3;
}
arith_encode(cinfo, st + 1, 1);
/* Figure F.6: Encoding nonzero value v */
/* Figure F.7: Encoding the sign of v */
if (v > 0) {
arith_encode(cinfo, entropy->fixed_bin, 0);
} else {
v = -v;
arith_encode(cinfo, entropy->fixed_bin, 1);
}
st += 2;
/* Figure F.8: Encoding the magnitude category of v */
m = 0;
if (v -= 1) {
arith_encode(cinfo, st, 1);
m = 1;
v2 = v;
if (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (v2 >>= 1) {
arith_encode(cinfo, st, 1);
m <<= 1;
st += 1;
}
}
}
arith_encode(cinfo, st, 0);
/* Figure F.9: Encoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
arith_encode(cinfo, st, (m & v) ? 1 : 0);
}
/* Encode EOB decision only if k < cinfo->lim_Se */
if (k < cinfo->lim_Se) {
st = entropy->ac_stats[tbl] + 3 * k;
arith_encode(cinfo, st, 1);
}
}
return TRUE;
}
/*
* Initialize for an arithmetic-compressed scan.
*/
METHODDEF(void)
start_pass (j_compress_ptr cinfo, boolean gather_statistics)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci, tbl;
jpeg_component_info * compptr;
if (gather_statistics)
/* Make sure to avoid that in the master control logic!
* We are fully adaptive here and need no extra
* statistics gathering pass!
*/
ERREXIT(cinfo, JERR_NOT_COMPILED);
/* We assume jcmaster.c already validated the progressive scan parameters. */
/* Select execution routines */
if (cinfo->progressive_mode) {
if (cinfo->Ah == 0) {
if (cinfo->Ss == 0)
entropy->pub.encode_mcu = encode_mcu_DC_first;
else
entropy->pub.encode_mcu = encode_mcu_AC_first;
} else {
if (cinfo->Ss == 0)
entropy->pub.encode_mcu = encode_mcu_DC_refine;
else
entropy->pub.encode_mcu = encode_mcu_AC_refine;
}
} else
entropy->pub.encode_mcu = encode_mcu;
/* Allocate & initialize requested statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* DC needs no table for refinement scan */
if (cinfo->Ss == 0 && cinfo->Ah == 0) {
tbl = compptr->dc_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->dc_stats[tbl] == NULL)
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
/* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
/* AC needs no table when not present */
if (cinfo->Se) {
tbl = compptr->ac_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->ac_stats[tbl] == NULL)
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
#ifdef CALCULATE_SPECTRAL_CONDITIONING
if (cinfo->progressive_mode)
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */
cinfo->arith_ac_K[tbl] = cinfo->Ss + ((8 + cinfo->Se - cinfo->Ss) >> 4);
#endif
}
}
/* Initialize arithmetic encoding variables */
entropy->c = 0;
entropy->a = 0x10000L;
entropy->sc = 0;
entropy->zc = 0;
entropy->ct = 11;
entropy->buffer = -1; /* empty */
/* Initialize restart stuff */
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num = 0;
}
/*
* Module initialization routine for arithmetic entropy encoding.
*/
GLOBAL(void)
jinit_arith_encoder (j_compress_ptr cinfo)
{
arith_entropy_ptr entropy;
int i;
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_encoder));
cinfo->entropy = &entropy->pub;
entropy->pub.start_pass = start_pass;
entropy->pub.finish_pass = finish_pass;
/* Mark tables unallocated */
for (i = 0; i < NUM_ARITH_TBLS; i++) {
entropy->dc_stats[i] = NULL;
entropy->ac_stats[i] = NULL;
}
/* Initialize index for fixed probability estimation */
entropy->fixed_bin[0] = 113;
}

View file

@ -2,6 +2,7 @@
* jccoefct.c * jccoefct.c
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2003-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -35,16 +36,14 @@ typedef struct {
struct jpeg_c_coef_controller pub; /* public fields */ struct jpeg_c_coef_controller pub; /* public fields */
JDIMENSION iMCU_row_num; /* iMCU row # within image */ JDIMENSION iMCU_row_num; /* iMCU row # within image */
JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
int MCU_vert_offset; /* counts MCU rows within iMCU row */ int MCU_vert_offset; /* counts MCU rows within iMCU row */
int MCU_rows_per_iMCU_row; /* number of such rows needed */ int MCU_rows_per_iMCU_row; /* number of such rows needed */
/* For single-pass compression, it's sufficient to buffer just one MCU /* For single-pass compression, it's sufficient to buffer just one MCU
* (although this may prove a bit slow in practice). We allocate a * (although this may prove a bit slow in practice).
* workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each * We append a workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks,
* MCU constructed and sent. (On 80x86, the workspace is FAR even though * and reuse it for each MCU constructed and sent.
* it's not really very big; this is to keep the module interfaces unchanged
* when a large coefficient buffer is necessary.)
* In multi-pass modes, this array points to the current MCU's blocks * In multi-pass modes, this array points to the current MCU's blocks
* within the virtual arrays. * within the virtual arrays.
*/ */
@ -52,6 +51,9 @@ typedef struct {
/* In multi-pass modes, we need a virtual block array for each component. */ /* In multi-pass modes, we need a virtual block array for each component. */
jvirt_barray_ptr whole_image[MAX_COMPONENTS]; jvirt_barray_ptr whole_image[MAX_COMPONENTS];
/* Workspace for single-pass compression (omitted otherwise). */
JBLOCK blk_buffer[C_MAX_BLOCKS_IN_MCU];
} my_coef_controller; } my_coef_controller;
typedef my_coef_controller * my_coef_ptr; typedef my_coef_controller * my_coef_ptr;
@ -87,7 +89,7 @@ start_iMCU_row (j_compress_ptr cinfo)
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
} }
coef->mcu_ctr = 0; coef->MCU_ctr = 0;
coef->MCU_vert_offset = 0; coef->MCU_vert_offset = 0;
} }
@ -124,7 +126,6 @@ start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
#endif #endif
default: default:
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
break;
} }
} }
@ -146,56 +147,56 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION MCU_col_num; /* index of current MCU within row */
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
int blkn, bi, ci, yindex, yoffset, blockcnt; int ci, xindex, yindex, yoffset, blockcnt;
JDIMENSION ypos, xpos; JBLOCKROW blkp;
JSAMPARRAY input_ptr;
JDIMENSION xpos;
jpeg_component_info *compptr; jpeg_component_info *compptr;
forward_DCT_ptr forward_DCT;
/* Loop to write as much as one whole iMCU row */ /* Loop to write as much as one whole iMCU row */
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
yoffset++) { yoffset++) {
for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
MCU_col_num++) { MCU_col_num++) {
/* Determine where data comes from in input_buf and do the DCT thing. /* Determine where data comes from in input_buf and do the DCT thing.
* Each call on forward_DCT processes a horizontal row of DCT blocks * Each call on forward_DCT processes a horizontal row of DCT blocks as
* as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks * wide as an MCU. Dummy blocks at the right or bottom edge are filled in
* sequentially. Dummy blocks at the right or bottom edge are filled in
* specially. The data in them does not matter for image reconstruction, * specially. The data in them does not matter for image reconstruction,
* so we fill them with values that will encode to the smallest amount of * so we fill them with values that will encode to the smallest amount of
* data, viz: all zeroes in the AC entries, DC entries equal to previous * data, viz: all zeroes in the AC entries, DC entries equal to previous
* block's DC value. (Thanks to Thomas Kinsman for this idea.) * block's DC value. (Thanks to Thomas Kinsman for this idea.)
*/ */
blkn = 0; blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
forward_DCT = cinfo->fdct->forward_DCT[compptr->component_index];
input_ptr = input_buf[compptr->component_index] +
yoffset * compptr->DCT_v_scaled_size;
/* ypos == (yoffset + yindex) * compptr->DCT_v_scaled_size */
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
: compptr->last_col_width; : compptr->last_col_width;
xpos = MCU_col_num * compptr->MCU_sample_width; xpos = MCU_col_num * compptr->MCU_sample_width;
ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */
for (yindex = 0; yindex < compptr->MCU_height; yindex++) { for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (coef->iMCU_row_num < last_iMCU_row || if (coef->iMCU_row_num < last_iMCU_row ||
yoffset+yindex < compptr->last_row_height) { yoffset + yindex < compptr->last_row_height) {
(*cinfo->fdct->forward_DCT) (cinfo, compptr, (*forward_DCT) (cinfo, compptr, input_ptr, blkp,
input_buf[compptr->component_index], xpos, (JDIMENSION) blockcnt);
coef->MCU_buffer[blkn], input_ptr += compptr->DCT_v_scaled_size;
ypos, xpos, (JDIMENSION) blockcnt); blkp += blockcnt;
if (blockcnt < compptr->MCU_width) { /* Dummy blocks at right edge */
/* Create some dummy blocks at the right edge of the image. */ if ((xindex = compptr->MCU_width - blockcnt) == 0)
jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], continue;
(compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK));
for (bi = blockcnt; bi < compptr->MCU_width; bi++) {
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0];
}
}
} else { } else {
/* Create a row of dummy blocks at the bottom of the image. */ /* At bottom of image, need a whole row of dummy blocks */
jzero_far((void FAR *) coef->MCU_buffer[blkn], xindex = compptr->MCU_width;
compptr->MCU_width * SIZEOF(JBLOCK));
for (bi = 0; bi < compptr->MCU_width; bi++) {
coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0];
}
} }
blkn += compptr->MCU_width; /* Fill in any dummy blocks needed in this row */
ypos += DCTSIZE; MEMZERO(blkp, xindex * SIZEOF(JBLOCK));
do {
blkp[0][0] = blkp[-1][0];
blkp++;
} while (--xindex);
} }
} }
/* Try to write the MCU. In event of a suspension failure, we will /* Try to write the MCU. In event of a suspension failure, we will
@ -204,12 +205,12 @@ compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
/* Suspension forced; update state counters and exit */ /* Suspension forced; update state counters and exit */
coef->MCU_vert_offset = yoffset; coef->MCU_vert_offset = yoffset;
coef->mcu_ctr = MCU_col_num; coef->MCU_ctr = MCU_col_num;
return FALSE; return FALSE;
} }
} }
/* Completed an MCU row, but perhaps not an iMCU row */ /* Completed an MCU row, but perhaps not an iMCU row */
coef->mcu_ctr = 0; coef->MCU_ctr = 0;
} }
/* Completed the iMCU row, advance counters for next one */ /* Completed the iMCU row, advance counters for next one */
coef->iMCU_row_num++; coef->iMCU_row_num++;
@ -252,6 +253,8 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
jpeg_component_info *compptr; jpeg_component_info *compptr;
JBLOCKARRAY buffer; JBLOCKARRAY buffer;
JBLOCKROW thisblockrow, lastblockrow; JBLOCKROW thisblockrow, lastblockrow;
JSAMPARRAY input_ptr;
forward_DCT_ptr forward_DCT;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
@ -274,19 +277,20 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
ndummy = (int) (blocks_across % h_samp_factor); ndummy = (int) (blocks_across % h_samp_factor);
if (ndummy > 0) if (ndummy > 0)
ndummy = h_samp_factor - ndummy; ndummy = h_samp_factor - ndummy;
forward_DCT = cinfo->fdct->forward_DCT[ci];
input_ptr = input_buf[ci];
/* Perform DCT for all non-dummy blocks in this iMCU row. Each call /* Perform DCT for all non-dummy blocks in this iMCU row. Each call
* on forward_DCT processes a complete horizontal row of DCT blocks. * on forward_DCT processes a complete horizontal row of DCT blocks.
*/ */
for (block_row = 0; block_row < block_rows; block_row++) { for (block_row = 0; block_row < block_rows; block_row++) {
thisblockrow = buffer[block_row]; thisblockrow = buffer[block_row];
(*cinfo->fdct->forward_DCT) (cinfo, compptr, (*forward_DCT) (cinfo, compptr, input_ptr, thisblockrow,
input_buf[ci], thisblockrow, (JDIMENSION) 0, blocks_across);
(JDIMENSION) (block_row * DCTSIZE), input_ptr += compptr->DCT_v_scaled_size;
(JDIMENSION) 0, blocks_across);
if (ndummy > 0) { if (ndummy > 0) {
/* Create dummy blocks at the right edge of the image. */ /* Create dummy blocks at the right edge of the image. */
thisblockrow += blocks_across; /* => first dummy block */ thisblockrow += blocks_across; /* => first dummy block */
jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); FMEMZERO((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK));
lastDC = thisblockrow[-1][0]; lastDC = thisblockrow[-1][0];
for (bi = 0; bi < ndummy; bi++) { for (bi = 0; bi < ndummy; bi++) {
thisblockrow[bi][0] = lastDC; thisblockrow[bi][0] = lastDC;
@ -298,15 +302,14 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
* of the dummy blocks to match the last real block's DC value. * of the dummy blocks to match the last real block's DC value.
* This squeezes a few more bytes out of the resulting file... * This squeezes a few more bytes out of the resulting file...
*/ */
if (coef->iMCU_row_num == last_iMCU_row) { if (block_row < compptr->v_samp_factor) {
blocks_across += ndummy; /* include lower right corner */ blocks_across += ndummy; /* include lower right corner */
MCUs_across = blocks_across / h_samp_factor; MCUs_across = blocks_across / h_samp_factor;
for (block_row = block_rows; block_row < compptr->v_samp_factor; do {
block_row++) {
thisblockrow = buffer[block_row]; thisblockrow = buffer[block_row];
lastblockrow = buffer[block_row-1]; lastblockrow = buffer[block_row-1];
jzero_far((void FAR *) thisblockrow, FMEMZERO((void FAR *) thisblockrow,
(size_t) (blocks_across * SIZEOF(JBLOCK))); (size_t) blocks_across * SIZEOF(JBLOCK));
for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) {
lastDC = lastblockrow[h_samp_factor-1][0]; lastDC = lastblockrow[h_samp_factor-1][0];
for (bi = 0; bi < h_samp_factor; bi++) { for (bi = 0; bi < h_samp_factor; bi++) {
@ -315,7 +318,7 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
thisblockrow += h_samp_factor; /* advance to next MCU in row */ thisblockrow += h_samp_factor; /* advance to next MCU in row */
lastblockrow += h_samp_factor; lastblockrow += h_samp_factor;
} }
} } while (++block_row < compptr->v_samp_factor);
} }
} }
/* NB: compress_output will increment iMCU_row_num if successful. /* NB: compress_output will increment iMCU_row_num if successful.
@ -338,12 +341,13 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
*/ */
METHODDEF(boolean) METHODDEF(boolean)
compress_output (j_compress_ptr cinfo, JSAMPIMAGE) compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
{ {
my_coef_ptr coef = (my_coef_ptr) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION MCU_col_num; /* index of current MCU within row */
int blkn, ci, xindex, yindex, yoffset; int ci, xindex, yindex, yoffset;
JDIMENSION start_col; JDIMENSION start_col;
JBLOCKARRAY blkp;
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
JBLOCKROW buffer_ptr; JBLOCKROW buffer_ptr;
jpeg_component_info *compptr; jpeg_component_info *compptr;
@ -363,30 +367,31 @@ compress_output (j_compress_ptr cinfo, JSAMPIMAGE)
/* Loop to process one whole iMCU row */ /* Loop to process one whole iMCU row */
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
yoffset++) { yoffset++) {
for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
MCU_col_num++) { MCU_col_num++) {
/* Construct list of pointers to DCT blocks belonging to this MCU */ /* Construct list of pointers to DCT blocks belonging to this MCU */
blkn = 0; /* index of current DCT block within MCU */ blkp = coef->MCU_buffer; /* pointer to current DCT block within MCU */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
start_col = MCU_col_num * compptr->MCU_width; start_col = MCU_col_num * compptr->MCU_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) { for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
buffer_ptr = buffer[ci][yindex+yoffset] + start_col; buffer_ptr = buffer[ci][yoffset + yindex] + start_col;
for (xindex = 0; xindex < compptr->MCU_width; xindex++) { xindex = compptr->MCU_width;
coef->MCU_buffer[blkn++] = buffer_ptr++; do {
} *blkp++ = buffer_ptr++;
} while (--xindex);
} }
} }
/* Try to write the MCU. */ /* Try to write the MCU. */
if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) {
/* Suspension forced; update state counters and exit */ /* Suspension forced; update state counters and exit */
coef->MCU_vert_offset = yoffset; coef->MCU_vert_offset = yoffset;
coef->mcu_ctr = MCU_col_num; coef->MCU_ctr = MCU_col_num;
return FALSE; return FALSE;
} }
} }
/* Completed an MCU row, but perhaps not an iMCU row */ /* Completed an MCU row, but perhaps not an iMCU row */
coef->mcu_ctr = 0; coef->MCU_ctr = 0;
} }
/* Completed the iMCU row, advance counters for next one */ /* Completed the iMCU row, advance counters for next one */
coef->iMCU_row_num++; coef->iMCU_row_num++;
@ -406,13 +411,6 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
{ {
my_coef_ptr coef; my_coef_ptr coef;
coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller));
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
coef->pub.start_pass = start_pass_coef;
/* Create the coefficient buffer. */
if (need_full_buffer) { if (need_full_buffer) {
#ifdef FULL_COEF_BUFFER_SUPPORTED #ifdef FULL_COEF_BUFFER_SUPPORTED
/* Allocate a full-image virtual array for each component, */ /* Allocate a full-image virtual array for each component, */
@ -420,6 +418,9 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
int ci; int ci;
jpeg_component_info *compptr; jpeg_component_info *compptr;
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller) - SIZEOF(coef->blk_buffer));
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
@ -435,15 +436,21 @@ jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer)
#endif #endif
} else { } else {
/* We only need a single-MCU buffer. */ /* We only need a single-MCU buffer. */
JBLOCKROW buffer; JBLOCKARRAY blkp;
int i; JBLOCKROW buffer_ptr;
int bi;
buffer = (JBLOCKROW) coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller));
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); blkp = coef->MCU_buffer;
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { buffer_ptr = coef->blk_buffer;
coef->MCU_buffer[i] = buffer + i; bi = C_MAX_BLOCKS_IN_MCU;
} do {
*blkp++ = buffer_ptr++;
} while (--bi);
coef->whole_image[0] = NULL; /* flag for no virtual arrays */ coef->whole_image[0] = NULL; /* flag for no virtual arrays */
} }
coef->pub.start_pass = start_pass_coef;
cinfo->coef = &coef->pub;
} }

View file

@ -2,6 +2,7 @@
* jccolor.c * jccolor.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2011-2023 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -28,13 +29,25 @@ typedef my_color_converter * my_cconvert_ptr;
/**************** RGB -> YCbCr conversion: most common case **************/ /**************** RGB -> YCbCr conversion: most common case **************/
/* /*
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are * YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011),
* normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. * previously known as Recommendation CCIR 601-1, except that Cb and Cr
* The conversion equations to be implemented are therefore * are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
* Y = 0.29900 * R + 0.58700 * G + 0.11400 * B * sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999.
* Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE * sYCC (standard luma-chroma-chroma color space with extended gamut)
* Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE * is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F.
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) * bg-sRGB and bg-sYCC (big gamut standard color spaces)
* are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G.
* Note that the derived conversion coefficients given in some of these
* documents are imprecise. The general conversion equations are
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
* Cb = (B - Y) / (1 - Kb) / K
* Cr = (R - Y) / (1 - Kr) / K
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
* from the 1953 FCC NTSC primaries and CIE Illuminant C), K = 2 for sYCC,
* the conversion equations to be implemented are therefore
* Y = 0.299 * R + 0.587 * G + 0.114 * B
* Cb = -0.168735892 * R - 0.331264108 * G + 0.5 * B + CENTERJSAMPLE
* Cr = 0.5 * R - 0.418687589 * G - 0.081312411 * B + CENTERJSAMPLE
* Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2,
* rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and
* negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0)
@ -48,9 +61,9 @@ typedef my_color_converter * my_cconvert_ptr;
* For even more speed, we avoid doing any multiplications in the inner loop * For even more speed, we avoid doing any multiplications in the inner loop
* by precalculating the constants times R,G,B for all possible values. * by precalculating the constants times R,G,B for all possible values.
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
* for 12-bit samples it is still acceptable. It's not very reasonable for * for 9-bit to 12-bit samples it is still acceptable. It's not very
* 16-bit samples, but if you want lossless storage you shouldn't be changing * reasonable for 16-bit samples, but if you want lossless storage
* colorspace anyway. * you shouldn't be changing colorspace anyway.
* The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included
* in the tables to save adding them separately in the inner loop. * in the tables to save adding them separately in the inner loop.
*/ */
@ -92,24 +105,24 @@ rgb_ycc_start (j_compress_ptr cinfo)
/* Allocate and fill in the conversion tables. */ /* Allocate and fill in the conversion tables. */
cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(TABLE_SIZE * SIZEOF(INT32))); TABLE_SIZE * SIZEOF(INT32));
for (i = 0; i <= MAXJSAMPLE; i++) { for (i = 0; i <= MAXJSAMPLE; i++) {
rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; rgb_ycc_tab[i+R_Y_OFF] = FIX(0.299) * i;
rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; rgb_ycc_tab[i+G_Y_OFF] = FIX(0.587) * i;
rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; rgb_ycc_tab[i+B_Y_OFF] = FIX(0.114) * i + ONE_HALF;
rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; rgb_ycc_tab[i+R_CB_OFF] = (- FIX(0.168735892)) * i;
rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; rgb_ycc_tab[i+G_CB_OFF] = (- FIX(0.331264108)) * i;
/* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr.
* This ensures that the maximum output will round to MAXJSAMPLE * This ensures that the maximum output will round to MAXJSAMPLE
* not MAXJSAMPLE+1, and thus that we don't have to range-limit. * not MAXJSAMPLE+1, and thus that we don't have to range-limit.
*/ */
rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; rgb_ycc_tab[i+B_CB_OFF] = (i << (SCALEBITS-1)) + CBCR_OFFSET + ONE_HALF-1;
/* B=>Cb and R=>Cr tables are the same /* B=>Cb and R=>Cr tables are the same
rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; rgb_ycc_tab[i+R_CR_OFF] = (i << (SCALEBITS-1)) + CBCR_OFFSET + ONE_HALF-1;
*/ */
rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; rgb_ycc_tab[i+G_CR_OFF] = (- FIX(0.418687589)) * i;
rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; rgb_ycc_tab[i+B_CR_OFF] = (- FIX(0.081312411)) * i;
} }
} }
@ -118,12 +131,12 @@ rgb_ycc_start (j_compress_ptr cinfo)
* Convert some rows of samples to the JPEG colorspace. * Convert some rows of samples to the JPEG colorspace.
* *
* Note that we change from the application's interleaved-pixel format * Note that we change from the application's interleaved-pixel format
* to our internal noninterleaved, one-plane-per-component format. * to our internal noninterleaved, one-plane-per-component format. The
* The input buffer is therefore three times as wide as the output buffer. * input buffer is therefore three times as wide as the output buffer.
* *
* A starting row offset is provided only for the output buffer. The caller * A starting row offset is provided only for the output buffer. The
* can easily adjust the passed input_buf value to accommodate any row * caller can easily adjust the passed input_buf value to accommodate
* offset required on that side. * any row offset required on that side.
*/ */
METHODDEF(void) METHODDEF(void)
@ -132,11 +145,11 @@ rgb_ycc_convert (j_compress_ptr cinfo,
JDIMENSION output_row, int num_rows) JDIMENSION output_row, int num_rows)
{ {
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int r, g, b; register int r, g, b;
INT32 * ctab = cconvert->rgb_ycc_tab; register INT32 * ctab = cconvert->rgb_ycc_tab;
JSAMPROW inptr; register JSAMPROW inptr;
JSAMPROW outptr0, outptr1, outptr2; register JSAMPROW outptr0, outptr1, outptr2;
JDIMENSION col; register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width; JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) { while (--num_rows >= 0) {
@ -177,8 +190,8 @@ rgb_ycc_convert (j_compress_ptr cinfo,
/* /*
* Convert some rows of samples to the JPEG colorspace. * Convert some rows of samples to the JPEG colorspace.
* This version handles RGB->grayscale conversion, which is the same * This version handles RGB->grayscale conversion,
* as the RGB->Y portion of RGB->YCbCr. * which is the same as the RGB->Y portion of RGB->YCbCr.
* We assume rgb_ycc_start has been called (we only use the Y tables). * We assume rgb_ycc_start has been called (we only use the Y tables).
*/ */
@ -188,26 +201,22 @@ rgb_gray_convert (j_compress_ptr cinfo,
JDIMENSION output_row, int num_rows) JDIMENSION output_row, int num_rows)
{ {
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int r, g, b; register INT32 y;
INT32 * ctab = cconvert->rgb_ycc_tab; register INT32 * ctab = cconvert->rgb_ycc_tab;
JSAMPROW inptr; register JSAMPROW inptr;
JSAMPROW outptr; register JSAMPROW outptr;
JDIMENSION col; register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width; JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) { while (--num_rows >= 0) {
inptr = *input_buf++; inptr = *input_buf++;
outptr = output_buf[0][output_row]; outptr = output_buf[0][output_row++];
output_row++;
for (col = 0; col < num_cols; col++) { for (col = 0; col < num_cols; col++) {
r = GETJSAMPLE(inptr[RGB_RED]); y = ctab[R_Y_OFF + GETJSAMPLE(inptr[RGB_RED])];
g = GETJSAMPLE(inptr[RGB_GREEN]); y += ctab[G_Y_OFF + GETJSAMPLE(inptr[RGB_GREEN])];
b = GETJSAMPLE(inptr[RGB_BLUE]); y += ctab[B_Y_OFF + GETJSAMPLE(inptr[RGB_BLUE])];
inptr += RGB_PIXELSIZE; inptr += RGB_PIXELSIZE;
/* Y */ outptr[col] = (JSAMPLE) (y >> SCALEBITS);
outptr[col] = (JSAMPLE)
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
>> SCALEBITS);
} }
} }
} }
@ -216,8 +225,8 @@ rgb_gray_convert (j_compress_ptr cinfo,
/* /*
* Convert some rows of samples to the JPEG colorspace. * Convert some rows of samples to the JPEG colorspace.
* This version handles Adobe-style CMYK->YCCK conversion, * This version handles Adobe-style CMYK->YCCK conversion,
* where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the
* conversion as above, while passing K (black) unchanged. * same conversion as above, while passing K (black) unchanged.
* We assume rgb_ycc_start has been called. * We assume rgb_ycc_start has been called.
*/ */
@ -227,11 +236,11 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
JDIMENSION output_row, int num_rows) JDIMENSION output_row, int num_rows)
{ {
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int r, g, b; register int r, g, b;
INT32 * ctab = cconvert->rgb_ycc_tab; register INT32 * ctab = cconvert->rgb_ycc_tab;
JSAMPROW inptr; register JSAMPROW inptr;
JSAMPROW outptr0, outptr1, outptr2, outptr3; register JSAMPROW outptr0, outptr1, outptr2, outptr3;
JDIMENSION col; register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width; JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) { while (--num_rows >= 0) {
@ -270,10 +279,52 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
} }
/*
* Convert some rows of samples to the JPEG colorspace.
* [R,G,B] to [R-G,G,B-G] conversion with modulo calculation
* (forward reversible color transform).
* This can be seen as an adaption of the general RGB->YCbCr
* conversion equation with Kr = Kb = 0, while replacing the
* normalization by modulo calculation.
*/
METHODDEF(void)
rgb_rgb1_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows)
{
register int r, g, b;
register JSAMPROW inptr;
register JSAMPROW outptr0, outptr1, outptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) {
inptr = *input_buf++;
outptr0 = output_buf[0][output_row];
outptr1 = output_buf[1][output_row];
outptr2 = output_buf[2][output_row];
output_row++;
for (col = 0; col < num_cols; col++) {
r = GETJSAMPLE(inptr[RGB_RED]);
g = GETJSAMPLE(inptr[RGB_GREEN]);
b = GETJSAMPLE(inptr[RGB_BLUE]);
inptr += RGB_PIXELSIZE;
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
* (modulo) operator is equivalent to the bitmask operator AND.
*/
outptr0[col] = (JSAMPLE) ((r - g + CENTERJSAMPLE) & MAXJSAMPLE);
outptr1[col] = (JSAMPLE) g;
outptr2[col] = (JSAMPLE) ((b - g + CENTERJSAMPLE) & MAXJSAMPLE);
}
}
}
/* /*
* Convert some rows of samples to the JPEG colorspace. * Convert some rows of samples to the JPEG colorspace.
* This version handles grayscale output with no conversion. * This version handles grayscale output with no conversion.
* The source can be either plain grayscale or YCbCr (since Y == gray). * The source can be either plain grayscale or YCC (since Y == gray).
*/ */
METHODDEF(void) METHODDEF(void)
@ -281,19 +332,51 @@ grayscale_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows) JDIMENSION output_row, int num_rows)
{ {
JSAMPROW inptr; register JSAMPROW inptr;
JSAMPROW outptr; register JSAMPROW outptr;
JDIMENSION col; register JDIMENSION count;
register int instride = cinfo->input_components;
JDIMENSION num_cols = cinfo->image_width; JDIMENSION num_cols = cinfo->image_width;
int instride = cinfo->input_components;
while (--num_rows >= 0) { while (--num_rows >= 0) {
inptr = *input_buf++; inptr = *input_buf++;
outptr = output_buf[0][output_row]; outptr = output_buf[0][output_row++];
for (count = num_cols; count > 0; count--) {
*outptr++ = *inptr; /* don't need GETJSAMPLE() here */
inptr += instride;
}
}
}
/*
* Convert some rows of samples to the JPEG colorspace.
* No colorspace conversion, but change from interleaved
* to separate-planes representation.
*/
METHODDEF(void)
rgb_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows)
{
register JSAMPROW inptr;
register JSAMPROW outptr0, outptr1, outptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->image_width;
while (--num_rows >= 0) {
inptr = *input_buf++;
outptr0 = output_buf[0][output_row];
outptr1 = output_buf[1][output_row];
outptr2 = output_buf[2][output_row];
output_row++; output_row++;
for (col = 0; col < num_cols; col++) { for (col = 0; col < num_cols; col++) {
outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ /* We can dispense with GETJSAMPLE() here */
inptr += instride; outptr0[col] = inptr[RGB_RED];
outptr1[col] = inptr[RGB_GREEN];
outptr2[col] = inptr[RGB_BLUE];
inptr += RGB_PIXELSIZE;
} }
} }
} }
@ -310,21 +393,21 @@ null_convert (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPIMAGE output_buf, JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
JDIMENSION output_row, int num_rows) JDIMENSION output_row, int num_rows)
{ {
JSAMPROW inptr; register JSAMPROW inptr;
JSAMPROW outptr; register JSAMPROW outptr;
JDIMENSION col; register JDIMENSION count;
int ci; register int num_comps = cinfo->num_components;
int nc = cinfo->num_components;
JDIMENSION num_cols = cinfo->image_width; JDIMENSION num_cols = cinfo->image_width;
int ci;
while (--num_rows >= 0) { while (--num_rows >= 0) {
/* It seems fastest to make a separate pass for each component. */ /* It seems fastest to make a separate pass for each component. */
for (ci = 0; ci < nc; ci++) { for (ci = 0; ci < num_comps; ci++) {
inptr = *input_buf; inptr = input_buf[0] + ci;
outptr = output_buf[ci][output_row]; outptr = output_buf[ci][output_row];
for (col = 0; col < num_cols; col++) { for (count = num_cols; count > 0; count--) {
outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ *outptr++ = *inptr; /* don't need GETJSAMPLE() here */
inptr += nc; inptr += num_comps;
} }
} }
input_buf++; input_buf++;
@ -338,7 +421,7 @@ null_convert (j_compress_ptr cinfo,
*/ */
METHODDEF(void) METHODDEF(void)
null_method (j_compress_ptr) null_method (j_compress_ptr cinfo)
{ {
/* no work needed */ /* no work needed */
} }
@ -353,10 +436,9 @@ jinit_color_converter (j_compress_ptr cinfo)
{ {
my_cconvert_ptr cconvert; my_cconvert_ptr cconvert;
cconvert = (my_cconvert_ptr) cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_converter));
SIZEOF(my_color_converter)); cinfo->cconvert = &cconvert->pub;
cinfo->cconvert = (struct jpeg_color_converter *) cconvert;
/* set start_pass to null method until we find out differently */ /* set start_pass to null method until we find out differently */
cconvert->pub.start_pass = null_method; cconvert->pub.start_pass = null_method;
@ -368,6 +450,7 @@ jinit_color_converter (j_compress_ptr cinfo)
break; break;
case JCS_RGB: case JCS_RGB:
case JCS_BG_RGB:
#if RGB_PIXELSIZE != 3 #if RGB_PIXELSIZE != 3
if (cinfo->input_components != RGB_PIXELSIZE) if (cinfo->input_components != RGB_PIXELSIZE)
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
@ -375,6 +458,7 @@ jinit_color_converter (j_compress_ptr cinfo)
#endif /* else share code with YCbCr */ #endif /* else share code with YCbCr */
case JCS_YCbCr: case JCS_YCbCr:
case JCS_BG_YCC:
if (cinfo->input_components != 3) if (cinfo->input_components != 3)
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
break; break;
@ -388,65 +472,121 @@ jinit_color_converter (j_compress_ptr cinfo)
default: /* JCS_UNKNOWN can be anything */ default: /* JCS_UNKNOWN can be anything */
if (cinfo->input_components < 1) if (cinfo->input_components < 1)
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
break;
} }
/* Support color transform only for RGB colorspaces */
if (cinfo->color_transform &&
cinfo->jpeg_color_space != JCS_RGB &&
cinfo->jpeg_color_space != JCS_BG_RGB)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
/* Check num_components, set conversion method based on requested space */ /* Check num_components, set conversion method based on requested space */
switch (cinfo->jpeg_color_space) { switch (cinfo->jpeg_color_space) {
case JCS_GRAYSCALE: case JCS_GRAYSCALE:
if (cinfo->num_components != 1) if (cinfo->num_components != 1)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_GRAYSCALE) switch (cinfo->in_color_space) {
case JCS_GRAYSCALE:
case JCS_YCbCr:
case JCS_BG_YCC:
cconvert->pub.color_convert = grayscale_convert; cconvert->pub.color_convert = grayscale_convert;
else if (cinfo->in_color_space == JCS_RGB) { break;
case JCS_RGB:
cconvert->pub.start_pass = rgb_ycc_start; cconvert->pub.start_pass = rgb_ycc_start;
cconvert->pub.color_convert = rgb_gray_convert; cconvert->pub.color_convert = rgb_gray_convert;
} else if (cinfo->in_color_space == JCS_YCbCr) break;
cconvert->pub.color_convert = grayscale_convert; default:
else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break; break;
case JCS_RGB: case JCS_RGB:
case JCS_BG_RGB:
if (cinfo->num_components != 3) if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) if (cinfo->in_color_space != cinfo->jpeg_color_space)
cconvert->pub.color_convert = null_convert;
else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb_rgb1_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break; break;
case JCS_YCbCr: case JCS_YCbCr:
if (cinfo->num_components != 3) if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_RGB) { switch (cinfo->in_color_space) {
case JCS_RGB:
cconvert->pub.start_pass = rgb_ycc_start; cconvert->pub.start_pass = rgb_ycc_start;
cconvert->pub.color_convert = rgb_ycc_convert; cconvert->pub.color_convert = rgb_ycc_convert;
} else if (cinfo->in_color_space == JCS_YCbCr) break;
case JCS_YCbCr:
cconvert->pub.color_convert = null_convert; cconvert->pub.color_convert = null_convert;
else break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break;
case JCS_BG_YCC:
if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
switch (cinfo->in_color_space) {
case JCS_RGB:
/* For conversion from normal RGB input to BG_YCC representation,
* the Cb/Cr values are first computed as usual, and then
* quantized further after DCT processing by a factor of
* 2 in reference to the nominal quantization factor.
*/
/* need quantization scale by factor of 2 after DCT */
cinfo->comp_info[1].component_needed = TRUE;
cinfo->comp_info[2].component_needed = TRUE;
/* compute normal YCC first */
cconvert->pub.start_pass = rgb_ycc_start;
cconvert->pub.color_convert = rgb_ycc_convert;
break;
case JCS_YCbCr:
/* need quantization scale by factor of 2 after DCT */
cinfo->comp_info[1].component_needed = TRUE;
cinfo->comp_info[2].component_needed = TRUE;
/*FALLTHROUGH*/
case JCS_BG_YCC:
/* Pass through for BG_YCC input */
cconvert->pub.color_convert = null_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break; break;
case JCS_CMYK: case JCS_CMYK:
if (cinfo->num_components != 4) if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK) if (cinfo->in_color_space != JCS_CMYK)
cconvert->pub.color_convert = null_convert;
else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
cconvert->pub.color_convert = null_convert;
break; break;
case JCS_YCCK: case JCS_YCCK:
if (cinfo->num_components != 4) if (cinfo->num_components != 4)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
if (cinfo->in_color_space == JCS_CMYK) { switch (cinfo->in_color_space) {
case JCS_CMYK:
cconvert->pub.start_pass = rgb_ycc_start; cconvert->pub.start_pass = rgb_ycc_start;
cconvert->pub.color_convert = cmyk_ycck_convert; cconvert->pub.color_convert = cmyk_ycck_convert;
} else if (cinfo->in_color_space == JCS_YCCK) break;
case JCS_YCCK:
cconvert->pub.color_convert = null_convert; cconvert->pub.color_convert = null_convert;
else break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break; break;
default: /* allow null conversion of JCS_UNKNOWN */ default: /* allow null conversion of JCS_UNKNOWN */
@ -454,6 +594,5 @@ jinit_color_converter (j_compress_ptr cinfo)
cinfo->num_components != cinfo->input_components) cinfo->num_components != cinfo->input_components)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
cconvert->pub.color_convert = null_convert; cconvert->pub.color_convert = null_convert;
break;
} }
} }

View file

@ -2,6 +2,7 @@
* jcdctmgr.c * jcdctmgr.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2003-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -23,210 +24,73 @@ typedef struct {
struct jpeg_forward_dct pub; /* public fields */ struct jpeg_forward_dct pub; /* public fields */
/* Pointer to the DCT routine actually in use */ /* Pointer to the DCT routine actually in use */
forward_DCT_method_ptr do_dct; forward_DCT_method_ptr do_dct[MAX_COMPONENTS];
/* The actual post-DCT divisors --- not identical to the quant table
* entries, because of scaling (especially for an unnormalized DCT).
* Each table is given in normal array order.
*/
DCTELEM * divisors[NUM_QUANT_TBLS];
#ifdef DCT_FLOAT_SUPPORTED #ifdef DCT_FLOAT_SUPPORTED
/* Same as above for the floating-point case. */ /* Same as above for the floating-point case. */
float_DCT_method_ptr do_float_dct; float_DCT_method_ptr do_float_dct[MAX_COMPONENTS];
FAST_FLOAT * float_divisors[NUM_QUANT_TBLS];
#endif #endif
} my_fdct_controller; } my_fdct_controller;
typedef my_fdct_controller * my_fdct_ptr; typedef my_fdct_controller * my_fdct_ptr;
/* /* The allocated post-DCT divisor tables -- big enough for any
* Initialize for a processing pass. * supported variant and not identical to the quant table entries,
* Verify that all referenced Q-tables are present, and set up * because of scaling (especially for an unnormalized DCT) --
* the divisor table for each one. * are pointed to by dct_table in the per-component comp_info
* In the current implementation, DCT of all components is done during * structures. Each table is given in normal array order.
* the first pass, even if only some components will be output in the
* first scan. Hence all components should be examined here.
*/ */
METHODDEF(void) typedef union {
start_pass_fdctmgr (j_compress_ptr cinfo) DCTELEM int_array[DCTSIZE2];
{
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
int ci, qtblno, i;
jpeg_component_info *compptr;
JQUANT_TBL * qtbl;
DCTELEM * dtbl;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
qtblno = compptr->quant_tbl_no;
/* Make sure specified quantization table is present */
if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
cinfo->quant_tbl_ptrs[qtblno] == NULL)
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
qtbl = cinfo->quant_tbl_ptrs[qtblno];
/* Compute divisors for this quant table */
/* We may do this more than once for same table, but it's not a big deal */
switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED
case JDCT_ISLOW:
/* For LL&M IDCT method, divisors are equal to raw quantization
* coefficients multiplied by 8 (to counteract scaling).
*/
if (fdct->divisors[qtblno] == NULL) {
fdct->divisors[qtblno] = (DCTELEM *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
DCTSIZE2 * SIZEOF(DCTELEM));
}
dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) {
dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;
}
break;
#endif
#ifdef DCT_IFAST_SUPPORTED
case JDCT_IFAST:
{
/* For AA&N IDCT method, divisors are equal to quantization
* coefficients scaled by scalefactor[row]*scalefactor[col], where
* scalefactor[0] = 1
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
* We apply a further scale factor of 8.
*/
#define CONST_BITS 14
static const INT16 aanscales[DCTSIZE2] = {
/* precomputed values scaled up by 14 bits */
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
};
SHIFT_TEMPS
if (fdct->divisors[qtblno] == NULL) {
fdct->divisors[qtblno] = (DCTELEM *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
DCTSIZE2 * SIZEOF(DCTELEM));
}
dtbl = fdct->divisors[qtblno];
for (i = 0; i < DCTSIZE2; i++) {
dtbl[i] = (DCTELEM)
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
(INT32) aanscales[i]),
CONST_BITS-3);
}
}
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED #ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT: FAST_FLOAT float_array[DCTSIZE2];
{ #endif
/* For float AA&N IDCT method, divisors are equal to quantization } divisor_table;
* coefficients scaled by scalefactor[row]*scalefactor[col], where
* scalefactor[0] = 1
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 /* The current scaled-DCT routines require ISLOW-style divisor tables,
* We apply a further scale factor of 8. * so be sure to compile that code if either ISLOW or SCALING is requested.
* What's actually stored is 1/divisor so that the inner loop can */
* use a multiplication rather than a division. #ifdef DCT_ISLOW_SUPPORTED
*/ #define PROVIDE_ISLOW_TABLES
FAST_FLOAT * fdtbl; #else
int row, col; #ifdef DCT_SCALING_SUPPORTED
static const double aanscalefactor[DCTSIZE] = { #define PROVIDE_ISLOW_TABLES
1.0, 1.387039845, 1.306562965, 1.175875602, #endif
1.0, 0.785694958, 0.541196100, 0.275899379
};
if (fdct->float_divisors[qtblno] == NULL) {
fdct->float_divisors[qtblno] = (FAST_FLOAT *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
DCTSIZE2 * SIZEOF(FAST_FLOAT));
}
fdtbl = fdct->float_divisors[qtblno];
i = 0;
for (row = 0; row < DCTSIZE; row++) {
for (col = 0; col < DCTSIZE; col++) {
fdtbl[i] = (FAST_FLOAT)
(1.0 / (((double) qtbl->quantval[i] *
aanscalefactor[row] * aanscalefactor[col] * 8.0)));
i++;
}
}
}
break;
#endif #endif
default:
ERREXIT(cinfo, JERR_NOT_COMPILED);
break;
}
}
}
/* /*
* Perform forward DCT on one or more blocks of a component. * Perform forward DCT on one or more blocks of a component.
* *
* The input samples are taken from the sample_data[] array starting at * The input samples are taken from the sample_data[] array starting at
* position start_row/start_col, and moving to the right for any additional * position start_col, and moving to the right for any additional blocks.
* blocks. The quantized coefficients are returned in coef_blocks[]. * The quantized coefficients are returned in coef_blocks[].
*/ */
METHODDEF(void) METHODDEF(void)
forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks, JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col, JDIMENSION start_col, JDIMENSION num_blocks)
JDIMENSION num_blocks)
/* This version is used for integer DCT implementations. */ /* This version is used for integer DCT implementations. */
{ {
/* This routine is heavily used, so it's worth coding it tightly. */ /* This routine is heavily used, so it's worth coding it tightly. */
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
forward_DCT_method_ptr do_dct = fdct->do_dct; forward_DCT_method_ptr do_dct = fdct->do_dct[compptr->component_index];
DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; DCTELEM * divisors = (DCTELEM *) compptr->dct_table;
DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */
JDIMENSION bi; JDIMENSION bi;
sample_data += start_row; /* fold in the vertical offset once */ for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) {
for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
/* Load data into workspace, applying unsigned->signed conversion */
{ DCTELEM *workspaceptr;
JSAMPROW elemptr;
int elemr;
workspaceptr = workspace;
for (elemr = 0; elemr < DCTSIZE; elemr++) {
elemptr = sample_data[elemr] + start_col;
#if DCTSIZE == 8 /* unroll the inner loop */
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
#else
{ int elemc;
for (elemc = DCTSIZE; elemc > 0; elemc--) {
*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;
}
}
#endif
}
}
/* Perform the DCT */ /* Perform the DCT */
(*do_dct) (workspace); (*do_dct) (workspace, sample_data, start_col);
/* Quantize/descale the coefficients, and store into coef_blocks[] */ /* Quantize/descale the coefficients, and store into coef_blocks[] */
{ DCTELEM temp, qval; { register DCTELEM temp, qval;
int i; register int i;
JCOEFPTR output_ptr = coef_blocks[bi]; register JCOEFPTR output_ptr = coef_blocks[bi];
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i < DCTSIZE2; i++) {
qval = divisors[i]; qval = divisors[i];
@ -269,55 +133,24 @@ forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr,
METHODDEF(void) METHODDEF(void)
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks, JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col, JDIMENSION start_col, JDIMENSION num_blocks)
JDIMENSION num_blocks)
/* This version is used for floating-point DCT implementations. */ /* This version is used for floating-point DCT implementations. */
{ {
/* This routine is heavily used, so it's worth coding it tightly. */ /* This routine is heavily used, so it's worth coding it tightly. */
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
float_DCT_method_ptr do_dct = fdct->do_float_dct; float_DCT_method_ptr do_dct = fdct->do_float_dct[compptr->component_index];
FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; FAST_FLOAT * divisors = (FAST_FLOAT *) compptr->dct_table;
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
JDIMENSION bi; JDIMENSION bi;
sample_data += start_row; /* fold in the vertical offset once */ for (bi = 0; bi < num_blocks; bi++, start_col += compptr->DCT_h_scaled_size) {
for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
/* Load data into workspace, applying unsigned->signed conversion */
{ FAST_FLOAT *workspaceptr;
JSAMPROW elemptr;
int elemr;
workspaceptr = workspace;
for (elemr = 0; elemr < DCTSIZE; elemr++) {
elemptr = sample_data[elemr] + start_col;
#if DCTSIZE == 8 /* unroll the inner loop */
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
#else
{ int elemc;
for (elemc = DCTSIZE; elemc > 0; elemc--) {
*workspaceptr++ = (FAST_FLOAT)
(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);
}
}
#endif
}
}
/* Perform the DCT */ /* Perform the DCT */
(*do_dct) (workspace); (*do_dct) (workspace, sample_data, start_col);
/* Quantize/descale the coefficients, and store into coef_blocks[] */ /* Quantize/descale the coefficients, and store into coef_blocks[] */
{ FAST_FLOAT temp; { register FAST_FLOAT temp;
int i; register int i;
JCOEFPTR output_ptr = coef_blocks[bi]; register JCOEFPTR output_ptr = coef_blocks[bi];
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i < DCTSIZE2; i++) {
/* Apply the quantization and scaling factor */ /* Apply the quantization and scaling factor */
@ -337,6 +170,277 @@ forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
#endif /* DCT_FLOAT_SUPPORTED */ #endif /* DCT_FLOAT_SUPPORTED */
/*
* Initialize for a processing pass.
* Verify that all referenced Q-tables are present, and set up
* the divisor table for each one.
* In the current implementation, DCT of all components is done during
* the first pass, even if only some components will be output in the
* first scan. Hence all components should be examined here.
*/
METHODDEF(void)
start_pass_fdctmgr (j_compress_ptr cinfo)
{
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
int ci, qtblno, i;
jpeg_component_info *compptr;
int method = 0;
JQUANT_TBL * qtbl;
DCTELEM * dtbl;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
/* Select the proper DCT routine for this component's scaling */
switch ((compptr->DCT_h_scaled_size << 8) + compptr->DCT_v_scaled_size) {
#ifdef DCT_SCALING_SUPPORTED
case ((1 << 8) + 1):
fdct->do_dct[ci] = jpeg_fdct_1x1;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((2 << 8) + 2):
fdct->do_dct[ci] = jpeg_fdct_2x2;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((3 << 8) + 3):
fdct->do_dct[ci] = jpeg_fdct_3x3;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((4 << 8) + 4):
fdct->do_dct[ci] = jpeg_fdct_4x4;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((5 << 8) + 5):
fdct->do_dct[ci] = jpeg_fdct_5x5;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((6 << 8) + 6):
fdct->do_dct[ci] = jpeg_fdct_6x6;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((7 << 8) + 7):
fdct->do_dct[ci] = jpeg_fdct_7x7;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((9 << 8) + 9):
fdct->do_dct[ci] = jpeg_fdct_9x9;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((10 << 8) + 10):
fdct->do_dct[ci] = jpeg_fdct_10x10;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((11 << 8) + 11):
fdct->do_dct[ci] = jpeg_fdct_11x11;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((12 << 8) + 12):
fdct->do_dct[ci] = jpeg_fdct_12x12;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((13 << 8) + 13):
fdct->do_dct[ci] = jpeg_fdct_13x13;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((14 << 8) + 14):
fdct->do_dct[ci] = jpeg_fdct_14x14;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((15 << 8) + 15):
fdct->do_dct[ci] = jpeg_fdct_15x15;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((16 << 8) + 16):
fdct->do_dct[ci] = jpeg_fdct_16x16;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((16 << 8) + 8):
fdct->do_dct[ci] = jpeg_fdct_16x8;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((14 << 8) + 7):
fdct->do_dct[ci] = jpeg_fdct_14x7;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((12 << 8) + 6):
fdct->do_dct[ci] = jpeg_fdct_12x6;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((10 << 8) + 5):
fdct->do_dct[ci] = jpeg_fdct_10x5;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((8 << 8) + 4):
fdct->do_dct[ci] = jpeg_fdct_8x4;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((6 << 8) + 3):
fdct->do_dct[ci] = jpeg_fdct_6x3;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((4 << 8) + 2):
fdct->do_dct[ci] = jpeg_fdct_4x2;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((2 << 8) + 1):
fdct->do_dct[ci] = jpeg_fdct_2x1;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((8 << 8) + 16):
fdct->do_dct[ci] = jpeg_fdct_8x16;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((7 << 8) + 14):
fdct->do_dct[ci] = jpeg_fdct_7x14;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((6 << 8) + 12):
fdct->do_dct[ci] = jpeg_fdct_6x12;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((5 << 8) + 10):
fdct->do_dct[ci] = jpeg_fdct_5x10;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((4 << 8) + 8):
fdct->do_dct[ci] = jpeg_fdct_4x8;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((3 << 8) + 6):
fdct->do_dct[ci] = jpeg_fdct_3x6;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((2 << 8) + 4):
fdct->do_dct[ci] = jpeg_fdct_2x4;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
case ((1 << 8) + 2):
fdct->do_dct[ci] = jpeg_fdct_1x2;
method = JDCT_ISLOW; /* jfdctint uses islow-style table */
break;
#endif
case ((DCTSIZE << 8) + DCTSIZE):
switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED
case JDCT_ISLOW:
fdct->do_dct[ci] = jpeg_fdct_islow;
method = JDCT_ISLOW;
break;
#endif
#ifdef DCT_IFAST_SUPPORTED
case JDCT_IFAST:
fdct->do_dct[ci] = jpeg_fdct_ifast;
method = JDCT_IFAST;
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT:
fdct->do_float_dct[ci] = jpeg_fdct_float;
method = JDCT_FLOAT;
break;
#endif
default:
ERREXIT(cinfo, JERR_NOT_COMPILED);
}
break;
default:
ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size);
}
qtblno = compptr->quant_tbl_no;
/* Make sure specified quantization table is present */
if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
cinfo->quant_tbl_ptrs[qtblno] == NULL)
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
qtbl = cinfo->quant_tbl_ptrs[qtblno];
/* Create divisor table from quant table */
switch (method) {
#ifdef PROVIDE_ISLOW_TABLES
case JDCT_ISLOW:
/* For LL&M IDCT method, divisors are equal to raw quantization
* coefficients multiplied by 8 (to counteract scaling).
*/
dtbl = (DCTELEM *) compptr->dct_table;
for (i = 0; i < DCTSIZE2; i++) {
dtbl[i] =
((DCTELEM) qtbl->quantval[i]) << (compptr->component_needed ? 4 : 3);
}
fdct->pub.forward_DCT[ci] = forward_DCT;
break;
#endif
#ifdef DCT_IFAST_SUPPORTED
case JDCT_IFAST:
{
/* For AA&N IDCT method, divisors are equal to quantization
* coefficients scaled by scalefactor[row]*scalefactor[col], where
* scalefactor[0] = 1
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
* We apply a further scale factor of 8.
*/
#define CONST_BITS 14
static const INT16 aanscales[DCTSIZE2] = {
/* precomputed values scaled up by 14 bits */
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,
21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,
19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,
16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,
12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,
8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,
4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247
};
SHIFT_TEMPS
dtbl = (DCTELEM *) compptr->dct_table;
for (i = 0; i < DCTSIZE2; i++) {
dtbl[i] = (DCTELEM)
DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i],
(INT32) aanscales[i]),
compptr->component_needed ? CONST_BITS-4 : CONST_BITS-3);
}
}
fdct->pub.forward_DCT[ci] = forward_DCT;
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT:
{
/* For float AA&N IDCT method, divisors are equal to quantization
* coefficients scaled by scalefactor[row]*scalefactor[col], where
* scalefactor[0] = 1
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
* We apply a further scale factor of 8.
* What's actually stored is 1/divisor so that the inner loop can
* use a multiplication rather than a division.
*/
FAST_FLOAT * fdtbl = (FAST_FLOAT *) compptr->dct_table;
int row, col;
static const double aanscalefactor[DCTSIZE] = {
1.0, 1.387039845, 1.306562965, 1.175875602,
1.0, 0.785694958, 0.541196100, 0.275899379
};
i = 0;
for (row = 0; row < DCTSIZE; row++) {
for (col = 0; col < DCTSIZE; col++) {
fdtbl[i] = (FAST_FLOAT)
(1.0 / ((double) qtbl->quantval[i] *
aanscalefactor[row] * aanscalefactor[col] *
(compptr->component_needed ? 16.0 : 8.0)));
i++;
}
}
}
fdct->pub.forward_DCT[ci] = forward_DCT_float;
break;
#endif
default:
ERREXIT(cinfo, JERR_NOT_COMPILED);
}
}
}
/* /*
* Initialize FDCT manager. * Initialize FDCT manager.
*/ */
@ -345,43 +449,18 @@ GLOBAL(void)
jinit_forward_dct (j_compress_ptr cinfo) jinit_forward_dct (j_compress_ptr cinfo)
{ {
my_fdct_ptr fdct; my_fdct_ptr fdct;
int i; int ci;
jpeg_component_info *compptr;
fdct = (my_fdct_ptr) fdct = (my_fdct_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_fdct_controller));
SIZEOF(my_fdct_controller)); cinfo->fdct = &fdct->pub;
cinfo->fdct = (struct jpeg_forward_dct *) fdct;
fdct->pub.start_pass = start_pass_fdctmgr; fdct->pub.start_pass = start_pass_fdctmgr;
switch (cinfo->dct_method) { for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
#ifdef DCT_ISLOW_SUPPORTED ci++, compptr++) {
case JDCT_ISLOW: /* Allocate a divisor table for each component */
fdct->pub.forward_DCT = forward_DCT; compptr->dct_table = (*cinfo->mem->alloc_small)
fdct->do_dct = jpeg_fdct_islow; ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(divisor_table));
break;
#endif
#ifdef DCT_IFAST_SUPPORTED
case JDCT_IFAST:
fdct->pub.forward_DCT = forward_DCT;
fdct->do_dct = jpeg_fdct_ifast;
break;
#endif
#ifdef DCT_FLOAT_SUPPORTED
case JDCT_FLOAT:
fdct->pub.forward_DCT = forward_DCT_float;
fdct->do_float_dct = jpeg_fdct_float;
break;
#endif
default:
ERREXIT(cinfo, JERR_NOT_COMPILED);
break;
}
/* Mark divisor tables unallocated */
for (i = 0; i < NUM_QUANT_TBLS; i++) {
fdct->divisors[i] = NULL;
#ifdef DCT_FLOAT_SUPPORTED
fdct->float_divisors[i] = NULL;
#endif
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -1,52 +0,0 @@
/*
* jchuff.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains declarations for Huffman entropy encoding routines
* that are shared between the sequential encoder (jchuff.c) and the
* progressive encoder (jcphuff.c). No other modules need to see these.
*/
/* The legal range of a DCT coefficient is
* -1024 .. +1023 for 8-bit data;
* -16384 .. +16383 for 12-bit data.
* Hence the magnitude should always fit in 10 or 14 bits respectively.
*/
#ifndef _jchuff_h_
#define _jchuff_h_
#if BITS_IN_JSAMPLE == 8
#define MAX_COEF_BITS 10
#else
#define MAX_COEF_BITS 14
#endif
/* Derived data constructed for each Huffman table */
typedef struct {
unsigned int ehufco[256]; /* code for each symbol */
char ehufsi[256]; /* length of code for each symbol */
/* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
} c_derived_tbl;
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jpeg_make_c_derived_tbl jMkCDerived
#define jpeg_gen_optimal_table jGenOptTbl
#endif /* NEED_SHORT_EXTERNAL_NAMES */
/* Expand a Huffman table definition into the derived format */
EXTERN(void) jpeg_make_c_derived_tbl
JPP((j_compress_ptr cinfo, boolean isDC, int tblno,
c_derived_tbl ** pdtbl));
/* Generate an optimal table definition given the specified counts */
EXTERN(void) jpeg_gen_optimal_table
JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]));
#endif

View file

@ -2,6 +2,7 @@
* jcinit.c * jcinit.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2003-2017 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -20,6 +21,168 @@
#include "jpeglib.h" #include "jpeglib.h"
/*
* Compute JPEG image dimensions and related values.
* NOTE: this is exported for possible use by application.
* Hence it mustn't do anything that can't be done twice.
*/
GLOBAL(void)
jpeg_calc_jpeg_dimensions (j_compress_ptr cinfo)
/* Do computations that are needed before master selection phase */
{
/* Sanity check on input image dimensions to prevent overflow in
* following calculations.
* We do check jpeg_width and jpeg_height in initial_setup in jcmaster.c,
* but image_width and image_height can come from arbitrary data,
* and we need some space for multiplication by block_size.
*/
if (((long) cinfo->image_width >> 24) || ((long) cinfo->image_height >> 24))
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
#ifdef DCT_SCALING_SUPPORTED
/* Compute actual JPEG image dimensions and DCT scaling choices. */
if (cinfo->scale_num >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/1 scaling */
cinfo->jpeg_width = cinfo->image_width * cinfo->block_size;
cinfo->jpeg_height = cinfo->image_height * cinfo->block_size;
cinfo->min_DCT_h_scaled_size = 1;
cinfo->min_DCT_v_scaled_size = 1;
} else if (cinfo->scale_num * 2 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/2 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 2L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 2L);
cinfo->min_DCT_h_scaled_size = 2;
cinfo->min_DCT_v_scaled_size = 2;
} else if (cinfo->scale_num * 3 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/3 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 3L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 3L);
cinfo->min_DCT_h_scaled_size = 3;
cinfo->min_DCT_v_scaled_size = 3;
} else if (cinfo->scale_num * 4 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/4 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 4L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 4L);
cinfo->min_DCT_h_scaled_size = 4;
cinfo->min_DCT_v_scaled_size = 4;
} else if (cinfo->scale_num * 5 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/5 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 5L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 5L);
cinfo->min_DCT_h_scaled_size = 5;
cinfo->min_DCT_v_scaled_size = 5;
} else if (cinfo->scale_num * 6 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/6 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 6L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 6L);
cinfo->min_DCT_h_scaled_size = 6;
cinfo->min_DCT_v_scaled_size = 6;
} else if (cinfo->scale_num * 7 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/7 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 7L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 7L);
cinfo->min_DCT_h_scaled_size = 7;
cinfo->min_DCT_v_scaled_size = 7;
} else if (cinfo->scale_num * 8 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/8 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 8L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 8L);
cinfo->min_DCT_h_scaled_size = 8;
cinfo->min_DCT_v_scaled_size = 8;
} else if (cinfo->scale_num * 9 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/9 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 9L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 9L);
cinfo->min_DCT_h_scaled_size = 9;
cinfo->min_DCT_v_scaled_size = 9;
} else if (cinfo->scale_num * 10 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/10 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 10L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 10L);
cinfo->min_DCT_h_scaled_size = 10;
cinfo->min_DCT_v_scaled_size = 10;
} else if (cinfo->scale_num * 11 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/11 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 11L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 11L);
cinfo->min_DCT_h_scaled_size = 11;
cinfo->min_DCT_v_scaled_size = 11;
} else if (cinfo->scale_num * 12 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/12 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 12L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 12L);
cinfo->min_DCT_h_scaled_size = 12;
cinfo->min_DCT_v_scaled_size = 12;
} else if (cinfo->scale_num * 13 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/13 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 13L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 13L);
cinfo->min_DCT_h_scaled_size = 13;
cinfo->min_DCT_v_scaled_size = 13;
} else if (cinfo->scale_num * 14 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/14 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 14L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 14L);
cinfo->min_DCT_h_scaled_size = 14;
cinfo->min_DCT_v_scaled_size = 14;
} else if (cinfo->scale_num * 15 >= cinfo->scale_denom * cinfo->block_size) {
/* Provide block_size/15 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 15L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 15L);
cinfo->min_DCT_h_scaled_size = 15;
cinfo->min_DCT_v_scaled_size = 15;
} else {
/* Provide block_size/16 scaling */
cinfo->jpeg_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * cinfo->block_size, 16L);
cinfo->jpeg_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * cinfo->block_size, 16L);
cinfo->min_DCT_h_scaled_size = 16;
cinfo->min_DCT_v_scaled_size = 16;
}
#else /* !DCT_SCALING_SUPPORTED */
/* Hardwire it to "no scaling" */
cinfo->jpeg_width = cinfo->image_width;
cinfo->jpeg_height = cinfo->image_height;
cinfo->min_DCT_h_scaled_size = DCTSIZE;
cinfo->min_DCT_v_scaled_size = DCTSIZE;
#endif /* DCT_SCALING_SUPPORTED */
}
/* /*
* Master selection of compression modules. * Master selection of compression modules.
* This is done once at the start of processing an image. We determine * This is done once at the start of processing an image. We determine
@ -29,6 +192,27 @@
GLOBAL(void) GLOBAL(void)
jinit_compress_master (j_compress_ptr cinfo) jinit_compress_master (j_compress_ptr cinfo)
{ {
long samplesperrow;
JDIMENSION jd_samplesperrow;
/* For now, precision must match compiled-in value... */
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Sanity check on input image dimensions */
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
cinfo->input_components <= 0)
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
/* Width of an input scanline must be representable as JDIMENSION. */
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components;
jd_samplesperrow = (JDIMENSION) samplesperrow;
if ((long) jd_samplesperrow != samplesperrow)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
/* Compute JPEG image dimensions and related values. */
jpeg_calc_jpeg_dimensions(cinfo);
/* Initialize master control (includes parameter checking/processing) */ /* Initialize master control (includes parameter checking/processing) */
jinit_c_master_control(cinfo, FALSE /* full compression */); jinit_c_master_control(cinfo, FALSE /* full compression */);
@ -41,17 +225,10 @@ jinit_compress_master (j_compress_ptr cinfo)
/* Forward DCT */ /* Forward DCT */
jinit_forward_dct(cinfo); jinit_forward_dct(cinfo);
/* Entropy encoding: either Huffman or arithmetic coding. */ /* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code)
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); jinit_arith_encoder(cinfo);
} else { else {
if (cinfo->progressive_mode) { jinit_huff_encoder(cinfo);
#ifdef C_PROGRESSIVE_SUPPORTED
jinit_phuff_encoder(cinfo);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else
jinit_huff_encoder(cinfo);
} }
/* Need a full-image coefficient buffer in any multi-pass mode. */ /* Need a full-image coefficient buffer in any multi-pass mode. */

View file

@ -2,6 +2,7 @@
* jcmainct.c * jcmainct.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2003-2012 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -68,32 +69,32 @@ METHODDEF(void) process_data_buffer_main
METHODDEF(void) METHODDEF(void)
start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
{ {
my_main_ptr main_ = (my_main_ptr) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
/* Do nothing in raw-data mode. */ /* Do nothing in raw-data mode. */
if (cinfo->raw_data_in) if (cinfo->raw_data_in)
return; return;
main_->cur_iMCU_row = 0; /* initialize counters */ mainp->cur_iMCU_row = 0; /* initialize counters */
main_->rowgroup_ctr = 0; mainp->rowgroup_ctr = 0;
main_->suspended = FALSE; mainp->suspended = FALSE;
main_->pass_mode = pass_mode; /* save mode for use by process_data */ mainp->pass_mode = pass_mode; /* save mode for use by process_data */
switch (pass_mode) { switch (pass_mode) {
case JBUF_PASS_THRU: case JBUF_PASS_THRU:
#ifdef FULL_MAIN_BUFFER_SUPPORTED #ifdef FULL_MAIN_BUFFER_SUPPORTED
if (main_->whole_image[0] != NULL) if (mainp->whole_image[0] != NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
#endif #endif
main_->pub.process_data = process_data_simple_main; mainp->pub.process_data = process_data_simple_main;
break; break;
#ifdef FULL_MAIN_BUFFER_SUPPORTED #ifdef FULL_MAIN_BUFFER_SUPPORTED
case JBUF_SAVE_SOURCE: case JBUF_SAVE_SOURCE:
case JBUF_CRANK_DEST: case JBUF_CRANK_DEST:
case JBUF_SAVE_AND_PASS: case JBUF_SAVE_AND_PASS:
if (main_->whole_image[0] == NULL) if (mainp->whole_image[0] == NULL)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
main_->pub.process_data = process_data_buffer_main; mainp->pub.process_data = process_data_buffer_main;
break; break;
#endif #endif
default: default:
@ -114,46 +115,46 @@ process_data_simple_main (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
JDIMENSION in_rows_avail) JDIMENSION in_rows_avail)
{ {
my_main_ptr main_ = (my_main_ptr) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
while (main_->cur_iMCU_row < cinfo->total_iMCU_rows) { while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
/* Read input data if we haven't filled the main buffer yet */ /* Read input data if we haven't filled the main buffer yet */
if (main_->rowgroup_ctr < DCTSIZE) if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
(*cinfo->prep->pre_process_data) (cinfo, (*cinfo->prep->pre_process_data) (cinfo,
input_buf, in_row_ctr, in_rows_avail, input_buf, in_row_ctr, in_rows_avail,
main_->buffer, &main_->rowgroup_ctr, mainp->buffer, &mainp->rowgroup_ctr,
(JDIMENSION) DCTSIZE); (JDIMENSION) cinfo->min_DCT_v_scaled_size);
/* If we don't have a full iMCU row buffered, return to application for /* If we don't have a full iMCU row buffered, return to application for
* more data. Note that preprocessor will always pad to fill the iMCU row * more data. Note that preprocessor will always pad to fill the iMCU row
* at the bottom of the image. * at the bottom of the image.
*/ */
if (main_->rowgroup_ctr != DCTSIZE) if (mainp->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size)
return; return;
/* Send the completed row to the compressor */ /* Send the completed row to the compressor */
if (! (*cinfo->coef->compress_data) (cinfo, main_->buffer)) { if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
/* If compressor did not consume the whole row, then we must need to /* If compressor did not consume the whole row, then we must need to
* suspend processing and return to the application. In this situation * suspend processing and return to the application. In this situation
* we pretend we didn't yet consume the last input row; otherwise, if * we pretend we didn't yet consume the last input row; otherwise, if
* it happened to be the last row of the image, the application would * it happened to be the last row of the image, the application would
* think we were done. * think we were done.
*/ */
if (! main_->suspended) { if (! mainp->suspended) {
(*in_row_ctr)--; (*in_row_ctr)--;
main_->suspended = TRUE; mainp->suspended = TRUE;
} }
return; return;
} }
/* We did finish the row. Undo our little suspension hack if a previous /* We did finish the row. Undo our little suspension hack if a previous
* call suspended; then mark the main buffer empty. * call suspended; then mark the main buffer empty.
*/ */
if (main_->suspended) { if (mainp->suspended) {
(*in_row_ctr)++; (*in_row_ctr)++;
main_->suspended = FALSE; mainp->suspended = FALSE;
} }
main_->rowgroup_ctr = 0; mainp->rowgroup_ctr = 0;
main_->cur_iMCU_row++; mainp->cur_iMCU_row++;
} }
} }
@ -170,25 +171,27 @@ process_data_buffer_main (j_compress_ptr cinfo,
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
JDIMENSION in_rows_avail) JDIMENSION in_rows_avail)
{ {
my_main_ptr main = (my_main_ptr) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
int ci; int ci;
jpeg_component_info *compptr; jpeg_component_info *compptr;
boolean writing = (main->pass_mode != JBUF_CRANK_DEST); boolean writing = (mainp->pass_mode != JBUF_CRANK_DEST);
while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { while (mainp->cur_iMCU_row < cinfo->total_iMCU_rows) {
/* Realign the virtual buffers if at the start of an iMCU row. */ /* Realign the virtual buffers if at the start of an iMCU row. */
if (main->rowgroup_ctr == 0) { if (mainp->rowgroup_ctr == 0) {
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
main->buffer[ci] = (*cinfo->mem->access_virt_sarray) mainp->buffer[ci] = (*cinfo->mem->access_virt_sarray)
((j_common_ptr) cinfo, main->whole_image[ci], ((j_common_ptr) cinfo, mainp->whole_image[ci], mainp->cur_iMCU_row *
main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), ((JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size)),
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); (JDIMENSION) (compptr->v_samp_factor * cinfo->min_DCT_v_scaled_size),
writing);
} }
/* In a read pass, pretend we just read some source data. */ /* In a read pass, pretend we just read some source data. */
if (! writing) { if (! writing) {
*in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; *in_row_ctr += (JDIMENSION)
main->rowgroup_ctr = DCTSIZE; (cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size);
mainp->rowgroup_ctr = (JDIMENSION) cinfo->min_DCT_v_scaled_size;
} }
} }
@ -197,40 +200,40 @@ process_data_buffer_main (j_compress_ptr cinfo,
if (writing) { if (writing) {
(*cinfo->prep->pre_process_data) (cinfo, (*cinfo->prep->pre_process_data) (cinfo,
input_buf, in_row_ctr, in_rows_avail, input_buf, in_row_ctr, in_rows_avail,
main->buffer, &main->rowgroup_ctr, mainp->buffer, &mainp->rowgroup_ctr,
(JDIMENSION) DCTSIZE); (JDIMENSION) cinfo->min_DCT_v_scaled_size);
/* Return to application if we need more data to fill the iMCU row. */ /* Return to application if we need more data to fill the iMCU row. */
if (main->rowgroup_ctr < DCTSIZE) if (mainp->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
return; return;
} }
/* Emit data, unless this is a sink-only pass. */ /* Emit data, unless this is a sink-only pass. */
if (main->pass_mode != JBUF_SAVE_SOURCE) { if (mainp->pass_mode != JBUF_SAVE_SOURCE) {
if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { if (! (*cinfo->coef->compress_data) (cinfo, mainp->buffer)) {
/* If compressor did not consume the whole row, then we must need to /* If compressor did not consume the whole row, then we must need to
* suspend processing and return to the application. In this situation * suspend processing and return to the application. In this situation
* we pretend we didn't yet consume the last input row; otherwise, if * we pretend we didn't yet consume the last input row; otherwise, if
* it happened to be the last row of the image, the application would * it happened to be the last row of the image, the application would
* think we were done. * think we were done.
*/ */
if (! main->suspended) { if (! mainp->suspended) {
(*in_row_ctr)--; (*in_row_ctr)--;
main->suspended = TRUE; mainp->suspended = TRUE;
} }
return; return;
} }
/* We did finish the row. Undo our little suspension hack if a previous /* We did finish the row. Undo our little suspension hack if a previous
* call suspended; then mark the main buffer empty. * call suspended; then mark the main buffer empty.
*/ */
if (main->suspended) { if (mainp->suspended) {
(*in_row_ctr)++; (*in_row_ctr)++;
main->suspended = FALSE; mainp->suspended = FALSE;
} }
} }
/* If get here, we are done with this iMCU row. Mark buffer empty. */ /* If get here, we are done with this iMCU row. Mark buffer empty. */
main->rowgroup_ctr = 0; mainp->rowgroup_ctr = 0;
main->cur_iMCU_row++; mainp->cur_iMCU_row++;
} }
} }
@ -244,15 +247,15 @@ process_data_buffer_main (j_compress_ptr cinfo,
GLOBAL(void) GLOBAL(void)
jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
{ {
my_main_ptr main_; my_main_ptr mainp;
int ci; int ci;
jpeg_component_info *compptr; jpeg_component_info *compptr;
main_ = (my_main_ptr) mainp = (my_main_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_main_controller)); SIZEOF(my_main_controller));
cinfo->main = (struct jpeg_c_main_controller *) main_; cinfo->main = &mainp->pub;
main_->pub.start_pass = start_pass_main; mainp->pub.start_pass = start_pass_main;
/* We don't need to create a buffer in raw-data mode. */ /* We don't need to create a buffer in raw-data mode. */
if (cinfo->raw_data_in) if (cinfo->raw_data_in)
@ -267,27 +270,28 @@ jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
/* Note we pad the bottom to a multiple of the iMCU height */ /* Note we pad the bottom to a multiple of the iMCU height */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) mainp->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
compptr->width_in_blocks * DCTSIZE, compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
(JDIMENSION) jround_up((long) compptr->height_in_blocks, ((JDIMENSION) jround_up((long) compptr->height_in_blocks,
(long) compptr->v_samp_factor) * DCTSIZE, (long) compptr->v_samp_factor)) *
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); ((JDIMENSION) cinfo->min_DCT_v_scaled_size),
(JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
} }
#else #else
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
#endif #endif
} else { } else {
#ifdef FULL_MAIN_BUFFER_SUPPORTED #ifdef FULL_MAIN_BUFFER_SUPPORTED
main_->whole_image[0] = NULL; /* flag for no virtual arrays */ mainp->whole_image[0] = NULL; /* flag for no virtual arrays */
#endif #endif
/* Allocate a strip buffer for each component */ /* Allocate a strip buffer for each component */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
main_->buffer[ci] = (*cinfo->mem->alloc_sarray) mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
compptr->width_in_blocks * DCTSIZE, compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); (JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
} }
} }
} }

View file

@ -2,6 +2,7 @@
* jcmarker.c * jcmarker.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -13,6 +14,74 @@
#include "jpeglib.h" #include "jpeglib.h"
typedef enum { /* JPEG marker codes */
M_SOF0 = 0xc0,
M_SOF1 = 0xc1,
M_SOF2 = 0xc2,
M_SOF3 = 0xc3,
M_SOF5 = 0xc5,
M_SOF6 = 0xc6,
M_SOF7 = 0xc7,
M_JPG = 0xc8,
M_SOF9 = 0xc9,
M_SOF10 = 0xca,
M_SOF11 = 0xcb,
M_SOF13 = 0xcd,
M_SOF14 = 0xce,
M_SOF15 = 0xcf,
M_DHT = 0xc4,
M_DAC = 0xcc,
M_RST0 = 0xd0,
M_RST1 = 0xd1,
M_RST2 = 0xd2,
M_RST3 = 0xd3,
M_RST4 = 0xd4,
M_RST5 = 0xd5,
M_RST6 = 0xd6,
M_RST7 = 0xd7,
M_SOI = 0xd8,
M_EOI = 0xd9,
M_SOS = 0xda,
M_DQT = 0xdb,
M_DNL = 0xdc,
M_DRI = 0xdd,
M_DHP = 0xde,
M_EXP = 0xdf,
M_APP0 = 0xe0,
M_APP1 = 0xe1,
M_APP2 = 0xe2,
M_APP3 = 0xe3,
M_APP4 = 0xe4,
M_APP5 = 0xe5,
M_APP6 = 0xe6,
M_APP7 = 0xe7,
M_APP8 = 0xe8,
M_APP9 = 0xe9,
M_APP10 = 0xea,
M_APP11 = 0xeb,
M_APP12 = 0xec,
M_APP13 = 0xed,
M_APP14 = 0xee,
M_APP15 = 0xef,
M_JPG0 = 0xf0,
M_JPG8 = 0xf8,
M_JPG13 = 0xfd,
M_COM = 0xfe,
M_TEM = 0x01,
M_ERROR = 0x100
} JPEG_MARKER;
/* Private state */ /* Private state */
@ -86,21 +155,22 @@ emit_dqt (j_compress_ptr cinfo, int index)
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
prec = 0; prec = 0;
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i <= cinfo->lim_Se; i++) {
if (qtbl->quantval[i] > 255) if (qtbl->quantval[cinfo->natural_order[i]] > 255)
prec = 1; prec = 1;
} }
if (! qtbl->sent_table) { if (! qtbl->sent_table) {
emit_marker(cinfo, M_DQT); emit_marker(cinfo, M_DQT);
emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); emit_2bytes(cinfo,
prec ? cinfo->lim_Se * 2 + 2 + 1 + 2 : cinfo->lim_Se + 1 + 1 + 2);
emit_byte(cinfo, index + (prec<<4)); emit_byte(cinfo, index + (prec<<4));
for (i = 0; i < DCTSIZE2; i++) { for (i = 0; i <= cinfo->lim_Se; i++) {
/* The table entries must be emitted in zigzag order. */ /* The table entries must be emitted in zigzag order. */
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; unsigned int qval = qtbl->quantval[cinfo->natural_order[i]];
if (prec) if (prec)
emit_byte(cinfo, (int) (qval >> 8)); emit_byte(cinfo, (int) (qval >> 8));
emit_byte(cinfo, (int) (qval & 0xFF)); emit_byte(cinfo, (int) (qval & 0xFF));
@ -119,7 +189,7 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
{ {
JHUFF_TBL * htbl; JHUFF_TBL * htbl;
int length, i; int length, i;
if (is_ac) { if (is_ac) {
htbl = cinfo->ac_huff_tbl_ptrs[index]; htbl = cinfo->ac_huff_tbl_ptrs[index];
index += 0x10; /* output index has AC bit set */ index += 0x10; /* output index has AC bit set */
@ -129,30 +199,30 @@ emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
if (htbl == NULL) if (htbl == NULL)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
if (! htbl->sent_table) { if (! htbl->sent_table) {
emit_marker(cinfo, M_DHT); emit_marker(cinfo, M_DHT);
length = 0; length = 0;
for (i = 1; i <= 16; i++) for (i = 1; i <= 16; i++)
length += htbl->bits[i]; length += htbl->bits[i];
emit_2bytes(cinfo, length + 2 + 1 + 16); emit_2bytes(cinfo, length + 2 + 1 + 16);
emit_byte(cinfo, index); emit_byte(cinfo, index);
for (i = 1; i <= 16; i++) for (i = 1; i <= 16; i++)
emit_byte(cinfo, htbl->bits[i]); emit_byte(cinfo, htbl->bits[i]);
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
emit_byte(cinfo, htbl->huffval[i]); emit_byte(cinfo, htbl->huffval[i]);
htbl->sent_table = TRUE; htbl->sent_table = TRUE;
} }
} }
LOCAL(void) LOCAL(void)
emit_dac (j_compress_ptr) emit_dac (j_compress_ptr cinfo)
/* Emit a DAC marker */ /* Emit a DAC marker */
/* Since the useful info is so small, we want to emit all the tables in */ /* Since the useful info is so small, we want to emit all the tables in */
/* one DAC marker. Therefore this routine does its own scan of the table. */ /* one DAC marker. Therefore this routine does its own scan of the table. */
@ -168,26 +238,32 @@ emit_dac (j_compress_ptr)
for (i = 0; i < cinfo->comps_in_scan; i++) { for (i = 0; i < cinfo->comps_in_scan; i++) {
compptr = cinfo->cur_comp_info[i]; compptr = cinfo->cur_comp_info[i];
dc_in_use[compptr->dc_tbl_no] = 1; /* DC needs no table for refinement scan */
ac_in_use[compptr->ac_tbl_no] = 1; if (cinfo->Ss == 0 && cinfo->Ah == 0)
dc_in_use[compptr->dc_tbl_no] = 1;
/* AC needs no table when not present */
if (cinfo->Se)
ac_in_use[compptr->ac_tbl_no] = 1;
} }
length = 0; length = 0;
for (i = 0; i < NUM_ARITH_TBLS; i++) for (i = 0; i < NUM_ARITH_TBLS; i++)
length += dc_in_use[i] + ac_in_use[i]; length += dc_in_use[i] + ac_in_use[i];
emit_marker(cinfo, M_DAC); if (length) {
emit_marker(cinfo, M_DAC);
emit_2bytes(cinfo, length*2 + 2); emit_2bytes(cinfo, length*2 + 2);
for (i = 0; i < NUM_ARITH_TBLS; i++) { for (i = 0; i < NUM_ARITH_TBLS; i++) {
if (dc_in_use[i]) { if (dc_in_use[i]) {
emit_byte(cinfo, i); emit_byte(cinfo, i);
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
} }
if (ac_in_use[i]) { if (ac_in_use[i]) {
emit_byte(cinfo, i + 0x10); emit_byte(cinfo, i + 0x10);
emit_byte(cinfo, cinfo->arith_ac_K[i]); emit_byte(cinfo, cinfo->arith_ac_K[i]);
}
} }
} }
#endif /* C_ARITH_CODING_SUPPORTED */ #endif /* C_ARITH_CODING_SUPPORTED */
@ -199,32 +275,63 @@ emit_dri (j_compress_ptr cinfo)
/* Emit a DRI marker */ /* Emit a DRI marker */
{ {
emit_marker(cinfo, M_DRI); emit_marker(cinfo, M_DRI);
emit_2bytes(cinfo, 4); /* fixed length */ emit_2bytes(cinfo, 4); /* fixed length */
emit_2bytes(cinfo, (int) cinfo->restart_interval); emit_2bytes(cinfo, (int) cinfo->restart_interval);
} }
LOCAL(void)
emit_lse_ict (j_compress_ptr cinfo)
/* Emit an LSE inverse color transform specification marker */
{
/* Support only 1 transform */
if (cinfo->color_transform != JCT_SUBTRACT_GREEN ||
cinfo->num_components < 3)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
emit_marker(cinfo, M_JPG8);
emit_2bytes(cinfo, 24); /* fixed length */
emit_byte(cinfo, 0x0D); /* ID inverse transform specification */
emit_2bytes(cinfo, MAXJSAMPLE); /* MAXTRANS */
emit_byte(cinfo, 3); /* Nt=3 */
emit_byte(cinfo, cinfo->comp_info[1].component_id);
emit_byte(cinfo, cinfo->comp_info[0].component_id);
emit_byte(cinfo, cinfo->comp_info[2].component_id);
emit_byte(cinfo, 0x80); /* F1: CENTER1=1, NORM1=0 */
emit_2bytes(cinfo, 0); /* A(1,1)=0 */
emit_2bytes(cinfo, 0); /* A(1,2)=0 */
emit_byte(cinfo, 0); /* F2: CENTER2=0, NORM2=0 */
emit_2bytes(cinfo, 1); /* A(2,1)=1 */
emit_2bytes(cinfo, 0); /* A(2,2)=0 */
emit_byte(cinfo, 0); /* F3: CENTER3=0, NORM3=0 */
emit_2bytes(cinfo, 1); /* A(3,1)=1 */
emit_2bytes(cinfo, 0); /* A(3,2)=0 */
}
LOCAL(void) LOCAL(void)
emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
/* Emit a SOF marker */ /* Emit a SOF marker */
{ {
int ci; int ci;
jpeg_component_info *compptr; jpeg_component_info *compptr;
emit_marker(cinfo, code); emit_marker(cinfo, code);
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
/* Make sure image isn't bigger than SOF field can handle */ /* Make sure image isn't bigger than SOF field can handle */
if ((long) cinfo->image_height > 65535L || if ((long) cinfo->jpeg_height > 65535L ||
(long) cinfo->image_width > 65535L) (long) cinfo->jpeg_width > 65535L)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
emit_byte(cinfo, cinfo->data_precision); emit_byte(cinfo, cinfo->data_precision);
emit_2bytes(cinfo, (int) cinfo->image_height); emit_2bytes(cinfo, (int) cinfo->jpeg_height);
emit_2bytes(cinfo, (int) cinfo->image_width); emit_2bytes(cinfo, (int) cinfo->jpeg_width);
emit_byte(cinfo, cinfo->num_components); emit_byte(cinfo, cinfo->num_components);
@ -243,32 +350,26 @@ emit_sos (j_compress_ptr cinfo)
{ {
int i, td, ta; int i, td, ta;
jpeg_component_info *compptr; jpeg_component_info *compptr;
emit_marker(cinfo, M_SOS); emit_marker(cinfo, M_SOS);
emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
emit_byte(cinfo, cinfo->comps_in_scan); emit_byte(cinfo, cinfo->comps_in_scan);
for (i = 0; i < cinfo->comps_in_scan; i++) { for (i = 0; i < cinfo->comps_in_scan; i++) {
compptr = cinfo->cur_comp_info[i]; compptr = cinfo->cur_comp_info[i];
emit_byte(cinfo, compptr->component_id); emit_byte(cinfo, compptr->component_id);
td = compptr->dc_tbl_no;
ta = compptr->ac_tbl_no; /* We emit 0 for unused field(s); this is recommended by the P&M text
if (cinfo->progressive_mode) { * but does not seem to be specified in the standard.
/* Progressive mode: only DC or only AC tables are used in one scan; */
* furthermore, Huffman coding of DC refinement uses no table at all.
* We emit 0 for unused field(s); this is recommended by the P&M text /* DC needs no table for refinement scan */
* but does not seem to be specified in the standard. td = cinfo->Ss == 0 && cinfo->Ah == 0 ? compptr->dc_tbl_no : 0;
*/ /* AC needs no table when not present */
if (cinfo->Ss == 0) { ta = cinfo->Se ? compptr->ac_tbl_no : 0;
ta = 0; /* DC scan */
if (cinfo->Ah != 0 && !cinfo->arith_code)
td = 0; /* no DC table either */
} else {
td = 0; /* AC scan */
}
}
emit_byte(cinfo, (td << 4) + ta); emit_byte(cinfo, (td << 4) + ta);
} }
@ -278,6 +379,22 @@ emit_sos (j_compress_ptr cinfo)
} }
LOCAL(void)
emit_pseudo_sos (j_compress_ptr cinfo)
/* Emit a pseudo SOS marker */
{
emit_marker(cinfo, M_SOS);
emit_2bytes(cinfo, 2 + 1 + 3); /* length */
emit_byte(cinfo, 0); /* Ns */
emit_byte(cinfo, 0); /* Ss */
emit_byte(cinfo, cinfo->block_size * cinfo->block_size - 1); /* Se */
emit_byte(cinfo, 0); /* Ah/Al */
}
LOCAL(void) LOCAL(void)
emit_jfif_app0 (j_compress_ptr cinfo) emit_jfif_app0 (j_compress_ptr cinfo)
/* Emit a JFIF-compliant APP0 marker */ /* Emit a JFIF-compliant APP0 marker */
@ -293,9 +410,9 @@ emit_jfif_app0 (j_compress_ptr cinfo)
* Thumbnail X size (1 byte) * Thumbnail X size (1 byte)
* Thumbnail Y size (1 byte) * Thumbnail Y size (1 byte)
*/ */
emit_marker(cinfo, M_APP0); emit_marker(cinfo, M_APP0);
emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
@ -332,9 +449,9 @@ emit_adobe_app14 (j_compress_ptr cinfo)
* YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
* whether the encoder performed a transformation, which is pretty useless. * whether the encoder performed a transformation, which is pretty useless.
*/ */
emit_marker(cinfo, M_APP14); emit_marker(cinfo, M_APP14);
emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
@ -354,7 +471,6 @@ emit_adobe_app14 (j_compress_ptr cinfo)
break; break;
default: default:
emit_byte(cinfo, 0); /* Color transform = 0 */ emit_byte(cinfo, 0); /* Color transform = 0 */
break;
} }
} }
@ -391,8 +507,8 @@ write_marker_byte (j_compress_ptr cinfo, int val)
* Write datastream header. * Write datastream header.
* This consists of an SOI and optional APPn markers. * This consists of an SOI and optional APPn markers.
* We recommend use of the JFIF marker, but not the Adobe marker, * We recommend use of the JFIF marker, but not the Adobe marker,
* when using YCbCr or grayscale data. The JFIF marker should NOT * when using YCbCr or grayscale data. The JFIF marker is also used
* be used for any other JPEG colorspace. The Adobe marker is helpful * for other standard JPEG colorspaces. The Adobe marker is helpful
* to distinguish RGB, CMYK, and YCCK colorspaces. * to distinguish RGB, CMYK, and YCCK colorspaces.
* Note that an application can write additional header markers after * Note that an application can write additional header markers after
* jpeg_start_compress returns. * jpeg_start_compress returns.
@ -417,7 +533,8 @@ write_file_header (j_compress_ptr cinfo)
/* /*
* Write frame header. * Write frame header.
* This consists of DQT and SOFn markers. * This consists of DQT and SOFn markers,
* a conditional LSE marker and a conditional pseudo SOS marker.
* Note that we do not emit the SOF until we have emitted the DQT(s). * Note that we do not emit the SOF until we have emitted the DQT(s).
* This avoids compatibility problems with incorrect implementations that * This avoids compatibility problems with incorrect implementations that
* try to error-check the quant table numbers as soon as they see the SOF. * try to error-check the quant table numbers as soon as they see the SOF.
@ -429,7 +546,7 @@ write_frame_header (j_compress_ptr cinfo)
int ci, prec; int ci, prec;
boolean is_baseline; boolean is_baseline;
jpeg_component_info *compptr; jpeg_component_info *compptr;
/* Emit DQT for each quantization table. /* Emit DQT for each quantization table.
* Note that emit_dqt() suppresses any duplicate tables. * Note that emit_dqt() suppresses any duplicate tables.
*/ */
@ -444,7 +561,7 @@ write_frame_header (j_compress_ptr cinfo)
* Note we assume that Huffman table numbers won't be changed later. * Note we assume that Huffman table numbers won't be changed later.
*/ */
if (cinfo->arith_code || cinfo->progressive_mode || if (cinfo->arith_code || cinfo->progressive_mode ||
cinfo->data_precision != 8) { cinfo->data_precision != 8 || cinfo->block_size != DCTSIZE) {
is_baseline = FALSE; is_baseline = FALSE;
} else { } else {
is_baseline = TRUE; is_baseline = TRUE;
@ -462,7 +579,10 @@ write_frame_header (j_compress_ptr cinfo)
/* Emit the proper SOF marker */ /* Emit the proper SOF marker */
if (cinfo->arith_code) { if (cinfo->arith_code) {
emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ if (cinfo->progressive_mode)
emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
else
emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
} else { } else {
if (cinfo->progressive_mode) if (cinfo->progressive_mode)
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
@ -471,6 +591,14 @@ write_frame_header (j_compress_ptr cinfo)
else else
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
} }
/* Check to emit LSE inverse color transform specification marker */
if (cinfo->color_transform)
emit_lse_ict(cinfo);
/* Check to emit pseudo SOS marker */
if (cinfo->progressive_mode && cinfo->block_size != DCTSIZE)
emit_pseudo_sos(cinfo);
} }
@ -499,19 +627,12 @@ write_scan_header (j_compress_ptr cinfo)
*/ */
for (i = 0; i < cinfo->comps_in_scan; i++) { for (i = 0; i < cinfo->comps_in_scan; i++) {
compptr = cinfo->cur_comp_info[i]; compptr = cinfo->cur_comp_info[i];
if (cinfo->progressive_mode) { /* DC needs no table for refinement scan */
/* Progressive mode: only DC or only AC tables are used in one scan */ if (cinfo->Ss == 0 && cinfo->Ah == 0)
if (cinfo->Ss == 0) {
if (cinfo->Ah == 0) /* DC needs no table for refinement scan */
emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
} else {
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
}
} else {
/* Sequential mode: need both DC and AC tables */
emit_dht(cinfo, compptr->dc_tbl_no, FALSE); emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
/* AC needs no table when not present */
if (cinfo->Se)
emit_dht(cinfo, compptr->ac_tbl_no, TRUE); emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
}
} }
} }
@ -580,10 +701,9 @@ jinit_marker_writer (j_compress_ptr cinfo)
my_marker_ptr marker; my_marker_ptr marker;
/* Create the subobject */ /* Create the subobject */
marker = (my_marker_ptr) marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_marker_writer));
SIZEOF(my_marker_writer)); cinfo->marker = &marker->pub;
cinfo->marker = (struct jpeg_marker_writer *) marker;
/* Initialize method pointers */ /* Initialize method pointers */
marker->pub.write_file_header = write_file_header; marker->pub.write_file_header = write_file_header;
marker->pub.write_frame_header = write_frame_header; marker->pub.write_frame_header = write_frame_header;

View file

@ -2,12 +2,13 @@
* jcmaster.c * jcmaster.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2003-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains master control logic for the JPEG compressor. * This file contains master control logic for the JPEG compressor.
* These routines are concerned with parameter validation, initial setup, * These routines are concerned with parameter validation, initial setup,
* and inter-pass control (determining the number of passes and the work * and inter-pass control (determining the number of passes and the work
* to be done in each pass). * to be done in each pass).
*/ */
@ -46,29 +47,40 @@ LOCAL(void)
initial_setup (j_compress_ptr cinfo) initial_setup (j_compress_ptr cinfo)
/* Do computations that are needed before master selection phase */ /* Do computations that are needed before master selection phase */
{ {
int ci; int ci, ssize;
jpeg_component_info *compptr; jpeg_component_info *compptr;
long samplesperrow;
JDIMENSION jd_samplesperrow; /* Sanity check on block_size */
if (cinfo->block_size < 1 || cinfo->block_size > 16)
ERREXIT2(cinfo, JERR_BAD_DCTSIZE, cinfo->block_size, cinfo->block_size);
/* Derive natural_order from block_size */
switch (cinfo->block_size) {
case 2: cinfo->natural_order = jpeg_natural_order2; break;
case 3: cinfo->natural_order = jpeg_natural_order3; break;
case 4: cinfo->natural_order = jpeg_natural_order4; break;
case 5: cinfo->natural_order = jpeg_natural_order5; break;
case 6: cinfo->natural_order = jpeg_natural_order6; break;
case 7: cinfo->natural_order = jpeg_natural_order7; break;
default: cinfo->natural_order = jpeg_natural_order;
}
/* Derive lim_Se from block_size */
cinfo->lim_Se = cinfo->block_size < DCTSIZE ?
cinfo->block_size * cinfo->block_size - 1 : DCTSIZE2-1;
/* Sanity check on image dimensions */ /* Sanity check on image dimensions */
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
|| cinfo->num_components <= 0 || cinfo->input_components <= 0) cinfo->num_components <= 0)
ERREXIT(cinfo, JERR_EMPTY_IMAGE); ERREXIT(cinfo, JERR_EMPTY_IMAGE);
/* Make sure image isn't bigger than I can handle */ /* Make sure image isn't bigger than I can handle */
if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || if ((long) cinfo->jpeg_height > (long) JPEG_MAX_DIMENSION ||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) (long) cinfo->jpeg_width > (long) JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
/* Width of an input scanline must be representable as JDIMENSION. */ /* Only 8 to 12 bits data precision are supported for DCT based JPEG */
samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
jd_samplesperrow = (JDIMENSION) samplesperrow;
if ((long) jd_samplesperrow != samplesperrow)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
/* For now, precision must match compiled-in value... */
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Check that number of components won't exceed internal array sizes */ /* Check that number of components won't exceed internal array sizes */
@ -95,32 +107,68 @@ initial_setup (j_compress_ptr cinfo)
ci++, compptr++) { ci++, compptr++) {
/* Fill in the correct component_index value; don't rely on application */ /* Fill in the correct component_index value; don't rely on application */
compptr->component_index = ci; compptr->component_index = ci;
/* For compression, we never do DCT scaling. */ /* In selecting the actual DCT scaling for each component, we try to
compptr->DCT_scaled_size = DCTSIZE; * scale down the chroma components via DCT scaling rather than downsampling.
* This saves time if the downsampler gets to use 1:1 scaling.
* Note this code adapts subsampling ratios which are powers of 2.
*/
ssize = 1;
#ifdef DCT_SCALING_SUPPORTED
if (! cinfo->raw_data_in)
while (cinfo->min_DCT_h_scaled_size * ssize <=
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
#endif
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
ssize = 1;
#ifdef DCT_SCALING_SUPPORTED
if (! cinfo->raw_data_in)
while (cinfo->min_DCT_v_scaled_size * ssize <=
(cinfo->do_fancy_downsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
#endif
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
/* We don't support DCT ratios larger than 2. */
if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2)
compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
/* Size in DCT blocks */ /* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION) compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, jdiv_round_up((long) cinfo->jpeg_width * (long) compptr->h_samp_factor,
(long) (cinfo->max_h_samp_factor * DCTSIZE)); (long) (cinfo->max_h_samp_factor * cinfo->block_size));
compptr->height_in_blocks = (JDIMENSION) compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, jdiv_round_up((long) cinfo->jpeg_height * (long) compptr->v_samp_factor,
(long) (cinfo->max_v_samp_factor * DCTSIZE)); (long) (cinfo->max_v_samp_factor * cinfo->block_size));
/* Size in samples */ /* Size in samples */
compptr->downsampled_width = (JDIMENSION) compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, jdiv_round_up((long) cinfo->jpeg_width *
(long) cinfo->max_h_samp_factor); (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size),
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
compptr->downsampled_height = (JDIMENSION) compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, jdiv_round_up((long) cinfo->jpeg_height *
(long) cinfo->max_v_samp_factor); (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
/* Mark component needed (this flag isn't actually used for compression) */ (long) (cinfo->max_v_samp_factor * cinfo->block_size));
compptr->component_needed = TRUE; /* Don't need quantization scale after DCT,
* until color conversion says otherwise.
*/
compptr->component_needed = FALSE;
} }
/* Compute number of fully interleaved MCU rows (number of times that /* Compute number of fully interleaved MCU rows (number of times that
* main controller will call coefficient controller). * main controller will call coefficient controller).
*/ */
cinfo->total_iMCU_rows = (JDIMENSION) cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, jdiv_round_up((long) cinfo->jpeg_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE)); (long) (cinfo->max_v_samp_factor * cinfo->block_size));
} }
@ -153,7 +201,7 @@ validate_script (j_compress_ptr cinfo)
#ifdef C_PROGRESSIVE_SUPPORTED #ifdef C_PROGRESSIVE_SUPPORTED
cinfo->progressive_mode = TRUE; cinfo->progressive_mode = TRUE;
last_bitpos_ptr = & last_bitpos[0][0]; last_bitpos_ptr = & last_bitpos[0][0];
for (ci = 0; ci < cinfo->num_components; ci++) for (ci = 0; ci < cinfo->num_components; ci++)
for (coefi = 0; coefi < DCTSIZE2; coefi++) for (coefi = 0; coefi < DCTSIZE2; coefi++)
*last_bitpos_ptr++ = -1; *last_bitpos_ptr++ = -1;
#else #else
@ -161,7 +209,7 @@ validate_script (j_compress_ptr cinfo)
#endif #endif
} else { } else {
cinfo->progressive_mode = FALSE; cinfo->progressive_mode = FALSE;
for (ci = 0; ci < cinfo->num_components; ci++) for (ci = 0; ci < cinfo->num_components; ci++)
component_sent[ci] = FALSE; component_sent[ci] = FALSE;
} }
@ -192,13 +240,9 @@ validate_script (j_compress_ptr cinfo)
* out-of-range reconstructed DC values during the first DC scan, * out-of-range reconstructed DC values during the first DC scan,
* which might cause problems for some decoders. * which might cause problems for some decoders.
*/ */
#if BITS_IN_JSAMPLE == 8
#define MAX_AH_AL 10
#else
#define MAX_AH_AL 13
#endif
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) Ah < 0 || Ah > (cinfo->data_precision > 8 ? 13 : 10) ||
Al < 0 || Al > (cinfo->data_precision > 8 ? 13 : 10))
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
if (Ss == 0) { if (Ss == 0) {
if (Se != 0) /* DC and AC together not OK */ if (Se != 0) /* DC and AC together not OK */
@ -260,6 +304,39 @@ validate_script (j_compress_ptr cinfo)
} }
} }
LOCAL(void)
reduce_script (j_compress_ptr cinfo)
/* Adapt scan script for use with reduced block size;
* assume that script has been validated before.
*/
{
jpeg_scan_info * scanptr;
int idxout, idxin;
/* Circumvent const declaration for this function */
scanptr = (jpeg_scan_info *) cinfo->scan_info;
idxout = 0;
for (idxin = 0; idxin < cinfo->num_scans; idxin++) {
/* After skipping, idxout becomes smaller than idxin */
if (idxin != idxout)
/* Copy rest of data;
* note we stay in given chunk of allocated memory.
*/
scanptr[idxout] = scanptr[idxin];
if (scanptr[idxout].Ss > cinfo->lim_Se)
/* Entire scan out of range - skip this entry */
continue;
if (scanptr[idxout].Se > cinfo->lim_Se)
/* Limit scan to end of block */
scanptr[idxout].Se = cinfo->lim_Se;
idxout++;
}
cinfo->num_scans = idxout;
}
#endif /* C_MULTISCAN_FILES_SUPPORTED */ #endif /* C_MULTISCAN_FILES_SUPPORTED */
@ -280,10 +357,13 @@ select_scan_parameters (j_compress_ptr cinfo)
cinfo->cur_comp_info[ci] = cinfo->cur_comp_info[ci] =
&cinfo->comp_info[scanptr->component_index[ci]]; &cinfo->comp_info[scanptr->component_index[ci]];
} }
cinfo->Ss = scanptr->Ss; if (cinfo->progressive_mode) {
cinfo->Se = scanptr->Se; cinfo->Ss = scanptr->Ss;
cinfo->Ah = scanptr->Ah; cinfo->Se = scanptr->Se;
cinfo->Al = scanptr->Al; cinfo->Ah = scanptr->Ah;
cinfo->Al = scanptr->Al;
return;
}
} }
else else
#endif #endif
@ -296,11 +376,11 @@ select_scan_parameters (j_compress_ptr cinfo)
for (ci = 0; ci < cinfo->num_components; ci++) { for (ci = 0; ci < cinfo->num_components; ci++) {
cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
} }
cinfo->Ss = 0;
cinfo->Se = DCTSIZE2-1;
cinfo->Ah = 0;
cinfo->Al = 0;
} }
cinfo->Ss = 0;
cinfo->Se = cinfo->block_size * cinfo->block_size - 1;
cinfo->Ah = 0;
cinfo->Al = 0;
} }
@ -325,7 +405,7 @@ per_scan_setup (j_compress_ptr cinfo)
compptr->MCU_width = 1; compptr->MCU_width = 1;
compptr->MCU_height = 1; compptr->MCU_height = 1;
compptr->MCU_blocks = 1; compptr->MCU_blocks = 1;
compptr->MCU_sample_width = DCTSIZE; compptr->MCU_sample_width = compptr->DCT_h_scaled_size;
compptr->last_col_width = 1; compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height /* For noninterleaved scans, it is convenient to define last_row_height
* as the number of block rows present in the last iMCU row. * as the number of block rows present in the last iMCU row.
@ -347,11 +427,9 @@ per_scan_setup (j_compress_ptr cinfo)
/* Overall image size in MCUs */ /* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION) cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, jdiv_round_up((long) cinfo->jpeg_width,
(long) (cinfo->max_h_samp_factor*DCTSIZE)); (long) (cinfo->max_h_samp_factor * cinfo->block_size));
cinfo->MCU_rows_in_scan = (JDIMENSION) cinfo->MCU_rows_in_scan = cinfo->total_iMCU_rows;
jdiv_round_up((long) cinfo->image_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE));
cinfo->blocks_in_MCU = 0; cinfo->blocks_in_MCU = 0;
@ -361,7 +439,7 @@ per_scan_setup (j_compress_ptr cinfo)
compptr->MCU_width = compptr->h_samp_factor; compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor; compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_h_scaled_size;
/* Figure number of non-dummy blocks in last MCU column & row */ /* Figure number of non-dummy blocks in last MCU column & row */
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width; if (tmp == 0) tmp = compptr->MCU_width;
@ -433,7 +511,7 @@ prepare_for_pass (j_compress_ptr cinfo)
/* Do Huffman optimization for a scan after the first one. */ /* Do Huffman optimization for a scan after the first one. */
select_scan_parameters(cinfo); select_scan_parameters(cinfo);
per_scan_setup(cinfo); per_scan_setup(cinfo);
if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { if (cinfo->Ss != 0 || cinfo->Ah == 0) {
(*cinfo->entropy->start_pass) (cinfo, TRUE); (*cinfo->entropy->start_pass) (cinfo, TRUE);
(*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST);
master->pub.call_pass_startup = FALSE; master->pub.call_pass_startup = FALSE;
@ -544,10 +622,9 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
{ {
my_master_ptr master; my_master_ptr master;
master = (my_master_ptr) master = (my_master_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_comp_master));
SIZEOF(my_comp_master)); cinfo->master = &master->pub;
cinfo->master = (struct jpeg_comp_master *) master;
master->pub.prepare_for_pass = prepare_for_pass; master->pub.prepare_for_pass = prepare_for_pass;
master->pub.pass_startup = pass_startup; master->pub.pass_startup = pass_startup;
master->pub.finish_pass = finish_pass_master; master->pub.finish_pass = finish_pass_master;
@ -559,6 +636,8 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
if (cinfo->scan_info != NULL) { if (cinfo->scan_info != NULL) {
#ifdef C_MULTISCAN_FILES_SUPPORTED #ifdef C_MULTISCAN_FILES_SUPPORTED
validate_script(cinfo); validate_script(cinfo);
if (cinfo->block_size < DCTSIZE)
reduce_script(cinfo);
#else #else
ERREXIT(cinfo, JERR_NOT_COMPILED); ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif #endif
@ -567,8 +646,14 @@ jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only)
cinfo->num_scans = 1; cinfo->num_scans = 1;
} }
if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ if (cinfo->optimize_coding)
cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ cinfo->arith_code = FALSE; /* disable arithmetic coding */
else if (! cinfo->arith_code &&
(cinfo->progressive_mode ||
(cinfo->block_size > 1 && cinfo->block_size < DCTSIZE)))
/* TEMPORARY HACK ??? */
/* assume default tables no good for progressive or reduced AC mode */
cinfo->optimize_coding = TRUE; /* force Huffman optimization */
/* Initialize my private state */ /* Initialize my private state */
if (transcode_only) { if (transcode_only) {

View file

@ -2,6 +2,7 @@
* jcomapi.c * jcomapi.c
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -104,3 +105,140 @@ jpeg_alloc_huff_table (j_common_ptr cinfo)
tbl->sent_table = FALSE; /* make sure this is false in any new table */ tbl->sent_table = FALSE; /* make sure this is false in any new table */
return tbl; return tbl;
} }
/*
* Set up the standard Huffman tables (cf. JPEG standard section K.3).
* IMPORTANT: these are only valid for 8-bit data precision!
* (Would jutils.c be a more reasonable place to put this?)
*/
GLOBAL(JHUFF_TBL *)
jpeg_std_huff_table (j_common_ptr cinfo, boolean isDC, int tblno)
{
JHUFF_TBL **htblptr, *htbl;
const UINT8 *bits, *val;
int nsymbols, len;
static const UINT8 bits_dc_luminance[17] =
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
static const UINT8 val_dc_luminance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_dc_chrominance[17] =
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
static const UINT8 val_dc_chrominance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_ac_luminance[17] =
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
static const UINT8 val_ac_luminance[] =
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
static const UINT8 bits_ac_chrominance[17] =
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
static const UINT8 val_ac_chrominance[] =
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
if (cinfo->is_decompressor) {
if (isDC)
htblptr = ((j_decompress_ptr) cinfo)->dc_huff_tbl_ptrs;
else
htblptr = ((j_decompress_ptr) cinfo)->ac_huff_tbl_ptrs;
} else {
if (isDC)
htblptr = ((j_compress_ptr) cinfo)->dc_huff_tbl_ptrs;
else
htblptr = ((j_compress_ptr) cinfo)->ac_huff_tbl_ptrs;
}
switch (tblno) {
case 0:
if (isDC) {
bits = bits_dc_luminance;
val = val_dc_luminance;
} else {
bits = bits_ac_luminance;
val = val_ac_luminance;
}
break;
case 1:
if (isDC) {
bits = bits_dc_chrominance;
val = val_dc_chrominance;
} else {
bits = bits_ac_chrominance;
val = val_ac_chrominance;
}
break;
default:
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
return NULL; /* avoid compiler warnings for uninitialized variables */
}
if (htblptr[tblno] == NULL)
htblptr[tblno] = jpeg_alloc_huff_table(cinfo);
htbl = htblptr[tblno];
/* Copy the number-of-symbols-of-each-code-length counts */
MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
/* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val[] array, without risking marching off
* the end of memory. jxhuff.c will do a more thorough test later.
*/
nsymbols = 0;
for (len = 1; len <= 16; len++)
nsymbols += bits[len];
if (nsymbols > 256)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
if (nsymbols > 0)
MEMCOPY(htbl->huffval, val, nsymbols * SIZEOF(UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */
htbl->sent_table = FALSE;
return htbl;
}

View file

@ -1,59 +1,171 @@
/* jconfig.vc --- jconfig.h for Microsoft Visual C++ on Windows 95 or NT. */ /*
/* see jconfig.doc for explanations */ * jconfig.txt
*
* Copyright (C) 1991-1994, Thomas G. Lane.
* Modified 2009-2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file documents the configuration options that are required to
* customize the JPEG software for a particular system.
*
* The actual configuration options for a particular installation are stored
* in jconfig.h. On many machines, jconfig.h can be generated automatically
* or copied from one of the "canned" jconfig files that we supply. But if
* you need to generate a jconfig.h file by hand, this file tells you how.
*
* DO NOT EDIT THIS FILE --- IT WON'T ACCOMPLISH ANYTHING.
* EDIT A COPY NAMED JCONFIG.H.
*/
// disable all the warnings under MSVC
#ifdef _MSC_VER
#pragma warning (disable: 4996 4267 4100 4127 4702 4244)
#endif
#ifdef __BORLANDC__ /*
#pragma warn -8057 * These symbols indicate the properties of your machine or compiler.
#pragma warn -8019 * #define the symbol if yes, #undef it if no.
#pragma warn -8004 */
#pragma warn -8008
#endif
/* Does your compiler support function prototypes?
* (If not, you also need to use ansi2knr, see install.txt)
*/
#define HAVE_PROTOTYPES #define HAVE_PROTOTYPES
/* Does your compiler support the declaration "unsigned char" ?
* How about "unsigned short" ?
*/
#define HAVE_UNSIGNED_CHAR #define HAVE_UNSIGNED_CHAR
#define HAVE_UNSIGNED_SHORT #define HAVE_UNSIGNED_SHORT
/* Define "void" as "char" if your compiler doesn't know about type void.
* NOTE: be sure to define void such that "void *" represents the most general
* pointer type, e.g., that returned by malloc().
*/
/* #define void char */ /* #define void char */
/* Define "const" as empty if your compiler doesn't know the "const" keyword.
*/
/* #define const */ /* #define const */
/* Define this if an ordinary "char" type is unsigned.
* If you're not sure, leaving it undefined will work at some cost in speed.
* If you defined HAVE_UNSIGNED_CHAR then the speed difference is minimal.
*/
#undef CHAR_IS_UNSIGNED #undef CHAR_IS_UNSIGNED
/* Define this if your system has an ANSI-conforming <stddef.h> file.
*/
#define HAVE_STDDEF_H #define HAVE_STDDEF_H
#ifndef HAVE_STDLIB_H
#define HAVE_STDLIB_H /* Define this if your system has an ANSI-conforming <stdlib.h> file.
#endif */
#define HAVE_STDLIB_H
/* Define this if your system does not have an ANSI/SysV <string.h>,
* but does have a BSD-style <strings.h>.
*/
#undef NEED_BSD_STRINGS #undef NEED_BSD_STRINGS
/* Define this if your system does not provide typedef size_t in any of the
* ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in
* <sys/types.h> instead.
*/
#undef NEED_SYS_TYPES_H #undef NEED_SYS_TYPES_H
#undef NEED_FAR_POINTERS /* we presume a 32-bit flat memory model */
/* For 80x86 machines, you need to define NEED_FAR_POINTERS,
* unless you are using a large-data memory model or 80386 flat-memory mode.
* On less brain-damaged CPUs this symbol must not be defined.
* (Defining this symbol causes large data structures to be referenced through
* "far" pointers and to be allocated with a special version of malloc.)
*/
#undef NEED_FAR_POINTERS
/* Define this if your linker needs global names to be unique in less
* than the first 15 characters.
*/
#undef NEED_SHORT_EXTERNAL_NAMES #undef NEED_SHORT_EXTERNAL_NAMES
/* Although a real ANSI C compiler can deal perfectly well with pointers to
* unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
* and pseudo-ANSI compilers get confused. To keep one of these bozos happy,
* define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you
* actually get "missing structure definition" warnings or errors while
* compiling the JPEG code.
*/
#undef INCOMPLETE_TYPES_BROKEN #undef INCOMPLETE_TYPES_BROKEN
/* Define "boolean" as unsigned char, not int, per Windows custom */ /* Define "boolean" as unsigned char, not enum, on Windows systems.
*/
#ifdef _WIN32
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
typedef unsigned char boolean; typedef unsigned char boolean;
#endif #endif
#ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
#endif
/*
* The following options affect code selection within the JPEG library,
* but they don't need to be visible to applications using the library.
* To minimize application namespace pollution, the symbols won't be
* defined unless JPEG_INTERNALS has been defined.
*/
#ifdef JPEG_INTERNALS #ifdef JPEG_INTERNALS
/* Define this if your compiler implements ">>" on signed values as a logical
* (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
* which is the normal and rational definition.
*/
#undef RIGHT_SHIFT_IS_UNSIGNED #undef RIGHT_SHIFT_IS_UNSIGNED
#endif /* JPEG_INTERNALS */ #endif /* JPEG_INTERNALS */
/*
* The remaining options do not affect the JPEG library proper,
* but only the sample applications cjpeg/djpeg (see cjpeg.c, djpeg.c).
* Other applications can ignore these.
*/
#ifdef JPEG_CJPEG_DJPEG #ifdef JPEG_CJPEG_DJPEG
/* These defines indicate which image (non-JPEG) file formats are allowed. */
#define BMP_SUPPORTED /* BMP image file format */ #define BMP_SUPPORTED /* BMP image file format */
#define GIF_SUPPORTED /* GIF image file format */ #define GIF_SUPPORTED /* GIF image file format */
#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */
#undef RLE_SUPPORTED /* Utah RLE image file format */ #undef RLE_SUPPORTED /* Utah RLE image file format */
#define TARGA_SUPPORTED /* Targa image file format */ #define TARGA_SUPPORTED /* Targa image file format */
#define TWO_FILE_COMMANDLINE /* optional */ /* Define this if you want to name both input and output files on the command
#define USE_SETMODE /* Microsoft has setmode() */ * line, rather than using stdout and optionally stdin. You MUST do this if
* your system can't cope with binary I/O to stdin/stdout. See comments at
* head of cjpeg.c or djpeg.c.
*/
#undef TWO_FILE_COMMANDLINE
/* Define this if your system needs explicit cleanup of temporary files.
* This is crucial under MS-DOS, where the temporary "files" may be areas
* of extended memory; on most other systems it's not as important.
*/
#undef NEED_SIGNAL_CATCHER #undef NEED_SIGNAL_CATCHER
/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
* This is necessary on systems that distinguish text files from binary files,
* and is harmless on most systems that don't. If you have one of the rare
* systems that complains about the "b" spec, define this symbol.
*/
#undef DONT_USE_B_MODE #undef DONT_USE_B_MODE
#undef PROGRESS_REPORT /* optional */
/* Define this if you want percent-done progress reports from cjpeg/djpeg.
*/
#undef PROGRESS_REPORT
#endif /* JPEG_CJPEG_DJPEG */ #endif /* JPEG_CJPEG_DJPEG */

View file

@ -2,6 +2,7 @@
* jcparam.c * jcparam.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2003-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -60,6 +61,48 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl,
} }
/* These are the sample quantization tables given in JPEG spec section K.1.
* NOTE: chrominance DC value is changed from 17 to 16 for lossless support.
* The spec says that the values given produce "good" quality,
* and when divided by 2, "very good" quality.
*/
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
16, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
GLOBAL(void)
jpeg_default_qtables (j_compress_ptr cinfo, boolean force_baseline)
/* Set or change the 'quality' (quantization) setting, using default tables
* and straight percentage-scaling quality scales.
* This entry point allows different scalings for luminance and chrominance.
*/
{
/* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
cinfo->q_scale_factor[0], force_baseline);
jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl,
cinfo->q_scale_factor[1], force_baseline);
}
GLOBAL(void) GLOBAL(void)
jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
boolean force_baseline) boolean force_baseline)
@ -69,31 +112,6 @@ jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor,
* applications that insist on a linear percentage scaling. * applications that insist on a linear percentage scaling.
*/ */
{ {
/* These are the sample quantization tables given in JPEG spec section K.1.
* The spec says that the values given produce "good" quality, and
* when divided by 2, "very good" quality.
*/
static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = {
16, 11, 10, 16, 24, 40, 51, 61,
12, 12, 14, 19, 26, 58, 60, 55,
14, 13, 16, 24, 40, 57, 69, 56,
14, 17, 22, 29, 51, 87, 80, 62,
18, 22, 37, 56, 68, 109, 103, 77,
24, 35, 55, 64, 81, 104, 113, 92,
49, 64, 78, 87, 103, 121, 120, 101,
72, 92, 95, 98, 112, 100, 103, 99
};
static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = {
17, 18, 24, 47, 99, 99, 99, 99,
18, 21, 26, 66, 99, 99, 99, 99,
24, 26, 56, 99, 99, 99, 99, 99,
47, 66, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
/* Set up two quantization tables using the specified scaling */ /* Set up two quantization tables using the specified scaling */
jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl,
scale_factor, force_baseline); scale_factor, force_baseline);
@ -133,7 +151,7 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
/* Set or change the 'quality' (quantization) setting, using default tables. /* Set or change the 'quality' (quantization) setting, using default tables.
* This is the standard quality-adjusting entry point for typical user * This is the standard quality-adjusting entry point for typical user
* interfaces; only those who want detailed control over quantization tables * interfaces; only those who want detailed control over quantization tables
* would use the preceding three routines directly. * would use the preceding routines directly.
*/ */
{ {
/* Convert user 0-100 rating to percentage scaling */ /* Convert user 0-100 rating to percentage scaling */
@ -145,112 +163,23 @@ jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline)
/* /*
* Huffman table setup routines * Reset standard Huffman tables
*/ */
LOCAL(void)
add_huff_table (j_compress_ptr cinfo,
JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val)
/* Define a Huffman table */
{
int nsymbols, len;
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
/* Copy the number-of-symbols-of-each-code-length counts */
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
/* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val[] array, without risking marching off
* the end of memory. jchuff.c will do a more thorough test later.
*/
nsymbols = 0;
for (len = 1; len <= 16; len++)
nsymbols += bits[len];
if (nsymbols < 1 || nsymbols > 256)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */
(*htblptr)->sent_table = FALSE;
}
LOCAL(void) LOCAL(void)
std_huff_tables (j_compress_ptr cinfo) std_huff_tables (j_compress_ptr cinfo)
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
/* IMPORTANT: these are only valid for 8-bit data precision! */
{ {
static const UINT8 bits_dc_luminance[17] = if (cinfo->dc_huff_tbl_ptrs[0] != NULL)
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; (void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 0);
static const UINT8 val_dc_luminance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_dc_chrominance[17] = if (cinfo->ac_huff_tbl_ptrs[0] != NULL)
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; (void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 0);
static const UINT8 val_dc_chrominance[] =
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
static const UINT8 bits_ac_luminance[17] = if (cinfo->dc_huff_tbl_ptrs[1] != NULL)
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; (void) jpeg_std_huff_table((j_common_ptr) cinfo, TRUE, 1);
static const UINT8 val_ac_luminance[] =
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0,
0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16,
0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98,
0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5,
0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4,
0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2,
0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea,
0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
static const UINT8 bits_ac_chrominance[17] = if (cinfo->ac_huff_tbl_ptrs[1] != NULL)
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; (void) jpeg_std_huff_table((j_common_ptr) cinfo, FALSE, 1);
static const UINT8 val_ac_chrominance[] =
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0,
0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34,
0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26,
0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38,
0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68,
0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96,
0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5,
0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3,
0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2,
0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda,
0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8,
0xf9, 0xfa };
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0],
bits_dc_luminance, val_dc_luminance);
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0],
bits_ac_luminance, val_ac_luminance);
add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1],
bits_dc_chrominance, val_dc_chrominance);
add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1],
bits_ac_chrominance, val_ac_chrominance);
} }
@ -284,10 +213,12 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* Initialize everything not dependent on the color space */ /* Initialize everything not dependent on the color space */
cinfo->scale_num = 1; /* 1:1 scaling */
cinfo->scale_denom = 1;
cinfo->data_precision = BITS_IN_JSAMPLE; cinfo->data_precision = BITS_IN_JSAMPLE;
/* Set up two quantization tables using default quality of 75 */ /* Set up two quantization tables using default quality of 75 */
jpeg_set_quality(cinfo, 75, TRUE); jpeg_set_quality(cinfo, 75, TRUE);
/* Set up two Huffman tables */ /* Reset standard Huffman tables */
std_huff_tables(cinfo); std_huff_tables(cinfo);
/* Initialize default arithmetic coding conditioning */ /* Initialize default arithmetic coding conditioning */
@ -304,22 +235,24 @@ jpeg_set_defaults (j_compress_ptr cinfo)
/* Expect normal source image, not raw downsampled data */ /* Expect normal source image, not raw downsampled data */
cinfo->raw_data_in = FALSE; cinfo->raw_data_in = FALSE;
/* Use Huffman coding, not arithmetic coding, by default */ /* The standard Huffman tables are only valid for 8-bit data precision.
cinfo->arith_code = FALSE; * If the precision is higher, use arithmetic coding.
* (Alternatively, using Huffman coding would be possible with forcing
* optimization on so that usable tables will be computed, or by
* supplying default tables that are valid for the desired precision.)
* Otherwise, use Huffman coding by default.
*/
cinfo->arith_code = cinfo->data_precision > 8 ? TRUE : FALSE;
/* By default, don't do extra passes to optimize entropy coding */ /* By default, don't do extra passes to optimize entropy coding */
cinfo->optimize_coding = FALSE; cinfo->optimize_coding = FALSE;
/* The standard Huffman tables are only valid for 8-bit data precision.
* If the precision is higher, force optimization on so that usable
* tables will be computed. This test can be removed if default tables
* are supplied that are valid for the desired precision.
*/
if (cinfo->data_precision > 8)
cinfo->optimize_coding = TRUE;
/* By default, use the simpler non-cosited sampling alignment */ /* By default, use the simpler non-cosited sampling alignment */
cinfo->CCIR601_sampling = FALSE; cinfo->CCIR601_sampling = FALSE;
/* By default, apply fancy downsampling */
cinfo->do_fancy_downsampling = TRUE;
/* No input smoothing */ /* No input smoothing */
cinfo->smoothing_factor = 0; cinfo->smoothing_factor = 0;
@ -338,6 +271,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
* JFIF_minor_version to 2. We could probably get away with just defaulting * JFIF_minor_version to 2. We could probably get away with just defaulting
* to 1.02, but there may still be some decoders in use that will complain * to 1.02, but there may still be some decoders in use that will complain
* about that; saying 1.01 should minimize compatibility problems. * about that; saying 1.01 should minimize compatibility problems.
*
* For wide gamut colorspaces (BG_RGB and BG_YCC), the major version will be
* overridden by jpeg_set_colorspace and set to 2.
*/ */
cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */
cinfo->JFIF_minor_version = 1; cinfo->JFIF_minor_version = 1;
@ -345,6 +281,9 @@ jpeg_set_defaults (j_compress_ptr cinfo)
cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ cinfo->X_density = 1; /* Pixel aspect ratio is square by default */
cinfo->Y_density = 1; cinfo->Y_density = 1;
/* No color transform */
cinfo->color_transform = JCT_NONE;
/* Choose JPEG colorspace based on input space, set defaults accordingly */ /* Choose JPEG colorspace based on input space, set defaults accordingly */
jpeg_default_colorspace(cinfo); jpeg_default_colorspace(cinfo);
@ -359,6 +298,9 @@ GLOBAL(void)
jpeg_default_colorspace (j_compress_ptr cinfo) jpeg_default_colorspace (j_compress_ptr cinfo)
{ {
switch (cinfo->in_color_space) { switch (cinfo->in_color_space) {
case JCS_UNKNOWN:
jpeg_set_colorspace(cinfo, JCS_UNKNOWN);
break;
case JCS_GRAYSCALE: case JCS_GRAYSCALE:
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
break; break;
@ -374,8 +316,12 @@ jpeg_default_colorspace (j_compress_ptr cinfo)
case JCS_YCCK: case JCS_YCCK:
jpeg_set_colorspace(cinfo, JCS_YCCK); jpeg_set_colorspace(cinfo, JCS_YCCK);
break; break;
case JCS_UNKNOWN: case JCS_BG_RGB:
jpeg_set_colorspace(cinfo, JCS_UNKNOWN); /* No translation for now -- conversion to BG_YCC not yet supportet */
jpeg_set_colorspace(cinfo, JCS_BG_RGB);
break;
case JCS_BG_YCC:
jpeg_set_colorspace(cinfo, JCS_BG_YCC);
break; break;
default: default:
ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE);
@ -416,27 +362,42 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */
switch (colorspace) { switch (colorspace) {
case JCS_UNKNOWN:
cinfo->num_components = cinfo->input_components;
if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS)
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
MAX_COMPONENTS);
for (ci = 0; ci < cinfo->num_components; ci++) {
SET_COMP(ci, ci, 1,1, 0, 0,0);
}
break;
case JCS_GRAYSCALE: case JCS_GRAYSCALE:
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
cinfo->num_components = 1; cinfo->num_components = 1;
/* JFIF specifies component ID 1 */ /* JFIF specifies component ID 1 */
SET_COMP(0, 1, 1,1, 0, 0,0); SET_COMP(0, 0x01, 1,1, 0, 0,0);
break; break;
case JCS_RGB: case JCS_RGB:
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */
cinfo->num_components = 3; cinfo->num_components = 3;
SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); SET_COMP(0, 0x52 /* 'R' */, 1,1,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0);
SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); SET_COMP(2, 0x42 /* 'B' */, 1,1,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
break; break;
case JCS_YCbCr: case JCS_YCbCr:
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
cinfo->num_components = 3; cinfo->num_components = 3;
/* JFIF specifies component IDs 1,2,3 */ /* JFIF specifies component IDs 1,2,3 */
/* We default to 2x2 subsamples of chrominance */ /* We default to 2x2 subsamples of chrominance */
SET_COMP(0, 1, 2,2, 0, 0,0); SET_COMP(0, 0x01, 2,2, 0, 0,0);
SET_COMP(1, 2, 1,1, 1, 1,1); SET_COMP(1, 0x02, 1,1, 1, 1,1);
SET_COMP(2, 3, 1,1, 1, 1,1); SET_COMP(2, 0x03, 1,1, 1, 1,1);
break; break;
case JCS_CMYK: case JCS_CMYK:
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */
@ -449,19 +410,35 @@ jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace)
case JCS_YCCK: case JCS_YCCK:
cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */
cinfo->num_components = 4; cinfo->num_components = 4;
SET_COMP(0, 1, 2,2, 0, 0,0); SET_COMP(0, 0x01, 2,2, 0, 0,0);
SET_COMP(1, 2, 1,1, 1, 1,1); SET_COMP(1, 0x02, 1,1, 1, 1,1);
SET_COMP(2, 3, 1,1, 1, 1,1); SET_COMP(2, 0x03, 1,1, 1, 1,1);
SET_COMP(3, 4, 2,2, 0, 0,0); SET_COMP(3, 0x04, 2,2, 0, 0,0);
break; break;
case JCS_UNKNOWN: case JCS_BG_RGB:
cinfo->num_components = cinfo->input_components; cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, cinfo->num_components = 3;
MAX_COMPONENTS); /* Add offset 0x20 to the normal R/G/B component IDs */
for (ci = 0; ci < cinfo->num_components; ci++) { SET_COMP(0, 0x72 /* 'r' */, 1,1,
SET_COMP(ci, ci, 1,1, 0, 0,0); cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
} cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
SET_COMP(1, 0x67 /* 'g' */, 1,1, 0, 0,0);
SET_COMP(2, 0x62 /* 'b' */, 1,1,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0,
cinfo->color_transform == JCT_SUBTRACT_GREEN ? 1 : 0);
break;
case JCS_BG_YCC:
cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */
cinfo->JFIF_major_version = 2; /* Set JFIF major version = 2 */
cinfo->num_components = 3;
/* Add offset 0x20 to the normal Cb/Cr component IDs */
/* We default to 2x2 subsamples of chrominance */
SET_COMP(0, 0x01, 2,2, 0, 0,0);
SET_COMP(1, 0x22, 1,1, 1, 1,1);
SET_COMP(2, 0x23, 1,1, 1, 1,1);
break; break;
default: default:
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
@ -545,8 +522,10 @@ jpeg_simple_progression (j_compress_ptr cinfo)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Figure space needed for script. Calculation must match code below! */ /* Figure space needed for script. Calculation must match code below! */
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { if (ncomps == 3 &&
/* Custom script for YCbCr color images. */ (cinfo->jpeg_color_space == JCS_YCbCr ||
cinfo->jpeg_color_space == JCS_BG_YCC)) {
/* Custom script for YCC color images. */
nscans = 10; nscans = 10;
} else { } else {
/* All-purpose script for other color spaces. */ /* All-purpose script for other color spaces. */
@ -561,7 +540,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
* multiple compressions without changing the settings. To avoid a memory * multiple compressions without changing the settings. To avoid a memory
* leak if jpeg_simple_progression is called repeatedly for the same JPEG * leak if jpeg_simple_progression is called repeatedly for the same JPEG
* object, we try to re-use previously allocated space, and we allocate * object, we try to re-use previously allocated space, and we allocate
* enough space to handle YCbCr even if initially asked for grayscale. * enough space to handle YCC even if initially asked for grayscale.
*/ */
if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) {
cinfo->script_space_size = MAX(nscans, 10); cinfo->script_space_size = MAX(nscans, 10);
@ -573,8 +552,10 @@ jpeg_simple_progression (j_compress_ptr cinfo)
cinfo->scan_info = scanptr; cinfo->scan_info = scanptr;
cinfo->num_scans = nscans; cinfo->num_scans = nscans;
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { if (ncomps == 3 &&
/* Custom script for YCbCr color images. */ (cinfo->jpeg_color_space == JCS_YCbCr ||
cinfo->jpeg_color_space == JCS_BG_YCC)) {
/* Custom script for YCC color images. */
/* Initial DC scan */ /* Initial DC scan */
scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); scanptr = fill_dc_scans(scanptr, ncomps, 0, 1);
/* Initial AC scan: get some luma data out in a hurry */ /* Initial AC scan: get some luma data out in a hurry */
@ -592,7 +573,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0);
scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0);
/* Luma bottom bit comes last since it's usually largest scan */ /* Luma bottom bit comes last since it's usually largest scan */
fill_a_scan(scanptr, 0, 1, 63, 1, 0); scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0);
} else { } else {
/* All-purpose script for other color spaces. */ /* All-purpose script for other color spaces. */
/* Successive approximation first pass */ /* Successive approximation first pass */
@ -603,7 +584,7 @@ jpeg_simple_progression (j_compress_ptr cinfo)
scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1);
/* Successive approximation final pass */ /* Successive approximation final pass */
scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); scanptr = fill_dc_scans(scanptr, ncomps, 1, 0);
fill_scans(scanptr, ncomps, 1, 63, 1, 0); scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0);
} }
} }

View file

@ -1,833 +0,0 @@
/*
* jcphuff.c
*
* Copyright (C) 1995-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains Huffman entropy encoding routines for progressive JPEG.
*
* We do not support output suspension in this module, since the library
* currently does not allow multiple-scan files to be written with output
* suspension.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jchuff.h" /* Declarations shared with jchuff.c */
#ifdef C_PROGRESSIVE_SUPPORTED
/* Expanded entropy encoder object for progressive Huffman encoding. */
typedef struct {
struct jpeg_entropy_encoder pub; /* public fields */
/* Mode flag: TRUE for optimization, FALSE for actual data output */
boolean gather_statistics;
/* Bit-level coding status.
* next_output_byte/free_in_buffer are local copies of cinfo->dest fields.
*/
JOCTET * next_output_byte; /* => next byte to write in buffer */
size_t free_in_buffer; /* # of byte spaces remaining in buffer */
INT32 put_buffer; /* current bit-accumulation buffer */
int put_bits; /* # of bits now in it */
j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */
/* Coding status for DC components */
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
/* Coding status for AC components */
int ac_tbl_no; /* the table number of the single component */
unsigned int EOBRUN; /* run length of EOBs */
unsigned int BE; /* # of buffered correction bits before MCU */
char * bit_buffer; /* buffer for correction bits (1 per char) */
/* packing correction bits tightly would save some space but cost time... */
unsigned int restarts_to_go; /* MCUs left in this restart interval */
int next_restart_num; /* next restart number to write (0-7) */
/* Pointers to derived tables (these workspaces have image lifespan).
* Since any one scan codes only DC or only AC, we only need one set
* of tables, not one for DC and one for AC.
*/
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS];
/* Statistics tables for optimization; again, one set is enough */
long * count_ptrs[NUM_HUFF_TBLS];
} phuff_entropy_encoder;
typedef phuff_entropy_encoder * phuff_entropy_ptr;
/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit
* buffer can hold. Larger sizes may slightly improve compression, but
* 1000 is already well into the realm of overkill.
* The minimum safe size is 64 bits.
*/
#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */
/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.
* We assume that int right shift is unsigned if INT32 right shift is,
* which should be safe.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define ISHIFT_TEMPS int ishift_temp;
#define IRIGHT_SHIFT(x,shft) \
((ishift_temp = (x)) < 0 ? \
(ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
(ishift_temp >> (shft)))
#else
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
/* Forward declarations */
METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo));
METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo));
/*
* Initialize for a Huffman-compressed scan using progressive JPEG.
*/
METHODDEF(void)
start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
boolean is_DC_band;
int ci, tbl;
jpeg_component_info * compptr;
entropy->cinfo = cinfo;
entropy->gather_statistics = gather_statistics;
is_DC_band = (cinfo->Ss == 0);
/* We assume jcmaster.c already validated the scan parameters. */
/* Select execution routines */
if (cinfo->Ah == 0) {
if (is_DC_band)
entropy->pub.encode_mcu = encode_mcu_DC_first;
else
entropy->pub.encode_mcu = encode_mcu_AC_first;
} else {
if (is_DC_band)
entropy->pub.encode_mcu = encode_mcu_DC_refine;
else {
entropy->pub.encode_mcu = encode_mcu_AC_refine;
/* AC refinement needs a correction bit buffer */
if (entropy->bit_buffer == NULL)
entropy->bit_buffer = (char *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
MAX_CORR_BITS * SIZEOF(char));
}
}
if (gather_statistics)
entropy->pub.finish_pass = finish_pass_gather_phuff;
else
entropy->pub.finish_pass = finish_pass_phuff;
/* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1
* for AC coefficients.
*/
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
/* Get table index */
if (is_DC_band) {
if (cinfo->Ah != 0) /* DC refinement needs no table */
continue;
tbl = compptr->dc_tbl_no;
} else {
entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;
}
if (gather_statistics) {
/* Check for invalid table index */
/* (make_c_derived_tbl does this in the other path) */
if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
/* Allocate and zero the statistics tables */
/* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
if (entropy->count_ptrs[tbl] == NULL)
entropy->count_ptrs[tbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
257 * SIZEOF(long));
MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long));
} else {
/* Compute derived values for Huffman table */
/* We may do this more than once for a table, but it's not expensive */
jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
& entropy->derived_tbls[tbl]);
}
}
/* Initialize AC stuff */
entropy->EOBRUN = 0;
entropy->BE = 0;
/* Initialize bit buffer to empty */
entropy->put_buffer = 0;
entropy->put_bits = 0;
/* Initialize restart stuff */
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num = 0;
}
/* Outputting bytes to the file.
* NB: these must be called only when actually outputting,
* that is, entropy->gather_statistics == FALSE.
*/
/* Emit a byte */
#define emit_byte(entropy,val) \
{ *(entropy)->next_output_byte++ = (JOCTET) (val); \
if (--(entropy)->free_in_buffer == 0) \
dump_buffer_p(entropy); }
LOCAL(void)
dump_buffer_p (phuff_entropy_ptr entropy)
/* Empty the output buffer; we do not support suspension in this module. */
{
struct jpeg_destination_mgr * dest = entropy->cinfo->dest;
if (! (*dest->empty_output_buffer) (entropy->cinfo))
ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
/* After a successful buffer dump, must reset buffer pointers */
entropy->next_output_byte = dest->next_output_byte;
entropy->free_in_buffer = dest->free_in_buffer;
}
/* Outputting bits to the file */
/* Only the right 24 bits of put_buffer are used; the valid bits are
* left-justified in this part. At most 16 bits can be passed to emit_bits
* in one call, and we never retain more than 7 bits in put_buffer
* between calls, so 24 bits are sufficient.
*/
INLINE
LOCAL(void)
emit_bits_p (phuff_entropy_ptr entropy, unsigned int code, int size)
/* Emit some bits, unless we are in gather mode */
{
/* This routine is heavily used, so it's worth coding tightly. */
INT32 put_buffer = (INT32) code;
int put_bits = entropy->put_bits;
/* if size is 0, caller used an invalid Huffman table entry */
if (size == 0)
ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
if (entropy->gather_statistics)
return; /* do nothing if we're only getting stats */
put_buffer &= (((INT32) 1)<<size) - 1; /* mask off any extra bits in code */
put_bits += size; /* new number of bits in buffer */
put_buffer <<= 24 - put_bits; /* align incoming bits */
put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
while (put_bits >= 8) {
int c = (int) ((put_buffer >> 16) & 0xFF);
emit_byte(entropy, c);
if (c == 0xFF) { /* need to stuff a zero byte? */
emit_byte(entropy, 0);
}
put_buffer <<= 8;
put_bits -= 8;
}
entropy->put_buffer = put_buffer; /* update variables */
entropy->put_bits = put_bits;
}
LOCAL(void)
flush_bits_p (phuff_entropy_ptr entropy)
{
emit_bits_p(entropy, 0x7F, 7); /* fill any partial byte with ones */
entropy->put_buffer = 0; /* and reset bit-buffer to empty */
entropy->put_bits = 0;
}
/*
* Emit (or just count) a Huffman symbol.
*/
INLINE
LOCAL(void)
emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol)
{
if (entropy->gather_statistics)
entropy->count_ptrs[tbl_no][symbol]++;
else {
c_derived_tbl * tbl = entropy->derived_tbls[tbl_no];
emit_bits_p(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
}
}
/*
* Emit bits from a correction bit buffer.
*/
LOCAL(void)
emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart,
unsigned int nbits)
{
if (entropy->gather_statistics)
return; /* no real work */
while (nbits > 0) {
emit_bits_p(entropy, (unsigned int) (*bufstart), 1);
bufstart++;
nbits--;
}
}
/*
* Emit any pending EOBRUN symbol.
*/
LOCAL(void)
emit_eobrun (phuff_entropy_ptr entropy)
{
int temp, nbits;
if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */
temp = entropy->EOBRUN;
nbits = 0;
while ((temp >>= 1))
nbits++;
/* safety check: shouldn't happen given limited correction-bit buffer */
if (nbits > 14)
ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
if (nbits)
emit_bits_p(entropy, entropy->EOBRUN, nbits);
entropy->EOBRUN = 0;
/* Emit any buffered correction bits */
emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
entropy->BE = 0;
}
}
/*
* Emit a restart marker & resynchronize predictions.
*/
LOCAL(void)
emit_restart_p (phuff_entropy_ptr entropy, int restart_num)
{
int ci;
emit_eobrun(entropy);
if (! entropy->gather_statistics) {
flush_bits_p(entropy);
emit_byte(entropy, 0xFF);
emit_byte(entropy, JPEG_RST0 + restart_num);
}
if (entropy->cinfo->Ss == 0) {
/* Re-initialize DC predictions to 0 */
for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
entropy->last_dc_val[ci] = 0;
} else {
/* Re-initialize all AC-related fields to 0 */
entropy->EOBRUN = 0;
entropy->BE = 0;
}
}
/*
* MCU encoding for DC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int temp, temp2;
int nbits;
int blkn, ci;
int Al = cinfo->Al;
JBLOCKROW block;
jpeg_component_info * compptr;
ISHIFT_TEMPS
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
/* Emit restart marker if needed */
if (cinfo->restart_interval)
if (entropy->restarts_to_go == 0)
emit_restart_p(entropy, entropy->next_restart_num);
/* Encode the MCU data blocks */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
ci = cinfo->MCU_membership[blkn];
compptr = cinfo->cur_comp_info[ci];
/* Compute the DC value after the required point transform by Al.
* This is simply an arithmetic right shift.
*/
temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al);
/* DC differences are figured on the point-transformed values. */
temp = temp2 - entropy->last_dc_val[ci];
entropy->last_dc_val[ci] = temp2;
/* Encode the DC coefficient difference per section G.1.2.1 */
temp2 = temp;
if (temp < 0) {
temp = -temp; /* temp is abs value of input */
/* For a negative input, want temp2 = bitwise complement of abs(input) */
/* This code assumes we are on a two's complement machine */
temp2--;
}
/* Find the number of bits needed for the magnitude of the coefficient */
nbits = 0;
while (temp) {
nbits++;
temp >>= 1;
}
/* Check for out-of-range coefficient values.
* Since we're encoding a difference, the range limit is twice as much.
*/
if (nbits > MAX_COEF_BITS+1)
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
/* Count/emit the Huffman-coded symbol for the number of bits */
emit_symbol(entropy, compptr->dc_tbl_no, nbits);
/* Emit that number of bits of the value, if positive, */
/* or the complement of its magnitude, if negative. */
if (nbits) /* emit_bits rejects calls with size 0 */
emit_bits_p(entropy, (unsigned int) temp2, nbits);
}
cinfo->dest->next_output_byte = entropy->next_output_byte;
cinfo->dest->free_in_buffer = entropy->free_in_buffer;
/* Update restart-interval state too */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
return TRUE;
}
/*
* MCU encoding for AC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int temp, temp2;
int nbits;
int r, k;
int Se = cinfo->Se;
int Al = cinfo->Al;
JBLOCKROW block;
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
/* Emit restart marker if needed */
if (cinfo->restart_interval)
if (entropy->restarts_to_go == 0)
emit_restart_p(entropy, entropy->next_restart_num);
/* Encode the MCU data block */
block = MCU_data[0];
/* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
r = 0; /* r = run length of zeros */
for (k = cinfo->Ss; k <= Se; k++) {
if ((temp = (*block)[jpeg_natural_order[k]]) == 0) {
r++;
continue;
}
/* We must apply the point transform by Al. For AC coefficients this
* is an integer division with rounding towards 0. To do this portably
* in C, we shift after obtaining the absolute value; so the code is
* interwoven with finding the abs value (temp) and output bits (temp2).
*/
if (temp < 0) {
temp = -temp; /* temp is abs value of input */
temp >>= Al; /* apply the point transform */
/* For a negative coef, want temp2 = bitwise complement of abs(coef) */
temp2 = ~temp;
} else {
temp >>= Al; /* apply the point transform */
temp2 = temp;
}
/* Watch out for case that nonzero coef is zero after point transform */
if (temp == 0) {
r++;
continue;
}
/* Emit any pending EOBRUN */
if (entropy->EOBRUN > 0)
emit_eobrun(entropy);
/* if run length > 15, must emit special run-length-16 codes (0xF0) */
while (r > 15) {
emit_symbol(entropy, entropy->ac_tbl_no, 0xF0);
r -= 16;
}
/* Find the number of bits needed for the magnitude of the coefficient */
nbits = 1; /* there must be at least one 1 bit */
while ((temp >>= 1))
nbits++;
/* Check for out-of-range coefficient values */
if (nbits > MAX_COEF_BITS)
ERREXIT(cinfo, JERR_BAD_DCT_COEF);
/* Count/emit Huffman symbol for run length / number of bits */
emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits);
/* Emit that number of bits of the value, if positive, */
/* or the complement of its magnitude, if negative. */
emit_bits_p(entropy, (unsigned int) temp2, nbits);
r = 0; /* reset zero run length */
}
if (r > 0) { /* If there are trailing zeroes, */
entropy->EOBRUN++; /* count an EOB */
if (entropy->EOBRUN == 0x7FFF)
emit_eobrun(entropy); /* force it out to avoid overflow */
}
cinfo->dest->next_output_byte = entropy->next_output_byte;
cinfo->dest->free_in_buffer = entropy->free_in_buffer;
/* Update restart-interval state too */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
return TRUE;
}
/*
* MCU encoding for DC successive approximation refinement scan.
* Note: we assume such scans can be multi-component, although the spec
* is not very clear on the point.
*/
METHODDEF(boolean)
encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int temp;
int blkn;
int Al = cinfo->Al;
JBLOCKROW block;
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
/* Emit restart marker if needed */
if (cinfo->restart_interval)
if (entropy->restarts_to_go == 0)
emit_restart_p(entropy, entropy->next_restart_num);
/* Encode the MCU data blocks */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
/* We simply emit the Al'th bit of the DC coefficient value. */
temp = (*block)[0];
emit_bits_p(entropy, (unsigned int) (temp >> Al), 1);
}
cinfo->dest->next_output_byte = entropy->next_output_byte;
cinfo->dest->free_in_buffer = entropy->free_in_buffer;
/* Update restart-interval state too */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
return TRUE;
}
/*
* MCU encoding for AC successive approximation refinement scan.
*/
METHODDEF(boolean)
encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
int temp;
int r, k;
int EOB;
char *BR_buffer;
unsigned int BR;
int Se = cinfo->Se;
int Al = cinfo->Al;
JBLOCKROW block;
int absvalues[DCTSIZE2];
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
/* Emit restart marker if needed */
if (cinfo->restart_interval)
if (entropy->restarts_to_go == 0)
emit_restart_p(entropy, entropy->next_restart_num);
/* Encode the MCU data block */
block = MCU_data[0];
/* It is convenient to make a pre-pass to determine the transformed
* coefficients' absolute values and the EOB position.
*/
EOB = 0;
for (k = cinfo->Ss; k <= Se; k++) {
temp = (*block)[jpeg_natural_order[k]];
/* We must apply the point transform by Al. For AC coefficients this
* is an integer division with rounding towards 0. To do this portably
* in C, we shift after obtaining the absolute value.
*/
if (temp < 0)
temp = -temp; /* temp is abs value of input */
temp >>= Al; /* apply the point transform */
absvalues[k] = temp; /* save abs value for main pass */
if (temp == 1)
EOB = k; /* EOB = index of last newly-nonzero coef */
}
/* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
r = 0; /* r = run length of zeros */
BR = 0; /* BR = count of buffered bits added now */
BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
for (k = cinfo->Ss; k <= Se; k++) {
if ((temp = absvalues[k]) == 0) {
r++;
continue;
}
/* Emit any required ZRLs, but not if they can be folded into EOB */
while (r > 15 && k <= EOB) {
/* emit any pending EOBRUN and the BE correction bits */
emit_eobrun(entropy);
/* Emit ZRL */
emit_symbol(entropy, entropy->ac_tbl_no, 0xF0);
r -= 16;
/* Emit buffered correction bits that must be associated with ZRL */
emit_buffered_bits(entropy, BR_buffer, BR);
BR_buffer = entropy->bit_buffer; /* BE bits are gone now */
BR = 0;
}
/* If the coef was previously nonzero, it only needs a correction bit.
* NOTE: a straight translation of the spec's figure G.7 would suggest
* that we also need to test r > 15. But if r > 15, we can only get here
* if k > EOB, which implies that this coefficient is not 1.
*/
if (temp > 1) {
/* The correction bit is the next bit of the absolute value. */
BR_buffer[BR++] = (char) (temp & 1);
continue;
}
/* Emit any pending EOBRUN and the BE correction bits */
emit_eobrun(entropy);
/* Count/emit Huffman symbol for run length / number of bits */
emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1);
/* Emit output bit for newly-nonzero coef */
temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1;
emit_bits_p(entropy, (unsigned int) temp, 1);
/* Emit buffered correction bits that must be associated with this code */
emit_buffered_bits(entropy, BR_buffer, BR);
BR_buffer = entropy->bit_buffer; /* BE bits are gone now */
BR = 0;
r = 0; /* reset zero run length */
}
if (r > 0 || BR > 0) { /* If there are trailing zeroes, */
entropy->EOBRUN++; /* count an EOB */
entropy->BE += BR; /* concat my correction bits to older ones */
/* We force out the EOB if we risk either:
* 1. overflow of the EOB counter;
* 2. overflow of the correction bit buffer during the next MCU.
*/
if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1))
emit_eobrun(entropy);
}
cinfo->dest->next_output_byte = entropy->next_output_byte;
cinfo->dest->free_in_buffer = entropy->free_in_buffer;
/* Update restart-interval state too */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0) {
entropy->restarts_to_go = cinfo->restart_interval;
entropy->next_restart_num++;
entropy->next_restart_num &= 7;
}
entropy->restarts_to_go--;
}
return TRUE;
}
/*
* Finish up at the end of a Huffman-compressed progressive scan.
*/
METHODDEF(void)
finish_pass_phuff (j_compress_ptr cinfo)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
entropy->next_output_byte = cinfo->dest->next_output_byte;
entropy->free_in_buffer = cinfo->dest->free_in_buffer;
/* Flush out any buffered data */
emit_eobrun(entropy);
flush_bits_p(entropy);
cinfo->dest->next_output_byte = entropy->next_output_byte;
cinfo->dest->free_in_buffer = entropy->free_in_buffer;
}
/*
* Finish up a statistics-gathering pass and create the new Huffman tables.
*/
METHODDEF(void)
finish_pass_gather_phuff (j_compress_ptr cinfo)
{
phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;
boolean is_DC_band;
int ci, tbl;
jpeg_component_info * compptr;
JHUFF_TBL **htblptr;
boolean did[NUM_HUFF_TBLS];
/* Flush out buffered data (all we care about is counting the EOB symbol) */
emit_eobrun(entropy);
is_DC_band = (cinfo->Ss == 0);
/* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts!
*/
MEMZERO(did, SIZEOF(did));
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (is_DC_band) {
if (cinfo->Ah != 0) /* DC refinement needs no table */
continue;
tbl = compptr->dc_tbl_no;
} else {
tbl = compptr->ac_tbl_no;
}
if (! did[tbl]) {
if (is_DC_band)
htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
else
htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
did[tbl] = TRUE;
}
}
}
/*
* Module initialization routine for progressive Huffman entropy encoding.
*/
GLOBAL(void)
jinit_phuff_encoder (j_compress_ptr cinfo)
{
phuff_entropy_ptr entropy;
int i;
entropy = (phuff_entropy_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(phuff_entropy_encoder));
cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
entropy->pub.start_pass = start_pass_phuff;
/* Mark tables unallocated */
for (i = 0; i < NUM_HUFF_TBLS; i++) {
entropy->derived_tbls[i] = NULL;
entropy->count_ptrs[i] = NULL;
}
entropy->bit_buffer = NULL; /* needed only in AC refinement scan */
}
#endif /* C_PROGRESSIVE_SUPPORTED */

View file

@ -2,6 +2,7 @@
* jcprepct.c * jcprepct.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2003-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -106,10 +107,11 @@ LOCAL(void)
expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols,
int input_rows, int output_rows) int input_rows, int output_rows)
{ {
int row; register int row;
for (row = input_rows; row < output_rows; row++) { for (row = input_rows; row < output_rows; row++) {
jcopy_sample_rows(image_data, input_rows-1, image_data, row, jcopy_sample_rows(image_data + input_rows - 1,
image_data + row,
1, num_cols); 1, num_cols);
} }
} }
@ -173,10 +175,12 @@ pre_process_data (j_compress_ptr cinfo,
*out_row_group_ctr < out_row_groups_avail) { *out_row_group_ctr < out_row_groups_avail) {
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
numrows = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
cinfo->min_DCT_v_scaled_size;
expand_bottom_edge(output_buf[ci], expand_bottom_edge(output_buf[ci],
compptr->width_in_blocks * DCTSIZE, compptr->width_in_blocks * compptr->DCT_h_scaled_size,
(int) (*out_row_group_ctr * compptr->v_samp_factor), (int) (*out_row_group_ctr * numrows),
(int) (out_row_groups_avail * compptr->v_samp_factor)); (int) (out_row_groups_avail * numrows));
} }
*out_row_group_ctr = out_row_groups_avail; *out_row_group_ctr = out_row_groups_avail;
break; /* can exit outer loop without test */ break; /* can exit outer loop without test */
@ -218,8 +222,8 @@ pre_process_context (j_compress_ptr cinfo,
for (ci = 0; ci < cinfo->num_components; ci++) { for (ci = 0; ci < cinfo->num_components; ci++) {
int row; int row;
for (row = 1; row <= cinfo->max_v_samp_factor; row++) { for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
jcopy_sample_rows(prep->color_buf[ci], 0, jcopy_sample_rows(prep->color_buf[ci],
prep->color_buf[ci], -row, prep->color_buf[ci] - row,
1, cinfo->image_width); 1, cinfo->image_width);
} }
} }
@ -275,10 +279,9 @@ create_context_buffer (j_compress_ptr cinfo)
/* Grab enough space for fake row pointers for all the components; /* Grab enough space for fake row pointers for all the components;
* we need five row groups' worth of pointers for each component. * we need five row groups' worth of pointers for each component.
*/ */
fake_buffer = (JSAMPARRAY) fake_buffer = (JSAMPARRAY) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
(cinfo->num_components * 5 * rgroup_height) * (cinfo->num_components * 5 * rgroup_height) * SIZEOF(JSAMPROW));
SIZEOF(JSAMPROW));
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
@ -288,7 +291,8 @@ create_context_buffer (j_compress_ptr cinfo)
*/ */
true_buffer = (*cinfo->mem->alloc_sarray) true_buffer = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * (JDIMENSION) (((long) compptr->width_in_blocks *
cinfo->min_DCT_h_scaled_size *
cinfo->max_h_samp_factor) / compptr->h_samp_factor), cinfo->max_h_samp_factor) / compptr->h_samp_factor),
(JDIMENSION) (3 * rgroup_height)); (JDIMENSION) (3 * rgroup_height));
/* Copy true buffer row pointers into the middle of the fake row array */ /* Copy true buffer row pointers into the middle of the fake row array */
@ -321,10 +325,9 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
if (need_full_buffer) /* safety check */ if (need_full_buffer) /* safety check */
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
prep = (my_prep_ptr) prep = (my_prep_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_prep_controller));
SIZEOF(my_prep_controller)); cinfo->prep = &prep->pub;
cinfo->prep = (struct jpeg_c_prep_controller *) prep;
prep->pub.start_pass = start_pass_prep; prep->pub.start_pass = start_pass_prep;
/* Allocate the color conversion buffer. /* Allocate the color conversion buffer.
@ -346,7 +349,8 @@ jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer)
ci++, compptr++) { ci++, compptr++) {
prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) prep->color_buf[ci] = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * (JDIMENSION) (((long) compptr->width_in_blocks *
cinfo->min_DCT_h_scaled_size *
cinfo->max_h_samp_factor) / compptr->h_samp_factor), cinfo->max_h_samp_factor) / compptr->h_samp_factor),
(JDIMENSION) cinfo->max_v_samp_factor); (JDIMENSION) cinfo->max_v_samp_factor);
} }

View file

@ -2,6 +2,7 @@
* jcsample.c * jcsample.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2003-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -62,6 +63,15 @@ typedef struct {
/* Downsampling method pointers, one per component */ /* Downsampling method pointers, one per component */
downsample1_ptr methods[MAX_COMPONENTS]; downsample1_ptr methods[MAX_COMPONENTS];
/* Height of an output row group for each component. */
int rowgroup_height[MAX_COMPONENTS];
/* These arrays save pixel expansion factors so that int_downsample need not
* recompute them each time. They are unused for other downsampling methods.
*/
UINT8 h_expand[MAX_COMPONENTS];
UINT8 v_expand[MAX_COMPONENTS];
} my_downsampler; } my_downsampler;
typedef my_downsampler * my_downsample_ptr; typedef my_downsampler * my_downsample_ptr;
@ -72,7 +82,7 @@ typedef my_downsampler * my_downsample_ptr;
*/ */
METHODDEF(void) METHODDEF(void)
start_pass_downsample (j_compress_ptr) start_pass_downsample (j_compress_ptr cinfo)
{ {
/* no work for now */ /* no work for now */
} }
@ -87,9 +97,9 @@ LOCAL(void)
expand_right_edge (JSAMPARRAY image_data, int num_rows, expand_right_edge (JSAMPARRAY image_data, int num_rows,
JDIMENSION input_cols, JDIMENSION output_cols) JDIMENSION input_cols, JDIMENSION output_cols)
{ {
JSAMPROW ptr; register JSAMPROW ptr;
JSAMPLE pixval; register JSAMPLE pixval;
int count; register int count;
int row; int row;
int numcols = (int) (output_cols - input_cols); int numcols = (int) (output_cols - input_cols);
@ -123,7 +133,8 @@ sep_downsample (j_compress_ptr cinfo,
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
in_ptr = input_buf[ci] + in_row_index; in_ptr = input_buf[ci] + in_row_index;
out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); out_ptr = output_buf[ci] +
(out_row_group_index * downsample->rowgroup_height[ci]);
(*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr);
} }
} }
@ -140,14 +151,15 @@ METHODDEF(void)
int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data) JSAMPARRAY input_data, JSAMPARRAY output_data)
{ {
my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample;
int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v;
JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
JSAMPROW inptr, outptr; JSAMPROW inptr, outptr;
INT32 outvalue; INT32 outvalue;
h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; h_expand = downsample->h_expand[compptr->component_index];
v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; v_expand = downsample->v_expand[compptr->component_index];
numpix = h_expand * v_expand; numpix = h_expand * v_expand;
numpix2 = numpix/2; numpix2 = numpix/2;
@ -158,8 +170,8 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
expand_right_edge(input_data, cinfo->max_v_samp_factor, expand_right_edge(input_data, cinfo->max_v_samp_factor,
cinfo->image_width, output_cols * h_expand); cinfo->image_width, output_cols * h_expand);
inrow = 0; inrow = outrow = 0;
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { while (inrow < cinfo->max_v_samp_factor) {
outptr = output_data[outrow]; outptr = output_data[outrow];
for (outcol = 0, outcol_h = 0; outcol < output_cols; for (outcol = 0, outcol_h = 0; outcol < output_cols;
outcol++, outcol_h += h_expand) { outcol++, outcol_h += h_expand) {
@ -173,6 +185,7 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
*outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix);
} }
inrow += v_expand; inrow += v_expand;
outrow++;
} }
} }
@ -188,11 +201,11 @@ fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data) JSAMPARRAY input_data, JSAMPARRAY output_data)
{ {
/* Copy the data */ /* Copy the data */
jcopy_sample_rows(input_data, 0, output_data, 0, jcopy_sample_rows(input_data, output_data,
cinfo->max_v_samp_factor, cinfo->image_width); cinfo->max_v_samp_factor, cinfo->image_width);
/* Edge-expand */ /* Edge-expand */
expand_right_edge(output_data, cinfo->max_v_samp_factor, expand_right_edge(output_data, cinfo->max_v_samp_factor, cinfo->image_width,
cinfo->image_width, compptr->width_in_blocks * DCTSIZE); compptr->width_in_blocks * compptr->DCT_h_scaled_size);
} }
@ -212,11 +225,11 @@ METHODDEF(void)
h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data) JSAMPARRAY input_data, JSAMPARRAY output_data)
{ {
int outrow; int inrow;
JDIMENSION outcol; JDIMENSION outcol;
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
int bias; register int bias;
/* Expand input data enough to let all the output samples be generated /* Expand input data enough to let all the output samples be generated
* by the standard loop. Special-casing padded output would be more * by the standard loop. Special-casing padded output would be more
@ -225,9 +238,9 @@ h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
expand_right_edge(input_data, cinfo->max_v_samp_factor, expand_right_edge(input_data, cinfo->max_v_samp_factor,
cinfo->image_width, output_cols * 2); cinfo->image_width, output_cols * 2);
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
outptr = output_data[outrow]; outptr = output_data[inrow];
inptr = input_data[outrow]; inptr = input_data[inrow];
bias = 0; /* bias = 0,1,0,1,... for successive samples */ bias = 0; /* bias = 0,1,0,1,... for successive samples */
for (outcol = 0; outcol < output_cols; outcol++) { for (outcol = 0; outcol < output_cols; outcol++) {
*outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1])
@ -251,9 +264,9 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
{ {
int inrow, outrow; int inrow, outrow;
JDIMENSION outcol; JDIMENSION outcol;
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
JSAMPROW inptr0, inptr1, outptr; register JSAMPROW inptr0, inptr1, outptr;
int bias; register int bias;
/* Expand input data enough to let all the output samples be generated /* Expand input data enough to let all the output samples be generated
* by the standard loop. Special-casing padded output would be more * by the standard loop. Special-casing padded output would be more
@ -262,8 +275,8 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
expand_right_edge(input_data, cinfo->max_v_samp_factor, expand_right_edge(input_data, cinfo->max_v_samp_factor,
cinfo->image_width, output_cols * 2); cinfo->image_width, output_cols * 2);
inrow = 0; inrow = outrow = 0;
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { while (inrow < cinfo->max_v_samp_factor) {
outptr = output_data[outrow]; outptr = output_data[outrow];
inptr0 = input_data[inrow]; inptr0 = input_data[inrow];
inptr1 = input_data[inrow+1]; inptr1 = input_data[inrow+1];
@ -276,6 +289,7 @@ h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
inptr0 += 2; inptr1 += 2; inptr0 += 2; inptr1 += 2;
} }
inrow += 2; inrow += 2;
outrow++;
} }
} }
@ -294,8 +308,8 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
{ {
int inrow, outrow; int inrow, outrow;
JDIMENSION colctr; JDIMENSION colctr;
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr;
INT32 membersum, neighsum, memberscale, neighscale; INT32 membersum, neighsum, memberscale, neighscale;
/* Expand input data enough to let all the output samples be generated /* Expand input data enough to let all the output samples be generated
@ -321,8 +335,8 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */
neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */
inrow = 0; inrow = outrow = 0;
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { while (inrow < cinfo->max_v_samp_factor) {
outptr = output_data[outrow]; outptr = output_data[outrow];
inptr0 = input_data[inrow]; inptr0 = input_data[inrow];
inptr1 = input_data[inrow+1]; inptr1 = input_data[inrow+1];
@ -378,6 +392,7 @@ h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
*outptr = (JSAMPLE) ((membersum + 32768) >> 16); *outptr = (JSAMPLE) ((membersum + 32768) >> 16);
inrow += 2; inrow += 2;
outrow++;
} }
} }
@ -392,10 +407,10 @@ METHODDEF(void)
fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
JSAMPARRAY input_data, JSAMPARRAY output_data) JSAMPARRAY input_data, JSAMPARRAY output_data)
{ {
int outrow; int inrow;
JDIMENSION colctr; JDIMENSION colctr;
JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; JDIMENSION output_cols = compptr->width_in_blocks * compptr->DCT_h_scaled_size;
JSAMPROW inptr, above_ptr, below_ptr, outptr; register JSAMPROW inptr, above_ptr, below_ptr, outptr;
INT32 membersum, neighsum, memberscale, neighscale; INT32 membersum, neighsum, memberscale, neighscale;
int colsum, lastcolsum, nextcolsum; int colsum, lastcolsum, nextcolsum;
@ -415,11 +430,11 @@ fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr,
memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */
neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ neighscale = cinfo->smoothing_factor * 64; /* scaled SF */
for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
outptr = output_data[outrow]; outptr = output_data[inrow];
inptr = input_data[outrow]; inptr = input_data[inrow];
above_ptr = input_data[outrow-1]; above_ptr = input_data[inrow-1];
below_ptr = input_data[outrow+1]; below_ptr = input_data[inrow+1];
/* Special case for first column */ /* Special case for first column */
colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) +
@ -467,11 +482,11 @@ jinit_downsampler (j_compress_ptr cinfo)
int ci; int ci;
jpeg_component_info * compptr; jpeg_component_info * compptr;
boolean smoothok = TRUE; boolean smoothok = TRUE;
int h_in_group, v_in_group, h_out_group, v_out_group;
downsample = (my_downsample_ptr) downsample = (my_downsample_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_downsampler));
SIZEOF(my_downsampler)); cinfo->downsample = &downsample->pub;
cinfo->downsample = (struct jpeg_downsampler *) downsample;
downsample->pub.start_pass = start_pass_downsample; downsample->pub.start_pass = start_pass_downsample;
downsample->pub.downsample = sep_downsample; downsample->pub.downsample = sep_downsample;
downsample->pub.need_context_rows = FALSE; downsample->pub.need_context_rows = FALSE;
@ -482,8 +497,17 @@ jinit_downsampler (j_compress_ptr cinfo)
/* Verify we can handle the sampling factors, and set up method pointers */ /* Verify we can handle the sampling factors, and set up method pointers */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
if (compptr->h_samp_factor == cinfo->max_h_samp_factor && /* Compute size of an "output group" for DCT scaling. This many samples
compptr->v_samp_factor == cinfo->max_v_samp_factor) { * are to be converted from max_h_samp_factor * max_v_samp_factor pixels.
*/
h_out_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) /
cinfo->min_DCT_h_scaled_size;
v_out_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
cinfo->min_DCT_v_scaled_size;
h_in_group = cinfo->max_h_samp_factor;
v_in_group = cinfo->max_v_samp_factor;
downsample->rowgroup_height[ci] = v_out_group; /* save for use later */
if (h_in_group == h_out_group && v_in_group == v_out_group) {
#ifdef INPUT_SMOOTHING_SUPPORTED #ifdef INPUT_SMOOTHING_SUPPORTED
if (cinfo->smoothing_factor) { if (cinfo->smoothing_factor) {
downsample->methods[ci] = fullsize_smooth_downsample; downsample->methods[ci] = fullsize_smooth_downsample;
@ -491,12 +515,12 @@ jinit_downsampler (j_compress_ptr cinfo)
} else } else
#endif #endif
downsample->methods[ci] = fullsize_downsample; downsample->methods[ci] = fullsize_downsample;
} else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && } else if (h_in_group == h_out_group * 2 &&
compptr->v_samp_factor == cinfo->max_v_samp_factor) { v_in_group == v_out_group) {
smoothok = FALSE; smoothok = FALSE;
downsample->methods[ci] = h2v1_downsample; downsample->methods[ci] = h2v1_downsample;
} else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && } else if (h_in_group == h_out_group * 2 &&
compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { v_in_group == v_out_group * 2) {
#ifdef INPUT_SMOOTHING_SUPPORTED #ifdef INPUT_SMOOTHING_SUPPORTED
if (cinfo->smoothing_factor) { if (cinfo->smoothing_factor) {
downsample->methods[ci] = h2v2_smooth_downsample; downsample->methods[ci] = h2v2_smooth_downsample;
@ -504,10 +528,12 @@ jinit_downsampler (j_compress_ptr cinfo)
} else } else
#endif #endif
downsample->methods[ci] = h2v2_downsample; downsample->methods[ci] = h2v2_downsample;
} else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && } else if ((h_in_group % h_out_group) == 0 &&
(cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { (v_in_group % v_out_group) == 0) {
smoothok = FALSE; smoothok = FALSE;
downsample->methods[ci] = int_downsample; downsample->methods[ci] = int_downsample;
downsample->h_expand[ci] = (UINT8) (h_in_group / h_out_group);
downsample->v_expand[ci] = (UINT8) (v_in_group / v_out_group);
} else } else
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
} }

View file

@ -2,6 +2,7 @@
* jctrans.c * jctrans.c
* *
* Copyright (C) 1995-1998, Thomas G. Lane. * Copyright (C) 1995-1998, Thomas G. Lane.
* Modified 2000-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -76,13 +77,23 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
dstinfo->image_height = srcinfo->image_height; dstinfo->image_height = srcinfo->image_height;
dstinfo->input_components = srcinfo->num_components; dstinfo->input_components = srcinfo->num_components;
dstinfo->in_color_space = srcinfo->jpeg_color_space; dstinfo->in_color_space = srcinfo->jpeg_color_space;
dstinfo->jpeg_width = srcinfo->output_width;
dstinfo->jpeg_height = srcinfo->output_height;
dstinfo->min_DCT_h_scaled_size = srcinfo->min_DCT_h_scaled_size;
dstinfo->min_DCT_v_scaled_size = srcinfo->min_DCT_v_scaled_size;
/* Initialize all parameters to default values */ /* Initialize all parameters to default values */
jpeg_set_defaults(dstinfo); jpeg_set_defaults(dstinfo);
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
* Fix it to get the right header markers for the image colorspace. * Fix it to get the right header markers for the image colorspace.
* Note: Entropy table assignment in jpeg_set_colorspace
* depends on color_transform.
* Adaption is also required for setting the appropriate
* entropy coding mode dependent on image data precision.
*/ */
dstinfo->color_transform = srcinfo->color_transform;
jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space);
dstinfo->data_precision = srcinfo->data_precision; dstinfo->data_precision = srcinfo->data_precision;
dstinfo->arith_code = srcinfo->data_precision > 8 ? TRUE : FALSE;
dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling;
/* Copy the source's quantization tables. */ /* Copy the source's quantization tables. */
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
@ -125,7 +136,7 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
} }
} }
/* Note: we do not copy the source's Huffman table assignments; /* Note: we do not copy the source's entropy table assignments;
* instead we rely on jpeg_set_colorspace to have made a suitable choice. * instead we rely on jpeg_set_colorspace to have made a suitable choice.
*/ */
} }
@ -135,10 +146,10 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
* if the application chooses to copy JFIF 1.02 extension markers from * if the application chooses to copy JFIF 1.02 extension markers from
* the source file, we need to copy the version to make sure we don't * the source file, we need to copy the version to make sure we don't
* emit a file that has 1.02 extensions but a claimed version of 1.01. * emit a file that has 1.02 extensions but a claimed version of 1.01.
* We will *not*, however, copy version info from mislabeled "2.01" files.
*/ */
if (srcinfo->saw_JFIF_marker) { if (srcinfo->saw_JFIF_marker) {
if (srcinfo->JFIF_major_version == 1) { if (srcinfo->JFIF_major_version == 1 ||
srcinfo->JFIF_major_version == 2) {
dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; dstinfo->JFIF_major_version = srcinfo->JFIF_major_version;
dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version;
} }
@ -149,6 +160,18 @@ jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
} }
LOCAL(void)
jpeg_calc_trans_dimensions (j_compress_ptr cinfo)
/* Do computations that are needed before master selection phase */
{
if (cinfo->min_DCT_h_scaled_size != cinfo->min_DCT_v_scaled_size)
ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
cinfo->min_DCT_h_scaled_size, cinfo->min_DCT_v_scaled_size);
cinfo->block_size = cinfo->min_DCT_h_scaled_size;
}
/* /*
* Master selection of compression modules for transcoding. * Master selection of compression modules for transcoding.
* This substitutes for jcinit.c's initialization of the full compressor. * This substitutes for jcinit.c's initialization of the full compressor.
@ -158,25 +181,17 @@ LOCAL(void)
transencode_master_selection (j_compress_ptr cinfo, transencode_master_selection (j_compress_ptr cinfo,
jvirt_barray_ptr * coef_arrays) jvirt_barray_ptr * coef_arrays)
{ {
/* Although we don't actually use input_components for transcoding, /* Do computations that are needed before master selection phase */
* jcmaster.c's initial_setup will complain if input_components is 0. jpeg_calc_trans_dimensions(cinfo);
*/
cinfo->input_components = 1;
/* Initialize master control (includes parameter checking/processing) */ /* Initialize master control (includes parameter checking/processing) */
jinit_c_master_control(cinfo, TRUE /* transcode only */); jinit_c_master_control(cinfo, TRUE /* transcode only */);
/* Entropy encoding: either Huffman or arithmetic coding. */ /* Entropy encoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code)
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); jinit_arith_encoder(cinfo);
} else { else {
if (cinfo->progressive_mode) { jinit_huff_encoder(cinfo);
#ifdef C_PROGRESSIVE_SUPPORTED
jinit_phuff_encoder(cinfo);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else
jinit_huff_encoder(cinfo);
} }
/* We need a special coefficient buffer controller. */ /* We need a special coefficient buffer controller. */
@ -209,7 +224,7 @@ typedef struct {
struct jpeg_c_coef_controller pub; /* public fields */ struct jpeg_c_coef_controller pub; /* public fields */
JDIMENSION iMCU_row_num; /* iMCU row # within image */ JDIMENSION iMCU_row_num; /* iMCU row # within image */
JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
int MCU_vert_offset; /* counts MCU rows within iMCU row */ int MCU_vert_offset; /* counts MCU rows within iMCU row */
int MCU_rows_per_iMCU_row; /* number of such rows needed */ int MCU_rows_per_iMCU_row; /* number of such rows needed */
@ -217,17 +232,17 @@ typedef struct {
jvirt_barray_ptr * whole_image; jvirt_barray_ptr * whole_image;
/* Workspace for constructing dummy blocks at right/bottom edges. */ /* Workspace for constructing dummy blocks at right/bottom edges. */
JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; JBLOCK dummy_buffer[C_MAX_BLOCKS_IN_MCU];
} my_coef_controller2; } my_coef_controller;
typedef my_coef_controller2 * my_coef_ptr2; typedef my_coef_controller * my_coef_ptr;
LOCAL(void) LOCAL(void)
start_iMCU_row2 (j_compress_ptr cinfo) start_iMCU_row (j_compress_ptr cinfo)
/* Reset within-iMCU-row counters for a new row */ /* Reset within-iMCU-row counters for a new row */
{ {
my_coef_ptr2 coef = (my_coef_ptr2) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
/* In an interleaved scan, an MCU row is the same as an iMCU row. /* In an interleaved scan, an MCU row is the same as an iMCU row.
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
@ -242,7 +257,7 @@ start_iMCU_row2 (j_compress_ptr cinfo)
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
} }
coef->mcu_ctr = 0; coef->MCU_ctr = 0;
coef->MCU_vert_offset = 0; coef->MCU_vert_offset = 0;
} }
@ -252,15 +267,15 @@ start_iMCU_row2 (j_compress_ptr cinfo)
*/ */
METHODDEF(void) METHODDEF(void)
start_pass_coef2 (j_compress_ptr cinfo, J_BUF_MODE pass_mode) start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
{ {
my_coef_ptr2 coef = (my_coef_ptr2) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
if (pass_mode != JBUF_CRANK_DEST) if (pass_mode != JBUF_CRANK_DEST)
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
coef->iMCU_row_num = 0; coef->iMCU_row_num = 0;
start_iMCU_row2(cinfo); start_iMCU_row(cinfo);
} }
@ -275,9 +290,9 @@ start_pass_coef2 (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
*/ */
METHODDEF(boolean) METHODDEF(boolean)
compress_output2 (j_compress_ptr cinfo, JSAMPIMAGE) compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
{ {
my_coef_ptr2 coef = (my_coef_ptr2) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION MCU_col_num; /* index of current MCU within row */
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
@ -300,25 +315,30 @@ compress_output2 (j_compress_ptr cinfo, JSAMPIMAGE)
/* Loop to process one whole iMCU row */ /* Loop to process one whole iMCU row */
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
yoffset++) { yoffset++) {
for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
MCU_col_num++) { MCU_col_num++) {
/* Construct list of pointers to DCT blocks belonging to this MCU */ /* Construct list of pointers to DCT blocks belonging to this MCU */
blkn = 0; /* index of current DCT block within MCU */ blkn = 0; /* index of current DCT block within MCU */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
start_col = MCU_col_num * compptr->MCU_width;
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
: compptr->last_col_width; : compptr->last_col_width;
start_col = MCU_col_num * compptr->MCU_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) { for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (coef->iMCU_row_num < last_iMCU_row || if (coef->iMCU_row_num < last_iMCU_row ||
yindex+yoffset < compptr->last_row_height) { yoffset + yindex < compptr->last_row_height) {
/* Fill in pointers to real blocks in this row */ /* Fill in pointers to real blocks in this row */
buffer_ptr = buffer[ci][yindex+yoffset] + start_col; buffer_ptr = buffer[ci][yoffset + yindex] + start_col;
for (xindex = 0; xindex < blockcnt; xindex++) xindex = blockcnt;
do {
MCU_buffer[blkn++] = buffer_ptr++; MCU_buffer[blkn++] = buffer_ptr++;
} while (--xindex);
/* Dummy blocks at right edge */
if ((xindex = compptr->MCU_width - blockcnt) == 0)
continue;
} else { } else {
/* At bottom of image, need a whole row of dummy blocks */ /* At bottom of image, need a whole row of dummy blocks */
xindex = 0; xindex = compptr->MCU_width;
} }
/* Fill in any dummy blocks needed in this row. /* Fill in any dummy blocks needed in this row.
* Dummy blocks are filled in the same way as in jccoefct.c: * Dummy blocks are filled in the same way as in jccoefct.c:
@ -326,27 +346,27 @@ compress_output2 (j_compress_ptr cinfo, JSAMPIMAGE)
* block's DC value. The init routine has already zeroed the * block's DC value. The init routine has already zeroed the
* AC entries, so we need only set the DC entries correctly. * AC entries, so we need only set the DC entries correctly.
*/ */
for (; xindex < compptr->MCU_width; xindex++) { buffer_ptr = coef->dummy_buffer + blkn;
MCU_buffer[blkn] = coef->dummy_buffer[blkn]; do {
MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; buffer_ptr[0][0] = MCU_buffer[blkn-1][0][0];
blkn++; MCU_buffer[blkn++] = buffer_ptr++;
} } while (--xindex);
} }
} }
/* Try to write the MCU. */ /* Try to write the MCU. */
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
/* Suspension forced; update state counters and exit */ /* Suspension forced; update state counters and exit */
coef->MCU_vert_offset = yoffset; coef->MCU_vert_offset = yoffset;
coef->mcu_ctr = MCU_col_num; coef->MCU_ctr = MCU_col_num;
return FALSE; return FALSE;
} }
} }
/* Completed an MCU row, but perhaps not an iMCU row */ /* Completed an MCU row, but perhaps not an iMCU row */
coef->mcu_ctr = 0; coef->MCU_ctr = 0;
} }
/* Completed the iMCU row, advance counters for next one */ /* Completed the iMCU row, advance counters for next one */
coef->iMCU_row_num++; coef->iMCU_row_num++;
start_iMCU_row2(cinfo); start_iMCU_row(cinfo);
return TRUE; return TRUE;
} }
@ -363,26 +383,17 @@ LOCAL(void)
transencode_coef_controller (j_compress_ptr cinfo, transencode_coef_controller (j_compress_ptr cinfo,
jvirt_barray_ptr * coef_arrays) jvirt_barray_ptr * coef_arrays)
{ {
my_coef_ptr2 coef; my_coef_ptr coef;
JBLOCKROW buffer;
int i;
coef = (my_coef_ptr2) coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller));
SIZEOF(my_coef_controller2)); cinfo->coef = &coef->pub;
cinfo->coef = (struct jpeg_c_coef_controller *) coef; coef->pub.start_pass = start_pass_coef;
coef->pub.start_pass = start_pass_coef2; coef->pub.compress_data = compress_output;
coef->pub.compress_data = compress_output2;
/* Save pointer to virtual arrays */ /* Save pointer to virtual arrays */
coef->whole_image = coef_arrays; coef->whole_image = coef_arrays;
/* Allocate and pre-zero space for dummy DCT blocks. */ /* Pre-zero space for dummy DCT blocks */
buffer = (JBLOCKROW) MEMZERO(coef->dummy_buffer, SIZEOF(coef->dummy_buffer));
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
coef->dummy_buffer[i] = buffer + i;
}
} }

View file

@ -2,6 +2,7 @@
* jdapimin.c * jdapimin.c
* *
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2009-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -36,7 +37,7 @@ jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
if (version != JPEG_LIB_VERSION) if (version != JPEG_LIB_VERSION)
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
if (structsize != SIZEOF(struct jpeg_decompress_struct)) if (structsize != SIZEOF(struct jpeg_decompress_struct))
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
/* For debugging purposes, we zero the whole master structure. /* For debugging purposes, we zero the whole master structure.
@ -113,8 +114,9 @@ jpeg_abort_decompress (j_decompress_ptr cinfo)
LOCAL(void) LOCAL(void)
default_decompress_parms (j_decompress_ptr cinfo) default_decompress_parms (j_decompress_ptr cinfo)
{ {
int cid0, cid1, cid2, cid3;
/* Guess the input colorspace, and set output colorspace accordingly. */ /* Guess the input colorspace, and set output colorspace accordingly. */
/* (Wish JPEG committee had provided a real way to specify this...) */
/* Note application may override our guesses. */ /* Note application may override our guesses. */
switch (cinfo->num_components) { switch (cinfo->num_components) {
case 1: case 1:
@ -123,9 +125,25 @@ default_decompress_parms (j_decompress_ptr cinfo)
break; break;
case 3: case 3:
if (cinfo->saw_JFIF_marker) { cid0 = cinfo->comp_info[0].component_id;
cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ cid1 = cinfo->comp_info[1].component_id;
} else if (cinfo->saw_Adobe_marker) { cid2 = cinfo->comp_info[2].component_id;
/* For robust detection of standard colorspaces
* regardless of the presence of special markers,
* check component IDs from SOF marker first.
*/
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03)
cinfo->jpeg_color_space = JCS_YCbCr;
else if (cid0 == 0x01 && cid1 == 0x22 && cid2 == 0x23)
cinfo->jpeg_color_space = JCS_BG_YCC;
else if (cid0 == 0x52 && cid1 == 0x47 && cid2 == 0x42)
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
else if (cid0 == 0x72 && cid1 == 0x67 && cid2 == 0x62)
cinfo->jpeg_color_space = JCS_BG_RGB; /* ASCII 'r', 'g', 'b' */
else if (cinfo->saw_JFIF_marker)
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
else if (cinfo->saw_Adobe_marker) {
switch (cinfo->Adobe_transform) { switch (cinfo->Adobe_transform) {
case 0: case 0:
cinfo->jpeg_color_space = JCS_RGB; cinfo->jpeg_color_space = JCS_RGB;
@ -135,30 +153,31 @@ default_decompress_parms (j_decompress_ptr cinfo)
break; break;
default: default:
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
break;
} }
} else { } else {
/* Saw no special markers, try to guess from the component IDs */ TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
int cid0 = cinfo->comp_info[0].component_id; cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
int cid1 = cinfo->comp_info[1].component_id;
int cid2 = cinfo->comp_info[2].component_id;
if (cid0 == 1 && cid1 == 2 && cid2 == 3)
cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
else {
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
}
} }
/* Always guess RGB is proper output colorspace. */ /* Always guess RGB is proper output colorspace. */
cinfo->out_color_space = JCS_RGB; cinfo->out_color_space = JCS_RGB;
break; break;
case 4: case 4:
if (cinfo->saw_Adobe_marker) { cid0 = cinfo->comp_info[0].component_id;
cid1 = cinfo->comp_info[1].component_id;
cid2 = cinfo->comp_info[2].component_id;
cid3 = cinfo->comp_info[3].component_id;
/* For robust detection of standard colorspaces
* regardless of the presence of special markers,
* check component IDs from SOF marker first.
*/
if (cid0 == 0x01 && cid1 == 0x02 && cid2 == 0x03 && cid3 == 0x04)
cinfo->jpeg_color_space = JCS_YCCK;
else if (cid0 == 0x43 && cid1 == 0x4D && cid2 == 0x59 && cid3 == 0x4B)
cinfo->jpeg_color_space = JCS_CMYK; /* ASCII 'C', 'M', 'Y', 'K' */
else if (cinfo->saw_Adobe_marker) {
switch (cinfo->Adobe_transform) { switch (cinfo->Adobe_transform) {
case 0: case 0:
cinfo->jpeg_color_space = JCS_CMYK; cinfo->jpeg_color_space = JCS_CMYK;
@ -168,11 +187,10 @@ default_decompress_parms (j_decompress_ptr cinfo)
break; break;
default: default:
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
break;
} }
} else { } else {
/* No special markers, assume straight CMYK. */ /* Unknown IDs and no special markers, assume straight CMYK. */
cinfo->jpeg_color_space = JCS_CMYK; cinfo->jpeg_color_space = JCS_CMYK;
} }
cinfo->out_color_space = JCS_CMYK; cinfo->out_color_space = JCS_CMYK;
@ -181,12 +199,11 @@ default_decompress_parms (j_decompress_ptr cinfo)
default: default:
cinfo->jpeg_color_space = JCS_UNKNOWN; cinfo->jpeg_color_space = JCS_UNKNOWN;
cinfo->out_color_space = JCS_UNKNOWN; cinfo->out_color_space = JCS_UNKNOWN;
break;
} }
/* Set defaults for other decompression parameters. */ /* Set defaults for other decompression parameters. */
cinfo->scale_num = 1; /* 1:1 scaling */ cinfo->scale_num = cinfo->block_size; /* 1:1 scaling */
cinfo->scale_denom = 1; cinfo->scale_denom = cinfo->block_size;
cinfo->output_gamma = 1.0; cinfo->output_gamma = 1.0;
cinfo->buffered_image = FALSE; cinfo->buffered_image = FALSE;
cinfo->raw_data_out = FALSE; cinfo->raw_data_out = FALSE;

View file

@ -2,6 +2,7 @@
* jdapistd.c * jdapistd.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2002-2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -202,7 +203,7 @@ jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
} }
/* Verify that at least one iMCU row can be returned. */ /* Verify that at least one iMCU row can be returned. */
lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
if (max_lines < lines_per_iMCU_row) if (max_lines < lines_per_iMCU_row)
ERREXIT(cinfo, JERR_BUFFER_SIZE); ERREXIT(cinfo, JERR_BUFFER_SIZE);

View file

@ -0,0 +1,796 @@
/*
* jdarith.c
*
* Developed 1997-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains portable arithmetic entropy decoding routines for JPEG
* (implementing the ISO/IEC IS 10918-1 and CCITT Recommendation ITU-T T.81).
*
* Both sequential and progressive modes are supported in this single module.
*
* Suspension is not currently supported in this module.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
/* Expanded entropy decoder object for arithmetic decoding. */
typedef struct {
struct jpeg_entropy_decoder pub; /* public fields */
INT32 c; /* C register, base of coding interval + input bit buffer */
INT32 a; /* A register, normalized size of coding interval */
int ct; /* bit shift counter, # of bits left in bit buffer part of C */
/* init: ct = -16 */
/* run: ct = 0..7 */
/* error: ct = -1 */
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
int dc_context[MAX_COMPS_IN_SCAN]; /* context index for DC conditioning */
unsigned int restarts_to_go; /* MCUs left in this restart interval */
/* Pointers to statistics areas (these workspaces have image lifespan) */
unsigned char * dc_stats[NUM_ARITH_TBLS];
unsigned char * ac_stats[NUM_ARITH_TBLS];
/* Statistics bin for coding with fixed probability 0.5 */
unsigned char fixed_bin[4];
} arith_entropy_decoder;
typedef arith_entropy_decoder * arith_entropy_ptr;
/* The following two definitions specify the allocation chunk size
* for the statistics area.
* According to sections F.1.4.4.1.3 and F.1.4.4.2, we need at least
* 49 statistics bins for DC, and 245 statistics bins for AC coding.
*
* We use a compact representation with 1 byte per statistics bin,
* thus the numbers directly represent byte sizes.
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/
#define DC_STAT_BINS 64
#define AC_STAT_BINS 256
LOCAL(int)
get_byte (j_decompress_ptr cinfo)
/* Read next input byte; we do not support suspension in this module. */
{
struct jpeg_source_mgr * src = cinfo->src;
if (src->bytes_in_buffer == 0)
if (! (*src->fill_input_buffer) (cinfo))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
src->bytes_in_buffer--;
return GETJOCTET(*src->next_input_byte++);
}
/*
* The core arithmetic decoding routine (common in JPEG and JBIG).
* This needs to go as fast as possible.
* Machine-dependent optimization facilities
* are not utilized in this portable implementation.
* However, this code should be fairly efficient and
* may be a good base for further optimizations anyway.
*
* Return value is 0 or 1 (binary decision).
*
* Note: I've changed the handling of the code base & bit
* buffer register C compared to other implementations
* based on the standards layout & procedures.
* While it also contains both the actual base of the
* coding interval (16 bits) and the next-bits buffer,
* the cut-point between these two parts is floating
* (instead of fixed) with the bit shift counter CT.
* Thus, we also need only one (variable instead of
* fixed size) shift for the LPS/MPS decision, and
* we can do away with any renormalization update
* of C (except for new data insertion, of course).
*
* I've also introduced a new scheme for accessing
* the probability estimation state machine table,
* derived from Markus Kuhn's JBIG implementation.
*/
LOCAL(int)
arith_decode (j_decompress_ptr cinfo, unsigned char *st)
{
register arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
register unsigned char nl, nm;
register INT32 qe, temp;
register int sv, data;
/* Renormalization & data input per section D.2.6 */
while (e->a < 0x8000L) {
if (--e->ct < 0) {
/* Need to fetch next data byte */
if (cinfo->unread_marker)
data = 0; /* stuff zero data */
else {
data = get_byte(cinfo); /* read next input byte */
if (data == 0xFF) { /* zero stuff or marker code */
do data = get_byte(cinfo);
while (data == 0xFF); /* swallow extra 0xFF bytes */
if (data == 0)
data = 0xFF; /* discard stuffed zero byte */
else {
/* Note: Different from the Huffman decoder, hitting
* a marker while processing the compressed data
* segment is legal in arithmetic coding.
* The convention is to supply zero data
* then until decoding is complete.
*/
cinfo->unread_marker = data;
data = 0;
}
}
}
e->c = (e->c << 8) | data; /* insert data into C register */
if ((e->ct += 8) < 0) /* update bit shift counter */
/* Need more initial bytes */
if (++e->ct == 0)
/* Got 2 initial bytes -> re-init A and exit loop */
e->a = 0x8000L; /* => e->a = 0x10000L after loop exit */
}
e->a <<= 1;
}
/* Fetch values from our compact representation of Table D.3(D.2):
* Qe values and probability estimation state machine
*/
sv = *st;
qe = jpeg_aritab[sv & 0x7F]; /* => Qe_Value */
nl = qe & 0xFF; qe >>= 8; /* Next_Index_LPS + Switch_MPS */
nm = qe & 0xFF; qe >>= 8; /* Next_Index_MPS */
/* Decode & estimation procedures per sections D.2.4 & D.2.5 */
temp = e->a - qe;
e->a = temp;
temp <<= e->ct;
if (e->c >= temp) {
e->c -= temp;
/* Conditional LPS (less probable symbol) exchange */
if (e->a < qe) {
e->a = qe;
*st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
} else {
e->a = qe;
*st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
sv ^= 0x80; /* Exchange LPS/MPS */
}
} else if (e->a < 0x8000L) {
/* Conditional MPS (more probable symbol) exchange */
if (e->a < qe) {
*st = (sv & 0x80) ^ nl; /* Estimate_after_LPS */
sv ^= 0x80; /* Exchange LPS/MPS */
} else {
*st = (sv & 0x80) ^ nm; /* Estimate_after_MPS */
}
}
return sv >> 7;
}
/*
* Check for a restart marker & resynchronize decoder.
*/
LOCAL(void)
process_restart (j_decompress_ptr cinfo)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci;
jpeg_component_info * compptr;
/* Advance past the RSTn marker */
if (! (*cinfo->marker->read_restart_marker) (cinfo))
ERREXIT(cinfo, JERR_CANT_SUSPEND);
/* Re-initialize statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (! cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS);
/* Reset DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
if ((! cinfo->progressive_mode && cinfo->lim_Se) ||
(cinfo->progressive_mode && cinfo->Ss)) {
MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS);
}
}
/* Reset arithmetic decoding variables */
entropy->c = 0;
entropy->a = 0;
entropy->ct = -16; /* force reading 2 initial bytes to fill C */
/* Reset restart counter */
entropy->restarts_to_go = cinfo->restart_interval;
}
/*
* Arithmetic MCU decoding.
* Each of these routines decodes and returns one MCU's worth of
* arithmetic-compressed coefficients.
* The coefficients are reordered from zigzag order into natural array order,
* but are not dequantized.
*
* The i'th block of the MCU is stored into the block pointed to by
* MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
*/
/*
* MCU decoding for DC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
unsigned char *st;
int blkn, ci, tbl, sign;
int v, m;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
ci = cinfo->MCU_membership[blkn];
tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
/* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.19: Decode_DC_DIFF */
if (arith_decode(cinfo, st) == 0)
entropy->dc_context[ci] = 0;
else {
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, st + 1);
st += 2; st += sign;
/* Figure F.23: Decoding the magnitude category of v */
if ((m = arith_decode(cinfo, st)) != 0) {
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
else
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
entropy->last_dc_val[ci] += v;
}
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
(*block)[0] = (JCOEF) (entropy->last_dc_val[ci] << cinfo->Al);
}
return TRUE;
}
/*
* MCU decoding for AC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
unsigned char *st;
int tbl, sign, k;
int v, m;
const int * natural_order;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
natural_order = cinfo->natural_order;
/* There is always only one block per MCU */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
/* Figure F.20: Decode_AC_coefficients */
k = cinfo->Ss - 1;
do {
st = entropy->ac_stats[tbl] + 3 * k;
if (arith_decode(cinfo, st)) break; /* EOB flag */
for (;;) {
k++;
if (arith_decode(cinfo, st + 1)) break;
st += 3;
if (k >= cinfo->Se) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* spectral overflow */
return TRUE;
}
}
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, entropy->fixed_bin);
st += 2;
/* Figure F.23: Decoding the magnitude category of v */
if ((m = arith_decode(cinfo, st)) != 0) {
if (arith_decode(cinfo, st)) {
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
}
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
/* Scale and output coefficient in natural (dezigzagged) order */
(*block)[natural_order[k]] = (JCOEF) (v << cinfo->Al);
} while (k < cinfo->Se);
return TRUE;
}
/*
* MCU decoding for DC successive approximation refinement scan.
* Note: we assume such scans can be multi-component,
* although the spec is not very clear on the point.
*/
METHODDEF(boolean)
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
unsigned char *st;
JCOEF p1;
int blkn;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
st = entropy->fixed_bin; /* use fixed probability estimation */
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
/* Encoded data is simply the next bit of the two's-complement DC value */
if (arith_decode(cinfo, st))
MCU_data[blkn][0][0] |= p1;
}
return TRUE;
}
/*
* MCU decoding for AC successive approximation refinement scan.
*/
METHODDEF(boolean)
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
JBLOCKROW block;
JCOEFPTR thiscoef;
unsigned char *st;
int tbl, k, kex;
JCOEF p1, m1;
const int * natural_order;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
natural_order = cinfo->natural_order;
/* There is always only one block per MCU */
block = MCU_data[0];
tbl = cinfo->cur_comp_info[0]->ac_tbl_no;
p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
m1 = -p1; /* -1 in the bit position being coded */
/* Establish EOBx (previous stage end-of-block) index */
kex = cinfo->Se;
do {
if ((*block)[natural_order[kex]]) break;
} while (--kex);
k = cinfo->Ss - 1;
do {
st = entropy->ac_stats[tbl] + 3 * k;
if (k >= kex)
if (arith_decode(cinfo, st)) break; /* EOB flag */
for (;;) {
thiscoef = *block + natural_order[++k];
if (*thiscoef) { /* previously nonzero coef */
if (arith_decode(cinfo, st + 2)) {
if (*thiscoef < 0)
*thiscoef += m1;
else
*thiscoef += p1;
}
break;
}
if (arith_decode(cinfo, st + 1)) { /* newly nonzero coef */
if (arith_decode(cinfo, entropy->fixed_bin))
*thiscoef = m1;
else
*thiscoef = p1;
break;
}
st += 3;
if (k >= cinfo->Se) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* spectral overflow */
return TRUE;
}
}
} while (k < cinfo->Se);
return TRUE;
}
/*
* Decode one MCU's worth of arithmetic-compressed coefficients.
*/
METHODDEF(boolean)
decode_mcu (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
jpeg_component_info * compptr;
JBLOCKROW block;
unsigned char *st;
int blkn, ci, tbl, sign, k;
int v, m;
const int * natural_order;
/* Process restart marker if needed */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
process_restart(cinfo);
entropy->restarts_to_go--;
}
if (entropy->ct == -1) return TRUE; /* if error do nothing */
natural_order = cinfo->natural_order;
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
ci = cinfo->MCU_membership[blkn];
compptr = cinfo->cur_comp_info[ci];
/* Sections F.2.4.1 & F.1.4.4.1: Decoding of DC coefficients */
tbl = compptr->dc_tbl_no;
/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
st = entropy->dc_stats[tbl] + entropy->dc_context[ci];
/* Figure F.19: Decode_DC_DIFF */
if (arith_decode(cinfo, st) == 0)
entropy->dc_context[ci] = 0;
else {
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, st + 1);
st += 2; st += sign;
/* Figure F.23: Decoding the magnitude category of v */
if ((m = arith_decode(cinfo, st)) != 0) {
st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
if (m < (int) ((1L << cinfo->arith_dc_L[tbl]) >> 1))
entropy->dc_context[ci] = 0; /* zero diff category */
else if (m > (int) ((1L << cinfo->arith_dc_U[tbl]) >> 1))
entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */
else
entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
entropy->last_dc_val[ci] += v;
}
(*block)[0] = (JCOEF) entropy->last_dc_val[ci];
/* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
if (cinfo->lim_Se == 0) continue;
tbl = compptr->ac_tbl_no;
k = 0;
/* Figure F.20: Decode_AC_coefficients */
do {
st = entropy->ac_stats[tbl] + 3 * k;
if (arith_decode(cinfo, st)) break; /* EOB flag */
for (;;) {
k++;
if (arith_decode(cinfo, st + 1)) break;
st += 3;
if (k >= cinfo->lim_Se) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* spectral overflow */
return TRUE;
}
}
/* Figure F.21: Decoding nonzero value v */
/* Figure F.22: Decoding the sign of v */
sign = arith_decode(cinfo, entropy->fixed_bin);
st += 2;
/* Figure F.23: Decoding the magnitude category of v */
if ((m = arith_decode(cinfo, st)) != 0) {
if (arith_decode(cinfo, st)) {
m <<= 1;
st = entropy->ac_stats[tbl] +
(k <= cinfo->arith_ac_K[tbl] ? 189 : 217);
while (arith_decode(cinfo, st)) {
if ((m <<= 1) == (int) 0x8000U) {
WARNMS(cinfo, JWRN_ARITH_BAD_CODE);
entropy->ct = -1; /* magnitude overflow */
return TRUE;
}
st += 1;
}
}
}
v = m;
/* Figure F.24: Decoding the magnitude bit pattern of v */
st += 14;
while (m >>= 1)
if (arith_decode(cinfo, st)) v |= m;
v += 1; if (sign) v = -v;
(*block)[natural_order[k]] = (JCOEF) v;
} while (k < cinfo->lim_Se);
}
return TRUE;
}
/*
* Initialize for an arithmetic-compressed scan.
*/
METHODDEF(void)
start_pass (j_decompress_ptr cinfo)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci, tbl;
jpeg_component_info * compptr;
if (cinfo->progressive_mode) {
/* Validate progressive scan parameters */
if (cinfo->Ss == 0) {
if (cinfo->Se != 0)
goto bad;
} else {
/* need not check Ss/Se < 0 since they came from unsigned bytes */
if (cinfo->Se < cinfo->Ss || cinfo->Se > cinfo->lim_Se)
goto bad;
/* AC scans may have only one component */
if (cinfo->comps_in_scan != 1)
goto bad;
}
if (cinfo->Ah != 0) {
/* Successive approximation refinement scan: must have Al = Ah-1. */
if (cinfo->Ah-1 != cinfo->Al)
goto bad;
}
if (cinfo->Al > 13) { /* need not check for < 0 */
bad:
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
}
/* Update progression status, and verify that scan order is legal.
* Note that inter-scan inconsistencies are treated as warnings
* not fatal errors ... not clear if this is right way to behave.
*/
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
if (cinfo->Ah != expected)
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
coef_bit_ptr[coefi] = cinfo->Al;
}
}
/* Select MCU decoding routine */
if (cinfo->Ah == 0) {
if (cinfo->Ss == 0)
entropy->pub.decode_mcu = decode_mcu_DC_first;
else
entropy->pub.decode_mcu = decode_mcu_AC_first;
} else {
if (cinfo->Ss == 0)
entropy->pub.decode_mcu = decode_mcu_DC_refine;
else
entropy->pub.decode_mcu = decode_mcu_AC_refine;
}
} else {
/* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
* This ought to be an error condition, but we make it a warning.
*/
if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 ||
(cinfo->Se < DCTSIZE2 && cinfo->Se != cinfo->lim_Se))
WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
/* Select MCU decoding routine */
entropy->pub.decode_mcu = decode_mcu;
}
/* Allocate & initialize requested statistics areas */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (! cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
tbl = compptr->dc_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->dc_stats[tbl] == NULL)
entropy->dc_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, DC_STAT_BINS);
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS);
/* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0;
}
if ((! cinfo->progressive_mode && cinfo->lim_Se) ||
(cinfo->progressive_mode && cinfo->Ss)) {
tbl = compptr->ac_tbl_no;
if (tbl < 0 || tbl >= NUM_ARITH_TBLS)
ERREXIT1(cinfo, JERR_NO_ARITH_TABLE, tbl);
if (entropy->ac_stats[tbl] == NULL)
entropy->ac_stats[tbl] = (unsigned char *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS);
}
}
/* Initialize arithmetic decoding variables */
entropy->c = 0;
entropy->a = 0;
entropy->ct = -16; /* force reading 2 initial bytes to fill C */
/* Initialize restart counter */
entropy->restarts_to_go = cinfo->restart_interval;
}
/*
* Finish up at the end of an arithmetic-compressed scan.
*/
METHODDEF(void)
finish_pass (j_decompress_ptr cinfo)
{
/* no work necessary here */
}
/*
* Module initialization routine for arithmetic entropy decoding.
*/
GLOBAL(void)
jinit_arith_decoder (j_decompress_ptr cinfo)
{
arith_entropy_ptr entropy;
int i;
entropy = (arith_entropy_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(arith_entropy_decoder));
cinfo->entropy = &entropy->pub;
entropy->pub.start_pass = start_pass;
entropy->pub.finish_pass = finish_pass;
/* Mark tables unallocated */
for (i = 0; i < NUM_ARITH_TBLS; i++) {
entropy->dc_stats[i] = NULL;
entropy->ac_stats[i] = NULL;
}
/* Initialize index for fixed probability estimation */
entropy->fixed_bin[0] = 113;
if (cinfo->progressive_mode) {
/* Create progression status table */
int *coef_bit_ptr, ci;
cinfo->coef_bits = (int (*)[DCTSIZE2]) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * DCTSIZE2 * SIZEOF(int));
coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)
*coef_bit_ptr++ = -1;
}
}

View file

@ -0,0 +1,263 @@
/*
* jdatadst.c
*
* Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains compression data destination routines for the case of
* emitting JPEG data to memory or to a file (or any stdio stream).
* While these routines are sufficient for most applications,
* some will want to use a different destination manager.
* IMPORTANT: we assume that fwrite() will correctly transcribe an array of
* JOCTETs into 8-bit-wide elements on external storage. If char is wider
* than 8 bits on your machine, you may need to do some tweaking.
*/
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */
#include "jinclude.h"
#include "jpeglib.h"
#include "jerror.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
extern void * malloc JPP((size_t size));
extern void free JPP((void *ptr));
#endif
/* Expanded data destination object for stdio output */
#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
FILE * outfile; /* target stream */
JOCTET buffer[OUTPUT_BUF_SIZE]; /* output buffer */
} my_destination_mgr;
typedef my_destination_mgr * my_dest_ptr;
/* Expanded data destination object for memory output */
typedef struct {
struct jpeg_destination_mgr pub; /* public fields */
unsigned char ** outbuffer; /* target buffer */
size_t * outsize;
unsigned char * newbuffer; /* newly allocated buffer */
JOCTET * buffer; /* start of buffer */
size_t bufsize;
} my_mem_destination_mgr;
typedef my_mem_destination_mgr * my_mem_dest_ptr;
/*
* Initialize destination --- called by jpeg_start_compress
* before any data is actually written.
*/
METHODDEF(void)
init_destination (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
}
METHODDEF(void)
init_mem_destination (j_compress_ptr cinfo)
{
/* no work necessary here */
}
/*
* Empty the output buffer --- called whenever buffer fills up.
*
* In typical applications, this should write the entire output buffer
* (ignoring the current state of next_output_byte & free_in_buffer),
* reset the pointer & count to the start of the buffer, and return TRUE
* indicating that the buffer has been dumped.
*
* In applications that need to be able to suspend compression due to output
* overrun, a FALSE return indicates that the buffer cannot be emptied now.
* In this situation, the compressor will return to its caller (possibly with
* an indication that it has not accepted all the supplied scanlines). The
* application should resume compression after it has made more room in the
* output buffer. Note that there are substantial restrictions on the use of
* suspension --- see the documentation.
*
* When suspending, the compressor will back up to a convenient restart point
* (typically the start of the current MCU). next_output_byte & free_in_buffer
* indicate where the restart point will be if the current call returns FALSE.
* Data beyond this point will be regenerated after resumption, so do not
* write it out when emptying the buffer externally.
*/
METHODDEF(boolean)
empty_output_buffer (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
(size_t) OUTPUT_BUF_SIZE)
ERREXIT(cinfo, JERR_FILE_WRITE);
dest->pub.next_output_byte = dest->buffer;
dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
return TRUE;
}
METHODDEF(boolean)
empty_mem_output_buffer (j_compress_ptr cinfo)
{
size_t nextsize;
JOCTET * nextbuffer;
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
/* Try to allocate new buffer with double size */
nextsize = dest->bufsize * 2;
nextbuffer = (JOCTET *) malloc(nextsize);
if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 11);
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize);
if (dest->newbuffer != NULL)
free(dest->newbuffer);
dest->newbuffer = nextbuffer;
dest->pub.next_output_byte = nextbuffer + dest->bufsize;
dest->pub.free_in_buffer = dest->bufsize;
dest->buffer = nextbuffer;
dest->bufsize = nextsize;
return TRUE;
}
/*
* Terminate destination --- called by jpeg_finish_compress
* after all data has been written. Usually needs to flush buffer.
*
* NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
* application must deal with any cleanup that should happen even
* for error exit.
*/
METHODDEF(void)
term_destination (j_compress_ptr cinfo)
{
my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
/* Write any data remaining in the buffer */
if (datacount > 0) {
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
ERREXIT(cinfo, JERR_FILE_WRITE);
}
JFFLUSH(dest->outfile);
/* Make sure we wrote the output file OK */
if (JFERROR(dest->outfile))
ERREXIT(cinfo, JERR_FILE_WRITE);
}
METHODDEF(void)
term_mem_destination (j_compress_ptr cinfo)
{
my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
*dest->outbuffer = dest->buffer;
*dest->outsize = dest->bufsize - dest->pub.free_in_buffer;
}
/*
* Prepare for output to a stdio stream.
* The caller must have already opened the stream,
* and is responsible for closing it after finishing compression.
*/
GLOBAL(void)
jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
{
my_dest_ptr dest;
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same file without re-executing jpeg_stdio_dest.
* This makes it dangerous to use this manager and a different destination
* manager serially with the same JPEG object, because their private object
* sizes may be different. Caveat programmer.
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_destination_mgr));
}
dest = (my_dest_ptr) cinfo->dest;
dest->pub.init_destination = init_destination;
dest->pub.empty_output_buffer = empty_output_buffer;
dest->pub.term_destination = term_destination;
dest->outfile = outfile;
}
/*
* Prepare for output to a memory buffer.
* The caller may supply an own initial buffer with appropriate size.
* Otherwise, or when the actual data output exceeds the given size,
* the library adapts the buffer size as necessary.
* The standard library functions malloc/free are used for allocating
* larger memory, so the buffer is available to the application after
* finishing compression, and then the application is responsible for
* freeing the requested memory.
* Note: An initial buffer supplied by the caller is expected to be
* managed by the application. The library does not free such buffer
* when allocating a larger buffer.
*/
GLOBAL(void)
jpeg_mem_dest (j_compress_ptr cinfo,
unsigned char ** outbuffer, size_t * outsize)
{
my_mem_dest_ptr dest;
if (outbuffer == NULL || outsize == NULL) /* sanity check */
ERREXIT(cinfo, JERR_BUFFER_SIZE);
/* The destination object is made permanent so that multiple JPEG images
* can be written to the same buffer without re-executing jpeg_mem_dest.
*/
if (cinfo->dest == NULL) { /* first time for this JPEG object? */
cinfo->dest = (struct jpeg_destination_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_mem_destination_mgr));
}
dest = (my_mem_dest_ptr) cinfo->dest;
dest->pub.init_destination = init_mem_destination;
dest->pub.empty_output_buffer = empty_mem_output_buffer;
dest->pub.term_destination = term_mem_destination;
dest->outbuffer = outbuffer;
dest->outsize = outsize;
dest->newbuffer = NULL;
if (*outbuffer == NULL || *outsize == 0) {
/* Allocate initial buffer */
dest->newbuffer = *outbuffer = (unsigned char *) malloc(OUTPUT_BUF_SIZE);
if (dest->newbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
*outsize = OUTPUT_BUF_SIZE;
}
dest->pub.next_output_byte = dest->buffer = *outbuffer;
dest->pub.free_in_buffer = dest->bufsize = *outsize;
}

View file

@ -2,13 +2,14 @@
* jdatasrc.c * jdatasrc.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains decompression data source routines for the case of * This file contains decompression data source routines for the case of
* reading JPEG data from a file (or any stdio stream). While these routines * reading JPEG data from memory or from a file (or any stdio stream).
* are sufficient for most applications, some will want to use a different * While these routines are sufficient for most applications,
* source manager. * some will want to use a different source manager.
* IMPORTANT: we assume that fread() will correctly transcribe an array of * IMPORTANT: we assume that fread() will correctly transcribe an array of
* JOCTETs from 8-bit-wide elements on external storage. If char is wider * JOCTETs from 8-bit-wide elements on external storage. If char is wider
* than 8 bits on your machine, you may need to do some tweaking. * than 8 bits on your machine, you may need to do some tweaking.
@ -22,18 +23,18 @@
/* Expanded data source object for stdio input */ /* Expanded data source object for stdio input */
#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
typedef struct { typedef struct {
struct jpeg_source_mgr pub; /* public fields */ struct jpeg_source_mgr pub; /* public fields */
FILE * infile; /* source stream */ FILE * infile; /* source stream */
JOCTET * buffer; /* start of buffer */ JOCTET buffer[INPUT_BUF_SIZE]; /* input buffer */
boolean start_of_file; /* have we gotten any data yet? */ boolean start_of_file; /* have we gotten any data yet? */
} my_source_mgr; } my_source_mgr;
typedef my_source_mgr * my_src_ptr; typedef my_source_mgr * my_src_ptr;
#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
/* /*
* Initialize source --- called by jpeg_read_header * Initialize source --- called by jpeg_read_header
@ -52,6 +53,12 @@ init_source (j_decompress_ptr cinfo)
src->start_of_file = TRUE; src->start_of_file = TRUE;
} }
METHODDEF(void)
init_mem_source (j_decompress_ptr cinfo)
{
/* no work necessary here */
}
/* /*
* Fill the input buffer --- called whenever buffer is emptied. * Fill the input buffer --- called whenever buffer is emptied.
@ -111,6 +118,27 @@ fill_input_buffer (j_decompress_ptr cinfo)
return TRUE; return TRUE;
} }
METHODDEF(boolean)
fill_mem_input_buffer (j_decompress_ptr cinfo)
{
static const JOCTET mybuffer[4] = {
(JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0
};
/* The whole JPEG data is expected to reside in the supplied memory
* buffer, so any request for more data beyond the given buffer size
* is treated as an error.
*/
WARNMS(cinfo, JWRN_JPEG_EOF);
/* Insert a fake EOI marker */
cinfo->src->next_input_byte = mybuffer;
cinfo->src->bytes_in_buffer = 2;
return TRUE;
}
/* /*
* Skip data --- used to skip over a potentially large amount of * Skip data --- used to skip over a potentially large amount of
@ -127,22 +155,24 @@ fill_input_buffer (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
skip_input_data (j_decompress_ptr cinfo, long num_bytes) skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{ {
my_src_ptr src = (my_src_ptr) cinfo->src; struct jpeg_source_mgr * src = cinfo->src;
size_t nbytes;
/* Just a dumb implementation for now. Could use fseek() except /* Just a dumb implementation for now. Could use fseek() except
* it doesn't work on pipes. Not clear that being smart is worth * it doesn't work on pipes. Not clear that being smart is worth
* any trouble anyway --- large skips are infrequent. * any trouble anyway --- large skips are infrequent.
*/ */
if (num_bytes > 0) { if (num_bytes > 0) {
while (num_bytes > (long) src->pub.bytes_in_buffer) { nbytes = (size_t) num_bytes;
num_bytes -= (long) src->pub.bytes_in_buffer; while (nbytes > src->bytes_in_buffer) {
(void) fill_input_buffer(cinfo); nbytes -= src->bytes_in_buffer;
(void) (*src->fill_input_buffer) (cinfo);
/* note we assume that fill_input_buffer will never return FALSE, /* note we assume that fill_input_buffer will never return FALSE,
* so suspension need not be handled. * so suspension need not be handled.
*/ */
} }
src->pub.next_input_byte += (size_t) num_bytes; src->next_input_byte += nbytes;
src->pub.bytes_in_buffer -= (size_t) num_bytes; src->bytes_in_buffer -= nbytes;
} }
} }
@ -166,7 +196,7 @@ skip_input_data (j_decompress_ptr cinfo, long num_bytes)
*/ */
METHODDEF(void) METHODDEF(void)
term_source (j_decompress_ptr) term_source (j_decompress_ptr cinfo)
{ {
/* no work necessary here */ /* no work necessary here */
} }
@ -174,8 +204,8 @@ term_source (j_decompress_ptr)
/* /*
* Prepare for input from a stdio stream. * Prepare for input from a stdio stream.
* The caller must have already opened the stream, and is responsible * The caller must have already opened the stream,
* for closing it after finishing decompression. * and is responsible for closing it after finishing decompression.
*/ */
GLOBAL(void) GLOBAL(void)
@ -183,21 +213,16 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
{ {
my_src_ptr src; my_src_ptr src;
/* The source object and input buffer are made permanent so that a series /* The source object including the input buffer is made permanent so that
* of JPEG images can be read from the same file by calling jpeg_stdio_src * a series of JPEG images can be read from the same file by calling
* only before the first one. (If we discarded the buffer at the end of * jpeg_stdio_src only before the first one. (If we discarded the buffer
* one image, we'd likely lose the start of the next one.) * at the end of one image, we'd likely lose the start of the next one.)
* This makes it unsafe to use this manager and a different source * This makes it unsafe to use this manager and a different source
* manager serially with the same JPEG object. Caveat programmer. * manager serially with the same JPEG object. Caveat programmer.
*/ */
if (cinfo->src == NULL) { /* first time for this JPEG object? */ if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *) cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_source_mgr));
SIZEOF(my_source_mgr));
src = (my_src_ptr) cinfo->src;
src->buffer = (JOCTET *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
INPUT_BUF_SIZE * SIZEOF(JOCTET));
} }
src = (my_src_ptr) cinfo->src; src = (my_src_ptr) cinfo->src;
@ -210,3 +235,37 @@ jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
src->pub.next_input_byte = NULL; /* until buffer loaded */ src->pub.next_input_byte = NULL; /* until buffer loaded */
} }
/*
* Prepare for input from a supplied memory buffer.
* The buffer must contain the whole JPEG data.
*/
GLOBAL(void)
jpeg_mem_src (j_decompress_ptr cinfo,
const unsigned char * inbuffer, size_t insize)
{
struct jpeg_source_mgr * src;
if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */
ERREXIT(cinfo, JERR_INPUT_EMPTY);
/* The source object is made permanent so that a series of JPEG images
* can be read from the same buffer by calling jpeg_mem_src only before
* the first one.
*/
if (cinfo->src == NULL) { /* first time for this JPEG object? */
cinfo->src = (struct jpeg_source_mgr *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(struct jpeg_source_mgr));
}
src = cinfo->src;
src->init_source = init_mem_source;
src->fill_input_buffer = fill_mem_input_buffer;
src->skip_input_data = skip_input_data;
src->resync_to_restart = jpeg_resync_to_restart; /* use default method */
src->term_source = term_source;
src->bytes_in_buffer = insize;
src->next_input_byte = (const JOCTET *) inbuffer;
}

View file

@ -2,6 +2,7 @@
* jdcoefct.c * jdcoefct.c
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 2002-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -18,11 +19,13 @@
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
/* Block smoothing is only applicable for progressive JPEG, so: */ /* Block smoothing is only applicable for progressive JPEG, so: */
#ifndef D_PROGRESSIVE_SUPPORTED #ifndef D_PROGRESSIVE_SUPPORTED
#undef BLOCK_SMOOTHING_SUPPORTED #undef BLOCK_SMOOTHING_SUPPORTED
#endif #endif
/* Private buffer controller object */ /* Private buffer controller object */
typedef struct { typedef struct {
@ -37,11 +40,8 @@ typedef struct {
/* The output side's location is represented by cinfo->output_iMCU_row. */ /* The output side's location is represented by cinfo->output_iMCU_row. */
/* In single-pass modes, it's sufficient to buffer just one MCU. /* In single-pass modes, it's sufficient to buffer just one MCU.
* We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, * We append a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
* and let the entropy decoder write into that workspace each time. * and let the entropy decoder write into that workspace each time.
* (On 80x86, the workspace is FAR even though it's not really very big;
* this is to keep the module interfaces unchanged when a large coefficient
* buffer is necessary.)
* In multi-pass modes, this array points to the current MCU's blocks * In multi-pass modes, this array points to the current MCU's blocks
* within the virtual arrays; it is used only by the input side. * within the virtual arrays; it is used only by the input side.
*/ */
@ -57,9 +57,13 @@ typedef struct {
int * coef_bits_latch; int * coef_bits_latch;
#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ #define SAVED_COEFS 6 /* we save coef_bits[0..5] */
#endif #endif
} my_coef_controller3;
typedef my_coef_controller3 * my_coef_ptr3; /* Workspace for single-pass modes (omitted otherwise). */
JBLOCK blk_buffer[D_MAX_BLOCKS_IN_MCU];
} my_coef_controller;
typedef my_coef_controller * my_coef_ptr;
/* Forward declarations */ /* Forward declarations */
METHODDEF(int) decompress_onepass METHODDEF(int) decompress_onepass
@ -76,10 +80,10 @@ METHODDEF(int) decompress_smooth_data
LOCAL(void) LOCAL(void)
start_iMCU_row3 (j_decompress_ptr cinfo) start_iMCU_row (j_decompress_ptr cinfo)
/* Reset within-iMCU-row counters for a new row (input side) */ /* Reset within-iMCU-row counters for a new row (input side) */
{ {
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
/* In an interleaved scan, an MCU row is the same as an iMCU row. /* In an interleaved scan, an MCU row is the same as an iMCU row.
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
@ -107,7 +111,7 @@ METHODDEF(void)
start_input_pass (j_decompress_ptr cinfo) start_input_pass (j_decompress_ptr cinfo)
{ {
cinfo->input_iMCU_row = 0; cinfo->input_iMCU_row = 0;
start_iMCU_row3(cinfo); start_iMCU_row(cinfo);
} }
@ -119,7 +123,7 @@ METHODDEF(void)
start_output_pass (j_decompress_ptr cinfo) start_output_pass (j_decompress_ptr cinfo)
{ {
#ifdef BLOCK_SMOOTHING_SUPPORTED #ifdef BLOCK_SMOOTHING_SUPPORTED
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
/* If multipass, check to see whether to use block smoothing on this pass */ /* If multipass, check to see whether to use block smoothing on this pass */
if (coef->pub.coef_arrays != NULL) { if (coef->pub.coef_arrays != NULL) {
@ -146,11 +150,12 @@ start_output_pass (j_decompress_ptr cinfo)
METHODDEF(int) METHODDEF(int)
decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
{ {
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION MCU_col_num; /* index of current MCU within row */
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
int blkn, ci, xindex, yindex, yoffset, useful_width; int ci, xindex, yindex, yoffset, useful_width;
JBLOCKROW blkp;
JSAMPARRAY output_ptr; JSAMPARRAY output_ptr;
JDIMENSION start_col, output_col; JDIMENSION start_col, output_col;
jpeg_component_info *compptr; jpeg_component_info *compptr;
@ -161,9 +166,10 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
yoffset++) { yoffset++) {
for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
MCU_col_num++) { MCU_col_num++) {
blkp = coef->blk_buffer; /* pointer to current DCT block within MCU */
/* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
jzero_far((void FAR *) coef->MCU_buffer[0], if (cinfo->lim_Se) /* can bypass in DC only case */
(size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); MEMZERO(blkp, cinfo->blocks_in_MCU * SIZEOF(JBLOCK));
if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
/* Suspension forced; update state counters and exit */ /* Suspension forced; update state counters and exit */
coef->MCU_vert_offset = yoffset; coef->MCU_vert_offset = yoffset;
@ -171,37 +177,34 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
} }
/* Determine where data should go in output_buf and do the IDCT thing. /* Determine where data should go in output_buf and do the IDCT thing.
* We skip dummy blocks at the right and bottom edges (but blkn gets * We skip dummy blocks at the right and bottom edges (but blkp gets
* incremented past them!). Note the inner loop relies on having * incremented past them!).
* allocated the MCU_buffer[] blocks sequentially.
*/ */
blkn = 0; /* index of current DCT block within MCU */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
/* Don't bother to IDCT an uninteresting component. */ /* Don't bother to IDCT an uninteresting component. */
if (! compptr->component_needed) { if (! compptr->component_needed) {
blkn += compptr->MCU_blocks; blkp += compptr->MCU_blocks;
continue; continue;
} }
inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
output_ptr = output_buf[compptr->component_index] +
yoffset * compptr->DCT_v_scaled_size;
useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
: compptr->last_col_width; : compptr->last_col_width;
output_ptr = output_buf[compptr->component_index] +
yoffset * compptr->DCT_scaled_size;
start_col = MCU_col_num * compptr->MCU_sample_width; start_col = MCU_col_num * compptr->MCU_sample_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) { for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
if (cinfo->input_iMCU_row < last_iMCU_row || if (cinfo->input_iMCU_row < last_iMCU_row ||
yoffset+yindex < compptr->last_row_height) { yoffset + yindex < compptr->last_row_height) {
output_col = start_col; output_col = start_col;
for (xindex = 0; xindex < useful_width; xindex++) { for (xindex = 0; xindex < useful_width; xindex++) {
(*inverse_DCT) (cinfo, compptr, (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) (blkp + xindex),
(JCOEFPTR) coef->MCU_buffer[blkn+xindex],
output_ptr, output_col); output_ptr, output_col);
output_col += compptr->DCT_scaled_size; output_col += compptr->DCT_h_scaled_size;
} }
output_ptr += compptr->DCT_v_scaled_size;
} }
blkn += compptr->MCU_width; blkp += compptr->MCU_width;
output_ptr += compptr->DCT_scaled_size;
} }
} }
} }
@ -210,8 +213,8 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
} }
/* Completed the iMCU row, advance counters for next one */ /* Completed the iMCU row, advance counters for next one */
cinfo->output_iMCU_row++; cinfo->output_iMCU_row++;
if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { if (++(cinfo->input_iMCU_row) <= last_iMCU_row) {
start_iMCU_row3(cinfo); start_iMCU_row(cinfo);
return JPEG_ROW_COMPLETED; return JPEG_ROW_COMPLETED;
} }
/* Completed the scan */ /* Completed the scan */
@ -225,7 +228,7 @@ decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
*/ */
METHODDEF(int) METHODDEF(int)
dummy_consume_data (j_decompress_ptr) dummy_consume_data (j_decompress_ptr cinfo)
{ {
return JPEG_SUSPENDED; /* Always indicate nothing was done */ return JPEG_SUSPENDED; /* Always indicate nothing was done */
} }
@ -243,10 +246,11 @@ dummy_consume_data (j_decompress_ptr)
METHODDEF(int) METHODDEF(int)
consume_data (j_decompress_ptr cinfo) consume_data (j_decompress_ptr cinfo)
{ {
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION MCU_col_num; /* index of current MCU within row */
int blkn, ci, xindex, yindex, yoffset; int ci, xindex, yindex, yoffset;
JDIMENSION start_col; JDIMENSION start_col;
JBLOCKARRAY blkp;
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
JBLOCKROW buffer_ptr; JBLOCKROW buffer_ptr;
jpeg_component_info *compptr; jpeg_component_info *compptr;
@ -270,15 +274,16 @@ consume_data (j_decompress_ptr cinfo)
for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
MCU_col_num++) { MCU_col_num++) {
/* Construct list of pointers to DCT blocks belonging to this MCU */ /* Construct list of pointers to DCT blocks belonging to this MCU */
blkn = 0; /* index of current DCT block within MCU */ blkp = coef->MCU_buffer; /* pointer to current DCT block within MCU */
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
start_col = MCU_col_num * compptr->MCU_width; start_col = MCU_col_num * compptr->MCU_width;
for (yindex = 0; yindex < compptr->MCU_height; yindex++) { for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
buffer_ptr = buffer[ci][yindex+yoffset] + start_col; buffer_ptr = buffer[ci][yoffset + yindex] + start_col;
for (xindex = 0; xindex < compptr->MCU_width; xindex++) { xindex = compptr->MCU_width;
coef->MCU_buffer[blkn++] = buffer_ptr++; do {
} *blkp++ = buffer_ptr++;
} while (--xindex);
} }
} }
/* Try to fetch the MCU. */ /* Try to fetch the MCU. */
@ -294,7 +299,7 @@ consume_data (j_decompress_ptr cinfo)
} }
/* Completed the iMCU row, advance counters for next one */ /* Completed the iMCU row, advance counters for next one */
if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
start_iMCU_row3(cinfo); start_iMCU_row(cinfo);
return JPEG_ROW_COMPLETED; return JPEG_ROW_COMPLETED;
} }
/* Completed the scan */ /* Completed the scan */
@ -314,7 +319,7 @@ consume_data (j_decompress_ptr cinfo)
METHODDEF(int) METHODDEF(int)
decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
{ {
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
JDIMENSION block_num; JDIMENSION block_num;
int ci, block_row, block_rows; int ci, block_row, block_rows;
@ -362,13 +367,13 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
(*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
output_ptr, output_col); output_ptr, output_col);
buffer_ptr++; buffer_ptr++;
output_col += compptr->DCT_scaled_size; output_col += compptr->DCT_h_scaled_size;
} }
output_ptr += compptr->DCT_scaled_size; output_ptr += compptr->DCT_v_scaled_size;
} }
} }
if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) if (++(cinfo->output_iMCU_row) <= last_iMCU_row)
return JPEG_ROW_COMPLETED; return JPEG_ROW_COMPLETED;
return JPEG_SCAN_COMPLETED; return JPEG_SCAN_COMPLETED;
} }
@ -404,7 +409,7 @@ decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
LOCAL(boolean) LOCAL(boolean)
smoothing_ok (j_decompress_ptr cinfo) smoothing_ok (j_decompress_ptr cinfo)
{ {
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
boolean smoothing_useful = FALSE; boolean smoothing_useful = FALSE;
int ci, coefi; int ci, coefi;
jpeg_component_info *compptr; jpeg_component_info *compptr;
@ -417,10 +422,9 @@ smoothing_ok (j_decompress_ptr cinfo)
/* Allocate latch area if not already done */ /* Allocate latch area if not already done */
if (coef->coef_bits_latch == NULL) if (coef->coef_bits_latch == NULL)
coef->coef_bits_latch = (int *) coef->coef_bits_latch = (int *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * cinfo->num_components * (SAVED_COEFS * SIZEOF(int)));
(SAVED_COEFS * SIZEOF(int)));
coef_bits_latch = coef->coef_bits_latch; coef_bits_latch = coef->coef_bits_latch;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
@ -460,7 +464,7 @@ smoothing_ok (j_decompress_ptr cinfo)
METHODDEF(int) METHODDEF(int)
decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
{ {
my_coef_ptr3 coef = (my_coef_ptr3) cinfo->coef; my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
JDIMENSION block_num, last_block_column; JDIMENSION block_num, last_block_column;
int ci, block_row, block_rows, access_rows; int ci, block_row, block_rows, access_rows;
@ -654,13 +658,13 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
DC4 = DC5; DC5 = DC6; DC4 = DC5; DC5 = DC6;
DC7 = DC8; DC8 = DC9; DC7 = DC8; DC8 = DC9;
buffer_ptr++, prev_block_row++, next_block_row++; buffer_ptr++, prev_block_row++, next_block_row++;
output_col += compptr->DCT_scaled_size; output_col += compptr->DCT_h_scaled_size;
} }
output_ptr += compptr->DCT_scaled_size; output_ptr += compptr->DCT_v_scaled_size;
} }
} }
if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) if (++(cinfo->output_iMCU_row) <= last_iMCU_row)
return JPEG_ROW_COMPLETED; return JPEG_ROW_COMPLETED;
return JPEG_SCAN_COMPLETED; return JPEG_SCAN_COMPLETED;
} }
@ -675,19 +679,8 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
GLOBAL(void) GLOBAL(void)
jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
{ {
my_coef_ptr3 coef; my_coef_ptr coef;
coef = (my_coef_ptr3)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller3));
cinfo->coef = (struct jpeg_d_coef_controller *) coef;
coef->pub.start_input_pass = start_input_pass;
coef->pub.start_output_pass = start_output_pass;
#ifdef BLOCK_SMOOTHING_SUPPORTED
coef->coef_bits_latch = NULL;
#endif
/* Create the coefficient buffer. */
if (need_full_buffer) { if (need_full_buffer) {
#ifdef D_MULTISCAN_FILES_SUPPORTED #ifdef D_MULTISCAN_FILES_SUPPORTED
/* Allocate a full-image virtual array for each component, */ /* Allocate a full-image virtual array for each component, */
@ -696,6 +689,9 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
int ci, access_rows; int ci, access_rows;
jpeg_component_info *compptr; jpeg_component_info *compptr;
coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_coef_controller) - SIZEOF(coef->blk_buffer));
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
access_rows = compptr->v_samp_factor; access_rows = compptr->v_samp_factor;
@ -720,17 +716,29 @@ jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
#endif #endif
} else { } else {
/* We only need a single-MCU buffer. */ /* We only need a single-MCU buffer. */
JBLOCKROW buffer; JBLOCKARRAY blkp;
int i; JBLOCKROW buffer_ptr;
int bi;
buffer = (JBLOCKROW) coef = (my_coef_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_coef_controller));
D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); buffer_ptr = coef->blk_buffer;
for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { if (cinfo->lim_Se == 0) /* DC only case: want to bypass later */
coef->MCU_buffer[i] = buffer + i; MEMZERO(buffer_ptr, SIZEOF(coef->blk_buffer));
} blkp = coef->MCU_buffer;
bi = D_MAX_BLOCKS_IN_MCU;
do {
*blkp++ = buffer_ptr++;
} while (--bi);
coef->pub.consume_data = dummy_consume_data; coef->pub.consume_data = dummy_consume_data;
coef->pub.decompress_data = decompress_onepass; coef->pub.decompress_data = decompress_onepass;
coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
} }
coef->pub.start_input_pass = start_input_pass;
coef->pub.start_output_pass = start_output_pass;
#ifdef BLOCK_SMOOTHING_SUPPORTED
coef->coef_bits_latch = NULL;
#endif
cinfo->coef = &coef->pub;
} }

View file

@ -2,6 +2,7 @@
* jdcolor.c * jdcolor.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2011-2023 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -13,32 +14,70 @@
#include "jpeglib.h" #include "jpeglib.h"
#if RANGE_BITS < 2
/* Deliberate syntax err */
Sorry, this code requires 2 or more range extension bits.
#endif
/* Private subobject */ /* Private subobject */
typedef struct { typedef struct {
struct jpeg_color_deconverter pub; /* public fields */ struct jpeg_color_deconverter pub; /* public fields */
/* Private state for YCC->RGB conversion */ /* Private state for YCbCr->RGB and BG_YCC->RGB conversion */
int * Cr_r_tab; /* => table for Cr to R conversion */ int * Cr_r_tab; /* => table for Cr to R conversion */
int * Cb_b_tab; /* => table for Cb to B conversion */ int * Cb_b_tab; /* => table for Cb to B conversion */
INT32 * Cr_g_tab; /* => table for Cr to G conversion */ INT32 * Cr_g_tab; /* => table for Cr to G conversion */
INT32 * Cb_g_tab; /* => table for Cb to G conversion */ INT32 * Cb_g_tab; /* => table for Cb to G conversion */
} my_color_deconverter2;
typedef my_color_deconverter2 * my_cconvert_ptr2; /* Private state for RGB->Y conversion */
INT32 * R_y_tab; /* => table for R to Y conversion */
INT32 * G_y_tab; /* => table for G to Y conversion */
INT32 * B_y_tab; /* => table for B to Y conversion */
} my_color_deconverter;
typedef my_color_deconverter * my_cconvert_ptr;
/**************** YCbCr -> RGB conversion: most common case **************/ /*************** YCbCr -> RGB conversion: most common case **************/
/*************** BG_YCC -> RGB conversion: less common case **************/
/*************** RGB -> Y conversion: less common case **************/
/* /*
* YCbCr is defined per CCIR 601-1, except that Cb and Cr are * YCbCr is defined per Recommendation ITU-R BT.601-7 (03/2011),
* normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. * previously known as Recommendation CCIR 601-1, except that Cb and Cr
* The conversion equations to be implemented are therefore * are normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
* R = Y + 1.40200 * Cr * sRGB (standard RGB color space) is defined per IEC 61966-2-1:1999.
* G = Y - 0.34414 * Cb - 0.71414 * Cr * sYCC (standard luma-chroma-chroma color space with extended gamut)
* B = Y + 1.77200 * Cb * is defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex F.
* bg-sRGB and bg-sYCC (big gamut standard color spaces)
* are defined per IEC 61966-2-1:1999 Amendment A1:2003 Annex G.
* Note that the derived conversion coefficients given in some of these
* documents are imprecise. The general conversion equations are
*
* R = Y + K * (1 - Kr) * Cr
* G = Y - K * (Kb * (1 - Kb) * Cb + Kr * (1 - Kr) * Cr) / (1 - Kr - Kb)
* B = Y + K * (1 - Kb) * Cb
*
* Y = Kr * R + (1 - Kr - Kb) * G + Kb * B
*
* With Kr = 0.299 and Kb = 0.114 (derived according to SMPTE RP 177-1993
* from the 1953 FCC NTSC primaries and CIE Illuminant C), K = 2 for sYCC,
* the conversion equations to be implemented are therefore
*
* R = Y + 1.402 * Cr
* G = Y - 0.344136286 * Cb - 0.714136286 * Cr
* B = Y + 1.772 * Cb
*
* Y = 0.299 * R + 0.587 * G + 0.114 * B
*
* where Cb and Cr represent the incoming values less CENTERJSAMPLE. * where Cb and Cr represent the incoming values less CENTERJSAMPLE.
* (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) * For bg-sYCC, with K = 4, the equations are
*
* R = Y + 2.804 * Cr
* G = Y - 0.688272572 * Cb - 1.428272572 * Cr
* B = Y + 3.544 * Cb
* *
* To avoid floating-point arithmetic, we represent the fractional constants * To avoid floating-point arithmetic, we represent the fractional constants
* as integers scaled up by 2^16 (about 4 digits precision); we have to divide * as integers scaled up by 2^16 (about 4 digits precision); we have to divide
@ -49,12 +88,12 @@ typedef my_color_deconverter2 * my_cconvert_ptr2;
* For even more speed, we avoid doing any multiplications in the inner loop * For even more speed, we avoid doing any multiplications in the inner loop
* by precalculating the constants times Cb and Cr for all possible values. * by precalculating the constants times Cb and Cr for all possible values.
* For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table);
* for 12-bit samples it is still acceptable. It's not very reasonable for * for 9-bit to 12-bit samples it is still acceptable. It's not very
* 16-bit samples, but if you want lossless storage you shouldn't be changing * reasonable for 16-bit samples, but if you want lossless storage
* colorspace anyway. * you shouldn't be changing colorspace anyway.
* The Cr=>R and Cb=>B values can be rounded to integers in advance; the * The Cr=>R and Cb=>B values can be rounded to integers in advance;
* values for the G calculation are left scaled up, since we must add them * the values for the G calculation are left scaled up,
* together before rounding. * since we must add them together before rounding.
*/ */
#define SCALEBITS 16 /* speediest right-shift on some machines */ #define SCALEBITS 16 /* speediest right-shift on some machines */
@ -63,44 +102,73 @@ typedef my_color_deconverter2 * my_cconvert_ptr2;
/* /*
* Initialize tables for YCC->RGB colorspace conversion. * Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
*/ */
LOCAL(void) LOCAL(void)
build_ycc_rgb_table (j_decompress_ptr cinfo) build_ycc_rgb_table (j_decompress_ptr cinfo)
/* Normal case, sYCC */
{ {
my_cconvert_ptr2 cconvert = (my_cconvert_ptr2) cinfo->cconvert; my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int i; int i;
INT32 x; INT32 x;
SHIFT_TEMPS SHIFT_TEMPS
cconvert->Cr_r_tab = (int *) cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
(MAXJSAMPLE+1) * SIZEOF(int)); cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
cconvert->Cb_b_tab = (int *) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
(MAXJSAMPLE+1) * SIZEOF(int)); ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cr_g_tab = (INT32 *) cconvert->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
(MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.40200 * x */ /* Cr=>R value is nearest int to 1.402 * x */
cconvert->Cr_r_tab[i] = (int) cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); /* Cb=>B value is nearest int to 1.772 * x */
/* Cb=>B value is nearest int to 1.77200 * x */ cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
cconvert->Cb_b_tab[i] = (int) /* Cr=>G value is scaled-up -0.714136286 * x */
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); cconvert->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
/* Cr=>G value is scaled-up -0.71414 * x */ /* Cb=>G value is scaled-up -0.344136286 * x */
cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x;
/* Cb=>G value is scaled-up -0.34414 * x */
/* We also add in ONE_HALF so that need not do it in inner loop */ /* We also add in ONE_HALF so that need not do it in inner loop */
cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; cconvert->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF;
}
}
LOCAL(void)
build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
/* Wide gamut case, bg-sYCC */
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int i;
INT32 x;
SHIFT_TEMPS
cconvert->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
cconvert->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 2.804 * x */
cconvert->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS);
/* Cb=>B value is nearest int to 3.544 * x */
cconvert->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS);
/* Cr=>G value is scaled-up -1.428272572 * x */
cconvert->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
/* Cb=>G value is scaled-up -0.688272572 * x */
/* We also add in ONE_HALF so that need not do it in inner loop */
cconvert->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
} }
} }
@ -111,6 +179,7 @@ build_ycc_rgb_table (j_decompress_ptr cinfo)
* Note that we change from noninterleaved, one-plane-per-component format * Note that we change from noninterleaved, one-plane-per-component format
* to interleaved-pixel format. The output buffer is therefore three times * to interleaved-pixel format. The output buffer is therefore three times
* as wide as the input buffer. * as wide as the input buffer.
*
* A starting row offset is provided only for the input buffer. The caller * A starting row offset is provided only for the input buffer. The caller
* can easily adjust the passed output_buf value to accommodate any row * can easily adjust the passed output_buf value to accommodate any row
* offset required on that side. * offset required on that side.
@ -121,18 +190,18 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows) JSAMPARRAY output_buf, int num_rows)
{ {
my_cconvert_ptr2 cconvert = (my_cconvert_ptr2) cinfo->cconvert; my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int y, cb, cr; register int y, cb, cr;
JSAMPROW outptr; register JSAMPROW outptr;
JSAMPROW inptr0, inptr1, inptr2; register JSAMPROW inptr0, inptr1, inptr2;
JDIMENSION col; register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width; JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */ /* copy these pointers into registers if possible */
JSAMPLE * range_limit = cinfo->sample_range_limit; register JSAMPLE * range_limit = cinfo->sample_range_limit;
int * Crrtab = cconvert->Cr_r_tab; register int * Crrtab = cconvert->Cr_r_tab;
int * Cbbtab = cconvert->Cb_b_tab; register int * Cbbtab = cconvert->Cb_b_tab;
INT32 * Crgtab = cconvert->Cr_g_tab; register INT32 * Crgtab = cconvert->Cr_g_tab;
INT32 * Cbgtab = cconvert->Cb_g_tab; register INT32 * Cbgtab = cconvert->Cb_g_tab;
SHIFT_TEMPS SHIFT_TEMPS
while (--num_rows >= 0) { while (--num_rows >= 0) {
@ -145,64 +214,252 @@ ycc_rgb_convert (j_decompress_ptr cinfo,
y = GETJSAMPLE(inptr0[col]); y = GETJSAMPLE(inptr0[col]);
cb = GETJSAMPLE(inptr1[col]); cb = GETJSAMPLE(inptr1[col]);
cr = GETJSAMPLE(inptr2[col]); cr = GETJSAMPLE(inptr2[col]);
/* Range-limiting is essential due to noise introduced by DCT losses. */ /* Range-limiting is essential due to noise introduced by DCT losses,
outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; * for extended gamut (sYCC) and wide gamut (bg-sYCC) encodings.
*/
outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
outptr[RGB_GREEN] = range_limit[y + outptr[RGB_GREEN] = range_limit[y +
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
SCALEBITS))]; SCALEBITS))];
outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
outptr += RGB_PIXELSIZE; outptr += RGB_PIXELSIZE;
} }
} }
} }
/**************** Cases other than YCbCr -> RGB **************/ /**************** Cases other than YCC -> RGB ****************/
/*
* Initialize for RGB->grayscale colorspace conversion.
*/
LOCAL(void)
build_rgb_y_table (j_decompress_ptr cinfo)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
INT32 i;
cconvert->R_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->G_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
cconvert->B_y_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0; i <= MAXJSAMPLE; i++) {
cconvert->R_y_tab[i] = FIX(0.299) * i;
cconvert->G_y_tab[i] = FIX(0.587) * i;
cconvert->B_y_tab[i] = FIX(0.114) * i + ONE_HALF;
}
}
/*
* Convert RGB to grayscale.
*/
METHODDEF(void)
rgb_gray_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 y;
register INT32 * Rytab = cconvert->R_y_tab;
register INT32 * Gytab = cconvert->G_y_tab;
register INT32 * Bytab = cconvert->B_y_tab;
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
while (--num_rows >= 0) {
inptr0 = input_buf[0][input_row];
inptr1 = input_buf[1][input_row];
inptr2 = input_buf[2][input_row];
input_row++;
outptr = *output_buf++;
for (col = 0; col < num_cols; col++) {
y = Rytab[GETJSAMPLE(inptr0[col])];
y += Gytab[GETJSAMPLE(inptr1[col])];
y += Bytab[GETJSAMPLE(inptr2[col])];
outptr[col] = (JSAMPLE) (y >> SCALEBITS);
}
}
}
/*
* Convert some rows of samples to the output colorspace.
* [R-G,G,B-G] to [R,G,B] conversion with modulo calculation
* (inverse color transform).
* This can be seen as an adaption of the general YCbCr->RGB
* conversion equation with Kr = Kb = 0, while replacing the
* normalization by modulo calculation.
*/
METHODDEF(void)
rgb1_rgb_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows)
{
register int r, g, b;
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
while (--num_rows >= 0) {
inptr0 = input_buf[0][input_row];
inptr1 = input_buf[1][input_row];
inptr2 = input_buf[2][input_row];
input_row++;
outptr = *output_buf++;
for (col = 0; col < num_cols; col++) {
r = GETJSAMPLE(inptr0[col]);
g = GETJSAMPLE(inptr1[col]);
b = GETJSAMPLE(inptr2[col]);
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
* (modulo) operator is equivalent to the bitmask operator AND.
*/
outptr[RGB_RED] = (JSAMPLE) ((r + g - CENTERJSAMPLE) & MAXJSAMPLE);
outptr[RGB_GREEN] = (JSAMPLE) g;
outptr[RGB_BLUE] = (JSAMPLE) ((b + g - CENTERJSAMPLE) & MAXJSAMPLE);
outptr += RGB_PIXELSIZE;
}
}
}
/*
* [R-G,G,B-G] to grayscale conversion with modulo calculation
* (inverse color transform).
*/
METHODDEF(void)
rgb1_gray_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register int r, g, b;
register INT32 y;
register INT32 * Rytab = cconvert->R_y_tab;
register INT32 * Gytab = cconvert->G_y_tab;
register INT32 * Bytab = cconvert->B_y_tab;
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
while (--num_rows >= 0) {
inptr0 = input_buf[0][input_row];
inptr1 = input_buf[1][input_row];
inptr2 = input_buf[2][input_row];
input_row++;
outptr = *output_buf++;
for (col = 0; col < num_cols; col++) {
r = GETJSAMPLE(inptr0[col]);
g = GETJSAMPLE(inptr1[col]);
b = GETJSAMPLE(inptr2[col]);
/* Assume that MAXJSAMPLE+1 is a power of 2, so that the MOD
* (modulo) operator is equivalent to the bitmask operator AND.
*/
y = Rytab[(r + g - CENTERJSAMPLE) & MAXJSAMPLE];
y += Gytab[g];
y += Bytab[(b + g - CENTERJSAMPLE) & MAXJSAMPLE];
outptr[col] = (JSAMPLE) (y >> SCALEBITS);
}
}
}
/*
* Convert some rows of samples to the output colorspace.
* No colorspace change, but conversion from separate-planes
* to interleaved representation.
*/
METHODDEF(void)
rgb_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows)
{
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
while (--num_rows >= 0) {
inptr0 = input_buf[0][input_row];
inptr1 = input_buf[1][input_row];
inptr2 = input_buf[2][input_row];
input_row++;
outptr = *output_buf++;
for (col = 0; col < num_cols; col++) {
/* We can dispense with GETJSAMPLE() here */
outptr[RGB_RED] = inptr0[col];
outptr[RGB_GREEN] = inptr1[col];
outptr[RGB_BLUE] = inptr2[col];
outptr += RGB_PIXELSIZE;
}
}
}
/* /*
* Color conversion for no colorspace change: just copy the data, * Color conversion for no colorspace change: just copy the data,
* converting from separate-planes to interleaved representation. * converting from separate-planes to interleaved representation.
* Note: Omit uninteresting components in output buffer.
*/ */
METHODDEF(void) METHODDEF(void)
null_convert2 (j_decompress_ptr cinfo, null_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows) JSAMPARRAY output_buf, int num_rows)
{ {
JSAMPROW inptr, outptr; register JSAMPROW outptr;
JDIMENSION count; register JSAMPROW inptr;
int num_components = cinfo->num_components; register JDIMENSION count;
register int out_comps = cinfo->out_color_components;
JDIMENSION num_cols = cinfo->output_width; JDIMENSION num_cols = cinfo->output_width;
JSAMPROW startptr;
int ci; int ci;
jpeg_component_info *compptr;
while (--num_rows >= 0) { while (--num_rows >= 0) {
for (ci = 0; ci < num_components; ci++) { /* It seems fastest to make a separate pass for each component. */
startptr = *output_buf++;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
if (! compptr->component_needed)
continue; /* skip uninteresting component */
inptr = input_buf[ci][input_row]; inptr = input_buf[ci][input_row];
outptr = output_buf[0] + ci; outptr = startptr++;
for (count = num_cols; count > 0; count--) { for (count = num_cols; count > 0; count--) {
*outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ *outptr = *inptr++; /* don't need GETJSAMPLE() here */
outptr += num_components; outptr += out_comps;
} }
} }
input_row++; input_row++;
output_buf++;
} }
} }
/* /*
* Color conversion for grayscale: just copy the data. * Color conversion for grayscale: just copy the data.
* This also works for YCbCr -> grayscale conversion, in which * This also works for YCC -> grayscale conversion, in which
* we just copy the Y (luminance) component and ignore chrominance. * we just copy the Y (luminance) component and ignore chrominance.
*/ */
METHODDEF(void) METHODDEF(void)
grayscale_convert2 (j_decompress_ptr cinfo, grayscale_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows) JSAMPARRAY output_buf, int num_rows)
{ {
jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, jcopy_sample_rows(input_buf[0] + input_row, output_buf,
num_rows, cinfo->output_width); num_rows, cinfo->output_width);
} }
@ -218,8 +475,9 @@ gray_rgb_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows) JSAMPARRAY output_buf, int num_rows)
{ {
JSAMPROW inptr, outptr; register JSAMPROW outptr;
JDIMENSION col; register JSAMPROW inptr;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width; JDIMENSION num_cols = cinfo->output_width;
while (--num_rows >= 0) { while (--num_rows >= 0) {
@ -235,9 +493,10 @@ gray_rgb_convert (j_decompress_ptr cinfo,
/* /*
* Adobe-style YCCK->CMYK conversion. * Convert some rows of samples to the output colorspace.
* We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same * This version handles Adobe-style YCCK->CMYK conversion,
* conversion as above, while passing K (black) unchanged. * where we convert YCbCr to R=1-C, G=1-M, and B=1-Y using the
* same conversion as above, while passing K (black) unchanged.
* We assume build_ycc_rgb_table has been called. * We assume build_ycc_rgb_table has been called.
*/ */
@ -246,18 +505,18 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row, JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows) JSAMPARRAY output_buf, int num_rows)
{ {
my_cconvert_ptr2 cconvert = (my_cconvert_ptr2) cinfo->cconvert; my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
int y, cb, cr; register int y, cb, cr;
JSAMPROW outptr; register JSAMPROW outptr;
JSAMPROW inptr0, inptr1, inptr2, inptr3; register JSAMPROW inptr0, inptr1, inptr2, inptr3;
JDIMENSION col; register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width; JDIMENSION num_cols = cinfo->output_width;
/* copy these pointers into registers if possible */ /* copy these pointers into registers if possible */
JSAMPLE * range_limit = cinfo->sample_range_limit; register JSAMPLE * range_limit = cinfo->sample_range_limit;
int * Crrtab = cconvert->Cr_r_tab; register int * Crrtab = cconvert->Cr_r_tab;
int * Cbbtab = cconvert->Cb_b_tab; register int * Cbbtab = cconvert->Cb_b_tab;
INT32 * Crgtab = cconvert->Cr_g_tab; register INT32 * Crgtab = cconvert->Cr_g_tab;
INT32 * Cbgtab = cconvert->Cb_g_tab; register INT32 * Cbgtab = cconvert->Cb_g_tab;
SHIFT_TEMPS SHIFT_TEMPS
while (--num_rows >= 0) { while (--num_rows >= 0) {
@ -271,7 +530,9 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
y = GETJSAMPLE(inptr0[col]); y = GETJSAMPLE(inptr0[col]);
cb = GETJSAMPLE(inptr1[col]); cb = GETJSAMPLE(inptr1[col]);
cr = GETJSAMPLE(inptr2[col]); cr = GETJSAMPLE(inptr2[col]);
/* Range-limiting is essential due to noise introduced by DCT losses. */ /* Range-limiting is essential due to noise introduced by DCT losses,
* and for extended gamut encodings (sYCC).
*/
outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */
outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */
((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
@ -285,12 +546,52 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
} }
/*
* Convert CMYK to YK part of YCCK for colorless output.
* We assume build_rgb_y_table has been called.
*/
METHODDEF(void)
cmyk_yk_convert (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION input_row,
JSAMPARRAY output_buf, int num_rows)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register INT32 y;
register INT32 * Rytab = cconvert->R_y_tab;
register INT32 * Gytab = cconvert->G_y_tab;
register INT32 * Bytab = cconvert->B_y_tab;
register JSAMPROW outptr;
register JSAMPROW inptr0, inptr1, inptr2, inptr3;
register JDIMENSION col;
JDIMENSION num_cols = cinfo->output_width;
while (--num_rows >= 0) {
inptr0 = input_buf[0][input_row];
inptr1 = input_buf[1][input_row];
inptr2 = input_buf[2][input_row];
inptr3 = input_buf[3][input_row];
input_row++;
outptr = *output_buf++;
for (col = 0; col < num_cols; col++) {
y = Rytab[MAXJSAMPLE - GETJSAMPLE(inptr0[col])];
y += Gytab[MAXJSAMPLE - GETJSAMPLE(inptr1[col])];
y += Bytab[MAXJSAMPLE - GETJSAMPLE(inptr2[col])];
outptr[0] = (JSAMPLE) (y >> SCALEBITS);
/* K passes through unchanged */
outptr[1] = inptr3[col]; /* don't need GETJSAMPLE here */
outptr += 2;
}
}
}
/* /*
* Empty method for start_pass. * Empty method for start_pass.
*/ */
METHODDEF(void) METHODDEF(void)
start_pass_dcolor (j_decompress_ptr) start_pass_dcolor (j_decompress_ptr cinfo)
{ {
/* no work needed */ /* no work needed */
} }
@ -303,13 +604,12 @@ start_pass_dcolor (j_decompress_ptr)
GLOBAL(void) GLOBAL(void)
jinit_color_deconverter (j_decompress_ptr cinfo) jinit_color_deconverter (j_decompress_ptr cinfo)
{ {
my_cconvert_ptr2 cconvert; my_cconvert_ptr cconvert;
int ci; int ci, i;
cconvert = (my_cconvert_ptr2) cconvert = (my_cconvert_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_color_deconverter));
SIZEOF(my_color_deconverter2)); cinfo->cconvert = &cconvert->pub;
cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert;
cconvert->pub.start_pass = start_pass_dcolor; cconvert->pub.start_pass = start_pass_dcolor;
/* Make sure num_components agrees with jpeg_color_space */ /* Make sure num_components agrees with jpeg_color_space */
@ -321,6 +621,8 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
case JCS_RGB: case JCS_RGB:
case JCS_YCbCr: case JCS_YCbCr:
case JCS_BG_RGB:
case JCS_BG_YCC:
if (cinfo->num_components != 3) if (cinfo->num_components != 3)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
break; break;
@ -334,59 +636,130 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
default: /* JCS_UNKNOWN can be anything */ default: /* JCS_UNKNOWN can be anything */
if (cinfo->num_components < 1) if (cinfo->num_components < 1)
ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); ERREXIT(cinfo, JERR_BAD_J_COLORSPACE);
break;
} }
/* Support color transform only for RGB colorspaces */
if (cinfo->color_transform &&
cinfo->jpeg_color_space != JCS_RGB &&
cinfo->jpeg_color_space != JCS_BG_RGB)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
/* Set out_color_components and conversion method based on requested space. /* Set out_color_components and conversion method based on requested space.
* Also clear the component_needed flags for any unused components, * Also adjust the component_needed flags for any unused components,
* so that earlier pipeline stages can avoid useless computation. * so that earlier pipeline stages can avoid useless computation.
*/ */
switch (cinfo->out_color_space) { switch (cinfo->out_color_space) {
case JCS_GRAYSCALE: case JCS_GRAYSCALE:
cinfo->out_color_components = 1; cinfo->out_color_components = 1;
if (cinfo->jpeg_color_space == JCS_GRAYSCALE || switch (cinfo->jpeg_color_space) {
cinfo->jpeg_color_space == JCS_YCbCr) { case JCS_GRAYSCALE:
cconvert->pub.color_convert = grayscale_convert2; case JCS_YCbCr:
case JCS_BG_YCC:
cconvert->pub.color_convert = grayscale_convert;
/* For color->grayscale conversion, only the Y (0) component is needed */ /* For color->grayscale conversion, only the Y (0) component is needed */
for (ci = 1; ci < cinfo->num_components; ci++) for (ci = 1; ci < cinfo->num_components; ci++)
cinfo->comp_info[ci].component_needed = FALSE; cinfo->comp_info[ci].component_needed = FALSE;
} else break;
case JCS_RGB:
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_gray_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb1_gray_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
build_rgb_y_table(cinfo);
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break; break;
case JCS_RGB: case JCS_RGB:
cinfo->out_color_components = RGB_PIXELSIZE; cinfo->out_color_components = RGB_PIXELSIZE;
if (cinfo->jpeg_color_space == JCS_YCbCr) { switch (cinfo->jpeg_color_space) {
case JCS_GRAYSCALE:
cconvert->pub.color_convert = gray_rgb_convert;
break;
case JCS_YCbCr:
cconvert->pub.color_convert = ycc_rgb_convert; cconvert->pub.color_convert = ycc_rgb_convert;
build_ycc_rgb_table(cinfo); build_ycc_rgb_table(cinfo);
} else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { break;
cconvert->pub.color_convert = gray_rgb_convert; case JCS_BG_YCC:
} else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { cconvert->pub.color_convert = ycc_rgb_convert;
cconvert->pub.color_convert = null_convert2; build_bg_ycc_rgb_table(cinfo);
} else break;
case JCS_RGB:
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb1_rgb_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break;
case JCS_BG_RGB:
if (cinfo->jpeg_color_space != JCS_BG_RGB)
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
cinfo->out_color_components = RGB_PIXELSIZE;
switch (cinfo->color_transform) {
case JCT_NONE:
cconvert->pub.color_convert = rgb_convert;
break;
case JCT_SUBTRACT_GREEN:
cconvert->pub.color_convert = rgb1_rgb_convert;
break;
default:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
break; break;
case JCS_CMYK: case JCS_CMYK:
if (cinfo->jpeg_color_space != JCS_YCCK)
goto def_label;
cinfo->out_color_components = 4; cinfo->out_color_components = 4;
if (cinfo->jpeg_color_space == JCS_YCCK) { cconvert->pub.color_convert = ycck_cmyk_convert;
cconvert->pub.color_convert = ycck_cmyk_convert; build_ycc_rgb_table(cinfo);
build_ycc_rgb_table(cinfo);
} else if (cinfo->jpeg_color_space == JCS_CMYK) {
cconvert->pub.color_convert = null_convert2;
} else
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
break; break;
default: case JCS_YCCK:
/* Permit null conversion to same output space */ if (cinfo->jpeg_color_space != JCS_CMYK ||
if (cinfo->out_color_space == cinfo->jpeg_color_space) { /* Support only YK part of YCCK for colorless output */
cinfo->out_color_components = cinfo->num_components; ! cinfo->comp_info[0].component_needed ||
cconvert->pub.color_convert = null_convert2; cinfo->comp_info[1].component_needed ||
} else /* unsupported non-null conversion */ cinfo->comp_info[2].component_needed ||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); ! cinfo->comp_info[3].component_needed)
goto def_label;
cinfo->out_color_components = 2;
/* Need all components on input side */
cinfo->comp_info[1].component_needed = TRUE;
cinfo->comp_info[2].component_needed = TRUE;
cconvert->pub.color_convert = cmyk_yk_convert;
build_rgb_y_table(cinfo);
break; break;
default: def_label: /* permit null conversion to same output space */
if (cinfo->out_color_space != cinfo->jpeg_color_space)
/* unsupported non-null conversion */
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
i = 0;
for (ci = 0; ci < cinfo->num_components; ci++)
if (cinfo->comp_info[ci].component_needed)
i++; /* count output color components */
cinfo->out_color_components = i;
cconvert->pub.color_convert = null_convert;
} }
if (cinfo->quantize_colors) if (cinfo->quantize_colors)

View file

@ -2,23 +2,29 @@
* jdct.h * jdct.h
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2002-2023 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This include file contains common declarations for the forward and * This include file contains common declarations for the forward and
* inverse DCT modules. These declarations are private to the DCT managers * inverse DCT modules. These declarations are private to the DCT managers
* (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.
* The individual DCT algorithms are kept in separate files to ease * The individual DCT algorithms are kept in separate files to ease
* machine-dependent tuning (e.g., assembly coding). * machine-dependent tuning (e.g., assembly coding).
*/ */
/* /*
* A forward DCT routine is given a pointer to a work area of type DCTELEM[]; * A forward DCT routine is given a pointer to an input sample array and
* the DCT is to be performed in-place in that buffer. Type DCTELEM is int * a pointer to a work area of type DCTELEM[]; the DCT is to be performed
* for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT * in-place in that buffer. Type DCTELEM is int for 8-bit samples, INT32
* implementations use an array of type FAST_FLOAT, instead.) * for 12-bit samples. (NOTE: Floating-point DCT implementations use an
* The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). * array of type FAST_FLOAT, instead.)
* The input data is to be fetched from the sample array starting at a
* specified column. (Any row offset needed will be applied to the array
* pointer before it is passed to the FDCT code.)
* Note that the number of samples fetched by the FDCT routine is
* DCT_h_scaled_size * DCT_v_scaled_size.
* The DCT outputs are returned scaled up by a factor of 8; they therefore * The DCT outputs are returned scaled up by a factor of 8; they therefore
* have a range of +-8K for 8-bit data, +-128K for 12-bit data. This * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
* convention improves accuracy in integer implementations and saves some * convention improves accuracy in integer implementations and saves some
@ -26,17 +32,18 @@
* Quantization of the output coefficients is done by jcdctmgr.c. * Quantization of the output coefficients is done by jcdctmgr.c.
*/ */
#ifndef __jdct_h__
#define __jdct_h__
#if BITS_IN_JSAMPLE == 8 #if BITS_IN_JSAMPLE == 8
typedef int DCTELEM; /* 16 or 32 bits is fine */ typedef int DCTELEM; /* 16 or 32 bits is fine */
#else #else
typedef INT32 DCTELEM; /* must have 32 bits */ typedef INT32 DCTELEM; /* must have 32 bits */
#endif #endif
typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data,
typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); JSAMPARRAY sample_data,
JDIMENSION start_col));
typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data,
JSAMPARRAY sample_data,
JDIMENSION start_col));
/* /*
@ -47,7 +54,7 @@ typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data));
* sample array starting at a specified column. (Any row offset needed will * sample array starting at a specified column. (Any row offset needed will
* be applied to the array pointer before it is passed to the IDCT code.) * be applied to the array pointer before it is passed to the IDCT code.)
* Note that the number of samples emitted by the IDCT routine is * Note that the number of samples emitted by the IDCT routine is
* DCT_scaled_size * DCT_scaled_size. * DCT_h_scaled_size * DCT_v_scaled_size.
*/ */
/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ /* typedef inverse_DCT_method_ptr is declared in jpegint.h */
@ -72,13 +79,15 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
* converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
* be quite far out of range if the input data is corrupt, so a bulletproof * be quite far out of range if the input data is corrupt, so a bulletproof
* range-limiting step is required. We use a mask-and-table-lookup method * range-limiting step is required. We use a mask-and-table-lookup method
* to do the combined operations quickly. See the comments with * to do the combined operations quickly, assuming that RANGE_CENTER
* (defined in jpegint.h) is a power of 2. See the comments with
* prepare_range_limit_table (in jdmaster.c) for more info. * prepare_range_limit_table (in jdmaster.c) for more info.
*/ */
#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) #define RANGE_MASK (RANGE_CENTER * 2 - 1)
#define RANGE_SUBSET (RANGE_CENTER - CENTERJSAMPLE)
#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ #define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit - RANGE_SUBSET)
/* Short forms of external names for systems with brain-damaged linkers. */ /* Short forms of external names for systems with brain-damaged linkers. */
@ -87,19 +96,143 @@ typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
#define jpeg_fdct_islow jFDislow #define jpeg_fdct_islow jFDislow
#define jpeg_fdct_ifast jFDifast #define jpeg_fdct_ifast jFDifast
#define jpeg_fdct_float jFDfloat #define jpeg_fdct_float jFDfloat
#define jpeg_fdct_7x7 jFD7x7
#define jpeg_fdct_6x6 jFD6x6
#define jpeg_fdct_5x5 jFD5x5
#define jpeg_fdct_4x4 jFD4x4
#define jpeg_fdct_3x3 jFD3x3
#define jpeg_fdct_2x2 jFD2x2
#define jpeg_fdct_1x1 jFD1x1
#define jpeg_fdct_9x9 jFD9x9
#define jpeg_fdct_10x10 jFD10x10
#define jpeg_fdct_11x11 jFD11x11
#define jpeg_fdct_12x12 jFD12x12
#define jpeg_fdct_13x13 jFD13x13
#define jpeg_fdct_14x14 jFD14x14
#define jpeg_fdct_15x15 jFD15x15
#define jpeg_fdct_16x16 jFD16x16
#define jpeg_fdct_16x8 jFD16x8
#define jpeg_fdct_14x7 jFD14x7
#define jpeg_fdct_12x6 jFD12x6
#define jpeg_fdct_10x5 jFD10x5
#define jpeg_fdct_8x4 jFD8x4
#define jpeg_fdct_6x3 jFD6x3
#define jpeg_fdct_4x2 jFD4x2
#define jpeg_fdct_2x1 jFD2x1
#define jpeg_fdct_8x16 jFD8x16
#define jpeg_fdct_7x14 jFD7x14
#define jpeg_fdct_6x12 jFD6x12
#define jpeg_fdct_5x10 jFD5x10
#define jpeg_fdct_4x8 jFD4x8
#define jpeg_fdct_3x6 jFD3x6
#define jpeg_fdct_2x4 jFD2x4
#define jpeg_fdct_1x2 jFD1x2
#define jpeg_idct_islow jRDislow #define jpeg_idct_islow jRDislow
#define jpeg_idct_ifast jRDifast #define jpeg_idct_ifast jRDifast
#define jpeg_idct_float jRDfloat #define jpeg_idct_float jRDfloat
#define jpeg_idct_7x7 jRD7x7
#define jpeg_idct_6x6 jRD6x6
#define jpeg_idct_5x5 jRD5x5
#define jpeg_idct_4x4 jRD4x4 #define jpeg_idct_4x4 jRD4x4
#define jpeg_idct_3x3 jRD3x3
#define jpeg_idct_2x2 jRD2x2 #define jpeg_idct_2x2 jRD2x2
#define jpeg_idct_1x1 jRD1x1 #define jpeg_idct_1x1 jRD1x1
#define jpeg_idct_9x9 jRD9x9
#define jpeg_idct_10x10 jRD10x10
#define jpeg_idct_11x11 jRD11x11
#define jpeg_idct_12x12 jRD12x12
#define jpeg_idct_13x13 jRD13x13
#define jpeg_idct_14x14 jRD14x14
#define jpeg_idct_15x15 jRD15x15
#define jpeg_idct_16x16 jRD16x16
#define jpeg_idct_16x8 jRD16x8
#define jpeg_idct_14x7 jRD14x7
#define jpeg_idct_12x6 jRD12x6
#define jpeg_idct_10x5 jRD10x5
#define jpeg_idct_8x4 jRD8x4
#define jpeg_idct_6x3 jRD6x3
#define jpeg_idct_4x2 jRD4x2
#define jpeg_idct_2x1 jRD2x1
#define jpeg_idct_8x16 jRD8x16
#define jpeg_idct_7x14 jRD7x14
#define jpeg_idct_6x12 jRD6x12
#define jpeg_idct_5x10 jRD5x10
#define jpeg_idct_4x8 jRD4x8
#define jpeg_idct_3x6 jRD3x6
#define jpeg_idct_2x4 jRD2x4
#define jpeg_idct_1x2 jRD1x2
#endif /* NEED_SHORT_EXTERNAL_NAMES */ #endif /* NEED_SHORT_EXTERNAL_NAMES */
/* Extern declarations for the forward and inverse DCT routines. */ /* Extern declarations for the forward and inverse DCT routines. */
EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); EXTERN(void) jpeg_fdct_islow
EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); EXTERN(void) jpeg_fdct_ifast
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_float
JPP((FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_7x7
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_6x6
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_5x5
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_4x4
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_3x3
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_2x2
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_1x1
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_9x9
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_10x10
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_11x11
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_12x12
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_13x13
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_14x14
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_15x15
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_16x16
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_16x8
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_14x7
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_12x6
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_10x5
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_8x4
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_6x3
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_4x2
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_2x1
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_8x16
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_7x14
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_6x12
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_5x10
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_4x8
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_3x6
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_2x4
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_fdct_1x2
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
EXTERN(void) jpeg_idct_islow EXTERN(void) jpeg_idct_islow
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
@ -110,15 +243,99 @@ EXTERN(void) jpeg_idct_ifast
EXTERN(void) jpeg_idct_float EXTERN(void) jpeg_idct_float
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_7x7
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_6x6
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_5x5
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_4x4 EXTERN(void) jpeg_idct_4x4
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_3x3
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_2x2 EXTERN(void) jpeg_idct_2x2
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_1x1 EXTERN(void) jpeg_idct_1x1
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_9x9
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_10x10
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_11x11
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_12x12
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_13x13
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_14x14
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_15x15
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_16x16
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_16x8
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_14x7
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_12x6
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_10x5
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_8x4
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_6x3
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_4x2
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_2x1
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_8x16
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_7x14
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_6x12
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_5x10
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_4x8
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_3x6
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_2x4
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
EXTERN(void) jpeg_idct_1x2
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
/* /*
@ -141,13 +358,6 @@ EXTERN(void) jpeg_idct_1x1
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) #define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* This macro is used only when the two inputs will actually be no more than * This macro is used only when the two inputs will actually be no more than
* 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
@ -178,5 +388,22 @@ EXTERN(void) jpeg_idct_1x1
#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) #define MULTIPLY16V16(var1,var2) ((var1) * (var2))
#endif #endif
/* Like RIGHT_SHIFT, but applies to a DCTELEM.
* We assume that int right shift is unsigned if INT32 right shift is.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define ISHIFT_TEMPS DCTELEM ishift_temp;
#if BITS_IN_JSAMPLE == 8
#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
#else
#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
#endif
#define IRIGHT_SHIFT(x,shft) \
((ishift_temp = (x)) < 0 ? \
(ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
(ishift_temp >> (shft)))
#else
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif #endif

View file

@ -2,6 +2,7 @@
* jddctmgr.c * jddctmgr.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2002-2013 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -98,22 +99,134 @@ start_pass (j_decompress_ptr cinfo)
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
/* Select the proper IDCT routine for this component's scaling */ /* Select the proper IDCT routine for this component's scaling */
switch (compptr->DCT_scaled_size) { switch ((compptr->DCT_h_scaled_size << 8) + compptr->DCT_v_scaled_size) {
#ifdef IDCT_SCALING_SUPPORTED #ifdef IDCT_SCALING_SUPPORTED
case 1: case ((1 << 8) + 1):
method_ptr = jpeg_idct_1x1; method_ptr = jpeg_idct_1x1;
method = JDCT_ISLOW; /* jidctred uses islow-style table */ method = JDCT_ISLOW; /* jidctint uses islow-style table */
break; break;
case 2: case ((2 << 8) + 2):
method_ptr = jpeg_idct_2x2; method_ptr = jpeg_idct_2x2;
method = JDCT_ISLOW; /* jidctred uses islow-style table */ method = JDCT_ISLOW; /* jidctint uses islow-style table */
break; break;
case 4: case ((3 << 8) + 3):
method_ptr = jpeg_idct_3x3;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((4 << 8) + 4):
method_ptr = jpeg_idct_4x4; method_ptr = jpeg_idct_4x4;
method = JDCT_ISLOW; /* jidctred uses islow-style table */ method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((5 << 8) + 5):
method_ptr = jpeg_idct_5x5;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((6 << 8) + 6):
method_ptr = jpeg_idct_6x6;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((7 << 8) + 7):
method_ptr = jpeg_idct_7x7;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((9 << 8) + 9):
method_ptr = jpeg_idct_9x9;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((10 << 8) + 10):
method_ptr = jpeg_idct_10x10;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((11 << 8) + 11):
method_ptr = jpeg_idct_11x11;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((12 << 8) + 12):
method_ptr = jpeg_idct_12x12;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((13 << 8) + 13):
method_ptr = jpeg_idct_13x13;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((14 << 8) + 14):
method_ptr = jpeg_idct_14x14;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((15 << 8) + 15):
method_ptr = jpeg_idct_15x15;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((16 << 8) + 16):
method_ptr = jpeg_idct_16x16;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((16 << 8) + 8):
method_ptr = jpeg_idct_16x8;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((14 << 8) + 7):
method_ptr = jpeg_idct_14x7;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((12 << 8) + 6):
method_ptr = jpeg_idct_12x6;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((10 << 8) + 5):
method_ptr = jpeg_idct_10x5;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((8 << 8) + 4):
method_ptr = jpeg_idct_8x4;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((6 << 8) + 3):
method_ptr = jpeg_idct_6x3;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((4 << 8) + 2):
method_ptr = jpeg_idct_4x2;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((2 << 8) + 1):
method_ptr = jpeg_idct_2x1;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((8 << 8) + 16):
method_ptr = jpeg_idct_8x16;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((7 << 8) + 14):
method_ptr = jpeg_idct_7x14;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((6 << 8) + 12):
method_ptr = jpeg_idct_6x12;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((5 << 8) + 10):
method_ptr = jpeg_idct_5x10;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((4 << 8) + 8):
method_ptr = jpeg_idct_4x8;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((3 << 8) + 6):
method_ptr = jpeg_idct_3x6;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((2 << 8) + 4):
method_ptr = jpeg_idct_2x4;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break;
case ((1 << 8) + 2):
method_ptr = jpeg_idct_1x2;
method = JDCT_ISLOW; /* jidctint uses islow-style table */
break; break;
#endif #endif
case DCTSIZE: case ((DCTSIZE << 8) + DCTSIZE):
switch (cinfo->dct_method) { switch (cinfo->dct_method) {
#ifdef DCT_ISLOW_SUPPORTED #ifdef DCT_ISLOW_SUPPORTED
case JDCT_ISLOW: case JDCT_ISLOW:
@ -139,7 +252,8 @@ start_pass (j_decompress_ptr cinfo)
} }
break; break;
default: default:
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); ERREXIT2(cinfo, JERR_BAD_DCTSIZE,
compptr->DCT_h_scaled_size, compptr->DCT_v_scaled_size);
break; break;
} }
idct->pub.inverse_DCT[ci] = method_ptr; idct->pub.inverse_DCT[ci] = method_ptr;
@ -211,6 +325,7 @@ start_pass (j_decompress_ptr cinfo)
* coefficients scaled by scalefactor[row]*scalefactor[col], where * coefficients scaled by scalefactor[row]*scalefactor[col], where
* scalefactor[0] = 1 * scalefactor[0] = 1
* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7
* We apply a further scale factor of 1/8.
*/ */
FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table;
int row, col; int row, col;
@ -224,7 +339,7 @@ start_pass (j_decompress_ptr cinfo)
for (col = 0; col < DCTSIZE; col++) { for (col = 0; col < DCTSIZE; col++) {
fmtbl[i] = (FLOAT_MULT_TYPE) fmtbl[i] = (FLOAT_MULT_TYPE)
((double) qtbl->quantval[i] * ((double) qtbl->quantval[i] *
aanscalefactor[row] * aanscalefactor[col]); aanscalefactor[row] * aanscalefactor[col] * 0.125);
i++; i++;
} }
} }
@ -253,7 +368,7 @@ jinit_inverse_dct (j_decompress_ptr cinfo)
idct = (my_idct_ptr) idct = (my_idct_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(my_idct_controller)); SIZEOF(my_idct_controller));
cinfo->idct = (struct jpeg_inverse_dct *) idct; cinfo->idct = &idct->pub;
idct->pub.start_pass = start_pass; idct->pub.start_pass = start_pass;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;

File diff suppressed because it is too large Load diff

View file

@ -1,206 +0,0 @@
/*
* jdhuff.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains declarations for Huffman entropy decoding routines
* that are shared between the sequential decoder (jdhuff.c) and the
* progressive decoder (jdphuff.c). No other modules need to see these.
*/
/* Short forms of external names for systems with brain-damaged linkers. */
#ifndef __jdhuff_h__
#define __jdhuff_h__
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jpeg_make_d_derived_tbl jMkDDerived
#define jpeg_fill_bit_buffer jFilBitBuf
#define jpeg_huff_decode jHufDecode
#endif /* NEED_SHORT_EXTERNAL_NAMES */
/* Derived data constructed for each Huffman table */
#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */
typedef struct {
/* Basic tables: (element [0] of each array is unused) */
INT32 maxcode[18]; /* largest code of length k (-1 if none) */
/* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */
INT32 valoffset[17]; /* huffval[] offset for codes of length k */
/* valoffset[k] = huffval[] index of 1st symbol of code length k, less
* the smallest code of length k; so given a code of length k, the
* corresponding symbol is huffval[code + valoffset[k]]
*/
/* Link to public Huffman table (needed only in jpeg_huff_decode) */
JHUFF_TBL *pub;
/* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of
* the input data stream. If the next Huffman code is no more
* than HUFF_LOOKAHEAD bits long, we can obtain its length and
* the corresponding symbol directly from these tables.
*/
int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */
UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */
} d_derived_tbl;
/* Expand a Huffman table definition into the derived format */
EXTERN(void) jpeg_make_d_derived_tbl
JPP((j_decompress_ptr cinfo, boolean isDC, int tblno,
d_derived_tbl ** pdtbl));
/*
* Fetching the next N bits from the input stream is a time-critical operation
* for the Huffman decoders. We implement it with a combination of inline
* macros and out-of-line subroutines. Note that N (the number of bits
* demanded at one time) never exceeds 15 for JPEG use.
*
* We read source bytes into get_buffer and dole out bits as needed.
* If get_buffer already contains enough bits, they are fetched in-line
* by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough
* bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer
* as full as possible (not just to the number of bits needed; this
* prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).
* Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.
* On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains
* at least the requested number of bits --- dummy zeroes are inserted if
* necessary.
*/
typedef INT32 bit_buf_type; /* type of bit-extraction buffer */
#define BIT_BUF_SIZE 32 /* size of buffer in bits */
/* If long is > 32 bits on your machine, and shifting/masking longs is
* reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE
* appropriately should be a win. Unfortunately we can't define the size
* with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)
* because not all machines measure sizeof in 8-bit bytes.
*/
typedef struct { /* Bitreading state saved across MCUs */
bit_buf_type get_buffer; /* current bit-extraction buffer */
int bits_left; /* # of unused bits in it */
} bitread_perm_state;
typedef struct { /* Bitreading working state within an MCU */
/* Current data source location */
/* We need a copy, rather than munging the original, in case of suspension */
const JOCTET * next_input_byte; /* => next byte to read from source */
size_t bytes_in_buffer; /* # of bytes remaining in source buffer */
/* Bit input buffer --- note these values are kept in register variables,
* not in this struct, inside the inner loops.
*/
bit_buf_type get_buffer; /* current bit-extraction buffer */
int bits_left; /* # of unused bits in it */
/* Pointer needed by jpeg_fill_bit_buffer. */
j_decompress_ptr cinfo; /* back link to decompress master record */
} bitread_working_state;
/* Macros to declare and load/save bitread local variables. */
#define BITREAD_STATE_VARS \
bit_buf_type get_buffer; \
int bits_left; \
bitread_working_state br_state
#define BITREAD_LOAD_STATE(cinfop,permstate) \
br_state.cinfo = cinfop; \
br_state.next_input_byte = cinfop->src->next_input_byte; \
br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
get_buffer = permstate.get_buffer; \
bits_left = permstate.bits_left;
#define BITREAD_SAVE_STATE(cinfop,permstate) \
cinfop->src->next_input_byte = br_state.next_input_byte; \
cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
permstate.get_buffer = get_buffer; \
permstate.bits_left = bits_left
/*
* These macros provide the in-line portion of bit fetching.
* Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer
* before using GET_BITS, PEEK_BITS, or DROP_BITS.
* The variables get_buffer and bits_left are assumed to be locals,
* but the state struct might not be (jpeg_huff_decode needs this).
* CHECK_BIT_BUFFER(state,n,action);
* Ensure there are N bits in get_buffer; if suspend, take action.
* val = GET_BITS(n);
* Fetch next N bits.
* val = PEEK_BITS(n);
* Fetch next N bits without removing them from the buffer.
* DROP_BITS(n);
* Discard next N bits.
* The value N should be a simple variable, not an expression, because it
* is evaluated multiple times.
*/
#define CHECK_BIT_BUFFER(state,nbits,action) \
{ if (bits_left < (nbits)) { \
if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
{ action; } \
get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
#define GET_BITS(nbits) \
(((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1))
#define PEEK_BITS(nbits) \
(((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1))
#define DROP_BITS(nbits) \
(bits_left -= (nbits))
/* Load up the bit buffer to a depth of at least nbits */
EXTERN(boolean) jpeg_fill_bit_buffer
JPP((bitread_working_state * state, bit_buf_type get_buffer,
int bits_left, int nbits));
/*
* Code for extracting next Huffman-coded symbol from input bit stream.
* Again, this is time-critical and we make the main paths be macros.
*
* We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits
* without looping. Usually, more than 95% of the Huffman codes will be 8
* or fewer bits long. The few overlength codes are handled with a loop,
* which need not be inline code.
*
* Notes about the HUFF_DECODE macro:
* 1. Near the end of the data segment, we may fail to get enough bits
* for a lookahead. In that case, we do it the hard way.
* 2. If the lookahead table contains no entry, the next code must be
* more than HUFF_LOOKAHEAD bits long.
* 3. jpeg_huff_decode returns -1 if forced to suspend.
*/
#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
{ int nb, look; \
if (bits_left < HUFF_LOOKAHEAD) { \
if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
get_buffer = state.get_buffer; bits_left = state.bits_left; \
if (bits_left < HUFF_LOOKAHEAD) { \
nb = 1; goto slowlabel; \
} \
} \
look = PEEK_BITS(HUFF_LOOKAHEAD); \
if ((nb = htbl->look_nbits[look]) != 0) { \
DROP_BITS(nb); \
result = htbl->look_sym[look]; \
} else { \
nb = HUFF_LOOKAHEAD+1; \
slowlabel: \
if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
{ failaction; } \
get_buffer = state.get_buffer; bits_left = state.bits_left; \
} \
}
/* Out-of-line case for Huffman code fetching */
EXTERN(int) jpeg_huff_decode
JPP((bitread_working_state * state, bit_buf_type get_buffer,
int bits_left, d_derived_tbl * htbl, int min_bits));
#endif

View file

@ -2,13 +2,14 @@
* jdinput.c * jdinput.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2002-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains input control logic for the JPEG decompressor. * This file contains input control logic for the JPEG decompressor.
* These routines are concerned with controlling the decompressor's input * These routines are concerned with controlling the decompressor's input
* processing (marker reading and coefficient decoding). The actual input * processing (marker reading and coefficient decoding). The actual input
* reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. * reading is done in jdmarker.c, jdhuff.c, and jdarith.c.
*/ */
#define JPEG_INTERNALS #define JPEG_INTERNALS
@ -21,7 +22,7 @@
typedef struct { typedef struct {
struct jpeg_input_controller pub; /* public fields */ struct jpeg_input_controller pub; /* public fields */
boolean inheaders; /* TRUE until first SOS is reached */ int inheaders; /* Nonzero until first SOS is reached */
} my_input_controller; } my_input_controller;
typedef my_input_controller * my_inputctl_ptr; typedef my_input_controller * my_inputctl_ptr;
@ -35,8 +36,176 @@ METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo));
* Routines to calculate various quantities related to the size of the image. * Routines to calculate various quantities related to the size of the image.
*/ */
/*
* Compute output image dimensions and related values.
* NOTE: this is exported for possible use by application.
* Hence it mustn't do anything that can't be done twice.
*/
GLOBAL(void)
jpeg_core_output_dimensions (j_decompress_ptr cinfo)
/* Do computations that are needed before master selection phase.
* This function is used for transcoding and full decompression.
*/
{
#ifdef IDCT_SCALING_SUPPORTED
int ci;
jpeg_component_info *compptr;
/* Compute actual output image dimensions and DCT scaling choices. */
if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) {
/* Provide 1/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 1;
cinfo->min_DCT_v_scaled_size = 1;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) {
/* Provide 2/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 2L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 2L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 2;
cinfo->min_DCT_v_scaled_size = 2;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 3) {
/* Provide 3/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 3L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 3L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 3;
cinfo->min_DCT_v_scaled_size = 3;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) {
/* Provide 4/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 4L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 4L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 4;
cinfo->min_DCT_v_scaled_size = 4;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 5) {
/* Provide 5/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 5L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 5L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 5;
cinfo->min_DCT_v_scaled_size = 5;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 6) {
/* Provide 6/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 6L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 6L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 6;
cinfo->min_DCT_v_scaled_size = 6;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 7) {
/* Provide 7/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 7L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 7L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 7;
cinfo->min_DCT_v_scaled_size = 7;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) {
/* Provide 8/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 8L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 8L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 8;
cinfo->min_DCT_v_scaled_size = 8;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 9) {
/* Provide 9/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 9L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 9L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 9;
cinfo->min_DCT_v_scaled_size = 9;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 10) {
/* Provide 10/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 10L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 10L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 10;
cinfo->min_DCT_v_scaled_size = 10;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 11) {
/* Provide 11/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 11L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 11L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 11;
cinfo->min_DCT_v_scaled_size = 11;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 12) {
/* Provide 12/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 12L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 12L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 12;
cinfo->min_DCT_v_scaled_size = 12;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 13) {
/* Provide 13/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 13L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 13L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 13;
cinfo->min_DCT_v_scaled_size = 13;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 14) {
/* Provide 14/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 14L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 14L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 14;
cinfo->min_DCT_v_scaled_size = 14;
} else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 15) {
/* Provide 15/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 15L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 15L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 15;
cinfo->min_DCT_v_scaled_size = 15;
} else {
/* Provide 16/block_size scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 16L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 16L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 16;
cinfo->min_DCT_v_scaled_size = 16;
}
/* Recompute dimensions of components */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size;
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size;
}
#else /* !IDCT_SCALING_SUPPORTED */
/* Hardwire it to "no scaling" */
cinfo->output_width = cinfo->image_width;
cinfo->output_height = cinfo->image_height;
/* initial_setup has already initialized DCT_scaled_size,
* and has computed unscaled downsampled_width and downsampled_height.
*/
#endif /* IDCT_SCALING_SUPPORTED */
}
LOCAL(void) LOCAL(void)
initial_setup2 (j_decompress_ptr cinfo) initial_setup (j_decompress_ptr cinfo)
/* Called once, when first SOS marker is reached */ /* Called once, when first SOS marker is reached */
{ {
int ci; int ci;
@ -47,8 +216,8 @@ initial_setup2 (j_decompress_ptr cinfo)
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
/* For now, precision must match compiled-in value... */ /* Only 8 to 12 bits data precision are supported for DCT based JPEG */
if (cinfo->data_precision != BITS_IN_JSAMPLE) if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Check that number of components won't exceed internal array sizes */ /* Check that number of components won't exceed internal array sizes */
@ -70,23 +239,120 @@ initial_setup2 (j_decompress_ptr cinfo)
compptr->v_samp_factor); compptr->v_samp_factor);
} }
/* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. /* Derive block_size, natural_order, and lim_Se */
* In the full decompressor, this will be overridden by jdmaster.c; if (cinfo->is_baseline || (cinfo->progressive_mode &&
* but in the transcoder, jdmaster.c is not used, so we must do it here. cinfo->comps_in_scan)) { /* no pseudo SOS marker */
cinfo->block_size = DCTSIZE;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
} else
switch (cinfo->Se) {
case (1*1-1):
cinfo->block_size = 1;
cinfo->natural_order = jpeg_natural_order; /* not needed */
cinfo->lim_Se = cinfo->Se;
break;
case (2*2-1):
cinfo->block_size = 2;
cinfo->natural_order = jpeg_natural_order2;
cinfo->lim_Se = cinfo->Se;
break;
case (3*3-1):
cinfo->block_size = 3;
cinfo->natural_order = jpeg_natural_order3;
cinfo->lim_Se = cinfo->Se;
break;
case (4*4-1):
cinfo->block_size = 4;
cinfo->natural_order = jpeg_natural_order4;
cinfo->lim_Se = cinfo->Se;
break;
case (5*5-1):
cinfo->block_size = 5;
cinfo->natural_order = jpeg_natural_order5;
cinfo->lim_Se = cinfo->Se;
break;
case (6*6-1):
cinfo->block_size = 6;
cinfo->natural_order = jpeg_natural_order6;
cinfo->lim_Se = cinfo->Se;
break;
case (7*7-1):
cinfo->block_size = 7;
cinfo->natural_order = jpeg_natural_order7;
cinfo->lim_Se = cinfo->Se;
break;
case (8*8-1):
cinfo->block_size = 8;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (9*9-1):
cinfo->block_size = 9;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (10*10-1):
cinfo->block_size = 10;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (11*11-1):
cinfo->block_size = 11;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (12*12-1):
cinfo->block_size = 12;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (13*13-1):
cinfo->block_size = 13;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (14*14-1):
cinfo->block_size = 14;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (15*15-1):
cinfo->block_size = 15;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
case (16*16-1):
cinfo->block_size = 16;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;
default:
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
}
/* We initialize DCT_scaled_size and min_DCT_scaled_size to block_size.
* In the full decompressor,
* this will be overridden by jpeg_calc_output_dimensions in jdmaster.c;
* but in the transcoder,
* jpeg_calc_output_dimensions is not used, so we must do it here.
*/ */
cinfo->min_DCT_scaled_size = DCTSIZE; cinfo->min_DCT_h_scaled_size = cinfo->block_size;
cinfo->min_DCT_v_scaled_size = cinfo->block_size;
/* Compute dimensions of components */ /* Compute dimensions of components */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
compptr->DCT_scaled_size = DCTSIZE; compptr->DCT_h_scaled_size = cinfo->block_size;
compptr->DCT_v_scaled_size = cinfo->block_size;
/* Size in DCT blocks */ /* Size in DCT blocks */
compptr->width_in_blocks = (JDIMENSION) compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
(long) (cinfo->max_h_samp_factor * DCTSIZE)); (long) (cinfo->max_h_samp_factor * cinfo->block_size));
compptr->height_in_blocks = (JDIMENSION) compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
(long) (cinfo->max_v_samp_factor * DCTSIZE)); (long) (cinfo->max_v_samp_factor * cinfo->block_size));
/* downsampled_width and downsampled_height will also be overridden by /* downsampled_width and downsampled_height will also be overridden by
* jdmaster.c if we are doing full decompression. The transcoder library * jdmaster.c if we are doing full decompression. The transcoder library
* doesn't use these values, but the calling application might. * doesn't use these values, but the calling application might.
@ -107,7 +373,7 @@ initial_setup2 (j_decompress_ptr cinfo)
/* Compute number of fully interleaved MCU rows. */ /* Compute number of fully interleaved MCU rows. */
cinfo->total_iMCU_rows = (JDIMENSION) cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, jdiv_round_up((long) cinfo->image_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE)); (long) (cinfo->max_v_samp_factor * cinfo->block_size));
/* Decide whether file contains multiple scans */ /* Decide whether file contains multiple scans */
if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
@ -118,7 +384,7 @@ initial_setup2 (j_decompress_ptr cinfo)
LOCAL(void) LOCAL(void)
per_scan_setup2 (j_decompress_ptr cinfo) per_scan_setup (j_decompress_ptr cinfo)
/* Do computations that are needed before processing a JPEG scan */ /* Do computations that are needed before processing a JPEG scan */
/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ /* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */
{ {
@ -138,7 +404,7 @@ per_scan_setup2 (j_decompress_ptr cinfo)
compptr->MCU_width = 1; compptr->MCU_width = 1;
compptr->MCU_height = 1; compptr->MCU_height = 1;
compptr->MCU_blocks = 1; compptr->MCU_blocks = 1;
compptr->MCU_sample_width = compptr->DCT_scaled_size; compptr->MCU_sample_width = compptr->DCT_h_scaled_size;
compptr->last_col_width = 1; compptr->last_col_width = 1;
/* For noninterleaved scans, it is convenient to define last_row_height /* For noninterleaved scans, it is convenient to define last_row_height
* as the number of block rows present in the last iMCU row. * as the number of block rows present in the last iMCU row.
@ -161,10 +427,8 @@ per_scan_setup2 (j_decompress_ptr cinfo)
/* Overall image size in MCUs */ /* Overall image size in MCUs */
cinfo->MCUs_per_row = (JDIMENSION) cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, jdiv_round_up((long) cinfo->image_width,
(long) (cinfo->max_h_samp_factor*DCTSIZE)); (long) (cinfo->max_h_samp_factor * cinfo->block_size));
cinfo->MCU_rows_in_scan = (JDIMENSION) cinfo->MCU_rows_in_scan = cinfo->total_iMCU_rows;
jdiv_round_up((long) cinfo->image_height,
(long) (cinfo->max_v_samp_factor*DCTSIZE));
cinfo->blocks_in_MCU = 0; cinfo->blocks_in_MCU = 0;
@ -174,7 +438,7 @@ per_scan_setup2 (j_decompress_ptr cinfo)
compptr->MCU_width = compptr->h_samp_factor; compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor; compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_h_scaled_size;
/* Figure number of non-dummy blocks in last MCU column & row */ /* Figure number of non-dummy blocks in last MCU column & row */
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width; if (tmp == 0) tmp = compptr->MCU_width;
@ -234,9 +498,8 @@ latch_quant_tables (j_decompress_ptr cinfo)
cinfo->quant_tbl_ptrs[qtblno] == NULL) cinfo->quant_tbl_ptrs[qtblno] == NULL)
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
/* OK, save away the quantization table */ /* OK, save away the quantization table */
qtbl = (JQUANT_TBL *) qtbl = (JQUANT_TBL *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(JQUANT_TBL));
SIZEOF(JQUANT_TBL));
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
compptr->quant_table = qtbl; compptr->quant_table = qtbl;
} }
@ -251,9 +514,9 @@ latch_quant_tables (j_decompress_ptr cinfo)
*/ */
METHODDEF(void) METHODDEF(void)
start_input_pass2 (j_decompress_ptr cinfo) start_input_pass (j_decompress_ptr cinfo)
{ {
per_scan_setup2(cinfo); per_scan_setup(cinfo);
latch_quant_tables(cinfo); latch_quant_tables(cinfo);
(*cinfo->entropy->start_pass) (cinfo); (*cinfo->entropy->start_pass) (cinfo);
(*cinfo->coef->start_input_pass) (cinfo); (*cinfo->coef->start_input_pass) (cinfo);
@ -270,6 +533,7 @@ start_input_pass2 (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
finish_input_pass (j_decompress_ptr cinfo) finish_input_pass (j_decompress_ptr cinfo)
{ {
(*cinfo->entropy->finish_pass) (cinfo);
cinfo->inputctl->consume_input = consume_markers; cinfo->inputctl->consume_input = consume_markers;
} }
@ -282,6 +546,10 @@ finish_input_pass (j_decompress_ptr cinfo)
* The consume_input method pointer points either here or to the * The consume_input method pointer points either here or to the
* coefficient controller's consume_data routine, depending on whether * coefficient controller's consume_data routine, depending on whether
* we are reading a compressed data segment or inter-segment markers. * we are reading a compressed data segment or inter-segment markers.
*
* Note: This function should NOT return a pseudo SOS marker (with zero
* component number) to the caller. A pseudo marker received by
* read_markers is processed and then skipped for other markers.
*/ */
METHODDEF(int) METHODDEF(int)
@ -293,41 +561,50 @@ consume_markers (j_decompress_ptr cinfo)
if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */
return JPEG_REACHED_EOI; return JPEG_REACHED_EOI;
val = (*cinfo->marker->read_markers) (cinfo); for (;;) { /* Loop to pass pseudo SOS marker */
val = (*cinfo->marker->read_markers) (cinfo);
switch (val) { switch (val) {
case JPEG_REACHED_SOS: /* Found SOS */ case JPEG_REACHED_SOS: /* Found SOS */
if (inputctl->inheaders) { /* 1st SOS */ if (inputctl->inheaders) { /* 1st SOS */
initial_setup2(cinfo); if (inputctl->inheaders == 1)
inputctl->inheaders = FALSE; initial_setup(cinfo);
/* Note: start_input_pass must be called by jdmaster.c if (cinfo->comps_in_scan == 0) { /* pseudo SOS marker */
* before any more input can be consumed. jdapimin.c is inputctl->inheaders = 2;
* responsible for enforcing this sequencing. break;
*/ }
} else { /* 2nd or later SOS marker */ inputctl->inheaders = 0;
if (! inputctl->pub.has_multiple_scans) /* Note: start_input_pass must be called by jdmaster.c
ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ * before any more input can be consumed. jdapimin.c is
start_input_pass2(cinfo); * responsible for enforcing this sequencing.
*/
} else { /* 2nd or later SOS marker */
if (! inputctl->pub.has_multiple_scans)
ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */
if (cinfo->comps_in_scan == 0) /* unexpected pseudo SOS marker */
break;
start_input_pass(cinfo);
}
return val;
case JPEG_REACHED_EOI: /* Found EOI */
inputctl->pub.eoi_reached = TRUE;
if (inputctl->inheaders) { /* Tables-only datastream, apparently */
if (cinfo->marker->saw_SOF)
ERREXIT(cinfo, JERR_SOF_NO_SOS);
} else {
/* Prevent infinite loop in coef ctlr's decompress_data routine
* if user set output_scan_number larger than number of scans.
*/
if (cinfo->output_scan_number > cinfo->input_scan_number)
cinfo->output_scan_number = cinfo->input_scan_number;
}
return val;
case JPEG_SUSPENDED:
return val;
default:
return val;
} }
break;
case JPEG_REACHED_EOI: /* Found EOI */
inputctl->pub.eoi_reached = TRUE;
if (inputctl->inheaders) { /* Tables-only datastream, apparently */
if (cinfo->marker->saw_SOF)
ERREXIT(cinfo, JERR_SOF_NO_SOS);
} else {
/* Prevent infinite loop in coef ctlr's decompress_data routine
* if user set output_scan_number larger than number of scans.
*/
if (cinfo->output_scan_number > cinfo->input_scan_number)
cinfo->output_scan_number = cinfo->input_scan_number;
}
break;
case JPEG_SUSPENDED:
break;
} }
return val;
} }
@ -343,7 +620,7 @@ reset_input_controller (j_decompress_ptr cinfo)
inputctl->pub.consume_input = consume_markers; inputctl->pub.consume_input = consume_markers;
inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
inputctl->pub.eoi_reached = FALSE; inputctl->pub.eoi_reached = FALSE;
inputctl->inheaders = TRUE; inputctl->inheaders = 1;
/* Reset other modules */ /* Reset other modules */
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
(*cinfo->marker->reset_marker_reader) (cinfo); (*cinfo->marker->reset_marker_reader) (cinfo);
@ -363,19 +640,18 @@ jinit_input_controller (j_decompress_ptr cinfo)
my_inputctl_ptr inputctl; my_inputctl_ptr inputctl;
/* Create subobject in permanent pool */ /* Create subobject in permanent pool */
inputctl = (my_inputctl_ptr) inputctl = (my_inputctl_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_input_controller));
SIZEOF(my_input_controller)); cinfo->inputctl = &inputctl->pub;
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
/* Initialize method pointers */ /* Initialize method pointers */
inputctl->pub.consume_input = consume_markers; inputctl->pub.consume_input = consume_markers;
inputctl->pub.reset_input_controller = reset_input_controller; inputctl->pub.reset_input_controller = reset_input_controller;
inputctl->pub.start_input_pass = start_input_pass2; inputctl->pub.start_input_pass = start_input_pass;
inputctl->pub.finish_input_pass = finish_input_pass; inputctl->pub.finish_input_pass = finish_input_pass;
/* Initialize state: can't use reset_input_controller since we don't /* Initialize state: can't use reset_input_controller since we don't
* want to try to reset other modules yet. * want to try to reset other modules yet.
*/ */
inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */
inputctl->pub.eoi_reached = FALSE; inputctl->pub.eoi_reached = FALSE;
inputctl->inheaders = TRUE; inputctl->inheaders = 1;
} }

View file

@ -2,6 +2,7 @@
* jdmainct.c * jdmainct.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2002-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -25,8 +26,8 @@
* trivial. Its responsibility is to provide context rows for upsampling/ * trivial. Its responsibility is to provide context rows for upsampling/
* rescaling, and doing this in an efficient fashion is a bit tricky. * rescaling, and doing this in an efficient fashion is a bit tricky.
* *
* Postprocessor input data is counted in "row groups". A row group * Postprocessor input data is counted in "row groups". A row group is
* is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) * defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size)
* sample rows of each component. (We require DCT_scaled_size values to be * sample rows of each component. (We require DCT_scaled_size values to be
* chosen such that these numbers are integers. In practice DCT_scaled_size * chosen such that these numbers are integers. In practice DCT_scaled_size
* values will likely be powers of two, so we actually have the stronger * values will likely be powers of two, so we actually have the stronger
@ -36,8 +37,8 @@
* applying). * applying).
* *
* The coefficient controller will deliver data to us one iMCU row at a time; * The coefficient controller will deliver data to us one iMCU row at a time;
* each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or * each iMCU row contains v_samp_factor * DCT_v_scaled_size sample rows, or
* exactly min_DCT_scaled_size row groups. (This amount of data corresponds * exactly min_DCT_v_scaled_size row groups. (This amount of data corresponds
* to one row of MCUs when the image is fully interleaved.) Note that the * to one row of MCUs when the image is fully interleaved.) Note that the
* number of sample rows varies across components, but the number of row * number of sample rows varies across components, but the number of row
* groups does not. Some garbage sample rows may be included in the last iMCU * groups does not. Some garbage sample rows may be included in the last iMCU
@ -74,7 +75,7 @@
* We could do this most simply by copying data around in our buffer, but * We could do this most simply by copying data around in our buffer, but
* that'd be very slow. We can avoid copying any data by creating a rather * that'd be very slow. We can avoid copying any data by creating a rather
* strange pointer structure. Here's how it works. We allocate a workspace * strange pointer structure. Here's how it works. We allocate a workspace
* consisting of M+2 row groups (where M = min_DCT_scaled_size is the number * consisting of M+2 row groups (where M = min_DCT_v_scaled_size is the number
* of row groups per iMCU row). We create two sets of redundant pointers to * of row groups per iMCU row). We create two sets of redundant pointers to
* the workspace. Labeling the physical row groups 0 to M+1, the synthesized * the workspace. Labeling the physical row groups 0 to M+1, the synthesized
* pointer lists look like this: * pointer lists look like this:
@ -99,11 +100,11 @@
* the first or last sample row as necessary (this is cheaper than copying * the first or last sample row as necessary (this is cheaper than copying
* sample rows around). * sample rows around).
* *
* This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that * This scheme breaks down if M < 2, ie, min_DCT_v_scaled_size is 1. In that
* situation each iMCU row provides only one row group so the buffering logic * situation each iMCU row provides only one row group so the buffering logic
* must be different (eg, we must read two iMCU rows before we can emit the * must be different (eg, we must read two iMCU rows before we can emit the
* first row group). For now, we simply do not support providing context * first row group). For now, we simply do not support providing context
* rows when min_DCT_scaled_size is 1. That combination seems unlikely to * rows when min_DCT_v_scaled_size is 1. That combination seems unlikely to
* be worth providing --- if someone wants a 1/8th-size preview, they probably * be worth providing --- if someone wants a 1/8th-size preview, they probably
* want it quick and dirty, so a context-free upsampler is sufficient. * want it quick and dirty, so a context-free upsampler is sufficient.
*/ */
@ -117,21 +118,22 @@ typedef struct {
/* Pointer to allocated workspace (M or M+2 row groups). */ /* Pointer to allocated workspace (M or M+2 row groups). */
JSAMPARRAY buffer[MAX_COMPONENTS]; JSAMPARRAY buffer[MAX_COMPONENTS];
boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
/* Remaining fields are only used in the context case. */ /* Remaining fields are only used in the context case. */
boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
/* These are the master pointers to the funny-order pointer lists. */ /* These are the master pointers to the funny-order pointer lists. */
JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
int whichptr; /* indicates which pointer set is now in use */ int whichptr; /* indicates which pointer set is now in use */
int context_state; /* process_data state machine status */ int context_state; /* process_data state machine status */
JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */
} my_main_controller4; } my_main_controller;
typedef my_main_controller4 * my_main_ptr4; typedef my_main_controller * my_main_ptr;
/* context_state values: */ /* context_state values: */
#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ #define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */
@ -140,7 +142,7 @@ typedef my_main_controller4 * my_main_ptr4;
/* Forward declarations */ /* Forward declarations */
METHODDEF(void) process_data_simple_main2 METHODDEF(void) process_data_simple_main
JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf,
JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail));
METHODDEF(void) process_data_context_main METHODDEF(void) process_data_context_main
@ -159,34 +161,35 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
* This is done only once, not once per pass. * This is done only once, not once per pass.
*/ */
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
int ci, rgroup; int ci, rgroup;
int M = cinfo->min_DCT_scaled_size; int M = cinfo->min_DCT_v_scaled_size;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY xbuf; JSAMPARRAY xbuf;
/* Get top-level space for component array pointers. /* Get top-level space for component array pointers.
* We alloc both arrays with one call to save a few cycles. * We alloc both arrays with one call to save a few cycles.
*/ */
main_->xbuffer[0] = (JSAMPIMAGE) mainp->xbuffer[0] = (JSAMPIMAGE) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); cinfo->num_components * 2 * SIZEOF(JSAMPARRAY));
main_->xbuffer[1] = main_->xbuffer[0] + cinfo->num_components; mainp->xbuffer[1] = mainp->xbuffer[0] + cinfo->num_components;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / if (! compptr->component_needed)
cinfo->min_DCT_scaled_size; /* height of a row group of component */ continue; /* skip uninteresting component */
rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
/* Get space for pointer lists --- M+4 row groups in each list. /* Get space for pointer lists --- M+4 row groups in each list.
* We alloc both pointer lists with one call to save a few cycles. * We alloc both pointer lists with one call to save a few cycles.
*/ */
xbuf = (JSAMPARRAY) xbuf = (JSAMPARRAY) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, JPOOL_IMAGE, 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW));
xbuf += rgroup; /* want one row group at negative offsets */ xbuf += rgroup; /* want one row group at negative offsets */
main_->xbuffer[0][ci] = xbuf; mainp->xbuffer[0][ci] = xbuf;
xbuf += rgroup * (M + 4); xbuf += rgroup * (M + 4);
main_->xbuffer[1][ci] = xbuf; mainp->xbuffer[1][ci] = xbuf;
} }
} }
@ -194,26 +197,28 @@ alloc_funny_pointers (j_decompress_ptr cinfo)
LOCAL(void) LOCAL(void)
make_funny_pointers (j_decompress_ptr cinfo) make_funny_pointers (j_decompress_ptr cinfo)
/* Create the funny pointer lists discussed in the comments above. /* Create the funny pointer lists discussed in the comments above.
* The actual workspace is already allocated (in main->buffer), * The actual workspace is already allocated (in mainp->buffer),
* and the space for the pointer lists is allocated too. * and the space for the pointer lists is allocated too.
* This routine just fills in the curiously ordered lists. * This routine just fills in the curiously ordered lists.
* This will be repeated at the beginning of each pass. * This will be repeated at the beginning of each pass.
*/ */
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
int ci, i, rgroup; int ci, i, rgroup;
int M = cinfo->min_DCT_scaled_size; int M = cinfo->min_DCT_v_scaled_size;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY buf, xbuf0, xbuf1; JSAMPARRAY buf, xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / if (! compptr->component_needed)
cinfo->min_DCT_scaled_size; /* height of a row group of component */ continue; /* skip uninteresting component */
xbuf0 = main_->xbuffer[0][ci]; rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
xbuf1 = main_->xbuffer[1][ci]; cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
xbuf0 = mainp->xbuffer[0][ci];
xbuf1 = mainp->xbuffer[1][ci];
/* First copy the workspace pointers as-is */ /* First copy the workspace pointers as-is */
buf = main_->buffer[ci]; buf = mainp->buffer[ci];
for (i = 0; i < rgroup * (M + 2); i++) { for (i = 0; i < rgroup * (M + 2); i++) {
xbuf0[i] = xbuf1[i] = buf[i]; xbuf0[i] = xbuf1[i] = buf[i];
} }
@ -240,18 +245,20 @@ set_wraparound_pointers (j_decompress_ptr cinfo)
* This changes the pointer list state from top-of-image to the normal state. * This changes the pointer list state from top-of-image to the normal state.
*/ */
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
int ci, i, rgroup; int ci, i, rgroup;
int M = cinfo->min_DCT_scaled_size; int M = cinfo->min_DCT_v_scaled_size;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY xbuf0, xbuf1; JSAMPARRAY xbuf0, xbuf1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / if (! compptr->component_needed)
cinfo->min_DCT_scaled_size; /* height of a row group of component */ continue; /* skip uninteresting component */
xbuf0 = main_->xbuffer[0][ci]; rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
xbuf1 = main_->xbuffer[1][ci]; cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
xbuf0 = mainp->xbuffer[0][ci];
xbuf1 = mainp->xbuffer[1][ci];
for (i = 0; i < rgroup; i++) { for (i = 0; i < rgroup; i++) {
xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i];
xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i];
@ -269,16 +276,18 @@ set_bottom_pointers (j_decompress_ptr cinfo)
* Also sets rowgroups_avail to indicate number of nondummy row groups in row. * Also sets rowgroups_avail to indicate number of nondummy row groups in row.
*/ */
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
int ci, i, rgroup, iMCUheight, rows_left; int ci, i, rgroup, iMCUheight, rows_left;
jpeg_component_info *compptr; jpeg_component_info *compptr;
JSAMPARRAY xbuf; JSAMPARRAY xbuf;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
if (! compptr->component_needed)
continue; /* skip uninteresting component */
/* Count sample rows in one iMCU row and in one row group */ /* Count sample rows in one iMCU row and in one row group */
iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; iMCUheight = compptr->v_samp_factor * compptr->DCT_v_scaled_size;
rgroup = iMCUheight / cinfo->min_DCT_scaled_size; rgroup = iMCUheight / cinfo->min_DCT_v_scaled_size;
/* Count nondummy sample rows remaining for this component */ /* Count nondummy sample rows remaining for this component */
rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight);
if (rows_left == 0) rows_left = iMCUheight; if (rows_left == 0) rows_left = iMCUheight;
@ -286,12 +295,12 @@ set_bottom_pointers (j_decompress_ptr cinfo)
* so we need only do it once. * so we need only do it once.
*/ */
if (ci == 0) { if (ci == 0) {
main_->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); mainp->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1);
} }
/* Duplicate the last real sample row rgroup*2 times; this pads out the /* Duplicate the last real sample row rgroup*2 times; this pads out the
* last partial rowgroup and ensures at least one full rowgroup of context. * last partial rowgroup and ensures at least one full rowgroup of context.
*/ */
xbuf = main_->xbuffer[main_->whichptr][ci]; xbuf = mainp->xbuffer[mainp->whichptr][ci];
for (i = 0; i < rgroup * 2; i++) { for (i = 0; i < rgroup * 2; i++) {
xbuf[rows_left + i] = xbuf[rows_left-1]; xbuf[rows_left + i] = xbuf[rows_left-1];
} }
@ -304,34 +313,33 @@ set_bottom_pointers (j_decompress_ptr cinfo)
*/ */
METHODDEF(void) METHODDEF(void)
start_pass_main2 (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
switch (pass_mode) { switch (pass_mode) {
case JBUF_PASS_THRU: case JBUF_PASS_THRU:
if (cinfo->upsample->need_context_rows) { if (cinfo->upsample->need_context_rows) {
main_->pub.process_data = process_data_context_main; mainp->pub.process_data = process_data_context_main;
make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ make_funny_pointers(cinfo); /* Create the xbuffer[] lists */
main_->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ mainp->whichptr = 0; /* Read first iMCU row into xbuffer[0] */
main_->context_state = CTX_PREPARE_FOR_IMCU; mainp->context_state = CTX_PREPARE_FOR_IMCU;
main_->iMCU_row_ctr = 0; mainp->iMCU_row_ctr = 0;
mainp->buffer_full = FALSE; /* Mark buffer empty */
} else { } else {
/* Simple case with no context needed */ /* Simple case with no context needed */
main_->pub.process_data = process_data_simple_main2; mainp->pub.process_data = process_data_simple_main;
mainp->rowgroup_ctr = mainp->rowgroups_avail; /* Mark buffer empty */
} }
main_->buffer_full = FALSE; /* Mark buffer empty */
main_->rowgroup_ctr = 0;
break; break;
#ifdef QUANT_2PASS_SUPPORTED #ifdef QUANT_2PASS_SUPPORTED
case JBUF_CRANK_DEST: case JBUF_CRANK_DEST:
/* For last pass of 2-pass quantization, just crank the postprocessor */ /* For last pass of 2-pass quantization, just crank the postprocessor */
main_->pub.process_data = process_data_crank_post; mainp->pub.process_data = process_data_crank_post;
break; break;
#endif #endif
default: default:
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
break;
} }
} }
@ -342,37 +350,27 @@ start_pass_main2 (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)
*/ */
METHODDEF(void) METHODDEF(void)
process_data_simple_main2 (j_decompress_ptr cinfo, process_data_simple_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
JDIMENSION out_rows_avail)
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
JDIMENSION rowgroups_avail;
/* Read input data if we haven't filled the main buffer yet */ /* Read input data if we haven't filled the main buffer yet */
if (! main_->buffer_full) { if (mainp->rowgroup_ctr >= mainp->rowgroups_avail) {
if (! (*cinfo->coef->decompress_data) (cinfo, main_->buffer)) if (! (*cinfo->coef->decompress_data) (cinfo, mainp->buffer))
return; /* suspension forced, can do nothing more */ return; /* suspension forced, can do nothing more */
main_->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ mainp->rowgroup_ctr = 0; /* OK, we have an iMCU row to work with */
} }
/* There are always min_DCT_scaled_size row groups in an iMCU row. */
rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;
/* Note: at the bottom of the image, we may pass extra garbage row groups /* Note: at the bottom of the image, we may pass extra garbage row groups
* to the postprocessor. The postprocessor has to check for bottom * to the postprocessor. The postprocessor has to check for bottom
* of image anyway (at row resolution), so no point in us doing it too. * of image anyway (at row resolution), so no point in us doing it too.
*/ */
/* Feed the postprocessor */ /* Feed the postprocessor */
(*cinfo->post->post_process_data) (cinfo, main_->buffer, (*cinfo->post->post_process_data) (cinfo, mainp->buffer,
&main_->rowgroup_ctr, rowgroups_avail, &mainp->rowgroup_ctr, mainp->rowgroups_avail,
output_buf, out_row_ctr, out_rows_avail); output_buf, out_row_ctr, out_rows_avail);
/* Has postprocessor consumed all the data yet? If so, mark buffer empty */
if (main_->rowgroup_ctr >= rowgroups_avail) {
main_->buffer_full = FALSE;
main_->rowgroup_ctr = 0;
}
} }
@ -382,19 +380,18 @@ process_data_simple_main2 (j_decompress_ptr cinfo,
*/ */
METHODDEF(void) METHODDEF(void)
process_data_context_main (j_decompress_ptr cinfo, process_data_context_main (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
JDIMENSION out_rows_avail)
{ {
my_main_ptr4 main_ = (my_main_ptr4) cinfo->main; my_main_ptr mainp = (my_main_ptr) cinfo->main;
/* Read input data if we haven't filled the main buffer yet */ /* Read input data if we haven't filled the main buffer yet */
if (! main_->buffer_full) { if (! mainp->buffer_full) {
if (! (*cinfo->coef->decompress_data) (cinfo, if (! (*cinfo->coef->decompress_data) (cinfo,
main_->xbuffer[main_->whichptr])) mainp->xbuffer[mainp->whichptr]))
return; /* suspension forced, can do nothing more */ return; /* suspension forced, can do nothing more */
main_->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ mainp->buffer_full = TRUE; /* OK, we have an iMCU row to work with */
main_->iMCU_row_ctr++; /* count rows received */ mainp->iMCU_row_ctr++; /* count rows received */
} }
/* Postprocessor typically will not swallow all the input data it is handed /* Postprocessor typically will not swallow all the input data it is handed
@ -402,47 +399,47 @@ process_data_context_main (j_decompress_ptr cinfo,
* to exit and restart. This switch lets us keep track of how far we got. * to exit and restart. This switch lets us keep track of how far we got.
* Note that each case falls through to the next on successful completion. * Note that each case falls through to the next on successful completion.
*/ */
switch (main_->context_state) { switch (mainp->context_state) {
case CTX_POSTPONED_ROW: case CTX_POSTPONED_ROW:
/* Call postprocessor using previously set pointers for postponed row */ /* Call postprocessor using previously set pointers for postponed row */
(*cinfo->post->post_process_data) (cinfo, main_->xbuffer[main_->whichptr], (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
&main_->rowgroup_ctr, main_->rowgroups_avail, &mainp->rowgroup_ctr, mainp->rowgroups_avail,
output_buf, out_row_ctr, out_rows_avail); output_buf, out_row_ctr, out_rows_avail);
if (main_->rowgroup_ctr < main_->rowgroups_avail) if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
return; /* Need to suspend */ return; /* Need to suspend */
main_->context_state = CTX_PREPARE_FOR_IMCU; mainp->context_state = CTX_PREPARE_FOR_IMCU;
if (*out_row_ctr >= out_rows_avail) if (*out_row_ctr >= out_rows_avail)
return; /* Postprocessor exactly filled output buf */ return; /* Postprocessor exactly filled output buf */
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case CTX_PREPARE_FOR_IMCU: case CTX_PREPARE_FOR_IMCU:
/* Prepare to process first M-1 row groups of this iMCU row */ /* Prepare to process first M-1 row groups of this iMCU row */
main_->rowgroup_ctr = 0; mainp->rowgroup_ctr = 0;
main_->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size - 1);
/* Check for bottom of image: if so, tweak pointers to "duplicate" /* Check for bottom of image: if so, tweak pointers to "duplicate"
* the last sample row, and adjust rowgroups_avail to ignore padding rows. * the last sample row, and adjust rowgroups_avail to ignore padding rows.
*/ */
if (main_->iMCU_row_ctr == cinfo->total_iMCU_rows) if (mainp->iMCU_row_ctr == cinfo->total_iMCU_rows)
set_bottom_pointers(cinfo); set_bottom_pointers(cinfo);
main_->context_state = CTX_PROCESS_IMCU; mainp->context_state = CTX_PROCESS_IMCU;
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case CTX_PROCESS_IMCU: case CTX_PROCESS_IMCU:
/* Call postprocessor using previously set pointers */ /* Call postprocessor using previously set pointers */
(*cinfo->post->post_process_data) (cinfo, main_->xbuffer[main_->whichptr], (*cinfo->post->post_process_data) (cinfo, mainp->xbuffer[mainp->whichptr],
&main_->rowgroup_ctr, main_->rowgroups_avail, &mainp->rowgroup_ctr, mainp->rowgroups_avail,
output_buf, out_row_ctr, out_rows_avail); output_buf, out_row_ctr, out_rows_avail);
if (main_->rowgroup_ctr < main_->rowgroups_avail) if (mainp->rowgroup_ctr < mainp->rowgroups_avail)
return; /* Need to suspend */ return; /* Need to suspend */
/* After the first iMCU, change wraparound pointers to normal state */ /* After the first iMCU, change wraparound pointers to normal state */
if (main_->iMCU_row_ctr == 1) if (mainp->iMCU_row_ctr == 1)
set_wraparound_pointers(cinfo); set_wraparound_pointers(cinfo);
/* Prepare to load new iMCU row using other xbuffer list */ /* Prepare to load new iMCU row using other xbuffer list */
main_->whichptr ^= 1; /* 0=>1 or 1=>0 */ mainp->whichptr ^= 1; /* 0=>1 or 1=>0 */
main_->buffer_full = FALSE; mainp->buffer_full = FALSE;
/* Still need to process last row group of this iMCU row, */ /* Still need to process last row group of this iMCU row, */
/* which is saved at index M+1 of the other xbuffer */ /* which is saved at index M+1 of the other xbuffer */
main_->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); mainp->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 1);
main_->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); mainp->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_v_scaled_size + 2);
main_->context_state = CTX_POSTPONED_ROW; mainp->context_state = CTX_POSTPONED_ROW;
} }
} }
@ -456,13 +453,12 @@ process_data_context_main (j_decompress_ptr cinfo,
#ifdef QUANT_2PASS_SUPPORTED #ifdef QUANT_2PASS_SUPPORTED
METHODDEF(void) METHODDEF(void)
process_data_crank_post (j_decompress_ptr cinfo, process_data_crank_post (j_decompress_ptr cinfo, JSAMPARRAY output_buf,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)
JDIMENSION out_rows_avail)
{ {
(*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL,
(JDIMENSION *) NULL, (JDIMENSION) 0, (JDIMENSION *) NULL, (JDIMENSION) 0,
output_buf, out_row_ctr, out_rows_avail); output_buf, out_row_ctr, out_rows_avail);
} }
#endif /* QUANT_2PASS_SUPPORTED */ #endif /* QUANT_2PASS_SUPPORTED */
@ -475,15 +471,14 @@ process_data_crank_post (j_decompress_ptr cinfo,
GLOBAL(void) GLOBAL(void)
jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
{ {
my_main_ptr4 main_; my_main_ptr mainp;
int ci, rgroup, ngroups; int ci, rgroup, ngroups;
jpeg_component_info *compptr; jpeg_component_info *compptr;
main_ = (my_main_ptr4) mainp = (my_main_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_main_controller));
SIZEOF(my_main_controller4)); cinfo->main = &mainp->pub;
cinfo->main = (struct jpeg_d_main_controller *) main_; mainp->pub.start_pass = start_pass_main;
main_->pub.start_pass = start_pass_main2;
if (need_full_buffer) /* shouldn't happen */ if (need_full_buffer) /* shouldn't happen */
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
@ -492,21 +487,25 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
* ngroups is the number of row groups we need. * ngroups is the number of row groups we need.
*/ */
if (cinfo->upsample->need_context_rows) { if (cinfo->upsample->need_context_rows) {
if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ if (cinfo->min_DCT_v_scaled_size < 2) /* unsupported, see comments above */
ERREXIT(cinfo, JERR_NOTIMPL); ERREXIT(cinfo, JERR_NOTIMPL);
alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */
ngroups = cinfo->min_DCT_scaled_size + 2; ngroups = cinfo->min_DCT_v_scaled_size + 2;
} else { } else {
ngroups = cinfo->min_DCT_scaled_size; /* There are always min_DCT_v_scaled_size row groups in an iMCU row. */
ngroups = cinfo->min_DCT_v_scaled_size;
mainp->rowgroups_avail = (JDIMENSION) ngroups;
} }
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / if (! compptr->component_needed)
cinfo->min_DCT_scaled_size; /* height of a row group of component */ continue; /* skip uninteresting component */
main_->buffer[ci] = (*cinfo->mem->alloc_sarray) rgroup = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->min_DCT_v_scaled_size; /* height of a row group of component */
compptr->width_in_blocks * compptr->DCT_scaled_size, mainp->buffer[ci] = (*cinfo->mem->alloc_sarray)
(JDIMENSION) (rgroup * ngroups)); ((j_common_ptr) cinfo, JPOOL_IMAGE,
compptr->width_in_blocks * ((JDIMENSION) compptr->DCT_h_scaled_size),
(JDIMENSION) (rgroup * ngroups));
} }
} }

View file

@ -2,6 +2,7 @@
* jdmarker.c * jdmarker.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2009-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -17,6 +18,75 @@
#include "jpeglib.h" #include "jpeglib.h"
typedef enum { /* JPEG marker codes */
M_SOF0 = 0xc0,
M_SOF1 = 0xc1,
M_SOF2 = 0xc2,
M_SOF3 = 0xc3,
M_SOF5 = 0xc5,
M_SOF6 = 0xc6,
M_SOF7 = 0xc7,
M_JPG = 0xc8,
M_SOF9 = 0xc9,
M_SOF10 = 0xca,
M_SOF11 = 0xcb,
M_SOF13 = 0xcd,
M_SOF14 = 0xce,
M_SOF15 = 0xcf,
M_DHT = 0xc4,
M_DAC = 0xcc,
M_RST0 = 0xd0,
M_RST1 = 0xd1,
M_RST2 = 0xd2,
M_RST3 = 0xd3,
M_RST4 = 0xd4,
M_RST5 = 0xd5,
M_RST6 = 0xd6,
M_RST7 = 0xd7,
M_SOI = 0xd8,
M_EOI = 0xd9,
M_SOS = 0xda,
M_DQT = 0xdb,
M_DNL = 0xdc,
M_DRI = 0xdd,
M_DHP = 0xde,
M_EXP = 0xdf,
M_APP0 = 0xe0,
M_APP1 = 0xe1,
M_APP2 = 0xe2,
M_APP3 = 0xe3,
M_APP4 = 0xe4,
M_APP5 = 0xe5,
M_APP6 = 0xe6,
M_APP7 = 0xe7,
M_APP8 = 0xe8,
M_APP9 = 0xe9,
M_APP10 = 0xea,
M_APP11 = 0xeb,
M_APP12 = 0xec,
M_APP13 = 0xed,
M_APP14 = 0xee,
M_APP15 = 0xef,
M_JPG0 = 0xf0,
M_JPG8 = 0xf8,
M_JPG13 = 0xfd,
M_COM = 0xfe,
M_TEM = 0x01,
M_ERROR = 0x100
} JPEG_MARKER;
/* Private state */ /* Private state */
typedef struct { typedef struct {
@ -36,7 +106,7 @@ typedef struct {
/* Note: cur_marker is not linked into marker_list until it's all read. */ /* Note: cur_marker is not linked into marker_list until it's all read. */
} my_marker_reader; } my_marker_reader;
typedef my_marker_reader * my_marker_ptr2; typedef my_marker_reader * my_marker_ptr;
/* /*
@ -130,7 +200,7 @@ get_soi (j_decompress_ptr cinfo)
/* Process an SOI marker */ /* Process an SOI marker */
{ {
int i; int i;
TRACEMS(cinfo, 1, JTRC_SOI); TRACEMS(cinfo, 1, JTRC_SOI);
if (cinfo->marker->saw_SOI) if (cinfo->marker->saw_SOI)
@ -148,6 +218,7 @@ get_soi (j_decompress_ptr cinfo)
/* Set initial assumptions for colorspace etc */ /* Set initial assumptions for colorspace etc */
cinfo->jpeg_color_space = JCS_UNKNOWN; cinfo->jpeg_color_space = JCS_UNKNOWN;
cinfo->color_transform = JCT_NONE;
cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
cinfo->saw_JFIF_marker = FALSE; cinfo->saw_JFIF_marker = FALSE;
@ -166,14 +237,16 @@ get_soi (j_decompress_ptr cinfo)
LOCAL(boolean) LOCAL(boolean)
get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) get_sof (j_decompress_ptr cinfo, boolean is_baseline, boolean is_prog,
boolean is_arith)
/* Process a SOFn marker */ /* Process a SOFn marker */
{ {
INT32 length; INT32 length;
int c, ci; int c, ci, i;
jpeg_component_info * compptr; jpeg_component_info * compptr;
INPUT_VARS(cinfo); INPUT_VARS(cinfo);
cinfo->is_baseline = is_baseline;
cinfo->progressive_mode = is_prog; cinfo->progressive_mode = is_prog;
cinfo->arith_code = is_arith; cinfo->arith_code = is_arith;
@ -196,8 +269,8 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
/* We don't support files in which the image height is initially specified */ /* We don't support files in which the image height is initially specified */
/* as 0 and is later redefined by DNL. As long as we have to check that, */ /* as 0 and is later redefined by DNL. As long as we have to check that, */
/* might as well have a general sanity check. */ /* might as well have a general sanity check. */
if (cinfo->image_height <= 0 || cinfo->image_width <= 0 if (cinfo->image_height <= 0 || cinfo->image_width <= 0 ||
|| cinfo->num_components <= 0) cinfo->num_components <= 0)
ERREXIT(cinfo, JERR_EMPTY_IMAGE); ERREXIT(cinfo, JERR_EMPTY_IMAGE);
if (length != (cinfo->num_components * 3)) if (length != (cinfo->num_components * 3))
@ -208,10 +281,26 @@ get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components * SIZEOF(jpeg_component_info)); cinfo->num_components * SIZEOF(jpeg_component_info));
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0; ci < cinfo->num_components; ci++) {
ci++, compptr++) { INPUT_BYTE(cinfo, c, return FALSE);
/* Check to see whether component id has already been seen */
/* (in violation of the spec, but unfortunately seen in some */
/* files). If so, create "fake" component id equal to the */
/* max id seen so far + 1. */
for (i = 0, compptr = cinfo->comp_info; i < ci; i++, compptr++) {
if (c == compptr->component_id) {
compptr = cinfo->comp_info;
c = compptr->component_id;
compptr++;
for (i = 1; i < ci; i++, compptr++) {
if (compptr->component_id > c) c = compptr->component_id;
}
c++;
break;
}
}
compptr->component_id = c;
compptr->component_index = ci; compptr->component_index = ci;
INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
INPUT_BYTE(cinfo, c, return FALSE); INPUT_BYTE(cinfo, c, return FALSE);
compptr->h_samp_factor = (c >> 4) & 15; compptr->h_samp_factor = (c >> 4) & 15;
compptr->v_samp_factor = (c ) & 15; compptr->v_samp_factor = (c ) & 15;
@ -234,12 +323,12 @@ get_sos (j_decompress_ptr cinfo)
/* Process a SOS marker */ /* Process a SOS marker */
{ {
INT32 length; INT32 length;
int i, ci, n, c, cc; int c, ci, i, n;
jpeg_component_info * compptr; jpeg_component_info * compptr;
INPUT_VARS(cinfo); INPUT_VARS(cinfo);
if (! cinfo->marker->saw_SOF) if (! cinfo->marker->saw_SOF)
ERREXIT(cinfo, JERR_SOS_NO_SOF); ERREXITS(cinfo, JERR_SOF_BEFORE, "SOS");
INPUT_2BYTES(cinfo, length, return FALSE); INPUT_2BYTES(cinfo, length, return FALSE);
@ -247,7 +336,9 @@ get_sos (j_decompress_ptr cinfo)
TRACEMS1(cinfo, 1, JTRC_SOS, n); TRACEMS1(cinfo, 1, JTRC_SOS, n);
if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) if (length != (n * 2 + 6) || n > MAX_COMPS_IN_SCAN ||
(n == 0 && !cinfo->progressive_mode))
/* pseudo SOS marker only allowed in progressive mode */
ERREXIT(cinfo, JERR_BAD_LENGTH); ERREXIT(cinfo, JERR_BAD_LENGTH);
cinfo->comps_in_scan = n; cinfo->comps_in_scan = n;
@ -255,24 +346,41 @@ get_sos (j_decompress_ptr cinfo)
/* Collect the component-spec parameters */ /* Collect the component-spec parameters */
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
INPUT_BYTE(cinfo, cc, return FALSE);
INPUT_BYTE(cinfo, c, return FALSE); INPUT_BYTE(cinfo, c, return FALSE);
/* Detect the case where component id's are not unique, and, if so, */
/* create a fake component id using the same logic as in get_sof. */
/* Note: This also ensures that all of the SOF components are */
/* referenced in the single scan case, which prevents access to */
/* uninitialized memory in later decoding stages. */
for (ci = 0; ci < i; ci++) {
if (c == cinfo->cur_comp_info[ci]->component_id) {
c = cinfo->cur_comp_info[0]->component_id;
for (ci = 1; ci < i; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (compptr->component_id > c) c = compptr->component_id;
}
c++;
break;
}
}
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
if (cc == compptr->component_id) if (c == compptr->component_id)
goto id_found; goto id_found;
} }
ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, c);
id_found: id_found:
cinfo->cur_comp_info[i] = compptr; cinfo->cur_comp_info[i] = compptr;
INPUT_BYTE(cinfo, c, return FALSE);
compptr->dc_tbl_no = (c >> 4) & 15; compptr->dc_tbl_no = (c >> 4) & 15;
compptr->ac_tbl_no = (c ) & 15; compptr->ac_tbl_no = (c ) & 15;
TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, compptr->component_id,
compptr->dc_tbl_no, compptr->ac_tbl_no); compptr->dc_tbl_no, compptr->ac_tbl_no);
} }
@ -291,8 +399,8 @@ get_sos (j_decompress_ptr cinfo)
/* Prepare to scan data & restart markers */ /* Prepare to scan data & restart markers */
cinfo->marker->next_restart_num = 0; cinfo->marker->next_restart_num = 0;
/* Count another SOS marker */ /* Count another (non-pseudo) SOS marker */
cinfo->input_scan_number++; if (n) cinfo->input_scan_number++;
INPUT_SYNC(cinfo); INPUT_SYNC(cinfo);
return TRUE; return TRUE;
@ -311,7 +419,7 @@ get_dac (j_decompress_ptr cinfo)
INPUT_2BYTES(cinfo, length, return FALSE); INPUT_2BYTES(cinfo, length, return FALSE);
length -= 2; length -= 2;
while (length > 0) { while (length > 0) {
INPUT_BYTE(cinfo, index, return FALSE); INPUT_BYTE(cinfo, index, return FALSE);
INPUT_BYTE(cinfo, val, return FALSE); INPUT_BYTE(cinfo, val, return FALSE);
@ -360,12 +468,12 @@ get_dht (j_decompress_ptr cinfo)
INPUT_2BYTES(cinfo, length, return FALSE); INPUT_2BYTES(cinfo, length, return FALSE);
length -= 2; length -= 2;
while (length > 16) { while (length > 16) {
INPUT_BYTE(cinfo, index, return FALSE); INPUT_BYTE(cinfo, index, return FALSE);
TRACEMS1(cinfo, 1, JTRC_DHT, index); TRACEMS1(cinfo, 1, JTRC_DHT, index);
bits[0] = 0; bits[0] = 0;
count = 0; count = 0;
for (i = 1; i <= 16; i++) { for (i = 1; i <= 16; i++) {
@ -405,9 +513,10 @@ get_dht (j_decompress_ptr cinfo)
if (*htblptr == NULL) if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); if (count > 0)
MEMCOPY((*htblptr)->huffval, huffval, count * SIZEOF(UINT8));
} }
if (length != 0) if (length != 0)
@ -422,16 +531,18 @@ LOCAL(boolean)
get_dqt (j_decompress_ptr cinfo) get_dqt (j_decompress_ptr cinfo)
/* Process a DQT marker */ /* Process a DQT marker */
{ {
INT32 length; INT32 length, count, i;
int n, i, prec; int n, prec;
unsigned int tmp; unsigned int tmp;
JQUANT_TBL *quant_ptr; JQUANT_TBL *quant_ptr;
const int *natural_order;
INPUT_VARS(cinfo); INPUT_VARS(cinfo);
INPUT_2BYTES(cinfo, length, return FALSE); INPUT_2BYTES(cinfo, length, return FALSE);
length -= 2; length -= 2;
while (length > 0) { while (length > 0) {
length--;
INPUT_BYTE(cinfo, n, return FALSE); INPUT_BYTE(cinfo, n, return FALSE);
prec = n >> 4; prec = n >> 4;
n &= 0x0F; n &= 0x0F;
@ -440,18 +551,48 @@ get_dqt (j_decompress_ptr cinfo)
if (n >= NUM_QUANT_TBLS) if (n >= NUM_QUANT_TBLS)
ERREXIT1(cinfo, JERR_DQT_INDEX, n); ERREXIT1(cinfo, JERR_DQT_INDEX, n);
if (cinfo->quant_tbl_ptrs[n] == NULL) if (cinfo->quant_tbl_ptrs[n] == NULL)
cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
quant_ptr = cinfo->quant_tbl_ptrs[n]; quant_ptr = cinfo->quant_tbl_ptrs[n];
for (i = 0; i < DCTSIZE2; i++) { if (prec) {
if (length < DCTSIZE2 * 2) {
/* Initialize full table for safety. */
for (i = 0; i < DCTSIZE2; i++) {
quant_ptr->quantval[i] = 1;
}
count = length >> 1;
} else
count = DCTSIZE2;
} else {
if (length < DCTSIZE2) {
/* Initialize full table for safety. */
for (i = 0; i < DCTSIZE2; i++) {
quant_ptr->quantval[i] = 1;
}
count = length;
} else
count = DCTSIZE2;
}
switch ((int) count) {
case (2*2): natural_order = jpeg_natural_order2; break;
case (3*3): natural_order = jpeg_natural_order3; break;
case (4*4): natural_order = jpeg_natural_order4; break;
case (5*5): natural_order = jpeg_natural_order5; break;
case (6*6): natural_order = jpeg_natural_order6; break;
case (7*7): natural_order = jpeg_natural_order7; break;
default: natural_order = jpeg_natural_order;
}
for (i = 0; i < count; i++) {
if (prec) if (prec)
INPUT_2BYTES(cinfo, tmp, return FALSE); INPUT_2BYTES(cinfo, tmp, return FALSE);
else else
INPUT_BYTE(cinfo, tmp, return FALSE); INPUT_BYTE(cinfo, tmp, return FALSE);
/* We convert the zigzag-order table to natural array order. */ /* We convert the zigzag-order table to natural array order. */
quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; quant_ptr->quantval[natural_order[i]] = (UINT16) tmp;
} }
if (cinfo->err->trace_level >= 2) { if (cinfo->err->trace_level >= 2) {
@ -464,8 +605,8 @@ get_dqt (j_decompress_ptr cinfo)
} }
} }
length -= DCTSIZE2+1; length -= count;
if (prec) length -= DCTSIZE2; if (prec) length -= count;
} }
if (length != 0) if (length != 0)
@ -485,7 +626,7 @@ get_dri (j_decompress_ptr cinfo)
INPUT_VARS(cinfo); INPUT_VARS(cinfo);
INPUT_2BYTES(cinfo, length, return FALSE); INPUT_2BYTES(cinfo, length, return FALSE);
if (length != 4) if (length != 4)
ERREXIT(cinfo, JERR_BAD_LENGTH); ERREXIT(cinfo, JERR_BAD_LENGTH);
@ -500,6 +641,68 @@ get_dri (j_decompress_ptr cinfo)
} }
LOCAL(boolean)
get_lse (j_decompress_ptr cinfo)
/* Process an LSE marker */
{
INT32 length;
unsigned int tmp;
int cid;
INPUT_VARS(cinfo);
if (! cinfo->marker->saw_SOF)
ERREXITS(cinfo, JERR_SOF_BEFORE, "LSE");
if (cinfo->num_components < 3) goto bad;
INPUT_2BYTES(cinfo, length, return FALSE);
if (length != 24)
ERREXIT(cinfo, JERR_BAD_LENGTH);
INPUT_BYTE(cinfo, tmp, return FALSE);
if (tmp != 0x0D) /* ID inverse transform specification */
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != MAXJSAMPLE) goto bad; /* MAXTRANS */
INPUT_BYTE(cinfo, tmp, return FALSE);
if (tmp != 3) goto bad; /* Nt=3 */
INPUT_BYTE(cinfo, cid, return FALSE);
if (cid != cinfo->comp_info[1].component_id) goto bad;
INPUT_BYTE(cinfo, cid, return FALSE);
if (cid != cinfo->comp_info[0].component_id) goto bad;
INPUT_BYTE(cinfo, cid, return FALSE);
if (cid != cinfo->comp_info[2].component_id) goto bad;
INPUT_BYTE(cinfo, tmp, return FALSE);
if (tmp != 0x80) goto bad; /* F1: CENTER1=1, NORM1=0 */
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != 0) goto bad; /* A(1,1)=0 */
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != 0) goto bad; /* A(1,2)=0 */
INPUT_BYTE(cinfo, tmp, return FALSE);
if (tmp != 0) goto bad; /* F2: CENTER2=0, NORM2=0 */
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != 1) goto bad; /* A(2,1)=1 */
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != 0) goto bad; /* A(2,2)=0 */
INPUT_BYTE(cinfo, tmp, return FALSE);
if (tmp != 0) goto bad; /* F3: CENTER3=0, NORM3=0 */
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != 1) goto bad; /* A(3,1)=1 */
INPUT_2BYTES(cinfo, tmp, return FALSE);
if (tmp != 0) { /* A(3,2)=0 */
bad:
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
}
/* OK, valid transform that we can handle. */
cinfo->color_transform = JCT_SUBTRACT_GREEN;
INPUT_SYNC(cinfo);
return TRUE;
}
/* /*
* Routines for processing APPn and COM markers. * Routines for processing APPn and COM markers.
* These are either saved in memory or discarded, per application request. * These are either saved in memory or discarded, per application request.
@ -536,12 +739,13 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
/* Check version. /* Check version.
* Major version must be 1, anything else signals an incompatible change. * Major version must be 1 or 2, anything else signals an incompatible
* change.
* (We used to treat this as an error, but now it's a nonfatal warning, * (We used to treat this as an error, but now it's a nonfatal warning,
* because some bozo at Hijaak couldn't read the spec.) * because some bozo at Hijaak couldn't read the spec.)
* Minor version should be 0..2, but process anyway if newer. * Minor version should be 0..2, but process anyway if newer.
*/ */
if (cinfo->JFIF_major_version != 1) if (cinfo->JFIF_major_version != 1 && cinfo->JFIF_major_version != 2)
WARNMS2(cinfo, JWRN_JFIF_MAJOR, WARNMS2(cinfo, JWRN_JFIF_MAJOR,
cinfo->JFIF_major_version, cinfo->JFIF_minor_version); cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
/* Generate trace messages */ /* Generate trace messages */
@ -579,7 +783,6 @@ examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
default: default:
TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
GETJOCTET(data[5]), (int) totallen); GETJOCTET(data[5]), (int) totallen);
break;
} }
} else { } else {
/* Start of APP0 does not match "JFIF" or "JFXX", or too short */ /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
@ -653,7 +856,6 @@ get_interesting_appn (j_decompress_ptr cinfo)
default: default:
/* can't get here unless jpeg_save_markers chooses wrong processor */ /* can't get here unless jpeg_save_markers chooses wrong processor */
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
break;
} }
/* skip any remaining data -- could be lots */ /* skip any remaining data -- could be lots */
@ -671,7 +873,7 @@ METHODDEF(boolean)
save_marker (j_decompress_ptr cinfo) save_marker (j_decompress_ptr cinfo)
/* Save an APPn or COM marker into the marker list */ /* Save an APPn or COM marker into the marker list */
{ {
my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker; my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
jpeg_saved_marker_ptr cur_marker = marker->cur_marker; jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
unsigned int bytes_read, data_length; unsigned int bytes_read, data_length;
JOCTET FAR * data; JOCTET FAR * data;
@ -759,7 +961,6 @@ save_marker (j_decompress_ptr cinfo)
default: default:
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
(int) (data_length + length)); (int) (data_length + length));
break;
} }
/* skip any remaining data -- could be lots */ /* skip any remaining data -- could be lots */
@ -782,7 +983,7 @@ skip_variable (j_decompress_ptr cinfo)
INPUT_2BYTES(cinfo, length, return FALSE); INPUT_2BYTES(cinfo, length, return FALSE);
length -= 2; length -= 2;
TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
INPUT_SYNC(cinfo); /* do before skip_input_data */ INPUT_SYNC(cinfo); /* do before skip_input_data */
@ -878,6 +1079,11 @@ first_marker (j_decompress_ptr cinfo)
* *
* Returns same codes as are defined for jpeg_consume_input: * Returns same codes as are defined for jpeg_consume_input:
* JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
*
* Note: This function may return a pseudo SOS marker (with zero
* component number) for treat by input controller's consume_input.
* consume_input itself should filter out (skip) the pseudo marker
* after processing for the caller.
*/ */
METHODDEF(int) METHODDEF(int)
@ -907,23 +1113,27 @@ read_markers (j_decompress_ptr cinfo)
break; break;
case M_SOF0: /* Baseline */ case M_SOF0: /* Baseline */
if (! get_sof(cinfo, TRUE, FALSE, FALSE))
return JPEG_SUSPENDED;
break;
case M_SOF1: /* Extended sequential, Huffman */ case M_SOF1: /* Extended sequential, Huffman */
if (! get_sof(cinfo, FALSE, FALSE)) if (! get_sof(cinfo, FALSE, FALSE, FALSE))
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
case M_SOF2: /* Progressive, Huffman */ case M_SOF2: /* Progressive, Huffman */
if (! get_sof(cinfo, TRUE, FALSE)) if (! get_sof(cinfo, FALSE, TRUE, FALSE))
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
case M_SOF9: /* Extended sequential, arithmetic */ case M_SOF9: /* Extended sequential, arithmetic */
if (! get_sof(cinfo, FALSE, TRUE)) if (! get_sof(cinfo, FALSE, FALSE, TRUE))
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
case M_SOF10: /* Progressive, arithmetic */ case M_SOF10: /* Progressive, arithmetic */
if (! get_sof(cinfo, TRUE, TRUE)) if (! get_sof(cinfo, FALSE, TRUE, TRUE))
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
@ -971,6 +1181,11 @@ read_markers (j_decompress_ptr cinfo)
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
case M_JPG8:
if (! get_lse(cinfo))
return JPEG_SUSPENDED;
break;
case M_APP0: case M_APP0:
case M_APP1: case M_APP1:
case M_APP2: case M_APP2:
@ -987,13 +1202,13 @@ read_markers (j_decompress_ptr cinfo)
case M_APP13: case M_APP13:
case M_APP14: case M_APP14:
case M_APP15: case M_APP15:
if (! (*((my_marker_ptr2) cinfo->marker)->process_APPn[ if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[
cinfo->unread_marker - (int) M_APP0]) (cinfo)) cinfo->unread_marker - (int) M_APP0]) (cinfo))
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
case M_COM: case M_COM:
if (! (*((my_marker_ptr2) cinfo->marker)->process_COM) (cinfo)) if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
return JPEG_SUSPENDED; return JPEG_SUSPENDED;
break; break;
@ -1021,7 +1236,6 @@ read_markers (j_decompress_ptr cinfo)
* ought to change! * ought to change!
*/ */
ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
break;
} }
/* Successfully processed marker, so reset state variable */ /* Successfully processed marker, so reset state variable */
cinfo->unread_marker = 0; cinfo->unread_marker = 0;
@ -1125,10 +1339,10 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
{ {
int marker = cinfo->unread_marker; int marker = cinfo->unread_marker;
int action = 1; int action = 1;
/* Always put up a warning. */ /* Always put up a warning. */
WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
/* Outer loop handles repeated decision after scanning forward. */ /* Outer loop handles repeated decision after scanning forward. */
for (;;) { for (;;) {
if (marker < (int) M_SOF0) if (marker < (int) M_SOF0)
@ -1173,7 +1387,7 @@ jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
METHODDEF(void) METHODDEF(void)
reset_marker_reader (j_decompress_ptr cinfo) reset_marker_reader (j_decompress_ptr cinfo)
{ {
my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker; my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
cinfo->comp_info = NULL; /* until allocated by get_sof */ cinfo->comp_info = NULL; /* until allocated by get_sof */
cinfo->input_scan_number = 0; /* no SOS seen yet */ cinfo->input_scan_number = 0; /* no SOS seen yet */
@ -1193,14 +1407,13 @@ reset_marker_reader (j_decompress_ptr cinfo)
GLOBAL(void) GLOBAL(void)
jinit_marker_reader (j_decompress_ptr cinfo) jinit_marker_reader (j_decompress_ptr cinfo)
{ {
my_marker_ptr2 marker; my_marker_ptr marker;
int i; int i;
/* Create subobject in permanent pool */ /* Create subobject in permanent pool */
marker = (my_marker_ptr2) marker = (my_marker_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, ((j_common_ptr) cinfo, JPOOL_PERMANENT, SIZEOF(my_marker_reader));
SIZEOF(my_marker_reader)); cinfo->marker = &marker->pub;
cinfo->marker = (struct jpeg_marker_reader *) marker;
/* Initialize public method pointers */ /* Initialize public method pointers */
marker->pub.reset_marker_reader = reset_marker_reader; marker->pub.reset_marker_reader = reset_marker_reader;
marker->pub.read_markers = read_markers; marker->pub.read_markers = read_markers;
@ -1232,7 +1445,7 @@ GLOBAL(void)
jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
unsigned int length_limit) unsigned int length_limit)
{ {
my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker; my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
long maxlength; long maxlength;
jpeg_marker_parser_method processor; jpeg_marker_parser_method processor;
@ -1281,7 +1494,7 @@ GLOBAL(void)
jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,
jpeg_marker_parser_method routine) jpeg_marker_parser_method routine)
{ {
my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker; my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
if (marker_code == (int) M_COM) if (marker_code == (int) M_COM)
marker->process_COM = routine; marker->process_COM = routine;

View file

@ -2,6 +2,7 @@
* jdmaster.c * jdmaster.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2002-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -32,7 +33,7 @@ typedef struct {
struct jpeg_color_quantizer * quantizer_2pass; struct jpeg_color_quantizer * quantizer_2pass;
} my_decomp_master; } my_decomp_master;
typedef my_decomp_master * my_master_ptr6; typedef my_decomp_master * my_master_ptr;
/* /*
@ -44,13 +45,26 @@ LOCAL(boolean)
use_merged_upsample (j_decompress_ptr cinfo) use_merged_upsample (j_decompress_ptr cinfo)
{ {
#ifdef UPSAMPLE_MERGING_SUPPORTED #ifdef UPSAMPLE_MERGING_SUPPORTED
/* Merging is the equivalent of plain box-filter upsampling */ /* Merging is the equivalent of plain box-filter upsampling. */
if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) /* The following condition is only needed if fancy shall select
* a different upsampling method. In our current implementation
* fancy only affects the DCT scaling, thus we can use fancy
* upsampling and merged upsample simultaneously, in particular
* with scaled DCT sizes larger than the default DCTSIZE.
*/
#if 0
if (cinfo->do_fancy_upsampling)
return FALSE;
#endif
if (cinfo->CCIR601_sampling)
return FALSE; return FALSE;
/* jdmerge.c only supports YCC=>RGB color conversion */ /* jdmerge.c only supports YCC=>RGB color conversion */
if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || if ((cinfo->jpeg_color_space != JCS_YCbCr &&
cinfo->jpeg_color_space != JCS_BG_YCC) ||
cinfo->num_components != 3 ||
cinfo->out_color_space != JCS_RGB || cinfo->out_color_space != JCS_RGB ||
cinfo->out_color_components != RGB_PIXELSIZE) cinfo->out_color_components != RGB_PIXELSIZE ||
cinfo->color_transform)
return FALSE; return FALSE;
/* and it only handles 2h1v or 2h2v sampling ratios */ /* and it only handles 2h1v or 2h2v sampling ratios */
if (cinfo->comp_info[0].h_samp_factor != 2 || if (cinfo->comp_info[0].h_samp_factor != 2 ||
@ -61,9 +75,12 @@ use_merged_upsample (j_decompress_ptr cinfo)
cinfo->comp_info[2].v_samp_factor != 1) cinfo->comp_info[2].v_samp_factor != 1)
return FALSE; return FALSE;
/* furthermore, it doesn't work if we've scaled the IDCTs differently */ /* furthermore, it doesn't work if we've scaled the IDCTs differently */
if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
cinfo->comp_info[0].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
cinfo->comp_info[1].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
cinfo->comp_info[2].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size)
return FALSE; return FALSE;
/* ??? also need to test for upsample-time rescaling, when & if supported */ /* ??? also need to test for upsample-time rescaling, when & if supported */
return TRUE; /* by golly, it'll work... */ return TRUE; /* by golly, it'll work... */
@ -82,113 +99,87 @@ use_merged_upsample (j_decompress_ptr cinfo)
GLOBAL(void) GLOBAL(void)
jpeg_calc_output_dimensions (j_decompress_ptr cinfo) jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
/* Do computations that are needed before master selection phase */ /* Do computations that are needed before master selection phase.
* This function is used for full decompression.
*/
{ {
#ifdef IDCT_SCALING_SUPPORTED int ci, i;
int ci;
jpeg_component_info *compptr; jpeg_component_info *compptr;
#endif
/* Prevent application from calling me at wrong times */ /* Prevent application from calling me at wrong times */
if (cinfo->global_state != DSTATE_READY) if (cinfo->global_state != DSTATE_READY)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Compute core output image dimensions and DCT scaling choices. */
jpeg_core_output_dimensions(cinfo);
#ifdef IDCT_SCALING_SUPPORTED #ifdef IDCT_SCALING_SUPPORTED
/* Compute actual output image dimensions and DCT scaling choices. */
if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
/* Provide 1/8 scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, 8L);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, 8L);
cinfo->min_DCT_scaled_size = 1;
} else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
/* Provide 1/4 scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, 4L);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, 4L);
cinfo->min_DCT_scaled_size = 2;
} else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
/* Provide 1/2 scaling */
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, 2L);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, 2L);
cinfo->min_DCT_scaled_size = 4;
} else {
/* Provide 1/1 scaling */
cinfo->output_width = cinfo->image_width;
cinfo->output_height = cinfo->image_height;
cinfo->min_DCT_scaled_size = DCTSIZE;
}
/* In selecting the actual DCT scaling for each component, we try to /* In selecting the actual DCT scaling for each component, we try to
* scale up the chroma components via IDCT scaling rather than upsampling. * scale up the chroma components via IDCT scaling rather than upsampling.
* This saves time if the upsampler gets to use 1:1 scaling. * This saves time if the upsampler gets to use 1:1 scaling.
* Note this code assumes that the supported DCT scalings are powers of 2. * Note this code adapts subsampling ratios which are powers of 2.
*/ */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
int ssize = cinfo->min_DCT_scaled_size; int ssize = 1;
while (ssize < DCTSIZE && if (! cinfo->raw_data_out)
(compptr->h_samp_factor * ssize * 2 <= while (cinfo->min_DCT_h_scaled_size * ssize <=
cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
(compptr->v_samp_factor * ssize * 2 <= (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) ==
cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { 0) {
ssize = ssize * 2; ssize = ssize * 2;
} }
compptr->DCT_scaled_size = ssize; compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
} ssize = 1;
if (! cinfo->raw_data_out)
while (cinfo->min_DCT_v_scaled_size * ssize <=
(cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
(cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) ==
0) {
ssize = ssize * 2;
}
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
/* Recompute downsampled dimensions of components; /* We don't support IDCT ratios larger than 2. */
* application needs to know these if using raw downsampled data. if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2)
*/ compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
ci++, compptr++) { compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
/* Recompute downsampled dimensions of components;
* application needs to know these if using raw downsampled data.
*/
/* Size in samples, after IDCT scaling */ /* Size in samples, after IDCT scaling */
compptr->downsampled_width = (JDIMENSION) compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * jdiv_round_up((long) cinfo->image_width *
(long) (compptr->h_samp_factor * compptr->DCT_scaled_size), (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size),
(long) (cinfo->max_h_samp_factor * DCTSIZE)); (long) (cinfo->max_h_samp_factor * cinfo->block_size));
compptr->downsampled_height = (JDIMENSION) compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * jdiv_round_up((long) cinfo->image_height *
(long) (compptr->v_samp_factor * compptr->DCT_scaled_size), (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
(long) (cinfo->max_v_samp_factor * DCTSIZE)); (long) (cinfo->max_v_samp_factor * cinfo->block_size));
} }
#else /* !IDCT_SCALING_SUPPORTED */
/* Hardwire it to "no scaling" */
cinfo->output_width = cinfo->image_width;
cinfo->output_height = cinfo->image_height;
/* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
* and has computed unscaled downsampled_width and downsampled_height.
*/
#endif /* IDCT_SCALING_SUPPORTED */ #endif /* IDCT_SCALING_SUPPORTED */
/* Report number of components in selected colorspace. */ /* Report number of components in selected colorspace. */
/* Probably this should be in the color conversion module... */ /* This should correspond to the actual code in the color conversion module. */
switch (cinfo->out_color_space) { switch (cinfo->out_color_space) {
case JCS_GRAYSCALE: case JCS_GRAYSCALE:
cinfo->out_color_components = 1; cinfo->out_color_components = 1;
break; break;
case JCS_RGB: case JCS_RGB:
#if RGB_PIXELSIZE != 3 case JCS_BG_RGB:
cinfo->out_color_components = RGB_PIXELSIZE; cinfo->out_color_components = RGB_PIXELSIZE;
break; break;
#endif /* else share code with YCbCr */ default: /* YCCK <=> CMYK conversion or same colorspace as in file */
case JCS_YCbCr: i = 0;
cinfo->out_color_components = 3; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
break; ci++, compptr++)
case JCS_CMYK: if (compptr->component_needed)
case JCS_YCCK: i++; /* count output color components */
cinfo->out_color_components = 4; cinfo->out_color_components = i;
break;
default: /* else must be same colorspace as in file */
cinfo->out_color_components = cinfo->num_components;
break;
} }
cinfo->output_components = (cinfo->quantize_colors ? 1 : cinfo->output_components = (cinfo->quantize_colors ? 1 :
cinfo->out_color_components); cinfo->out_color_components);
@ -215,30 +206,20 @@ jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
* These processes all use a common table prepared by the routine below. * These processes all use a common table prepared by the routine below.
* *
* For most steps we can mathematically guarantee that the initial value * For most steps we can mathematically guarantee that the initial value
* of x is within MAXJSAMPLE+1 of the legal range, so a table running from * of x is within 2*(MAXJSAMPLE+1) of the legal range, so a table running
* -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial * from -2*(MAXJSAMPLE+1) to 3*MAXJSAMPLE+2 is sufficient. But for the
* limiting step (just after the IDCT), a wildly out-of-range value is * initial limiting step (just after the IDCT), a wildly out-of-range value
* possible if the input data is corrupt. To avoid any chance of indexing * is possible if the input data is corrupt. To avoid any chance of indexing
* off the end of memory and getting a bad-pointer trap, we perform the * off the end of memory and getting a bad-pointer trap, we perform the
* post-IDCT limiting thus: * post-IDCT limiting thus:
* x = range_limit[x & MASK]; * x = (sample_range_limit - SUBSET)[(x + CENTER) & MASK];
* where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
* samples. Under normal circumstances this is more than enough range and * samples. Under normal circumstances this is more than enough range and
* a correct output will be generated; with bogus input data the mask will * a correct output will be generated; with bogus input data the mask will
* cause wraparound, and we will safely generate a bogus-but-in-range output. * cause wraparound, and we will safely generate a bogus-but-in-range output.
* For the post-IDCT step, we want to convert the data from signed to unsigned * For the post-IDCT step, we want to convert the data from signed to unsigned
* representation by adding CENTERJSAMPLE at the same time that we limit it. * representation by adding CENTERJSAMPLE at the same time that we limit it.
* So the post-IDCT limiting table ends up looking like this: * This is accomplished with SUBSET = CENTER - CENTERJSAMPLE.
* CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
* MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
* 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
* 0,1,...,CENTERJSAMPLE-1
* Negative inputs select values from the upper half of the table after
* masking.
*
* We can save some space by overlapping the start of the post-IDCT table
* with the simpler range limiting table. The post-IDCT table begins at
* sample_range_limit + CENTERJSAMPLE.
* *
* Note that the table is allocated in near data space on PCs; it's small * Note that the table is allocated in near data space on PCs; it's small
* enough and used often enough to justify this. * enough and used often enough to justify this.
@ -251,25 +232,18 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
JSAMPLE * table; JSAMPLE * table;
int i; int i;
table = (JSAMPLE *) table = (JSAMPLE *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo,
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, JPOOL_IMAGE, (RANGE_CENTER * 2 + MAXJSAMPLE + 1) * SIZEOF(JSAMPLE));
(5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); /* First segment of range limit table: limit[x] = 0 for x < 0 */
table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ MEMZERO(table, RANGE_CENTER * SIZEOF(JSAMPLE));
table += RANGE_CENTER; /* allow negative subscripts of table */
cinfo->sample_range_limit = table; cinfo->sample_range_limit = table;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */ /* Main part of range limit table: limit[x] = x */
MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
/* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++) for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE) i; table[i] = (JSAMPLE) i;
table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ /* End of range limit table: limit[x] = MAXJSAMPLE for x > MAXJSAMPLE */
/* End of simple table, rest of first half of post-IDCT table */ for (; i <= MAXJSAMPLE + RANGE_CENTER; i++)
for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
table[i] = MAXJSAMPLE; table[i] = MAXJSAMPLE;
/* Second half of post-IDCT table */
MEMZERO(table + (2 * (MAXJSAMPLE+1)),
(2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
} }
@ -287,15 +261,24 @@ prepare_range_limit_table (j_decompress_ptr cinfo)
LOCAL(void) LOCAL(void)
master_selection (j_decompress_ptr cinfo) master_selection (j_decompress_ptr cinfo)
{ {
my_master_ptr6 master = (my_master_ptr6) cinfo->master; my_master_ptr master = (my_master_ptr) cinfo->master;
boolean use_c_buffer; boolean use_c_buffer;
long samplesperrow; long samplesperrow;
JDIMENSION jd_samplesperrow; JDIMENSION jd_samplesperrow;
/* For now, precision must match compiled-in value... */
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
/* Initialize dimensions and other stuff */ /* Initialize dimensions and other stuff */
jpeg_calc_output_dimensions(cinfo); jpeg_calc_output_dimensions(cinfo);
prepare_range_limit_table(cinfo); prepare_range_limit_table(cinfo);
/* Sanity check on image dimensions */
if (cinfo->output_height <= 0 || cinfo->output_width <= 0 ||
cinfo->out_color_components <= 0)
ERREXIT(cinfo, JERR_EMPTY_IMAGE);
/* Width of an output scanline must be representable as JDIMENSION. */ /* Width of an output scanline must be representable as JDIMENSION. */
samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
jd_samplesperrow = (JDIMENSION) samplesperrow; jd_samplesperrow = (JDIMENSION) samplesperrow;
@ -372,17 +355,10 @@ master_selection (j_decompress_ptr cinfo)
/* Inverse DCT */ /* Inverse DCT */
jinit_inverse_dct(cinfo); jinit_inverse_dct(cinfo);
/* Entropy decoding: either Huffman or arithmetic coding. */ /* Entropy decoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code)
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); jinit_arith_decoder(cinfo);
} else { else {
if (cinfo->progressive_mode) { jinit_huff_decoder(cinfo);
#ifdef D_PROGRESSIVE_SUPPORTED
jinit_phuff_decoder(cinfo);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else
jinit_huff_decoder(cinfo);
} }
/* Initialize principal buffer controllers. */ /* Initialize principal buffer controllers. */
@ -437,7 +413,7 @@ master_selection (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
prepare_for_output_pass (j_decompress_ptr cinfo) prepare_for_output_pass (j_decompress_ptr cinfo)
{ {
my_master_ptr6 master = (my_master_ptr6) cinfo->master; my_master_ptr master = (my_master_ptr) cinfo->master;
if (master->pub.is_dummy_pass) { if (master->pub.is_dummy_pass) {
#ifdef QUANT_2PASS_SUPPORTED #ifdef QUANT_2PASS_SUPPORTED
@ -497,7 +473,7 @@ prepare_for_output_pass (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
finish_output_pass (j_decompress_ptr cinfo) finish_output_pass (j_decompress_ptr cinfo)
{ {
my_master_ptr6 master = (my_master_ptr6) cinfo->master; my_master_ptr master = (my_master_ptr) cinfo->master;
if (cinfo->quantize_colors) if (cinfo->quantize_colors)
(*cinfo->cquantize->finish_pass) (cinfo); (*cinfo->cquantize->finish_pass) (cinfo);
@ -514,7 +490,7 @@ finish_output_pass (j_decompress_ptr cinfo)
GLOBAL(void) GLOBAL(void)
jpeg_new_colormap (j_decompress_ptr cinfo) jpeg_new_colormap (j_decompress_ptr cinfo)
{ {
my_master_ptr6 master = (my_master_ptr6) cinfo->master; my_master_ptr master = (my_master_ptr) cinfo->master;
/* Prevent application from calling me at wrong times */ /* Prevent application from calling me at wrong times */
if (cinfo->global_state != DSTATE_BUFIMAGE) if (cinfo->global_state != DSTATE_BUFIMAGE)
@ -542,12 +518,11 @@ jpeg_new_colormap (j_decompress_ptr cinfo)
GLOBAL(void) GLOBAL(void)
jinit_master_decompress (j_decompress_ptr cinfo) jinit_master_decompress (j_decompress_ptr cinfo)
{ {
my_master_ptr6 master; my_master_ptr master;
master = (my_master_ptr6) master = (my_master_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_decomp_master));
SIZEOF(my_decomp_master)); cinfo->master = &master->pub;
cinfo->master = (struct jpeg_decomp_master *) master;
master->pub.prepare_for_output_pass = prepare_for_output_pass; master->pub.prepare_for_output_pass = prepare_for_output_pass;
master->pub.finish_output_pass = finish_output_pass; master->pub.finish_output_pass = finish_output_pass;

View file

@ -2,6 +2,7 @@
* jdmerge.c * jdmerge.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2013-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -19,17 +20,17 @@
* B = Y + K4 * Cb * B = Y + K4 * Cb
* only the Y term varies among the group of pixels corresponding to a pair * only the Y term varies among the group of pixels corresponding to a pair
* of chroma samples, so the rest of the terms can be calculated just once. * of chroma samples, so the rest of the terms can be calculated just once.
* At typical sampling ratios, this eliminates half or three-quarters of the * At typical sampling ratios, this eliminates half or three-quarters
* multiplications needed for color conversion. * of the multiplications needed for color conversion.
* *
* This file currently provides implementations for the following cases: * This file currently provides implementations for the following cases:
* YCbCr => RGB color conversion only. * YCC => RGB color conversion only (YCbCr or BG_YCC).
* Sampling ratios of 2h1v or 2h2v. * Sampling ratios of 2h1v or 2h2v.
* No scaling needed at upsample time. * No scaling needed at upsample time.
* Corner-aligned (non-CCIR601) sampling alignment. * Corner-aligned (non-CCIR601) sampling alignment.
* Other special cases could be added, but in most applications these are * Other special cases could be added, but in most applications these
* the only common cases. (For uncommon cases we fall back on the more * are the only common cases. (For uncommon cases we fall back on
* general code in jdsample.c and jdcolor.c.) * the more general code in jdsample.c and jdcolor.c.)
*/ */
#define JPEG_INTERNALS #define JPEG_INTERNALS
@ -39,6 +40,12 @@
#ifdef UPSAMPLE_MERGING_SUPPORTED #ifdef UPSAMPLE_MERGING_SUPPORTED
#if RANGE_BITS < 2
/* Deliberate syntax err */
Sorry, this code requires 2 or more range extension bits.
#endif
/* Private subobject */ /* Private subobject */
typedef struct { typedef struct {
@ -75,45 +82,74 @@ typedef my_upsampler * my_upsample_ptr;
/* /*
* Initialize tables for YCC->RGB colorspace conversion. * Initialize tables for YCbCr->RGB and BG_YCC->RGB colorspace conversion.
* This is taken directly from jdcolor.c; see that file for more info. * This is taken directly from jdcolor.c; see that file for more info.
*/ */
LOCAL(void) LOCAL(void)
build_ycc_rgb_table2 (j_decompress_ptr cinfo) build_ycc_rgb_table (j_decompress_ptr cinfo)
/* Normal case, sYCC */
{ {
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
int i; int i;
INT32 x; INT32 x;
SHIFT_TEMPS SHIFT_TEMPS
upsample->Cr_r_tab = (int *) upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
(MAXJSAMPLE+1) * SIZEOF(int)); upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
upsample->Cb_b_tab = (int *) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
(MAXJSAMPLE+1) * SIZEOF(int)); ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cr_g_tab = (INT32 *) upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
(MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cb_g_tab = (INT32 *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
(MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 1.40200 * x */ /* Cr=>R value is nearest int to 1.402 * x */
upsample->Cr_r_tab[i] = (int) upsample->Cr_r_tab[i] = (int) DESCALE(FIX(1.402) * x, SCALEBITS);
RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); /* Cb=>B value is nearest int to 1.772 * x */
/* Cb=>B value is nearest int to 1.77200 * x */ upsample->Cb_b_tab[i] = (int) DESCALE(FIX(1.772) * x, SCALEBITS);
upsample->Cb_b_tab[i] = (int) /* Cr=>G value is scaled-up -0.714136286 * x */
RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); upsample->Cr_g_tab[i] = (- FIX(0.714136286)) * x;
/* Cr=>G value is scaled-up -0.71414 * x */ /* Cb=>G value is scaled-up -0.344136286 * x */
upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x;
/* Cb=>G value is scaled-up -0.34414 * x */
/* We also add in ONE_HALF so that need not do it in inner loop */ /* We also add in ONE_HALF so that need not do it in inner loop */
upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; upsample->Cb_g_tab[i] = (- FIX(0.344136286)) * x + ONE_HALF;
}
}
LOCAL(void)
build_bg_ycc_rgb_table (j_decompress_ptr cinfo)
/* Wide gamut case, bg-sYCC */
{
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
int i;
INT32 x;
SHIFT_TEMPS
upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int));
upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small)
((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32));
for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) {
/* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
/* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */
/* Cr=>R value is nearest int to 2.804 * x */
upsample->Cr_r_tab[i] = (int) DESCALE(FIX(2.804) * x, SCALEBITS);
/* Cb=>B value is nearest int to 3.544 * x */
upsample->Cb_b_tab[i] = (int) DESCALE(FIX(3.544) * x, SCALEBITS);
/* Cr=>G value is scaled-up -1.428272572 * x */
upsample->Cr_g_tab[i] = (- FIX(1.428272572)) * x;
/* Cb=>G value is scaled-up -0.688272572 * x */
/* We also add in ONE_HALF so that need not do it in inner loop */
upsample->Cb_g_tab[i] = (- FIX(0.688272572)) * x + ONE_HALF;
} }
} }
@ -143,7 +179,7 @@ start_pass_merged_upsample (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
merged_2v_upsample (j_decompress_ptr cinfo, merged_2v_upsample (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
JDIMENSION, JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail) JDIMENSION out_rows_avail)
/* 2:1 vertical sampling case: may need a spare row. */ /* 2:1 vertical sampling case: may need a spare row. */
@ -154,7 +190,7 @@ merged_2v_upsample (j_decompress_ptr cinfo,
if (upsample->spare_full) { if (upsample->spare_full) {
/* If we have a spare row saved from a previous cycle, just return it. */ /* If we have a spare row saved from a previous cycle, just return it. */
jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, jcopy_sample_rows(& upsample->spare_row, output_buf + *out_row_ctr,
1, upsample->out_row_width); 1, upsample->out_row_width);
num_rows = 1; num_rows = 1;
upsample->spare_full = FALSE; upsample->spare_full = FALSE;
@ -192,9 +228,9 @@ merged_2v_upsample (j_decompress_ptr cinfo,
METHODDEF(void) METHODDEF(void)
merged_1v_upsample (j_decompress_ptr cinfo, merged_1v_upsample (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
JDIMENSION, JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION) JDIMENSION out_rows_avail)
/* 1:1 vertical sampling case: much easier, never need a spare row. */ /* 1:1 vertical sampling case: much easier, never need a spare row. */
{ {
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
@ -228,13 +264,13 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
JSAMPARRAY output_buf) JSAMPARRAY output_buf)
{ {
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
int y, cred, cgreen, cblue; register int y, cred, cgreen, cblue;
int cb, cr; int cb, cr;
JSAMPROW outptr; register JSAMPROW outptr;
JSAMPROW inptr0, inptr1, inptr2; JSAMPROW inptr0, inptr1, inptr2;
JDIMENSION col; JDIMENSION col;
/* copy these pointers into registers if possible */ /* copy these pointers into registers if possible */
JSAMPLE * range_limit = cinfo->sample_range_limit; register JSAMPLE * range_limit = cinfo->sample_range_limit;
int * Crrtab = upsample->Cr_r_tab; int * Crrtab = upsample->Cr_r_tab;
int * Cbbtab = upsample->Cb_b_tab; int * Cbbtab = upsample->Cb_b_tab;
INT32 * Crgtab = upsample->Cr_g_tab; INT32 * Crgtab = upsample->Cr_g_tab;
@ -250,32 +286,31 @@ h2v1_merged_upsample (j_decompress_ptr cinfo,
/* Do the chroma part of the calculation */ /* Do the chroma part of the calculation */
cb = GETJSAMPLE(*inptr1++); cb = GETJSAMPLE(*inptr1++);
cr = GETJSAMPLE(*inptr2++); cr = GETJSAMPLE(*inptr2++);
cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
cblue = Cbbtab[cb]; cblue = Cbbtab[cb];
cred = Crrtab[cr];
/* Fetch 2 Y values and emit 2 pixels */ /* Fetch 2 Y values and emit 2 pixels */
y = GETJSAMPLE(*inptr0++); y = GETJSAMPLE(*inptr0++);
outptr[RGB_RED] = range_limit[y + cred]; outptr[RGB_RED] = range_limit[y + cred];
outptr[RGB_GREEN] = range_limit[y + cgreen]; outptr[RGB_GREEN] = range_limit[y + cgreen];
outptr[RGB_BLUE] = range_limit[y + cblue]; outptr[RGB_BLUE] = range_limit[y + cblue];
outptr += RGB_PIXELSIZE; outptr += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr0++); y = GETJSAMPLE(*inptr0++);
outptr[RGB_RED] = range_limit[y + cred]; outptr[RGB_RED] = range_limit[y + cred];
outptr[RGB_GREEN] = range_limit[y + cgreen]; outptr[RGB_GREEN] = range_limit[y + cgreen];
outptr[RGB_BLUE] = range_limit[y + cblue]; outptr[RGB_BLUE] = range_limit[y + cblue];
outptr += RGB_PIXELSIZE; outptr += RGB_PIXELSIZE;
} }
/* If image width is odd, do the last output column separately */ /* If image width is odd, do the last output column separately */
if (cinfo->output_width & 1) { if (cinfo->output_width & 1) {
y = GETJSAMPLE(*inptr0);
cb = GETJSAMPLE(*inptr1); cb = GETJSAMPLE(*inptr1);
cr = GETJSAMPLE(*inptr2); cr = GETJSAMPLE(*inptr2);
cred = Crrtab[cr]; outptr[RGB_RED] = range_limit[y + Crrtab[cr]];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); outptr[RGB_GREEN] = range_limit[y +
cblue = Cbbtab[cb]; ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],
y = GETJSAMPLE(*inptr0); SCALEBITS))];
outptr[RGB_RED] = range_limit[y + cred]; outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]];
outptr[RGB_GREEN] = range_limit[y + cgreen];
outptr[RGB_BLUE] = range_limit[y + cblue];
} }
} }
@ -290,13 +325,13 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
JSAMPARRAY output_buf) JSAMPARRAY output_buf)
{ {
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
int y, cred, cgreen, cblue; register int y, cred, cgreen, cblue;
int cb, cr; int cb, cr;
JSAMPROW outptr0, outptr1; register JSAMPROW outptr0, outptr1;
JSAMPROW inptr00, inptr01, inptr1, inptr2; JSAMPROW inptr00, inptr01, inptr1, inptr2;
JDIMENSION col; JDIMENSION col;
/* copy these pointers into registers if possible */ /* copy these pointers into registers if possible */
JSAMPLE * range_limit = cinfo->sample_range_limit; register JSAMPLE * range_limit = cinfo->sample_range_limit;
int * Crrtab = upsample->Cr_r_tab; int * Crrtab = upsample->Cr_r_tab;
int * Cbbtab = upsample->Cb_b_tab; int * Cbbtab = upsample->Cb_b_tab;
INT32 * Crgtab = upsample->Cr_g_tab; INT32 * Crgtab = upsample->Cr_g_tab;
@ -314,46 +349,46 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
/* Do the chroma part of the calculation */ /* Do the chroma part of the calculation */
cb = GETJSAMPLE(*inptr1++); cb = GETJSAMPLE(*inptr1++);
cr = GETJSAMPLE(*inptr2++); cr = GETJSAMPLE(*inptr2++);
cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
cblue = Cbbtab[cb]; cblue = Cbbtab[cb];
cred = Crrtab[cr];
/* Fetch 4 Y values and emit 4 pixels */ /* Fetch 4 Y values and emit 4 pixels */
y = GETJSAMPLE(*inptr00++); y = GETJSAMPLE(*inptr00++);
outptr0[RGB_RED] = range_limit[y + cred]; outptr0[RGB_RED] = range_limit[y + cred];
outptr0[RGB_GREEN] = range_limit[y + cgreen]; outptr0[RGB_GREEN] = range_limit[y + cgreen];
outptr0[RGB_BLUE] = range_limit[y + cblue]; outptr0[RGB_BLUE] = range_limit[y + cblue];
outptr0 += RGB_PIXELSIZE; outptr0 += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr00++); y = GETJSAMPLE(*inptr00++);
outptr0[RGB_RED] = range_limit[y + cred]; outptr0[RGB_RED] = range_limit[y + cred];
outptr0[RGB_GREEN] = range_limit[y + cgreen]; outptr0[RGB_GREEN] = range_limit[y + cgreen];
outptr0[RGB_BLUE] = range_limit[y + cblue]; outptr0[RGB_BLUE] = range_limit[y + cblue];
outptr0 += RGB_PIXELSIZE; outptr0 += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr01++); y = GETJSAMPLE(*inptr01++);
outptr1[RGB_RED] = range_limit[y + cred]; outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen]; outptr1[RGB_GREEN] = range_limit[y + cgreen];
outptr1[RGB_BLUE] = range_limit[y + cblue]; outptr1[RGB_BLUE] = range_limit[y + cblue];
outptr1 += RGB_PIXELSIZE; outptr1 += RGB_PIXELSIZE;
y = GETJSAMPLE(*inptr01++); y = GETJSAMPLE(*inptr01++);
outptr1[RGB_RED] = range_limit[y + cred]; outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen]; outptr1[RGB_GREEN] = range_limit[y + cgreen];
outptr1[RGB_BLUE] = range_limit[y + cblue]; outptr1[RGB_BLUE] = range_limit[y + cblue];
outptr1 += RGB_PIXELSIZE; outptr1 += RGB_PIXELSIZE;
} }
/* If image width is odd, do the last output column separately */ /* If image width is odd, do the last output column separately */
if (cinfo->output_width & 1) { if (cinfo->output_width & 1) {
cb = GETJSAMPLE(*inptr1); cb = GETJSAMPLE(*inptr1);
cr = GETJSAMPLE(*inptr2); cr = GETJSAMPLE(*inptr2);
cred = Crrtab[cr];
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
cblue = Cbbtab[cb]; cblue = Cbbtab[cb];
cred = Crrtab[cr];
y = GETJSAMPLE(*inptr00); y = GETJSAMPLE(*inptr00);
outptr0[RGB_RED] = range_limit[y + cred]; outptr0[RGB_RED] = range_limit[y + cred];
outptr0[RGB_GREEN] = range_limit[y + cgreen]; outptr0[RGB_GREEN] = range_limit[y + cgreen];
outptr0[RGB_BLUE] = range_limit[y + cblue]; outptr0[RGB_BLUE] = range_limit[y + cblue];
y = GETJSAMPLE(*inptr01); y = GETJSAMPLE(*inptr01);
outptr1[RGB_RED] = range_limit[y + cred]; outptr1[RGB_RED] = range_limit[y + cred];
outptr1[RGB_GREEN] = range_limit[y + cgreen]; outptr1[RGB_GREEN] = range_limit[y + cgreen];
outptr1[RGB_BLUE] = range_limit[y + cblue]; outptr1[RGB_BLUE] = range_limit[y + cblue];
} }
} }
@ -371,10 +406,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
{ {
my_upsample_ptr upsample; my_upsample_ptr upsample;
upsample = (my_upsample_ptr) upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
SIZEOF(my_upsampler)); cinfo->upsample = &upsample->pub;
cinfo->upsample = (struct jpeg_upsampler *) upsample;
upsample->pub.start_pass = start_pass_merged_upsample; upsample->pub.start_pass = start_pass_merged_upsample;
upsample->pub.need_context_rows = FALSE; upsample->pub.need_context_rows = FALSE;
@ -384,9 +418,9 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
upsample->pub.upsample = merged_2v_upsample; upsample->pub.upsample = merged_2v_upsample;
upsample->upmethod = h2v2_merged_upsample; upsample->upmethod = h2v2_merged_upsample;
/* Allocate a spare row buffer */ /* Allocate a spare row buffer */
upsample->spare_row = (JSAMPROW) upsample->spare_row = (JSAMPROW) (*cinfo->mem->alloc_large)
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); (size_t) upsample->out_row_width * SIZEOF(JSAMPLE));
} else { } else {
upsample->pub.upsample = merged_1v_upsample; upsample->pub.upsample = merged_1v_upsample;
upsample->upmethod = h2v1_merged_upsample; upsample->upmethod = h2v1_merged_upsample;
@ -394,7 +428,10 @@ jinit_merged_upsampler (j_decompress_ptr cinfo)
upsample->spare_row = NULL; upsample->spare_row = NULL;
} }
build_ycc_rgb_table2(cinfo); if (cinfo->jpeg_color_space == JCS_BG_YCC)
build_bg_ycc_rgb_table(cinfo);
else
build_ycc_rgb_table(cinfo);
} }
#endif /* UPSAMPLE_MERGING_SUPPORTED */ #endif /* UPSAMPLE_MERGING_SUPPORTED */

View file

@ -1,642 +0,0 @@
/*
* jdphuff.c
*
* Copyright (C) 1995-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains Huffman entropy decoding routines for progressive JPEG.
*
* Much of the complexity here has to do with supporting input suspension.
* If the data source module demands suspension, we want to be able to back
* up to the start of the current MCU. To do this, we copy state variables
* into local working storage, and update them back to the permanent
* storage only upon successful completion of an MCU.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jdhuff.h" /* Declarations shared with jdhuff.c */
#ifdef D_PROGRESSIVE_SUPPORTED
/*
* Expanded entropy decoder object for progressive Huffman decoding.
*
* The savable_state subrecord contains fields that change within an MCU,
* but must not be updated permanently until we complete the MCU.
*/
typedef struct {
unsigned int EOBRUN; /* remaining EOBs in EOBRUN */
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
} savable_state3;
/* This macro is to work around compilers with missing or broken
* structure assignment. You'll need to fix this code if you have
* such a compiler and you change MAX_COMPS_IN_SCAN.
*/
#ifndef NO_STRUCT_ASSIGN
#define ASSIGN_STATE(dest,src) ((dest) = (src))
#else
#if MAX_COMPS_IN_SCAN == 4
#define ASSIGN_STATE(dest,src) \
((dest).EOBRUN = (src).EOBRUN, \
(dest).last_dc_val[0] = (src).last_dc_val[0], \
(dest).last_dc_val[1] = (src).last_dc_val[1], \
(dest).last_dc_val[2] = (src).last_dc_val[2], \
(dest).last_dc_val[3] = (src).last_dc_val[3])
#endif
#endif
typedef struct {
struct jpeg_entropy_decoder pub; /* public fields */
/* These fields are loaded into local variables at start of each MCU.
* In case of suspension, we exit WITHOUT updating them.
*/
bitread_perm_state bitstate; /* Bit buffer at start of MCU */
savable_state3 saved; /* Other state at start of MCU */
/* These fields are NOT loaded into local working state. */
unsigned int restarts_to_go; /* MCUs left in this restart interval */
/* Pointers to derived tables (these workspaces have image lifespan) */
d_derived_tbl * derived_tbls[NUM_HUFF_TBLS];
d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */
} phuff_entropy_decoder;
typedef phuff_entropy_decoder * phuff_entropy_ptr2;
/* Forward declarations */
METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo,
JBLOCKROW *MCU_data));
METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo,
JBLOCKROW *MCU_data));
/*
* Initialize for a Huffman-compressed scan.
*/
METHODDEF(void)
start_pass_phuff_decoder (j_decompress_ptr cinfo)
{
phuff_entropy_ptr2 entropy = (phuff_entropy_ptr2) cinfo->entropy;
boolean is_DC_band, bad;
int ci, coefi, tbl;
int *coef_bit_ptr;
jpeg_component_info * compptr;
is_DC_band = (cinfo->Ss == 0);
/* Validate scan parameters */
bad = FALSE;
if (is_DC_band) {
if (cinfo->Se != 0)
bad = TRUE;
} else {
/* need not check Ss/Se < 0 since they came from unsigned bytes */
if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2)
bad = TRUE;
/* AC scans may have only one component */
if (cinfo->comps_in_scan != 1)
bad = TRUE;
}
if (cinfo->Ah != 0) {
/* Successive approximation refinement scan: must have Al = Ah-1. */
if (cinfo->Al != cinfo->Ah-1)
bad = TRUE;
}
if (cinfo->Al > 13) /* need not check for < 0 */
bad = TRUE;
/* Arguably the maximum Al value should be less than 13 for 8-bit precision,
* but the spec doesn't say so, and we try to be liberal about what we
* accept. Note: large Al values could result in out-of-range DC
* coefficients during early scans, leading to bizarre displays due to
* overflows in the IDCT math. But we won't crash.
*/
if (bad)
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
/* Update progression status, and verify that scan order is legal.
* Note that inter-scan inconsistencies are treated as warnings
* not fatal errors ... not clear if this is right way to behave.
*/
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
int cindex = cinfo->cur_comp_info[ci]->component_index;
coef_bit_ptr = & cinfo->coef_bits[cindex][0];
if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
if (cinfo->Ah != expected)
WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
coef_bit_ptr[coefi] = cinfo->Al;
}
}
/* Select MCU decoding routine */
if (cinfo->Ah == 0) {
if (is_DC_band)
entropy->pub.decode_mcu = decode_mcu_DC_first;
else
entropy->pub.decode_mcu = decode_mcu_AC_first;
} else {
if (is_DC_band)
entropy->pub.decode_mcu = decode_mcu_DC_refine;
else
entropy->pub.decode_mcu = decode_mcu_AC_refine;
}
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
/* Make sure requested tables are present, and compute derived tables.
* We may build same derived table more than once, but it's not expensive.
*/
if (is_DC_band) {
if (cinfo->Ah == 0) { /* DC refinement needs no table */
tbl = compptr->dc_tbl_no;
jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
& entropy->derived_tbls[tbl]);
}
} else {
tbl = compptr->ac_tbl_no;
jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
& entropy->derived_tbls[tbl]);
/* remember the single active table */
entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
}
/* Initialize DC predictions to 0 */
entropy->saved.last_dc_val[ci] = 0;
}
/* Initialize bitread state variables */
entropy->bitstate.bits_left = 0;
entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
entropy->pub.insufficient_data = FALSE;
/* Initialize private state variables */
entropy->saved.EOBRUN = 0;
/* Initialize restart counter */
entropy->restarts_to_go = cinfo->restart_interval;
}
/*
* Check for a restart marker & resynchronize decoder.
* Returns FALSE if must suspend.
*/
LOCAL(boolean)
process_restartp (j_decompress_ptr cinfo)
{
phuff_entropy_ptr2 entropy = (phuff_entropy_ptr2) cinfo->entropy;
int ci;
/* Throw away any unused bits remaining in bit buffer; */
/* include any full bytes in next_marker's count of discarded bytes */
cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
entropy->bitstate.bits_left = 0;
/* Advance past the RSTn marker */
if (! (*cinfo->marker->read_restart_marker) (cinfo))
return FALSE;
/* Re-initialize DC predictions to 0 */
for (ci = 0; ci < cinfo->comps_in_scan; ci++)
entropy->saved.last_dc_val[ci] = 0;
/* Re-init EOB run count, too */
entropy->saved.EOBRUN = 0;
/* Reset restart counter */
entropy->restarts_to_go = cinfo->restart_interval;
/* Reset out-of-data flag, unless read_restart_marker left us smack up
* against a marker. In that case we will end up treating the next data
* segment as empty, and we can avoid producing bogus output pixels by
* leaving the flag set.
*/
if (cinfo->unread_marker == 0)
entropy->pub.insufficient_data = FALSE;
return TRUE;
}
/*
* Huffman MCU decoding.
* Each of these routines decodes and returns one MCU's worth of
* Huffman-compressed coefficients.
* The coefficients are reordered from zigzag order into natural array order,
* but are not dequantized.
*
* The i'th block of the MCU is stored into the block pointed to by
* MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
*
* We return FALSE if data source requested suspension. In that case no
* changes have been made to permanent state. (Exception: some output
* coefficients may already have been assigned. This is harmless for
* spectral selection, since we'll just re-assign them on the next call.
* Successive approximation AC refinement has to be more careful, however.)
*/
/*
* MCU decoding for DC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr2 entropy = (phuff_entropy_ptr2) cinfo->entropy;
int Al = cinfo->Al;
int s, r;
int blkn, ci;
JBLOCKROW block;
BITREAD_STATE_VARS;
savable_state3 state;
d_derived_tbl * tbl;
jpeg_component_info * compptr;
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restartp(cinfo))
return FALSE;
}
/* If we've run out of data, just leave the MCU set to zeroes.
* This way, we return uniform gray for the remainder of the segment.
*/
if (! entropy->pub.insufficient_data) {
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
ASSIGN_STATE(state, entropy->saved);
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
ci = cinfo->MCU_membership[blkn];
compptr = cinfo->cur_comp_info[ci];
tbl = entropy->derived_tbls[compptr->dc_tbl_no];
/* Decode a single block's worth of coefficients */
/* Section F.2.2.1: decode the DC coefficient difference */
HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
if (s) {
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
}
/* Convert DC difference to actual value, update last_dc_val */
s += state.last_dc_val[ci];
state.last_dc_val[ci] = s;
/* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
(*block)[0] = (JCOEF) (s << Al);
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
ASSIGN_STATE(entropy->saved, state);
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
return TRUE;
}
/*
* MCU decoding for AC initial scan (either spectral selection,
* or first pass of successive approximation).
*/
METHODDEF(boolean)
decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr2 entropy = (phuff_entropy_ptr2) cinfo->entropy;
int Se = cinfo->Se;
int Al = cinfo->Al;
int s, k, r;
unsigned int EOBRUN;
JBLOCKROW block;
BITREAD_STATE_VARS;
d_derived_tbl * tbl;
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restartp(cinfo))
return FALSE;
}
/* If we've run out of data, just leave the MCU set to zeroes.
* This way, we return uniform gray for the remainder of the segment.
*/
if (! entropy->pub.insufficient_data) {
/* Load up working state.
* We can avoid loading/saving bitread state if in an EOB run.
*/
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
/* There is always only one block per MCU */
if (EOBRUN > 0) /* if it's a band of zeroes... */
EOBRUN--; /* ...process it now (we do nothing) */
else {
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
block = MCU_data[0];
tbl = entropy->ac_derived_tbl;
for (k = cinfo->Ss; k <= Se; k++) {
HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
r = s >> 4;
s &= 15;
if (s) {
k += r;
CHECK_BIT_BUFFER(br_state, s, return FALSE);
r = GET_BITS(s);
s = HUFF_EXTEND(r, s);
/* Scale and output coefficient in natural (dezigzagged) order */
(*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al);
} else {
if (r == 15) { /* ZRL */
k += 15; /* skip 15 zeroes in band */
} else { /* EOBr, run length is 2^r + appended bits */
EOBRUN = 1 << r;
if (r) { /* EOBr, r > 0 */
CHECK_BIT_BUFFER(br_state, r, return FALSE);
r = GET_BITS(r);
EOBRUN += r;
}
EOBRUN--; /* this band is processed at this moment */
break; /* force end-of-band */
}
}
}
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
}
/* Completed MCU, so update state */
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
return TRUE;
}
/*
* MCU decoding for DC successive approximation refinement scan.
* Note: we assume such scans can be multi-component, although the spec
* is not very clear on the point.
*/
METHODDEF(boolean)
decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr2 entropy = (phuff_entropy_ptr2) cinfo->entropy;
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
int blkn;
JBLOCKROW block;
BITREAD_STATE_VARS;
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restartp(cinfo))
return FALSE;
}
/* Not worth the cycles to check insufficient_data here,
* since we will not change the data anyway if we read zeroes.
*/
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
/* Outer loop handles each block in the MCU */
for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
block = MCU_data[blkn];
/* Encoded data is simply the next bit of the two's-complement DC value */
CHECK_BIT_BUFFER(br_state, 1, return FALSE);
if (GET_BITS(1))
(*block)[0] |= p1;
/* Note: since we use |=, repeating the assignment later is safe */
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
return TRUE;
}
/*
* MCU decoding for AC successive approximation refinement scan.
*/
METHODDEF(boolean)
decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
{
phuff_entropy_ptr2 entropy = (phuff_entropy_ptr2) cinfo->entropy;
int Se = cinfo->Se;
int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
int s, k, r;
unsigned int EOBRUN;
JBLOCKROW block;
JCOEFPTR thiscoef;
BITREAD_STATE_VARS;
d_derived_tbl * tbl;
int num_newnz;
int newnz_pos[DCTSIZE2];
/* Process restart marker if needed; may have to suspend */
if (cinfo->restart_interval) {
if (entropy->restarts_to_go == 0)
if (! process_restartp(cinfo))
return FALSE;
}
/* If we've run out of data, don't modify the MCU.
*/
if (! entropy->pub.insufficient_data) {
/* Load up working state */
BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
/* There is always only one block per MCU */
block = MCU_data[0];
tbl = entropy->ac_derived_tbl;
/* If we are forced to suspend, we must undo the assignments to any newly
* nonzero coefficients in the block, because otherwise we'd get confused
* next time about which coefficients were already nonzero.
* But we need not undo addition of bits to already-nonzero coefficients;
* instead, we can test the current bit to see if we already did it.
*/
num_newnz = 0;
/* initialize coefficient loop counter to start of band */
k = cinfo->Ss;
if (EOBRUN == 0) {
for (; k <= Se; k++) {
HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
r = s >> 4;
s &= 15;
if (s) {
if (s != 1) /* size of new coef should always be 1 */
WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
CHECK_BIT_BUFFER(br_state, 1, goto undoit);
if (GET_BITS(1))
s = p1; /* newly nonzero coef is positive */
else
s = m1; /* newly nonzero coef is negative */
} else {
if (r != 15) {
EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */
if (r) {
CHECK_BIT_BUFFER(br_state, r, goto undoit);
r = GET_BITS(r);
EOBRUN += r;
}
break; /* rest of block is handled by EOB logic */
}
/* note s = 0 for processing ZRL */
}
/* Advance over already-nonzero coefs and r still-zero coefs,
* appending correction bits to the nonzeroes. A correction bit is 1
* if the absolute value of the coefficient must be increased.
*/
do {
thiscoef = *block + jpeg_natural_order[k];
if (*thiscoef != 0) {
CHECK_BIT_BUFFER(br_state, 1, goto undoit);
if (GET_BITS(1)) {
if ((*thiscoef & p1) == 0) { /* do nothing if already set it */
if (*thiscoef >= 0)
*thiscoef += p1;
else
*thiscoef += m1;
}
}
} else {
if (--r < 0)
break; /* reached target zero coefficient */
}
k++;
} while (k <= Se);
if (s) {
int pos = jpeg_natural_order[k];
/* Output newly nonzero coefficient */
(*block)[pos] = (JCOEF) s;
/* Remember its position in case we have to suspend */
newnz_pos[num_newnz++] = pos;
}
}
}
if (EOBRUN > 0) {
/* Scan any remaining coefficient positions after the end-of-band
* (the last newly nonzero coefficient, if any). Append a correction
* bit to each already-nonzero coefficient. A correction bit is 1
* if the absolute value of the coefficient must be increased.
*/
for (; k <= Se; k++) {
thiscoef = *block + jpeg_natural_order[k];
if (*thiscoef != 0) {
CHECK_BIT_BUFFER(br_state, 1, goto undoit);
if (GET_BITS(1)) {
if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */
if (*thiscoef >= 0)
*thiscoef += p1;
else
*thiscoef += m1;
}
}
}
}
/* Count one block completed in EOB run */
EOBRUN--;
}
/* Completed MCU, so update state */
BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
}
/* Account for restart interval (no-op if not using restarts) */
entropy->restarts_to_go--;
return TRUE;
undoit:
/* Re-zero any output coefficients that we made newly nonzero */
while (num_newnz > 0)
(*block)[newnz_pos[--num_newnz]] = 0;
return FALSE;
}
/*
* Module initialization routine for progressive Huffman entropy decoding.
*/
GLOBAL(void)
jinit_phuff_decoder (j_decompress_ptr cinfo)
{
phuff_entropy_ptr2 entropy;
int *coef_bit_ptr;
int ci, i;
entropy = (phuff_entropy_ptr2)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(phuff_entropy_decoder));
cinfo->entropy = (struct jpeg_entropy_decoder *) entropy;
entropy->pub.start_pass = start_pass_phuff_decoder;
/* Mark derived tables unallocated */
for (i = 0; i < NUM_HUFF_TBLS; i++) {
entropy->derived_tbls[i] = NULL;
}
/* Create progression status table */
cinfo->coef_bits = (int (*)[DCTSIZE2])
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
cinfo->num_components*DCTSIZE2*SIZEOF(int));
coef_bit_ptr = & cinfo->coef_bits[0][0];
for (ci = 0; ci < cinfo->num_components; ci++)
for (i = 0; i < DCTSIZE2; i++)
*coef_bit_ptr++ = -1;
}
#endif /* D_PROGRESSIVE_SUPPORTED */

View file

@ -158,8 +158,8 @@ METHODDEF(void)
post_process_prepass (j_decompress_ptr cinfo, post_process_prepass (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail, JDIMENSION in_row_groups_avail,
JSAMPARRAY, JDIMENSION *out_row_ctr, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION) JDIMENSION out_rows_avail)
{ {
my_post_ptr post = (my_post_ptr) cinfo->post; my_post_ptr post = (my_post_ptr) cinfo->post;
JDIMENSION old_next_row, num_rows; JDIMENSION old_next_row, num_rows;
@ -200,8 +200,8 @@ post_process_prepass (j_decompress_ptr cinfo,
METHODDEF(void) METHODDEF(void)
post_process_2pass (j_decompress_ptr cinfo, post_process_2pass (j_decompress_ptr cinfo,
JSAMPIMAGE, JDIMENSION *, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
JDIMENSION, JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail) JDIMENSION out_rows_avail)
{ {

View file

@ -2,13 +2,14 @@
* jdsample.c * jdsample.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2002-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
* This file contains upsampling routines. * This file contains upsampling routines.
* *
* Upsampling input data is counted in "row groups". A row group * Upsampling input data is counted in "row groups". A row group
* is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) * is defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size)
* sample rows of each component. Upsampling will normally produce * sample rows of each component. Upsampling will normally produce
* max_v_samp_factor pixel rows from each row group (but this could vary * max_v_samp_factor pixel rows from each row group (but this could vary
* if the upsampler is applying a scale factor of its own). * if the upsampler is applying a scale factor of its own).
@ -26,7 +27,7 @@
/* Pointer to routine to upsample a single component */ /* Pointer to routine to upsample a single component */
typedef JMETHOD(void, upsample1_ptr, typedef JMETHOD(void, upsample1_ptr,
(j_decompress_ptr cinfo, jpeg_component_info * compptr, (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr));
/* Private subobject */ /* Private subobject */
@ -56,9 +57,9 @@ typedef struct {
*/ */
UINT8 h_expand[MAX_COMPONENTS]; UINT8 h_expand[MAX_COMPONENTS];
UINT8 v_expand[MAX_COMPONENTS]; UINT8 v_expand[MAX_COMPONENTS];
} my_upsampler2; } my_upsampler;
typedef my_upsampler2 * my_upsample_ptr2; typedef my_upsampler * my_upsample_ptr;
/* /*
@ -68,7 +69,7 @@ typedef my_upsampler2 * my_upsample_ptr2;
METHODDEF(void) METHODDEF(void)
start_pass_upsample (j_decompress_ptr cinfo) start_pass_upsample (j_decompress_ptr cinfo)
{ {
my_upsample_ptr2 upsample = (my_upsample_ptr2) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
/* Mark the conversion buffer empty */ /* Mark the conversion buffer empty */
upsample->next_row_out = cinfo->max_v_samp_factor; upsample->next_row_out = cinfo->max_v_samp_factor;
@ -88,11 +89,11 @@ start_pass_upsample (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
sep_upsample (j_decompress_ptr cinfo, sep_upsample (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
JDIMENSION, JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail) JDIMENSION out_rows_avail)
{ {
my_upsample_ptr2 upsample = (my_upsample_ptr2) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
int ci; int ci;
jpeg_component_info * compptr; jpeg_component_info * compptr;
JDIMENSION num_rows; JDIMENSION num_rows;
@ -101,6 +102,9 @@ sep_upsample (j_decompress_ptr cinfo,
if (upsample->next_row_out >= cinfo->max_v_samp_factor) { if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
/* Don't bother to upsample an uninteresting component. */
if (! compptr->component_needed)
continue;
/* Invoke per-component upsample method. Notice we pass a POINTER /* Invoke per-component upsample method. Notice we pass a POINTER
* to color_buf[ci], so that fullsize_upsample can change it. * to color_buf[ci], so that fullsize_upsample can change it.
*/ */
@ -118,7 +122,7 @@ sep_upsample (j_decompress_ptr cinfo,
/* Not more than the distance to the end of the image. Need this test /* Not more than the distance to the end of the image. Need this test
* in case the image height is not a multiple of max_v_samp_factor: * in case the image height is not a multiple of max_v_samp_factor:
*/ */
if (num_rows > upsample->rows_to_go) if (num_rows > upsample->rows_to_go)
num_rows = upsample->rows_to_go; num_rows = upsample->rows_to_go;
/* And not more than what the client can accept: */ /* And not more than what the client can accept: */
out_rows_avail -= *out_row_ctr; out_rows_avail -= *out_row_ctr;
@ -154,26 +158,13 @@ sep_upsample (j_decompress_ptr cinfo,
*/ */
METHODDEF(void) METHODDEF(void)
fullsize_upsample (j_decompress_ptr, jpeg_component_info *, fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
{ {
*output_data_ptr = input_data; *output_data_ptr = input_data;
} }
/*
* This is a no-op version used for "uninteresting" components.
* These components will not be referenced by color conversion.
*/
METHODDEF(void)
noop_upsample (j_decompress_ptr, jpeg_component_info *,
JSAMPARRAY, JSAMPARRAY * output_data_ptr)
{
*output_data_ptr = NULL; /* safety check */
}
/* /*
* This version handles any integral sampling ratios. * This version handles any integral sampling ratios.
* This is not used for typical JPEG files, so it need not be fast. * This is not used for typical JPEG files, so it need not be fast.
@ -187,25 +178,25 @@ noop_upsample (j_decompress_ptr, jpeg_component_info *,
METHODDEF(void) METHODDEF(void)
int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
{ {
my_upsample_ptr2 upsample = (my_upsample_ptr2) cinfo->upsample; my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
JSAMPARRAY output_data = *output_data_ptr; JSAMPARRAY output_data, output_end;
JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
JSAMPLE invalue; register JSAMPLE invalue;
int h; register int h;
JSAMPROW outend; JSAMPROW outend;
int h_expand, v_expand; int h_expand, v_expand;
int inrow, outrow;
h_expand = upsample->h_expand[compptr->component_index]; h_expand = upsample->h_expand[compptr->component_index];
v_expand = upsample->v_expand[compptr->component_index]; v_expand = upsample->v_expand[compptr->component_index];
inrow = outrow = 0; output_data = *output_data_ptr;
while (outrow < cinfo->max_v_samp_factor) { output_end = output_data + cinfo->max_v_samp_factor;
for (; output_data < output_end; output_data += v_expand) {
/* Generate one output row with proper horizontal expansion */ /* Generate one output row with proper horizontal expansion */
inptr = input_data[inrow]; inptr = *input_data++;
outptr = output_data[outrow]; outptr = *output_data;
outend = outptr + cinfo->output_width; outend = outptr + cinfo->output_width;
while (outptr < outend) { while (outptr < outend) {
invalue = *inptr++; /* don't need GETJSAMPLE() here */ invalue = *inptr++; /* don't need GETJSAMPLE() here */
@ -215,11 +206,9 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
} }
/* Generate any additional output rows by duplicating the first one */ /* Generate any additional output rows by duplicating the first one */
if (v_expand > 1) { if (v_expand > 1) {
jcopy_sample_rows(output_data, outrow, output_data, outrow+1, jcopy_sample_rows(output_data, output_data + 1,
v_expand-1, cinfo->output_width); v_expand - 1, cinfo->output_width);
} }
inrow++;
outrow += v_expand;
} }
} }
@ -230,18 +219,18 @@ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
*/ */
METHODDEF(void) METHODDEF(void)
h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *, h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
{ {
JSAMPARRAY output_data = *output_data_ptr; JSAMPARRAY output_data = *output_data_ptr;
JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
JSAMPLE invalue; register JSAMPLE invalue;
JSAMPROW outend; JSAMPROW outend;
int inrow; int outrow;
for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { for (outrow = 0; outrow < cinfo->max_v_samp_factor; outrow++) {
inptr = input_data[inrow]; inptr = input_data[outrow];
outptr = output_data[inrow]; outptr = output_data[outrow];
outend = outptr + cinfo->output_width; outend = outptr + cinfo->output_width;
while (outptr < outend) { while (outptr < outend) {
invalue = *inptr++; /* don't need GETJSAMPLE() here */ invalue = *inptr++; /* don't need GETJSAMPLE() here */
@ -258,135 +247,27 @@ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info *,
*/ */
METHODDEF(void) METHODDEF(void)
h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info *, h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) JSAMPARRAY input_data, JSAMPIMAGE output_data_ptr)
{ {
JSAMPARRAY output_data = *output_data_ptr; JSAMPARRAY output_data, output_end;
JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
JSAMPLE invalue; register JSAMPLE invalue;
JSAMPROW outend; JSAMPROW outend;
int inrow, outrow;
inrow = outrow = 0; output_data = *output_data_ptr;
while (outrow < cinfo->max_v_samp_factor) { output_end = output_data + cinfo->max_v_samp_factor;
inptr = input_data[inrow]; for (; output_data < output_end; output_data += 2) {
outptr = output_data[outrow]; inptr = *input_data++;
outptr = *output_data;
outend = outptr + cinfo->output_width; outend = outptr + cinfo->output_width;
while (outptr < outend) { while (outptr < outend) {
invalue = *inptr++; /* don't need GETJSAMPLE() here */ invalue = *inptr++; /* don't need GETJSAMPLE() here */
*outptr++ = invalue; *outptr++ = invalue;
*outptr++ = invalue; *outptr++ = invalue;
} }
jcopy_sample_rows(output_data, outrow, output_data, outrow+1, jcopy_sample_rows(output_data, output_data + 1,
1, cinfo->output_width); 1, cinfo->output_width);
inrow++;
outrow += 2;
}
}
/*
* Fancy processing for the common case of 2:1 horizontal and 1:1 vertical.
*
* The upsampling algorithm is linear interpolation between pixel centers,
* also known as a "triangle filter". This is a good compromise between
* speed and visual quality. The centers of the output pixels are 1/4 and 3/4
* of the way between input pixel centers.
*
* A note about the "bias" calculations: when rounding fractional values to
* integer, we do not want to always round 0.5 up to the next integer.
* If we did that, we'd introduce a noticeable bias towards larger values.
* Instead, this code is arranged so that 0.5 will be rounded up or down at
* alternate pixel locations (a simple ordered dither pattern).
*/
METHODDEF(void)
h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
{
JSAMPARRAY output_data = *output_data_ptr;
JSAMPROW inptr, outptr;
int invalue;
JDIMENSION colctr;
int inrow;
for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) {
inptr = input_data[inrow];
outptr = output_data[inrow];
/* Special case for first column */
invalue = GETJSAMPLE(*inptr++);
*outptr++ = (JSAMPLE) invalue;
*outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2);
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
/* General case: 3/4 * nearer pixel + 1/4 * further pixel */
invalue = GETJSAMPLE(*inptr++) * 3;
*outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2);
*outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2);
}
/* Special case for last column */
invalue = GETJSAMPLE(*inptr);
*outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2);
*outptr++ = (JSAMPLE) invalue;
}
}
/*
* Fancy processing for the common case of 2:1 horizontal and 2:1 vertical.
* Again a triangle filter; see comments for h2v1 case, above.
*
* It is OK for us to reference the adjacent input rows because we demanded
* context from the main buffer controller (see initialization code).
*/
METHODDEF(void)
h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
{
JSAMPARRAY output_data = *output_data_ptr;
JSAMPROW inptr0, inptr1, outptr;
#if BITS_IN_JSAMPLE == 8
int thiscolsum, lastcolsum, nextcolsum;
#else
INT32 thiscolsum, lastcolsum, nextcolsum;
#endif
JDIMENSION colctr;
int inrow, outrow, v;
inrow = outrow = 0;
while (outrow < cinfo->max_v_samp_factor) {
for (v = 0; v < 2; v++) {
/* inptr0 points to nearest input row, inptr1 points to next nearest */
inptr0 = input_data[inrow];
if (v == 0) /* next nearest is row above */
inptr1 = input_data[inrow-1];
else /* next nearest is row below */
inptr1 = input_data[inrow+1];
outptr = output_data[outrow++];
/* Special case for first column */
thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
*outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4);
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) {
/* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */
/* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */
nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++);
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4);
lastcolsum = thiscolsum; thiscolsum = nextcolsum;
}
/* Special case for last column */
*outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4);
*outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4);
}
inrow++;
} }
} }
@ -398,16 +279,14 @@ h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
GLOBAL(void) GLOBAL(void)
jinit_upsampler (j_decompress_ptr cinfo) jinit_upsampler (j_decompress_ptr cinfo)
{ {
my_upsample_ptr2 upsample; my_upsample_ptr upsample;
int ci; int ci;
jpeg_component_info * compptr; jpeg_component_info * compptr;
boolean need_buffer, do_fancy;
int h_in_group, v_in_group, h_out_group, v_out_group; int h_in_group, v_in_group, h_out_group, v_out_group;
upsample = (my_upsample_ptr2) upsample = (my_upsample_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_upsampler));
SIZEOF(my_upsampler2)); cinfo->upsample = &upsample->pub;
cinfo->upsample = (struct jpeg_upsampler *) upsample;
upsample->pub.start_pass = start_pass_upsample; upsample->pub.start_pass = start_pass_upsample;
upsample->pub.upsample = sep_upsample; upsample->pub.upsample = sep_upsample;
upsample->pub.need_context_rows = FALSE; /* until we find out differently */ upsample->pub.need_context_rows = FALSE; /* until we find out differently */
@ -415,50 +294,36 @@ jinit_upsampler (j_decompress_ptr cinfo)
if (cinfo->CCIR601_sampling) /* this isn't supported */ if (cinfo->CCIR601_sampling) /* this isn't supported */
ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
/* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1,
* so don't ask for it.
*/
do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1;
/* Verify we can handle the sampling factors, select per-component methods, /* Verify we can handle the sampling factors, select per-component methods,
* and create storage as needed. * and create storage as needed.
*/ */
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) { ci++, compptr++) {
/* Don't bother to upsample an uninteresting component. */
if (! compptr->component_needed)
continue;
/* Compute size of an "input group" after IDCT scaling. This many samples /* Compute size of an "input group" after IDCT scaling. This many samples
* are to be converted to max_h_samp_factor * max_v_samp_factor pixels. * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
*/ */
h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / h_in_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) /
cinfo->min_DCT_scaled_size; cinfo->min_DCT_h_scaled_size;
v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / v_in_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
cinfo->min_DCT_scaled_size; cinfo->min_DCT_v_scaled_size;
h_out_group = cinfo->max_h_samp_factor; h_out_group = cinfo->max_h_samp_factor;
v_out_group = cinfo->max_v_samp_factor; v_out_group = cinfo->max_v_samp_factor;
upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
need_buffer = TRUE; if (h_in_group == h_out_group && v_in_group == v_out_group) {
if (! compptr->component_needed) {
/* Don't bother to upsample an uninteresting component. */
upsample->methods[ci] = noop_upsample;
need_buffer = FALSE;
} else if (h_in_group == h_out_group && v_in_group == v_out_group) {
/* Fullsize components can be processed without any work. */ /* Fullsize components can be processed without any work. */
upsample->methods[ci] = fullsize_upsample; upsample->methods[ci] = fullsize_upsample;
need_buffer = FALSE; continue; /* don't need to allocate buffer */
} else if (h_in_group * 2 == h_out_group && }
v_in_group == v_out_group) { if (h_in_group * 2 == h_out_group && v_in_group == v_out_group) {
/* Special cases for 2h1v upsampling */ /* Special case for 2h1v upsampling */
if (do_fancy && compptr->downsampled_width > 2) upsample->methods[ci] = h2v1_upsample;
upsample->methods[ci] = h2v1_fancy_upsample;
else
upsample->methods[ci] = h2v1_upsample;
} else if (h_in_group * 2 == h_out_group && } else if (h_in_group * 2 == h_out_group &&
v_in_group * 2 == v_out_group) { v_in_group * 2 == v_out_group) {
/* Special cases for 2h2v upsampling */ /* Special case for 2h2v upsampling */
if (do_fancy && compptr->downsampled_width > 2) { upsample->methods[ci] = h2v2_upsample;
upsample->methods[ci] = h2v2_fancy_upsample;
upsample->pub.need_context_rows = TRUE;
} else
upsample->methods[ci] = h2v2_upsample;
} else if ((h_out_group % h_in_group) == 0 && } else if ((h_out_group % h_in_group) == 0 &&
(v_out_group % v_in_group) == 0) { (v_out_group % v_in_group) == 0) {
/* Generic integral-factors upsampling method */ /* Generic integral-factors upsampling method */
@ -467,12 +332,10 @@ jinit_upsampler (j_decompress_ptr cinfo)
upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
} else } else
ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
if (need_buffer) { upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE,
((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) jround_up((long) cinfo->output_width,
(JDIMENSION) jround_up((long) cinfo->output_width, (long) cinfo->max_h_samp_factor),
(long) cinfo->max_h_samp_factor), (JDIMENSION) cinfo->max_v_samp_factor);
(JDIMENSION) cinfo->max_v_samp_factor);
}
} }
} }

View file

@ -2,6 +2,7 @@
* jdtrans.c * jdtrans.c
* *
* Copyright (C) 1995-1997, Thomas G. Lane. * Copyright (C) 1995-1997, Thomas G. Lane.
* Modified 2000-2009 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -99,18 +100,14 @@ transdecode_master_selection (j_decompress_ptr cinfo)
/* This is effectively a buffered-image operation. */ /* This is effectively a buffered-image operation. */
cinfo->buffered_image = TRUE; cinfo->buffered_image = TRUE;
/* Compute output image dimensions and related values. */
jpeg_core_output_dimensions(cinfo);
/* Entropy decoding: either Huffman or arithmetic coding. */ /* Entropy decoding: either Huffman or arithmetic coding. */
if (cinfo->arith_code) { if (cinfo->arith_code)
ERREXIT(cinfo, JERR_ARITH_NOTIMPL); jinit_arith_decoder(cinfo);
} else { else {
if (cinfo->progressive_mode) { jinit_huff_decoder(cinfo);
#ifdef D_PROGRESSIVE_SUPPORTED
jinit_phuff_decoder(cinfo);
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
} else
jinit_huff_decoder(cinfo);
} }
/* Always get a full-image coefficient buffer. */ /* Always get a full-image coefficient buffer. */

View file

@ -2,6 +2,7 @@
* jerror.c * jerror.c
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2012-2015 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -18,16 +19,16 @@
* These routines are used by both the compression and decompression code. * These routines are used by both the compression and decompression code.
*/ */
#ifdef USE_WINDOWS_MESSAGEBOX
#include <windows.h>
#endif
/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ /* this is not a core library module, so it doesn't define JPEG_INTERNALS */
#include "jinclude.h" #include "jinclude.h"
#include "jpeglib.h" #include "jpeglib.h"
#include "jversion.h" #include "jversion.h"
#include "jerror.h" #include "jerror.h"
#ifdef USE_WINDOWS_MESSAGEBOX
#include <windows.h>
#endif
#ifndef EXIT_FAILURE /* define exit() codes if not provided */ #ifndef EXIT_FAILURE /* define exit() codes if not provided */
#define EXIT_FAILURE 1 #define EXIT_FAILURE 1
#endif #endif
@ -66,7 +67,7 @@ const char * const jpeg_std_message_table[] = {
* or jpeg_destroy) at some point. * or jpeg_destroy) at some point.
*/ */
METHODDEF(void) METHODDEF(noreturn_t)
error_exit (j_common_ptr cinfo) error_exit (j_common_ptr cinfo)
{ {
/* Always display the message */ /* Always display the message */

View file

@ -2,6 +2,7 @@
* jerror.h * jerror.h
* *
* Copyright (C) 1994-1997, Thomas G. Lane. * Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 1997-2018 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -39,14 +40,15 @@ typedef enum {
JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
/* For maintenance convenience, list is alphabetical by message code name */ /* For maintenance convenience, list is alphabetical by message code name */
JMESSAGE(JERR_ARITH_NOTIMPL,
"Sorry, there are legal restrictions on arithmetic coding")
JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request")
JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") JMESSAGE(JERR_BAD_DCTSIZE, "DCT scaled block size %dx%d not supported")
JMESSAGE(JERR_BAD_DROP_SAMPLING,
"Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c")
JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
@ -82,7 +84,7 @@ JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
JMESSAGE(JERR_FILE_READ, "Input file read error") JMESSAGE(JERR_FILE_READ, "Input file read error")
JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") JMESSAGE(JERR_HUFF_CLEN_OUTOFBOUNDS, "Huffman code size table out of bounds")
JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
@ -93,6 +95,7 @@ JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
JMESSAGE(JERR_NOTIMPL, "Not implemented yet") JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
@ -103,11 +106,11 @@ JMESSAGE(JERR_QUANT_COMPONENTS,
"Cannot quantize more than %d color components") "Cannot quantize more than %d color components")
JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
JMESSAGE(JERR_SOF_BEFORE, "Invalid JPEG file structure: %s before SOF")
JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
@ -170,6 +173,7 @@ JMESSAGE(JTRC_UNKNOWN_IDS,
JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
JMESSAGE(JWRN_BOGUS_PROGRESSION, JMESSAGE(JWRN_BOGUS_PROGRESSION,
"Inconsistent progression sequence for component %d coefficient %d") "Inconsistent progression sequence for component %d coefficient %d")
JMESSAGE(JWRN_EXTRANEOUS_DATA, JMESSAGE(JWRN_EXTRANEOUS_DATA,
@ -227,6 +231,15 @@ JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
(cinfo)->err->msg_parm.i[2] = (p3), \ (cinfo)->err->msg_parm.i[2] = (p3), \
(cinfo)->err->msg_parm.i[3] = (p4), \ (cinfo)->err->msg_parm.i[3] = (p4), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXIT6(cinfo,code,p1,p2,p3,p4,p5,p6) \
((cinfo)->err->msg_code = (code), \
(cinfo)->err->msg_parm.i[0] = (p1), \
(cinfo)->err->msg_parm.i[1] = (p2), \
(cinfo)->err->msg_parm.i[2] = (p3), \
(cinfo)->err->msg_parm.i[3] = (p4), \
(cinfo)->err->msg_parm.i[4] = (p5), \
(cinfo)->err->msg_parm.i[5] = (p6), \
(*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
#define ERREXITS(cinfo,code,str) \ #define ERREXITS(cinfo,code,str) \
((cinfo)->err->msg_code = (code), \ ((cinfo)->err->msg_code = (code), \
strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \

View file

@ -2,6 +2,7 @@
* jfdctflt.c * jfdctflt.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2003-2017 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -47,35 +48,41 @@
*/ */
#if DCTSIZE != 8 #if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
#endif #endif
/* /*
* Perform the forward DCT on one block of samples. * Perform the forward DCT on one block of samples.
*
* cK represents cos(K*pi/16).
*/ */
GLOBAL(void) GLOBAL(void)
jpeg_fdct_float (FAST_FLOAT * data) jpeg_fdct_float (FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{ {
FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
FAST_FLOAT tmp10, tmp11, tmp12, tmp13; FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; FAST_FLOAT z1, z2, z3, z4, z5, z11, z13;
FAST_FLOAT *dataptr; FAST_FLOAT *dataptr;
JSAMPROW elemptr;
int ctr; int ctr;
/* Pass 1: process rows. */ /* Pass 1: process rows. */
dataptr = data; dataptr = data;
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { for (ctr = 0; ctr < DCTSIZE; ctr++) {
tmp0 = dataptr[0] + dataptr[7]; elemptr = sample_data[ctr] + start_col;
tmp7 = dataptr[0] - dataptr[7];
tmp1 = dataptr[1] + dataptr[6]; /* Load data into workspace */
tmp6 = dataptr[1] - dataptr[6]; tmp0 = (FAST_FLOAT) (GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]));
tmp2 = dataptr[2] + dataptr[5]; tmp7 = (FAST_FLOAT) (GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]));
tmp5 = dataptr[2] - dataptr[5]; tmp1 = (FAST_FLOAT) (GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]));
tmp3 = dataptr[3] + dataptr[4]; tmp6 = (FAST_FLOAT) (GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]));
tmp4 = dataptr[3] - dataptr[4]; tmp2 = (FAST_FLOAT) (GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]));
tmp5 = (FAST_FLOAT) (GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]));
tmp3 = (FAST_FLOAT) (GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]));
tmp4 = (FAST_FLOAT) (GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]));
/* Even part */ /* Even part */
@ -84,7 +91,8 @@ jpeg_fdct_float (FAST_FLOAT * data)
tmp11 = tmp1 + tmp2; tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2; tmp12 = tmp1 - tmp2;
dataptr[0] = tmp10 + tmp11; /* phase 3 */ /* Apply unsigned->signed conversion. */
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
dataptr[4] = tmp10 - tmp11; dataptr[4] = tmp10 - tmp11;
z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */

View file

@ -2,6 +2,7 @@
* jfdctfst.c * jfdctfst.c
* *
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2003-2017 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -43,7 +44,7 @@
*/ */
#if DCTSIZE != 8 #if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
#endif #endif
@ -108,30 +109,36 @@
/* /*
* Perform the forward DCT on one block of samples. * Perform the forward DCT on one block of samples.
*
* cK represents cos(K*pi/16).
*/ */
GLOBAL(void) GLOBAL(void)
jpeg_fdct_ifast (DCTELEM * data) jpeg_fdct_ifast (DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col)
{ {
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
DCTELEM tmp10, tmp11, tmp12, tmp13; DCTELEM tmp10, tmp11, tmp12, tmp13;
DCTELEM z1, z2, z3, z4, z5, z11, z13; DCTELEM z1, z2, z3, z4, z5, z11, z13;
DCTELEM *dataptr; DCTELEM *dataptr;
JSAMPROW elemptr;
int ctr; int ctr;
SHIFT_TEMPS SHIFT_TEMPS
/* Pass 1: process rows. */ /* Pass 1: process rows. */
dataptr = data; dataptr = data;
for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { for (ctr = 0; ctr < DCTSIZE; ctr++) {
tmp0 = dataptr[0] + dataptr[7]; elemptr = sample_data[ctr] + start_col;
tmp7 = dataptr[0] - dataptr[7];
tmp1 = dataptr[1] + dataptr[6]; /* Load data into workspace */
tmp6 = dataptr[1] - dataptr[6]; tmp0 = GETJSAMPLE(elemptr[0]) + GETJSAMPLE(elemptr[7]);
tmp2 = dataptr[2] + dataptr[5]; tmp7 = GETJSAMPLE(elemptr[0]) - GETJSAMPLE(elemptr[7]);
tmp5 = dataptr[2] - dataptr[5]; tmp1 = GETJSAMPLE(elemptr[1]) + GETJSAMPLE(elemptr[6]);
tmp3 = dataptr[3] + dataptr[4]; tmp6 = GETJSAMPLE(elemptr[1]) - GETJSAMPLE(elemptr[6]);
tmp4 = dataptr[3] - dataptr[4]; tmp2 = GETJSAMPLE(elemptr[2]) + GETJSAMPLE(elemptr[5]);
tmp5 = GETJSAMPLE(elemptr[2]) - GETJSAMPLE(elemptr[5]);
tmp3 = GETJSAMPLE(elemptr[3]) + GETJSAMPLE(elemptr[4]);
tmp4 = GETJSAMPLE(elemptr[3]) - GETJSAMPLE(elemptr[4]);
/* Even part */ /* Even part */
@ -140,7 +147,8 @@ jpeg_fdct_ifast (DCTELEM * data)
tmp11 = tmp1 + tmp2; tmp11 = tmp1 + tmp2;
tmp12 = tmp1 - tmp2; tmp12 = tmp1 - tmp2;
dataptr[0] = tmp10 + tmp11; /* phase 3 */ /* Apply unsigned->signed conversion. */
dataptr[0] = tmp10 + tmp11 - 8 * CENTERJSAMPLE; /* phase 3 */
dataptr[4] = tmp10 - tmp11; dataptr[4] = tmp10 - tmp11;
z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,7 @@
* jidctflt.c * jidctflt.c
* *
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2010-2017 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -49,7 +50,7 @@
*/ */
#if DCTSIZE != 8 #if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
#endif #endif
@ -62,6 +63,8 @@
/* /*
* Perform dequantization and inverse DCT on one block of coefficients. * Perform dequantization and inverse DCT on one block of coefficients.
*
* cK represents cos(K*pi/16).
*/ */
GLOBAL(void) GLOBAL(void)
@ -79,7 +82,6 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JSAMPLE *range_limit = IDCT_range_limit(cinfo); JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr; int ctr;
FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
SHIFT_TEMPS
/* Pass 1: process columns from input, store into work array. */ /* Pass 1: process columns from input, store into work array. */
@ -152,12 +154,12 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
tmp6 = tmp12 - tmp7; /* phase 2 */ tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6; tmp5 = tmp11 - tmp6;
tmp4 = tmp10 + tmp5; tmp4 = tmp10 - tmp5;
wsptr[DCTSIZE*0] = tmp0 + tmp7; wsptr[DCTSIZE*0] = tmp0 + tmp7;
wsptr[DCTSIZE*7] = tmp0 - tmp7; wsptr[DCTSIZE*7] = tmp0 - tmp7;
@ -165,8 +167,8 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
wsptr[DCTSIZE*6] = tmp1 - tmp6; wsptr[DCTSIZE*6] = tmp1 - tmp6;
wsptr[DCTSIZE*2] = tmp2 + tmp5; wsptr[DCTSIZE*2] = tmp2 + tmp5;
wsptr[DCTSIZE*5] = tmp2 - tmp5; wsptr[DCTSIZE*5] = tmp2 - tmp5;
wsptr[DCTSIZE*4] = tmp3 + tmp4; wsptr[DCTSIZE*3] = tmp3 + tmp4;
wsptr[DCTSIZE*3] = tmp3 - tmp4; wsptr[DCTSIZE*4] = tmp3 - tmp4;
inptr++; /* advance pointers to next column */ inptr++; /* advance pointers to next column */
quantptr++; quantptr++;
@ -174,7 +176,6 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
} }
/* Pass 2: process rows from work array, store into output array. */ /* Pass 2: process rows from work array, store into output array. */
/* Note that we must descale the results by a factor of 8 == 2**3. */
wsptr = workspace; wsptr = workspace;
for (ctr = 0; ctr < DCTSIZE; ctr++) { for (ctr = 0; ctr < DCTSIZE; ctr++) {
@ -187,11 +188,14 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
/* Even part */ /* Even part */
tmp10 = wsptr[0] + wsptr[4]; /* Prepare range-limit and float->int conversion */
tmp11 = wsptr[0] - wsptr[4]; z5 = wsptr[0] + (((FAST_FLOAT) RANGE_CENTER) + ((FAST_FLOAT) 0.5));
tmp10 = z5 + wsptr[4];
tmp11 = z5 - wsptr[4];
tmp13 = wsptr[2] + wsptr[6]; tmp13 = wsptr[2] + wsptr[6];
tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; tmp12 = (wsptr[2] - wsptr[6]) *
((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
tmp0 = tmp10 + tmp13; tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13; tmp3 = tmp10 - tmp13;
@ -205,35 +209,27 @@ jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
z11 = wsptr[1] + wsptr[7]; z11 = wsptr[1] + wsptr[7];
z12 = wsptr[1] - wsptr[7]; z12 = wsptr[1] - wsptr[7];
tmp7 = z11 + z13; tmp7 = z11 + z13; /* phase 5 */
tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
tmp6 = tmp12 - tmp7; tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6; tmp5 = tmp11 - tmp6;
tmp4 = tmp10 + tmp5; tmp4 = tmp10 - tmp5;
/* Final output stage: scale down by a factor of 8 and range-limit */ /* Final output stage: float->int conversion and range-limit */
outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) outptr[0] = range_limit[(int) (tmp0 + tmp7) & RANGE_MASK];
& RANGE_MASK]; outptr[7] = range_limit[(int) (tmp0 - tmp7) & RANGE_MASK];
outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) outptr[1] = range_limit[(int) (tmp1 + tmp6) & RANGE_MASK];
& RANGE_MASK]; outptr[6] = range_limit[(int) (tmp1 - tmp6) & RANGE_MASK];
outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) outptr[2] = range_limit[(int) (tmp2 + tmp5) & RANGE_MASK];
& RANGE_MASK]; outptr[5] = range_limit[(int) (tmp2 - tmp5) & RANGE_MASK];
outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) outptr[3] = range_limit[(int) (tmp3 + tmp4) & RANGE_MASK];
& RANGE_MASK]; outptr[4] = range_limit[(int) (tmp3 - tmp4) & RANGE_MASK];
outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3)
& RANGE_MASK];
outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3)
& RANGE_MASK];
outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3)
& RANGE_MASK];
outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3)
& RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */ wsptr += DCTSIZE; /* advance pointer to next row */
} }

View file

@ -2,6 +2,7 @@
* jidctfst.c * jidctfst.c
* *
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2015-2017 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -45,7 +46,7 @@
*/ */
#if DCTSIZE != 8 #if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ Sorry, this code only copes with 8x8 DCT blocks. /* deliberate syntax err */
#endif #endif
@ -133,35 +134,10 @@
#endif #endif
/* Like DESCALE, but applies to a DCTELEM and produces an int.
* We assume that int right shift is unsigned if INT32 right shift is.
*/
#ifdef RIGHT_SHIFT_IS_UNSIGNED
#define ISHIFT_TEMPS DCTELEM ishift_temp;
#if BITS_IN_JSAMPLE == 8
#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
#else
#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
#endif
#define IRIGHT_SHIFT(x,shft) \
((ishift_temp = (x)) < 0 ? \
(ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
(ishift_temp >> (shft)))
#else
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif
#ifdef USE_ACCURATE_ROUNDING
#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))
#else
#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n))
#endif
/* /*
* Perform dequantization and inverse DCT on one block of coefficients. * Perform dequantization and inverse DCT on one block of coefficients.
*
* cK represents cos(K*pi/16).
*/ */
GLOBAL(void) GLOBAL(void)
@ -180,7 +156,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
int ctr; int ctr;
int workspace[DCTSIZE2]; /* buffers data between passes */ int workspace[DCTSIZE2]; /* buffers data between passes */
SHIFT_TEMPS /* for DESCALE */ SHIFT_TEMPS /* for DESCALE */
ISHIFT_TEMPS /* for IDESCALE */ ISHIFT_TEMPS /* for IRIGHT_SHIFT */
/* Pass 1: process columns from input, store into work array. */ /* Pass 1: process columns from input, store into work array. */
@ -196,7 +172,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
* With typical images and quantization tables, half or more of the * With typical images and quantization tables, half or more of the
* column DCT calculations can be simplified this way. * column DCT calculations can be simplified this way.
*/ */
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
@ -212,13 +188,13 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
wsptr[DCTSIZE*5] = dcval; wsptr[DCTSIZE*5] = dcval;
wsptr[DCTSIZE*6] = dcval; wsptr[DCTSIZE*6] = dcval;
wsptr[DCTSIZE*7] = dcval; wsptr[DCTSIZE*7] = dcval;
inptr++; /* advance pointers to next column */ inptr++; /* advance pointers to next column */
quantptr++; quantptr++;
wsptr++; wsptr++;
continue; continue;
} }
/* Even part */ /* Even part */
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
@ -236,7 +212,7 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
tmp3 = tmp10 - tmp13; tmp3 = tmp10 - tmp13;
tmp1 = tmp11 + tmp12; tmp1 = tmp11 + tmp12;
tmp2 = tmp11 - tmp12; tmp2 = tmp11 - tmp12;
/* Odd part */ /* Odd part */
tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
@ -253,12 +229,12 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */
tmp6 = tmp12 - tmp7; /* phase 2 */ tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6; tmp5 = tmp11 - tmp6;
tmp4 = tmp10 + tmp5; tmp4 = tmp10 - tmp5;
wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
@ -266,21 +242,28 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); wsptr[DCTSIZE*3] = (int) (tmp3 + tmp4);
wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); wsptr[DCTSIZE*4] = (int) (tmp3 - tmp4);
inptr++; /* advance pointers to next column */ inptr++; /* advance pointers to next column */
quantptr++; quantptr++;
wsptr++; wsptr++;
} }
/* Pass 2: process rows from work array, store into output array. */ /* Pass 2: process rows from work array, store into output array.
/* Note that we must descale the results by a factor of 8 == 2**3, */ * Note that we must descale the results by a factor of 8 == 2**3,
/* and also undo the PASS1_BITS scaling. */ * and also undo the PASS1_BITS scaling.
*/
wsptr = workspace; wsptr = workspace;
for (ctr = 0; ctr < DCTSIZE; ctr++) { for (ctr = 0; ctr < DCTSIZE; ctr++) {
outptr = output_buf[ctr] + output_col; outptr = output_buf[ctr] + output_col;
/* Add range center and fudge factor for final descale and range-limit. */
z5 = (DCTELEM) wsptr[0] +
((((DCTELEM) RANGE_CENTER) << (PASS1_BITS+3)) +
(1 << (PASS1_BITS+2)));
/* Rows of zeroes can be exploited in the same way as we did with columns. /* Rows of zeroes can be exploited in the same way as we did with columns.
* However, the column calculation has created many nonzero AC terms, so * However, the column calculation has created many nonzero AC terms, so
* the simplification applies less often (typically 5% to 10% of the time). * the simplification applies less often (typically 5% to 10% of the time).
@ -288,14 +271,14 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
* test takes more time than it's worth. In that case this section * test takes more time than it's worth. In that case this section
* may be commented out. * may be commented out.
*/ */
#ifndef NO_ZERO_ROW_TEST #ifndef NO_ZERO_ROW_TEST
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */ /* AC terms all zero */
JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) JSAMPLE dcval = range_limit[(int) IRIGHT_SHIFT(z5, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[0] = dcval; outptr[0] = dcval;
outptr[1] = dcval; outptr[1] = dcval;
outptr[2] = dcval; outptr[2] = dcval;
@ -309,15 +292,15 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
continue; continue;
} }
#endif #endif
/* Even part */ /* Even part */
tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); tmp10 = z5 + (DCTELEM) wsptr[4];
tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); tmp11 = z5 - (DCTELEM) wsptr[4];
tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); tmp13 = (DCTELEM) wsptr[2] + (DCTELEM) wsptr[6];
tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6],
- tmp13; FIX_1_414213562) - tmp13; /* 2*c4 */
tmp0 = tmp10 + tmp13; tmp0 = tmp10 + tmp13;
tmp3 = tmp10 - tmp13; tmp3 = tmp10 - tmp13;
@ -335,30 +318,30 @@ jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ tmp10 = z5 - MULTIPLY(z12, FIX_1_082392200); /* 2*(c2-c6) */
tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ tmp12 = z5 - MULTIPLY(z10, FIX_2_613125930); /* 2*(c2+c6) */
tmp6 = tmp12 - tmp7; /* phase 2 */ tmp6 = tmp12 - tmp7; /* phase 2 */
tmp5 = tmp11 - tmp6; tmp5 = tmp11 - tmp6;
tmp4 = tmp10 + tmp5; tmp4 = tmp10 - tmp5;
/* Final output stage: scale down by a factor of 8 and range-limit */ /* Final output stage: scale down by a factor of 8 and range-limit */
outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) outptr[0] = range_limit[(int) IRIGHT_SHIFT(tmp0 + tmp7, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) outptr[7] = range_limit[(int) IRIGHT_SHIFT(tmp0 - tmp7, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) outptr[1] = range_limit[(int) IRIGHT_SHIFT(tmp1 + tmp6, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) outptr[6] = range_limit[(int) IRIGHT_SHIFT(tmp1 - tmp6, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) outptr[2] = range_limit[(int) IRIGHT_SHIFT(tmp2 + tmp5, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) outptr[5] = range_limit[(int) IRIGHT_SHIFT(tmp2 - tmp5, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) outptr[3] = range_limit[(int) IRIGHT_SHIFT(tmp3 + tmp4, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) outptr[4] = range_limit[(int) IRIGHT_SHIFT(tmp3 - tmp4, PASS1_BITS+3)
& RANGE_MASK]; & RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */ wsptr += DCTSIZE; /* advance pointer to next row */

File diff suppressed because it is too large Load diff

View file

@ -1,398 +0,0 @@
/*
* jidctred.c
*
* Copyright (C) 1994-1998, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains inverse-DCT routines that produce reduced-size output:
* either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block.
*
* The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M)
* algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step
* with an 8-to-4 step that produces the four averages of two adjacent outputs
* (or an 8-to-2 step producing two averages of four outputs, for 2x2 output).
* These steps were derived by computing the corresponding values at the end
* of the normal LL&M code, then simplifying as much as possible.
*
* 1x1 is trivial: just take the DC coefficient divided by 8.
*
* See jidctint.c for additional comments.
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "jdct.h" /* Private declarations for DCT subsystem */
#ifdef IDCT_SCALING_SUPPORTED
/*
* This module is specialized to the case DCTSIZE = 8.
*/
#if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
#endif
/* Scaling is the same as in jidctint.c. */
#if BITS_IN_JSAMPLE == 8
#define CONST_BITS 13
#define PASS1_BITS 2
#else
#define CONST_BITS 13
#define PASS1_BITS 1 /* lose a little precision to avoid overflow */
#endif
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
* causing a lot of useless floating-point operations at run time.
* To get around this we use the following pre-calculated constants.
* If you change CONST_BITS you may want to add appropriate values.
* (With a reasonable C compiler, you can just rely on the FIX() macro...)
*/
#if CONST_BITS == 13
#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */
#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */
#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */
#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */
#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */
#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */
#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */
#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */
#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */
#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */
#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */
#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */
#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */
#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */
#else
#define FIX_0_211164243 FIX(0.211164243)
#define FIX_0_509795579 FIX(0.509795579)
#define FIX_0_601344887 FIX(0.601344887)
#define FIX_0_720959822 FIX(0.720959822)
#define FIX_0_765366865 FIX(0.765366865)
#define FIX_0_850430095 FIX(0.850430095)
#define FIX_0_899976223 FIX(0.899976223)
#define FIX_1_061594337 FIX(1.061594337)
#define FIX_1_272758580 FIX(1.272758580)
#define FIX_1_451774981 FIX(1.451774981)
#define FIX_1_847759065 FIX(1.847759065)
#define FIX_2_172734803 FIX(2.172734803)
#define FIX_2_562915447 FIX(2.562915447)
#define FIX_3_624509785 FIX(3.624509785)
#endif
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
* For 8-bit samples with the recommended scaling, all the variable
* and constant values involved are no more than 16 bits wide, so a
* 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
* For 12-bit samples, a full 32-bit multiplication will be needed.
*/
#if BITS_IN_JSAMPLE == 8
#define MULTIPLY(var,const) MULTIPLY16C16(var,const)
#else
#define MULTIPLY(var,const) ((var) * (const))
#endif
/* Dequantize a coefficient by multiplying it by the multiplier-table
* entry; produce an int result. In this module, both inputs and result
* are 16 bits or less, so either int or short multiply will work.
*/
#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval))
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a reduced-size 4x4 output block.
*/
GLOBAL(void)
jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
INT32 tmp0, tmp2, tmp10, tmp12;
INT32 z1, z2, z3, z4;
JCOEFPTR inptr;
ISLOW_MULT_TYPE * quantptr;
int * wsptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[DCTSIZE*4]; /* buffers data between passes */
SHIFT_TEMPS
/* Pass 1: process columns from input, store into work array. */
inptr = coef_block;
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
wsptr = workspace;
for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
/* Don't bother to process column 4, because second pass won't use it */
if (ctr == DCTSIZE-4)
continue;
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
/* AC terms all zero; we need not examine term 4 for 4x4 output */
int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
wsptr[DCTSIZE*0] = dcval;
wsptr[DCTSIZE*1] = dcval;
wsptr[DCTSIZE*2] = dcval;
wsptr[DCTSIZE*3] = dcval;
continue;
}
/* Even part */
tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
tmp0 <<= (CONST_BITS+1);
z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
tmp10 = tmp0 + tmp2;
tmp12 = tmp0 - tmp2;
/* Odd part */
z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
+ MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
+ MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
+ MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
+ MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
+ MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
+ MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
/* Final output stage */
wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
}
/* Pass 2: process 4 rows from work array, store into output array. */
wsptr = workspace;
for (ctr = 0; ctr < 4; ctr++) {
outptr = output_buf[ctr] + output_col;
/* It's not clear whether a zero row test is worthwhile here ... */
#ifndef NO_ZERO_ROW_TEST
if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)
& RANGE_MASK];
outptr[0] = dcval;
outptr[1] = dcval;
outptr[2] = dcval;
outptr[3] = dcval;
wsptr += DCTSIZE; /* advance pointer to next row */
continue;
}
#endif
/* Even part */
tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1);
tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065)
+ MULTIPLY((INT32) wsptr[6], - FIX_0_765366865);
tmp10 = tmp0 + tmp2;
tmp12 = tmp0 - tmp2;
/* Odd part */
z1 = (INT32) wsptr[7];
z2 = (INT32) wsptr[5];
z3 = (INT32) wsptr[3];
z4 = (INT32) wsptr[1];
tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
+ MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
+ MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
+ MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
+ MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
+ MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
+ MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
/* Final output stage */
outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
CONST_BITS+PASS1_BITS+3+1)
& RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */
}
}
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a reduced-size 2x2 output block.
*/
GLOBAL(void)
jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
INT32 tmp0, tmp10, z1;
JCOEFPTR inptr;
ISLOW_MULT_TYPE * quantptr;
int * wsptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
int ctr;
int workspace[DCTSIZE*2]; /* buffers data between passes */
SHIFT_TEMPS
/* Pass 1: process columns from input, store into work array. */
inptr = coef_block;
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
wsptr = workspace;
for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
/* Don't bother to process columns 2,4,6 */
if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
continue;
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
/* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
wsptr[DCTSIZE*0] = dcval;
wsptr[DCTSIZE*1] = dcval;
continue;
}
/* Even part */
z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
tmp10 = z1 << (CONST_BITS+2);
/* Odd part */
z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
/* Final output stage */
wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
}
/* Pass 2: process 2 rows from work array, store into output array. */
wsptr = workspace;
for (ctr = 0; ctr < 2; ctr++) {
outptr = output_buf[ctr] + output_col;
/* It's not clear whether a zero row test is worthwhile here ... */
#ifndef NO_ZERO_ROW_TEST
if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
/* AC terms all zero */
JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)
& RANGE_MASK];
outptr[0] = dcval;
outptr[1] = dcval;
wsptr += DCTSIZE; /* advance pointer to next row */
continue;
}
#endif
/* Even part */
tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2);
/* Odd part */
tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
+ MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
+ MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
+ MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
/* Final output stage */
outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
CONST_BITS+PASS1_BITS+3+2)
& RANGE_MASK];
outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
CONST_BITS+PASS1_BITS+3+2)
& RANGE_MASK];
wsptr += DCTSIZE; /* advance pointer to next row */
}
}
/*
* Perform dequantization and inverse DCT on one block of coefficients,
* producing a reduced-size 1x1 output block.
*/
GLOBAL(void)
jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
int dcval;
ISLOW_MULT_TYPE * quantptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo);
SHIFT_TEMPS
/* We hardly need an inverse DCT routine for this: just take the
* average pixel value, which is one-eighth of the DC coefficient.
*/
quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
dcval = (int) DESCALE((INT32) dcval, 3);
output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
}
#endif /* IDCT_SCALING_SUPPORTED */

View file

@ -2,6 +2,7 @@
* jinclude.h * jinclude.h
* *
* Copyright (C) 1991-1994, Thomas G. Lane. * Copyright (C) 1991-1994, Thomas G. Lane.
* Modified 2017-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -10,16 +11,13 @@
* care of by the standard jconfig symbols, but on really weird systems * care of by the standard jconfig symbols, but on really weird systems
* you may have to edit this file.) * you may have to edit this file.)
* *
* NOTE: this file is NOT intended to be included by applications using the * NOTE: this file is NOT intended to be included by applications using
* JPEG library. Most applications need only include jpeglib.h. * the JPEG library. Most applications need only include jpeglib.h.
*/ */
/* Include auto-config file to find out which system include files we need. */ /* Include auto-config file to find out which system include files we need. */
#ifndef __jinclude_h__
#define __jinclude_h__
#include "jconfig.h" /* auto configuration options */ #include "jconfig.h" /* auto configuration options */
#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
@ -86,112 +84,74 @@
* The modules that use fread() and fwrite() always invoke them through * The modules that use fread() and fwrite() always invoke them through
* these macros. On some systems you may need to twiddle the argument casts. * these macros. On some systems you may need to twiddle the argument casts.
* CAUTION: argument order is different from underlying functions! * CAUTION: argument order is different from underlying functions!
*
* Furthermore, macros are provided for fflush() and ferror() in order
* to facilitate adaption by applications using an own FILE class.
*
* You can define your own custom file I/O functions in jconfig.h and
* #define JPEG_HAVE_FILE_IO_CUSTOM there to prevent redefinition here.
*
* You can #define JPEG_USE_FILE_IO_CUSTOM in jconfig.h to use custom file
* I/O functions implemented in Delphi VCL (Visual Component Library)
* in Vcl.Imaging.jpeg.pas for the TJPEGImage component utilizing
* the Delphi RTL (Run-Time Library) TMemoryStream component:
*
* procedure jpeg_stdio_src(var cinfo: jpeg_decompress_struct;
* input_file: TStream); external;
*
* procedure jpeg_stdio_dest(var cinfo: jpeg_compress_struct;
* output_file: TStream); external;
*
* function jfread(var buf; recsize, reccount: Integer; S: TStream): Integer;
* begin
* Result := S.Read(buf, recsize * reccount);
* end;
*
* function jfwrite(const buf; recsize, reccount: Integer; S: TStream): Integer;
* begin
* Result := S.Write(buf, recsize * reccount);
* end;
*
* function jfflush(S: TStream): Integer;
* begin
* Result := 0;
* end;
*
* function jferror(S: TStream): Integer;
* begin
* Result := 0;
* end;
*
* TMemoryStream of Delphi RTL has the distinctive feature to provide dynamic
* memory buffer management with a file/stream-based interface, particularly for
* the write (output) operation, which is easier to apply compared with direct
* implementations as given in jdatadst.c for memory destination. Those direct
* implementations of dynamic memory write tend to be more difficult to use,
* so providing an option like TMemoryStream may be a useful alternative.
*
* The CFile/CMemFile classes of the Microsoft Foundation Class (MFC) Library
* may be used in a similar fashion.
*/ */
#ifndef JPEG_HAVE_FILE_IO_CUSTOM
#ifdef JPEG_USE_FILE_IO_CUSTOM
extern size_t jfread(void * __ptr, size_t __size, size_t __n, FILE * __stream);
extern size_t jfwrite(const void * __ptr, size_t __size, size_t __n, FILE * __stream);
extern int jfflush(FILE * __stream);
extern int jferror(FILE * __fp);
#define JFREAD(file,buf,sizeofbuf) \
((size_t) jfread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
#define JFWRITE(file,buf,sizeofbuf) \
((size_t) jfwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
#define JFFLUSH(file) jfflush(file)
#define JFERROR(file) jferror(file)
#else
#define JFREAD(file,buf,sizeofbuf) \ #define JFREAD(file,buf,sizeofbuf) \
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
#define JFWRITE(file,buf,sizeofbuf) \ #define JFWRITE(file,buf,sizeofbuf) \
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
#define JFFLUSH(file) fflush(file)
#define JFERROR(file) ferror(file)
#endif
typedef enum { /* JPEG marker codes */
M_SOF0 = 0xc0,
M_SOF1 = 0xc1,
M_SOF2 = 0xc2,
M_SOF3 = 0xc3,
M_SOF5 = 0xc5,
M_SOF6 = 0xc6,
M_SOF7 = 0xc7,
M_JPG = 0xc8,
M_SOF9 = 0xc9,
M_SOF10 = 0xca,
M_SOF11 = 0xcb,
M_SOF13 = 0xcd,
M_SOF14 = 0xce,
M_SOF15 = 0xcf,
M_DHT = 0xc4,
M_DAC = 0xcc,
M_RST0 = 0xd0,
M_RST1 = 0xd1,
M_RST2 = 0xd2,
M_RST3 = 0xd3,
M_RST4 = 0xd4,
M_RST5 = 0xd5,
M_RST6 = 0xd6,
M_RST7 = 0xd7,
M_SOI = 0xd8,
M_EOI = 0xd9,
M_SOS = 0xda,
M_DQT = 0xdb,
M_DNL = 0xdc,
M_DRI = 0xdd,
M_DHP = 0xde,
M_EXP = 0xdf,
M_APP0 = 0xe0,
M_APP1 = 0xe1,
M_APP2 = 0xe2,
M_APP3 = 0xe3,
M_APP4 = 0xe4,
M_APP5 = 0xe5,
M_APP6 = 0xe6,
M_APP7 = 0xe7,
M_APP8 = 0xe8,
M_APP9 = 0xe9,
M_APP10 = 0xea,
M_APP11 = 0xeb,
M_APP12 = 0xec,
M_APP13 = 0xed,
M_APP14 = 0xee,
M_APP15 = 0xef,
M_JPG0 = 0xf0,
M_JPG13 = 0xfd,
M_COM = 0xfe,
M_TEM = 0x01,
M_ERROR = 0x100
} JPEG_MARKER;
/*
* Figure F.12: extend sign bit.
* On some machines, a shift and add will be faster than a table lookup.
*/
#ifdef AVOID_TABLES
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
#else
#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
static const int extend_test[16] = /* entry n is 2**(n-1) */
{ 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
#define SHIFTED_BITS_PLUS_ONE(n) (int) (((unsigned int) -1) << n) + 1
static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */
{ 0,
SHIFTED_BITS_PLUS_ONE (1), SHIFTED_BITS_PLUS_ONE (2), SHIFTED_BITS_PLUS_ONE (3), SHIFTED_BITS_PLUS_ONE (4),
SHIFTED_BITS_PLUS_ONE (5), SHIFTED_BITS_PLUS_ONE (6), SHIFTED_BITS_PLUS_ONE (7), SHIFTED_BITS_PLUS_ONE (8),
SHIFTED_BITS_PLUS_ONE (9), SHIFTED_BITS_PLUS_ONE (10), SHIFTED_BITS_PLUS_ONE (11), SHIFTED_BITS_PLUS_ONE (12),
SHIFTED_BITS_PLUS_ONE (13), SHIFTED_BITS_PLUS_ONE (14), SHIFTED_BITS_PLUS_ONE (15) };
#undef SHIFTED_BITS_PLUS_ONE
#endif /* AVOID_TABLES */
#endif #endif

View file

@ -2,6 +2,7 @@
* jmemmgr.c * jmemmgr.c
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2011-2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -129,7 +130,7 @@ typedef struct {
jvirt_barray_ptr virt_barray_list; jvirt_barray_ptr virt_barray_list;
/* This counts total space obtained from jpeg_get_small/large */ /* This counts total space obtained from jpeg_get_small/large */
long total_space_allocated; size_t total_space_allocated;
/* alloc_sarray and alloc_barray set this value for use by virtual /* alloc_sarray and alloc_barray set this value for use by virtual
* array routines. * array routines.
@ -194,7 +195,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
* This is helpful because message parm array can't handle longs. * This is helpful because message parm array can't handle longs.
*/ */
fprintf(stderr, "Freeing pool %d, total space = %ld\n", fprintf(stderr, "Freeing pool %d, total space = %ld\n",
pool_id, mem->total_space_allocated); pool_id, (long) mem->total_space_allocated);
for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL;
lhdr_ptr = lhdr_ptr->hdr.next) { lhdr_ptr = lhdr_ptr->hdr.next) {
@ -213,7 +214,7 @@ print_mem_stats (j_common_ptr cinfo, int pool_id)
#endif /* MEM_STATS */ #endif /* MEM_STATS */
LOCAL(void) LOCAL(noreturn_t)
out_of_memory (j_common_ptr cinfo, int which) out_of_memory (j_common_ptr cinfo, int which)
/* Report an out-of-memory error and stop execution */ /* Report an out-of-memory error and stop execution */
/* If we compiled MEM_STATS support, report alloc requests before dying */ /* If we compiled MEM_STATS support, report alloc requests before dying */
@ -238,13 +239,13 @@ out_of_memory (j_common_ptr cinfo, int which)
* machines, but may be too small if longs are 64 bits or more. * machines, but may be too small if longs are 64 bits or more.
*/ */
static const size_t first_pool_slop[JPOOL_NUMPOOLS] = static const size_t first_pool_slop[JPOOL_NUMPOOLS] =
{ {
1600, /* first PERMANENT pool */ 1600, /* first PERMANENT pool */
16000 /* first IMAGE pool */ 16000 /* first IMAGE pool */
}; };
static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = static const size_t extra_pool_slop[JPOOL_NUMPOOLS] =
{ {
0, /* additional PERMANENT pools */ 0, /* additional PERMANENT pools */
5000 /* additional IMAGE pools */ 5000 /* additional IMAGE pools */
@ -259,11 +260,11 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
{ {
my_mem_ptr mem = (my_mem_ptr) cinfo->mem; my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
small_pool_ptr hdr_ptr, prev_hdr_ptr; small_pool_ptr hdr_ptr, prev_hdr_ptr;
char * data_ptr;
size_t odd_bytes, min_request, slop; size_t odd_bytes, min_request, slop;
char * data_ptr;
/* Check for unsatisfiable request (do now to ensure no overflow below) */ /* Check for unsatisfiable request (do now to ensure no overflow below) */
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(small_pool_hdr))
out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ out_of_memory(cinfo, 1); /* request exceeds malloc's ability */
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
@ -292,8 +293,8 @@ alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
else else
slop = extra_pool_slop[pool_id]; slop = extra_pool_slop[pool_id];
/* Don't ask for more than MAX_ALLOC_CHUNK */ /* Don't ask for more than MAX_ALLOC_CHUNK */
if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) if (slop > (size_t) MAX_ALLOC_CHUNK - min_request)
slop = (size_t) (MAX_ALLOC_CHUNK-min_request); slop = (size_t) MAX_ALLOC_CHUNK - min_request;
/* Try to get space, if fail reduce slop and try again */ /* Try to get space, if fail reduce slop and try again */
for (;;) { for (;;) {
hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop);
@ -347,7 +348,7 @@ alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject)
size_t odd_bytes; size_t odd_bytes;
/* Check for unsatisfiable request (do now to ensure no overflow below) */ /* Check for unsatisfiable request (do now to ensure no overflow below) */
if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) if (sizeofobject > (size_t) MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr))
out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ out_of_memory(cinfo, 3); /* request exceeds malloc's ability */
/* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */
@ -403,7 +404,7 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
long ltemp; long ltemp;
/* Calculate max # of rows allowed in one allocation chunk */ /* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
((long) samplesperrow * SIZEOF(JSAMPLE)); ((long) samplesperrow * SIZEOF(JSAMPLE));
if (ltemp <= 0) if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
@ -415,15 +416,14 @@ alloc_sarray (j_common_ptr cinfo, int pool_id,
/* Get space for row pointers (small object) */ /* Get space for row pointers (small object) */
result = (JSAMPARRAY) alloc_small(cinfo, pool_id, result = (JSAMPARRAY) alloc_small(cinfo, pool_id,
(size_t) (numrows * SIZEOF(JSAMPROW))); (size_t) numrows * SIZEOF(JSAMPROW));
/* Get the rows themselves (large objects) */ /* Get the rows themselves (large objects) */
currow = 0; currow = 0;
while (currow < numrows) { while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow); rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JSAMPROW) alloc_large(cinfo, pool_id, workspace = (JSAMPROW) alloc_large(cinfo, pool_id,
(size_t) ((size_t) rowsperchunk * (size_t) samplesperrow (size_t) rowsperchunk * (size_t) samplesperrow * SIZEOF(JSAMPLE));
* SIZEOF(JSAMPLE)));
for (i = rowsperchunk; i > 0; i--) { for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace; result[currow++] = workspace;
workspace += samplesperrow; workspace += samplesperrow;
@ -451,7 +451,7 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
long ltemp; long ltemp;
/* Calculate max # of rows allowed in one allocation chunk */ /* Calculate max # of rows allowed in one allocation chunk */
ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / ltemp = (MAX_ALLOC_CHUNK - SIZEOF(large_pool_hdr)) /
((long) blocksperrow * SIZEOF(JBLOCK)); ((long) blocksperrow * SIZEOF(JBLOCK));
if (ltemp <= 0) if (ltemp <= 0)
ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
@ -463,15 +463,14 @@ alloc_barray (j_common_ptr cinfo, int pool_id,
/* Get space for row pointers (small object) */ /* Get space for row pointers (small object) */
result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, result = (JBLOCKARRAY) alloc_small(cinfo, pool_id,
(size_t) (numrows * SIZEOF(JBLOCKROW))); (size_t) numrows * SIZEOF(JBLOCKROW));
/* Get the rows themselves (large objects) */ /* Get the rows themselves (large objects) */
currow = 0; currow = 0;
while (currow < numrows) { while (currow < numrows) {
rowsperchunk = MIN(rowsperchunk, numrows - currow); rowsperchunk = MIN(rowsperchunk, numrows - currow);
workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, workspace = (JBLOCKROW) alloc_large(cinfo, pool_id,
(size_t) ((size_t) rowsperchunk * (size_t) blocksperrow (size_t) rowsperchunk * (size_t) blocksperrow * SIZEOF(JBLOCK));
* SIZEOF(JBLOCK)));
for (i = rowsperchunk; i > 0; i--) { for (i = rowsperchunk; i > 0; i--) {
result[currow++] = workspace; result[currow++] = workspace;
workspace += blocksperrow; workspace += blocksperrow;
@ -584,8 +583,8 @@ realize_virt_arrays (j_common_ptr cinfo)
/* Allocate the in-memory buffers for any unrealized virtual arrays */ /* Allocate the in-memory buffers for any unrealized virtual arrays */
{ {
my_mem_ptr mem = (my_mem_ptr) cinfo->mem; my_mem_ptr mem = (my_mem_ptr) cinfo->mem;
long space_per_minheight, maximum_space, avail_mem; long bytesperrow, space_per_minheight, maximum_space;
long minheights, max_minheights; long avail_mem, minheights, max_minheights;
jvirt_sarray_ptr sptr; jvirt_sarray_ptr sptr;
jvirt_barray_ptr bptr; jvirt_barray_ptr bptr;
@ -597,18 +596,16 @@ realize_virt_arrays (j_common_ptr cinfo)
maximum_space = 0; maximum_space = 0;
for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) {
if (sptr->mem_buffer == NULL) { /* if not realized yet */ if (sptr->mem_buffer == NULL) { /* if not realized yet */
space_per_minheight += (long) sptr->maxaccess * bytesperrow = (long) sptr->samplesperrow * SIZEOF(JSAMPLE);
(long) sptr->samplesperrow * SIZEOF(JSAMPLE); space_per_minheight += (long) sptr->maxaccess * bytesperrow;
maximum_space += (long) sptr->rows_in_array * maximum_space += (long) sptr->rows_in_array * bytesperrow;
(long) sptr->samplesperrow * SIZEOF(JSAMPLE);
} }
} }
for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) {
if (bptr->mem_buffer == NULL) { /* if not realized yet */ if (bptr->mem_buffer == NULL) { /* if not realized yet */
space_per_minheight += (long) bptr->maxaccess * bytesperrow = (long) bptr->blocksperrow * SIZEOF(JBLOCK);
(long) bptr->blocksperrow * SIZEOF(JBLOCK); space_per_minheight += (long) bptr->maxaccess * bytesperrow;
maximum_space += (long) bptr->rows_in_array * maximum_space += (long) bptr->rows_in_array * bytesperrow;
(long) bptr->blocksperrow * SIZEOF(JBLOCK);
} }
} }
@ -617,7 +614,7 @@ realize_virt_arrays (j_common_ptr cinfo)
/* Determine amount of memory to actually use; this is system-dependent. */ /* Determine amount of memory to actually use; this is system-dependent. */
avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space,
mem->total_space_allocated); (long) mem->total_space_allocated);
/* If the maximum space needed is available, make all the buffers full /* If the maximum space needed is available, make all the buffers full
* height; otherwise parcel it out with the same number of minheights * height; otherwise parcel it out with the same number of minheights
@ -693,7 +690,7 @@ do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing)
long bytesperrow, file_offset, byte_count, rows, thisrow, i; long bytesperrow, file_offset, byte_count, rows, thisrow, i;
bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE);
file_offset = ptr->cur_start_row * bytesperrow; file_offset = (long) ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */ /* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
/* One chunk, but check for short chunk at end of buffer */ /* One chunk, but check for short chunk at end of buffer */
@ -726,7 +723,7 @@ do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing)
long bytesperrow, file_offset, byte_count, rows, thisrow, i; long bytesperrow, file_offset, byte_count, rows, thisrow, i;
bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK);
file_offset = ptr->cur_start_row * bytesperrow; file_offset = (long) ptr->cur_start_row * bytesperrow;
/* Loop to read or write each allocation chunk in mem_buffer */ /* Loop to read or write each allocation chunk in mem_buffer */
for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) {
/* One chunk, but check for short chunk at end of buffer */ /* One chunk, but check for short chunk at end of buffer */
@ -770,7 +767,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
/* Make the desired part of the virtual array accessible */ /* Make the desired part of the virtual array accessible */
if (start_row < ptr->cur_start_row || if (start_row < ptr->cur_start_row ||
end_row > ptr->cur_start_row+ptr->rows_in_mem) { end_row > ptr->cur_start_row + ptr->rows_in_mem) {
if (! ptr->b_s_open) if (! ptr->b_s_open)
ERREXIT(cinfo, JERR_VIRTUAL_BUG); ERREXIT(cinfo, JERR_VIRTUAL_BUG);
/* Flush old buffer contents if necessary */ /* Flush old buffer contents if necessary */
@ -821,7 +818,7 @@ access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr,
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
end_row -= ptr->cur_start_row; end_row -= ptr->cur_start_row;
while (undef_row < end_row) { while (undef_row < end_row) {
jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); FMEMZERO((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
undef_row++; undef_row++;
} }
} else { } else {
@ -855,7 +852,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
/* Make the desired part of the virtual array accessible */ /* Make the desired part of the virtual array accessible */
if (start_row < ptr->cur_start_row || if (start_row < ptr->cur_start_row ||
end_row > ptr->cur_start_row+ptr->rows_in_mem) { end_row > ptr->cur_start_row + ptr->rows_in_mem) {
if (! ptr->b_s_open) if (! ptr->b_s_open)
ERREXIT(cinfo, JERR_VIRTUAL_BUG); ERREXIT(cinfo, JERR_VIRTUAL_BUG);
/* Flush old buffer contents if necessary */ /* Flush old buffer contents if necessary */
@ -906,7 +903,7 @@ access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr,
undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */
end_row -= ptr->cur_start_row; end_row -= ptr->cur_start_row;
while (undef_row < end_row) { while (undef_row < end_row) {
jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); FMEMZERO((void FAR *) ptr->mem_buffer[undef_row], bytesperrow);
undef_row++; undef_row++;
} }
} else { } else {
@ -1030,7 +1027,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
my_mem_ptr mem; my_mem_ptr mem;
long max_to_use; long max_to_use;
int pool; int pool;
// size_t test_mac; size_t test_mac;
cinfo->mem = NULL; /* for safety if init fails */ cinfo->mem = NULL; /* for safety if init fails */
@ -1048,10 +1045,10 @@ jinit_memory_mgr (j_common_ptr cinfo)
* Again, an "unreachable code" warning may be ignored here. * Again, an "unreachable code" warning may be ignored here.
* But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK.
*/ */
// test_mac = (size_t) MAX_ALLOC_CHUNK; test_mac = (size_t) MAX_ALLOC_CHUNK;
// if ((long) test_mac != MAX_ALLOC_CHUNK || if ((long) test_mac != MAX_ALLOC_CHUNK ||
// (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0)
// ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */
@ -1092,7 +1089,7 @@ jinit_memory_mgr (j_common_ptr cinfo)
mem->total_space_allocated = SIZEOF(my_memory_mgr); mem->total_space_allocated = SIZEOF(my_memory_mgr);
/* Declare ourselves open for business */ /* Declare ourselves open for business */
cinfo->mem = & mem->pub; cinfo->mem = &mem->pub;
/* Check for an environment variable JPEGMEM; if found, override the /* Check for an environment variable JPEGMEM; if found, override the
* default max_memory setting from jpeg_mem_init. Note that the * default max_memory setting from jpeg_mem_init. Note that the

View file

@ -2,6 +2,7 @@
* jmemnobs.c * jmemnobs.c
* *
* Copyright (C) 1992-1996, Thomas G. Lane. * Copyright (C) 1992-1996, Thomas G. Lane.
* Modified 2019 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -12,7 +13,7 @@
* This is very portable in the sense that it'll compile on almost anything, * This is very portable in the sense that it'll compile on almost anything,
* but you'd better have lots of main memory (or virtual memory) if you want * but you'd better have lots of main memory (or virtual memory) if you want
* to process big images. * to process big images.
* Note that the max_memory_to_use option is ignored by this implementation. * Note that the max_memory_to_use option is respected by this implementation.
*/ */
#define JPEG_INTERNALS #define JPEG_INTERNALS
@ -32,13 +33,13 @@ extern void free JPP((void *ptr));
*/ */
GLOBAL(void *) GLOBAL(void *)
jpeg_get_small (j_common_ptr , size_t sizeofobject) jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
{ {
return (void *) malloc(sizeofobject); return (void *) malloc(sizeofobject);
} }
GLOBAL(void) GLOBAL(void)
jpeg_free_small (j_common_ptr , void * object, size_t) jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
{ {
free(object); free(object);
} }
@ -52,13 +53,13 @@ jpeg_free_small (j_common_ptr , void * object, size_t)
*/ */
GLOBAL(void FAR *) GLOBAL(void FAR *)
jpeg_get_large (j_common_ptr, size_t sizeofobject) jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
{ {
return (void FAR *) malloc(sizeofobject); return (void FAR *) malloc(sizeofobject);
} }
GLOBAL(void) GLOBAL(void)
jpeg_free_large (j_common_ptr, void FAR * object, size_t) jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
{ {
free(object); free(object);
} }
@ -66,13 +67,16 @@ jpeg_free_large (j_common_ptr, void FAR * object, size_t)
/* /*
* This routine computes the total memory space available for allocation. * This routine computes the total memory space available for allocation.
* Here we always say, "we got all you want bud!"
*/ */
GLOBAL(long) GLOBAL(long)
jpeg_mem_available (j_common_ptr, long, jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
long max_bytes_needed, long) long max_bytes_needed, long already_allocated)
{ {
if (cinfo->mem->max_memory_to_use)
return cinfo->mem->max_memory_to_use - already_allocated;
/* Here we say, "we got all you want bud!" */
return max_bytes_needed; return max_bytes_needed;
} }
@ -84,8 +88,8 @@ jpeg_mem_available (j_common_ptr, long,
*/ */
GLOBAL(void) GLOBAL(void)
jpeg_open_backing_store (j_common_ptr cinfo, struct backing_store_struct *, jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
long ) long total_bytes_needed)
{ {
ERREXIT(cinfo, JERR_NO_BACKING_STORE); ERREXIT(cinfo, JERR_NO_BACKING_STORE);
} }
@ -97,13 +101,13 @@ jpeg_open_backing_store (j_common_ptr cinfo, struct backing_store_struct *,
*/ */
GLOBAL(long) GLOBAL(long)
jpeg_mem_init (j_common_ptr) jpeg_mem_init (j_common_ptr cinfo)
{ {
return 0; /* just set max_memory_to_use to 0 */ return 0; /* just set max_memory_to_use to 0 */
} }
GLOBAL(void) GLOBAL(void)
jpeg_mem_term (j_common_ptr) jpeg_mem_term (j_common_ptr cinfo)
{ {
/* no work */ /* no work */
} }

View file

@ -18,8 +18,6 @@
* and USE_MAC_MEMMGR. * and USE_MAC_MEMMGR.
*/ */
#ifndef __jmemsys_h__
#define __jmemsys_h__
/* Short forms of external names for systems with brain-damaged linkers. */ /* Short forms of external names for systems with brain-damaged linkers. */
@ -136,20 +134,20 @@ typedef union {
#endif /* USE_MAC_MEMMGR */ #endif /* USE_MAC_MEMMGR */
//typedef struct backing_store_struct * backing_store_ptr; typedef struct backing_store_struct * backing_store_ptr;
typedef struct backing_store_struct { typedef struct backing_store_struct {
/* Methods for reading/writing/closing this backing-store object */ /* Methods for reading/writing/closing this backing-store object */
JMETHOD(void, read_backing_store, (j_common_ptr cinfo, JMETHOD(void, read_backing_store, (j_common_ptr cinfo,
struct backing_store_struct *info, backing_store_ptr info,
void FAR * buffer_address, void FAR * buffer_address,
long file_offset, long byte_count)); long file_offset, long byte_count));
JMETHOD(void, write_backing_store, (j_common_ptr cinfo, JMETHOD(void, write_backing_store, (j_common_ptr cinfo,
struct backing_store_struct *info, backing_store_ptr info,
void FAR * buffer_address, void FAR * buffer_address,
long file_offset, long byte_count)); long file_offset, long byte_count));
JMETHOD(void, close_backing_store, (j_common_ptr cinfo, JMETHOD(void, close_backing_store, (j_common_ptr cinfo,
struct backing_store_struct *info)); backing_store_ptr info));
/* Private fields for system-dependent backing-store management */ /* Private fields for system-dependent backing-store management */
#ifdef USE_MSDOS_MEMMGR #ifdef USE_MSDOS_MEMMGR
@ -180,7 +178,7 @@ typedef struct backing_store_struct {
*/ */
EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo,
struct backing_store_struct *info, backing_store_ptr info,
long total_bytes_needed)); long total_bytes_needed));
@ -198,6 +196,3 @@ EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo,
EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo));
EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo));
#endif

View file

@ -2,6 +2,7 @@
* jmorecfg.h * jmorecfg.h
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -14,13 +15,22 @@
/* /*
* Define BITS_IN_JSAMPLE as either * Define BITS_IN_JSAMPLE as either
* 8 for 8-bit sample values (the usual setting) * 8 for 8-bit sample values (the usual setting)
* 9 for 9-bit sample values
* 10 for 10-bit sample values
* 11 for 11-bit sample values
* 12 for 12-bit sample values * 12 for 12-bit sample values
* Only 8 and 12 are legal data precisions for lossy JPEG according to the * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
* JPEG standard, and the IJG code does not support anything else! * full-feature DCT processing. Further depths up to 16-bit may be added
* We do not support run-time selection of data precision, sorry. * later for the lossless modes of operation.
* Run-time selection and conversion of data precision will be added later
* and are currently not supported, sorry.
* Exception: The transcoding part (jpegtran) supports all settings in a
* single instance, since it operates on the level of DCT coefficients and
* not sample values. The DCT coefficients are of the same type (16 bits)
* in all cases (see below).
*/ */
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ #define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */
/* /*
@ -76,6 +86,48 @@ typedef char JSAMPLE;
#endif /* BITS_IN_JSAMPLE == 8 */ #endif /* BITS_IN_JSAMPLE == 8 */
#if BITS_IN_JSAMPLE == 9
/* JSAMPLE should be the smallest type that will hold the values 0..511.
* On nearly all machines "short" will do nicely.
*/
typedef short JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#define MAXJSAMPLE 511
#define CENTERJSAMPLE 256
#endif /* BITS_IN_JSAMPLE == 9 */
#if BITS_IN_JSAMPLE == 10
/* JSAMPLE should be the smallest type that will hold the values 0..1023.
* On nearly all machines "short" will do nicely.
*/
typedef short JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#define MAXJSAMPLE 1023
#define CENTERJSAMPLE 512
#endif /* BITS_IN_JSAMPLE == 10 */
#if BITS_IN_JSAMPLE == 11
/* JSAMPLE should be the smallest type that will hold the values 0..2047.
* On nearly all machines "short" will do nicely.
*/
typedef short JSAMPLE;
#define GETJSAMPLE(value) ((int) (value))
#define MAXJSAMPLE 2047
#define CENTERJSAMPLE 1024
#endif /* BITS_IN_JSAMPLE == 11 */
#if BITS_IN_JSAMPLE == 12 #if BITS_IN_JSAMPLE == 12
/* JSAMPLE should be the smallest type that will hold the values 0..4095. /* JSAMPLE should be the smallest type that will hold the values 0..4095.
* On nearly all machines "short" will do nicely. * On nearly all machines "short" will do nicely.
@ -158,8 +210,14 @@ typedef short INT16;
/* INT32 must hold at least signed 32-bit values. */ /* INT32 must hold at least signed 32-bit values. */
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
#ifndef _BASETSD_H /* MinGW is slightly different */
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
typedef long INT32; typedef long INT32;
#endif #endif
#endif
#endif
#endif
/* Datatype used for image dimensions. The JPEG standard only supports /* Datatype used for image dimensions. The JPEG standard only supports
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
@ -203,17 +261,39 @@ typedef unsigned int JDIMENSION;
#endif #endif
/* The noreturn type identifier is used to declare functions
* which cannot return.
* Compilers can thus create more optimized code and perform
* better checks for warnings and errors.
* Static analyzer tools can make improved inferences about
* execution paths and are prevented from giving false alerts.
*
* Unfortunately, the proposed specifications of corresponding
* extensions in the Dec 2011 ISO C standard revision (C11),
* GCC, MSVC, etc. are not viable.
* Thus we introduce a user defined type to declare noreturn
* functions at least for clarity. A proper compiler would
* have a suitable noreturn type to match in place of void.
*/
#ifndef HAVE_NORETURN_T
typedef void noreturn_t;
#endif
/* Here is the pseudo-keyword for declaring pointers that must be "far" /* Here is the pseudo-keyword for declaring pointers that must be "far"
* on 80x86 machines. Most of the specialized coding for 80x86 is handled * on 80x86 machines. Most of the specialized coding for 80x86 is handled
* by just saying "FAR *" where such a pointer is needed. In a few places * by just saying "FAR *" where such a pointer is needed. In a few places
* explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
*/ */
#ifndef FAR
#ifdef NEED_FAR_POINTERS #ifdef NEED_FAR_POINTERS
#define FAR far #define FAR far
#else #else
#define FAR #define FAR
#endif #endif
#endif
/* /*
@ -224,14 +304,19 @@ typedef unsigned int JDIMENSION;
*/ */
#ifndef HAVE_BOOLEAN #ifndef HAVE_BOOLEAN
#if defined FALSE || defined TRUE || defined QGLOBAL_H
/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
typedef int boolean; typedef int boolean;
#endif
#ifndef FALSE /* in case these macros already exist */ #ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */ #define FALSE 0 /* values of boolean */
#endif #endif
#ifndef TRUE #ifndef TRUE
#define TRUE 1 #define TRUE 1
#endif #endif
#else
typedef enum { FALSE = 0, TRUE = 1 } boolean;
#endif
#endif
/* /*
@ -256,8 +341,6 @@ typedef int boolean;
* (You may HAVE to do that if your compiler doesn't like null source files.) * (You may HAVE to do that if your compiler doesn't like null source files.)
*/ */
/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */
/* Capability options common to encoder and decoder: */ /* Capability options common to encoder and decoder: */
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
@ -266,15 +349,17 @@ typedef int boolean;
/* Encoder capability options: */ /* Encoder capability options: */
#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ #define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */
#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW) */
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
/* Note: if you selected 12-bit data precision, it is dangerous to turn off /* Note: if you selected more than 8-bit data precision, it is dangerous to
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit * turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
* precision, so jchuff.c normally uses entropy optimization to compute * good for 8-bit precision, so arithmetic coding is recommended for higher
* usable tables for higher precision. If you don't want to do optimization, * precision. The Huffman encoder normally uses entropy optimization to
* you'll have to supply different default Huffman tables. * compute usable tables for higher precision. Otherwise, you'll have to
* supply different default Huffman tables.
* The exact same statements apply for progressive JPEG: the default tables * The exact same statements apply for progressive JPEG: the default tables
* don't work for progressive mode. (This may get fixed, however.) * don't work for progressive mode. (This may get fixed, however.)
*/ */
@ -282,12 +367,12 @@ typedef int boolean;
/* Decoder capability options: */ /* Decoder capability options: */
#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ #define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN) */
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW) */
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
@ -299,22 +384,31 @@ typedef int boolean;
/* /*
* Ordering of RGB data in scanlines passed to or from the application. * Ordering of RGB data in scanlines passed to or from the application.
* If your application wants to deal with data in the order B,G,R, just * If your application wants to deal with data in the order B,G,R, just
* change these macros. You can also deal with formats such as R,G,B,X * #define JPEG_USE_RGB_CUSTOM in jconfig.h, or define your own custom
* (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing * order in jconfig.h and #define JPEG_HAVE_RGB_CUSTOM.
* the offsets will also change the order in which colormap data is organized. * You can also deal with formats such as R,G,B,X (one extra byte per pixel)
* by changing RGB_PIXELSIZE.
* Note that changing the offsets will also change
* the order in which colormap data is organized.
* RESTRICTIONS: * RESTRICTIONS:
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
* 2. These macros only affect RGB<=>YCbCr color conversion, so they are not * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
* useful if you are using JPEG color spaces other than YCbCr or grayscale. * is not 3 (they don't understand about dummy color components!).
* 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE * So you can't use color quantization if you change that value.
* is not 3 (they don't understand about dummy color components!). So you
* can't use color quantization if you change that value.
*/ */
#ifndef JPEG_HAVE_RGB_CUSTOM
#ifdef JPEG_USE_RGB_CUSTOM
#define RGB_RED 2 /* Offset of Red in an RGB scanline element */
#define RGB_GREEN 1 /* Offset of Green */
#define RGB_BLUE 0 /* Offset of Blue */
#else
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
#define RGB_GREEN 1 /* Offset of Green */ #define RGB_GREEN 1 /* Offset of Green */
#define RGB_BLUE 2 /* Offset of Blue */ #define RGB_BLUE 2 /* Offset of Blue */
#endif
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
#endif
/* Definitions for speed-related optimizations. */ /* Definitions for speed-related optimizations. */

View file

@ -2,6 +2,7 @@
* jpegint.h * jpegint.h
* *
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -99,20 +100,21 @@ struct jpeg_downsampler {
}; };
/* Forward DCT (also controls coefficient quantization) */ /* Forward DCT (also controls coefficient quantization) */
typedef JMETHOD(void, forward_DCT_ptr,
(j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_col, JDIMENSION num_blocks));
struct jpeg_forward_dct { struct jpeg_forward_dct {
JMETHOD(void, start_pass, (j_compress_ptr cinfo)); JMETHOD(void, start_pass, (j_compress_ptr cinfo));
/* perhaps this should be an array??? */ /* It is useful to allow each component to have a separate FDCT method. */
JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, forward_DCT_ptr forward_DCT[MAX_COMPONENTS];
jpeg_component_info * compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks));
}; };
/* Entropy encoding */ /* Entropy encoding */
struct jpeg_entropy_encoder { struct jpeg_entropy_encoder {
JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics));
JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKARRAY MCU_data));
JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); JMETHOD(void, finish_pass, (j_compress_ptr cinfo));
}; };
@ -208,12 +210,8 @@ struct jpeg_marker_reader {
/* Entropy decoding */ /* Entropy decoding */
struct jpeg_entropy_decoder { struct jpeg_entropy_decoder {
JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); JMETHOD(void, start_pass, (j_decompress_ptr cinfo));
JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, JBLOCKARRAY MCU_data));
JBLOCKROW *MCU_data)); JMETHOD(void, finish_pass, (j_decompress_ptr cinfo));
/* This is here to share code between baseline and progressive decoders; */
/* other modules probably should not use it */
boolean insufficient_data; /* set TRUE after emitting warning */
}; };
/* Inverse DCT (also performs dequantization) */ /* Inverse DCT (also performs dequantization) */
@ -261,6 +259,19 @@ struct jpeg_color_quantizer {
}; };
/* Definition of range extension bits for decompression processes.
* See the comments with prepare_range_limit_table (in jdmaster.c)
* for more info.
* The recommended default value for normal applications is 2.
* Applications with special requirements may use a different value.
* For example, Ghostscript wants to use 3 for proper handling of
* wacky images with oversize coefficient values.
*/
#define RANGE_BITS 2
#define RANGE_CENTER (CENTERJSAMPLE << RANGE_BITS)
/* Miscellaneous useful macros */ /* Miscellaneous useful macros */
#undef MAX #undef MAX
@ -290,6 +301,13 @@ struct jpeg_color_quantizer {
#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) #define RIGHT_SHIFT(x,shft) ((x) >> (shft))
#endif #endif
/* Descale and correctly round an INT32 value that's scaled by N bits.
* We assume RIGHT_SHIFT rounds towards minus infinity, so adding
* the fudge factor is correct for either sign of X.
*/
#define DESCALE(x,n) RIGHT_SHIFT((x) + ((INT32) 1 << ((n)-1)), n)
/* Short forms of external names for systems with brain-damaged linkers. */ /* Short forms of external names for systems with brain-damaged linkers. */
@ -303,7 +321,7 @@ struct jpeg_color_quantizer {
#define jinit_downsampler jIDownsampler #define jinit_downsampler jIDownsampler
#define jinit_forward_dct jIFDCT #define jinit_forward_dct jIFDCT
#define jinit_huff_encoder jIHEncoder #define jinit_huff_encoder jIHEncoder
#define jinit_phuff_encoder jIPHEncoder #define jinit_arith_encoder jIAEncoder
#define jinit_marker_writer jIMWriter #define jinit_marker_writer jIMWriter
#define jinit_master_decompress jIDMaster #define jinit_master_decompress jIDMaster
#define jinit_d_main_controller jIDMainC #define jinit_d_main_controller jIDMainC
@ -312,7 +330,7 @@ struct jpeg_color_quantizer {
#define jinit_input_controller jIInCtlr #define jinit_input_controller jIInCtlr
#define jinit_marker_reader jIMReader #define jinit_marker_reader jIMReader
#define jinit_huff_decoder jIHDecoder #define jinit_huff_decoder jIHDecoder
#define jinit_phuff_decoder jIPHDecoder #define jinit_arith_decoder jIADecoder
#define jinit_inverse_dct jIIDCT #define jinit_inverse_dct jIIDCT
#define jinit_upsampler jIUpsampler #define jinit_upsampler jIUpsampler
#define jinit_color_deconverter jIDColor #define jinit_color_deconverter jIDColor
@ -322,14 +340,41 @@ struct jpeg_color_quantizer {
#define jinit_memory_mgr jIMemMgr #define jinit_memory_mgr jIMemMgr
#define jdiv_round_up jDivRound #define jdiv_round_up jDivRound
#define jround_up jRound #define jround_up jRound
#define jzero_far jZeroFar
#define jcopy_sample_rows jCopySamples #define jcopy_sample_rows jCopySamples
#define jcopy_block_row jCopyBlocks #define jcopy_block_row jCopyBlocks
#define jzero_far jZeroFar
#define jpeg_zigzag_order jZIGTable #define jpeg_zigzag_order jZIGTable
#define jpeg_natural_order jZAGTable #define jpeg_natural_order jZAGTable
#define jpeg_natural_order7 jZAG7Table
#define jpeg_natural_order6 jZAG6Table
#define jpeg_natural_order5 jZAG5Table
#define jpeg_natural_order4 jZAG4Table
#define jpeg_natural_order3 jZAG3Table
#define jpeg_natural_order2 jZAG2Table
#define jpeg_aritab jAriTab
#endif /* NEED_SHORT_EXTERNAL_NAMES */ #endif /* NEED_SHORT_EXTERNAL_NAMES */
/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays
* and coefficient-block arrays. This won't work on 80x86 because the arrays
* are FAR and we're assuming a small-pointer memory model. However, some
* DOS compilers provide far-pointer versions of memcpy() and memset() even
* in the small-model libraries. These will be used if USE_FMEM is defined.
* Otherwise, the routines in jutils.c do it the hard way.
*/
#ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */
#define FMEMZERO(target,size) MEMZERO(target,size)
#else /* 80x86 case */
#ifdef USE_FMEM
#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size))
#else
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
#define FMEMZERO(target,size) jzero_far(target, size)
#endif
#endif
/* Compression module initialization routines */ /* Compression module initialization routines */
EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo,
@ -344,7 +389,7 @@ EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_arith_encoder JPP((j_compress_ptr cinfo));
EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo));
/* Decompression module initialization routines */ /* Decompression module initialization routines */
EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo));
@ -357,7 +402,7 @@ EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo,
EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_arith_decoder JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo));
EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo));
@ -370,17 +415,25 @@ EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo));
/* Utility routines in jutils.c */ /* Utility routines in jutils.c */
EXTERN(long) jdiv_round_up JPP((long a, long b)); EXTERN(long) jdiv_round_up JPP((long a, long b));
EXTERN(long) jround_up JPP((long a, long b)); EXTERN(long) jround_up JPP((long a, long b));
EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array,
JSAMPARRAY output_array, int dest_row, JSAMPARRAY output_array,
int num_rows, JDIMENSION num_cols)); int num_rows, JDIMENSION num_cols));
EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row,
JDIMENSION num_blocks)); JDIMENSION num_blocks));
EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero));
/* Constant tables in jutils.c */ /* Constant tables in jutils.c */
#if 0 /* This table is not actually needed in v6a */ #if 0 /* This table is not actually needed in v6a */
extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */
#endif #endif
extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
extern const int jpeg_natural_order7[]; /* zz to natural order for 7x7 block */
extern const int jpeg_natural_order6[]; /* zz to natural order for 6x6 block */
extern const int jpeg_natural_order5[]; /* zz to natural order for 5x5 block */
extern const int jpeg_natural_order4[]; /* zz to natural order for 4x4 block */
extern const int jpeg_natural_order3[]; /* zz to natural order for 3x3 block */
extern const int jpeg_natural_order2[]; /* zz to natural order for 2x2 block */
/* Arithmetic coding probability estimation tables in jaricom.c */
extern const INT32 jpeg_aritab[];
/* Suppress undefined-structure complaints if necessary. */ /* Suppress undefined-structure complaints if necessary. */

View file

@ -2,6 +2,7 @@
* jpeglib.h * jpeglib.h
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2002-2022 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -26,19 +27,27 @@
#include "jmorecfg.h" /* seldom changed options */ #include "jmorecfg.h" /* seldom changed options */
/* Version ID for the JPEG library. #ifdef __cplusplus
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". #ifndef DONT_USE_EXTERN_C
extern "C" {
#endif
#endif
/* Version IDs for the JPEG library.
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 90".
*/ */
#define JPEG_LIB_VERSION 62 /* Version 6b */ #define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
#define JPEG_LIB_VERSION_MAJOR 9
#define JPEG_LIB_VERSION_MINOR 6
/* Various constants determining the sizes of things. /* Various constants determining the sizes of things.
* All of these are specified by the JPEG standard, so don't change them * All of these are specified by the JPEG standard,
* if you want to be compatible. * so don't change them if you want to be compatible.
*/ */
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ #define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ #define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ #define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ #define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
@ -138,33 +147,38 @@ typedef struct {
*/ */
JDIMENSION width_in_blocks; JDIMENSION width_in_blocks;
JDIMENSION height_in_blocks; JDIMENSION height_in_blocks;
/* Size of a DCT block in samples. Always DCTSIZE for compression. /* Size of a DCT block in samples,
* For decompression this is the size of the output from one DCT block, * reflecting any scaling we choose to apply during the DCT step.
* reflecting any scaling we choose to apply during the IDCT step. * Values from 1 to 16 are supported.
* Values of 1,2,4,8 are likely to be supported. Note that different * Note that different components may receive different DCT scalings.
* components may receive different IDCT scalings.
*/ */
int DCT_scaled_size; int DCT_h_scaled_size;
int DCT_v_scaled_size;
/* The downsampled dimensions are the component's actual, unpadded number /* The downsampled dimensions are the component's actual, unpadded number
* of samples at the main buffer (preprocessing/compression interface), thus * of samples at the main buffer (preprocessing/compression interface);
* downsampled_width = ceil(image_width * Hi/Hmax) * DCT scaling is included, so
* and similarly for height. For decompression, IDCT scaling is included, so * downsampled_width =
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) * ceil(image_width * Hi/Hmax * DCT_h_scaled_size/block_size)
* and similarly for height.
*/ */
JDIMENSION downsampled_width; /* actual width in samples */ JDIMENSION downsampled_width; /* actual width in samples */
JDIMENSION downsampled_height; /* actual height in samples */ JDIMENSION downsampled_height; /* actual height in samples */
/* This flag is used only for decompression. In cases where some of the /* For decompression, in cases where some of the components will be
* components will be ignored (eg grayscale output from YCbCr image), * ignored (eg grayscale output from YCbCr image), we can skip most
* we can skip most computations for the unused components. * computations for the unused components.
* For compression, some of the components will need further quantization
* scale by factor of 2 after DCT (eg BG_YCC output from normal RGB input).
* The field is first set TRUE for decompression, FALSE for compression
* in initial_setup, and then adapted in color conversion setup.
*/ */
boolean component_needed; /* do we need the value of this component? */ boolean component_needed;
/* These values are computed before starting a scan of the component. */ /* These values are computed before starting a scan of the component. */
/* The decompressor output side may not use these variables. */ /* The decompressor output side may not use these variables. */
int MCU_width; /* number of blocks per MCU, horizontally */ int MCU_width; /* number of blocks per MCU, horizontally */
int MCU_height; /* number of blocks per MCU, vertically */ int MCU_height; /* number of blocks per MCU, vertically */
int MCU_blocks; /* MCU_width * MCU_height */ int MCU_blocks; /* MCU_width * MCU_height */
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ int MCU_sample_width; /* MCU width in samples: MCU_width * DCT_h_scaled_size */
int last_col_width; /* # of non-dummy blocks across in last MCU */ int last_col_width; /* # of non-dummy blocks across in last MCU */
int last_row_height; /* # of non-dummy blocks down in last MCU */ int last_row_height; /* # of non-dummy blocks down in last MCU */
@ -206,12 +220,21 @@ struct jpeg_marker_struct {
typedef enum { typedef enum {
JCS_UNKNOWN, /* error/unspecified */ JCS_UNKNOWN, /* error/unspecified */
JCS_GRAYSCALE, /* monochrome */ JCS_GRAYSCALE, /* monochrome */
JCS_RGB, /* red/green/blue */ JCS_RGB, /* red/green/blue, standard RGB (sRGB) */
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ JCS_YCbCr, /* Y/Cb/Cr (also known as YUV), standard YCC */
JCS_CMYK, /* C/M/Y/K */ JCS_CMYK, /* C/M/Y/K */
JCS_YCCK /* Y/Cb/Cr/K */ JCS_YCCK, /* Y/Cb/Cr/K */
JCS_BG_RGB, /* big gamut red/green/blue, bg-sRGB */
JCS_BG_YCC /* big gamut Y/Cb/Cr, bg-sYCC */
} J_COLOR_SPACE; } J_COLOR_SPACE;
/* Supported color transforms. */
typedef enum {
JCT_NONE = 0,
JCT_SUBTRACT_GREEN = 1
} J_COLOR_TRANSFORM;
/* DCT/IDCT algorithm options. */ /* DCT/IDCT algorithm options. */
typedef enum { typedef enum {
@ -291,6 +314,17 @@ struct jpeg_compress_struct {
* helper routines to simplify changing parameters. * helper routines to simplify changing parameters.
*/ */
unsigned int scale_num, scale_denom; /* fraction by which to scale image */
JDIMENSION jpeg_width; /* scaled JPEG image width */
JDIMENSION jpeg_height; /* scaled JPEG image height */
/* Dimensions of actual JPEG image that will be written to file,
* derived from input dimensions by scaling factors above.
* These fields are computed by jpeg_start_compress().
* You can also use jpeg_calc_jpeg_dimensions() to determine these values
* in advance of calling jpeg_start_compress().
*/
int data_precision; /* bits of precision in image data */ int data_precision; /* bits of precision in image data */
int num_components; /* # of color components in JPEG image */ int num_components; /* # of color components in JPEG image */
@ -300,7 +334,10 @@ struct jpeg_compress_struct {
/* comp_info[i] describes component that appears i'th in SOF */ /* comp_info[i] describes component that appears i'th in SOF */
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS];
/* ptrs to coefficient quantization tables, or NULL if not defined */ int q_scale_factor[NUM_QUANT_TBLS];
/* ptrs to coefficient quantization tables, or NULL if not defined,
* and corresponding scale factors (percentage, initialized 100).
*/
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
@ -321,6 +358,7 @@ struct jpeg_compress_struct {
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */
int smoothing_factor; /* 1..100, or 0 for no input smoothing */ int smoothing_factor; /* 1..100, or 0 for no input smoothing */
J_DCT_METHOD dct_method; /* DCT algorithm selector */ J_DCT_METHOD dct_method; /* DCT algorithm selector */
@ -346,6 +384,9 @@ struct jpeg_compress_struct {
UINT16 Y_density; /* Vertical pixel density */ UINT16 Y_density; /* Vertical pixel density */
boolean write_Adobe_marker; /* should an Adobe marker be written? */ boolean write_Adobe_marker; /* should an Adobe marker be written? */
J_COLOR_TRANSFORM color_transform;
/* Color transform identifier, writes LSE marker if nonzero */
/* State variable: index of next scanline to be written to /* State variable: index of next scanline to be written to
* jpeg_write_scanlines(). Application may use this to control its * jpeg_write_scanlines(). Application may use this to control its
* processing loop, e.g., "while (next_scanline < image_height)". * processing loop, e.g., "while (next_scanline < image_height)".
@ -364,11 +405,14 @@ struct jpeg_compress_struct {
int max_h_samp_factor; /* largest h_samp_factor */ int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */ int max_v_samp_factor; /* largest v_samp_factor */
int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */
/* The coefficient controller receives data in units of MCU rows as defined /* The coefficient controller receives data in units of MCU rows as defined
* for fully interleaved scans (whether the JPEG file is interleaved or not). * for fully interleaved scans (whether the JPEG file is interleaved or not).
* There are v_samp_factor * DCTSIZE sample rows of each component in an * There are v_samp_factor * DCT_v_scaled_size sample rows of each component
* "iMCU" (interleaved MCU) row. * in an "iMCU" (interleaved MCU) row.
*/ */
/* /*
@ -389,6 +433,10 @@ struct jpeg_compress_struct {
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array */
int lim_Se; /* min( Se, DCTSIZE2-1 ) */
/* /*
* Links to compression subobjects (methods and private variables of modules) * Links to compression subobjects (methods and private variables of modules)
*/ */
@ -535,6 +583,7 @@ struct jpeg_decompress_struct {
jpeg_component_info * comp_info; jpeg_component_info * comp_info;
/* comp_info[i] describes component that appears i'th in SOF */ /* comp_info[i] describes component that appears i'th in SOF */
boolean is_baseline; /* TRUE if Baseline SOF0 encountered */
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */
@ -557,6 +606,9 @@ struct jpeg_decompress_struct {
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
UINT8 Adobe_transform; /* Color transform code from Adobe marker */ UINT8 Adobe_transform; /* Color transform code from Adobe marker */
J_COLOR_TRANSFORM color_transform;
/* Color transform identifier derived from LSE marker, otherwise zero */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */ boolean CCIR601_sampling; /* TRUE=first samples are cosited */
/* Aside from the specific data retained from APPn markers known to the /* Aside from the specific data retained from APPn markers known to the
@ -575,7 +627,8 @@ struct jpeg_decompress_struct {
int max_h_samp_factor; /* largest h_samp_factor */ int max_h_samp_factor; /* largest h_samp_factor */
int max_v_samp_factor; /* largest v_samp_factor */ int max_v_samp_factor; /* largest v_samp_factor */
int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */
int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */
JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */
/* The coefficient controller's input and output progress is measured in /* The coefficient controller's input and output progress is measured in
@ -583,7 +636,7 @@ struct jpeg_decompress_struct {
* in fully interleaved JPEG scans, but are used whether the scan is * in fully interleaved JPEG scans, but are used whether the scan is
* interleaved or not. We define an iMCU row as v_samp_factor DCT block * interleaved or not. We define an iMCU row as v_samp_factor DCT block
* rows of each component. Therefore, the IDCT output contains * rows of each component. Therefore, the IDCT output contains
* v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. * v_samp_factor * DCT_v_scaled_size sample rows of a component per iMCU row.
*/ */
JSAMPLE * sample_range_limit; /* table for fast range-limiting */ JSAMPLE * sample_range_limit; /* table for fast range-limiting */
@ -607,6 +660,12 @@ struct jpeg_decompress_struct {
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */
/* These fields are derived from Se of first SOS marker.
*/
int block_size; /* the basic DCT block size: 1..16 */
const int * natural_order; /* natural-order position array for entropy decode */
int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */
/* This field is shared between entropy decoder and marker parser. /* This field is shared between entropy decoder and marker parser.
* It is either zero or the code of a JPEG marker that has been * It is either zero or the code of a JPEG marker that has been
* read from the data source, but has not yet been processed. * read from the data source, but has not yet been processed.
@ -642,7 +701,7 @@ struct jpeg_decompress_struct {
struct jpeg_error_mgr { struct jpeg_error_mgr {
/* Error exit handler: does not return to caller */ /* Error exit handler: does not return to caller */
JMETHOD(void, error_exit, (j_common_ptr cinfo)); JMETHOD(noreturn_t, error_exit, (j_common_ptr cinfo));
/* Conditionally emit a trace or warning message */ /* Conditionally emit a trace or warning message */
JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
/* Routine that actually outputs a trace or error message */ /* Routine that actually outputs a trace or error message */
@ -824,7 +883,7 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
/* Short forms of external names for systems with brain-damaged linkers. /* Short forms of external names for systems with brain-damaged linkers.
* We shorten external names to be unique in the first six letters, which * We shorten external names to be unique in the first six letters, which
* is good enough for all known systems. * is good enough for all known systems.
* (If your compiler itself needs names to be unique in less than 15 * (If your compiler itself needs names to be unique in less than 15
* characters, you are out of luck. Get a better compiler.) * characters, you are out of luck. Get a better compiler.)
*/ */
@ -836,20 +895,25 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
#define jpeg_destroy_decompress jDestDecompress #define jpeg_destroy_decompress jDestDecompress
#define jpeg_stdio_dest jStdDest #define jpeg_stdio_dest jStdDest
#define jpeg_stdio_src jStdSrc #define jpeg_stdio_src jStdSrc
#define jpeg_mem_dest jMemDest
#define jpeg_mem_src jMemSrc
#define jpeg_set_defaults jSetDefaults #define jpeg_set_defaults jSetDefaults
#define jpeg_set_colorspace jSetColorspace #define jpeg_set_colorspace jSetColorspace
#define jpeg_default_colorspace jDefColorspace #define jpeg_default_colorspace jDefColorspace
#define jpeg_set_quality jSetQuality #define jpeg_set_quality jSetQuality
#define jpeg_set_linear_quality jSetLQuality #define jpeg_set_linear_quality jSetLQuality
#define jpeg_default_qtables jDefQTables
#define jpeg_add_quant_table jAddQuantTable #define jpeg_add_quant_table jAddQuantTable
#define jpeg_quality_scaling jQualityScaling #define jpeg_quality_scaling jQualityScaling
#define jpeg_simple_progression jSimProgress #define jpeg_simple_progression jSimProgress
#define jpeg_suppress_tables jSuppressTables #define jpeg_suppress_tables jSuppressTables
#define jpeg_alloc_quant_table jAlcQTable #define jpeg_alloc_quant_table jAlcQTable
#define jpeg_alloc_huff_table jAlcHTable #define jpeg_alloc_huff_table jAlcHTable
#define jpeg_std_huff_table jStdHTable
#define jpeg_start_compress jStrtCompress #define jpeg_start_compress jStrtCompress
#define jpeg_write_scanlines jWrtScanlines #define jpeg_write_scanlines jWrtScanlines
#define jpeg_finish_compress jFinCompress #define jpeg_finish_compress jFinCompress
#define jpeg_calc_jpeg_dimensions jCjpegDimensions
#define jpeg_write_raw_data jWrtRawData #define jpeg_write_raw_data jWrtRawData
#define jpeg_write_marker jWrtMarker #define jpeg_write_marker jWrtMarker
#define jpeg_write_m_header jWrtMHeader #define jpeg_write_m_header jWrtMHeader
@ -866,6 +930,7 @@ typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo));
#define jpeg_input_complete jInComplete #define jpeg_input_complete jInComplete
#define jpeg_new_colormap jNewCMap #define jpeg_new_colormap jNewCMap
#define jpeg_consume_input jConsumeInput #define jpeg_consume_input jConsumeInput
#define jpeg_core_output_dimensions jCoreDimensions
#define jpeg_calc_output_dimensions jCalcDimensions #define jpeg_calc_output_dimensions jCalcDimensions
#define jpeg_save_markers jSaveMarkers #define jpeg_save_markers jSaveMarkers
#define jpeg_set_marker_processor jSetMarker #define jpeg_set_marker_processor jSetMarker
@ -910,6 +975,14 @@ EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo));
EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));
EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));
/* Data source and destination managers: memory buffers. */
EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo,
unsigned char ** outbuffer,
size_t * outsize));
EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo,
const unsigned char * inbuffer,
size_t insize));
/* Default parameter setup for compression */ /* Default parameter setup for compression */
EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo));
/* Compression parameter setup aids */ /* Compression parameter setup aids */
@ -921,6 +994,8 @@ EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality,
EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo,
int scale_factor, int scale_factor,
boolean force_baseline)); boolean force_baseline));
EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo,
boolean force_baseline));
EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl,
const unsigned int *basic_table, const unsigned int *basic_table,
int scale_factor, int scale_factor,
@ -931,6 +1006,8 @@ EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo,
boolean suppress)); boolean suppress));
EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo));
EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo));
EXTERN(JHUFF_TBL *) jpeg_std_huff_table JPP((j_common_ptr cinfo,
boolean isDC, int tblno));
/* Main entry points for compression */ /* Main entry points for compression */
EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo,
@ -940,12 +1017,15 @@ EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo,
JDIMENSION num_lines)); JDIMENSION num_lines));
EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo));
/* Precalculate JPEG dimensions for current compression parameters. */
EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo));
/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ /* Replaces jpeg_write_scanlines when writing raw downsampled data. */
EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo,
JSAMPIMAGE data, JSAMPIMAGE data,
JDIMENSION num_lines)); JDIMENSION num_lines));
/* Write a special marker. See libjpeg.doc concerning safe usage. */ /* Write a special marker. See libjpeg.txt concerning safe usage. */
EXTERN(void) jpeg_write_marker EXTERN(void) jpeg_write_marker
JPP((j_compress_ptr cinfo, int marker, JPP((j_compress_ptr cinfo, int marker,
const JOCTET * dataptr, unsigned int datalen)); const JOCTET * dataptr, unsigned int datalen));
@ -999,6 +1079,7 @@ EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo));
#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ #define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */
/* Precalculate output dimensions for current decompression parameters. */ /* Precalculate output dimensions for current decompression parameters. */
EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo));
EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo));
/* Control saving of COM and APPn markers into marker_list. */ /* Control saving of COM and APPn markers into marker_list. */
@ -1093,4 +1174,10 @@ struct jpeg_color_quantizer { long dummy; };
#include "jerror.h" /* fetch error codes too */ #include "jerror.h" /* fetch error codes too */
#endif #endif
#ifdef __cplusplus
#ifndef DONT_USE_EXTERN_C
}
#endif
#endif
#endif /* JPEGLIB_H */ #endif /* JPEGLIB_H */

View file

@ -2,6 +2,7 @@
* jquant1.c * jquant1.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2011-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -242,7 +243,7 @@ select_ncolors (j_decompress_ptr cinfo, int Ncolors[])
LOCAL(int) LOCAL(int)
output_value (j_decompress_ptr, int, int j, int maxj) output_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
/* Return j'th output value, where j will range from 0 to maxj */ /* Return j'th output value, where j will range from 0 to maxj */
/* The output values must fall in 0..MAXJSAMPLE in increasing order */ /* The output values must fall in 0..MAXJSAMPLE in increasing order */
{ {
@ -256,7 +257,7 @@ output_value (j_decompress_ptr, int, int j, int maxj)
LOCAL(int) LOCAL(int)
largest_input_value (j_decompress_ptr, int, int j, int maxj) largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj)
/* Return largest input value that should map to j'th output value */ /* Return largest input value that should map to j'th output value */
/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ /* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */
{ {
@ -292,8 +293,7 @@ create_colormap (j_decompress_ptr cinfo)
/* The colors are ordered in the map in standard row-major order, */ /* The colors are ordered in the map in standard row-major order, */
/* i.e. rightmost (highest-indexed) color changes most rapidly. */ /* i.e. rightmost (highest-indexed) color changes most rapidly. */
colormap = (*cinfo->mem->alloc_sarray) colormap = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE,
((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components);
/* blksize is number of adjacent repeated entries for a component */ /* blksize is number of adjacent repeated entries for a component */
@ -399,9 +399,8 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
int j,k; int j,k;
INT32 num,den; INT32 num,den;
odither = (ODITHER_MATRIX_PTR) odither = (ODITHER_MATRIX_PTR) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(ODITHER_MATRIX));
SIZEOF(ODITHER_MATRIX));
/* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1).
* Hence the dither value for the matrix cell with fill order f * Hence the dither value for the matrix cell with fill order f
* (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1).
@ -424,7 +423,7 @@ make_odither_array (j_decompress_ptr cinfo, int ncolors)
/* /*
* Create the ordered-dither tables. * Create the ordered-dither tables.
* Components having the same number of representative colors may * Components having the same number of representative colors may
* share a dither table. * share a dither table.
*/ */
@ -462,12 +461,12 @@ color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
JSAMPARRAY colorindex = cquantize->colorindex; JSAMPARRAY colorindex = cquantize->colorindex;
int pixcode, ci; register int pixcode, ci;
JSAMPROW ptrin, ptrout; register JSAMPROW ptrin, ptrout;
int row; int row;
JDIMENSION col; JDIMENSION col;
JDIMENSION width = cinfo->output_width; JDIMENSION width = cinfo->output_width;
int nc = cinfo->out_color_components; register int nc = cinfo->out_color_components;
for (row = 0; row < num_rows; row++) { for (row = 0; row < num_rows; row++) {
ptrin = input_buf[row]; ptrin = input_buf[row];
@ -489,8 +488,8 @@ color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
/* Fast path for out_color_components==3, no dithering */ /* Fast path for out_color_components==3, no dithering */
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
int pixcode; register int pixcode;
JSAMPROW ptrin, ptrout; register JSAMPROW ptrin, ptrout;
JSAMPROW colorindex0 = cquantize->colorindex[0]; JSAMPROW colorindex0 = cquantize->colorindex[0];
JSAMPROW colorindex1 = cquantize->colorindex[1]; JSAMPROW colorindex1 = cquantize->colorindex[1];
JSAMPROW colorindex2 = cquantize->colorindex[2]; JSAMPROW colorindex2 = cquantize->colorindex[2];
@ -517,8 +516,8 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
/* General case, with ordered dithering */ /* General case, with ordered dithering */
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
JSAMPROW input_ptr; register JSAMPROW input_ptr;
JSAMPROW output_ptr; register JSAMPROW output_ptr;
JSAMPROW colorindex_ci; JSAMPROW colorindex_ci;
int * dither; /* points to active row of dither matrix */ int * dither; /* points to active row of dither matrix */
int row_index, col_index; /* current indexes into dither matrix */ int row_index, col_index; /* current indexes into dither matrix */
@ -530,8 +529,7 @@ quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
for (row = 0; row < num_rows; row++) { for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */ /* Initialize output values to 0 so can process components separately */
jzero_far((void FAR *) output_buf[row], FMEMZERO((void FAR *) output_buf[row], (size_t) width * SIZEOF(JSAMPLE));
(size_t) (width * SIZEOF(JSAMPLE)));
row_index = cquantize->row_index; row_index = cquantize->row_index;
for (ci = 0; ci < nc; ci++) { for (ci = 0; ci < nc; ci++) {
input_ptr = input_buf[row] + ci; input_ptr = input_buf[row] + ci;
@ -567,9 +565,9 @@ quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
/* Fast path for out_color_components==3, with ordered dithering */ /* Fast path for out_color_components==3, with ordered dithering */
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
int pixcode; register int pixcode;
JSAMPROW input_ptr; register JSAMPROW input_ptr;
JSAMPROW output_ptr; register JSAMPROW output_ptr;
JSAMPROW colorindex0 = cquantize->colorindex[0]; JSAMPROW colorindex0 = cquantize->colorindex[0];
JSAMPROW colorindex1 = cquantize->colorindex[1]; JSAMPROW colorindex1 = cquantize->colorindex[1];
JSAMPROW colorindex2 = cquantize->colorindex[2]; JSAMPROW colorindex2 = cquantize->colorindex[2];
@ -612,14 +610,14 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
/* General case, with Floyd-Steinberg dithering */ /* General case, with Floyd-Steinberg dithering */
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
LOCFSERROR cur; /* current error or pixel value */ register LOCFSERROR cur; /* current error or pixel value */
LOCFSERROR belowerr; /* error for pixel below cur */ LOCFSERROR belowerr; /* error for pixel below cur */
LOCFSERROR bpreverr; /* error for below/prev col */ LOCFSERROR bpreverr; /* error for below/prev col */
LOCFSERROR bnexterr; /* error for below/next col */ LOCFSERROR bnexterr; /* error for below/next col */
LOCFSERROR delta; LOCFSERROR delta;
FSERRPTR errorptr; /* => fserrors[] at column before current */ register FSERRPTR errorptr; /* => fserrors[] at column before current */
JSAMPROW input_ptr; register JSAMPROW input_ptr;
JSAMPROW output_ptr; register JSAMPROW output_ptr;
JSAMPROW colorindex_ci; JSAMPROW colorindex_ci;
JSAMPROW colormap_ci; JSAMPROW colormap_ci;
int pixcode; int pixcode;
@ -635,8 +633,7 @@ quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
for (row = 0; row < num_rows; row++) { for (row = 0; row < num_rows; row++) {
/* Initialize output values to 0 so can process components separately */ /* Initialize output values to 0 so can process components separately */
jzero_far((void FAR *) output_buf[row], FMEMZERO((void FAR *) output_buf[row], (size_t) width * SIZEOF(JSAMPLE));
(size_t) (width * SIZEOF(JSAMPLE)));
for (ci = 0; ci < nc; ci++) { for (ci = 0; ci < nc; ci++) {
input_ptr = input_buf[row] + ci; input_ptr = input_buf[row] + ci;
output_ptr = output_buf[row]; output_ptr = output_buf[row];
@ -725,10 +722,10 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
size_t arraysize; size_t arraysize;
int i; int i;
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); arraysize = ((size_t) cinfo->output_width + (size_t) 2) * SIZEOF(FSERROR);
for (i = 0; i < cinfo->out_color_components; i++) { for (i = 0; i < cinfo->out_color_components; i++) {
cquantize->fserrors[i] = (FSERRPTR) cquantize->fserrors[i] = (FSERRPTR) (*cinfo->mem->alloc_large)
(*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
} }
} }
@ -738,7 +735,7 @@ alloc_fs_workspace (j_decompress_ptr cinfo)
*/ */
METHODDEF(void) METHODDEF(void)
start_pass_1_quant (j_decompress_ptr cinfo, boolean) start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
{ {
my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
size_t arraysize; size_t arraysize;
@ -779,13 +776,12 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean)
if (cquantize->fserrors[0] == NULL) if (cquantize->fserrors[0] == NULL)
alloc_fs_workspace(cinfo); alloc_fs_workspace(cinfo);
/* Initialize the propagated errors to zero. */ /* Initialize the propagated errors to zero. */
arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); arraysize = ((size_t) cinfo->output_width + (size_t) 2) * SIZEOF(FSERROR);
for (i = 0; i < cinfo->out_color_components; i++) for (i = 0; i < cinfo->out_color_components; i++)
jzero_far((void FAR *) cquantize->fserrors[i], arraysize); FMEMZERO((void FAR *) cquantize->fserrors[i], arraysize);
break; break;
default: default:
ERREXIT(cinfo, JERR_NOT_COMPILED); ERREXIT(cinfo, JERR_NOT_COMPILED);
break;
} }
} }
@ -795,7 +791,7 @@ start_pass_1_quant (j_decompress_ptr cinfo, boolean)
*/ */
METHODDEF(void) METHODDEF(void)
finish_pass_1_quant (j_decompress_ptr) finish_pass_1_quant (j_decompress_ptr cinfo)
{ {
/* no work in 1-pass case */ /* no work in 1-pass case */
} }
@ -822,10 +818,9 @@ jinit_1pass_quantizer (j_decompress_ptr cinfo)
{ {
my_cquantize_ptr cquantize; my_cquantize_ptr cquantize;
cquantize = (my_cquantize_ptr) cquantize = (my_cquantize_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_cquantizer));
SIZEOF(my_cquantizer)); cinfo->cquantize = &cquantize->pub;
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
cquantize->pub.start_pass = start_pass_1_quant; cquantize->pub.start_pass = start_pass_1_quant;
cquantize->pub.finish_pass = finish_pass_1_quant; cquantize->pub.finish_pass = finish_pass_1_quant;
cquantize->pub.new_color_map = new_color_map_1_quant; cquantize->pub.new_color_map = new_color_map_1_quant;

View file

@ -2,6 +2,7 @@
* jquant2.c * jquant2.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2011-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -41,7 +42,7 @@
* color space, and repeatedly splits the "largest" remaining box until we * color space, and repeatedly splits the "largest" remaining box until we
* have as many boxes as desired colors. Then the mean color in each * have as many boxes as desired colors. Then the mean color in each
* remaining box becomes one of the possible output colors. * remaining box becomes one of the possible output colors.
* *
* The second pass over the image maps each input pixel to the closest output * The second pass over the image maps each input pixel to the closest output
* color (optionally after applying a Floyd-Steinberg dithering correction). * color (optionally after applying a Floyd-Steinberg dithering correction).
* This mapping is logically trivial, but making it go fast enough requires * This mapping is logically trivial, but making it go fast enough requires
@ -206,9 +207,9 @@ typedef struct {
FSERRPTR fserrors; /* accumulated errors */ FSERRPTR fserrors; /* accumulated errors */
boolean on_odd_row; /* flag to remember which row we are on */ boolean on_odd_row; /* flag to remember which row we are on */
int * error_limiter; /* table for clamping the applied error */ int * error_limiter; /* table for clamping the applied error */
} my_cquantizer2; } my_cquantizer;
typedef my_cquantizer2 * my_cquantize_ptr2; typedef my_cquantizer * my_cquantize_ptr;
/* /*
@ -222,12 +223,12 @@ typedef my_cquantizer2 * my_cquantize_ptr2;
METHODDEF(void) METHODDEF(void)
prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, prescan_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf,
JSAMPARRAY, int num_rows) JSAMPARRAY output_buf, int num_rows)
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
JSAMPROW ptr; register JSAMPROW ptr;
histptr histp; register histptr histp;
hist3d histogram = cquantize->histogram; register hist3d histogram = cquantize->histogram;
int row; int row;
JDIMENSION col; JDIMENSION col;
JDIMENSION width = cinfo->output_width; JDIMENSION width = cinfo->output_width;
@ -274,11 +275,11 @@ find_biggest_color_pop (boxptr boxlist, int numboxes)
/* Find the splittable box with the largest color population */ /* Find the splittable box with the largest color population */
/* Returns NULL if no splittable boxes remain */ /* Returns NULL if no splittable boxes remain */
{ {
boxptr boxp; register boxptr boxp;
int i; register int i;
long maxc = 0; register long maxc = 0;
boxptr which = NULL; boxptr which = NULL;
for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
if (boxp->colorcount > maxc && boxp->volume > 0) { if (boxp->colorcount > maxc && boxp->volume > 0) {
which = boxp; which = boxp;
@ -294,11 +295,11 @@ find_biggest_volume (boxptr boxlist, int numboxes)
/* Find the splittable box with the largest (scaled) volume */ /* Find the splittable box with the largest (scaled) volume */
/* Returns NULL if no splittable boxes remain */ /* Returns NULL if no splittable boxes remain */
{ {
boxptr boxp; register boxptr boxp;
int i; register int i;
INT32 maxv = 0; register INT32 maxv = 0;
boxptr which = NULL; boxptr which = NULL;
for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) {
if (boxp->volume > maxv) { if (boxp->volume > maxv) {
which = boxp; which = boxp;
@ -314,18 +315,18 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ /* Shrink the min/max bounds of a box to enclose only nonzero elements, */
/* and recompute its volume and population */ /* and recompute its volume and population */
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram; hist3d histogram = cquantize->histogram;
histptr histp; histptr histp;
int c0,c1,c2; int c0,c1,c2;
int c0min,c0max,c1min,c1max,c2min,c2max; int c0min,c0max,c1min,c1max,c2min,c2max;
INT32 dist0,dist1,dist2; INT32 dist0,dist1,dist2;
long ccount; long ccount;
c0min = boxp->c0min; c0max = boxp->c0max; c0min = boxp->c0min; c0max = boxp->c0max;
c1min = boxp->c1min; c1max = boxp->c1max; c1min = boxp->c1min; c1max = boxp->c1max;
c2min = boxp->c2min; c2max = boxp->c2max; c2min = boxp->c2min; c2max = boxp->c2max;
if (c0max > c0min) if (c0max > c0min)
for (c0 = c0min; c0 <= c0max; c0++) for (c0 = c0min; c0 <= c0max; c0++)
for (c1 = c1min; c1 <= c1max; c1++) { for (c1 = c1min; c1 <= c1max; c1++) {
@ -405,7 +406,7 @@ update_box (j_decompress_ptr cinfo, boxptr boxp)
dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE;
dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE;
boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2;
/* Now scan remaining volume of box and compute population */ /* Now scan remaining volume of box and compute population */
ccount = 0; ccount = 0;
for (c0 = c0min; c0 <= c0max; c0++) for (c0 = c0min; c0 <= c0max; c0++)
@ -427,7 +428,7 @@ median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes,
{ {
int n,lb; int n,lb;
int c0,c1,c2,cmax; int c0,c1,c2,cmax;
boxptr b1,b2; register boxptr b1,b2;
while (numboxes < desired_colors) { while (numboxes < desired_colors) {
/* Select box to split. /* Select box to split.
@ -501,7 +502,7 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
{ {
/* Current algorithm: mean weighted by pixels (not colors) */ /* Current algorithm: mean weighted by pixels (not colors) */
/* Note it is important to get the rounding correct! */ /* Note it is important to get the rounding correct! */
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram; hist3d histogram = cquantize->histogram;
histptr histp; histptr histp;
int c0,c1,c2; int c0,c1,c2;
@ -511,11 +512,11 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
long c0total = 0; long c0total = 0;
long c1total = 0; long c1total = 0;
long c2total = 0; long c2total = 0;
c0min = boxp->c0min; c0max = boxp->c0max; c0min = boxp->c0min; c0max = boxp->c0max;
c1min = boxp->c1min; c1max = boxp->c1max; c1min = boxp->c1min; c1max = boxp->c1max;
c2min = boxp->c2min; c2max = boxp->c2max; c2min = boxp->c2min; c2max = boxp->c2max;
for (c0 = c0min; c0 <= c0max; c0++) for (c0 = c0min; c0 <= c0max; c0++)
for (c1 = c1min; c1 <= c1max; c1++) { for (c1 = c1min; c1 <= c1max; c1++) {
histp = & histogram[c0][c1][c2min]; histp = & histogram[c0][c1][c2min];
@ -528,7 +529,7 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
} }
} }
} }
cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);
@ -783,12 +784,12 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
{ {
int ic0, ic1, ic2; int ic0, ic1, ic2;
int i, icolor; int i, icolor;
INT32 * bptr; /* pointer into bestdist[] array */ register INT32 * bptr; /* pointer into bestdist[] array */
JSAMPLE * cptr; /* pointer into bestcolor[] array */ JSAMPLE * cptr; /* pointer into bestcolor[] array */
INT32 dist0, dist1; /* initial distance values */ INT32 dist0, dist1; /* initial distance values */
INT32 dist2; /* current distance in inner loop */ register INT32 dist2; /* current distance in inner loop */
INT32 xx0, xx1; /* distance increments */ INT32 xx0, xx1; /* distance increments */
INT32 xx2; register INT32 xx2;
INT32 inc0, inc1, inc2; /* initial values for increments */ INT32 inc0, inc1, inc2; /* initial values for increments */
/* This array holds the distance to the nearest-so-far color for each cell */ /* This array holds the distance to the nearest-so-far color for each cell */
INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS];
@ -797,17 +798,17 @@ find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2,
bptr = bestdist; bptr = bestdist;
for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--)
*bptr++ = 0x7FFFFFFFL; *bptr++ = 0x7FFFFFFFL;
/* For each color selected by find_nearby_colors, /* For each color selected by find_nearby_colors,
* compute its distance to the center of each cell in the box. * compute its distance to the center of each cell in the box.
* If that's less than best-so-far, update best distance and color number. * If that's less than best-so-far, update best distance and color number.
*/ */
/* Nominal steps between cell centers ("x" in Thomas article) */ /* Nominal steps between cell centers ("x" in Thomas article) */
#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) #define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE)
#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) #define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE)
#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) #define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE)
for (i = 0; i < numcolors; i++) { for (i = 0; i < numcolors; i++) {
icolor = GETJSAMPLE(colorlist[i]); icolor = GETJSAMPLE(colorlist[i]);
/* Compute (square of) distance from minc0/c1/c2 to this color */ /* Compute (square of) distance from minc0/c1/c2 to this color */
@ -857,12 +858,12 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ /* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */
/* we can fill as many others as we wish.) */ /* we can fill as many others as we wish.) */
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram; hist3d histogram = cquantize->histogram;
int minc0, minc1, minc2; /* lower left corner of update box */ int minc0, minc1, minc2; /* lower left corner of update box */
int ic0, ic1, ic2; int ic0, ic1, ic2;
JSAMPLE * cptr; /* pointer into bestcolor[] array */ register JSAMPLE * cptr; /* pointer into bestcolor[] array */
histptr cachep; /* pointer into main cache array */ register histptr cachep; /* pointer into main cache array */
/* This array lists the candidate colormap indexes. */ /* This array lists the candidate colormap indexes. */
JSAMPLE colorlist[MAXNUMCOLORS]; JSAMPLE colorlist[MAXNUMCOLORS];
int numcolors; /* number of candidate colors */ int numcolors; /* number of candidate colors */
@ -881,7 +882,7 @@ fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2)
minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1);
minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1);
minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1);
/* Determine which colormap entries are close enough to be candidates /* Determine which colormap entries are close enough to be candidates
* for the nearest entry to some cell in the update box. * for the nearest entry to some cell in the update box.
*/ */
@ -916,11 +917,11 @@ pass2_no_dither (j_decompress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
/* This version performs no dithering */ /* This version performs no dithering */
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram; hist3d histogram = cquantize->histogram;
JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
histptr cachep; register histptr cachep;
int c0, c1, c2; register int c0, c1, c2;
int row; int row;
JDIMENSION col; JDIMENSION col;
JDIMENSION width = cinfo->output_width; JDIMENSION width = cinfo->output_width;
@ -950,12 +951,12 @@ pass2_fs_dither (j_decompress_ptr cinfo,
JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows)
/* This version performs Floyd-Steinberg dithering */ /* This version performs Floyd-Steinberg dithering */
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram; hist3d histogram = cquantize->histogram;
LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */
LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */
LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */
FSERRPTR errorptr; /* => fserrors[] at column before current */ register FSERRPTR errorptr; /* => fserrors[] at column before current */
JSAMPROW inptr; /* => current input pixel */ JSAMPROW inptr; /* => current input pixel */
JSAMPROW outptr; /* => current output pixel */ JSAMPROW outptr; /* => current output pixel */
histptr cachep; histptr cachep;
@ -1030,7 +1031,7 @@ pass2_fs_dither (j_decompress_ptr cinfo,
if (*cachep == 0) if (*cachep == 0)
fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT);
/* Now emit the colormap index for this cell */ /* Now emit the colormap index for this cell */
{ int pixcode = *cachep - 1; { register int pixcode = *cachep - 1;
*outptr = (JSAMPLE) pixcode; *outptr = (JSAMPLE) pixcode;
/* Compute representation error for this pixel */ /* Compute representation error for this pixel */
cur0 -= GETJSAMPLE(colormap0[pixcode]); cur0 -= GETJSAMPLE(colormap0[pixcode]);
@ -1041,7 +1042,7 @@ pass2_fs_dither (j_decompress_ptr cinfo,
* Add these into the running sums, and simultaneously shift the * Add these into the running sums, and simultaneously shift the
* next-line error sums left by 1 column. * next-line error sums left by 1 column.
*/ */
{ LOCFSERROR bnexterr, delta; { register LOCFSERROR bnexterr, delta;
bnexterr = cur0; /* Process component 0 */ bnexterr = cur0; /* Process component 0 */
delta = cur0 * 2; delta = cur0 * 2;
@ -1108,7 +1109,7 @@ LOCAL(void)
init_error_limit (j_decompress_ptr cinfo) init_error_limit (j_decompress_ptr cinfo)
/* Allocate and fill in the error_limiter table */ /* Allocate and fill in the error_limiter table */
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
int * table; int * table;
int in, out; int in, out;
@ -1142,7 +1143,7 @@ init_error_limit (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
finish_pass1 (j_decompress_ptr cinfo) finish_pass1 (j_decompress_ptr cinfo)
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
/* Select the representative colors and fill in cinfo->colormap */ /* Select the representative colors and fill in cinfo->colormap */
cinfo->colormap = cquantize->sv_colormap; cinfo->colormap = cquantize->sv_colormap;
@ -1153,7 +1154,7 @@ finish_pass1 (j_decompress_ptr cinfo)
METHODDEF(void) METHODDEF(void)
finish_pass2 (j_decompress_ptr) finish_pass2 (j_decompress_ptr cinfo)
{ {
/* no work */ /* no work */
} }
@ -1166,7 +1167,7 @@ finish_pass2 (j_decompress_ptr)
METHODDEF(void) METHODDEF(void)
start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
hist3d histogram = cquantize->histogram; hist3d histogram = cquantize->histogram;
int i; int i;
@ -1196,14 +1197,14 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
if (cinfo->dither_mode == JDITHER_FS) { if (cinfo->dither_mode == JDITHER_FS) {
size_t arraysize = (size_t) ((cinfo->output_width + 2) * size_t arraysize = ((size_t) cinfo->output_width + (size_t) 2)
(3 * SIZEOF(FSERROR))); * (3 * SIZEOF(FSERROR));
/* Allocate Floyd-Steinberg workspace if we didn't already. */ /* Allocate Floyd-Steinberg workspace if we didn't already. */
if (cquantize->fserrors == NULL) if (cquantize->fserrors == NULL)
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize);
/* Initialize the propagated errors to zero. */ /* Initialize the propagated errors to zero. */
jzero_far((void FAR *) cquantize->fserrors, arraysize); FMEMZERO((void FAR *) cquantize->fserrors, arraysize);
/* Make the error-limit table if we didn't already. */ /* Make the error-limit table if we didn't already. */
if (cquantize->error_limiter == NULL) if (cquantize->error_limiter == NULL)
init_error_limit(cinfo); init_error_limit(cinfo);
@ -1214,8 +1215,8 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
/* Zero the histogram or inverse color map, if necessary */ /* Zero the histogram or inverse color map, if necessary */
if (cquantize->needs_zeroed) { if (cquantize->needs_zeroed) {
for (i = 0; i < HIST_C0_ELEMS; i++) { for (i = 0; i < HIST_C0_ELEMS; i++) {
jzero_far((void FAR *) histogram[i], FMEMZERO((void FAR *) histogram[i],
HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell));
} }
cquantize->needs_zeroed = FALSE; cquantize->needs_zeroed = FALSE;
} }
@ -1229,7 +1230,7 @@ start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan)
METHODDEF(void) METHODDEF(void)
new_color_map_2_quant (j_decompress_ptr cinfo) new_color_map_2_quant (j_decompress_ptr cinfo)
{ {
my_cquantize_ptr2 cquantize = (my_cquantize_ptr2) cinfo->cquantize; my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize;
/* Reset the inverse color map */ /* Reset the inverse color map */
cquantize->needs_zeroed = TRUE; cquantize->needs_zeroed = TRUE;
@ -1243,13 +1244,12 @@ new_color_map_2_quant (j_decompress_ptr cinfo)
GLOBAL(void) GLOBAL(void)
jinit_2pass_quantizer (j_decompress_ptr cinfo) jinit_2pass_quantizer (j_decompress_ptr cinfo)
{ {
my_cquantize_ptr2 cquantize; my_cquantize_ptr cquantize;
int i; int i;
cquantize = (my_cquantize_ptr2) cquantize = (my_cquantize_ptr) (*cinfo->mem->alloc_small)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(my_cquantizer));
SIZEOF(my_cquantizer2)); cinfo->cquantize = &cquantize->pub;
cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
cquantize->pub.start_pass = start_pass_2_quant; cquantize->pub.start_pass = start_pass_2_quant;
cquantize->pub.new_color_map = new_color_map_2_quant; cquantize->pub.new_color_map = new_color_map_2_quant;
cquantize->fserrors = NULL; /* flag optional arrays not allocated */ cquantize->fserrors = NULL; /* flag optional arrays not allocated */
@ -1283,7 +1283,8 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
if (desired > MAXNUMCOLORS) if (desired > MAXNUMCOLORS)
ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); ((j_common_ptr) cinfo, JPOOL_IMAGE,
(JDIMENSION) desired, (JDIMENSION) 3);
cquantize->desired = desired; cquantize->desired = desired;
} else } else
cquantize->sv_colormap = NULL; cquantize->sv_colormap = NULL;
@ -1301,7 +1302,7 @@ jinit_2pass_quantizer (j_decompress_ptr cinfo)
if (cinfo->dither_mode == JDITHER_FS) { if (cinfo->dither_mode == JDITHER_FS) {
cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
((j_common_ptr) cinfo, JPOOL_IMAGE, ((j_common_ptr) cinfo, JPOOL_IMAGE,
(size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); ((size_t) cinfo->output_width + (size_t) 2) * (3 * SIZEOF(FSERROR)));
/* Might as well create the error-limiting table too. */ /* Might as well create the error-limiting table too. */
init_error_limit(cinfo); init_error_limit(cinfo);
} }

View file

@ -2,6 +2,7 @@
* jutils.c * jutils.c
* *
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009-2020 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -51,16 +52,67 @@ const int jpeg_zigzag_order[DCTSIZE2] = {
*/ */
const int jpeg_natural_order[DCTSIZE2+16] = { const int jpeg_natural_order[DCTSIZE2+16] = {
0, 1, 8, 16, 9, 2, 3, 10, 0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5, 17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34, 12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 7, 14, 21, 28, 27, 20, 13, 6, 7, 14, 21, 28,
35, 42, 49, 56, 57, 50, 43, 36, 35, 42, 49, 56, 57, 50, 43, 36,
29, 22, 15, 23, 30, 37, 44, 51, 29, 22, 15, 23, 30, 37, 44, 51,
58, 59, 52, 45, 38, 31, 39, 46, 58, 59, 52, 45, 38, 31, 39, 46,
53, 60, 61, 54, 47, 55, 62, 63, 53, 60, 61, 54, 47, 55, 62, 63,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63 63, 63, 63, 63, 63, 63, 63, 63
};
const int jpeg_natural_order7[7*7+16] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 48, 41, 34,
27, 20, 13, 6, 14, 21, 28, 35,
42, 49, 50, 43, 36, 29, 22, 30,
37, 44, 51, 52, 45, 38, 46, 53,
54,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63
};
const int jpeg_natural_order6[6*6+16] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 5,
12, 19, 26, 33, 40, 41, 34, 27,
20, 13, 21, 28, 35, 42, 43, 36,
29, 37, 44, 45,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63
};
const int jpeg_natural_order5[5*5+16] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 32, 25, 18, 11, 4, 12,
19, 26, 33, 34, 27, 20, 28, 35,
36,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63
};
const int jpeg_natural_order4[4*4+16] = {
0, 1, 8, 16, 9, 2, 3, 10,
17, 24, 25, 18, 11, 19, 26, 27,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63
};
const int jpeg_natural_order3[3*3+16] = {
0, 1, 8, 16, 9, 2, 10, 17,
18,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63
};
const int jpeg_natural_order2[2*2+16] = {
0, 1, 8, 9,
63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
63, 63, 63, 63, 63, 63, 63, 63
}; };
@ -96,37 +148,48 @@ jround_up (long a, long b)
* is not all that great, because these routines aren't very heavily used.) * is not all that great, because these routines aren't very heavily used.)
*/ */
#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ #ifndef NEED_FAR_POINTERS /* normal case, same as regular macro */
#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) #define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size)
#define FMEMZERO(target,size) MEMZERO(target,size)
#else /* 80x86 case, define if we can */ #else /* 80x86 case, define if we can */
#ifdef USE_FMEM #ifdef USE_FMEM
#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) #define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size))
#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) #else
/* This function is for use by the FMEMZERO macro defined in jpegint.h.
* Do not call this function directly, use the FMEMZERO macro instead.
*/
GLOBAL(void)
jzero_far (void FAR * target, size_t bytestozero)
/* Zero out a chunk of FAR memory. */
/* This might be sample-array data, block-array data, or alloc_large data. */
{
register char FAR * ptr = (char FAR *) target;
register size_t count;
for (count = bytestozero; count > 0; count--) {
*ptr++ = 0;
}
}
#endif #endif
#endif #endif
GLOBAL(void) GLOBAL(void)
jcopy_sample_rows (JSAMPARRAY input_array, int source_row, jcopy_sample_rows (JSAMPARRAY input_array,
JSAMPARRAY output_array, int dest_row, JSAMPARRAY output_array,
int num_rows, JDIMENSION num_cols) int num_rows, JDIMENSION num_cols)
/* Copy some rows of samples from one place to another. /* Copy some rows of samples from one place to another.
* num_rows rows are copied from input_array[source_row++] * num_rows rows are copied from *input_array++ to *output_array++;
* to output_array[dest_row++]; these areas may overlap for duplication. * these areas may overlap for duplication.
* The source and destination arrays must be at least as wide as num_cols. * The source and destination arrays must be at least as wide as num_cols.
*/ */
{ {
JSAMPROW inptr, outptr; register JSAMPROW inptr, outptr;
#ifdef FMEMCOPY #ifdef FMEMCOPY
size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); register size_t count = (size_t) num_cols * SIZEOF(JSAMPLE);
#else #else
JDIMENSION count; register JDIMENSION count;
#endif #endif
int row; register int row;
input_array += source_row;
output_array += dest_row;
for (row = num_rows; row > 0; row--) { for (row = num_rows; row > 0; row--) {
inptr = *input_array++; inptr = *input_array++;
@ -147,10 +210,10 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
/* Copy a row of coefficient blocks from one place to another. */ /* Copy a row of coefficient blocks from one place to another. */
{ {
#ifdef FMEMCOPY #ifdef FMEMCOPY
FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); FMEMCOPY(output_row, input_row, (size_t) num_blocks * (DCTSIZE2 * SIZEOF(JCOEF)));
#else #else
JCOEFPTR inptr, outptr; register JCOEFPTR inptr, outptr;
long count; register long count;
inptr = (JCOEFPTR) input_row; inptr = (JCOEFPTR) input_row;
outptr = (JCOEFPTR) output_row; outptr = (JCOEFPTR) output_row;
@ -159,21 +222,3 @@ jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row,
} }
#endif #endif
} }
GLOBAL(void)
jzero_far (void FAR * target, size_t bytestozero)
/* Zero out a chunk of FAR memory. */
/* This might be sample-array data, block-array data, or alloc_large data. */
{
#ifdef FMEMZERO
FMEMZERO(target, bytestozero);
#else
char FAR * ptr = (char FAR *) target;
size_t count;
for (count = bytestozero; count > 0; count--) {
*ptr++ = 0;
}
#endif
}

View file

@ -1,7 +1,7 @@
/* /*
* jversion.h * jversion.h
* *
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-2024, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software. * This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file. * For conditions of distribution and use, see the accompanying README file.
* *
@ -9,6 +9,6 @@
*/ */
#define JVERSION "6b 27-Mar-1998" #define JVERSION "9f 14-Jan-2024"
#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" #define JCOPYRIGHT "Copyright (C) 2024, Thomas G. Lane, Guido Vollbeding"

View file

@ -1,928 +0,0 @@
/*
* transupp.c
*
* Copyright (C) 1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains image transformation routines and other utility code
* used by the jpegtran sample application. These are NOT part of the core
* JPEG library. But we keep these routines separate from jpegtran.c to
* ease the task of maintaining jpegtran-like programs that have other user
* interfaces.
*/
/* Although this file really shouldn't have access to the library internals,
* it's helpful to let it call jround_up() and jcopy_block_row().
*/
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
#include "transupp.h" /* My own external interface */
#if TRANSFORMS_SUPPORTED
/*
* Lossless image transformation routines. These routines work on DCT
* coefficient arrays and thus do not require any lossy decompression
* or recompression of the image.
* Thanks to Guido Vollbeding for the initial design and code of this feature.
*
* Horizontal flipping is done in-place, using a single top-to-bottom
* pass through the virtual source array. It will thus be much the
* fastest option for images larger than main memory.
*
* The other routines require a set of destination virtual arrays, so they
* need twice as much memory as jpegtran normally does. The destination
* arrays are always written in normal scan order (top to bottom) because
* the virtual array manager expects this. The source arrays will be scanned
* in the corresponding order, which means multiple passes through the source
* arrays for most of the transforms. That could result in much thrashing
* if the image is larger than main memory.
*
* Some notes about the operating environment of the individual transform
* routines:
* 1. Both the source and destination virtual arrays are allocated from the
* source JPEG object, and therefore should be manipulated by calling the
* source's memory manager.
* 2. The destination's component count should be used. It may be smaller
* than the source's when forcing to grayscale.
* 3. Likewise the destination's sampling factors should be used. When
* forcing to grayscale the destination's sampling factors will be all 1,
* and we may as well take that as the effective iMCU size.
* 4. When "trim" is in effect, the destination's dimensions will be the
* trimmed values but the source's will be untrimmed.
* 5. All the routines assume that the source and destination buffers are
* padded out to a full iMCU boundary. This is true, although for the
* source buffer it is an undocumented property of jdcoefct.c.
* Notes 2,3,4 boil down to this: generally we should use the destination's
* dimensions and ignore the source's.
*/
LOCAL(void)
do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays)
/* Horizontal flip; done in-place, so no separate dest array is required */
{
JDIMENSION MCU_cols, comp_width, blk_x, blk_y;
int ci, k, offset_y;
JBLOCKARRAY buffer;
JCOEFPTR ptr1, ptr2;
JCOEF temp1, temp2;
jpeg_component_info *compptr;
/* Horizontal mirroring of DCT blocks is accomplished by swapping
* pairs of blocks in-place. Within a DCT block, we perform horizontal
* mirroring by changing the signs of odd-numbered columns.
* Partial iMCUs at the right edge are left untouched.
*/
MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
comp_width = MCU_cols * compptr->h_samp_factor;
for (blk_y = 0; blk_y < compptr->height_in_blocks;
blk_y += compptr->v_samp_factor) {
buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
for (blk_x = 0; blk_x * 2 < comp_width; blk_x++) {
ptr1 = buffer[offset_y][blk_x];
ptr2 = buffer[offset_y][comp_width - blk_x - 1];
/* this unrolled loop doesn't need to know which row it's on... */
for (k = 0; k < DCTSIZE2; k += 2) {
temp1 = *ptr1; /* swap even column */
temp2 = *ptr2;
*ptr1++ = temp2;
*ptr2++ = temp1;
temp1 = *ptr1; /* swap odd column with sign change */
temp2 = *ptr2;
*ptr1++ = -temp2;
*ptr2++ = -temp1;
}
}
}
}
}
}
LOCAL(void)
do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jvirt_barray_ptr *dst_coef_arrays)
/* Vertical flip */
{
JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y;
int ci, i, j, offset_y;
JBLOCKARRAY src_buffer, dst_buffer;
JBLOCKROW src_row_ptr, dst_row_ptr;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
/* We output into a separate array because we can't touch different
* rows of the source virtual array simultaneously. Otherwise, this
* is a pretty straightforward analog of horizontal flip.
* Within a DCT block, vertical mirroring is done by changing the signs
* of odd-numbered rows.
* Partial iMCUs at the bottom edge are copied verbatim.
*/
MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
comp_height = MCU_rows * compptr->v_samp_factor;
for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
dst_blk_y += compptr->v_samp_factor) {
dst_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
if (dst_blk_y < comp_height) {
/* Row is within the mirrorable area. */
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci],
comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor,
(JDIMENSION) compptr->v_samp_factor, FALSE);
} else {
/* Bottom-edge blocks will be copied verbatim. */
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, FALSE);
}
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
if (dst_blk_y < comp_height) {
/* Row is within the mirrorable area. */
dst_row_ptr = dst_buffer[offset_y];
src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1];
for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
dst_blk_x++) {
dst_ptr = dst_row_ptr[dst_blk_x];
src_ptr = src_row_ptr[dst_blk_x];
for (i = 0; i < DCTSIZE; i += 2) {
/* copy even row */
for (j = 0; j < DCTSIZE; j++)
*dst_ptr++ = *src_ptr++;
/* copy odd row with sign change */
for (j = 0; j < DCTSIZE; j++)
*dst_ptr++ = - *src_ptr++;
}
}
} else {
/* Just copy row verbatim. */
jcopy_block_row(src_buffer[offset_y], dst_buffer[offset_y],
compptr->width_in_blocks);
}
}
}
}
}
LOCAL(void)
do_transpose (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jvirt_barray_ptr *dst_coef_arrays)
/* Transpose source into destination */
{
JDIMENSION dst_blk_x, dst_blk_y;
int ci, i, j, offset_x, offset_y;
JBLOCKARRAY src_buffer, dst_buffer;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
/* Transposing pixels within a block just requires transposing the
* DCT coefficients.
* Partial iMCUs at the edges require no special treatment; we simply
* process all the available DCT blocks for every component.
*/
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
dst_blk_y += compptr->v_samp_factor) {
dst_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
dst_blk_x += compptr->h_samp_factor) {
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x,
(JDIMENSION) compptr->h_samp_factor, FALSE);
for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
src_ptr = src_buffer[offset_x][dst_blk_y + offset_y];
dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
for (i = 0; i < DCTSIZE; i++)
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
}
}
}
}
}
}
LOCAL(void)
do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jvirt_barray_ptr *dst_coef_arrays)
/* 90 degree rotation is equivalent to
* 1. Transposing the image;
* 2. Horizontal mirroring.
* These two steps are merged into a single processing routine.
*/
{
JDIMENSION MCU_cols, comp_width, dst_blk_x, dst_blk_y;
int ci, i, j, offset_x, offset_y;
JBLOCKARRAY src_buffer, dst_buffer;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
/* Because of the horizontal mirror step, we can't process partial iMCUs
* at the (output) right edge properly. They just get transposed and
* not mirrored.
*/
MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
comp_width = MCU_cols * compptr->h_samp_factor;
for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
dst_blk_y += compptr->v_samp_factor) {
dst_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
dst_blk_x += compptr->h_samp_factor) {
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x,
(JDIMENSION) compptr->h_samp_factor, FALSE);
for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
src_ptr = src_buffer[offset_x][dst_blk_y + offset_y];
if (dst_blk_x < comp_width) {
/* Block is within the mirrorable area. */
dst_ptr = dst_buffer[offset_y]
[comp_width - dst_blk_x - offset_x - 1];
for (i = 0; i < DCTSIZE; i++) {
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
i++;
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j];
}
} else {
/* Edge blocks are transposed but not mirrored. */
dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
for (i = 0; i < DCTSIZE; i++)
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
}
}
}
}
}
}
}
LOCAL(void)
do_rot_270 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jvirt_barray_ptr *dst_coef_arrays)
/* 270 degree rotation is equivalent to
* 1. Horizontal mirroring;
* 2. Transposing the image.
* These two steps are merged into a single processing routine.
*/
{
JDIMENSION MCU_rows, comp_height, dst_blk_x, dst_blk_y;
int ci, i, j, offset_x, offset_y;
JBLOCKARRAY src_buffer, dst_buffer;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
/* Because of the horizontal mirror step, we can't process partial iMCUs
* at the (output) bottom edge properly. They just get transposed and
* not mirrored.
*/
MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
comp_height = MCU_rows * compptr->v_samp_factor;
for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
dst_blk_y += compptr->v_samp_factor) {
dst_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
dst_blk_x += compptr->h_samp_factor) {
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x,
(JDIMENSION) compptr->h_samp_factor, FALSE);
for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
if (dst_blk_y < comp_height) {
/* Block is within the mirrorable area. */
src_ptr = src_buffer[offset_x]
[comp_height - dst_blk_y - offset_y - 1];
for (i = 0; i < DCTSIZE; i++) {
for (j = 0; j < DCTSIZE; j++) {
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
j++;
dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j];
}
}
} else {
/* Edge blocks are transposed but not mirrored. */
src_ptr = src_buffer[offset_x][dst_blk_y + offset_y];
for (i = 0; i < DCTSIZE; i++)
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
}
}
}
}
}
}
}
LOCAL(void)
do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jvirt_barray_ptr *dst_coef_arrays)
/* 180 degree rotation is equivalent to
* 1. Vertical mirroring;
* 2. Horizontal mirroring.
* These two steps are merged into a single processing routine.
*/
{
JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y;
int ci, i, j, offset_y;
JBLOCKARRAY src_buffer, dst_buffer;
JBLOCKROW src_row_ptr, dst_row_ptr;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
comp_width = MCU_cols * compptr->h_samp_factor;
comp_height = MCU_rows * compptr->v_samp_factor;
for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
dst_blk_y += compptr->v_samp_factor) {
dst_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
if (dst_blk_y < comp_height) {
/* Row is within the vertically mirrorable area. */
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci],
comp_height - dst_blk_y - (JDIMENSION) compptr->v_samp_factor,
(JDIMENSION) compptr->v_samp_factor, FALSE);
} else {
/* Bottom-edge rows are only mirrored horizontally. */
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, FALSE);
}
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
if (dst_blk_y < comp_height) {
/* Row is within the mirrorable area. */
dst_row_ptr = dst_buffer[offset_y];
src_row_ptr = src_buffer[compptr->v_samp_factor - offset_y - 1];
/* Process the blocks that can be mirrored both ways. */
for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) {
dst_ptr = dst_row_ptr[dst_blk_x];
src_ptr = src_row_ptr[comp_width - dst_blk_x - 1];
for (i = 0; i < DCTSIZE; i += 2) {
/* For even row, negate every odd column. */
for (j = 0; j < DCTSIZE; j += 2) {
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = - *src_ptr++;
}
/* For odd row, negate every even column. */
for (j = 0; j < DCTSIZE; j += 2) {
*dst_ptr++ = - *src_ptr++;
*dst_ptr++ = *src_ptr++;
}
}
}
/* Any remaining right-edge blocks are only mirrored vertically. */
for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) {
dst_ptr = dst_row_ptr[dst_blk_x];
src_ptr = src_row_ptr[dst_blk_x];
for (i = 0; i < DCTSIZE; i += 2) {
for (j = 0; j < DCTSIZE; j++)
*dst_ptr++ = *src_ptr++;
for (j = 0; j < DCTSIZE; j++)
*dst_ptr++ = - *src_ptr++;
}
}
} else {
/* Remaining rows are just mirrored horizontally. */
dst_row_ptr = dst_buffer[offset_y];
src_row_ptr = src_buffer[offset_y];
/* Process the blocks that can be mirrored. */
for (dst_blk_x = 0; dst_blk_x < comp_width; dst_blk_x++) {
dst_ptr = dst_row_ptr[dst_blk_x];
src_ptr = src_row_ptr[comp_width - dst_blk_x - 1];
for (i = 0; i < DCTSIZE2; i += 2) {
*dst_ptr++ = *src_ptr++;
*dst_ptr++ = - *src_ptr++;
}
}
/* Any remaining right-edge blocks are only copied. */
for (; dst_blk_x < compptr->width_in_blocks; dst_blk_x++) {
dst_ptr = dst_row_ptr[dst_blk_x];
src_ptr = src_row_ptr[dst_blk_x];
for (i = 0; i < DCTSIZE2; i++)
*dst_ptr++ = *src_ptr++;
}
}
}
}
}
}
LOCAL(void)
do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jvirt_barray_ptr *dst_coef_arrays)
/* Transverse transpose is equivalent to
* 1. 180 degree rotation;
* 2. Transposition;
* or
* 1. Horizontal mirroring;
* 2. Transposition;
* 3. Horizontal mirroring.
* These steps are merged into a single processing routine.
*/
{
JDIMENSION MCU_cols, MCU_rows, comp_width, comp_height, dst_blk_x, dst_blk_y;
int ci, i, j, offset_x, offset_y;
JBLOCKARRAY src_buffer, dst_buffer;
JCOEFPTR src_ptr, dst_ptr;
jpeg_component_info *compptr;
MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE);
MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE);
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
comp_width = MCU_cols * compptr->h_samp_factor;
comp_height = MCU_rows * compptr->v_samp_factor;
for (dst_blk_y = 0; dst_blk_y < compptr->height_in_blocks;
dst_blk_y += compptr->v_samp_factor) {
dst_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, dst_coef_arrays[ci], dst_blk_y,
(JDIMENSION) compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
for (dst_blk_x = 0; dst_blk_x < compptr->width_in_blocks;
dst_blk_x += compptr->h_samp_factor) {
src_buffer = (*srcinfo->mem->access_virt_barray)
((j_common_ptr) srcinfo, src_coef_arrays[ci], dst_blk_x,
(JDIMENSION) compptr->h_samp_factor, FALSE);
for (offset_x = 0; offset_x < compptr->h_samp_factor; offset_x++) {
if (dst_blk_y < comp_height) {
src_ptr = src_buffer[offset_x]
[comp_height - dst_blk_y - offset_y - 1];
if (dst_blk_x < comp_width) {
/* Block is within the mirrorable area. */
dst_ptr = dst_buffer[offset_y]
[comp_width - dst_blk_x - offset_x - 1];
for (i = 0; i < DCTSIZE; i++) {
for (j = 0; j < DCTSIZE; j++) {
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
j++;
dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j];
}
i++;
for (j = 0; j < DCTSIZE; j++) {
dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j];
j++;
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
}
}
} else {
/* Right-edge blocks are mirrored in y only */
dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
for (i = 0; i < DCTSIZE; i++) {
for (j = 0; j < DCTSIZE; j++) {
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
j++;
dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j];
}
}
}
} else {
src_ptr = src_buffer[offset_x][dst_blk_y + offset_y];
if (dst_blk_x < comp_width) {
/* Bottom-edge blocks are mirrored in x only */
dst_ptr = dst_buffer[offset_y]
[comp_width - dst_blk_x - offset_x - 1];
for (i = 0; i < DCTSIZE; i++) {
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
i++;
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = -src_ptr[i*DCTSIZE+j];
}
} else {
/* At lower right corner, just transpose, no mirroring */
dst_ptr = dst_buffer[offset_y][dst_blk_x + offset_x];
for (i = 0; i < DCTSIZE; i++)
for (j = 0; j < DCTSIZE; j++)
dst_ptr[j*DCTSIZE+i] = src_ptr[i*DCTSIZE+j];
}
}
}
}
}
}
}
}
/* Request any required workspace.
*
* We allocate the workspace virtual arrays from the source decompression
* object, so that all the arrays (both the original data and the workspace)
* will be taken into account while making memory management decisions.
* Hence, this routine must be called after jpeg_read_header (which reads
* the image dimensions) and before jpeg_read_coefficients (which realizes
* the source's virtual arrays).
*/
GLOBAL(void)
jtransform_request_workspace (j_decompress_ptr srcinfo,
jpeg_transform_info *info)
{
jvirt_barray_ptr *coef_arrays = NULL;
jpeg_component_info *compptr;
int ci;
if (info->force_grayscale &&
srcinfo->jpeg_color_space == JCS_YCbCr &&
srcinfo->num_components == 3) {
/* We'll only process the first component */
info->num_components = 1;
} else {
/* Process all the components */
info->num_components = srcinfo->num_components;
}
switch (info->transform) {
case JXFORM_NONE:
case JXFORM_FLIP_H:
/* Don't need a workspace array */
break;
case JXFORM_FLIP_V:
case JXFORM_ROT_180:
/* Need workspace arrays having same dimensions as source image.
* Note that we allocate arrays padded out to the next iMCU boundary,
* so that transform routines need not worry about missing edge blocks.
*/
coef_arrays = (jvirt_barray_ptr *)
(*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE,
SIZEOF(jvirt_barray_ptr) * info->num_components);
for (ci = 0; ci < info->num_components; ci++) {
compptr = srcinfo->comp_info + ci;
coef_arrays[ci] = (*srcinfo->mem->request_virt_barray)
((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE,
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
(long) compptr->h_samp_factor),
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
(long) compptr->v_samp_factor),
(JDIMENSION) compptr->v_samp_factor);
}
break;
case JXFORM_TRANSPOSE:
case JXFORM_TRANSVERSE:
case JXFORM_ROT_90:
case JXFORM_ROT_270:
/* Need workspace arrays having transposed dimensions.
* Note that we allocate arrays padded out to the next iMCU boundary,
* so that transform routines need not worry about missing edge blocks.
*/
coef_arrays = (jvirt_barray_ptr *)
(*srcinfo->mem->alloc_small) ((j_common_ptr) srcinfo, JPOOL_IMAGE,
SIZEOF(jvirt_barray_ptr) * info->num_components);
for (ci = 0; ci < info->num_components; ci++) {
compptr = srcinfo->comp_info + ci;
coef_arrays[ci] = (*srcinfo->mem->request_virt_barray)
((j_common_ptr) srcinfo, JPOOL_IMAGE, FALSE,
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
(long) compptr->v_samp_factor),
(JDIMENSION) jround_up((long) compptr->width_in_blocks,
(long) compptr->h_samp_factor),
(JDIMENSION) compptr->h_samp_factor);
}
break;
}
info->workspace_coef_arrays = coef_arrays;
}
/* Transpose destination image parameters */
LOCAL(void)
transpose_critical_parameters (j_compress_ptr dstinfo)
{
int tblno, i, j, ci, itemp;
jpeg_component_info *compptr;
JQUANT_TBL *qtblptr;
JDIMENSION dtemp;
UINT16 qtemp;
/* Transpose basic image dimensions */
dtemp = dstinfo->image_width;
dstinfo->image_width = dstinfo->image_height;
dstinfo->image_height = dtemp;
/* Transpose sampling factors */
for (ci = 0; ci < dstinfo->num_components; ci++) {
compptr = dstinfo->comp_info + ci;
itemp = compptr->h_samp_factor;
compptr->h_samp_factor = compptr->v_samp_factor;
compptr->v_samp_factor = itemp;
}
/* Transpose quantization tables */
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
qtblptr = dstinfo->quant_tbl_ptrs[tblno];
if (qtblptr != NULL) {
for (i = 0; i < DCTSIZE; i++) {
for (j = 0; j < i; j++) {
qtemp = qtblptr->quantval[i*DCTSIZE+j];
qtblptr->quantval[i*DCTSIZE+j] = qtblptr->quantval[j*DCTSIZE+i];
qtblptr->quantval[j*DCTSIZE+i] = qtemp;
}
}
}
}
}
/* Trim off any partial iMCUs on the indicated destination edge */
LOCAL(void)
trim_right_edge (j_compress_ptr dstinfo)
{
int ci, max_h_samp_factor;
JDIMENSION MCU_cols;
/* We have to compute max_h_samp_factor ourselves,
* because it hasn't been set yet in the destination
* (and we don't want to use the source's value).
*/
max_h_samp_factor = 1;
for (ci = 0; ci < dstinfo->num_components; ci++) {
int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor;
max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor);
}
MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE);
if (MCU_cols > 0) /* can't trim to 0 pixels */
dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE);
}
LOCAL(void)
trim_bottom_edge (j_compress_ptr dstinfo)
{
int ci, max_v_samp_factor;
JDIMENSION MCU_rows;
/* We have to compute max_v_samp_factor ourselves,
* because it hasn't been set yet in the destination
* (and we don't want to use the source's value).
*/
max_v_samp_factor = 1;
for (ci = 0; ci < dstinfo->num_components; ci++) {
int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor;
max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor);
}
MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE);
if (MCU_rows > 0) /* can't trim to 0 pixels */
dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE);
}
/* Adjust output image parameters as needed.
*
* This must be called after jpeg_copy_critical_parameters()
* and before jpeg_write_coefficients().
*
* The return value is the set of virtual coefficient arrays to be written
* (either the ones allocated by jtransform_request_workspace, or the
* original source data arrays). The caller will need to pass this value
* to jpeg_write_coefficients().
*/
GLOBAL(jvirt_barray_ptr *)
jtransform_adjust_parameters (j_decompress_ptr,
j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jpeg_transform_info *info)
{
/* If force-to-grayscale is requested, adjust destination parameters */
if (info->force_grayscale) {
/* We use jpeg_set_colorspace to make sure subsidiary settings get fixed
* properly. Among other things, the target h_samp_factor & v_samp_factor
* will get set to 1, which typically won't match the source.
* In fact we do this even if the source is already grayscale; that
* provides an easy way of coercing a grayscale JPEG with funny sampling
* factors to the customary 1,1. (Some decoders fail on other factors.)
*/
if ((dstinfo->jpeg_color_space == JCS_YCbCr &&
dstinfo->num_components == 3) ||
(dstinfo->jpeg_color_space == JCS_GRAYSCALE &&
dstinfo->num_components == 1)) {
/* We have to preserve the source's quantization table number. */
int sv_quant_tbl_no = dstinfo->comp_info[0].quant_tbl_no;
jpeg_set_colorspace(dstinfo, JCS_GRAYSCALE);
dstinfo->comp_info[0].quant_tbl_no = sv_quant_tbl_no;
} else {
/* Sorry, can't do it */
ERREXIT(dstinfo, JERR_CONVERSION_NOTIMPL);
}
}
/* Correct the destination's image dimensions etc if necessary */
switch (info->transform) {
case JXFORM_NONE:
/* Nothing to do */
break;
case JXFORM_FLIP_H:
if (info->trim)
trim_right_edge(dstinfo);
break;
case JXFORM_FLIP_V:
if (info->trim)
trim_bottom_edge(dstinfo);
break;
case JXFORM_TRANSPOSE:
transpose_critical_parameters(dstinfo);
/* transpose does NOT have to trim anything */
break;
case JXFORM_TRANSVERSE:
transpose_critical_parameters(dstinfo);
if (info->trim) {
trim_right_edge(dstinfo);
trim_bottom_edge(dstinfo);
}
break;
case JXFORM_ROT_90:
transpose_critical_parameters(dstinfo);
if (info->trim)
trim_right_edge(dstinfo);
break;
case JXFORM_ROT_180:
if (info->trim) {
trim_right_edge(dstinfo);
trim_bottom_edge(dstinfo);
}
break;
case JXFORM_ROT_270:
transpose_critical_parameters(dstinfo);
if (info->trim)
trim_bottom_edge(dstinfo);
break;
}
/* Return the appropriate output data set */
if (info->workspace_coef_arrays != NULL)
return info->workspace_coef_arrays;
return src_coef_arrays;
}
/* Execute the actual transformation, if any.
*
* This must be called *after* jpeg_write_coefficients, because it depends
* on jpeg_write_coefficients to have computed subsidiary values such as
* the per-component width and height fields in the destination object.
*
* Note that some transformations will modify the source data arrays!
*/
GLOBAL(void)
jtransform_execute_transformation (j_decompress_ptr srcinfo,
j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jpeg_transform_info *info)
{
jvirt_barray_ptr *dst_coef_arrays = info->workspace_coef_arrays;
switch (info->transform) {
case JXFORM_NONE:
break;
case JXFORM_FLIP_H:
do_flip_h(srcinfo, dstinfo, src_coef_arrays);
break;
case JXFORM_FLIP_V:
do_flip_v(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays);
break;
case JXFORM_TRANSPOSE:
do_transpose(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays);
break;
case JXFORM_TRANSVERSE:
do_transverse(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays);
break;
case JXFORM_ROT_90:
do_rot_90(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays);
break;
case JXFORM_ROT_180:
do_rot_180(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays);
break;
case JXFORM_ROT_270:
do_rot_270(srcinfo, dstinfo, src_coef_arrays, dst_coef_arrays);
break;
}
}
#endif /* TRANSFORMS_SUPPORTED */
/* Setup decompression object to save desired markers in memory.
* This must be called before jpeg_read_header() to have the desired effect.
*/
GLOBAL(void)
jcopy_markers_setup (j_decompress_ptr srcinfo, JCOPY_OPTION option)
{
#ifdef SAVE_MARKERS_SUPPORTED
int m;
/* Save comments except under NONE option */
if (option != JCOPYOPT_NONE) {
jpeg_save_markers(srcinfo, JPEG_COM, 0xFFFF);
}
/* Save all types of APPn markers iff ALL option */
if (option == JCOPYOPT_ALL) {
for (m = 0; m < 16; m++)
jpeg_save_markers(srcinfo, JPEG_APP0 + m, 0xFFFF);
}
#endif /* SAVE_MARKERS_SUPPORTED */
}
/* Copy markers saved in the given source object to the destination object.
* This should be called just after jpeg_start_compress() or
* jpeg_write_coefficients().
* Note that those routines will have written the SOI, and also the
* JFIF APP0 or Adobe APP14 markers if selected.
*/
GLOBAL(void)
jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
JCOPY_OPTION)
{
jpeg_saved_marker_ptr marker;
/* In the current implementation, we don't actually need to examine the
* option flag here; we just copy everything that got saved.
* But to avoid confusion, we do not output JFIF and Adobe APP14 markers
* if the encoder library already wrote one.
*/
for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
if (dstinfo->write_JFIF_header &&
marker->marker == JPEG_APP0 &&
marker->data_length >= 5 &&
GETJOCTET(marker->data[0]) == 0x4A &&
GETJOCTET(marker->data[1]) == 0x46 &&
GETJOCTET(marker->data[2]) == 0x49 &&
GETJOCTET(marker->data[3]) == 0x46 &&
GETJOCTET(marker->data[4]) == 0)
continue; /* reject duplicate JFIF */
if (dstinfo->write_Adobe_marker &&
marker->marker == JPEG_APP0+14 &&
marker->data_length >= 5 &&
GETJOCTET(marker->data[0]) == 0x41 &&
GETJOCTET(marker->data[1]) == 0x64 &&
GETJOCTET(marker->data[2]) == 0x6F &&
GETJOCTET(marker->data[3]) == 0x62 &&
GETJOCTET(marker->data[4]) == 0x65)
continue; /* reject duplicate Adobe */
#ifdef NEED_FAR_POINTERS
/* We could use jpeg_write_marker if the data weren't FAR... */
{
unsigned int i;
jpeg_write_m_header(dstinfo, marker->marker, marker->data_length);
for (i = 0; i < marker->data_length; i++)
jpeg_write_m_byte(dstinfo, marker->data[i]);
}
#else
jpeg_write_marker(dstinfo, marker->marker,
marker->data, marker->data_length);
#endif
}
}

View file

@ -1,135 +0,0 @@
/*
* transupp.h
*
* Copyright (C) 1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains declarations for image transformation routines and
* other utility code used by the jpegtran sample application. These are
* NOT part of the core JPEG library. But we keep these routines separate
* from jpegtran.c to ease the task of maintaining jpegtran-like programs
* that have other user interfaces.
*
* NOTE: all the routines declared here have very specific requirements
* about when they are to be executed during the reading and writing of the
* source and destination files. See the comments in transupp.c, or see
* jpegtran.c for an example of correct usage.
*/
/* If you happen not to want the image transform support, disable it here */
#ifndef TRANSFORMS_SUPPORTED
#define TRANSFORMS_SUPPORTED 1 /* 0 disables transform code */
#endif
/* Short forms of external names for systems with brain-damaged linkers. */
#ifdef NEED_SHORT_EXTERNAL_NAMES
#define jtransform_request_workspace jTrRequest
#define jtransform_adjust_parameters jTrAdjust
#define jtransform_execute_transformation jTrExec
#define jcopy_markers_setup jCMrkSetup
#define jcopy_markers_execute jCMrkExec
#endif /* NEED_SHORT_EXTERNAL_NAMES */
/*
* Codes for supported types of image transformations.
*/
typedef enum {
JXFORM_NONE, /* no transformation */
JXFORM_FLIP_H, /* horizontal flip */
JXFORM_FLIP_V, /* vertical flip */
JXFORM_TRANSPOSE, /* transpose across UL-to-LR axis */
JXFORM_TRANSVERSE, /* transpose across UR-to-LL axis */
JXFORM_ROT_90, /* 90-degree clockwise rotation */
JXFORM_ROT_180, /* 180-degree rotation */
JXFORM_ROT_270 /* 270-degree clockwise (or 90 ccw) */
} JXFORM_CODE;
/*
* Although rotating and flipping data expressed as DCT coefficients is not
* hard, there is an asymmetry in the JPEG format specification for images
* whose dimensions aren't multiples of the iMCU size. The right and bottom
* image edges are padded out to the next iMCU boundary with junk data; but
* no padding is possible at the top and left edges. If we were to flip
* the whole image including the pad data, then pad garbage would become
* visible at the top and/or left, and real pixels would disappear into the
* pad margins --- perhaps permanently, since encoders & decoders may not
* bother to preserve DCT blocks that appear to be completely outside the
* nominal image area. So, we have to exclude any partial iMCUs from the
* basic transformation.
*
* Transpose is the only transformation that can handle partial iMCUs at the
* right and bottom edges completely cleanly. flip_h can flip partial iMCUs
* at the bottom, but leaves any partial iMCUs at the right edge untouched.
* Similarly flip_v leaves any partial iMCUs at the bottom edge untouched.
* The other transforms are defined as combinations of these basic transforms
* and process edge blocks in a way that preserves the equivalence.
*
* The "trim" option causes untransformable partial iMCUs to be dropped;
* this is not strictly lossless, but it usually gives the best-looking
* result for odd-size images. Note that when this option is active,
* the expected mathematical equivalences between the transforms may not hold.
* (For example, -rot 270 -trim trims only the bottom edge, but -rot 90 -trim
* followed by -rot 180 -trim trims both edges.)
*
* We also offer a "force to grayscale" option, which simply discards the
* chrominance channels of a YCbCr image. This is lossless in the sense that
* the luminance channel is preserved exactly. It's not the same kind of
* thing as the rotate/flip transformations, but it's convenient to handle it
* as part of this package, mainly because the transformation routines have to
* be aware of the option to know how many components to work on.
*/
typedef struct {
/* Options: set by caller */
JXFORM_CODE transform; /* image transform operator */
boolean trim; /* if TRUE, trim partial MCUs as needed */
boolean force_grayscale; /* if TRUE, convert color image to grayscale */
/* Internal workspace: caller should not touch these */
int num_components; /* # of components in workspace */
jvirt_barray_ptr * workspace_coef_arrays; /* workspace for transformations */
} jpeg_transform_info;
#if TRANSFORMS_SUPPORTED
/* Request any required workspace */
EXTERN(void) jtransform_request_workspace
JPP((j_decompress_ptr srcinfo, jpeg_transform_info *info));
/* Adjust output image parameters */
EXTERN(jvirt_barray_ptr *) jtransform_adjust_parameters
JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jpeg_transform_info *info));
/* Execute the actual transformation, if any */
EXTERN(void) jtransform_execute_transformation
JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jvirt_barray_ptr *src_coef_arrays,
jpeg_transform_info *info));
#endif /* TRANSFORMS_SUPPORTED */
/*
* Support for copying optional markers from source to destination file.
*/
typedef enum {
JCOPYOPT_NONE, /* copy no optional markers */
JCOPYOPT_COMMENTS, /* copy only comment (COM) markers */
JCOPYOPT_ALL /* copy all optional markers */
} JCOPY_OPTION;
#define JCOPYOPT_DEFAULT JCOPYOPT_COMMENTS /* recommended default */
/* Setup decompression object to save desired markers in memory */
EXTERN(void) jcopy_markers_setup
JPP((j_decompress_ptr srcinfo, JCOPY_OPTION option));
/* Copy markers saved in the given source object to the destination object */
EXTERN(void) jcopy_markers_execute
JPP((j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
JCOPY_OPTION option));