Skip to content

Commit

Permalink
Update to 8.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Feb 1, 2022
1 parent f0f858a commit ad05eea
Show file tree
Hide file tree
Showing 159 changed files with 5,905 additions and 3,027 deletions.
4 changes: 2 additions & 2 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ android {
}
}

defaultConfig.versionCode = 2538
defaultConfig.versionCode = 2547

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand All @@ -319,7 +319,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 30
versionName "8.4.4"
versionName "8.5.0"

vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

Expand Down
13 changes: 7 additions & 6 deletions TMessagesProj/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavcodec.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavresample.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libavutil.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libswresample.a,
${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libvpx.a,
${CMAKE_HOME_DIRECTORY}/boringssl/lib/libssl_${ANDROID_ABI}.a,
${CMAKE_HOME_DIRECTORY}/boringssl/lib/libcrypto_${ANDROID_ABI}.a")

Expand Down Expand Up @@ -45,6 +46,10 @@ set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY
add_library(ssl STATIC IMPORTED)
set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/boringssl/lib/libssl_${ANDROID_ABI}.a)

add_library(libvpx STATIC IMPORTED)
set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/ffmpeg/${ANDROID_ABI}/libvpx.a)


#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
Expand Down Expand Up @@ -399,7 +404,7 @@ target_compile_definitions(sqlite PUBLIC
#voip
include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt)

set(NATIVE_LIB "tmessages.40")
set(NATIVE_LIB "tmessages.41")

#tmessages
add_library(${NATIVE_LIB} SHARED
Expand Down Expand Up @@ -685,6 +690,7 @@ target_link_libraries(${NATIVE_LIB}
avcodec
avresample
swresample
libvpx
avutil
ssl
crypto
Expand All @@ -697,11 +703,6 @@ target_link_libraries(${NATIVE_LIB}
OpenSLES
cpufeatures)

if (${ANDROID_ABI} STREQUAL "x86" OR ${ANDROID_ABI} STREQUAL "x86_64")
target_link_libraries(${NATIVE_LIB}
-Wl,--whole-archive libvpx_yasm -Wl,--no-whole-archive)
endif()

#if (${ANDROID_ABI} STREQUAL "x86" OR ${ANDROID_ABI} STREQUAL "x86_64")
# target_link_libraries(${NATIVE_LIB}
# -Wl,--whole-archive vpxasm -Wl,--no-whole-archive
Expand Down
Binary file modified TMessagesProj/jni/ffmpeg/arm64-v8a/libavcodec.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/arm64-v8a/libavformat.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/arm64-v8a/libavresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/arm64-v8a/libavutil.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/arm64-v8a/libswresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/arm64-v8a/libswscale.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/armeabi-v7a/libavcodec.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/armeabi-v7a/libavformat.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/armeabi-v7a/libavresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/armeabi-v7a/libavutil.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/armeabi-v7a/libswresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/armeabi-v7a/libswscale.a
Binary file not shown.
1 change: 1 addition & 0 deletions TMessagesProj/jni/ffmpeg/include/libavutil/mathematics.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
*
* The operation is mathematically equivalent to `a * b / c`, but writing that
* directly can overflow, and does not support different rounding methods.
* If the result is not representable then INT64_MIN is returned.
*
* @see av_rescale(), av_rescale_q(), av_rescale_q_rnd()
*/
Expand Down
Binary file modified TMessagesProj/jni/ffmpeg/x86/libavcodec.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86/libavformat.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86/libavresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86/libavutil.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86/libswresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86/libswscale.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86_64/libavcodec.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86_64/libavformat.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86_64/libavresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86_64/libavutil.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86_64/libswresample.a
Binary file not shown.
Binary file modified TMessagesProj/jni/ffmpeg/x86_64/libswscale.a
Binary file not shown.
60 changes: 44 additions & 16 deletions TMessagesProj/jni/gifvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ extern "C" {
#include <libavformat/isom.h>
#include <libavcodec/bytestream.h>
#include <libavcodec/get_bits.h>
#include <libavcodec/golomb.h>
#include <libavcodec/golomb.h>
#include <libavutil/eval.h>
#include <libavutil/intmath.h>
#include <libswscale/swscale.h>
}


#define RGB8888_A(p) ((p & (0xff<<24)) >> 24 )

static const std::string av_make_error_str(int errnum) {
char errbuf[AV_ERROR_MAX_STRING_SIZE];
av_strerror(errnum, errbuf, AV_ERROR_MAX_STRING_SIZE);
return (std::string) errbuf;
}

#undef av_err2str
#define av_err2str(errnum) av_make_error_str(errnum).c_str()
#define FFMPEG_AVSEEK_SIZE 0x10000
Expand Down Expand Up @@ -89,7 +91,7 @@ void ff_h2645_packet_uninit(H2645Packet *pkt) {
}

typedef struct VideoInfo {

~VideoInfo() {
if (video_dec_ctx) {
avcodec_close(video_dec_ctx);
Expand Down Expand Up @@ -194,6 +196,18 @@ void custom_log(void *ptr, int level, const char* fmt, va_list vl){
LOGE(line);
}

static enum AVPixelFormat get_format(AVCodecContext *ctx,
const enum AVPixelFormat *pix_fmts)
{
const enum AVPixelFormat *p;

for (p = pix_fmts; *p != -1; p++) {
LOGE("available format %d", p);
}

return pix_fmts[0];
}

int open_codec_context(int *stream_idx, AVCodecContext **dec_ctx, AVFormatContext *fmt_ctx, enum AVMediaType type) {
int ret, stream_index;
AVStream *st;
Expand Down Expand Up @@ -683,7 +697,7 @@ int ff_h264_decode_seq_parameter_set(GetBitContext *gb, int &width, int &height)
}
return mb_width != width || mb_height != height;
}

int decode_packet(VideoInfo *info, int *got_frame) {
int ret = 0;
int decoded = info->pkt.size;
Expand All @@ -709,7 +723,7 @@ int decode_packet(VideoInfo *info, int *got_frame) {
}
}
}

return decoded;
}

Expand Down Expand Up @@ -921,7 +935,7 @@ extern "C" JNIEXPORT void JNICALL Java_org_telegram_ui_Components_AnimatedFileDr

extern "C" JNIEXPORT jlong JNICALL Java_org_telegram_ui_Components_AnimatedFileDrawable_createDecoder(JNIEnv *env, jclass clazz, jstring src, jintArray data, jint account, jlong streamFileSize, jobject stream, jboolean preview) {
VideoInfo *info = new VideoInfo();

char const *srcString = env->GetStringUTFChars(src, 0);
size_t len = strlen(srcString);
info->src = new char[len + 1];
Expand Down Expand Up @@ -968,13 +982,13 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_telegram_ui_Components_AnimatedFileD
return 0;
}
}

if ((ret = avformat_find_stream_info(info->fmt_ctx, NULL)) < 0) {
LOGE("can't find stream information %s, %s", info->src, av_err2str(ret));
delete info;
return 0;
}

if (open_codec_context(&info->video_stream_idx, &info->video_dec_ctx, info->fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) {
info->video_stream = info->fmt_ctx->streams[info->video_stream_idx];
}
Expand All @@ -984,14 +998,14 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_telegram_ui_Components_AnimatedFileD
delete info;
return 0;
}

info->frame = av_frame_alloc();
if (info->frame == nullptr) {
LOGE("can't allocate frame %s", info->src);
delete info;
return 0;
}

av_init_packet(&info->pkt);
info->pkt.data = NULL;
info->pkt.size = 0;
Expand All @@ -1015,9 +1029,9 @@ extern "C" JNIEXPORT jlong JNICALL Java_org_telegram_ui_Components_AnimatedFileD
//(int32_t) (1000 * info->video_stream->duration * av_q2d(info->video_stream->time_base));
env->ReleaseIntArrayElements(data, dataArr, 0);
}

//LOGD("successfully opened file %s", info->src);

return (jlong) (intptr_t) info;
}

Expand Down Expand Up @@ -1166,7 +1180,9 @@ static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray da
}
}
if (info->sws_ctx == nullptr || ((intptr_t) pixels) % 16 != 0) {
if (info->frame->format == AV_PIX_FMT_YUV444P) {
if (info->frame->format == AV_PIX_FMT_YUVA420P) {
libyuv::I420AlphaToARGBMatrix(info->frame->data[0], info->frame->linesize[0], info->frame->data[2], info->frame->linesize[2], info->frame->data[1], info->frame->linesize[1], info->frame->data[3], info->frame->linesize[3], (uint8_t *) pixels, bitmapWidth * 4, &libyuv::kYvuI601Constants, bitmapWidth, bitmapHeight, 50);
} else if (info->frame->format == AV_PIX_FMT_YUV444P) {
libyuv::H444ToARGB(info->frame->data[0], info->frame->linesize[0], info->frame->data[2], info->frame->linesize[2], info->frame->data[1], info->frame->linesize[1], (uint8_t *) pixels, bitmapWidth * 4, bitmapWidth, bitmapHeight);
} else if (info->frame->format == AV_PIX_FMT_YUV420P || info->frame->format == AV_PIX_FMT_YUVJ420P) {
if (info->frame->colorspace == AVColorSpace::AVCOL_SPC_BT709) {
Expand All @@ -1181,7 +1197,19 @@ static inline void writeFrameToBitmap(JNIEnv *env, VideoInfo *info, jintArray da
uint8_t __attribute__ ((aligned (16))) *dst_data[1];
dst_data[0] = (uint8_t *) pixels;
info->dst_linesize[0] = stride;
sws_scale(info->sws_ctx, info->frame->data, info->frame->linesize, 0, info->frame->height, dst_data, info->dst_linesize);
sws_scale(info->sws_ctx, info->frame->data, info->frame->linesize, 0,
info->frame->height, dst_data, info->dst_linesize);
if (info->frame->format == AV_PIX_FMT_YUVA420P) {
auto pixelArr = ((uint32_t *) pixels);
for (int i = 0; i < bitmapWidth; i++) {
for (int j = 0; j < bitmapHeight; j++) {
int a = RGB8888_A(pixelArr[j * bitmapWidth + i]);
if (a < 125) {
pixelArr[j * bitmapWidth + i] = 0;
}
}
}
}
}
}
AndroidBitmap_unlockPixels(env, bitmap);
Expand Down Expand Up @@ -1337,7 +1365,7 @@ extern "C" JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_AnimatedFileDr
}
if (got_frame) {
//LOGD("decoded frame with w = %d, h = %d, format = %d", info->frame->width, info->frame->height, info->frame->format);
if (info->frame->format == AV_PIX_FMT_YUV420P || info->frame->format == AV_PIX_FMT_BGRA || info->frame->format == AV_PIX_FMT_YUVJ420P || info->frame->format == AV_PIX_FMT_YUV444P) {
if (info->frame->format == AV_PIX_FMT_YUV420P || info->frame->format == AV_PIX_FMT_BGRA || info->frame->format == AV_PIX_FMT_YUVJ420P || info->frame->format == AV_PIX_FMT_YUV444P || info->frame->format == AV_PIX_FMT_YUVA420P) {
writeFrameToBitmap(env, info, data, bitmap, stride);
}
info->has_decoded_frames = true;
Expand Down

1 comment on commit ad05eea

@zjns
Copy link

@zjns zjns commented on ad05eea Feb 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about this, but "ffmpeg/${ANDROID_ABI}/libvpx.a" static binary file is missing, can not pass compiling.

Please sign in to comment.