Commit a19a8e0e authored by Sébastien Toque's avatar Sébastien Toque
Browse files

allow to select chroma (RV32/RV16/YV12)

parent 03e841d3
......@@ -407,13 +407,14 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
methodId = (*env)->GetMethodID(env, cls, "timeStretchingEnabled", "()Z");
bool enable_time_stretch = (*env)->CallBooleanMethod(env, thiz, methodId);
methodId = (*env)->GetMethodID(env, cls, "yv12Enabled", "()Z");
bool yv12enabled = (*env)->CallBooleanMethod(env, thiz, methodId);
methodId = (*env)->GetMethodID(env, cls, "getChroma", "()Ljava/lang/String;");
jstring chroma = (*env)->CallObjectMethod(env, thiz, methodId);
const char *chromastr = (*env)->GetStringUTFChars(env, chroma, 0);
LOGD("Chroma set to \"%s\"", chromastr);
methodId = (*env)->GetMethodID(env, cls, "getSubtitlesEncoding", "()Ljava/lang/String;");
jstring subsencoding = (*env)->CallObjectMethod(env, thiz, methodId);
const char *subsencodingstr = (*env)->GetStringUTFChars(env, subsencoding, 0);
LOGD("Subtitle encoding set to \"%s\"", subsencodingstr);
verbosity = verbose;
......@@ -432,12 +433,13 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
"--subsdec-encoding", subsencodingstr,
enable_time_stretch ? "--audio-time-stretch" : "--no-audio-time-stretch",
use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
yv12enabled ? "--androidsurface-chroma=YV12" : "--androidsurface-chroma=RV32",
"--androidsurface-chroma", chromastr != NULL && chromastr[0] != 0 ? chromastr : "RV32",
};
libvlc_instance_t *instance = libvlc_new(sizeof(argv) / sizeof(*argv), argv);
setLong(env, thiz, "mLibVlcInstance", (jlong)(intptr_t) instance);
(*env)->ReleaseStringUTFChars(env, chroma, chromastr);
(*env)->ReleaseStringUTFChars(env, subsencoding, subsencodingstr);
if (!instance)
......
......@@ -144,8 +144,8 @@
<string name="set_locale">Définir la langue</string>
<string name="set_locale_detail">Laisser vide pour réinitialiser</string>
<string name="set_locale_popup">Quitter et relancer VLC pour appliquer la langue.</string>
<string name="enable_yv12_format">Forcer le format YV12</string>
<string name="enable_yv12_format_detail">NE PAS ACTIVER!!! Ne fonctionne pas sur tous les appareils. Android 2.3 et supérieur uniquement.</string>
<string name="chroma_format">Forcer le chroma</string>
<string name="chroma_format_detail">NE PAS ACTIVER!!! Ne fonctionne pas sur tous les appareils. Android 2.3 et supérieur uniquement.</string>
<string name="detect_headset">Détecter le casque</string>
<string name="detect_headset_detail">Pause lors du débranchement du casque, Reprise lors du branchement du casque</string>
<string name="steal_remote_control">Contrôle exclusif de la télécommande</string>
......
......@@ -165,8 +165,8 @@
<string name="set_locale">Set locale</string>
<string name="set_locale_detail">Leave blank to reset</string>
<string name="set_locale_popup">Quit and reset VLC for changes to take effect.</string>
<string name="enable_yv12_format">Force YV12 format</string>
<string name="enable_yv12_format_detail">DO NOT ACTIVATE!!! May not work with all devices. 2.3 and later only.</string>
<string name="chroma_format">Force chroma</string>
<string name="chroma_format_detail">DO NOT ACTIVATE!!! May not work with all devices. 2.3 and later only.</string>
<string name="detect_headset">Detect headset</string>
<string name="detect_headset_detail">Pause on headset removed; resume on headset inserted</string>
<string name="steal_remote_control">Exclusive headset remote control</string>
......@@ -316,4 +316,10 @@
<item>2</item>
</string-array>
<string-array name="chroma_formats" translatable="false">
<item>RV32</item>
<item>RV16</item>
<item>YV12</item>
</string-array>
</resources>
......@@ -85,11 +85,13 @@
android:summary="@string/set_locale_detail"
android:key="set_locale"
android:defaultValue="" />
<CheckBoxPreference
android:defaultValue="false"
android:key="enable_yv12_format"
android:summary="@string/enable_yv12_format_detail"
android:title="@string/enable_yv12_format" />
<ListPreference
android:defaultValue=""
android:key="chroma_format"
android:title="@string/chroma_format"
android:summary="@string/chroma_format_detail"
android:entries="@array/chroma_formats"
android:entryValues="@array/chroma_formats" />
</PreferenceScreen>
</PreferenceCategory>
......
......@@ -180,9 +180,10 @@ public class LibVLC {
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
return p.getBoolean("enable_time_stretching_audio", false);
}
public boolean yv12Enabled() {
public String getChroma() {
final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
return (p.getBoolean("enable_yv12_format", false) && Util.isGingerbreadOrLater());
String chroma = p.getString("chroma_format", "");
return chroma.equals("YV12") && !Util.isGingerbreadOrLater() ? "" : chroma;
}
/**
......
......@@ -208,7 +208,7 @@ public class PreferencesActivity extends PreferenceActivity implements OnSharedP
key.equalsIgnoreCase("subtitles_text_encoding") ||
key.equalsIgnoreCase("aout") ||
key.equalsIgnoreCase("enable_time_stretching_audio") ||
key.equalsIgnoreCase("enable_yv12_format")) {
key.equalsIgnoreCase("chroma_format")) {
LibVLC.restart();
}
}
......
......@@ -260,9 +260,15 @@ public class VideoPlayerActivity extends Activity {
mSurfaceHolder = mSurface.getHolder();
mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
int pitch;
if(Util.isGingerbreadOrLater() && pref.getBoolean("enable_yv12_format", false)) {
String chroma = pref.getString("chroma_format", "");
if(Util.isGingerbreadOrLater() && chroma.equals("YV12")) {
mSurfaceHolder.setFormat(ImageFormat.YV12);
pitch = ImageFormat.getBitsPerPixel(ImageFormat.YV12) / 8;
} else if (chroma.equals("RV16")) {
mSurfaceHolder.setFormat(PixelFormat.RGB_565);
PixelFormat info = new PixelFormat();
PixelFormat.getPixelFormatInfo(PixelFormat.RGB_565, info);
pitch = info.bytesPerPixel;
} else {
mSurfaceHolder.setFormat(PixelFormat.RGBX_8888);
PixelFormat info = new PixelFormat();
......@@ -1109,6 +1115,8 @@ public class VideoPlayerActivity extends Activity {
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if(format == PixelFormat.RGBX_8888)
Log.d(TAG, "Pixel format is RGBX_8888");
else if(format == PixelFormat.RGB_565)
Log.d(TAG, "Pixel format is RGB_565");
else if(format == ImageFormat.YV12)
Log.d(TAG, "Pixel format is YV12");
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment