Format *_jni.cc files

PiperOrigin-RevId: 374830877
This commit is contained in:
olly 2021-05-20 11:00:13 +01:00 committed by Oliver Woodman
parent 9e4315f48d
commit 0de6bc861a
4 changed files with 86 additions and 89 deletions

View File

@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <android/log.h>
#include <jni.h>
#include <stdlib.h>
#include <android/log.h>
extern "C" {
#ifdef __cplusplus
@ -33,8 +33,8 @@ extern "C" {
}
#define LOG_TAG "ffmpeg_jni"
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
__VA_ARGS__))
#define LOGE(...) \
((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \
extern "C" { \
@ -362,4 +362,3 @@ void releaseContext(AVCodecContext *context) {
}
avcodec_free_context(&context);
}

View File

@ -32,8 +32,9 @@
#define DECODER_FUNC(RETURN_TYPE, NAME, ...) \
extern "C" { \
JNIEXPORT RETURN_TYPE \
Java_com_google_android_exoplayer2_ext_flac_FlacDecoderJni_##NAME( \
JNIEnv *env, jobject thiz, ##__VA_ARGS__); \
Java_com_google_android_exoplayer2_ext_flac_FlacDecoderJni_##NAME(JNIEnv *env, \
jobject thiz, \
##__VA_ARGS__); \
} \
JNIEXPORT RETURN_TYPE \
Java_com_google_android_exoplayer2_ext_flac_FlacDecoderJni_##NAME( \

View File

@ -14,9 +14,8 @@
* limitations under the License.
*/
#include <jni.h>
#include <android/log.h>
#include <jni.h>
#include <cstdlib>
@ -24,28 +23,28 @@
#include "opus_multistream.h" // NOLINT
#define LOG_TAG "opus_jni"
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
__VA_ARGS__))
#define LOGE(...) \
((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#define DECODER_FUNC(RETURN_TYPE, NAME, ...) \
extern "C" { \
JNIEXPORT RETURN_TYPE \
Java_com_google_android_exoplayer2_ext_opus_OpusDecoder_ ## NAME \
(JNIEnv* env, jobject thiz, ##__VA_ARGS__);\
Java_com_google_android_exoplayer2_ext_opus_OpusDecoder_##NAME( \
JNIEnv* env, jobject thiz, ##__VA_ARGS__); \
} \
JNIEXPORT RETURN_TYPE \
Java_com_google_android_exoplayer2_ext_opus_OpusDecoder_ ## NAME \
(JNIEnv* env, jobject thiz, ##__VA_ARGS__)\
Java_com_google_android_exoplayer2_ext_opus_OpusDecoder_##NAME( \
JNIEnv* env, jobject thiz, ##__VA_ARGS__)
#define LIBRARY_FUNC(RETURN_TYPE, NAME, ...) \
extern "C" { \
JNIEXPORT RETURN_TYPE \
Java_com_google_android_exoplayer2_ext_opus_OpusLibrary_ ## NAME \
(JNIEnv* env, jobject thiz, ##__VA_ARGS__);\
Java_com_google_android_exoplayer2_ext_opus_OpusLibrary_##NAME( \
JNIEnv* env, jobject thiz, ##__VA_ARGS__); \
} \
JNIEXPORT RETURN_TYPE \
Java_com_google_android_exoplayer2_ext_opus_OpusLibrary_ ## NAME \
(JNIEnv* env, jobject thiz, ##__VA_ARGS__)\
Java_com_google_android_exoplayer2_ext_opus_OpusLibrary_##NAME( \
JNIEnv* env, jobject thiz, ##__VA_ARGS__)
// JNI references for SimpleOutputBuffer class.
static jmethodID outputBufferInit;
@ -66,7 +65,8 @@ static int errorCode;
static bool outputFloat = false;
DECODER_FUNC(jlong, opusInit, jint sampleRate, jint channelCount,
jint numStreams, jint numCoupled, jint gain, jbyteArray jStreamMap) {
jint numStreams, jint numCoupled, jint gain,
jbyteArray jStreamMap) {
int status = OPUS_INVALID_STATE;
::channelCount = channelCount;
errorCode = 0;
@ -88,8 +88,8 @@ DECODER_FUNC(jlong, opusInit, jint sampleRate, jint channelCount,
// Populate JNI References.
const jclass outputBufferClass = env->FindClass(
"com/google/android/exoplayer2/decoder/SimpleOutputBuffer");
outputBufferInit = env->GetMethodID(outputBufferClass, "init",
"(JI)Ljava/nio/ByteBuffer;");
outputBufferInit =
env->GetMethodID(outputBufferClass, "init", "(JI)Ljava/nio/ByteBuffer;");
return reinterpret_cast<intptr_t>(decoder);
}
@ -97,12 +97,11 @@ DECODER_FUNC(jlong, opusInit, jint sampleRate, jint channelCount,
DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
jobject jInputBuffer, jint inputSize, jobject jOutputBuffer) {
OpusMSDecoder* decoder = reinterpret_cast<OpusMSDecoder*>(jDecoder);
const uint8_t* inputBuffer =
reinterpret_cast<const uint8_t*>(
const uint8_t* inputBuffer = reinterpret_cast<const uint8_t*>(
env->GetDirectBufferAddress(jInputBuffer));
const int byteSizePerSample = outputFloat ?
kBytesPerFloatSample : kBytesPerIntPcmSample;
const int byteSizePerSample =
outputFloat ? kBytesPerFloatSample : kBytesPerIntPcmSample;
const jint outputSize =
kMaxOpusOutputPacketSizeSamples * byteSizePerSample * channelCount;
@ -111,8 +110,8 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
// Exception is thrown in Java when returning from the native call.
return -1;
}
const jobject jOutputBufferData = env->CallObjectMethod(jOutputBuffer,
outputBufferInit, jTimeUs, outputSize);
const jobject jOutputBufferData = env->CallObjectMethod(
jOutputBuffer, outputBufferInit, jTimeUs, outputSize);
if (env->ExceptionCheck()) {
// Exception is thrown in Java when returning from the native call.
return -1;
@ -122,13 +121,15 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
if (outputFloat) {
float* outputBufferData = reinterpret_cast<float*>(
env->GetDirectBufferAddress(jOutputBufferData));
sampleCount = opus_multistream_decode_float(decoder, inputBuffer, inputSize,
outputBufferData, kMaxOpusOutputPacketSizeSamples, 0);
sampleCount = opus_multistream_decode_float(
decoder, inputBuffer, inputSize, outputBufferData,
kMaxOpusOutputPacketSizeSamples, 0);
} else {
int16_t* outputBufferData = reinterpret_cast<int16_t*>(
env->GetDirectBufferAddress(jOutputBufferData));
sampleCount = opus_multistream_decode(decoder, inputBuffer, inputSize,
outputBufferData, kMaxOpusOutputPacketSizeSamples, 0);
outputBufferData,
kMaxOpusOutputPacketSizeSamples, 0);
}
// record error code
@ -139,9 +140,9 @@ DECODER_FUNC(jint, opusDecode, jlong jDecoder, jlong jTimeUs,
DECODER_FUNC(jint, opusSecureDecode, jlong jDecoder, jlong jTimeUs,
jobject jInputBuffer, jint inputSize, jobject jOutputBuffer,
jint sampleRate, jobject mediaCrypto, jint inputMode, jbyteArray key,
jbyteArray javaIv, jint inputNumSubSamples, jintArray numBytesOfClearData,
jintArray numBytesOfEncryptedData) {
jint sampleRate, jobject mediaCrypto, jint inputMode,
jbyteArray key, jbyteArray javaIv, jint inputNumSubSamples,
jintArray numBytesOfClearData, jintArray numBytesOfEncryptedData) {
// Doesn't support
// Java client should have checked vpxSupportSecureDecode
// and avoid calling this
@ -163,13 +164,9 @@ DECODER_FUNC(jstring, opusGetErrorMessage, jlong jContext) {
return env->NewStringUTF(opus_strerror(errorCode));
}
DECODER_FUNC(jint, opusGetErrorCode, jlong jContext) {
return errorCode;
}
DECODER_FUNC(jint, opusGetErrorCode, jlong jContext) { return errorCode; }
DECODER_FUNC(void, opusSetFloatOutput) {
outputFloat = true;
}
DECODER_FUNC(void, opusSetFloatOutput) { outputFloat = true; }
LIBRARY_FUNC(jstring, opusIsSecureDecodeSupported) {
// Doesn't support

View File

@ -18,12 +18,12 @@
#ifdef __ARM_NEON__
#include <arm_neon.h>
#endif
#include <jni.h>
#include <android/log.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include <jni.h>
#include <pthread.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
@ -31,12 +31,12 @@
#include <new>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vpx_decoder.h"
#include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h"
#define LOG_TAG "vpx_jni"
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, \
__VA_ARGS__))
#define LOGE(...) \
((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
#define DECODER_FUNC(RETURN_TYPE, NAME, ...) \
extern "C" { \
@ -480,12 +480,12 @@ DECODER_FUNC(jlong, vpxInit, jboolean disableLoopFilter,
// Populate JNI References.
const jclass outputBufferClass = env->FindClass(
"com/google/android/exoplayer2/video/VideoDecoderOutputBuffer");
initForYuvFrame = env->GetMethodID(outputBufferClass, "initForYuvFrame",
"(IIIII)Z");
initForYuvFrame =
env->GetMethodID(outputBufferClass, "initForYuvFrame", "(IIIII)Z");
initForPrivateFrame =
env->GetMethodID(outputBufferClass, "initForPrivateFrame", "(II)V");
dataField = env->GetFieldID(outputBufferClass, "data",
"Ljava/nio/ByteBuffer;");
dataField =
env->GetFieldID(outputBufferClass, "data", "Ljava/nio/ByteBuffer;");
outputModeField = env->GetFieldID(outputBufferClass, "mode", "I");
decoderPrivateField =
env->GetFieldID(outputBufferClass, "decoderPrivate", "I");