OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.media; | 5 package org.chromium.media; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.ImageFormat; | 8 import android.graphics.ImageFormat; |
9 import android.util.Log; | 9 |
10 import org.chromium.base.Log; | |
10 | 11 |
11 import java.nio.ByteBuffer; | 12 import java.nio.ByteBuffer; |
12 import java.util.ArrayList; | 13 import java.util.ArrayList; |
13 import java.util.Arrays; | 14 import java.util.Arrays; |
14 | 15 |
15 /** | 16 /** |
16 * This class extends the VideoCapture base class for manipulating a Tango | 17 * This class extends the VideoCapture base class for manipulating a Tango |
17 * device's cameras, namely the associated Depth (z-Buffer), Fisheye and back- | 18 * device's cameras, namely the associated Depth (z-Buffer), Fisheye and back- |
18 * facing 4MP video capture devices. These devices are differentiated via the | 19 * facing 4MP video capture devices. These devices are differentiated via the |
19 * |id| passed on constructor, according to the index correspondence in | 20 * |id| passed on constructor, according to the index correspondence in |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 private static final int SF_FULL_HEIGHT = SF_HEIGHT * 3 / 2; | 55 private static final int SF_FULL_HEIGHT = SF_HEIGHT * 3 / 2; |
55 private static final int SF_LINES_HEADER = 16; | 56 private static final int SF_LINES_HEADER = 16; |
56 private static final int SF_LINES_FISHEYE = 240; | 57 private static final int SF_LINES_FISHEYE = 240; |
57 private static final int SF_LINES_RESERVED = 80; // Spec says 96. | 58 private static final int SF_LINES_RESERVED = 80; // Spec says 96. |
58 private static final int SF_LINES_DEPTH = 60; | 59 private static final int SF_LINES_DEPTH = 60; |
59 private static final int SF_LINES_DEPTH_PADDED = 112; // Spec says 96. | 60 private static final int SF_LINES_DEPTH_PADDED = 112; // Spec says 96. |
60 private static final int SF_LINES_BIGIMAGE = 720; | 61 private static final int SF_LINES_BIGIMAGE = 720; |
61 private static final int SF_OFFSET_4MP_CHROMA = 112; | 62 private static final int SF_OFFSET_4MP_CHROMA = 112; |
62 | 63 |
63 private static final byte CHROMA_ZERO_LEVEL = 127; | 64 private static final byte CHROMA_ZERO_LEVEL = 127; |
64 private static final String TAG = "VideoCaptureTango"; | 65 private static final String TAG = Log.makeTag("media.VideoCaptureTango"); |
65 | 66 |
66 static int numberOfCameras() { | 67 static int numberOfCameras() { |
67 return CAM_PARAMS.length; | 68 return CAM_PARAMS.length; |
68 } | 69 } |
69 | 70 |
70 static int getCaptureApiType(int index) { | 71 static int getCaptureApiType(int index) { |
71 if (index >= CAM_PARAMS.length) { | 72 if (index >= CAM_PARAMS.length) { |
72 return CaptureApiType.API1; | 73 return CaptureApiType.API1; |
73 } | 74 } |
74 return CaptureApiType.TANGO; | 75 return CaptureApiType.TANGO; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 // Equivalent to the following |for| loop but much faster: | 174 // Equivalent to the following |for| loop but much faster: |
174 // for (int i = START; i < START + SIZE; ++i) | 175 // for (int i = START; i < START + SIZE; ++i) |
175 // mFrameBuffer.put(data[i]); | 176 // mFrameBuffer.put(data[i]); |
176 ByteBuffer.wrap(data, startY, sizeY) | 177 ByteBuffer.wrap(data, startY, sizeY) |
177 .get(mFrameBuffer.array(), 0, sizeY); | 178 .get(mFrameBuffer.array(), 0, sizeY); |
178 ByteBuffer.wrap(data, startU, sizeU) | 179 ByteBuffer.wrap(data, startU, sizeU) |
179 .get(mFrameBuffer.array(), sizeY, sizeU); | 180 .get(mFrameBuffer.array(), sizeY, sizeU); |
180 ByteBuffer.wrap(data, startV, sizeV) | 181 ByteBuffer.wrap(data, startV, sizeV) |
181 .get(mFrameBuffer.array(), sizeY + sizeU, sizeV); | 182 .get(mFrameBuffer.array(), sizeY + sizeU, sizeV); |
182 } else { | 183 } else { |
183 Log.e(TAG, "Unknown camera, #id: " + mTangoCameraId); | 184 Log.e(TAG, "Unknown camera, #id: " + mTangoCameraId); |
dgn
2015/06/09 13:10:53
%d ?
amogh.bihani
2015/06/10 04:44:20
Done.
| |
184 return; | 185 return; |
185 } | 186 } |
186 mFrameBuffer.rewind(); // Important! | 187 mFrameBuffer.rewind(); // Important! |
187 nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid, | 188 nativeOnFrameAvailable(mNativeVideoCaptureDeviceAndroid, |
188 mFrameBuffer.array(), | 189 mFrameBuffer.array(), |
189 mFrameBuffer.capacity(), | 190 mFrameBuffer.capacity(), |
190 getCameraRotation()); | 191 getCameraRotation()); |
191 } | 192 } |
192 } finally { | 193 } finally { |
193 mPreviewBufferLock.unlock(); | 194 mPreviewBufferLock.unlock(); |
194 } | 195 } |
195 } | 196 } |
196 } | 197 } |
OLD | NEW |