Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0631c2925a | ||
|
|
fbd9e93560 | ||
|
|
8b49cfe89c | ||
|
|
8e91fdaffe | ||
|
|
ea3e246f5b | ||
|
|
51f79d71ad | ||
|
|
d430a6ddec | ||
|
|
feb8788065 | ||
|
|
35095326cd | ||
|
|
c88d7a526e | ||
|
|
f6b64bc01c | ||
|
|
2bac87cc9f | ||
|
|
d34056eefb | ||
|
|
72e0b2e9e9 | ||
|
|
6d7e638613 | ||
|
|
cec2b5c490 | ||
|
|
4eaea80281 | ||
|
|
41a5a423b4 | ||
|
|
a721b3d6a8 | ||
|
|
dccdd2b095 | ||
|
|
cd393530cb | ||
|
|
7684dbeee7 | ||
|
|
e20100ff74 | ||
|
|
935ec55745 | ||
|
|
c88848d829 | ||
|
|
8df82dc573 | ||
|
|
688e1f0ed2 | ||
|
|
3a7bc14c01 | ||
|
|
d23623ac16 | ||
|
|
432ab6b045 | ||
|
|
c578cefeea | ||
|
|
ffdd42851c | ||
|
|
5c66172bb9 | ||
|
|
415a973a97 | ||
|
|
8149257c27 | ||
|
|
3bd56377c9 | ||
|
|
9d070fbdf9 | ||
|
|
52b62cefee | ||
|
|
61992ed2a2 | ||
|
|
71f1077241 | ||
|
|
ffe4eb0fa1 | ||
|
|
018b176541 | ||
|
|
c406f71578 | ||
|
|
133a6dc400 | ||
|
|
0d7e39168e | ||
|
|
f82cfb0540 | ||
|
|
4b4aaa982f | ||
|
|
ba21d1dc7c | ||
|
|
b405c92a6f | ||
|
|
1760d16c43 | ||
|
|
329246e155 | ||
|
|
d54ffee6d2 | ||
|
|
4ca72e498b | ||
|
|
0564b5c657 | ||
|
|
b33817bcc9 | ||
|
|
4998dd2e86 | ||
|
|
2f30c23e30 | ||
|
|
42ae15e3f7 | ||
|
|
aa04c8cfe7 | ||
|
|
16c847b669 | ||
|
|
a75bb29315 | ||
|
|
788631b6ee | ||
|
|
09229546c6 | ||
|
|
03582eb9da | ||
|
|
e2e794b85c | ||
|
|
ab949d5567 | ||
|
|
f340279e57 | ||
|
|
ddb1edb7d1 | ||
|
|
a7f29a3cd5 | ||
|
|
d09e4a9215 | ||
|
|
07335ba49c | ||
|
|
b55d5a1538 | ||
|
|
97fc40a69c | ||
|
|
cc73666475 | ||
|
|
0ed34f2eca | ||
|
|
a7a3d56c91 | ||
|
|
748c5cb812 | ||
|
|
f5318cf6d3 | ||
|
|
082dc2e3f5 | ||
|
|
c4ed7a034a | ||
|
|
28f548e565 | ||
|
|
20927eea63 | ||
|
|
1a302e5157 | ||
|
|
92417cb7b4 | ||
|
|
1dab2722dd | ||
|
|
3a59e3eaae | ||
|
|
d56c4e5386 | ||
|
|
0c3a7301cc | ||
|
|
6878de9175 | ||
|
|
97956b98df | ||
|
|
52bf4ac74d | ||
|
|
b53e8b49e0 | ||
|
|
51d648ac6b | ||
|
|
03a5b75648 | ||
|
|
bea31278a7 | ||
|
|
3bec2e47e3 | ||
|
|
13eb3d291d | ||
|
|
23225bdb56 | ||
|
|
8ba3d11c11 | ||
|
|
d519179ae2 | ||
|
|
e8aa39d66d | ||
|
|
ee231382f5 | ||
|
|
0324b87ad6 | ||
|
|
855e4cc61c | ||
|
|
b759ee0997 | ||
|
|
f2a1ad7df4 | ||
|
|
33999a317e | ||
|
|
2d9a54bc0e | ||
|
|
8d1ad9697b | ||
|
|
39d9701c75 | ||
|
|
d886cbe391 | ||
|
|
5afb351fcc | ||
|
|
7f5569a8d9 | ||
|
|
9df26b94c7 | ||
|
|
103cfe1749 | ||
|
|
006a8684ff | ||
|
|
645f0df208 | ||
|
|
60dc0a7f72 | ||
|
|
4c7c06e8dc | ||
|
|
d361eaf63d |
No files matched your search
@@ -1,58 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="com.android.toolchain.gcc.1322280913">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.android.toolchain.gcc.1322280913" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.android.toolchain.gcc.1322280913" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="com.android.toolchain.gcc.1322280913.1369823253" name="/" resourcePath="">
|
||||
<toolChain id="com.android.toolchain.gcc.803500692" name="Android GCC" superClass="com.android.toolchain.gcc">
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="com.android.targetPlatform.1260474165" isAbstract="false" superClass="com.android.targetPlatform"/>
|
||||
<builder arguments="NDK_DEBUG=0" command="ndk-build" enableCleanBuild="false" id="com.android.builder.2127875218" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder">
|
||||
<outputEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="obj"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="libs"/>
|
||||
</outputEntries>
|
||||
</builder>
|
||||
<tool id="com.android.gcc.compiler.877935514" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
|
||||
<inputType id="com.android.gcc.inputType.68370901" superClass="com.android.gcc.inputType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="jni"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="EhViewer.null.1834465747" name="EhViewer"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.1322280913;com.android.toolchain.gcc.1322280913.1369823253;com.android.gcc.compiler.877935514;com.android.gcc.inputType.68370901">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.android.AndroidPerProjectProfile"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Default">
|
||||
<resource resourceType="PROJECT" workspacePath="/EhViewer"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="com.android.toolchain.gcc.1322280913">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.android.toolchain.gcc.1322280913" moduleId="org.eclipse.cdt.core.settings" name="Default">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="com.android.toolchain.gcc.1322280913" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="com.android.toolchain.gcc.1322280913.1369823253" name="/" resourcePath="">
|
||||
<toolChain id="com.android.toolchain.gcc.803500692" name="Android GCC" superClass="com.android.toolchain.gcc">
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="com.android.targetPlatform.1260474165" isAbstract="false" superClass="com.android.targetPlatform"/>
|
||||
<builder arguments="NDK_DEBUG=0" autoBuildTarget="" cleanBuildTarget="clean" command="ndk-build" enableAutoBuild="false" enableCleanBuild="false" enabledIncrementalBuild="true" id="com.android.builder.2127875218" incrementalBuildTarget="" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Android Builder" superClass="com.android.builder">
|
||||
<outputEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="obj"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="libs"/>
|
||||
</outputEntries>
|
||||
</builder>
|
||||
<tool id="com.android.gcc.compiler.877935514" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
|
||||
<inputType id="com.android.gcc.inputType.68370901" superClass="com.android.gcc.inputType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="jni"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="EhViewer.null.1834465747" name="EhViewer"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="com.android.toolchain.gcc.1322280913;com.android.toolchain.gcc.1322280913.1369823253;com.android.gcc.compiler.877935514;com.android.gcc.inputType.68370901">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.android.AndroidPerProjectProfile"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="1">
|
||||
<resource resourceType="PROJECT" workspacePath="/EhViewer"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
||||
@@ -0,0 +1,12 @@
|
||||
.settings
|
||||
bin
|
||||
gen
|
||||
obj
|
||||
doc
|
||||
proguard
|
||||
lint.xml
|
||||
libs/armeabi
|
||||
libs/armeabi-v7a
|
||||
libs/arm64-v8a
|
||||
libs/mips
|
||||
libs/x86
|
||||
@@ -9,6 +9,62 @@
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>?children?</key>
|
||||
<value>?children?=?name?=entry\\\\\\\|\\\|?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\||</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value>NDK_DEBUG=0</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>ndk-build</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hippo.ehviewer"
|
||||
android:versionCode="24"
|
||||
android:versionName="0.6.3" >
|
||||
android:versionCode="30"
|
||||
android:versionName="0.6.9" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="19" />
|
||||
android:targetSdkVersion="21" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.GalleryListActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="behind"
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.GalleryDetailActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:screenOrientation="behind"
|
||||
android:windowSoftInputMode="adjustPan|adjustUnspecified|stateHidden" >
|
||||
<intent-filter>
|
||||
@@ -82,14 +82,14 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.GalleryActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.NoActionBar" >
|
||||
android:theme="@style/AppTheme.Gallery" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.SettingsActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:icon="@drawable/ic_action_settings"
|
||||
android:label="@string/preference_settings_title"
|
||||
android:screenOrientation="behind" >
|
||||
@@ -97,16 +97,25 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.FavouriteActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:icon="@drawable/ic_action_favorite"
|
||||
android:label="@string/favourite"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.ListActivity" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.HistoryActivity"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:icon="@drawable/ic_action_history"
|
||||
android:label="@string/history"
|
||||
android:screenOrientation="behind"
|
||||
android:theme="@style/AppTheme.ListActivity" >
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.DownloadActivity"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:configChanges="orientation|screenSize|uiMode"
|
||||
android:icon="@drawable/ic_setting_download"
|
||||
android:label="@string/download"
|
||||
android:launchMode="singleTask"
|
||||
@@ -120,6 +129,12 @@
|
||||
<service
|
||||
android:name=".service.DownloadService"
|
||||
android:label="DownloadService" />
|
||||
|
||||
<provider
|
||||
android:name=".SimpleSuggestionProvider"
|
||||
android:authorities="com.hippo.ehviewer.SimpleSuggestionProvider"
|
||||
android:exported="false" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -44,57 +44,66 @@ libjpeg-turbo/jquant2.c \
|
||||
libjpeg-turbo/jutils.c \
|
||||
libjpeg-turbo/transupp.c \
|
||||
libjpeg-turbo/turbojpeg.c
|
||||
LOCAL_CFLAGS := -O3
|
||||
LOCAL_CFLAGS := -O3 -DANDROID
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
LOCAL_CFLAGS += -mfpu=neon
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi armeabi-v7a))
|
||||
# Don't add -mfpu=neon
|
||||
# Some arm v7 cpu do not support neon,
|
||||
# libjpeg-turbo can check neon in init_simd()
|
||||
# through parse_proc_cpuinfo()
|
||||
#LOCAL_CFLAGS += -mfpu=neon
|
||||
LOCAL_SRC_FILES += \
|
||||
libjpeg-turbo/simd/jsimd_arm.c \
|
||||
libjpeg-turbo/simd/jsimd_arm_neon.S
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),x86)
|
||||
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
|
||||
LOCAL_SRC_FILES += \
|
||||
libjpeg-turbo/simd/jsimd_i386.c \
|
||||
libjpeg-turbo/simd/jccolor-mmx.asm \
|
||||
libjpeg-turbo/simd/jccolor-sse2.asm \
|
||||
libjpeg-turbo/simd/jcgray-mmx.asm \
|
||||
libjpeg-turbo/simd/jcgray-sse2.asm \
|
||||
libjpeg-turbo/simd/jcsample-mmx.asm \
|
||||
libjpeg-turbo/simd/jcsample-sse2.asm \
|
||||
libjpeg-turbo/simd/jdcolor-mmx.asm \
|
||||
libjpeg-turbo/simd/jdcolor-sse2.asm \
|
||||
libjpeg-turbo/simd/jdmerge-mmx.asm \
|
||||
libjpeg-turbo/simd/jdmerge-sse2.asm \
|
||||
libjpeg-turbo/simd/jdsample-mmx.asm \
|
||||
libjpeg-turbo/simd/jdsample-sse2.asm \
|
||||
libjpeg-turbo/simd/jfdctflt-3dn.asm \
|
||||
libjpeg-turbo/simd/jfdctflt-sse.asm \
|
||||
libjpeg-turbo/simd/jfdctfst-mmx.asm \
|
||||
libjpeg-turbo/simd/jfdctfst-sse2.asm \
|
||||
libjpeg-turbo/simd/jfdctint-mmx.asm \
|
||||
libjpeg-turbo/simd/jfdctint-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctflt-3dn.asm \
|
||||
libjpeg-turbo/simd/jidctflt-sse.asm \
|
||||
libjpeg-turbo/simd/jidctflt-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctfst-mmx.asm \
|
||||
libjpeg-turbo/simd/jidctfst-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctint-mmx.asm \
|
||||
libjpeg-turbo/simd/jidctint-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctred-mmx.asm \
|
||||
libjpeg-turbo/simd/jidctred-sse2.asm \
|
||||
libjpeg-turbo/simd/jquant-3dn.asm \
|
||||
libjpeg-turbo/simd/jquantf-sse2.asm \
|
||||
libjpeg-turbo/simd/jquanti-sse2.asm \
|
||||
libjpeg-turbo/simd/jquant-mmx.asm \
|
||||
libjpeg-turbo/simd/jquant-sse.asm \
|
||||
libjpeg-turbo/simd/jsimdcpu.asm
|
||||
libjpeg-turbo/simd/jsimd_arm64.c \
|
||||
libjpeg-turbo/simd/jsimd_arm64_neon.S
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH),mips)
|
||||
ifeq ($(TARGET_ARCH_ABI),x86)
|
||||
LOCAL_SRC_FILES += \
|
||||
libjpeg-turbo/simd/jsimd_i386.c \
|
||||
libjpeg-turbo/simd/jsimdcpu.asm \
|
||||
libjpeg-turbo/simd/jfdctflt-3dn.asm \
|
||||
libjpeg-turbo/simd/jidctflt-3dn.asm \
|
||||
libjpeg-turbo/simd/jquant-3dn.asm \
|
||||
libjpeg-turbo/simd/jccolor-mmx.asm \
|
||||
libjpeg-turbo/simd/jcgray-mmx.asm \
|
||||
libjpeg-turbo/simd/jcsample-mmx.asm \
|
||||
libjpeg-turbo/simd/jdcolor-mmx.asm \
|
||||
libjpeg-turbo/simd/jdmerge-mmx.asm \
|
||||
libjpeg-turbo/simd/jdsample-mmx.asm \
|
||||
libjpeg-turbo/simd/jfdctfst-mmx.asm \
|
||||
libjpeg-turbo/simd/jfdctint-mmx.asm \
|
||||
libjpeg-turbo/simd/jidctfst-mmx.asm \
|
||||
libjpeg-turbo/simd/jidctint-mmx.asm \
|
||||
libjpeg-turbo/simd/jidctred-mmx.asm \
|
||||
libjpeg-turbo/simd/jquant-mmx.asm \
|
||||
libjpeg-turbo/simd/jfdctflt-sse.asm \
|
||||
libjpeg-turbo/simd/jidctflt-sse.asm \
|
||||
libjpeg-turbo/simd/jquant-sse.asm \
|
||||
libjpeg-turbo/simd/jccolor-sse2.asm \
|
||||
libjpeg-turbo/simd/jcgray-sse2.asm \
|
||||
libjpeg-turbo/simd/jcsample-sse2.asm \
|
||||
libjpeg-turbo/simd/jdcolor-sse2.asm \
|
||||
libjpeg-turbo/simd/jdmerge-sse2.asm \
|
||||
libjpeg-turbo/simd/jdsample-sse2.asm \
|
||||
libjpeg-turbo/simd/jfdctfst-sse2.asm \
|
||||
libjpeg-turbo/simd/jfdctint-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctflt-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctfst-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctint-sse2.asm \
|
||||
libjpeg-turbo/simd/jidctred-sse2.asm \
|
||||
libjpeg-turbo/simd/jquantf-sse2.asm \
|
||||
libjpeg-turbo/simd/jquanti-sse2.asm
|
||||
|
||||
LOCAL_ASMFLAGS:= -Plibjpeg-turbo/simd/jsimdcfg.inc
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),mips)
|
||||
LOCAL_SRC_FILES += \
|
||||
libjpeg-turbo/simd/jsimd_mips.c \
|
||||
libjpeg-turbo/simd/jsimd_mips_dspr2.S
|
||||
@@ -117,7 +126,7 @@ zlib/inflate.c \
|
||||
zlib/inftrees.c \
|
||||
zlib/trees.c \
|
||||
zlib/zutil.c
|
||||
LOCAL_CFLAGS := -O3
|
||||
LOCAL_CFLAGS := -O3 -DANDROID
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
@@ -140,10 +149,15 @@ libpng/pngrtran.c \
|
||||
libpng/pngrutil.c \
|
||||
libpng/pngset.c \
|
||||
libpng/pngtrans.c
|
||||
LOCAL_CFLAGS := -O3
|
||||
LOCAL_CFLAGS := -O3 -DANDROID
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
# Add -mfpu=neon
|
||||
# libpng only check neon when add -mfpu=neon
|
||||
LOCAL_CFLAGS += -mfpu=neon
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi armeabi-v7a arm64-v8a))
|
||||
LOCAL_SRC_FILES += \
|
||||
libpng/arm/arm_init.c \
|
||||
libpng/arm/filter_neon_intrinsics.c \
|
||||
@@ -165,7 +179,7 @@ LOCAL_SRC_FILES := \
|
||||
giflib/dgif_lib.c \
|
||||
giflib/gif_hash.c \
|
||||
giflib/gifalloc.c
|
||||
LOCAL_CFLAGS := -O3
|
||||
LOCAL_CFLAGS := -O3 -DANDROID
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
@@ -184,7 +198,7 @@ jpeg.c \
|
||||
png.c \
|
||||
gif.c \
|
||||
utils.c
|
||||
LOCAL_CFLAGS := -O3
|
||||
LOCAL_CFLAGS := -O3 -DANDROID
|
||||
LOCAL_STATIC_LIBRARIES := libjpeg-turbo libpng libgif
|
||||
LOCAL_LDLIBS := -lGLESv2
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# x86 libjpeg-turbo 汇编链接会出错
|
||||
APP_ABI := armeabi armeabi-v7a# mips# x86
|
||||
APP_ABI := armeabi armeabi-v7a# arm64-v8a# mips# x86
|
||||
APP_PLATFORM := android-14
|
||||
APP_OPTIM := release
|
||||
@@ -491,13 +491,13 @@ jobject getObjFromGifFileType(JNIEnv* env, GifFileType* gifFile, int format) {
|
||||
gifClazz = (*env)->FindClass(env,
|
||||
"com/hippo/ehviewer/gallery/image/GifImage");
|
||||
constructor = (*env)->GetMethodID(env, gifClazz, "<init>",
|
||||
"(IIIIII[I)V");
|
||||
"(JIIIII[I)V");
|
||||
if (constructor == 0) {
|
||||
GIF_Free((JNIEnv*)NULL, (int)gif);
|
||||
GIF_Free((JNIEnv*)NULL, gif);
|
||||
return NULL;
|
||||
} else {
|
||||
return (*env)->NewObject(env, gifClazz, constructor, (jint) gif,
|
||||
FORMAT_GIF, realWidth, gifFile->SHeight, format,
|
||||
return (*env)->NewObject(env, gifClazz, constructor, (jlong) (intptr_t) gif,
|
||||
FILE_FORMAT_GIF, realWidth, gifFile->SHeight, format,
|
||||
DEFAULT_TYPE, delayArray);
|
||||
}
|
||||
}
|
||||
@@ -508,7 +508,10 @@ jobject GIF_DecodeStream(JNIEnv* env, jobject is, jint format) {
|
||||
GifFileType* gifFile;
|
||||
jobject gifImage;
|
||||
|
||||
sc = (StreamContainer*)getStreamContainer(env, is);
|
||||
if (format == FORMAT_AUTO)
|
||||
format = FORMAT_RGB;
|
||||
|
||||
sc = getStreamContainer(env, is);
|
||||
if (sc == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -537,6 +540,9 @@ jobject GIF_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
GifFileType* gifFile;
|
||||
jobject gifImage;
|
||||
|
||||
if (format == FORMAT_AUTO)
|
||||
format = FORMAT_RGB;
|
||||
|
||||
gifFile = DGifOpen(fp, &fileReadFun, &errorCode);
|
||||
if (gifFile == NULL)
|
||||
return NULL;
|
||||
@@ -548,18 +554,16 @@ jobject GIF_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
return gifImage;
|
||||
}
|
||||
|
||||
void GIF_Render(JNIEnv* env, int nativeImage, int format, int index) {
|
||||
void GIF_Render(JNIEnv* env, GIF* gif, int format, int index) {
|
||||
|
||||
GIF* gif = (GIF*) nativeImage;
|
||||
if (format != gif->format)
|
||||
return;
|
||||
|
||||
render(gif, index);
|
||||
}
|
||||
|
||||
void GIF_Free(JNIEnv* env, int nativeImage) {
|
||||
void GIF_Free(JNIEnv* env, GIF* gif) {
|
||||
|
||||
GIF* gif = (GIF*) nativeImage;
|
||||
DGifCloseFile(gif->gifFile, &errorCode);
|
||||
free(gif->trans);
|
||||
free(gif->disposals);
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef struct {
|
||||
|
||||
jobject GIF_DecodeStream(JNIEnv* env, jobject is, jint format);
|
||||
jobject GIF_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format);
|
||||
void GIF_Render(JNIEnv* env, int nativeImage, int format, int index);
|
||||
void GIF_Free(JNIEnv* env, int nativeImage);
|
||||
void GIF_Render(JNIEnv* env, GIF* gif, int format, int index);
|
||||
void GIF_Free(JNIEnv* env, GIF* gif);
|
||||
|
||||
#endif /* GIF_H_ */
|
||||
@@ -1,19 +1,20 @@
|
||||
#include "image.h"
|
||||
#include "jpeg.h"
|
||||
#include "gif.h"
|
||||
#include "png.h"
|
||||
#include "giflib/gif_lib.h"
|
||||
|
||||
static int checkFormat(int format) {
|
||||
if (format != GL_RGB && format != GL_RGBA && format != GL_LUMINANCE
|
||||
&& format != GL_LUMINANCE_ALPHA)
|
||||
return GL_RGB;
|
||||
if (format != FORMAT_AUTO && format != FORMAT_GRAY && format != FORMAT_GRAY_ALPHA
|
||||
&& format != FORMAT_RGB && format != FORMAT_RGBA)
|
||||
return FORMAT_AUTO;
|
||||
else
|
||||
return format;
|
||||
}
|
||||
|
||||
// TODO
|
||||
static int detectFileFormat() {
|
||||
return FORMAT_GIF;
|
||||
return FILE_FORMAT_GIF;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -28,25 +29,25 @@ static FILE* detectFileFormatPathName(const char* namePath, int* format) {
|
||||
|
||||
FILE* fp = fopen(namePath, "r");
|
||||
if (fp == NULL) {
|
||||
*format = FORMAT_UNKNOWN;
|
||||
*format = FILE_FORMAT_UNKNOWN;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fread(buf, 1, 2, fp) != 2) {
|
||||
fclose(fp);
|
||||
*format = FORMAT_UNKNOWN;
|
||||
*format = FILE_FORMAT_UNKNOWN;
|
||||
return NULL;
|
||||
}
|
||||
rewind(fp);
|
||||
|
||||
if (!memcmp(buf, jpegSig, 2))
|
||||
*format = FORMAT_JPEG;
|
||||
*format = FILE_FORMAT_JPEG;
|
||||
else if (!memcmp(buf, pngSig, 2))
|
||||
*format = FORMAT_PNG;
|
||||
*format = FILE_FORMAT_PNG;
|
||||
else if (!memcmp(buf, gifSig, 2))
|
||||
*format = FORMAT_GIF;
|
||||
*format = FILE_FORMAT_GIF;
|
||||
else
|
||||
*format = FORMAT_UNKNOWN;
|
||||
*format = FILE_FORMAT_UNKNOWN;
|
||||
|
||||
return fp;
|
||||
}
|
||||
@@ -58,16 +59,16 @@ Java_com_hippo_ehviewer_gallery_image_Image_nativeDecodeStream(JNIEnv* env,
|
||||
format = checkFormat(format);
|
||||
|
||||
switch (detectFileFormat()) {
|
||||
case FORMAT_JPEG:
|
||||
case FILE_FORMAT_JPEG:
|
||||
return JPEG_DecodeStream(env, is, format);
|
||||
|
||||
case FORMAT_PNG:
|
||||
case FILE_FORMAT_PNG:
|
||||
return PNG_DecodeStream(env, is, format);
|
||||
|
||||
case FORMAT_BMP:
|
||||
case FILE_FORMAT_BMP:
|
||||
return NULL;
|
||||
|
||||
case FORMAT_GIF:
|
||||
case FILE_FORMAT_GIF:
|
||||
return GIF_DecodeStream(env, is, format);
|
||||
|
||||
default:
|
||||
@@ -94,16 +95,16 @@ Java_com_hippo_ehviewer_gallery_image_Image_nativeDecodeFile(JNIEnv* env,
|
||||
}
|
||||
|
||||
switch (fileFormat) {
|
||||
case FORMAT_JPEG:
|
||||
case FILE_FORMAT_JPEG:
|
||||
image = JPEG_DecodeFileHandler(env, fp, format);
|
||||
break;
|
||||
case FORMAT_PNG:
|
||||
case FILE_FORMAT_PNG:
|
||||
image = PNG_DecodeFileHandler(env, fp, format);
|
||||
break;
|
||||
case FORMAT_BMP:
|
||||
case FILE_FORMAT_BMP:
|
||||
image = NULL;
|
||||
break;
|
||||
case FORMAT_GIF:
|
||||
case FILE_FORMAT_GIF:
|
||||
image = GIF_DecodeFileHandler(env, fp, format);
|
||||
break;
|
||||
default:
|
||||
@@ -119,48 +120,48 @@ Java_com_hippo_ehviewer_gallery_image_Image_nativeDecodeFile(JNIEnv* env,
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hippo_ehviewer_gallery_image_Image_nativeFree(JNIEnv* env,
|
||||
jclass clazz, jint nativeImage, jint fileFormat) {
|
||||
jclass clazz, jlong nativeImage, jint fileFormat) {
|
||||
|
||||
switch (fileFormat) {
|
||||
case FORMAT_JPEG:
|
||||
JPEG_Free(env, nativeImage);
|
||||
case FILE_FORMAT_JPEG:
|
||||
JPEG_Free(env, (JPEG*) (intptr_t) nativeImage);
|
||||
break;
|
||||
case FORMAT_PNG:
|
||||
PNG_Free(env, nativeImage);
|
||||
case FILE_FORMAT_PNG:
|
||||
PNG_Free(env, (PNG*) (intptr_t) nativeImage);
|
||||
break;
|
||||
case FORMAT_BMP:
|
||||
case FILE_FORMAT_BMP:
|
||||
break;
|
||||
case FORMAT_GIF:
|
||||
GIF_Free(env, nativeImage);
|
||||
case FILE_FORMAT_GIF:
|
||||
GIF_Free(env, (GIF*) (intptr_t) nativeImage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hippo_ehviewer_gallery_image_Image_nativeRender(JNIEnv* env,
|
||||
jclass clazz, jint format, jint type, jint nativeImage, jint fileFormat) {
|
||||
jclass clazz, jint format, jint type, jlong nativeImage, jint fileFormat) {
|
||||
|
||||
switch (fileFormat) {
|
||||
case FORMAT_JPEG:
|
||||
JPEG_Render(env, nativeImage, format);
|
||||
case FILE_FORMAT_JPEG:
|
||||
JPEG_Render(env, (JPEG*) (intptr_t) nativeImage, format);
|
||||
break;
|
||||
case FORMAT_PNG:
|
||||
PNG_Render(env, nativeImage, format);
|
||||
case FILE_FORMAT_PNG:
|
||||
PNG_Render(env, (PNG*) (intptr_t) nativeImage, format);
|
||||
break;
|
||||
case FORMAT_BMP:
|
||||
case FILE_FORMAT_BMP:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hippo_ehviewer_gallery_image_GifImage_nativeRender(JNIEnv* env,
|
||||
jclass clazz, jint format, jint type, jint nativeImage, jint fileFormat,
|
||||
jclass clazz, jint format, jint type, jlong nativeImage, jint fileFormat,
|
||||
jint index) {
|
||||
|
||||
if (type != DEFAULT_TYPE || fileFormat != FORMAT_GIF)
|
||||
if (type != DEFAULT_TYPE || fileFormat != FILE_FORMAT_GIF)
|
||||
return;
|
||||
|
||||
GIF_Render(env, nativeImage, format, index);
|
||||
GIF_Render(env, (GIF*) (intptr_t) nativeImage, format, index);
|
||||
}
|
||||
|
||||
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
|
||||
@@ -55,11 +55,17 @@ typedef struct {
|
||||
#define DEFAULT_TARGET GL_TEXTURE_2D
|
||||
#define DEFAULT_TYPE GL_UNSIGNED_BYTE
|
||||
|
||||
#define FORMAT_UNKNOWN -1
|
||||
#define FORMAT_JPEG 0x0
|
||||
#define FORMAT_PNG 0x1
|
||||
#define FORMAT_BMP 0x2
|
||||
#define FORMAT_GIF 0x3
|
||||
#define FILE_FORMAT_UNKNOWN -1
|
||||
#define FILE_FORMAT_JPEG 0x0
|
||||
#define FILE_FORMAT_PNG 0x1
|
||||
#define FILE_FORMAT_BMP 0x2
|
||||
#define FILE_FORMAT_GIF 0x3
|
||||
|
||||
#define FORMAT_AUTO 0x0
|
||||
#define FORMAT_GRAY GL_LUMINANCE
|
||||
#define FORMAT_GRAY_ALPHA GL_LUMINANCE_ALPHA
|
||||
#define FORMAT_RGB GL_RGB
|
||||
#define FORMAT_RGBA GL_RGBA
|
||||
|
||||
#define BG_LUM 0x21
|
||||
static rgb defaultBgColorRGB ={0x21, 0x21, 0x21};
|
||||
|
||||
@@ -11,9 +11,11 @@ struct my_error_mgr {
|
||||
|
||||
typedef struct my_error_mgr * my_error_ptr;
|
||||
|
||||
char emsg[JMSG_LENGTH_MAX];
|
||||
|
||||
static void my_error_exit(j_common_ptr cinfo) {
|
||||
my_error_ptr myerr = (my_error_ptr) cinfo->err;
|
||||
(*cinfo->err->output_message)(cinfo);
|
||||
(*cinfo->err->format_message)(cinfo, emsg);
|
||||
longjmp(myerr->setjmp_buffer, 1);
|
||||
}
|
||||
|
||||
@@ -43,6 +45,7 @@ jobject JPEG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
cinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
if (setjmp(jerr.setjmp_buffer)) {
|
||||
LOGE("%s", emsg);
|
||||
free(jpeg);
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return NULL;
|
||||
@@ -53,24 +56,35 @@ jobject JPEG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
|
||||
// Set png format
|
||||
switch (format) {
|
||||
case GL_RGB:
|
||||
case FORMAT_AUTO:
|
||||
if (cinfo.jpeg_color_space == JCS_GRAYSCALE) {
|
||||
format = FORMAT_GRAY;
|
||||
cinfo.out_color_space == JCS_GRAYSCALE;
|
||||
} else {
|
||||
format = FORMAT_RGB;
|
||||
cinfo.out_color_space = JCS_RGB;
|
||||
}
|
||||
break;
|
||||
case FORMAT_RGB:
|
||||
cinfo.out_color_space = JCS_RGB;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
case FORMAT_RGBA:
|
||||
cinfo.out_color_space = JCS_EXT_RGBA;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
default:
|
||||
format = GL_LUMINANCE;
|
||||
case FORMAT_GRAY:
|
||||
cinfo.out_color_space = JCS_GRAYSCALE;
|
||||
break;
|
||||
default:
|
||||
format = FORMAT_RGB;
|
||||
cinfo.out_color_space = JCS_RGB;
|
||||
break;
|
||||
}
|
||||
|
||||
jpeg_start_decompress(&cinfo);
|
||||
|
||||
// Set
|
||||
realStride = cinfo.output_width * cinfo.output_components;
|
||||
fakeWidth = format != GL_RGBA ? nextMulOf4(cinfo.output_width) : cinfo.output_width;
|
||||
fakeWidth = format != FORMAT_RGBA ? nextMulOf4(cinfo.output_width) : cinfo.output_width;
|
||||
fakeStride = fakeWidth * cinfo.output_components;
|
||||
data = malloc(fakeStride * cinfo.output_height);
|
||||
if (data == NULL) {
|
||||
@@ -107,19 +121,18 @@ jobject JPEG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
imageClazz = (*env)->FindClass(env,
|
||||
"com/hippo/ehviewer/gallery/image/Image");
|
||||
constructor = (*env)->GetMethodID(env, imageClazz, "<init>",
|
||||
"(IIIIII)V");
|
||||
"(JIIIII)V");
|
||||
if (constructor == 0) {
|
||||
JPEG_Free((JNIEnv*)NULL, (int) jpeg);
|
||||
JPEG_Free((JNIEnv*)NULL, jpeg);
|
||||
return NULL;
|
||||
} else {
|
||||
return (*env)->NewObject(env, imageClazz, constructor, (jint) jpeg,
|
||||
FORMAT_JPEG, cinfo.output_width, cinfo.output_height, format,
|
||||
return (*env)->NewObject(env, imageClazz, constructor, (jlong) (intptr_t) jpeg,
|
||||
FILE_FORMAT_JPEG, cinfo.output_width, cinfo.output_height, format,
|
||||
DEFAULT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
void JPEG_Render(JNIEnv* env, int nativeImage, int format) {
|
||||
JPEG* jpeg = (JPEG*) nativeImage;
|
||||
void JPEG_Render(JNIEnv* env, JPEG* jpeg, int format) {
|
||||
if (format != jpeg->format)
|
||||
return;
|
||||
|
||||
@@ -127,9 +140,8 @@ void JPEG_Render(JNIEnv* env, int nativeImage, int format) {
|
||||
jpeg->height, format, DEFAULT_TYPE, jpeg->data);
|
||||
}
|
||||
|
||||
void JPEG_Free(JNIEnv* env, int nativeImage) {
|
||||
void JPEG_Free(JNIEnv* env, JPEG* jpeg) {
|
||||
|
||||
JPEG* jpeg = (JPEG*) nativeImage;
|
||||
free(jpeg->data);
|
||||
free(jpeg);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ typedef struct {
|
||||
|
||||
jobject JPEG_DecodeStream(JNIEnv* env, jobject is, jint format);
|
||||
jobject JPEG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format);
|
||||
void JPEG_Render(JNIEnv* env, int nativeImage, int format);
|
||||
void JPEG_Free(JNIEnv* env, int nativeImage);
|
||||
void JPEG_Render(JNIEnv* env, JPEG* jpeg, int format);
|
||||
void JPEG_Free(JNIEnv* env, JPEG* jpeg);
|
||||
|
||||
#endif /* JPEG_H_ */
|
||||
@@ -5,6 +5,7 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* Copyright (C) 2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains output colorspace conversion routines.
|
||||
@@ -13,42 +14,11 @@
|
||||
/* This file is included by jdcolor.c */
|
||||
|
||||
|
||||
#define PACK_SHORT_565(r, g, b) ((((r) << 8) & 0xf800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_TWO_PIXELS(l, r) ((r << 16) | l)
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (pixels); \
|
||||
((INT16*)(addr))[1] = (pixels) >> 16; \
|
||||
}
|
||||
#define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(INT32 *)(addr)) = pixels)
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
|
||||
#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
|
||||
|
||||
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
#define DITHER_ROTATE(x) (((x) << 24) | (((x) >> 8) & 0x00FFFFFF))
|
||||
static const INT32 dither_matrix[4] = {
|
||||
0x0008020A,
|
||||
0x0C040E06,
|
||||
0x030B0109,
|
||||
0x0F070D05
|
||||
};
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb565_convert_internal (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 y, cb, cr;
|
||||
@@ -123,10 +93,11 @@ ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
ycc_rgb565D_convert_internal (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 y, cb, cr;
|
||||
@@ -208,10 +179,11 @@ ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
@@ -262,10 +234,11 @@ rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
rgb_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW outptr;
|
||||
register JSAMPROW inptr0, inptr1, inptr2;
|
||||
@@ -320,10 +293,11 @@ rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb565_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
@@ -359,10 +333,11 @@ gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
gray_rgb565D_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
register JSAMPROW inptr, outptr;
|
||||
register JDIMENSION col;
|
||||
|
||||
@@ -140,3 +140,43 @@ rgb_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Convert cmyk to extended RGB
|
||||
*/
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
cmyk_rgb_convert_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows) {
|
||||
|
||||
register float lum;
|
||||
register JSAMPROW inptr0, inptr1, inptr2, inptr3;
|
||||
register JSAMPROW outptr;
|
||||
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++) {
|
||||
lum = inptr3[col] / 255.0f;
|
||||
outptr[RGB_RED] = inptr0[col] * lum;
|
||||
outptr[RGB_GREEN] = inptr1[col] * lum;
|
||||
outptr[RGB_BLUE] = inptr2[col] * lum;
|
||||
/* Set unused byte to 0xFF so it can be interpreted as an opaque */
|
||||
/* alpha channel value */
|
||||
#ifdef RGB_ALPHA
|
||||
outptr[RGB_ALPHA] = 0xFF;
|
||||
#endif
|
||||
outptr += RGB_PIXELSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ycc_rgb_convert_internal ycc_extrgb_convert_internal
|
||||
#define gray_rgb_convert_internal gray_extrgb_convert_internal
|
||||
#define rgb_rgb_convert_internal rgb_extrgb_convert_internal
|
||||
#define cmyk_rgb_convert_internal cmyk_extrgb_convert_internal
|
||||
#include "jdcolext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
@@ -112,6 +113,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#undef ycc_rgb_convert_internal
|
||||
#undef gray_rgb_convert_internal
|
||||
#undef rgb_rgb_convert_internal
|
||||
#undef cmyk_rgb_convert_internal
|
||||
|
||||
#define RGB_RED EXT_RGBX_RED
|
||||
#define RGB_GREEN EXT_RGBX_GREEN
|
||||
@@ -121,6 +123,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ycc_rgb_convert_internal ycc_extrgbx_convert_internal
|
||||
#define gray_rgb_convert_internal gray_extrgbx_convert_internal
|
||||
#define rgb_rgb_convert_internal rgb_extrgbx_convert_internal
|
||||
#define cmyk_rgb_convert_internal cmyk_extrgbx_convert_internal
|
||||
#include "jdcolext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
@@ -130,6 +133,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#undef ycc_rgb_convert_internal
|
||||
#undef gray_rgb_convert_internal
|
||||
#undef rgb_rgb_convert_internal
|
||||
#undef cmyk_rgb_convert_internal
|
||||
|
||||
#define RGB_RED EXT_BGR_RED
|
||||
#define RGB_GREEN EXT_BGR_GREEN
|
||||
@@ -138,6 +142,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ycc_rgb_convert_internal ycc_extbgr_convert_internal
|
||||
#define gray_rgb_convert_internal gray_extbgr_convert_internal
|
||||
#define rgb_rgb_convert_internal rgb_extbgr_convert_internal
|
||||
#define cmyk_rgb_convert_internal cmyk_extbgr_convert_internal
|
||||
#include "jdcolext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
@@ -146,6 +151,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#undef ycc_rgb_convert_internal
|
||||
#undef gray_rgb_convert_internal
|
||||
#undef rgb_rgb_convert_internal
|
||||
#undef cmyk_rgb_convert_internal
|
||||
|
||||
#define RGB_RED EXT_BGRX_RED
|
||||
#define RGB_GREEN EXT_BGRX_GREEN
|
||||
@@ -155,6 +161,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ycc_rgb_convert_internal ycc_extbgrx_convert_internal
|
||||
#define gray_rgb_convert_internal gray_extbgrx_convert_internal
|
||||
#define rgb_rgb_convert_internal rgb_extbgrx_convert_internal
|
||||
#define cmyk_rgb_convert_internal cmyk_extbgrx_convert_internal
|
||||
#include "jdcolext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
@@ -164,6 +171,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#undef ycc_rgb_convert_internal
|
||||
#undef gray_rgb_convert_internal
|
||||
#undef rgb_rgb_convert_internal
|
||||
#undef cmyk_rgb_convert_internal
|
||||
|
||||
#define RGB_RED EXT_XBGR_RED
|
||||
#define RGB_GREEN EXT_XBGR_GREEN
|
||||
@@ -173,6 +181,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ycc_rgb_convert_internal ycc_extxbgr_convert_internal
|
||||
#define gray_rgb_convert_internal gray_extxbgr_convert_internal
|
||||
#define rgb_rgb_convert_internal rgb_extxbgr_convert_internal
|
||||
#define cmyk_rgb_convert_internal cmyk_extxbgr_convert_internal
|
||||
#include "jdcolext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
@@ -182,6 +191,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#undef ycc_rgb_convert_internal
|
||||
#undef gray_rgb_convert_internal
|
||||
#undef rgb_rgb_convert_internal
|
||||
#undef cmyk_rgb_convert_internal
|
||||
|
||||
#define RGB_RED EXT_XRGB_RED
|
||||
#define RGB_GREEN EXT_XRGB_GREEN
|
||||
@@ -191,6 +201,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#define ycc_rgb_convert_internal ycc_extxrgb_convert_internal
|
||||
#define gray_rgb_convert_internal gray_extxrgb_convert_internal
|
||||
#define rgb_rgb_convert_internal rgb_extxrgb_convert_internal
|
||||
#define cmyk_rgb_convert_internal cmyk_extxrgb_convert_internal
|
||||
#include "jdcolext.c"
|
||||
#undef RGB_RED
|
||||
#undef RGB_GREEN
|
||||
@@ -200,6 +211,7 @@ typedef my_color_deconverter * my_cconvert_ptr;
|
||||
#undef ycc_rgb_convert_internal
|
||||
#undef gray_rgb_convert_internal
|
||||
#undef rgb_rgb_convert_internal
|
||||
#undef cmyk_rgb_convert_internal
|
||||
|
||||
|
||||
/*
|
||||
@@ -353,6 +365,45 @@ rgb_gray_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert CMYK to grayscale.
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
cmyk_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 float lum;
|
||||
register int r, g, b;
|
||||
register INT32 * ctab = cconvert->rgb_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++) {
|
||||
lum = (inptr3[col]) / 255.0f;
|
||||
r = inptr0[col] * lum;
|
||||
g = inptr1[col] * lum;
|
||||
b = inptr2[col] * lum;
|
||||
/* Y */
|
||||
outptr[col] = (JSAMPLE)
|
||||
((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF])
|
||||
>> SCALEBITS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Color conversion for no colorspace change: just copy the data,
|
||||
@@ -492,6 +543,50 @@ rgb_rgb_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert CMYK to RGB
|
||||
*/
|
||||
|
||||
METHODDEF(void)
|
||||
cmyk_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
switch (cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
cmyk_extrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
case JCS_EXT_RGBX:
|
||||
case JCS_EXT_RGBA:
|
||||
cmyk_extrgbx_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
case JCS_EXT_BGR:
|
||||
cmyk_extbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
case JCS_EXT_BGRX:
|
||||
case JCS_EXT_BGRA:
|
||||
cmyk_extbgrx_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
case JCS_EXT_XBGR:
|
||||
case JCS_EXT_ABGR:
|
||||
cmyk_extxbgr_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
case JCS_EXT_XRGB:
|
||||
case JCS_EXT_ARGB:
|
||||
cmyk_extxrgb_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
default:
|
||||
cmyk_rgb_convert_internal(cinfo, input_buf, input_row, output_buf,
|
||||
num_rows);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Adobe-style YCCK->CMYK conversion.
|
||||
@@ -544,7 +639,162 @@ ycck_cmyk_convert (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(int *)(addr)) = pixels)
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
|
||||
#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
|
||||
|
||||
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
#define DITHER_ROTATE(x) (((x) << 24) | (((x) >> 8) & 0x00FFFFFF))
|
||||
static const INT32 dither_matrix[4] = {
|
||||
0x0008020A,
|
||||
0x0C040E06,
|
||||
0x030B0109,
|
||||
0x0F070D05
|
||||
};
|
||||
|
||||
|
||||
static INLINE boolean is_big_endian(void)
|
||||
{
|
||||
int test_value = 1;
|
||||
if(*(char *)&test_value != 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* Include inline routines for RGB565 conversion */
|
||||
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_LE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE
|
||||
#define ycc_rgb565_convert_internal ycc_rgb565_convert_le
|
||||
#define ycc_rgb565D_convert_internal ycc_rgb565D_convert_le
|
||||
#define rgb_rgb565_convert_internal rgb_rgb565_convert_le
|
||||
#define rgb_rgb565D_convert_internal rgb_rgb565D_convert_le
|
||||
#define gray_rgb565_convert_internal gray_rgb565_convert_le
|
||||
#define gray_rgb565D_convert_internal gray_rgb565D_convert_le
|
||||
#include "jdcol565.c"
|
||||
#undef PACK_SHORT_565
|
||||
#undef PACK_TWO_PIXELS
|
||||
#undef ycc_rgb565_convert_internal
|
||||
#undef ycc_rgb565D_convert_internal
|
||||
#undef rgb_rgb565_convert_internal
|
||||
#undef rgb_rgb565D_convert_internal
|
||||
#undef gray_rgb565_convert_internal
|
||||
#undef gray_rgb565D_convert_internal
|
||||
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_BE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE
|
||||
#define ycc_rgb565_convert_internal ycc_rgb565_convert_be
|
||||
#define ycc_rgb565D_convert_internal ycc_rgb565D_convert_be
|
||||
#define rgb_rgb565_convert_internal rgb_rgb565_convert_be
|
||||
#define rgb_rgb565D_convert_internal rgb_rgb565D_convert_be
|
||||
#define gray_rgb565_convert_internal gray_rgb565_convert_be
|
||||
#define gray_rgb565D_convert_internal gray_rgb565D_convert_be
|
||||
#include "jdcol565.c"
|
||||
#undef PACK_SHORT_565
|
||||
#undef PACK_TWO_PIXELS
|
||||
#undef ycc_rgb565_convert_internal
|
||||
#undef ycc_rgb565D_convert_internal
|
||||
#undef rgb_rgb565_convert_internal
|
||||
#undef rgb_rgb565D_convert_internal
|
||||
#undef gray_rgb565_convert_internal
|
||||
#undef gray_rgb565D_convert_internal
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
ycc_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
else
|
||||
ycc_rgb565_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
ycc_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
ycc_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
else
|
||||
ycc_rgb565D_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
rgb_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
else
|
||||
rgb_rgb565_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
rgb_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
rgb_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
else
|
||||
rgb_rgb565D_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
gray_rgb565_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
else
|
||||
gray_rgb565_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
gray_rgb565D_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (is_big_endian())
|
||||
gray_rgb565D_convert_be(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
else
|
||||
gray_rgb565D_convert_le(cinfo, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -616,8 +866,12 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
} else if (cinfo->jpeg_color_space == JCS_RGB) {
|
||||
cconvert->pub.color_convert = rgb_gray_convert;
|
||||
build_rgb_y_table(cinfo);
|
||||
} else
|
||||
} else if (cinfo->jpeg_color_space == JCS_CMYK) {
|
||||
cconvert->pub.color_convert = cmyk_gray_convert;
|
||||
build_rgb_y_table(cinfo);
|
||||
} else {
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_RGB:
|
||||
@@ -633,9 +887,9 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
case JCS_EXT_ARGB:
|
||||
cinfo->out_color_components = rgb_pixelsize[cinfo->out_color_space];
|
||||
if (cinfo->jpeg_color_space == JCS_YCbCr) {
|
||||
if (jsimd_can_ycc_rgb())
|
||||
if (jsimd_can_ycc_rgb()) {
|
||||
cconvert->pub.color_convert = jsimd_ycc_rgb_convert;
|
||||
else {
|
||||
} else {
|
||||
cconvert->pub.color_convert = ycc_rgb_convert;
|
||||
build_ycc_rgb_table(cinfo);
|
||||
}
|
||||
@@ -649,8 +903,11 @@ jinit_color_deconverter (j_decompress_ptr cinfo)
|
||||
cconvert->pub.color_convert = null_convert;
|
||||
else
|
||||
cconvert->pub.color_convert = rgb_rgb_convert;
|
||||
} else
|
||||
} else if (cinfo->jpeg_color_space == JCS_CMYK) {
|
||||
cconvert->pub.color_convert = cmyk_rgb_convert;
|
||||
} else {
|
||||
ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL);
|
||||
}
|
||||
break;
|
||||
|
||||
case JCS_RGB565:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2009, 2011, D. R. Commander.
|
||||
* Copyright (C) 2009, 2011, 2014 D. R. Commander.
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
@@ -45,38 +45,6 @@
|
||||
#ifdef UPSAMPLE_MERGING_SUPPORTED
|
||||
|
||||
|
||||
#define PACK_SHORT_565(r, g, b) ((((r) << 8) & 0xf800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_TWO_PIXELS(l, r) ((r << 16) | l)
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (pixels); \
|
||||
((INT16*)(addr))[1] = (pixels) >> 16; \
|
||||
}
|
||||
#define WRITE_TWO_ALIGNED_PIXELS(addr, pixels) ((*(INT32 *)(addr)) = pixels)
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
|
||||
#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
|
||||
|
||||
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
#define DITHER_ROTATE(x) (((x) << 24) | (((x) >> 8) & 0x00FFFFFF))
|
||||
static const INT32 dither_matrix[4] = {
|
||||
0x0008020A,
|
||||
0x0C040E06,
|
||||
0x030B0109,
|
||||
0x0F070D05
|
||||
};
|
||||
|
||||
|
||||
/* Private subobject */
|
||||
|
||||
typedef struct {
|
||||
@@ -451,72 +419,106 @@ h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* RGB565 conversion
|
||||
*/
|
||||
|
||||
#define PACK_SHORT_565_LE(r, g, b) ((((r) << 8) & 0xF800) | \
|
||||
(((g) << 3) & 0x7E0) | ((b) >> 3))
|
||||
#define PACK_SHORT_565_BE(r, g, b) (((r) & 0xF8) | ((g) >> 5) | \
|
||||
(((g) << 11) & 0xE000) | \
|
||||
(((b) << 5) & 0x1F00))
|
||||
|
||||
#define PACK_TWO_PIXELS_LE(l, r) ((r << 16) | l)
|
||||
#define PACK_TWO_PIXELS_BE(l, r) ((l << 16) | r)
|
||||
|
||||
#define PACK_NEED_ALIGNMENT(ptr) (((size_t)(ptr)) & 3)
|
||||
|
||||
#define WRITE_TWO_PIXELS_LE(addr, pixels) { \
|
||||
((INT16*)(addr))[0] = (pixels); \
|
||||
((INT16*)(addr))[1] = (pixels) >> 16; \
|
||||
}
|
||||
#define WRITE_TWO_PIXELS_BE(addr, pixels) { \
|
||||
((INT16*)(addr))[1] = (pixels); \
|
||||
((INT16*)(addr))[0] = (pixels) >> 16; \
|
||||
}
|
||||
|
||||
#define DITHER_565_R(r, dither) ((r) + ((dither) & 0xFF))
|
||||
#define DITHER_565_G(g, dither) ((g) + (((dither) & 0xFF) >> 1))
|
||||
#define DITHER_565_B(b, dither) ((b) + ((dither) & 0xFF))
|
||||
|
||||
|
||||
/* Declarations for ordered dithering
|
||||
*
|
||||
* We use a 4x4 ordered dither array packed into 32 bits. This array is
|
||||
* sufficent for dithering RGB888 to RGB565.
|
||||
*/
|
||||
|
||||
#define DITHER_MASK 0x3
|
||||
#define DITHER_ROTATE(x) (((x) << 24) | (((x) >> 8) & 0x00FFFFFF))
|
||||
static const INT32 dither_matrix[4] = {
|
||||
0x0008020A,
|
||||
0x0C040E06,
|
||||
0x030B0109,
|
||||
0x0F070D05
|
||||
};
|
||||
|
||||
|
||||
/* Include inline routines for RGB565 conversion */
|
||||
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_LE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_LE
|
||||
#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_LE
|
||||
#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_le
|
||||
#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_le
|
||||
#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_le
|
||||
#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_le
|
||||
#include "jdmrg565.c"
|
||||
#undef PACK_SHORT_565
|
||||
#undef PACK_TWO_PIXELS
|
||||
#undef WRITE_TWO_PIXELS
|
||||
#undef h2v1_merged_upsample_565_internal
|
||||
#undef h2v1_merged_upsample_565D_internal
|
||||
#undef h2v2_merged_upsample_565_internal
|
||||
#undef h2v2_merged_upsample_565D_internal
|
||||
|
||||
#define PACK_SHORT_565 PACK_SHORT_565_BE
|
||||
#define PACK_TWO_PIXELS PACK_TWO_PIXELS_BE
|
||||
#define WRITE_TWO_PIXELS WRITE_TWO_PIXELS_BE
|
||||
#define h2v1_merged_upsample_565_internal h2v1_merged_upsample_565_be
|
||||
#define h2v1_merged_upsample_565D_internal h2v1_merged_upsample_565D_be
|
||||
#define h2v2_merged_upsample_565_internal h2v2_merged_upsample_565_be
|
||||
#define h2v2_merged_upsample_565D_internal h2v2_merged_upsample_565D_be
|
||||
#include "jdmrg565.c"
|
||||
#undef PACK_SHORT_565
|
||||
#undef PACK_TWO_PIXELS
|
||||
#undef WRITE_TWO_PIXELS
|
||||
#undef h2v1_merged_upsample_565_internal
|
||||
#undef h2v1_merged_upsample_565D_internal
|
||||
#undef h2v2_merged_upsample_565_internal
|
||||
#undef h2v2_merged_upsample_565D_internal
|
||||
|
||||
|
||||
static INLINE boolean is_big_endian(void)
|
||||
{
|
||||
int test_value = 1;
|
||||
if(*(char *)&test_value != 1)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
METHODDEF(void)
|
||||
h2v1_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr = output_buf[0];
|
||||
|
||||
/* Loop for each pair of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
else
|
||||
h2v1_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -525,70 +527,12 @@ h2v1_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr = output_buf[0];
|
||||
|
||||
/* Loop for each pair of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
if (is_big_endian())
|
||||
h2v1_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
else
|
||||
h2v1_merged_upsample_565D_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -597,92 +541,12 @@ h2v2_merged_upsample_565 (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr * 2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
outptr1 = output_buf[1];
|
||||
|
||||
/* Loop for each group of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr1, rgb);
|
||||
outptr1 += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = rgb;
|
||||
}
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565_be(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
else
|
||||
h2v2_merged_upsample_565_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
|
||||
|
||||
@@ -691,98 +555,12 @@ h2v2_merged_upsample_565D (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
INT32 d1 = dither_matrix[(cinfo->output_scanline+1) & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr*2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
outptr1 = output_buf[1];
|
||||
|
||||
/* Loop for each group of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr1, rgb);
|
||||
outptr1 += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = rgb;
|
||||
}
|
||||
if (is_big_endian())
|
||||
h2v2_merged_upsample_565D_be(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
else
|
||||
h2v2_merged_upsample_565D_le(cinfo, input_buf, in_row_group_ctr,
|
||||
output_buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
* jdmrg565.c
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2013, Linaro Limited.
|
||||
* Copyright (C) 2014, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file contains code for merged upsampling/color conversion.
|
||||
*/
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr = output_buf[0];
|
||||
|
||||
/* Loop for each pair of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v1_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr;
|
||||
JSAMPROW inptr0, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr0 = input_buf[0][in_row_group_ctr];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr = output_buf[0];
|
||||
|
||||
/* Loop for each pair of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 2 Y values and emit 2 pixels */
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr0++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr, rgb);
|
||||
outptr += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
y = GETJSAMPLE(*inptr0);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_565_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr * 2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr * 2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
outptr1 = output_buf[1];
|
||||
|
||||
/* Loop for each group of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr1, rgb);
|
||||
outptr1 += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[y + cred];
|
||||
g = range_limit[y + cgreen];
|
||||
b = range_limit[y + cblue];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = rgb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
INLINE
|
||||
LOCAL(void)
|
||||
h2v2_merged_upsample_565D_internal (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
|
||||
register int y, cred, cgreen, cblue;
|
||||
int cb, cr;
|
||||
register JSAMPROW outptr0, outptr1;
|
||||
JSAMPROW inptr00, inptr01, inptr1, inptr2;
|
||||
JDIMENSION col;
|
||||
/* copy these pointers into registers if possible */
|
||||
register JSAMPLE * range_limit = cinfo->sample_range_limit;
|
||||
int * Crrtab = upsample->Cr_r_tab;
|
||||
int * Cbbtab = upsample->Cb_b_tab;
|
||||
INT32 * Crgtab = upsample->Cr_g_tab;
|
||||
INT32 * Cbgtab = upsample->Cb_g_tab;
|
||||
INT32 d0 = dither_matrix[cinfo->output_scanline & DITHER_MASK];
|
||||
INT32 d1 = dither_matrix[(cinfo->output_scanline+1) & DITHER_MASK];
|
||||
unsigned int r, g, b;
|
||||
INT32 rgb;
|
||||
SHIFT_TEMPS
|
||||
|
||||
inptr00 = input_buf[0][in_row_group_ctr*2];
|
||||
inptr01 = input_buf[0][in_row_group_ctr*2 + 1];
|
||||
inptr1 = input_buf[1][in_row_group_ctr];
|
||||
inptr2 = input_buf[2][in_row_group_ctr];
|
||||
outptr0 = output_buf[0];
|
||||
outptr1 = output_buf[1];
|
||||
|
||||
/* Loop for each group of output pixels */
|
||||
for (col = cinfo->output_width >> 1; col > 0; col--) {
|
||||
/* Do the chroma part of the calculation */
|
||||
cb = GETJSAMPLE(*inptr1++);
|
||||
cr = GETJSAMPLE(*inptr2++);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
/* Fetch 4 Y values and emit 4 pixels */
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr00++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr0, rgb);
|
||||
outptr0 += 4;
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
d0 = DITHER_ROTATE(d0);
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
|
||||
y = GETJSAMPLE(*inptr01++);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
d1 = DITHER_ROTATE(d1);
|
||||
rgb = PACK_TWO_PIXELS(rgb, PACK_SHORT_565(r, g, b));
|
||||
|
||||
WRITE_TWO_PIXELS(outptr1, rgb);
|
||||
outptr1 += 4;
|
||||
}
|
||||
|
||||
/* If image width is odd, do the last output column separately */
|
||||
if (cinfo->output_width & 1) {
|
||||
cb = GETJSAMPLE(*inptr1);
|
||||
cr = GETJSAMPLE(*inptr2);
|
||||
cred = Crrtab[cr];
|
||||
cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS);
|
||||
cblue = Cbbtab[cb];
|
||||
|
||||
y = GETJSAMPLE(*inptr00);
|
||||
r = range_limit[DITHER_565_R(y + cred, d0)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d0)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d0)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr0 = rgb;
|
||||
|
||||
y = GETJSAMPLE(*inptr01);
|
||||
r = range_limit[DITHER_565_R(y + cred, d1)];
|
||||
g = range_limit[DITHER_565_G(y + cgreen, d1)];
|
||||
b = range_limit[DITHER_565_B(y + cblue, d1)];
|
||||
rgb = PACK_SHORT_565(r, g, b);
|
||||
*(INT16*)outptr1 = rgb;
|
||||
}
|
||||
}
|
||||
@@ -1,83 +1,83 @@
|
||||
/*
|
||||
* jinclude.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1994, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file exists to provide a single place to fix any problems with
|
||||
* including the wrong system include files. (Common problems are taken
|
||||
* care of by the standard jconfig symbols, but on really weird systems
|
||||
* you may have to edit this file.)
|
||||
*
|
||||
* NOTE: this file is NOT intended to be included by applications using the
|
||||
* JPEG library. Most applications need only include jpeglib.h.
|
||||
*/
|
||||
|
||||
|
||||
/* Include auto-config file to find out which system include files we need. */
|
||||
|
||||
#include "jconfig.h" /* auto configuration options */
|
||||
#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
|
||||
|
||||
/*
|
||||
* We need the NULL macro and size_t typedef.
|
||||
* On an ANSI-conforming system it is sufficient to include <stddef.h>.
|
||||
* Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
|
||||
* pull in <sys/types.h> as well.
|
||||
* Note that the core JPEG library does not require <stdio.h>;
|
||||
* only the default error handler and data source/destination modules do.
|
||||
* But we must pull it in because of the references to FILE in jpeglib.h.
|
||||
* You can remove those references if you want to compile without <stdio.h>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* We need memory copying and zeroing functions, plus strncpy().
|
||||
* ANSI and System V implementations declare these in <string.h>.
|
||||
* BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
|
||||
* Some systems may declare memset and memcpy in <memory.h>.
|
||||
*
|
||||
* NOTE: we assume the size parameters to these functions are of type size_t.
|
||||
* Change the casts in these macros if not!
|
||||
*/
|
||||
|
||||
#ifdef NEED_BSD_STRINGS
|
||||
|
||||
#include <strings.h>
|
||||
#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
|
||||
|
||||
#else /* not BSD, assume ANSI/SysV string lib */
|
||||
|
||||
#include <string.h>
|
||||
#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The modules that use fread() and fwrite() always invoke them through
|
||||
* these macros. On some systems you may need to twiddle the argument casts.
|
||||
* CAUTION: argument order is different from underlying functions!
|
||||
*/
|
||||
|
||||
#define JFREAD(file,buf,sizeofbuf) \
|
||||
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFWRITE(file,buf,sizeofbuf) \
|
||||
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
/*
|
||||
* jinclude.h
|
||||
*
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1994, Thomas G. Lane.
|
||||
* It was modified by The libjpeg-turbo Project to include only code relevant
|
||||
* to libjpeg-turbo.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*
|
||||
* This file exists to provide a single place to fix any problems with
|
||||
* including the wrong system include files. (Common problems are taken
|
||||
* care of by the standard jconfig symbols, but on really weird systems
|
||||
* you may have to edit this file.)
|
||||
*
|
||||
* NOTE: this file is NOT intended to be included by applications using the
|
||||
* JPEG library. Most applications need only include jpeglib.h.
|
||||
*/
|
||||
|
||||
|
||||
/* Include auto-config file to find out which system include files we need. */
|
||||
|
||||
#include "jconfig.h" /* auto configuration options */
|
||||
#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
|
||||
|
||||
/*
|
||||
* We need the NULL macro and size_t typedef.
|
||||
* On an ANSI-conforming system it is sufficient to include <stddef.h>.
|
||||
* Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
|
||||
* pull in <sys/types.h> as well.
|
||||
* Note that the core JPEG library does not require <stdio.h>;
|
||||
* only the default error handler and data source/destination modules do.
|
||||
* But we must pull it in because of the references to FILE in jpeglib.h.
|
||||
* You can remove those references if you want to compile without <stdio.h>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#ifdef NEED_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* We need memory copying and zeroing functions, plus strncpy().
|
||||
* ANSI and System V implementations declare these in <string.h>.
|
||||
* BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
|
||||
* Some systems may declare memset and memcpy in <memory.h>.
|
||||
*
|
||||
* NOTE: we assume the size parameters to these functions are of type size_t.
|
||||
* Change the casts in these macros if not!
|
||||
*/
|
||||
|
||||
#ifdef NEED_BSD_STRINGS
|
||||
|
||||
#include <strings.h>
|
||||
#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size))
|
||||
|
||||
#else /* not BSD, assume ANSI/SysV string lib */
|
||||
|
||||
#include <string.h>
|
||||
#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size))
|
||||
#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size))
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The modules that use fread() and fwrite() always invoke them through
|
||||
* these macros. On some systems you may need to twiddle the argument casts.
|
||||
* CAUTION: argument order is different from underlying functions!
|
||||
*/
|
||||
|
||||
#define JFREAD(file,buf,sizeofbuf) \
|
||||
((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
#define JFWRITE(file,buf,sizeofbuf) \
|
||||
((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
|
||||
@@ -28,13 +28,13 @@
|
||||
#endif
|
||||
#include "jmorecfg.h" /* seldom changed options */
|
||||
|
||||
/*
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifndef DONT_USE_EXTERN_C
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
/* Various constants determining the sizes of things.
|
||||
* All of these are specified by the JPEG standard, so don't change them
|
||||
@@ -1096,12 +1096,10 @@ struct jpeg_color_quantizer { long dummy; };
|
||||
#include "jerror.h" /* fetch error codes too */
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
#ifndef DONT_USE_EXTERN_C
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
|
||||
#endif /* JPEGLIB_H */
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1 +0,0 @@
|
||||
# dummy
|
||||
@@ -1,109 +0,0 @@
|
||||
jsimd_x86_64.lo: jsimd_x86_64.c ../jinclude.h ../jconfig.h \
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/stddef.h \
|
||||
/usr/include/stdlib.h /usr/include/machine/ieeefp.h /usr/include/_ansi.h \
|
||||
/usr/include/newlib.h /usr/include/sys/config.h \
|
||||
/usr/include/sys/features.h /usr/include/cygwin/config.h \
|
||||
/usr/include/sys/reent.h /usr/include/_ansi.h /usr/include/sys/_types.h \
|
||||
/usr/include/machine/_types.h /usr/include/machine/_default_types.h \
|
||||
/usr/include/sys/lock.h /usr/include/machine/stdlib.h \
|
||||
/usr/include/alloca.h /usr/include/cygwin/stdlib.h \
|
||||
/usr/include/cygwin/wait.h /usr/include/sys/types.h \
|
||||
/usr/include/machine/types.h /usr/include/cygwin/types.h \
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/stdint.h \
|
||||
/usr/include/stdint.h /usr/include/bits/wordsize.h /usr/include/endian.h \
|
||||
/usr/include/bits/endian.h /usr/include/byteswap.h \
|
||||
/usr/include/sys/sysmacros.h /usr/include/stdio.h \
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/stdarg.h \
|
||||
/usr/include/sys/stdio.h \
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include-fixed/sys/cdefs.h \
|
||||
/usr/include/string.h /usr/include/sys/string.h ../jpeglib.h \
|
||||
../jmorecfg.h ../jpegint.h ../jerror.h ../jsimd.h ../jdct.h \
|
||||
../jsimddct.h jsimd.h
|
||||
|
||||
../jinclude.h:
|
||||
|
||||
../jconfig.h:
|
||||
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/stddef.h:
|
||||
|
||||
/usr/include/stdlib.h:
|
||||
|
||||
/usr/include/machine/ieeefp.h:
|
||||
|
||||
/usr/include/_ansi.h:
|
||||
|
||||
/usr/include/newlib.h:
|
||||
|
||||
/usr/include/sys/config.h:
|
||||
|
||||
/usr/include/sys/features.h:
|
||||
|
||||
/usr/include/cygwin/config.h:
|
||||
|
||||
/usr/include/sys/reent.h:
|
||||
|
||||
/usr/include/_ansi.h:
|
||||
|
||||
/usr/include/sys/_types.h:
|
||||
|
||||
/usr/include/machine/_types.h:
|
||||
|
||||
/usr/include/machine/_default_types.h:
|
||||
|
||||
/usr/include/sys/lock.h:
|
||||
|
||||
/usr/include/machine/stdlib.h:
|
||||
|
||||
/usr/include/alloca.h:
|
||||
|
||||
/usr/include/cygwin/stdlib.h:
|
||||
|
||||
/usr/include/cygwin/wait.h:
|
||||
|
||||
/usr/include/sys/types.h:
|
||||
|
||||
/usr/include/machine/types.h:
|
||||
|
||||
/usr/include/cygwin/types.h:
|
||||
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/stdint.h:
|
||||
|
||||
/usr/include/stdint.h:
|
||||
|
||||
/usr/include/bits/wordsize.h:
|
||||
|
||||
/usr/include/endian.h:
|
||||
|
||||
/usr/include/bits/endian.h:
|
||||
|
||||
/usr/include/byteswap.h:
|
||||
|
||||
/usr/include/sys/sysmacros.h:
|
||||
|
||||
/usr/include/stdio.h:
|
||||
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include/stdarg.h:
|
||||
|
||||
/usr/include/sys/stdio.h:
|
||||
|
||||
/usr/lib/gcc/x86_64-pc-cygwin/4.8.1/include-fixed/sys/cdefs.h:
|
||||
|
||||
/usr/include/string.h:
|
||||
|
||||
/usr/include/sys/string.h:
|
||||
|
||||
../jpeglib.h:
|
||||
|
||||
../jmorecfg.h:
|
||||
|
||||
../jpegint.h:
|
||||
|
||||
../jerror.h:
|
||||
|
||||
../jsimd.h:
|
||||
|
||||
../jdct.h:
|
||||
|
||||
../jsimddct.h:
|
||||
|
||||
jsimd.h:
|
||||
@@ -0,0 +1,544 @@
|
||||
/*
|
||||
* jsimd_arm64.c
|
||||
*
|
||||
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
||||
* Copyright 2009-2011, 2013-2014 D. R. Commander
|
||||
*
|
||||
* Based on the x86 SIMD extension for IJG JPEG library,
|
||||
* Copyright (C) 1999-2006, MIYASAKA Masaru.
|
||||
* For conditions of distribution and use, see copyright notice in jsimdext.inc
|
||||
*
|
||||
* This file contains the interface between the "normal" portions
|
||||
* of the library and the SIMD implementations when running on a
|
||||
* 64-bit ARM architecture.
|
||||
*/
|
||||
|
||||
#define JPEG_INTERNALS
|
||||
#include "../jinclude.h"
|
||||
#include "../jpeglib.h"
|
||||
#include "../jsimd.h"
|
||||
#include "../jdct.h"
|
||||
#include "../jsimddct.h"
|
||||
#include "jsimd.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static unsigned int simd_support = ~0;
|
||||
|
||||
/*
|
||||
* Check what SIMD accelerations are supported.
|
||||
*
|
||||
* FIXME: This code is racy under a multi-threaded environment.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ARMv8 architectures support NEON extensions by default.
|
||||
* It is no longer optional as it was with ARMv7.
|
||||
*/
|
||||
|
||||
|
||||
LOCAL(void)
|
||||
init_simd (void)
|
||||
{
|
||||
char *env = NULL;
|
||||
|
||||
if (simd_support != ~0U)
|
||||
return;
|
||||
|
||||
simd_support = 0;
|
||||
|
||||
simd_support |= JSIMD_ARM_NEON;
|
||||
|
||||
/* Force different settings through environment variables */
|
||||
env = getenv("JSIMD_FORCENEON");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support &= JSIMD_ARM_NEON;
|
||||
env = getenv("JSIMD_FORCENONE");
|
||||
if ((env != NULL) && (strcmp(env, "1") == 0))
|
||||
simd_support = 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_rgb_ycc (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_rgb_gray (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_ycc_rgb (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
/* The code is optimised for these values only */
|
||||
if (BITS_IN_JSAMPLE != 8)
|
||||
return 0;
|
||||
if (sizeof(JDIMENSION) != 4)
|
||||
return 0;
|
||||
if ((RGB_PIXELSIZE != 3) && (RGB_PIXELSIZE != 4))
|
||||
return 0;
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_ycc_rgb565 (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
/* The code is optimised for these values only */
|
||||
if (BITS_IN_JSAMPLE != 8)
|
||||
return 0;
|
||||
if (sizeof(JDIMENSION) != 4)
|
||||
return 0;
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_ycc_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_rgb_gray_convert (j_compress_ptr cinfo,
|
||||
JSAMPARRAY input_buf, JSAMPIMAGE output_buf,
|
||||
JDIMENSION output_row, int num_rows)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_ycc_rgb_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
void (*neonfct)(JDIMENSION, JSAMPIMAGE, JDIMENSION, JSAMPARRAY, int);
|
||||
|
||||
switch(cinfo->out_color_space) {
|
||||
case JCS_EXT_RGB:
|
||||
neonfct=jsimd_ycc_extrgb_convert_neon;
|
||||
break;
|
||||
case JCS_EXT_RGBX:
|
||||
case JCS_EXT_RGBA:
|
||||
neonfct=jsimd_ycc_extrgbx_convert_neon;
|
||||
break;
|
||||
case JCS_EXT_BGR:
|
||||
neonfct=jsimd_ycc_extbgr_convert_neon;
|
||||
break;
|
||||
case JCS_EXT_BGRX:
|
||||
case JCS_EXT_BGRA:
|
||||
neonfct=jsimd_ycc_extbgrx_convert_neon;
|
||||
break;
|
||||
case JCS_EXT_XBGR:
|
||||
case JCS_EXT_ABGR:
|
||||
neonfct=jsimd_ycc_extxbgr_convert_neon;
|
||||
break;
|
||||
case JCS_EXT_XRGB:
|
||||
case JCS_EXT_ARGB:
|
||||
neonfct=jsimd_ycc_extxrgb_convert_neon;
|
||||
break;
|
||||
default:
|
||||
neonfct=jsimd_ycc_extrgb_convert_neon;
|
||||
break;
|
||||
}
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
neonfct(cinfo->output_width, input_buf, input_row, output_buf, num_rows);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_ycc_rgb565_convert (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf, JDIMENSION input_row,
|
||||
JSAMPARRAY output_buf, int num_rows)
|
||||
{
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
jsimd_ycc_rgb565_convert_neon(cinfo->output_width, input_buf, input_row,
|
||||
output_buf, num_rows);
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_downsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_downsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data, JSAMPARRAY output_data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_upsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_upsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY * output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY * output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_fancy_upsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_fancy_upsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_fancy_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY * output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_fancy_upsample (j_decompress_ptr cinfo,
|
||||
jpeg_component_info * compptr,
|
||||
JSAMPARRAY input_data,
|
||||
JSAMPARRAY * output_data_ptr)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v2_merged_upsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_h2v1_merged_upsample (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v2_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_h2v1_merged_upsample (j_decompress_ptr cinfo,
|
||||
JSAMPIMAGE input_buf,
|
||||
JDIMENSION in_row_group_ctr,
|
||||
JSAMPARRAY output_buf)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_convsamp (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_convsamp_float (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_convsamp (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
DCTELEM * workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col,
|
||||
FAST_FLOAT * workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_islow (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_ifast (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_fdct_float (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_islow (DCTELEM * data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_ifast (DCTELEM * data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_fdct_float (FAST_FLOAT * data)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_quantize (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_quantize_float (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_quantize (JCOEFPTR coef_block, DCTELEM * divisors,
|
||||
DCTELEM * workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_quantize_float (JCOEFPTR coef_block, FAST_FLOAT * divisors,
|
||||
FAST_FLOAT * workspace)
|
||||
{
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_2x2 (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
/* The code is optimised for these values only */
|
||||
if (DCTSIZE != 8)
|
||||
return 0;
|
||||
if (sizeof(JCOEF) != 2)
|
||||
return 0;
|
||||
if (BITS_IN_JSAMPLE != 8)
|
||||
return 0;
|
||||
if (sizeof(JDIMENSION) != 4)
|
||||
return 0;
|
||||
if (sizeof(ISLOW_MULT_TYPE) != 2)
|
||||
return 0;
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_4x4 (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
/* The code is optimised for these values only */
|
||||
if (DCTSIZE != 8)
|
||||
return 0;
|
||||
if (sizeof(JCOEF) != 2)
|
||||
return 0;
|
||||
if (BITS_IN_JSAMPLE != 8)
|
||||
return 0;
|
||||
if (sizeof(JDIMENSION) != 4)
|
||||
return 0;
|
||||
if (sizeof(ISLOW_MULT_TYPE) != 2)
|
||||
return 0;
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
jsimd_idct_2x2_neon(compptr->dct_table, coef_block, output_buf,
|
||||
output_col);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
jsimd_idct_4x4_neon(compptr->dct_table, coef_block, output_buf,
|
||||
output_col);
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_islow (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
/* The code is optimised for these values only */
|
||||
if (DCTSIZE != 8)
|
||||
return 0;
|
||||
if (sizeof(JCOEF) != 2)
|
||||
return 0;
|
||||
if (BITS_IN_JSAMPLE != 8)
|
||||
return 0;
|
||||
if (sizeof(JDIMENSION) != 4)
|
||||
return 0;
|
||||
if (sizeof(ISLOW_MULT_TYPE) != 2)
|
||||
return 0;
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_ifast (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
/* The code is optimised for these values only */
|
||||
if (DCTSIZE != 8)
|
||||
return 0;
|
||||
if (sizeof(JCOEF) != 2)
|
||||
return 0;
|
||||
if (BITS_IN_JSAMPLE != 8)
|
||||
return 0;
|
||||
if (sizeof(JDIMENSION) != 4)
|
||||
return 0;
|
||||
if (sizeof(IFAST_MULT_TYPE) != 2)
|
||||
return 0;
|
||||
if (IFAST_SCALE_BITS != 2)
|
||||
return 0;
|
||||
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(int)
|
||||
jsimd_can_idct_float (void)
|
||||
{
|
||||
init_simd();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
jsimd_idct_islow_neon(compptr->dct_table, coef_block, output_buf,
|
||||
output_col);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
if (simd_support & JSIMD_ARM_NEON)
|
||||
jsimd_idct_ifast_neon(compptr->dct_table, coef_block, output_buf,
|
||||
output_col);
|
||||
}
|
||||
|
||||
GLOBAL(void)
|
||||
jsimd_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
|
||||
JCOEFPTR coef_block, JSAMPARRAY output_buf,
|
||||
JDIMENSION output_col)
|
||||
{
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2009-2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
* All rights reserved.
|
||||
* Author: Siarhei Siamashka <siarhei.siamashka@nokia.com>
|
||||
* Copyright (C) 2014 Siarhei Siamashka. All Rights Reserved.
|
||||
* Copyright (C) 2014 Linaro Limited. All Rights Reserved.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
@@ -1408,52 +1409,52 @@ asm_function jsimd_idct_2x2_neon
|
||||
.endm
|
||||
|
||||
.macro do_yuv_to_rgb_stage2_store_load_stage1
|
||||
/* "do_yuv_to_rgb_stage2" and "store" */
|
||||
vrshrn.s32 d20, q10, #15
|
||||
/* "do_yuv_to_rgb_stage2" and "store" */
|
||||
vrshrn.s32 d20, q10, #15
|
||||
/* "load" and "do_yuv_to_rgb_stage1" */
|
||||
pld [U, #64]
|
||||
vrshrn.s32 d21, q11, #15
|
||||
vrshrn.s32 d21, q11, #15
|
||||
pld [V, #64]
|
||||
vrshrn.s32 d24, q12, #14
|
||||
vrshrn.s32 d25, q13, #14
|
||||
vrshrn.s32 d24, q12, #14
|
||||
vrshrn.s32 d25, q13, #14
|
||||
vld1.8 {d4}, [U, :64]!
|
||||
vrshrn.s32 d28, q14, #14
|
||||
vrshrn.s32 d28, q14, #14
|
||||
vld1.8 {d5}, [V, :64]!
|
||||
vrshrn.s32 d29, q15, #14
|
||||
vrshrn.s32 d29, q15, #14
|
||||
vaddw.u8 q3, q1, d4 /* q3 = u - 128 */
|
||||
vaddw.u8 q4, q1, d5 /* q2 = v - 128 */
|
||||
vaddw.u8 q11, q10, d0
|
||||
vaddw.u8 q11, q10, d0
|
||||
vmull.s16 q10, d6, d1[1] /* multiply by -11277 */
|
||||
vmlal.s16 q10, d8, d1[2] /* multiply by -23401 */
|
||||
vaddw.u8 q12, q12, d0
|
||||
vaddw.u8 q14, q14, d0
|
||||
vaddw.u8 q12, q12, d0
|
||||
vaddw.u8 q14, q14, d0
|
||||
.if \bpp != 16 /**************** rgb24/rgb32 *********************************/
|
||||
vqmovun.s16 d1\g_offs, q11
|
||||
vqmovun.s16 d1\g_offs, q11
|
||||
pld [Y, #64]
|
||||
vqmovun.s16 d1\r_offs, q12
|
||||
vqmovun.s16 d1\r_offs, q12
|
||||
vld1.8 {d0}, [Y, :64]!
|
||||
vqmovun.s16 d1\b_offs, q14
|
||||
vqmovun.s16 d1\b_offs, q14
|
||||
vmull.s16 q11, d7, d1[1] /* multiply by -11277 */
|
||||
vmlal.s16 q11, d9, d1[2] /* multiply by -23401 */
|
||||
do_store \bpp, 8
|
||||
do_store \bpp, 8
|
||||
vmull.s16 q12, d8, d1[0] /* multiply by 22971 */
|
||||
vmull.s16 q13, d9, d1[0] /* multiply by 22971 */
|
||||
vmull.s16 q14, d6, d1[3] /* multiply by 29033 */
|
||||
vmull.s16 q15, d7, d1[3] /* multiply by 29033 */
|
||||
.else /**************************** rgb565 ***********************************/
|
||||
vqshlu.s16 q13, q11, #8
|
||||
vqshlu.s16 q13, q11, #8
|
||||
pld [Y, #64]
|
||||
vqshlu.s16 q15, q12, #8
|
||||
vqshlu.s16 q14, q14, #8
|
||||
vqshlu.s16 q15, q12, #8
|
||||
vqshlu.s16 q14, q14, #8
|
||||
vld1.8 {d0}, [Y, :64]!
|
||||
vmull.s16 q11, d7, d1[1]
|
||||
vmlal.s16 q11, d9, d1[2]
|
||||
vsri.u16 q15, q13, #5
|
||||
vsri.u16 q15, q13, #5
|
||||
vmull.s16 q12, d8, d1[0]
|
||||
vsri.u16 q15, q14, #11
|
||||
vsri.u16 q15, q14, #11
|
||||
vmull.s16 q13, d9, d1[0]
|
||||
vmull.s16 q14, d6, d1[3]
|
||||
do_store \bpp, 8
|
||||
do_store \bpp, 8
|
||||
vmull.s16 q15, d7, d1[3]
|
||||
.endif
|
||||
.endm
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
#include "jpeglib.h"
|
||||
#include "jerror.h"
|
||||
#include <setjmp.h>
|
||||
#include "turbojpeg.h"
|
||||
#include "tjutil.h"
|
||||
#include "./turbojpeg.h"
|
||||
#include "./tjutil.h"
|
||||
#include "transupp.h"
|
||||
#include "jpegcomp.h"
|
||||
#include "./jpegcomp.h"
|
||||
|
||||
extern void jpeg_mem_dest_tj(j_compress_ptr, unsigned char **,
|
||||
unsigned long *, boolean);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# define PNG_ARM_NEON_FILE "../contrib/arm-neon/linux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
/* contrib/arm-neon/linux.c
|
||||
*
|
||||
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||
* Written by John Bowler, 2014.
|
||||
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* SEE contrib/arm-neon/README before reporting bugs
|
||||
*
|
||||
* STATUS: SUPPORTED
|
||||
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||
*
|
||||
* png_have_neon implemented for Linux by reading the widely available
|
||||
* pseudo-file /proc/cpuinfo.
|
||||
*
|
||||
* This code is strict ANSI-C and is probably moderately portable, it does
|
||||
* however use <stdio.h> and assumes that /proc/cpuinfo is never localized.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||
|
||||
if (f != NULL)
|
||||
{
|
||||
/* This is a simple state machine which reads the input byte-by-byte until
|
||||
* it gets a match on the 'neon' feature or reaches the end of the stream.
|
||||
*/
|
||||
static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 };
|
||||
static const char ch_neon[] = { 78, 69, 79, 78 };
|
||||
|
||||
enum
|
||||
{
|
||||
StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine
|
||||
} state;
|
||||
int counter;
|
||||
|
||||
for (state=StartLine, counter=0;;)
|
||||
{
|
||||
int ch = fgetc(f);
|
||||
|
||||
if (ch == EOF)
|
||||
{
|
||||
/* EOF means error or end-of-file, return false; neon at EOF is
|
||||
* assumed to be a mistake.
|
||||
*/
|
||||
fclose(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case StartLine:
|
||||
/* Match spaces at the start of line */
|
||||
if (ch <= 32) /* skip control characters and space */
|
||||
break;
|
||||
|
||||
counter=0;
|
||||
state = Feature;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case Feature:
|
||||
/* Match 'FEATURE', ASCII case insensitive. */
|
||||
if ((ch & ~0x20) == ch_feature[counter])
|
||||
{
|
||||
if (++counter == (sizeof ch_feature))
|
||||
state = Colon;
|
||||
break;
|
||||
}
|
||||
|
||||
/* did not match 'feature' */
|
||||
state = SkipLine;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case SkipLine:
|
||||
skipLine:
|
||||
/* Skip everything until we see linefeed or carriage return */
|
||||
if (ch != 10 && ch != 13)
|
||||
break;
|
||||
|
||||
state = StartLine;
|
||||
break;
|
||||
|
||||
case Colon:
|
||||
/* Match any number of space or tab followed by ':' */
|
||||
if (ch == 32 || ch == 9)
|
||||
break;
|
||||
|
||||
if (ch == 58) /* i.e. ':' */
|
||||
{
|
||||
state = StartTag;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Either a bad line format or a 'feature' prefix followed by
|
||||
* other characters.
|
||||
*/
|
||||
state = SkipLine;
|
||||
goto skipLine;
|
||||
|
||||
case StartTag:
|
||||
/* Skip space characters before a tag */
|
||||
if (ch == 32 || ch == 9)
|
||||
break;
|
||||
|
||||
state = Neon;
|
||||
counter = 0;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case Neon:
|
||||
/* Look for 'neon' tag */
|
||||
if ((ch & ~0x20) == ch_neon[counter])
|
||||
{
|
||||
if (++counter == (sizeof ch_neon))
|
||||
state = HaveNeon;
|
||||
break;
|
||||
}
|
||||
|
||||
state = SkipTag;
|
||||
/* FALL THROUGH */
|
||||
|
||||
case SkipTag:
|
||||
/* Skip non-space characters */
|
||||
if (ch == 10 || ch == 13)
|
||||
state = StartLine;
|
||||
|
||||
else if (ch == 32 || ch == 9)
|
||||
state = StartTag;
|
||||
break;
|
||||
|
||||
case HaveNeon:
|
||||
/* Have seen a 'neon' prefix, but there must be a space or new
|
||||
* line character to terminate it.
|
||||
*/
|
||||
if (ch == 10 || ch == 13 || ch == 32 || ch == 9)
|
||||
{
|
||||
fclose(f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
state = SkipTag;
|
||||
break;
|
||||
|
||||
default:
|
||||
png_error(png_ptr, "png_have_neon: internal error (bug)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
#define PNG_16BIT_SUPPORTED
|
||||
#define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
#define PNG_ARM_NEON_API_SUPPORTED
|
||||
/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
|
||||
#define PNG_ARM_NEON_CHECK_SUPPORTED
|
||||
#define PNG_BENIGN_ERRORS_SUPPORTED
|
||||
#define PNG_BENIGN_READ_ERRORS_SUPPORTED
|
||||
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
|
||||
|
||||
@@ -7,7 +7,7 @@ jobject PNG_DecodeStream(JNIEnv* env, jobject is, jint format) {
|
||||
}
|
||||
|
||||
jobject PNG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
int pngFormat, width, height;
|
||||
int width, height;
|
||||
png_image image;
|
||||
png_bytep buffer;
|
||||
PNG* png;
|
||||
@@ -20,32 +20,47 @@ jobject PNG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
if (png == NULL)
|
||||
return NULL;
|
||||
|
||||
// Get png format
|
||||
switch (format) {
|
||||
case GL_RGB:
|
||||
pngFormat = PNG_FORMAT_RGB;
|
||||
break;
|
||||
case GL_RGBA:
|
||||
pngFormat = PNG_FORMAT_RGBA;
|
||||
break;
|
||||
case GL_LUMINANCE:
|
||||
pngFormat = PNG_FORMAT_GRAY;
|
||||
break;
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
default:
|
||||
format = GL_LUMINANCE_ALPHA;
|
||||
pngFormat = PNG_FORMAT_GA;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&image, 0, sizeof image);
|
||||
image.version = PNG_IMAGE_VERSION;
|
||||
|
||||
if (!png_image_begin_read_from_stdio(&image, fp))
|
||||
return NULL;
|
||||
|
||||
image.format = pngFormat;
|
||||
fakeWidth = format != GL_RGBA ? nextMulOf4(image.width) : image.width;
|
||||
// Get png format
|
||||
switch (format) {
|
||||
case FORMAT_AUTO:
|
||||
if (image.format == PNG_FORMAT_GRAY) {
|
||||
format = FORMAT_GRAY;
|
||||
} else if (image.format == PNG_FORMAT_GA) {
|
||||
format = FORMAT_GRAY_ALPHA;
|
||||
} else if (image.format == PNG_FORMAT_RGB) {
|
||||
format = FORMAT_RGB;
|
||||
} else if (image.format == PNG_FORMAT_RGBA) {
|
||||
format = FORMAT_RGBA;
|
||||
} else {
|
||||
format = FORMAT_RGB;
|
||||
image.format = PNG_FORMAT_RGB;
|
||||
}
|
||||
break;
|
||||
case FORMAT_RGB:
|
||||
image.format = PNG_FORMAT_RGB;
|
||||
break;
|
||||
case FORMAT_RGBA:
|
||||
image.format = PNG_FORMAT_RGBA;
|
||||
break;
|
||||
case FORMAT_GRAY:
|
||||
image.format = PNG_FORMAT_GRAY;
|
||||
break;
|
||||
case FORMAT_GRAY_ALPHA:
|
||||
image.format = PNG_FORMAT_GA;
|
||||
break;
|
||||
default:
|
||||
format = FORMAT_RGB;
|
||||
image.format = PNG_FORMAT_RGB;
|
||||
break;
|
||||
}
|
||||
|
||||
fakeWidth = format != FORMAT_RGBA ? nextMulOf4(image.width) : image.width;
|
||||
fakeStride = PNG_IMAGE_PIXEL_CHANNELS(image.format) * fakeWidth;
|
||||
buffer = malloc(image.height * fakeStride);
|
||||
if (buffer == NULL)
|
||||
@@ -67,20 +82,19 @@ jobject PNG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format) {
|
||||
imageClazz = (*env)->FindClass(env,
|
||||
"com/hippo/ehviewer/gallery/image/Image");
|
||||
constructor = (*env)->GetMethodID(env, imageClazz, "<init>",
|
||||
"(IIIIII)V");
|
||||
"(JIIIII)V");
|
||||
|
||||
if (constructor == 0) {
|
||||
PNG_Free((JNIEnv*)NULL, (int)png);
|
||||
PNG_Free((JNIEnv*)NULL, png);
|
||||
return NULL;
|
||||
} else {
|
||||
return (*env)->NewObject(env, imageClazz, constructor, (jint) png,
|
||||
FORMAT_PNG, png->width, png->height, format,
|
||||
return (*env)->NewObject(env, imageClazz, constructor, (jlong) (intptr_t) png,
|
||||
FILE_FORMAT_PNG, png->width, png->height, format,
|
||||
DEFAULT_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
void PNG_Render(JNIEnv* env, int nativeImage, int format) {
|
||||
PNG* png = (PNG*) nativeImage;
|
||||
void PNG_Render(JNIEnv* env, PNG* png, int format) {
|
||||
if (format != png->format)
|
||||
return;
|
||||
|
||||
@@ -88,9 +102,8 @@ void PNG_Render(JNIEnv* env, int nativeImage, int format) {
|
||||
png->height, format, DEFAULT_TYPE, png->data);
|
||||
}
|
||||
|
||||
void PNG_Free(JNIEnv* env, int nativeImage) {
|
||||
void PNG_Free(JNIEnv* env, PNG* png) {
|
||||
|
||||
PNG* png = (PNG*) nativeImage;
|
||||
free(png->data);
|
||||
free(png);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ typedef struct {
|
||||
|
||||
jobject PNG_DecodeStream(JNIEnv* env, jobject is, jint format);
|
||||
jobject PNG_DecodeFileHandler(JNIEnv* env, FILE* fp, jint format);
|
||||
void PNG_Render(JNIEnv* env, int nativeImage, int format);
|
||||
void PNG_Free(JNIEnv* env, int nativeImage);
|
||||
void PNG_Render(JNIEnv* env, PNG* png, int format);
|
||||
void PNG_Free(JNIEnv* env, PNG* png);
|
||||
|
||||
#endif /* PNG_H_ */
|
||||
@@ -5,6 +5,7 @@ int nextMulOf4(int x) {
|
||||
return (x + 3) / 4 * 4;
|
||||
}
|
||||
|
||||
// TODO Need a better one
|
||||
byte getVFrowRGB(byte r, byte g, byte b) {
|
||||
byte t = g > b ? g : b;
|
||||
return r > t ? r : t;
|
||||
|
||||
@@ -18,3 +18,25 @@
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
-keep class com.hippo.**
|
||||
|
||||
-keep class com.hippo.ehviewer.gallery.image.Image {*;}
|
||||
|
||||
-keep class com.hippo.ehviewer.gallery.image.GifImage {*;}
|
||||
|
||||
-keepclassmembers public class * extends android.graphics.drawable.Drawable {
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
|
||||
-keepclassmembers class com.hippo.ehviewer.drawable.MaterialProgressDrawable$Ring {
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
|
||||
-keepclassmembers public class * extends com.hippo.ehviewer.windowsanimate.Sprite {
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
@@ -8,9 +8,9 @@
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-19
|
||||
target=android-21
|
||||
android.library.reference.1=../../code/FloatingActionButton/FloatingActionButton
|
||||
android.library.reference.2=../../code/SlidingMenu/library
|
||||
android.library.reference.2=../../code/material-menu/library/src/main
|
||||
|
After Width: | Height: | Size: 270 B |
|
After Width: | Height: | Size: 249 B |
|
After Width: | Height: | Size: 354 B |
|
Before Width: | Height: | Size: 485 B |
|
After Width: | Height: | Size: 250 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 890 B |
|
Before Width: | Height: | Size: 998 B |
|
Before Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 829 B |
|
Before Width: | Height: | Size: 407 B |
|
After Width: | Height: | Size: 375 B |
|
After Width: | Height: | Size: 501 B |
|
After Width: | Height: | Size: 189 B |
|
After Width: | Height: | Size: 199 B |
|
After Width: | Height: | Size: 280 B |
|
Before Width: | Height: | Size: 307 B |
|
After Width: | Height: | Size: 221 B |
|
After Width: | Height: | Size: 740 B |
|
Before Width: | Height: | Size: 919 B |
|
After Width: | Height: | Size: 588 B |
|
Before Width: | Height: | Size: 714 B |
|
Before Width: | Height: | Size: 664 B |
|
After Width: | Height: | Size: 691 B |
|
After Width: | Height: | Size: 487 B |
|
Before Width: | Height: | Size: 289 B |
|
After Width: | Height: | Size: 228 B |
|
After Width: | Height: | Size: 393 B |
|
After Width: | Height: | Size: 327 B |
|
After Width: | Height: | Size: 331 B |
|
After Width: | Height: | Size: 534 B |
|
Before Width: | Height: | Size: 592 B |
|
After Width: | Height: | Size: 365 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |