Skip to content

Commit a1e815e

Browse files
authored
Merge pull request #8651 from unknownbrackets/android-clang
Switch Android build to using clang (needs buildbot update)
2 parents 2251c9c + e269a80 commit a1e815e

File tree

10 files changed

+70
-17
lines changed

10 files changed

+70
-17
lines changed

.travis.sh

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22

33
export USE_CCACHE=1
44
export NDK_CCACHE=ccache
5-
NDK_VER=android-ndk-r10d
5+
NDK_VER=android-ndk-r12b
66

77
download_extract() {
88
aria2c -x 16 $1 -o $2
99
tar -xf $2
1010
}
1111

1212
# This is used for the Android NDK.
13-
download_extract_xz() {
13+
download_extract_zip() {
1414
aria2c --file-allocation=none --timeout=120 --retry-wait=5 --max-tries=20 -Z -c $1 -o $2
15-
stat -c 'ATTEMPT 1 - %s' $2
16-
md5sum $2
1715
# This resumes the download, in case it failed.
1816
aria2c --file-allocation=none --timeout=120 --retry-wait=5 --max-tries=20 -Z -c $1 -o $2
19-
stat -c 'ATTEMPT 2 - %s' $2
20-
md5sum $2
2117

22-
# Keep some output going during the extract, so the build doesn't timeout.
23-
pv $2 | xz -vd | tar -x
18+
unzip $2 2>&1 | pv > /dev/null
2419
}
2520

2621
travis_before_install() {
@@ -73,7 +68,7 @@ travis_install() {
7368
if [ "$PPSSPP_BUILD_TYPE" = "Android" ]; then
7469
free -m
7570
sudo apt-get install ant -qq
76-
download_extract_xz http://hdkr.co/${NDK_VER}-x86_64.tar.xz ${NDK_VER}-x86_64.tar.xz
71+
download_extract_zip http://dl.google.com/android/repository/${NDK_VER}-linux-x86_64.zip ${NDK_VER}-linux-x86_64.zip
7772
fi
7873

7974
# Blackberry NDK: 10.3.0.440 + GCC: 4.8.2

Common/GL/GLInterface/EGLAndroid.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under GPLv2+
33
// Refer to the license.txt file included.
44

5+
#include <android/native_window.h>
56
#include "Common/Log.h"
67
#include "Common/GL/GLInterface/EGLAndroid.h"
78

Core/HLE/sceAtrac.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,13 @@ struct Atrac {
457457
avcodec_close(codecCtx_);
458458
av_freep(&codecCtx_);
459459
#endif
460+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
461+
av_packet_free(&packet_);
462+
#else
460463
av_free_packet(packet_);
461464
delete packet_;
462465
packet_ = nullptr;
466+
#endif
463467
}
464468
#endif // USE_FFMPEG
465469

@@ -552,7 +556,11 @@ struct Atrac {
552556

553557
int got_frame = 0;
554558
int bytes_read = avcodec_decode_audio4(codecCtx_, frame_, &got_frame, packet_);
559+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
560+
av_packet_unref(packet_);
561+
#else
555562
av_free_packet(packet_);
563+
#endif
556564
if (bytes_read == AVERROR_PATCHWELCOME) {
557565
ERROR_LOG(ME, "Unsupported feature in ATRAC audio.");
558566
// Let's try the next packet.
@@ -1836,10 +1844,14 @@ int __AtracSetContext(Atrac *atrac) {
18361844

18371845
// alloc audio frame
18381846
atrac->frame_ = av_frame_alloc();
1847+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
1848+
atrac->packet_ = av_packet_alloc();
1849+
#else
18391850
atrac->packet_ = new AVPacket;
18401851
av_init_packet(atrac->packet_);
18411852
atrac->packet_->data = nullptr;
18421853
atrac->packet_->size = 0;
1854+
#endif
18431855
// reinit decodePos, because ffmpeg had changed it.
18441856
atrac->decodePos_ = 0;
18451857
#endif

Core/HLE/sceMpeg.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static bool pmp_oldStateLoaded = false; // for dostate
9999

100100
extern "C" {
101101
#include "libavformat/avformat.h"
102+
#include "libavutil/imgutils.h"
102103
#include "libswscale/swscale.h"
103104
}
104105
static AVPixelFormat pmp_want_pix_fmt;
@@ -801,7 +802,11 @@ static bool InitPmp(MpegContext * ctx){
801802
}
802803

803804
// get RGBA picture buffer
805+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
806+
mediaengine->m_bufSize = av_image_get_buffer_size(pmp_want_pix_fmt, pmp_CodecCtx->width, pmp_CodecCtx->height, 1);
807+
#else
804808
mediaengine->m_bufSize = avpicture_get_size(pmp_want_pix_fmt, pmp_CodecCtx->width, pmp_CodecCtx->height);
809+
#endif
805810
mediaengine->m_buffer = (u8*)av_malloc(mediaengine->m_bufSize);
806811

807812
return true;
@@ -947,7 +952,12 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
947952
av_frame_unref(pFrameRGB);
948953

949954
// hook pFrameRGB output to buffer
955+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
956+
av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, mediaengine->m_buffer, pmp_want_pix_fmt, pCodecCtx->width, pCodecCtx->height, 1);
957+
#else
950958
avpicture_fill((AVPicture *)pFrameRGB, mediaengine->m_buffer, pmp_want_pix_fmt, pCodecCtx->width, pCodecCtx->height);
959+
#endif
960+
951961

952962
// decode video frame
953963
int len = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, &packet);
@@ -992,7 +1002,11 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
9921002
// SaveFrame(pNewFrameRGB, pCodecCtx->width, pCodecCtx->height);
9931003
}
9941004
// free some pointers
1005+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
1006+
av_packet_unref(&packet);
1007+
#else
9951008
av_free_packet(&packet);
1009+
#endif
9961010
pmpframes->~H264Frames();
9971011
// must reset pmp_VideoSource address to zero after decoding.
9981012
pmp_videoSource = 0;

Core/HW/MediaEngine.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ extern "C" {
3434

3535
#include "libavcodec/avcodec.h"
3636
#include "libavformat/avformat.h"
37+
#include "libavutil/imgutils.h"
3738
#include "libswscale/swscale.h"
3839

3940
}
@@ -449,11 +450,19 @@ bool MediaEngine::setVideoDim(int width, int height)
449450

450451
// Allocate video frame for RGB24
451452
m_pFrameRGB = av_frame_alloc();
453+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
454+
int numBytes = av_image_get_buffer_size((AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight, 1);
455+
#else
452456
int numBytes = avpicture_get_size((AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight);
457+
#endif
453458
m_buffer = (u8*)av_malloc(numBytes * sizeof(uint8_t));
454459

455460
// Assign appropriate parts of buffer to image planes in m_pFrameRGB
461+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
462+
av_image_fill_arrays(m_pFrameRGB->data, m_pFrameRGB->linesize, m_buffer, (AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight, 1);
463+
#else
456464
avpicture_fill((AVPicture *)m_pFrameRGB, m_buffer, (AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight);
465+
#endif
457466
#endif // USE_FFMPEG
458467
return true;
459468
}
@@ -522,8 +531,13 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
522531
// Still need to decode those, so keep calling avcodec_decode_video2().
523532
if (dataEnd || packet.stream_index == m_videoStream) {
524533
// avcodec_decode_video2() gives us the re-ordered frames with a NULL packet.
534+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
535+
if (dataEnd)
536+
av_packet_unref(&packet);
537+
#else
525538
if (dataEnd)
526539
av_free_packet(&packet);
540+
#endif
527541

528542
int result = avcodec_decode_video2(m_pCodecCtx, m_pFrame, &frameFinished, &packet);
529543
if (frameFinished) {
@@ -547,7 +561,11 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
547561
break;
548562
}
549563
}
564+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
565+
av_packet_unref(&packet);
566+
#else
550567
av_free_packet(&packet);
568+
#endif
551569
}
552570
return bGetFrame;
553571
#else

Core/HW/SimpleAudioDec.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,16 @@ bool SimpleAudio::Decode(void *inbuf, int inbytes, uint8_t *outbuf, int *outbyte
186186
*outbytes = 0;
187187
srcPos = 0;
188188
int len = avcodec_decode_audio4(codecCtx_, frame_, &got_frame, &packet);
189+
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
190+
av_packet_unref(&packet);
191+
#else
192+
av_free_packet(&packet);
193+
#endif
194+
189195
if (len < 0) {
190196
ERROR_LOG(ME, "Error decoding Audio frame (%i bytes): %i (%08x)", inbytes, len, len);
191-
// TODO: cleanup
192197
return false;
193198
}
194-
av_free_packet(&packet);
195199

196200
// get bytes consumed in source
197201
srcPos = len;

android/jni/Application.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ APP_STL := gnustl_static
22
APP_PLATFORM := android-9
33
APP_ABI := arm64-v8a armeabi-v7a x86 x86_64
44
APP_GNUSTL_CPP_FEATURES :=
5-
NDK_TOOLCHAIN_VERSION := 4.9
5+
NDK_TOOLCHAIN_VERSION := clang

android/jni/Locals.mk

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# These are definitions for LOCAL_ variables for PPSSPP.
22
# They are shared between ppsspp_jni (lib for Android app) and ppsspp_headless.
33

4-
LOCAL_CFLAGS := -DUSE_FFMPEG -DUSING_GLES2 -DMOBILE_DEVICE -O3 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -D__STDC_CONSTANT_MACROS -Wno-format
4+
LOCAL_CFLAGS := -DUSE_FFMPEG -DUSING_GLES2 -DMOBILE_DEVICE -O3 -fsigned-char -Wall -Wno-multichar -Wno-unused-variable -fno-strict-aliasing -D__STDC_CONSTANT_MACROS -Wno-format
55
# yes, it's really CPPFLAGS for C++
6-
# literal-suffix is generated by Android default code and causes noise.
7-
LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -fno-rtti -Wno-reorder -Wno-literal-suffix -Wno-format
6+
# deprecated-register is generated by Android default code and causes noise.
7+
LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -fno-rtti -Wno-reorder -Wno-format -Wno-deprecated-register
88
LOCAL_C_INCLUDES := \
99
$(LOCAL_PATH)/../../Common \
1010
$(LOCAL_PATH)/../.. \
@@ -16,7 +16,14 @@ LOCAL_C_INCLUDES := \
1616
$(LOCAL_PATH)
1717

1818
LOCAL_STATIC_LIBRARIES := native libzip glslang
19-
LOCAL_LDLIBS := -lz -landroid -lGLESv2 -lOpenSLES -lEGL -ldl -llog
19+
LOCAL_LDLIBS := -lz -landroid -lGLESv2 -lOpenSLES -lEGL -ldl -llog -latomic
20+
ifneq ($(NDK_DEBUG),1)
21+
# Prettier stack traces are nice on other platforms.
22+
# Maybe we can switch to storing the pre-stripped builds at some point.
23+
ifeq ($(TARGET_ARCH_ABI),x86_64)
24+
LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--exclude-libs,ALL
25+
endif
26+
endif
2027

2128
# ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
2229
ifeq ($(findstring armeabi-v7a,$(TARGET_ARCH_ABI)),armeabi-v7a)

ext/native/gfx/gl_common.h

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef void (EGLAPIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (
5959
#endif
6060
extern PFNGLBLITFRAMEBUFFERNVPROC glBlitFramebufferNV;
6161

62+
#ifdef IOS
6263
extern PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
6364
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
6465
extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES;
@@ -70,6 +71,7 @@ extern PFNGLISVERTEXARRAYOESPROC glIsVertexArrayOES;
7071
#define glBindVertexArray glBindVertexArrayOES
7172
#define glDeleteVertexArrays glDeleteVertexArraysOES
7273
#define glIsVertexArray glIsVertexArrayOES
74+
#endif
7375

7476
#endif
7577

ffmpeg

Submodule ffmpeg updated 2846 files

0 commit comments

Comments
 (0)