[Android] jni: deblocking properly

Edward Wang git at videolan.org
Sat Jun 22 21:10:48 CEST 2013


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Jun 22 14:44:49 2013 -0400| [0a825a3469623012b4d6d0046f96751bdfe3106a] | committer: Edward Wang

jni: deblocking properly

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=0a825a3469623012b4d6d0046f96751bdfe3106a
---

 vlc-android/jni/libvlcjni.c                     |    9 +++++---
 vlc-android/src/org/videolan/libvlc/LibVLC.java |   27 +++++++++++++++++++----
 vlc-android/src/org/videolan/vlc/Util.java      |   23 +++++++------------
 3 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index f65d439..a651a43 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -488,8 +488,11 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
     methodId = (*env)->GetMethodID(env, cls, "timeStretchingEnabled", "()Z");
     bool enable_time_stretch = (*env)->CallBooleanMethod(env, thiz, methodId);
 
-    methodId = (*env)->GetMethodID(env, cls, "deblockingEnabled", "()Z");
-    bool enable_deblocking = (*env)->CallBooleanMethod(env, thiz, methodId);
+    methodId = (*env)->GetMethodID(env, cls, "getDeblocking", "()I");
+    int deblocking = (*env)->CallIntMethod(env, thiz, methodId);
+    char deblockstr[2] = "3";
+    snprintf(deblockstr, 2, "%d", deblocking);
+    LOGD("Using deblocking level %d", deblocking);
 
     methodId = (*env)->GetMethodID(env, cls, "getChroma", "()Ljava/lang/String;");
     jstring chroma = (*env)->CallObjectMethod(env, thiz, methodId);
@@ -516,7 +519,7 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
         "--avcodec-threads=0",
         "--subsdec-encoding", subsencodingstr,
         enable_time_stretch ? "--audio-time-stretch" : "--no-audio-time-stretch",
-        enable_deblocking ? "" : "--avcodec-skiploopfilter=3",
+        "--avcodec-skiploopfilter", deblockstr,
         use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
         "--androidsurface-chroma", chromastr != NULL && chromastr[0] != 0 ? chromastr : "RV32",
     };
diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index d6964ce..a8bd9ff 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -58,7 +58,7 @@ public class LibVLC {
     private String subtitlesEncoding = "";
     private int aout = LibVlcUtil.isGingerbreadOrLater() ? AOUT_OPENSLES : AOUT_AUDIOTRACK_JAVA;
     private boolean timeStretching = false;
-    private boolean deblocking = false;
+    private int deblocking = -1;
     private String chroma = "";
     private boolean verboseMode = true;
 
@@ -200,11 +200,30 @@ public class LibVLC {
         this.timeStretching = timeStretching;
     }
 
-    public boolean deblockingEnabled() {
-        return deblocking;
+    public int getDeblocking() {
+        int ret = deblocking;
+        if(deblocking < 0) {
+            /**
+             * Set some reasonable deblocking defaults:
+             *
+             * Skip all (4) for armv6 and MIPS by default
+             * Skip non-ref (1) for all armv7 more than 1.2 Ghz and more than 2 cores
+             * Skip non-key (3) for all devices that don't meet anything above
+             */
+            LibVlcUtil.MachineSpecs m = LibVlcUtil.getMachineSpecs();
+            if( (m.hasArmV6 && !(m.hasArmV7)) || m.hasMips )
+                ret = 4;
+            else if(m.bogoMIPS > 1200 && m.processors > 2)
+                ret = 1;
+            else
+                ret = 3;
+        } else if(deblocking > 4) { // sanity check
+            ret = 3;
+        }
+        return ret;
     }
 
-    public void setDeblocking(boolean deblocking) {
+    public void setDeblocking(int deblocking) {
         this.deblocking = deblocking;
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index 19ca69c..ec727a9 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -37,7 +37,6 @@ import java.util.StringTokenizer;
 
 import org.videolan.libvlc.LibVLC;
 import org.videolan.libvlc.LibVlcException;
-import org.videolan.libvlc.LibVlcUtil;
 
 import android.content.Context;
 import android.content.SharedPreferences;
@@ -89,7 +88,6 @@ public class Util {
         instance.setIomx(pref.getBoolean("enable_iomx", false));
         instance.setSubtitlesEncoding(pref.getString("subtitles_text_encoding", ""));
         instance.setTimeStretching(pref.getBoolean("enable_time_stretching_audio", false));
-        instance.setDeblocking(pref.getBoolean("enable_deblocking", deblockingDefault()));
         instance.setChroma(pref.getString("chroma_format", ""));
         instance.setVerboseMode(pref.getBoolean("enable_verbose_mode", true));
 
@@ -100,20 +98,15 @@ public class Util {
         catch (NumberFormatException nfe) {
             aout = -1;
         }
+        int deblocking;
+        try {
+            deblocking = Integer.parseInt(pref.getString("deblocking", "-1"));
+        }
+        catch(NumberFormatException nfe) {
+            deblocking = -1;
+        }
         instance.setAout(aout);
-    }
-
-    public static boolean deblockingDefault() {
-        // Set some reasonable deblocking defaults
-        // For now, we will enable it on all ARMv7+NEON devices
-        // and disable it on others.
-        boolean deblocking_default;
-        LibVlcUtil.MachineSpecs m = LibVlcUtil.getMachineSpecs();
-        if(m.hasArmV7 && m.hasNeon)
-            deblocking_default = true;
-        else
-            deblocking_default = false;
-        return deblocking_default;
+        instance.setDeblocking(deblocking);
     }
 
     /** Print an on-screen message to alert the user */



More information about the Android mailing list