android: use neon downscaling function

parent 2841874a
......@@ -149,21 +149,31 @@ public class AndroidVideoApi5JniWrapper {
int rW = Math.max(requestedW, requestedH);
int rH = Math.min(requestedW, requestedH);
try {
try {
// look for nearest size
Size result = null;
int req = rW * rH;
int minDist = Integer.MAX_VALUE;
int useDownscale = 0;
for(Size s: supportedSizes) {
int dist = Math.abs(req - s.width * s.height);
if (dist < minDist) {
minDist = dist;
result = s;
useDownscale = 0;
}
/* MS2 has a NEON downscaler, so we test this too */
int downScaleDist = Math.abs(req - s.width * s.height / 4);
if (downScaleDist < minDist) {
minDist = downScaleDist;
result = s;
useDownscale = 1;
}
if (s.width == rW && s.height == rH)
return new int[] {s.width, s.height};
return new int[] {s.width, s.height, 0};
}
return new int[] {result.width, result.height};
return new int[] {result.width, result.height, useDownscale};
} catch (Exception exc) {
exc.printStackTrace();
return null;
......
......@@ -120,6 +120,13 @@ static int video_capture_set_vsize(MSFilter *f, void* data){
d->requestedSize=*(MSVideoSize*)data;
// always request landscape mode, orientation is handled later
if (d->requestedSize.height > d->requestedSize.width) {
int tmp = d->requestedSize.height;
d->requestedSize.height = d->requestedSize.width;
d->requestedSize.width = tmp;
}
JNIEnv *env = ms_get_jni_env();
jclass helperClass = getHelperClass(env);
......@@ -468,7 +475,7 @@ JNIEXPORT void JNICALL Java_org_linphone_mediastream_video_capture_AndroidVideoA
}
int y_cropping_offset=0, cbcr_cropping_offset=0;
compute_cropping_offsets(d->hwCapableSize, d->requestedSize, &y_cropping_offset, &cbcr_cropping_offset);
//compute_cropping_offsets(d->hwCapableSize, d->requestedSize, &y_cropping_offset, &cbcr_cropping_offset);
int width = d->hwCapableSize.width;
int height = d->hwCapableSize.height;
......
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