mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-06 07:56:07 +00:00
Add configurable ffmpeg performance options
This commit is contained in:
@@ -15,7 +15,20 @@ public class AvcDecoder {
|
||||
System.loadLibrary("nv_avc_dec");
|
||||
}
|
||||
|
||||
public static native int init(int width, int height, int perflvl);
|
||||
/** Disables the deblocking filter at the cost of image quality */
|
||||
public static final int DISABLE_LOOP_FILTER = 0x1;
|
||||
/** Uses the low latency decode flag (disables multithreading) */
|
||||
public static final int LOW_LATENCY_DECODE = 0x2;
|
||||
/** Threads process each slice, rather than each frame */
|
||||
public static final int SLICE_THREADING = 0x4;
|
||||
/** Uses nonstandard speedup tricks */
|
||||
public static final int FAST_DECODE = 0x8;
|
||||
/** Uses bilinear filtering instead of bicubic */
|
||||
public static final int BILINEAR_FILTERING = 0x10;
|
||||
/** Uses a faster bilinear filtering with lower image quality */
|
||||
public static final int FAST_BILINEAR_FILTERING = 0x20;
|
||||
|
||||
public static native int init(int width, int height, int perflvl, int threadcount);
|
||||
public static native void destroy();
|
||||
public static native void redraw(Surface surface);
|
||||
public static native int decode(byte[] indata, int inoff, int inlen);
|
||||
|
||||
@@ -73,7 +73,25 @@ public class CpuDecoderRenderer implements DecoderRenderer {
|
||||
this.renderTarget = renderTarget;
|
||||
this.perfLevel = findOptimalPerformanceLevel();
|
||||
|
||||
int err = AvcDecoder.init(width, height, perfLevel);
|
||||
int flags = 0;
|
||||
switch (perfLevel) {
|
||||
case LOW_PERF:
|
||||
flags = AvcDecoder.DISABLE_LOOP_FILTER |
|
||||
AvcDecoder.FAST_BILINEAR_FILTERING |
|
||||
AvcDecoder.FAST_DECODE |
|
||||
AvcDecoder.LOW_LATENCY_DECODE;
|
||||
break;
|
||||
case MED_PERF:
|
||||
flags = AvcDecoder.LOW_LATENCY_DECODE |
|
||||
AvcDecoder.FAST_DECODE |
|
||||
AvcDecoder.BILINEAR_FILTERING;
|
||||
break;
|
||||
case HIGH_PERF:
|
||||
flags = AvcDecoder.LOW_LATENCY_DECODE;
|
||||
break;
|
||||
}
|
||||
|
||||
int err = AvcDecoder.init(width, height, flags, 2);
|
||||
if (err != 0) {
|
||||
throw new IllegalStateException("AVC decoder initialization failure: "+err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user