Skip to content

Commit

Permalink
Testing build with libvpx include.
Browse files Browse the repository at this point in the history
Change-Id: I7a8f18de08ebdee6e1efde6e8d910583c9c1f875
  • Loading branch information
avesus committed May 16, 2014
1 parent f77a381 commit 355bf64
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ win/Win32
ios/libvpx/libvpx.a
ios/libvpx/libvpx_g.a
BuildConfig.java
/android/gen/com/aeonsoftech/guruchat/R.java
14 changes: 4 additions & 10 deletions android/.cproject
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>

<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<?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.976037261.259940810">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.android.toolchain.gcc.976037261.259940810" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<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"/>
<extension id="org.eclipse.cdt.autotools.core.ErrorParser" 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">
Expand All @@ -35,7 +32,6 @@
</tool>
</toolChain>
</folderInfo>
<fileInfo id="com.android.toolchain.gcc.976037261.259940810.283244380" name="libs-armv5te-android-gcc.mk" rcbsApplicability="disable" resourcePath="jni/libs-armv5te-android-gcc.mk" toolsToInvoke=""/>
<fileInfo id="com.android.toolchain.gcc.976037261.259940810.289270400" name="config.mk" rcbsApplicability="disable" resourcePath="jni/config.mk" toolsToInvoke=""/>
<fileInfo id="com.android.toolchain.gcc.976037261.259940810.1626450816" name="Makefile" rcbsApplicability="disable" resourcePath="jni/Makefile" toolsToInvoke=""/>
<sourceEntries>
Expand All @@ -49,15 +45,14 @@
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.android.toolchain.gcc.976037261.958453628" moduleId="org.eclipse.cdt.core.settings" name="Release">
<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"/>
<extension id="org.eclipse.cdt.autotools.core.ErrorParser" 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">
Expand All @@ -72,12 +67,11 @@
</outputEntries>
</builder>
<tool id="com.android.gcc.compiler.1368398077" name="Android GCC Compiler" superClass="com.android.gcc.compiler">
<option id="com.android.gcc.option.includePath.1947091560" superClass="com.android.gcc.option.includePath" valueType="includePath"/>
<option id="com.android.gcc.option.includePath.1947091560" superClass="com.android.gcc.option.includePath"/>
<inputType id="com.android.gcc.inputType.417193468" superClass="com.android.gcc.inputType"/>
</tool>
</toolChain>
</folderInfo>
<fileInfo id="com.android.toolchain.gcc.976037261.958453628.42702117" name="libs-armv5te-android-gcc.mk" rcbsApplicability="disable" resourcePath="jni/libs-armv5te-android-gcc.mk" toolsToInvoke=""/>
<fileInfo id="com.android.toolchain.gcc.976037261.958453628.2136766301" name="config.mk" rcbsApplicability="disable" resourcePath="jni/config.mk" toolsToInvoke=""/>
<fileInfo id="com.android.toolchain.gcc.976037261.958453628.1879292312" name="Makefile" rcbsApplicability="disable" resourcePath="jni/Makefile" toolsToInvoke=""/>
<sourceEntries>
Expand Down
89 changes: 88 additions & 1 deletion android/jni/guruchat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,97 @@

#include "./../../thirdparty/codec2/src/codec2.h"

vpx_codec_ctx_t vp8enc = {0};
vpx_codec_ctx_t vp8dec = {0};

# define VP8_CPU_USE -6

void InitVp8Codec()
{
vpx_codec_iface_t* vp8encIface = vpx_codec_vp8_cx();
vpx_codec_iface_t* vp8decIface = vpx_codec_vp8_dx();

vpx_codec_enc_cfg_t cfg = {0};
vpx_codec_err_t res = vpx_codec_enc_config_default(vp8encIface, &cfg, 0);

cfg.g_w = 320;
cfg.g_h = 240;
cfg.rc_target_bitrate = 4000;//25 << FRAME_RESOLUTION_NUMBER;

//cfg.rc_min_quantizer = 2; // WebRTC uses fixed 2
cfg.rc_min_quantizer = 36;//2;//2;//62;
// WebRTC allows setting via inst.qpMax
cfg.rc_max_quantizer = 2;

cfg.g_timebase.num = 1;
cfg.g_timebase.den = 30;
cfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT;// | VPX_ERROR_RESILIENT_PARTITIONS;

cfg.g_lag_in_frames = 0;

// Note: WebRTC uses 2 threads for >640x480 when ncores 4up
// and 3 threads when 1080p and ncores 6up
cfg.g_threads = 1;

// WebRTC uses 30 when dropping on.
cfg.rc_dropframe_thresh = 0;

// WebRTC allows setting
cfg.rc_resize_allowed = 0;

cfg.g_pass = VPX_RC_ONE_PASS;
cfg.rc_end_usage = VPX_VBR;

cfg.rc_undershoot_pct = 1000;
cfg.rc_overshoot_pct = 1000;

cfg.rc_buf_sz = 666; //1000 / CODEC_FPS;// VP8_KBITS_PER_SEC*1024;
cfg.rc_buf_initial_sz = 33;//1000 / CODEC_FPS;
cfg.rc_buf_optimal_sz = 333;//1000 / CODEC_FPS;

// WebRTC uses SLI & RPSI feedback from decoder and puts
// this setting to VPX_KF_DISABLED:
cfg.kf_mode = VPX_KF_AUTO;
//cfg.kf_mode = VPX_KF_DISABLED;
// codecSpecific.VP8.keyFrameInterval if not decoder feedback
cfg.kf_max_dist = 30;//999999;

res = vpx_codec_enc_init(&vp8enc, vp8encIface, &cfg, 0);
//VPX_CODEC_USE_PSNR);//VPX_CODEC_USE_OUTPUT_PARTITION);

// -12 on ARM, from -6 to -3 usually
vpx_codec_control(&vp8enc, VP8E_SET_STATIC_THRESHOLD, 0);
vpx_codec_control(&vp8enc, VP8E_SET_CPUUSED, VP8_CPU_USE);
vp8e_token_partitions partitions = VP8_ONE_TOKENPARTITION;
vpx_codec_control(&vp8enc, VP8E_SET_TOKEN_PARTITIONS,
partitions);
// On ARM disabled (very slow)
//vpx_codec_control(&vp8enc, VP8E_SET_NOISE_SENSITIVITY, 1);

uint32_t targetPct = cfg.rc_buf_optimal_sz * 0.5f * 30 / 10;
# ifdef VP8_KEYFRAME_PERCENT
uint32_t rc_max_intra_target = VP8_KEYFRAME_PERCENT;
# else
uint32_t rc_max_intra_target = (targetPct < 300) ? 300 : targetPct;
# endif
vpx_codec_control(&vp8enc, VP8E_SET_MAX_INTRA_BITRATE_PCT,
rc_max_intra_target);

// Init decoder

vpx_codec_dec_cfg_t decCfg = {0};
decCfg.w = 320;
decCfg.h = 240;
decCfg.threads = 1;
res = vpx_codec_dec_init(&vp8dec, vp8decIface, &decCfg,
VPX_CODEC_USE_POSTPROC | VPX_CODEC_USE_ERROR_CONCEALMENT);
}

extern "C" {

jstring Java_com_aeonsoftech_guruchat_LoginActivity_getJniString( JNIEnv* env, jobject obj)
{

InitVp8Codec();
short bufIn[320];

struct CODEC2* ctxt = codec2_create(CODEC2_MODE_1200);
Expand All @@ -32,6 +118,7 @@ jstring Java_com_aeonsoftech_guruchat_LoginActivity_getJniString( JNIEnv* env, j

vpx_codec_iface_t* vp8encIface = vpx_codec_vp8_cx();


libyuv::YUY2ToI420(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

jstring jstr = env->NewStringUTF("This comes from jni.");
Expand Down

0 comments on commit 355bf64

Please sign in to comment.