update to 11.1.1 (5235)

This commit is contained in:
dkaraush 2024-09-11 01:07:16 +04:00
parent 3409cb1c72
commit 3d718c8d36
8468 changed files with 19779 additions and 78080 deletions

View file

@ -43,7 +43,7 @@ dependencies {
implementation 'com.stripe:stripe-android:2.0.2'
implementation 'com.google.mlkit:language-id:16.1.1'
implementation 'com.android.billingclient:billing:6.0.1'
implementation 'com.google.code.gson:gson:2.10'
implementation 'com.google.code.gson:gson:2.11.0'
implementation 'com.google.guava:guava:31.1-android'
implementation 'com.google.android.play:integrity:1.3.0'
implementation 'com.google.android.gms:play-services-safetynet:18.0.1'
@ -64,8 +64,8 @@ dependencies {
def isWindows = String.valueOf(DefaultNativePlatform.currentOperatingSystem.toFamilyName() == OperatingSystemFamily.WINDOWS)
android {
compileSdkVersion 33
buildToolsVersion '33.0.0'
compileSdkVersion 34
buildToolsVersion '34.0.0'
ndkVersion "21.4.7075529"
sourceSets.main.jniLibs.srcDirs = ['./jni/']
@ -93,12 +93,10 @@ android {
coreLibraryDesugaringEnabled true
}
defaultConfig.versionCode = Integer.parseInt(APP_VERSION_CODE)
defaultConfig {
minSdkVersion 19
targetSdkVersion 33
versionName "8.9.0"
targetSdkVersion 34
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
@ -107,14 +105,13 @@ android {
externalNativeBuild {
cmake {
version '3.10.2'
arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-16', "-j=16"
arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-16'
}
}
}
buildTypes {
debug {
debuggable true
jniDebuggable true
minifyEnabled false
shrinkResources false
@ -129,7 +126,6 @@ android {
}
HA_private {
debuggable false
jniDebuggable false
minifyEnabled true
multiDexEnabled true
@ -143,7 +139,6 @@ android {
}
HA_public {
debuggable false
jniDebuggable false
minifyEnabled true
multiDexEnabled true
@ -157,7 +152,6 @@ android {
}
HA_hardcore {
debuggable false
jniDebuggable false
minifyEnabled true
multiDexEnabled true
@ -171,7 +165,6 @@ android {
}
standalone {
debuggable false
jniDebuggable false
minifyEnabled true
multiDexEnabled true
@ -185,7 +178,6 @@ android {
}
release {
debuggable false
jniDebuggable false
minifyEnabled true
shrinkResources false
@ -199,6 +191,7 @@ android {
buildConfigField "boolean", "BUILD_HOST_IS_WINDOWS", isWindows
}
}
namespace 'org.telegram.messenger'
}

View file

@ -16,6 +16,12 @@
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />

View file

@ -16,6 +16,12 @@
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

View file

@ -16,6 +16,14 @@
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<permission android:name="${applicationId}.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>

View file

@ -0,0 +1,98 @@
{
"project_info": {
"project_number": "760348033671",
"firebase_url": "https://tmessages2.firebaseio.com",
"project_id": "tmessages2",
"storage_bucket": "tmessages2.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:760348033671:android:f6afd7b67eae3860",
"android_client_info": {
"package_name": "org.telegram.messenger"
}
},
"oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:760348033671:android:dc022572c167a16c",
"android_client_info": {
"package_name": "org.telegram.messenger.beta"
}
},
"oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:760348033671:android:7396e651423888c3f66e22",
"android_client_info": {
"package_name": "org.telegram.messenger.web"
}
},
"oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyA-t0jLPjUt2FxrA8VPK2EiYHcYcboIR6k"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "760348033671-2hh8ebmuflsnjoc0kldkfells9rhtfni.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View file

@ -5,7 +5,7 @@ set(CMAKE_C_FLAGS "-w -std=c11 -DANDROID -D_LARGEFILE_SOURCE=1 -g")
set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libtgvoip.a,libtgcalls.a,libtgcalls_tp.a,libtgnet.a,libwebp.a,libflac.a,librlottie.a,libsqlite.a,
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,libtgvoip.a,libtgcalls.a,libtgcalls_tp.a,libtgnet.a,libflac.a,librlottie.a,libsqlite.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libswscale.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavformat.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavcodec.a,
@ -51,127 +51,127 @@ set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY
#tgnet
add_library(mozjpeg STATIC
mozjpeg/cjpeg.c mozjpeg/cdjpeg.c mozjpeg/rdgif.c mozjpeg/rdppm.c mozjpeg/rdjpeg.c mozjpeg/rdswitch.c mozjpeg/rdbmp.c
mozjpeg/rdtarga.c mozjpeg/wrbmp.c mozjpeg/wrtarga.c mozjpeg/djpeg.c mozjpeg/cdjpeg.c mozjpeg/rdcolmap.c mozjpeg/rdswitch.c
mozjpeg/wrgif.c mozjpeg/wrppm.c mozjpeg/jpegtran.c mozjpeg/cdjpeg.c mozjpeg/rdswitch.c mozjpeg/transupp.c mozjpeg/turbojpeg.c
mozjpeg/jdatadst-tj.c mozjpeg/jdatasrc-tj.c mozjpeg/jcapimin.c mozjpeg/jcapistd.c mozjpeg/jccoefct.c mozjpeg/jccolor.c
mozjpeg/jcdctmgr.c mozjpeg/jchuff.c mozjpeg/jcext.c mozjpeg/jcicc.c mozjpeg/jcinit.c mozjpeg/jcmainct.c mozjpeg/jcmarker.c
mozjpeg/jcmaster.c mozjpeg/jcomapi.c mozjpeg/jcparam.c mozjpeg/jcphuff.c mozjpeg/jcprepct.c mozjpeg/jcsample.c
mozjpeg/jctrans.c mozjpeg/jdapimin.c mozjpeg/jdapistd.c mozjpeg/jdatadst.c mozjpeg/jdatasrc.c
mozjpeg/jdcoefct.c mozjpeg/jdcolor.c mozjpeg/jddctmgr.c mozjpeg/jdhuff.c mozjpeg/jdicc.c mozjpeg/jdinput.c
mozjpeg/jdmainct.c mozjpeg/jdmarker.c mozjpeg/jdmaster.c mozjpeg/jdmerge.c mozjpeg/jdphuff.c mozjpeg/jdpostct.c mozjpeg/jdsample.c
mozjpeg/jdtrans.c mozjpeg/jerror.c mozjpeg/jfdctflt.c mozjpeg/jfdctfst.c mozjpeg/jfdctint.c mozjpeg/jidctflt.c mozjpeg/jidctfst.c
mozjpeg/jidctint.c mozjpeg/jidctred.c mozjpeg/jquant1.c mozjpeg/jquant2.c mozjpeg/jutils.c mozjpeg/jmemmgr.c mozjpeg/jmemnobs.c)
target_compile_options(mozjpeg PUBLIC
-Os)
set_target_properties(mozjpeg PROPERTIES
ANDROID_ARM_MODE arm)
target_compile_definitions(mozjpeg PUBLIC
BMP_SUPPORTED GIF_SUPPORTED PPM_SUPPORTED TARGA_SUPPORTED)
target_include_directories(mozjpeg PUBLIC
mozjpeg
mozjpeg/simd/nasm)
if (${ANDROID_ABI} STREQUAL "armeabi-v7a")
target_sources(mozjpeg PRIVATE
mozjpeg/simd/arm/jsimd_neon.S
mozjpeg/simd/arm/jsimd.c)
target_compile_definitions(mozjpeg PUBLIC
SIZEOF_SIZE_T=4)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
target_sources(mozjpeg PRIVATE
mozjpeg/simd/arm64/jsimd_neon.S
mozjpeg/simd/arm64/jsimd.c)
target_compile_definitions(mozjpeg PUBLIC
SIZEOF_SIZE_T=8)
elseif(${ANDROID_ABI} STREQUAL "x86")
set(CMAKE_ASM_NASM_COMPILER_ARG1 "${CMAKE_ASM_NASM_COMPILER_ARG1} -DPIC")
target_sources(mozjpeg PRIVATE
mozjpeg/simd/i386/jsimd.c
mozjpeg/simd/i386/jsimdcpu.asm
mozjpeg/simd/i386/jfdctflt-3dn.asm
mozjpeg/simd/i386/jidctflt-3dn.asm
mozjpeg/simd/i386/jquant-3dn.asm
mozjpeg/simd/i386/jccolor-mmx.asm
mozjpeg/simd/i386/jcgray-mmx.asm
mozjpeg/simd/i386/jcsample-mmx.asm
mozjpeg/simd/i386/jdcolor-mmx.asm
mozjpeg/simd/i386/jdmerge-mmx.asm
mozjpeg/simd/i386/jdsample-mmx.asm
mozjpeg/simd/i386/jfdctfst-mmx.asm
mozjpeg/simd/i386/jfdctint-mmx.asm
mozjpeg/simd/i386/jidctfst-mmx.asm
mozjpeg/simd/i386/jidctint-mmx.asm
mozjpeg/simd/i386/jidctred-mmx.asm
mozjpeg/simd/i386/jquant-mmx.asm
mozjpeg/simd/i386/jfdctflt-sse.asm
mozjpeg/simd/i386/jidctflt-sse.asm
mozjpeg/simd/i386/jquant-sse.asm
mozjpeg/simd/i386/jccolor-sse2.asm
mozjpeg/simd/i386/jcgray-sse2.asm
mozjpeg/simd/i386/jchuff-sse2.asm
mozjpeg/simd/i386/jcphuff-sse2.asm
mozjpeg/simd/i386/jcsample-sse2.asm
mozjpeg/simd/i386/jdcolor-sse2.asm
mozjpeg/simd/i386/jdmerge-sse2.asm
mozjpeg/simd/i386/jdsample-sse2.asm
mozjpeg/simd/i386/jfdctfst-sse2.asm
mozjpeg/simd/i386/jfdctint-sse2.asm
mozjpeg/simd/i386/jidctflt-sse2.asm
mozjpeg/simd/i386/jidctfst-sse2.asm
mozjpeg/simd/i386/jidctint-sse2.asm
mozjpeg/simd/i386/jidctred-sse2.asm
mozjpeg/simd/i386/jquantf-sse2.asm
mozjpeg/simd/i386/jquanti-sse2.asm
mozjpeg/simd/i386/jccolor-avx2.asm
mozjpeg/simd/i386/jcgray-avx2.asm
mozjpeg/simd/i386/jcsample-avx2.asm
mozjpeg/simd/i386/jdcolor-avx2.asm
mozjpeg/simd/i386/jdmerge-avx2.asm
mozjpeg/simd/i386/jdsample-avx2.asm
mozjpeg/simd/i386/jfdctint-avx2.asm
mozjpeg/simd/i386/jidctint-avx2.asm
mozjpeg/simd/i386/jquanti-avx2.asm)
target_compile_definitions(mozjpeg PUBLIC
SIZEOF_SIZE_T=4)
elseif(${ANDROID_ABI} STREQUAL "x86_64")
set(CMAKE_ASM_NASM_COMPILER_ARG1 "${CMAKE_ASM_NASM_COMPILER_ARG1} -DPIC")
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DELF")
set(CMAKE_ASM_NASM_DEBUG_FORMAT "dwarf2")
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -D__x86_64__")
target_sources(mozjpeg PRIVATE
mozjpeg/simd/x86_64/jsimd.c
mozjpeg/simd/x86_64/jsimdcpu.asm
mozjpeg/simd/x86_64/jfdctflt-sse.asm
mozjpeg/simd/x86_64/jccolor-sse2.asm
mozjpeg/simd/x86_64/jcgray-sse2.asm
mozjpeg/simd/x86_64/jchuff-sse2.asm
mozjpeg/simd/x86_64/jcphuff-sse2.asm
mozjpeg/simd/x86_64/jcsample-sse2.asm
mozjpeg/simd/x86_64/jdcolor-sse2.asm
mozjpeg/simd/x86_64/jdmerge-sse2.asm
mozjpeg/simd/x86_64/jdsample-sse2.asm
mozjpeg/simd/x86_64/jfdctfst-sse2.asm
mozjpeg/simd/x86_64/jfdctint-sse2.asm
mozjpeg/simd/x86_64/jidctflt-sse2.asm
mozjpeg/simd/x86_64/jidctfst-sse2.asm
mozjpeg/simd/x86_64/jidctint-sse2.asm
mozjpeg/simd/x86_64/jidctred-sse2.asm
mozjpeg/simd/x86_64/jquantf-sse2.asm
mozjpeg/simd/x86_64/jquanti-sse2.asm
mozjpeg/simd/x86_64/jccolor-avx2.asm
mozjpeg/simd/x86_64/jcgray-avx2.asm
mozjpeg/simd/x86_64/jcsample-avx2.asm
mozjpeg/simd/x86_64/jdcolor-avx2.asm
mozjpeg/simd/x86_64/jdmerge-avx2.asm
mozjpeg/simd/x86_64/jdsample-avx2.asm
mozjpeg/simd/x86_64/jfdctint-avx2.asm
mozjpeg/simd/x86_64/jidctint-avx2.asm
mozjpeg/simd/x86_64/jquanti-avx2.asm)
target_compile_definitions(mozjpeg PUBLIC
SIZEOF_SIZE_T=8)
endif()
#add_library(mozjpeg STATIC
# mozjpeg/cjpeg.c mozjpeg/cdjpeg.c mozjpeg/rdgif.c mozjpeg/rdppm.c mozjpeg/rdjpeg.c mozjpeg/rdswitch.c mozjpeg/rdbmp.c
# mozjpeg/rdtarga.c mozjpeg/wrbmp.c mozjpeg/wrtarga.c mozjpeg/djpeg.c mozjpeg/cdjpeg.c mozjpeg/rdcolmap.c mozjpeg/rdswitch.c
# mozjpeg/wrgif.c mozjpeg/wrppm.c mozjpeg/jpegtran.c mozjpeg/cdjpeg.c mozjpeg/rdswitch.c mozjpeg/transupp.c mozjpeg/turbojpeg.c
# mozjpeg/jdatadst-tj.c mozjpeg/jdatasrc-tj.c mozjpeg/jcapimin.c mozjpeg/jcapistd.c mozjpeg/jccoefct.c mozjpeg/jccolor.c
# mozjpeg/jcdctmgr.c mozjpeg/jchuff.c mozjpeg/jcext.c mozjpeg/jcicc.c mozjpeg/jcinit.c mozjpeg/jcmainct.c mozjpeg/jcmarker.c
# mozjpeg/jcmaster.c mozjpeg/jcomapi.c mozjpeg/jcparam.c mozjpeg/jcphuff.c mozjpeg/jcprepct.c mozjpeg/jcsample.c
# mozjpeg/jctrans.c mozjpeg/jdapimin.c mozjpeg/jdapistd.c mozjpeg/jdatadst.c mozjpeg/jdatasrc.c
# mozjpeg/jdcoefct.c mozjpeg/jdcolor.c mozjpeg/jddctmgr.c mozjpeg/jdhuff.c mozjpeg/jdicc.c mozjpeg/jdinput.c
# mozjpeg/jdmainct.c mozjpeg/jdmarker.c mozjpeg/jdmaster.c mozjpeg/jdmerge.c mozjpeg/jdphuff.c mozjpeg/jdpostct.c mozjpeg/jdsample.c
# mozjpeg/jdtrans.c mozjpeg/jerror.c mozjpeg/jfdctflt.c mozjpeg/jfdctfst.c mozjpeg/jfdctint.c mozjpeg/jidctflt.c mozjpeg/jidctfst.c
# mozjpeg/jidctint.c mozjpeg/jidctred.c mozjpeg/jquant1.c mozjpeg/jquant2.c mozjpeg/jutils.c mozjpeg/jmemmgr.c mozjpeg/jmemnobs.c)
#target_compile_options(mozjpeg PUBLIC
# -Os)
#set_target_properties(mozjpeg PROPERTIES
# ANDROID_ARM_MODE arm)
#target_compile_definitions(mozjpeg PUBLIC
# BMP_SUPPORTED GIF_SUPPORTED PPM_SUPPORTED TARGA_SUPPORTED)
#target_include_directories(mozjpeg PUBLIC
# mozjpeg
# mozjpeg/simd/nasm)
#
#if (${ANDROID_ABI} STREQUAL "armeabi-v7a")
# target_sources(mozjpeg PRIVATE
# mozjpeg/simd/arm/jsimd_neon.S
# mozjpeg/simd/arm/jsimd.c)
# target_compile_definitions(mozjpeg PUBLIC
# SIZEOF_SIZE_T=4)
#elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
# target_sources(mozjpeg PRIVATE
# mozjpeg/simd/arm64/jsimd_neon.S
# mozjpeg/simd/arm64/jsimd.c)
# target_compile_definitions(mozjpeg PUBLIC
# SIZEOF_SIZE_T=8)
#elseif(${ANDROID_ABI} STREQUAL "x86")
# set(CMAKE_ASM_NASM_COMPILER_ARG1 "${CMAKE_ASM_NASM_COMPILER_ARG1} -DPIC")
# target_sources(mozjpeg PRIVATE
# mozjpeg/simd/i386/jsimd.c
# mozjpeg/simd/i386/jsimdcpu.asm
# mozjpeg/simd/i386/jfdctflt-3dn.asm
# mozjpeg/simd/i386/jidctflt-3dn.asm
# mozjpeg/simd/i386/jquant-3dn.asm
# mozjpeg/simd/i386/jccolor-mmx.asm
# mozjpeg/simd/i386/jcgray-mmx.asm
# mozjpeg/simd/i386/jcsample-mmx.asm
# mozjpeg/simd/i386/jdcolor-mmx.asm
# mozjpeg/simd/i386/jdmerge-mmx.asm
# mozjpeg/simd/i386/jdsample-mmx.asm
# mozjpeg/simd/i386/jfdctfst-mmx.asm
# mozjpeg/simd/i386/jfdctint-mmx.asm
# mozjpeg/simd/i386/jidctfst-mmx.asm
# mozjpeg/simd/i386/jidctint-mmx.asm
# mozjpeg/simd/i386/jidctred-mmx.asm
# mozjpeg/simd/i386/jquant-mmx.asm
# mozjpeg/simd/i386/jfdctflt-sse.asm
# mozjpeg/simd/i386/jidctflt-sse.asm
# mozjpeg/simd/i386/jquant-sse.asm
# mozjpeg/simd/i386/jccolor-sse2.asm
# mozjpeg/simd/i386/jcgray-sse2.asm
# mozjpeg/simd/i386/jchuff-sse2.asm
# mozjpeg/simd/i386/jcphuff-sse2.asm
# mozjpeg/simd/i386/jcsample-sse2.asm
# mozjpeg/simd/i386/jdcolor-sse2.asm
# mozjpeg/simd/i386/jdmerge-sse2.asm
# mozjpeg/simd/i386/jdsample-sse2.asm
# mozjpeg/simd/i386/jfdctfst-sse2.asm
# mozjpeg/simd/i386/jfdctint-sse2.asm
# mozjpeg/simd/i386/jidctflt-sse2.asm
# mozjpeg/simd/i386/jidctfst-sse2.asm
# mozjpeg/simd/i386/jidctint-sse2.asm
# mozjpeg/simd/i386/jidctred-sse2.asm
# mozjpeg/simd/i386/jquantf-sse2.asm
# mozjpeg/simd/i386/jquanti-sse2.asm
# mozjpeg/simd/i386/jccolor-avx2.asm
# mozjpeg/simd/i386/jcgray-avx2.asm
# mozjpeg/simd/i386/jcsample-avx2.asm
# mozjpeg/simd/i386/jdcolor-avx2.asm
# mozjpeg/simd/i386/jdmerge-avx2.asm
# mozjpeg/simd/i386/jdsample-avx2.asm
# mozjpeg/simd/i386/jfdctint-avx2.asm
# mozjpeg/simd/i386/jidctint-avx2.asm
# mozjpeg/simd/i386/jquanti-avx2.asm)
# target_compile_definitions(mozjpeg PUBLIC
# SIZEOF_SIZE_T=4)
#elseif(${ANDROID_ABI} STREQUAL "x86_64")
# set(CMAKE_ASM_NASM_COMPILER_ARG1 "${CMAKE_ASM_NASM_COMPILER_ARG1} -DPIC")
# set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -DELF")
# set(CMAKE_ASM_NASM_DEBUG_FORMAT "dwarf2")
# set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -D__x86_64__")
# target_sources(mozjpeg PRIVATE
# mozjpeg/simd/x86_64/jsimd.c
# mozjpeg/simd/x86_64/jsimdcpu.asm
# mozjpeg/simd/x86_64/jfdctflt-sse.asm
# mozjpeg/simd/x86_64/jccolor-sse2.asm
# mozjpeg/simd/x86_64/jcgray-sse2.asm
# mozjpeg/simd/x86_64/jchuff-sse2.asm
# mozjpeg/simd/x86_64/jcphuff-sse2.asm
# mozjpeg/simd/x86_64/jcsample-sse2.asm
# mozjpeg/simd/x86_64/jdcolor-sse2.asm
# mozjpeg/simd/x86_64/jdmerge-sse2.asm
# mozjpeg/simd/x86_64/jdsample-sse2.asm
# mozjpeg/simd/x86_64/jfdctfst-sse2.asm
# mozjpeg/simd/x86_64/jfdctint-sse2.asm
# mozjpeg/simd/x86_64/jidctflt-sse2.asm
# mozjpeg/simd/x86_64/jidctfst-sse2.asm
# mozjpeg/simd/x86_64/jidctint-sse2.asm
# mozjpeg/simd/x86_64/jidctred-sse2.asm
# mozjpeg/simd/x86_64/jquantf-sse2.asm
# mozjpeg/simd/x86_64/jquanti-sse2.asm
# mozjpeg/simd/x86_64/jccolor-avx2.asm
# mozjpeg/simd/x86_64/jcgray-avx2.asm
# mozjpeg/simd/x86_64/jcsample-avx2.asm
# mozjpeg/simd/x86_64/jdcolor-avx2.asm
# mozjpeg/simd/x86_64/jdmerge-avx2.asm
# mozjpeg/simd/x86_64/jdsample-avx2.asm
# mozjpeg/simd/x86_64/jfdctint-avx2.asm
# mozjpeg/simd/x86_64/jidctint-avx2.asm
# mozjpeg/simd/x86_64/jquanti-avx2.asm)
# target_compile_definitions(mozjpeg PUBLIC
# SIZEOF_SIZE_T=8)
#endif()
#tgnet
add_library(tgnet STATIC
@ -306,82 +306,6 @@ target_compile_definitions(flac PUBLIC
target_include_directories(flac PUBLIC
exoplayer/libFLAC/include)
#webp
add_library(webp STATIC
libwebp/dec/alpha.c
libwebp/dec/buffer.c
libwebp/dec/frame.c
libwebp/dec/idec.c
libwebp/dec/io.c
libwebp/dec/quant.c
libwebp/dec/tree.c
libwebp/dec/vp8.c
libwebp/dec/vp8l.c
libwebp/dec/webp.c
libwebp/dsp/alpha_processing.c
libwebp/dsp/alpha_processing_sse2.c
libwebp/dsp/cpu.c
libwebp/dsp/dec.c
libwebp/dsp/dec_clip_tables.c
libwebp/dsp/dec_mips32.c
libwebp/dsp/dec_neon.c
libwebp/dsp/dec_sse2.c
libwebp/dsp/enc.c
libwebp/dsp/enc_avx2.c
libwebp/dsp/enc_mips32.c
libwebp/dsp/enc_neon.c
libwebp/dsp/enc_sse2.c
libwebp/dsp/lossless.c
libwebp/dsp/lossless_mips32.c
libwebp/dsp/lossless_neon.c
libwebp/dsp/lossless_sse2.c
libwebp/dsp/upsampling.c
libwebp/dsp/upsampling_neon.c
libwebp/dsp/upsampling_sse2.c
libwebp/dsp/yuv.c
libwebp/dsp/yuv_mips32.c
libwebp/dsp/yuv_sse2.c
libwebp/enc/alpha.c
libwebp/enc/analysis.c
libwebp/enc/backward_references.c
libwebp/enc/config.c
libwebp/enc/cost.c
libwebp/enc/filter.c
libwebp/enc/frame.c
libwebp/enc/histogram.c
libwebp/enc/iterator.c
libwebp/enc/picture.c
libwebp/enc/picture_csp.c
libwebp/enc/picture_psnr.c
libwebp/enc/picture_rescale.c
libwebp/enc/picture_tools.c
libwebp/enc/quant.c
libwebp/enc/syntax.c
libwebp/enc/token.c
libwebp/enc/tree.c
libwebp/enc/vp8l.c
libwebp/enc/webpenc.c
libwebp/utils/bit_reader.c
libwebp/utils/bit_writer.c
libwebp/utils/color_cache.c
libwebp/utils/filters.c
libwebp/utils/huffman.c
libwebp/utils/huffman_encode.c
libwebp/utils/quant_levels.c
libwebp/utils/quant_levels_dec.c
libwebp/utils/random.c
libwebp/utils/rescaler.c
libwebp/utils/thread.c
libwebp/utils/utils.c)
target_compile_options(webp PUBLIC
-Wall -finline-functions -ffast-math -Os)
set_target_properties(webp PROPERTIES
ANDROID_ARM_MODE arm)
target_compile_definitions(webp PUBLIC
HAVE_MALLOC_H HAVE_PTHREAD WEBP_USE_THREAD)
target_include_directories(webp PUBLIC
libwebp/src)
#sqlite
add_library(sqlite STATIC
sqlite/sqlite3.c)
@ -706,9 +630,8 @@ target_link_libraries(${NATIVE_LIB}
tgvoip
tgcalls
tgcalls_tp
mozjpeg
# mozjpeg
tgnet
webp
flac
rlottie
sqlite

View file

@ -86,17 +86,20 @@ LIBS=" -L${PREFIX}/lib"
--enable-swscale \
--enable-protocol=file \
--enable-decoder=h264 \
--enable-decoder=h265 \
--enable-decoder=mpeg4 \
--enable-decoder=mjpeg \
--enable-decoder=gif \
--enable-decoder=alac \
--enable-decoder=opus \
--enable-decoder=mp3 \
--enable-decoder=aac \
--enable-demuxer=mov \
--enable-demuxer=gif \
--enable-demuxer=ogg \
--enable-demuxer=matroska \
--enable-demuxer=mp3 \
--enable-demuxer=aac \
--enable-hwaccels \
--enable-runtime-cpudetect \
$ADDITIONAL_CONFIGURE_FLAG

View file

@ -7,14 +7,12 @@
#include <unistd.h>
#include <android/bitmap.h>
#include <string>
#include <mozjpeg/java/org_libjpegturbo_turbojpeg_TJ.h>
#include <mozjpeg/jpeglib.h>
//#include <mozjpeg/java/org_libjpegturbo_turbojpeg_TJ.h>
//#include <mozjpeg/jpeglib.h>
#include <tgnet/FileLog.h>
#include <vector>
#include <algorithm>
#include "libwebp/webp/decode.h"
#include "libwebp/webp/encode.h"
#include "mozjpeg/turbojpeg.h"
//#include "mozjpeg/turbojpeg.h"
#include "c_utils.h"
extern "C" {
@ -654,58 +652,6 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_unpinBitmap(JNIEnv *env, jc
AndroidBitmap_unlockPixels(env, bitmap);
}
JNIEXPORT jboolean Java_org_telegram_messenger_Utilities_loadWebpImage(JNIEnv *env, jclass clazz, jobject outputBitmap, jobject buffer, jint len, jobject options, jboolean unpin) {
if (!buffer) {
env->ThrowNew(jclass_NullPointerException, "Input buffer can not be null");
return 0;
}
jbyte *inputBuffer = (jbyte *) env->GetDirectBufferAddress(buffer);
int32_t bitmapWidth = 0;
int32_t bitmapHeight = 0;
if (!WebPGetInfo((uint8_t *)inputBuffer, len, &bitmapWidth, &bitmapHeight)) {
env->ThrowNew(jclass_RuntimeException, "Invalid WebP format");
return 0;
}
if (options && env->GetBooleanField(options, jclass_Options_inJustDecodeBounds) == JNI_TRUE) {
env->SetIntField(options, jclass_Options_outWidth, bitmapWidth);
env->SetIntField(options, jclass_Options_outHeight, bitmapHeight);
return 1;
}
if (!outputBitmap) {
env->ThrowNew(jclass_NullPointerException, "output bitmap can not be null");
return 0;
}
AndroidBitmapInfo bitmapInfo;
if (AndroidBitmap_getInfo(env, outputBitmap, &bitmapInfo) != ANDROID_BITMAP_RESUT_SUCCESS) {
env->ThrowNew(jclass_RuntimeException, "Failed to get Bitmap information");
return 0;
}
void *bitmapPixels = nullptr;
if (AndroidBitmap_lockPixels(env, outputBitmap, &bitmapPixels) != ANDROID_BITMAP_RESUT_SUCCESS) {
env->ThrowNew(jclass_RuntimeException, "Failed to lock Bitmap pixels");
return 0;
}
if (!WebPDecodeRGBAInto((uint8_t *) inputBuffer, len, (uint8_t *) bitmapPixels, bitmapInfo.height * bitmapInfo.stride, bitmapInfo.stride)) {
AndroidBitmap_unlockPixels(env, outputBitmap);
env->ThrowNew(jclass_RuntimeException, "Failed to decode webp image");
return 0;
}
if (unpin && AndroidBitmap_unlockPixels(env, outputBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) {
env->ThrowNew(jclass_RuntimeException, "Failed to unlock Bitmap pixels");
return 0;
}
return 1;
}
#define SQUARE(i) ((i)*(i))
inline static void zeroClearInt(int *p, size_t count) {
@ -1068,109 +1014,109 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_drawDitheredGradient(JNIEnv
}
}
JNIEXPORT jint Java_org_telegram_messenger_Utilities_saveProgressiveJpeg(JNIEnv *env, jclass clazz, jobject bitmap, jint width, jint height, jint stride, jint quality, jstring path) {
if (!bitmap || !path || !width || !height || !stride || stride != width * 4) {
return 0;
}
void *pixels = 0;
if (AndroidBitmap_lockPixels(env, bitmap, &pixels) < 0) {
return 0;
}
if (pixels == NULL) {
return 0;
}
tjhandle handle = 0;
if ((handle = tjInitCompress()) == NULL) {
return 0;
}
const char *pathStr = env->GetStringUTFChars(path, 0);
std::string filePath = std::string(pathStr);
if (pathStr != 0) {
env->ReleaseStringUTFChars(path, pathStr);
}
const char *enabledValue = "1";
const char *disabledValue = "0";
setenv("TJ_OPTIMIZE", enabledValue, 1);
setenv("TJ_ARITHMETIC", disabledValue, 1);
setenv("TJ_PROGRESSIVE", enabledValue, 1);
setenv("TJ_REVERT", enabledValue, 1);
TJSAMP jpegSubsamp = TJSAMP::TJSAMP_420;
jint buffSize = (jint) tjBufSize(width, height, jpegSubsamp);
unsigned char *jpegBuf = new unsigned char[buffSize];
unsigned char *srcBuf = (unsigned char *) pixels;
int pf = org_libjpegturbo_turbojpeg_TJ_PF_RGBA;
jsize actualPitch = width * tjPixelSize[pf];
jsize arraySize = (height - 1) * actualPitch + (width) * tjPixelSize[pf];
unsigned long jpegSize = tjBufSize(width, height, jpegSubsamp);
if (tjCompress2(handle, srcBuf, width, stride, height, pf, &jpegBuf, &jpegSize, jpegSubsamp, quality, TJFLAG_ACCURATEDCT | TJFLAG_PROGRESSIVE | TJFLAG_NOREALLOC) == 0) {
FILE *f = fopen(filePath.c_str(), "wb");
if (f && fwrite(jpegBuf, sizeof(unsigned char), jpegSize, f) == jpegSize) {
fflush(f);
fsync(fileno(f));
} else {
jpegSize = -1;
}
fclose(f);
} else {
jpegSize = -1;
}
delete[] jpegBuf;
tjDestroy(handle);
AndroidBitmap_unlockPixels(env, bitmap);
return jpegSize;
/*struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
const char *pathStr = env->GetStringUTFChars(path, 0);
std::string filePath = std::string(pathStr);
if (pathStr != 0) {
env->ReleaseStringUTFChars(path, pathStr);
}
uint8_t *outBuffer = NULL;
unsigned long outSize = 0;
jpeg_mem_dest(&cinfo, &outBuffer, &outSize);
unsigned char *srcBuf = (unsigned char *) pixels;
cinfo.image_width = (uint32_t) width;
cinfo.image_height = (uint32_t) height;
cinfo.input_components = 4;
cinfo.in_color_space = JCS_EXT_RGBA;
jpeg_c_set_int_param(&cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
jpeg_set_defaults(&cinfo);
cinfo.arith_code = FALSE;
cinfo.dct_method = JDCT_ISLOW;
cinfo.optimize_coding = TRUE;
jpeg_set_quality(&cinfo, 78, 1);
jpeg_simple_progression(&cinfo);
jpeg_start_compress(&cinfo, 1);
JSAMPROW rowPointer[1];
while (cinfo.next_scanline < cinfo.image_height) {
rowPointer[0] = (JSAMPROW) (srcBuf + cinfo.next_scanline * stride);
jpeg_write_scanlines(&cinfo, rowPointer, 1);
}
jpeg_finish_compress(&cinfo);
FILE *f = fopen(filePath.c_str(), "wb");
if (f && fwrite(outBuffer, sizeof(uint8_t), outSize, f) == outSize) {
fflush(f);
fsync(fileno(f));
}
fclose(f);
jpeg_destroy_compress(&cinfo);
return outSize;*/
}
//JNIEXPORT jint Java_org_telegram_messenger_Utilities_saveProgressiveJpeg(JNIEnv *env, jclass clazz, jobject bitmap, jint width, jint height, jint stride, jint quality, jstring path) {
// if (!bitmap || !path || !width || !height || !stride || stride != width * 4) {
// return 0;
// }
// void *pixels = 0;
// if (AndroidBitmap_lockPixels(env, bitmap, &pixels) < 0) {
// return 0;
// }
// if (pixels == NULL) {
// return 0;
// }
// tjhandle handle = 0;
// if ((handle = tjInitCompress()) == NULL) {
// return 0;
// }
// const char *pathStr = env->GetStringUTFChars(path, 0);
// std::string filePath = std::string(pathStr);
// if (pathStr != 0) {
// env->ReleaseStringUTFChars(path, pathStr);
// }
//
// const char *enabledValue = "1";
// const char *disabledValue = "0";
// setenv("TJ_OPTIMIZE", enabledValue, 1);
// setenv("TJ_ARITHMETIC", disabledValue, 1);
// setenv("TJ_PROGRESSIVE", enabledValue, 1);
// setenv("TJ_REVERT", enabledValue, 1);
//
// TJSAMP jpegSubsamp = TJSAMP::TJSAMP_420;
// jint buffSize = (jint) tjBufSize(width, height, jpegSubsamp);
// unsigned char *jpegBuf = new unsigned char[buffSize];
// unsigned char *srcBuf = (unsigned char *) pixels;
//
// int pf = org_libjpegturbo_turbojpeg_TJ_PF_RGBA;
//
// jsize actualPitch = width * tjPixelSize[pf];
// jsize arraySize = (height - 1) * actualPitch + (width) * tjPixelSize[pf];
// unsigned long jpegSize = tjBufSize(width, height, jpegSubsamp);
//
// if (tjCompress2(handle, srcBuf, width, stride, height, pf, &jpegBuf, &jpegSize, jpegSubsamp, quality, TJFLAG_ACCURATEDCT | TJFLAG_PROGRESSIVE | TJFLAG_NOREALLOC) == 0) {
// FILE *f = fopen(filePath.c_str(), "wb");
// if (f && fwrite(jpegBuf, sizeof(unsigned char), jpegSize, f) == jpegSize) {
// fflush(f);
// fsync(fileno(f));
// } else {
// jpegSize = -1;
// }
// fclose(f);
// } else {
// jpegSize = -1;
// }
// delete[] jpegBuf;
// tjDestroy(handle);
// AndroidBitmap_unlockPixels(env, bitmap);
// return jpegSize;
//
// /*struct jpeg_compress_struct cinfo;
// struct jpeg_error_mgr jerr;
// cinfo.err = jpeg_std_error(&jerr);
// jpeg_create_compress(&cinfo);
//
// const char *pathStr = env->GetStringUTFChars(path, 0);
// std::string filePath = std::string(pathStr);
// if (pathStr != 0) {
// env->ReleaseStringUTFChars(path, pathStr);
// }
//
// uint8_t *outBuffer = NULL;
// unsigned long outSize = 0;
// jpeg_mem_dest(&cinfo, &outBuffer, &outSize);
// unsigned char *srcBuf = (unsigned char *) pixels;
//
// cinfo.image_width = (uint32_t) width;
// cinfo.image_height = (uint32_t) height;
// cinfo.input_components = 4;
// cinfo.in_color_space = JCS_EXT_RGBA;
// jpeg_c_set_int_param(&cinfo, JINT_COMPRESS_PROFILE, JCP_FASTEST);
// jpeg_set_defaults(&cinfo);
// cinfo.arith_code = FALSE;
// cinfo.dct_method = JDCT_ISLOW;
// cinfo.optimize_coding = TRUE;
// jpeg_set_quality(&cinfo, 78, 1);
// jpeg_simple_progression(&cinfo);
// jpeg_start_compress(&cinfo, 1);
//
// JSAMPROW rowPointer[1];
// while (cinfo.next_scanline < cinfo.image_height) {
// rowPointer[0] = (JSAMPROW) (srcBuf + cinfo.next_scanline * stride);
// jpeg_write_scanlines(&cinfo, rowPointer, 1);
// }
//
// jpeg_finish_compress(&cinfo);
//
// FILE *f = fopen(filePath.c_str(), "wb");
// if (f && fwrite(outBuffer, sizeof(uint8_t), outSize, f) == outSize) {
// fflush(f);
// fsync(fileno(f));
// }
// fclose(f);
//
// jpeg_destroy_compress(&cinfo);
// return outSize;*/
//}
std::vector<std::pair<float, float>> gatherPositions(std::vector<std::pair<float, float>> list, int phase) {
std::vector<std::pair<float, float>> result(4);

View file

@ -1,24 +0,0 @@
Contributors:
- Charles Munger (clm at google dot com)
- Christian Duvivier (cduvivier at google dot com)
- Djordje Pesut (djordje dot pesut at imgtec dot com)
- James Zern (jzern at google dot com)
- Jan Engelhardt (jengelh at medozas dot de)
- Johann (johann dot koenig at duck dot com)
- Jovan Zelincevic (jovan dot zelincevic at imgtec dot com)
- Jyrki Alakuijala (jyrki at google dot com)
- levytamar82 (tamar dot levy at intel dot com)
- Lou Quillio (louquillio at google dot com)
- Mans Rullgard (mans at mansr dot com)
- Martin Olsson (mnemo at minimum dot se)
- Mikołaj Zalewski (mikolajz at google dot com)
- Noel Chromium (noel at chromium dot org)
- Pascal Massimino (pascal dot massimino at gmail dot com)
- Paweł Hajdan, Jr (phajdan dot jr at chromium dot org)
- Pierre Joye (pierre dot php at gmail dot com)
- Scott LaVarnway (slavarnway at google dot com)
- Scott Talbot (s at chikachow dot org)
- Slobodan Prijic (slobodan dot prijic at imgtec dot com)
- Somnath Banerjee (somnath dot banerjee at gmail dot com)
- Urvang Joshi (urvang at google dot com)
- Vikas Arora (vikasa at google dot com)

View file

@ -1,30 +0,0 @@
Copyright (c) 2010, Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Google nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1,23 +0,0 @@
Additional IP Rights Grant (Patents)
------------------------------------
"These implementations" means the copyrightable works that implement the WebM
codecs distributed by Google as part of the WebM Project.
Google hereby grants to you a perpetual, worldwide, non-exclusive, no-charge,
royalty-free, irrevocable (except as stated in this section) patent license to
make, have made, use, offer to sell, sell, import, transfer, and otherwise
run, modify and propagate the contents of these implementations of WebM, where
such license applies only to those patent claims, both currently owned by
Google and acquired in the future, licensable by Google that are necessarily
infringed by these implementations of WebM. This grant does not include claims
that would be infringed only as a consequence of further modification of these
implementations. If you or your agent or exclusive licensee institute or order
or agree to the institution of patent litigation or any other patent
enforcement activity against any entity (including a cross-claim or
counterclaim in a lawsuit) alleging that any of these implementations of WebM
or any code incorporated within any of these implementations of WebM
constitute direct or contributory patent infringement, or inducement of
patent infringement, then any patent rights granted to you under this License
for these implementations of WebM shall terminate as of the date such
litigation is filed.

View file

@ -1,165 +0,0 @@
// Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Alpha-plane decompression.
//
// Author: Skal (pascal.massimino@gmail.com)
#include <stdlib.h>
#include "./alphai.h"
#include "./vp8i.h"
#include "./vp8li.h"
#include "../utils/quant_levels_dec.h"
#include "../utils/utils.h"
#include "../webp/format_constants.h"
//------------------------------------------------------------------------------
// ALPHDecoder object.
ALPHDecoder* ALPHNew(void) {
ALPHDecoder* const dec = (ALPHDecoder*)WebPSafeCalloc(1ULL, sizeof(*dec));
return dec;
}
void ALPHDelete(ALPHDecoder* const dec) {
if (dec != NULL) {
VP8LDelete(dec->vp8l_dec_);
dec->vp8l_dec_ = NULL;
WebPSafeFree(dec);
}
}
//------------------------------------------------------------------------------
// Decoding.
// Initialize alpha decoding by parsing the alpha header and decoding the image
// header for alpha data stored using lossless compression.
// Returns false in case of error in alpha header (data too short, invalid
// compression method or filter, error in lossless header data etc).
static int ALPHInit(ALPHDecoder* const dec, const uint8_t* data,
size_t data_size, int width, int height, uint8_t* output) {
int ok = 0;
const uint8_t* const alpha_data = data + ALPHA_HEADER_LEN;
const size_t alpha_data_size = data_size - ALPHA_HEADER_LEN;
int rsrv;
assert(width > 0 && height > 0);
assert(data != NULL && output != NULL);
dec->width_ = width;
dec->height_ = height;
if (data_size <= ALPHA_HEADER_LEN) {
return 0;
}
dec->method_ = (data[0] >> 0) & 0x03;
dec->filter_ = (data[0] >> 2) & 0x03;
dec->pre_processing_ = (data[0] >> 4) & 0x03;
rsrv = (data[0] >> 6) & 0x03;
if (dec->method_ < ALPHA_NO_COMPRESSION ||
dec->method_ > ALPHA_LOSSLESS_COMPRESSION ||
dec->filter_ >= WEBP_FILTER_LAST ||
dec->pre_processing_ > ALPHA_PREPROCESSED_LEVELS ||
rsrv != 0) {
return 0;
}
if (dec->method_ == ALPHA_NO_COMPRESSION) {
const size_t alpha_decoded_size = dec->width_ * dec->height_;
ok = (alpha_data_size >= alpha_decoded_size);
} else {
assert(dec->method_ == ALPHA_LOSSLESS_COMPRESSION);
ok = VP8LDecodeAlphaHeader(dec, alpha_data, alpha_data_size, output);
}
return ok;
}
// Decodes, unfilters and dequantizes *at least* 'num_rows' rows of alpha
// starting from row number 'row'. It assumes that rows up to (row - 1) have
// already been decoded.
// Returns false in case of bitstream error.
static int ALPHDecode(VP8Decoder* const dec, int row, int num_rows) {
ALPHDecoder* const alph_dec = dec->alph_dec_;
const int width = alph_dec->width_;
const int height = alph_dec->height_;
WebPUnfilterFunc unfilter_func = WebPUnfilters[alph_dec->filter_];
uint8_t* const output = dec->alpha_plane_;
if (alph_dec->method_ == ALPHA_NO_COMPRESSION) {
const size_t offset = row * width;
const size_t num_pixels = num_rows * width;
assert(dec->alpha_data_size_ >= ALPHA_HEADER_LEN + offset + num_pixels);
memcpy(dec->alpha_plane_ + offset,
dec->alpha_data_ + ALPHA_HEADER_LEN + offset, num_pixels);
} else { // alph_dec->method_ == ALPHA_LOSSLESS_COMPRESSION
assert(alph_dec->vp8l_dec_ != NULL);
if (!VP8LDecodeAlphaImageStream(alph_dec, row + num_rows)) {
return 0;
}
}
if (unfilter_func != NULL) {
unfilter_func(width, height, width, row, num_rows, output);
}
if (row + num_rows == dec->pic_hdr_.height_) {
dec->is_alpha_decoded_ = 1;
}
return 1;
}
//------------------------------------------------------------------------------
// Main entry point.
const uint8_t* VP8DecompressAlphaRows(VP8Decoder* const dec,
int row, int num_rows) {
const int width = dec->pic_hdr_.width_;
const int height = dec->pic_hdr_.height_;
if (row < 0 || num_rows <= 0 || row + num_rows > height) {
return NULL; // sanity check.
}
if (row == 0) {
// Initialize decoding.
assert(dec->alpha_plane_ != NULL);
dec->alph_dec_ = ALPHNew();
if (dec->alph_dec_ == NULL) return NULL;
if (!ALPHInit(dec->alph_dec_, dec->alpha_data_, dec->alpha_data_size_,
width, height, dec->alpha_plane_)) {
ALPHDelete(dec->alph_dec_);
dec->alph_dec_ = NULL;
return NULL;
}
// if we allowed use of alpha dithering, check whether it's needed at all
if (dec->alph_dec_->pre_processing_ != ALPHA_PREPROCESSED_LEVELS) {
dec->alpha_dithering_ = 0; // disable dithering
} else {
num_rows = height; // decode everything in one pass
}
}
if (!dec->is_alpha_decoded_) {
int ok = 0;
assert(dec->alph_dec_ != NULL);
ok = ALPHDecode(dec, row, num_rows);
if (ok && dec->alpha_dithering_ > 0) {
ok = WebPDequantizeLevels(dec->alpha_plane_, width, height,
dec->alpha_dithering_);
}
if (!ok || dec->is_alpha_decoded_) {
ALPHDelete(dec->alph_dec_);
dec->alph_dec_ = NULL;
}
if (!ok) return NULL; // Error.
}
// Return a pointer to the current decoded row.
return dec->alpha_plane_ + row * width;
}

View file

@ -1,55 +0,0 @@
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Alpha decoder: internal header.
//
// Author: Urvang (urvang@google.com)
#ifndef WEBP_DEC_ALPHAI_H_
#define WEBP_DEC_ALPHAI_H_
#include "./webpi.h"
#include "../utils/filters.h"
#ifdef __cplusplus
extern "C" {
#endif
struct VP8LDecoder; // Defined in dec/vp8li.h.
typedef struct ALPHDecoder ALPHDecoder;
struct ALPHDecoder {
int width_;
int height_;
int method_;
WEBP_FILTER_TYPE filter_;
int pre_processing_;
struct VP8LDecoder* vp8l_dec_;
VP8Io io_;
int use_8b_decode; // Although alpha channel requires only 1 byte per
// pixel, sometimes VP8LDecoder may need to allocate
// 4 bytes per pixel internally during decode.
};
//------------------------------------------------------------------------------
// internal functions. Not public.
// Allocates a new alpha decoder instance.
ALPHDecoder* ALPHNew(void);
// Clears and deallocates an alpha decoder instance.
void ALPHDelete(ALPHDecoder* const dec);
//------------------------------------------------------------------------------
#ifdef __cplusplus
} // extern "C"
#endif
#endif /* WEBP_DEC_ALPHAI_H_ */

View file

@ -1,251 +0,0 @@
// Copyright 2011 Google Inc. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the COPYING file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS. All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
// -----------------------------------------------------------------------------
//
// Everything about WebPDecBuffer
//
// Author: Skal (pascal.massimino@gmail.com)
#include <stdlib.h>
#include "./vp8i.h"
#include "./webpi.h"
#include "../utils/utils.h"
//------------------------------------------------------------------------------
// WebPDecBuffer
// Number of bytes per pixel for the different color-spaces.
static const int kModeBpp[MODE_LAST] = {
3, 4, 3, 4, 4, 2, 2,
4, 4, 4, 2, // pre-multiplied modes
1, 1 };
// Check that webp_csp_mode is within the bounds of WEBP_CSP_MODE.
// Convert to an integer to handle both the unsigned/signed enum cases
// without the need for casting to remove type limit warnings.
static int IsValidColorspace(int webp_csp_mode) {
return (webp_csp_mode >= MODE_RGB && webp_csp_mode < MODE_LAST);
}
static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) {
int ok = 1;
const WEBP_CSP_MODE mode = buffer->colorspace;
const int width = buffer->width;
const int height = buffer->height;
if (!IsValidColorspace(mode)) {
ok = 0;
} else if (!WebPIsRGBMode(mode)) { // YUV checks
const WebPYUVABuffer* const buf = &buffer->u.YUVA;
const int y_stride = abs(buf->y_stride);
const int u_stride = abs(buf->u_stride);
const int v_stride = abs(buf->v_stride);
const int a_stride = abs(buf->a_stride);
const uint64_t y_size = (uint64_t)y_stride * height;
const uint64_t u_size = (uint64_t)u_stride * ((height + 1) / 2);
const uint64_t v_size = (uint64_t)v_stride * ((height + 1) / 2);
const uint64_t a_size = (uint64_t)a_stride * height;
ok &= (y_size <= buf->y_size);
ok &= (u_size <= buf->u_size);
ok &= (v_size <= buf->v_size);
ok &= (y_stride >= width);
ok &= (u_stride >= (width + 1) / 2);
ok &= (v_stride >= (width + 1) / 2);
ok &= (buf->y != NULL);
ok &= (buf->u != NULL);
ok &= (buf->v != NULL);
if (mode == MODE_YUVA) {
ok &= (a_stride >= width);
ok &= (a_size <= buf->a_size);
ok &= (buf->a != NULL);
}
} else { // RGB checks
const WebPRGBABuffer* const buf = &buffer->u.RGBA;
const int stride = abs(buf->stride);
const uint64_t size = (uint64_t)stride * height;
ok &= (size <= buf->size);
ok &= (stride >= width * kModeBpp[mode]);
ok &= (buf->rgba != NULL);
}
return ok ? VP8_STATUS_OK : VP8_STATUS_INVALID_PARAM;
}
static VP8StatusCode AllocateBuffer(WebPDecBuffer* const buffer) {
const int w = buffer->width;
const int h = buffer->height;
const WEBP_CSP_MODE mode = buffer->colorspace;
if (w <= 0 || h <= 0 || !IsValidColorspace(mode)) {
return VP8_STATUS_INVALID_PARAM;
}
if (!buffer->is_external_memory && buffer->private_memory == NULL) {
uint8_t* output;
int uv_stride = 0, a_stride = 0;
uint64_t uv_size = 0, a_size = 0, total_size;
// We need memory and it hasn't been allocated yet.
// => initialize output buffer, now that dimensions are known.
const int stride = w * kModeBpp[mode];
const uint64_t size = (uint64_t)stride * h;
if (!WebPIsRGBMode(mode)) {
uv_stride = (w + 1) / 2;
uv_size = (uint64_t)uv_stride * ((h + 1) / 2);
if (mode == MODE_YUVA) {
a_stride = w;
a_size = (uint64_t)a_stride * h;
}
}
total_size = size + 2 * uv_size + a_size;
// Security/sanity checks
output = (uint8_t*)WebPSafeMalloc(total_size, sizeof(*output));
if (output == NULL) {
return VP8_STATUS_OUT_OF_MEMORY;
}
buffer->private_memory = output;
if (!WebPIsRGBMode(mode)) { // YUVA initialization
WebPYUVABuffer* const buf = &buffer->u.YUVA;
buf->y = output;
buf->y_stride = stride;
buf->y_size = (size_t)size;
buf->u = output + size;
buf->u_stride = uv_stride;
buf->u_size = (size_t)uv_size;
buf->v = output + size + uv_size;
buf->v_stride = uv_stride;
buf->v_size = (size_t)uv_size;
if (mode == MODE_YUVA) {
buf->a = output + size + 2 * uv_size;
}
buf->a_size = (size_t)a_size;
buf->a_stride = a_stride;
} else { // RGBA initialization
WebPRGBABuffer* const buf = &buffer->u.RGBA;
buf->rgba = output;
buf->stride = stride;
buf->size = (size_t)size;
}
}
return CheckDecBuffer(buffer);
}
VP8StatusCode WebPFlipBuffer(WebPDecBuffer* const buffer) {
if (buffer == NULL) {
return VP8_STATUS_INVALID_PARAM;
}
if (WebPIsRGBMode(buffer->colorspace)) {
WebPRGBABuffer* const buf = &buffer->u.RGBA;
buf->rgba += (buffer->height - 1) * buf->stride;
buf->stride = -buf->stride;
} else {
WebPYUVABuffer* const buf = &buffer->u.YUVA;
const int H = buffer->height;
buf->y += (H - 1) * buf->y_stride;
buf->y_stride = -buf->y_stride;
buf->u += ((H - 1) >> 1) * buf->u_stride;
buf->u_stride = -buf->u_stride;
buf->v += ((H - 1) >> 1) * buf->v_stride;
buf->v_stride = -buf->v_stride;
if (buf->a != NULL) {
buf->a += (H - 1) * buf->a_stride;
buf->a_stride = -buf->a_stride;
}
}
return VP8_STATUS_OK;
}
VP8StatusCode WebPAllocateDecBuffer(int w, int h,
const WebPDecoderOptions* const options,
WebPDecBuffer* const out) {
VP8StatusCode status;
if (out == NULL || w <= 0 || h <= 0) {
return VP8_STATUS_INVALID_PARAM;
}
if (options != NULL) { // First, apply options if there is any.
if (options->use_cropping) {
const int cw = options->crop_width;
const int ch = options->crop_height;
const int x = options->crop_left & ~1;
const int y = options->crop_top & ~1;
if (x < 0 || y < 0 || cw <= 0 || ch <= 0 || x + cw > w || y + ch > h) {
return VP8_STATUS_INVALID_PARAM; // out of frame boundary.
}
w = cw;
h = ch;
}
if (options->use_scaling) {
if (options->scaled_width <= 0 || options->scaled_height <= 0) {
return VP8_STATUS_INVALID_PARAM;
}
w = options->scaled_width;
h = options->scaled_height;
}
}
out->width = w;
out->height = h;
// Then, allocate buffer for real.
status = AllocateBuffer(out);
if (status != VP8_STATUS_OK) return status;
#if WEBP_DECODER_ABI_VERSION > 0x0203
// Use the stride trick if vertical flip is needed.
if (options != NULL && options->flip) {
status = WebPFlipBuffer(out);
}
#endif
return status;
}
//------------------------------------------------------------------------------
// constructors / destructors
int WebPInitDecBufferInternal(WebPDecBuffer* buffer, int version) {
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DECODER_ABI_VERSION)) {
return 0; // version mismatch
}
if (buffer == NULL) return 0;
memset(buffer, 0, sizeof(*buffer));
return 1;
}
void WebPFreeDecBuffer(WebPDecBuffer* buffer) {
if (buffer != NULL) {
if (!buffer->is_external_memory) {
WebPSafeFree(buffer->private_memory);
}
buffer->private_memory = NULL;
}
}
void WebPCopyDecBuffer(const WebPDecBuffer* const src,
WebPDecBuffer* const dst) {
if (src != NULL && dst != NULL) {
*dst = *src;
if (src->private_memory != NULL) {
dst->is_external_memory = 1;