Add configurable ffmpeg performance options

This commit is contained in:
Cameron Gutman
2013-11-24 21:46:47 -05:00
parent c8b94217cf
commit fb8b6fd7f5
7 changed files with 72 additions and 21 deletions

View File

@@ -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);

View File

@@ -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);
}