Methods Summary |
---|
private static int | bytesPerSampleForClass(java.lang.Class clazz, int target)
// Native targets have objects manifested in a byte buffer. Thus it is important to
// correctly determine the size of single element here.
if (target == FrameFormat.TARGET_NATIVE) {
if (!NativeBuffer.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException("Native object-based formats must be of a " +
"NativeBuffer subclass! (Received class: " + clazz + ").");
}
try {
return ((NativeBuffer)clazz.newInstance()).getElementSize();
} catch (Exception e) {
throw new RuntimeException("Could not determine the size of an element in a "
+ "native object-based frame of type " + clazz + "! Perhaps it is missing a "
+ "default constructor?");
}
} else {
return FrameFormat.BYTES_PER_SAMPLE_UNSPECIFIED;
}
|
public static android.filterfw.core.MutableFrameFormat | fromClass(java.lang.Class clazz, int count, int target)
// Create frame format
MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target);
result.setObjectClass(getBoxedClass(clazz));
if (count != FrameFormat.SIZE_UNSPECIFIED) {
result.setDimensions(count);
}
result.setBytesPerSample(bytesPerSampleForClass(clazz, target));
return result;
|
public static android.filterfw.core.MutableFrameFormat | fromClass(java.lang.Class clazz, int target)
return fromClass(clazz, FrameFormat.SIZE_UNSPECIFIED, target);
|
public static android.filterfw.core.MutableFrameFormat | fromObject(java.lang.Object object, int target)
return object == null
? new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target)
: fromClass(object.getClass(), FrameFormat.SIZE_UNSPECIFIED, target);
|
public static android.filterfw.core.MutableFrameFormat | fromObject(java.lang.Object object, int count, int target)
return object == null
? new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target)
: fromClass(object.getClass(), count, target);
|
private static java.lang.Class | getBoxedClass(java.lang.Class type)
// Check if type is primitive
if (type.isPrimitive()) {
// Yes -> box it
if (type == boolean.class) {
return java.lang.Boolean.class;
} else if (type == byte.class) {
return java.lang.Byte.class;
} else if (type == char.class) {
return java.lang.Character.class;
} else if (type == short.class) {
return java.lang.Short.class;
} else if (type == int.class) {
return java.lang.Integer.class;
} else if (type == long.class) {
return java.lang.Long.class;
} else if (type == float.class) {
return java.lang.Float.class;
} else if (type == double.class) {
return java.lang.Double.class;
} else {
throw new IllegalArgumentException(
"Unknown primitive type: " + type.getSimpleName() + "!");
}
} else {
// No -> return it
return type;
}
|