Revert "Support none multiple of 16 pixels width on android."

Buildbot Android Tests (L Nexus9)(dbg) consistently fails on Instrumentation test libjingle_peerconnection_android_unittest (VideoCapturerAndroidTest) after this CL was landed.

This reverts commit f4acf46c863f2d516b09b00b39608de7e506ac65.

BUG=
TBR=perkj@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/45079004

Cr-Commit-Position: refs/heads/master@{#8981}
This commit is contained in:
Bjorn Volcker 2015-04-11 08:55:05 +02:00
parent 99c2fe5d2b
commit eba964f472
2 changed files with 15 additions and 26 deletions

View File

@ -34,11 +34,6 @@
#include "webrtc/base/timeutils.h"
#include "webrtc/base/thread.h"
static int RoundUp(int value, int alignment) {
DCHECK(value > 0 && alignment > 0);
return ((value + (alignment - 1)) & ~(alignment - 1));
}
namespace webrtc {
using cricket::WebRtcVideoFrame;
@ -98,14 +93,12 @@ class AndroidVideoCapturer::FrameFactory : public cricket::VideoFrameFactory {
if (!apply_rotation_ || captured_frame->rotation == kVideoRotation_0) {
DCHECK(captured_frame->fourcc == cricket::FOURCC_YV12);
const uint8_t* y_plane = static_cast<uint8_t*>(captured_frame_.data);
// Android guarantee that the stride is a multiple of 16.
// http://developer.android.com/reference/android/hardware/Camera.Parameters.html#setPreviewFormat%28int%29
const int y_stride = RoundUp(captured_frame->width, 16);
const int uv_stride = RoundUp(y_stride / 2, 16);
const uint8_t* v_plane = y_plane + y_stride * captured_frame->height;
const uint8_t* u_plane =
v_plane + uv_stride * captured_frame->height / 2;
const int y_stride = captured_frame->width;
const uint8_t* v_plane = y_plane +
captured_frame->width * captured_frame->height;
const int uv_stride = (captured_frame->width + 1) / 2;
const int uv_height = (captured_frame->height + 1) / 2;
const uint8_t* u_plane = v_plane + uv_stride * uv_height;
// Create a WrappedI420Buffer and bind the |no_longer_used| callback
// to the static method ReturnFrame. The |delegate_| is bound as an

View File

@ -28,7 +28,6 @@
package org.webrtc;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import android.content.Context;
import android.graphics.ImageFormat;
@ -312,6 +311,13 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
List<Camera.Size> supportedSizes = parameters.getSupportedPreviewSizes();
for (Camera.Size size : supportedSizes) {
if (size.width % 16 != 0) {
// If the width is not a multiple of 16, the frames received from the
// camera will have a stride != width when YV12 is used. Since we
// currently only support tightly packed images, we simply ignore
// those resolutions.
continue;
}
formatList.add(new CaptureFormat(size.width, size.height,
range[Camera.Parameters.PREVIEW_FPS_MIN_INDEX],
range[Camera.Parameters.PREVIEW_FPS_MAX_INDEX]));
@ -672,18 +678,8 @@ public class VideoCapturerAndroid extends VideoCapturer implements PreviewCallba
throw new RuntimeException("camera already set.");
this.camera = camera;
int newframeSize = 0;
if (format == ImageFormat.YV12) {
int yStride = (int) ceil(width / 16.0) * 16;
int uvStride = (int) ceil( (yStride / 2) / 16.0) * 16;
int ySize = yStride * height;
int uvSize = uvStride * height / 2;
newframeSize = ySize + uvSize * 2;
} else {
newframeSize =
width * height * ImageFormat.getBitsPerPixel(format) / 8;
}
int newframeSize =
width * height * ImageFormat.getBitsPerPixel(format) / 8;
int numberOfEnquedCameraBuffers = 0;
if (newframeSize != frameSize) {
// Create new frames and add to the camera.