blob: 9a992876118d475d42bf368b35b4f040042b1489 [file] [log] [blame]
Yin-Chia Yehc3603822016-01-18 22:11:19 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -070017/**
18 * @addtogroup Media Camera
19 * @{
20 */
21
22/**
23 * @file NdkImage.h
24 */
25
Yin-Chia Yehc3603822016-01-18 22:11:19 -080026/*
27 * This file defines an NDK API.
28 * Do not remove methods.
29 * Do not change method signatures.
30 * Do not change the value of constants.
31 * Do not change the size of any of the classes defined in here.
32 * Do not reference types that are not part of the NDK.
33 * Do not #include files that aren't part of the NDK.
34 */
35
36#ifndef _NDK_IMAGE_H
37#define _NDK_IMAGE_H
38
Dan Albert2975a242016-09-23 16:17:45 -070039#include <sys/cdefs.h>
40
Yin-Chia Yehc3603822016-01-18 22:11:19 -080041#include "NdkMediaError.h"
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
Dan Albert2975a242016-09-23 16:17:45 -070047#if __ANDROID_API__ >= 24
48
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -070049/**
50 * AImage is an opaque type that provides access to image generated by {@link AImageReader}.
51 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -080052typedef struct AImage AImage;
53
54// Formats not listed here will not be supported by AImageReader
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -070055enum AIMAGE_FORMATS {
56 /**
57 * Multi-plane Android YUV 420 format.
58 *
59 * <p>This format is a generic YCbCr format, capable of describing any 4:2:0
60 * chroma-subsampled planar or semiplanar buffer (but not fully interleaved),
61 * with 8 bits per color sample.</p>
62 *
63 * <p>Images in this format are always represented by three separate buffers
64 * of data, one for each color plane. Additional information always
65 * accompanies the buffers, describing the row stride and the pixel stride
66 * for each plane.</p>
67 *
68 * <p>The order of planes is guaranteed such that plane #0 is always Y, plane #1 is always
69 * U (Cb), and plane #2 is always V (Cr).</p>
70 *
71 * <p>The Y-plane is guaranteed not to be interleaved with the U/V planes
72 * (in particular, pixel stride is always 1 in {@link AImage_getPlanePixelStride}).</p>
73 *
74 * <p>The U/V planes are guaranteed to have the same row stride and pixel stride, that is, the
75 * return value of {@link AImage_getPlaneRowStride} for the U/V plane are guaranteed to be the
76 * same, and the return value of {@link AImage_getPlanePixelStride} for the U/V plane are also
77 * guaranteed to be the same.</p>
78 *
79 * <p>For example, the {@link AImage} object can provide data
80 * in this format from a {@link ACameraDevice} through an {@link AImageReader} object.</p>
81 *
82 * <p>This format is always supported as an output format for the android Camera2 NDK API.</p>
83 *
84 * @see AImage
85 * @see AImageReader
86 * @see ACameraDevice
87 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -080088 AIMAGE_FORMAT_YUV_420_888 = 0x23,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -070089
90 /**
91 * Compressed JPEG format.
92 *
93 * <p>This format is always supported as an output format for the android Camera2 NDK API.</p>
94 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -080095 AIMAGE_FORMAT_JPEG = 0x100,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -070096
97 /**
98 * 16 bits per pixel raw camera sensor image format, usually representing a single-channel
99 * Bayer-mosaic image.
100 *
101 * <p>The layout of the color mosaic, the maximum and minimum encoding
102 * values of the raw pixel data, the color space of the image, and all other
103 * needed information to interpret a raw sensor image must be queried from
104 * the {@link ACameraDevice} which produced the image.</p>
105 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800106 AIMAGE_FORMAT_RAW16 = 0x20,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700107
108 /**
109 * Private raw camera sensor image format, a single channel image with implementation depedent
110 * pixel layout.
111 *
112 * <p>AIMAGE_FORMAT_RAW_PRIVATE is a format for unprocessed raw image buffers coming from an
113 * image sensor. The actual structure of buffers of this format is implementation-dependent.</p>
114 *
115 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800116 AIMAGE_FORMAT_RAW_PRIVATE = 0x24,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700117
118 /**
119 * Android 10-bit raw format.
120 *
121 * <p>
122 * This is a single-plane, 10-bit per pixel, densely packed (in each row),
123 * unprocessed format, usually representing raw Bayer-pattern images coming
124 * from an image sensor.
125 * </p>
126 * <p>
127 * In an image buffer with this format, starting from the first pixel of
128 * each row, each 4 consecutive pixels are packed into 5 bytes (40 bits).
129 * Each one of the first 4 bytes contains the top 8 bits of each pixel, The
130 * fifth byte contains the 2 least significant bits of the 4 pixels, the
131 * exact layout data for each 4 consecutive pixels is illustrated below
132 * (Pi[j] stands for the jth bit of the ith pixel):
133 * </p>
134 * <table>
135 * <tr>
136 * <th align="center"></th>
137 * <th align="center">bit 7</th>
138 * <th align="center">bit 6</th>
139 * <th align="center">bit 5</th>
140 * <th align="center">bit 4</th>
141 * <th align="center">bit 3</th>
142 * <th align="center">bit 2</th>
143 * <th align="center">bit 1</th>
144 * <th align="center">bit 0</th>
145 * </tr>
146 * <tr>
147 * <td align="center">Byte 0:</td>
148 * <td align="center">P0[9]</td>
149 * <td align="center">P0[8]</td>
150 * <td align="center">P0[7]</td>
151 * <td align="center">P0[6]</td>
152 * <td align="center">P0[5]</td>
153 * <td align="center">P0[4]</td>
154 * <td align="center">P0[3]</td>
155 * <td align="center">P0[2]</td>
156 * </tr>
157 * <tr>
158 * <td align="center">Byte 1:</td>
159 * <td align="center">P1[9]</td>
160 * <td align="center">P1[8]</td>
161 * <td align="center">P1[7]</td>
162 * <td align="center">P1[6]</td>
163 * <td align="center">P1[5]</td>
164 * <td align="center">P1[4]</td>
165 * <td align="center">P1[3]</td>
166 * <td align="center">P1[2]</td>
167 * </tr>
168 * <tr>
169 * <td align="center">Byte 2:</td>
170 * <td align="center">P2[9]</td>
171 * <td align="center">P2[8]</td>
172 * <td align="center">P2[7]</td>
173 * <td align="center">P2[6]</td>
174 * <td align="center">P2[5]</td>
175 * <td align="center">P2[4]</td>
176 * <td align="center">P2[3]</td>
177 * <td align="center">P2[2]</td>
178 * </tr>
179 * <tr>
180 * <td align="center">Byte 3:</td>
181 * <td align="center">P3[9]</td>
182 * <td align="center">P3[8]</td>
183 * <td align="center">P3[7]</td>
184 * <td align="center">P3[6]</td>
185 * <td align="center">P3[5]</td>
186 * <td align="center">P3[4]</td>
187 * <td align="center">P3[3]</td>
188 * <td align="center">P3[2]</td>
189 * </tr>
190 * <tr>
191 * <td align="center">Byte 4:</td>
192 * <td align="center">P3[1]</td>
193 * <td align="center">P3[0]</td>
194 * <td align="center">P2[1]</td>
195 * <td align="center">P2[0]</td>
196 * <td align="center">P1[1]</td>
197 * <td align="center">P1[0]</td>
198 * <td align="center">P0[1]</td>
199 * <td align="center">P0[0]</td>
200 * </tr>
201 * </table>
202 * <p>
203 * This format assumes
204 * <ul>
205 * <li>a width multiple of 4 pixels</li>
206 * <li>an even height</li>
207 * </ul>
208 * </p>
209 *
210 * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
211 * not pixels.
212 *
213 * <p>
214 * Since this is a densely packed format, the pixel stride is always 0. The
215 * application must use the pixel data layout defined in above table to
216 * access each row data. When row stride is equal to (width * (10 / 8)), there
217 * will be no padding bytes at the end of each row, the entire image data is
218 * densely packed. When stride is larger than (width * (10 / 8)), padding
219 * bytes will be present at the end of each row.
220 * </p>
221 * <p>
222 * For example, the {@link AImage} object can provide data in this format from a
223 * {@link ACameraDevice} (if supported) through a {@link AImageReader} object.
224 * The number of planes returned by {@link AImage_getNumberOfPlanes} will always be 1.
225 * The pixel stride is undefined ({@link AImage_getPlanePixelStride} will return
226 * {@link AMEDIA_ERROR_UNSUPPORTED}), and the {@link AImage_getPlaneRowStride} described the
227 * vertical neighboring pixel distance (in bytes) between adjacent rows.
228 * </p>
229 *
230 * @see AImage
231 * @see AImageReader
232 * @see ACameraDevice
233 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800234 AIMAGE_FORMAT_RAW10 = 0x25,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700235
236 /**
237 * Android 12-bit raw format.
238 *
239 * <p>
240 * This is a single-plane, 12-bit per pixel, densely packed (in each row),
241 * unprocessed format, usually representing raw Bayer-pattern images coming
242 * from an image sensor.
243 * </p>
244 * <p>
245 * In an image buffer with this format, starting from the first pixel of each
246 * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
247 * and second byte contains the top 8 bits of first and second pixel. The third
248 * byte contains the 4 least significant bits of the two pixels, the exact layout
249 * data for each two consecutive pixels is illustrated below (Pi[j] stands for
250 * the jth bit of the ith pixel):
251 * </p>
252 * <table>
253 * <tr>
254 * <th align="center"></th>
255 * <th align="center">bit 7</th>
256 * <th align="center">bit 6</th>
257 * <th align="center">bit 5</th>
258 * <th align="center">bit 4</th>
259 * <th align="center">bit 3</th>
260 * <th align="center">bit 2</th>
261 * <th align="center">bit 1</th>
262 * <th align="center">bit 0</th>
263 * </tr>
264 * <tr>
265 * <td align="center">Byte 0:</td>
266 * <td align="center">P0[11]</td>
267 * <td align="center">P0[10]</td>
268 * <td align="center">P0[ 9]</td>
269 * <td align="center">P0[ 8]</td>
270 * <td align="center">P0[ 7]</td>
271 * <td align="center">P0[ 6]</td>
272 * <td align="center">P0[ 5]</td>
273 * <td align="center">P0[ 4]</td>
274 * </tr>
275 * <tr>
276 * <td align="center">Byte 1:</td>
277 * <td align="center">P1[11]</td>
278 * <td align="center">P1[10]</td>
279 * <td align="center">P1[ 9]</td>
280 * <td align="center">P1[ 8]</td>
281 * <td align="center">P1[ 7]</td>
282 * <td align="center">P1[ 6]</td>
283 * <td align="center">P1[ 5]</td>
284 * <td align="center">P1[ 4]</td>
285 * </tr>
286 * <tr>
287 * <td align="center">Byte 2:</td>
288 * <td align="center">P1[ 3]</td>
289 * <td align="center">P1[ 2]</td>
290 * <td align="center">P1[ 1]</td>
291 * <td align="center">P1[ 0]</td>
292 * <td align="center">P0[ 3]</td>
293 * <td align="center">P0[ 2]</td>
294 * <td align="center">P0[ 1]</td>
295 * <td align="center">P0[ 0]</td>
296 * </tr>
297 * </table>
298 * <p>
299 * This format assumes
300 * <ul>
301 * <li>a width multiple of 4 pixels</li>
302 * <li>an even height</li>
303 * </ul>
304 * </p>
305 *
306 * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
307 * not pixels.
308 *
309 * <p>
310 * Since this is a densely packed format, the pixel stride is always 0. The
311 * application must use the pixel data layout defined in above table to
312 * access each row data. When row stride is equal to (width * (12 / 8)), there
313 * will be no padding bytes at the end of each row, the entire image data is
314 * densely packed. When stride is larger than (width * (12 / 8)), padding
315 * bytes will be present at the end of each row.
316 * </p>
317 * <p>
318 * For example, the {@link AImage} object can provide data in this format from a
319 * {@link ACameraDevice} (if supported) through a {@link AImageReader} object.
320 * The number of planes returned by {@link AImage_getNumberOfPlanes} will always be 1.
321 * The pixel stride is undefined ({@link AImage_getPlanePixelStride} will return
322 * {@link AMEDIA_ERROR_UNSUPPORTED}), and the {@link AImage_getPlaneRowStride} described the
323 * vertical neighboring pixel distance (in bytes) between adjacent rows.
324 * </p>
325 *
326 * @see AImage
327 * @see AImageReader
328 * @see ACameraDevice
329 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800330 AIMAGE_FORMAT_RAW12 = 0x26,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700331
332 /**
333 * Android dense depth image format.
334 *
335 * <p>Each pixel is 16 bits, representing a depth ranging measurement from a depth camera or
336 * similar sensor. The 16-bit sample consists of a confidence value and the actual ranging
337 * measurement.</p>
338 *
339 * <p>The confidence value is an estimate of correctness for this sample. It is encoded in the
340 * 3 most significant bits of the sample, with a value of 0 representing 100% confidence, a
341 * value of 1 representing 0% confidence, a value of 2 representing 1/7, a value of 3
342 * representing 2/7, and so on.</p>
343 *
344 * <p>As an example, the following sample extracts the range and confidence from the first pixel
345 * of a DEPTH16-format {@link AImage}, and converts the confidence to a floating-point value
346 * between 0 and 1.f inclusive, with 1.f representing maximum confidence:
347 *
348 * <pre>
349 * uint16_t* data;
350 * int dataLength;
351 * AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
352 * uint16_t depthSample = data[0];
353 * uint16_t depthRange = (depthSample & 0x1FFF);
354 * uint16_t depthConfidence = ((depthSample >> 13) & 0x7);
355 * float depthPercentage = depthConfidence == 0 ? 1.f : (depthConfidence - 1) / 7.f;
356 * </pre>
357 * </p>
358 *
359 * <p>This format assumes
360 * <ul>
361 * <li>an even width</li>
362 * <li>an even height</li>
363 * <li>a horizontal stride multiple of 16 pixels</li>
364 * </ul>
365 * </p>
366 *
367 * <pre> y_size = stride * height </pre>
368 *
369 * When produced by a camera, the units for the range are millimeters.
370 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800371 AIMAGE_FORMAT_DEPTH16 = 0x44363159,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700372
373 /**
374 * Android sparse depth point cloud format.
375 *
376 * <p>A variable-length list of 3D points plus a confidence value, with each point represented
377 * by four floats; first the X, Y, Z position coordinates, and then the confidence value.</p>
378 *
379 * <p>The number of points is ((size of the buffer in bytes) / 16).
380 *
381 * <p>The coordinate system and units of the position values depend on the source of the point
382 * cloud data. The confidence value is between 0.f and 1.f, inclusive, with 0 representing 0%
383 * confidence and 1.f representing 100% confidence in the measured position values.</p>
384 *
385 * <p>As an example, the following code extracts the first depth point in a DEPTH_POINT_CLOUD
386 * format {@link AImage}:
387 * <pre>
388 * float* data;
389 * int dataLength;
390 * AImage_getPlaneData(image, 0, (uint8_t**)&data, &dataLength);
391 * float x = data[0];
392 * float y = data[1];
393 * float z = data[2];
394 * float confidence = data[3];
395 * </pre>
396 *
397 */
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -0700398 AIMAGE_FORMAT_DEPTH_POINT_CLOUD = 0x101,
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700399
400 /**
401 * Android private opaque image format.
402 *
403 * <p>This format is not currently supported by {@link AImageReader}.</p>
404 */
405 AIMAGE_FORMAT_PRIVATE = 0x22
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800406};
407
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700408/**
409 * Data type describing an cropped rectangle returned by {@link AImage_getCropRect}.
410 *
411 * <p>Note that the right and bottom coordinates are exclusive, so the width of the rectangle is
412 * (right - left) and the height of the rectangle is (bottom - top).</p>
413 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800414typedef struct AImageCropRect {
415 int32_t left;
416 int32_t top;
417 int32_t right;
418 int32_t bottom;
419} AImageCropRect;
420
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700421/**
422 * Return the image back the the system and delete the AImage object from memory.
423 *
424 * <p>Do NOT use the image pointer after this method returns.
425 * Note that if the parent {@link AImageReader} is closed, all the {@link AImage} objects acquired
426 * from the parent reader will be returned to system. All AImage_* methods except this method will
427 * return {@link AMEDIA_ERROR_INVALID_OBJECT}. Application still needs to call this method on those
428 * {@link AImage} objects to fully delete the {@link AImage} object from memory.</p>
429 *
430 * @param image The {@link AImage} to be deleted.
431 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800432void AImage_delete(AImage* image);
433
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700434/**
435 * Query the width of the input {@link AImage}.
436 *
437 * @param image the {@link AImage} of interest.
438 * @param width the width of the image will be filled here if the method call succeeeds.
439 *
440 * @return <ul>
441 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
442 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or width is NULL.</li>
443 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
444 * image has been deleted.</li></ul>
445 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800446media_status_t AImage_getWidth(const AImage* image, /*out*/int32_t* width);
447
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700448/**
449 * Query the height of the input {@link AImage}.
450 *
451 * @param image the {@link AImage} of interest.
452 * @param height the height of the image will be filled here if the method call succeeeds.
453 *
454 * @return <ul>
455 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
456 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or height is NULL.</li>
457 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
458 * image has been deleted.</li></ul>
459 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800460media_status_t AImage_getHeight(const AImage* image, /*out*/int32_t* height);
461
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700462/**
463 * Query the format of the input {@link AImage}.
464 *
465 * <p>The format value will be one of AIMAGE_FORMAT_* enum value.</p>
466 *
467 * @param image the {@link AImage} of interest.
468 * @param format the format of the image will be filled here if the method call succeeeds.
469 *
470 * @return <ul>
471 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
472 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or format is NULL.</li>
473 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
474 * image has been deleted.</li></ul>
475 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800476media_status_t AImage_getFormat(const AImage* image, /*out*/int32_t* format);
477
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700478/**
479 * Query the cropped rectangle of the input {@link AImage}.
480 *
481 * <p>The crop rectangle specifies the region of valid pixels in the image, using coordinates in the
482 * largest-resolution plane.</p>
483 *
484 * @param image the {@link AImage} of interest.
485 * @param rect the cropped rectangle of the image will be filled here if the method call succeeeds.
486 *
487 * @return <ul>
488 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
489 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or rect is NULL.</li>
490 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
491 * image has been deleted.</li></ul>
492 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800493media_status_t AImage_getCropRect(const AImage* image, /*out*/AImageCropRect* rect);
494
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700495/**
496 * Query the timestamp of the input {@link AImage}.
497 *
498 * <p>
499 * The timestamp is measured in nanoseconds, and is normally monotonically increasing. The
500 * timestamps for the images from different sources may have different timebases therefore may not
501 * be comparable. The specific meaning and timebase of the timestamp depend on the source providing
502 * images. For images generated by camera, the timestamp value will match
503 * {@link ACAMERA_SENSOR_TIMESTAMP} of the {@link ACameraMetadata} in
504 * {@link ACameraCaptureSession_captureCallbacks#onCaptureStarted} and
505 * {@link ACameraCaptureSession_captureCallbacks#onCaptureCompleted} callback.
506 * </p>
507 *
508 * @param image the {@link AImage} of interest.
509 * @param timestampNs the timestamp of the image will be filled here if the method call succeeeds.
510 *
511 * @return <ul>
512 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
513 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or timestampNs is NULL.</li>
514 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
515 * image has been deleted.</li></ul>
516 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800517media_status_t AImage_getTimestamp(const AImage* image, /*out*/int64_t* timestampNs);
518
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700519/**
520 * Query the number of planes of the input {@link AImage}.
521 *
522 * <p>The number of plane of an {@link AImage} is determined by its format, which can be queried by
523 * {@link AImage_getFormat} method.</p>
524 *
525 * @param image the {@link AImage} of interest.
526 * @param numPlanes the number of planes of the image will be filled here if the method call
527 * succeeeds.
528 *
529 * @return <ul>
530 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
531 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or numPlanes is NULL.</li>
532 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
533 * image has been deleted.</li></ul>
534 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800535media_status_t AImage_getNumberOfPlanes(const AImage* image, /*out*/int32_t* numPlanes);
536
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700537/**
538 * Query the pixel stride of the input {@link AImage}.
539 *
540 * <p>This is the distance between two consecutive pixel values in a row of pixels. It may be
541 * larger than the size of a single pixel to account for interleaved image data or padded formats.
542 * Note that pixel stride is undefined for some formats such as {@link AIMAGE_FORMAT_RAW_PRIVATE},
543 * and calling this method on images of these formats will cause {@link AMEDIA_ERROR_UNSUPPORTED}
544 * being returned.
545 * For formats where pixel stride is well defined, the pixel stride is always greater than 0.</p>
546 *
547 * @param image the {@link AImage} of interest.
548 * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
549 * @param pixelStride the pixel stride of the image will be filled here if the method call succeeeds.
550 *
551 * @return <ul>
552 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
553 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or pixelStride is NULL, or planeIdx
554 * is out of the range of [0, numOfPlanes - 1].</li>
555 * <li>{@link AMEDIA_ERROR_UNSUPPORTED} if pixel stride is undefined for the format of input
556 * image.</li>
557 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
558 * image has been deleted.</li></ul>
559 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800560media_status_t AImage_getPlanePixelStride(
561 const AImage* image, int planeIdx, /*out*/int32_t* pixelStride);
562
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700563/**
564 * Query the row stride of the input {@link AImage}.
565 *
566 * <p>This is the distance between the start of two consecutive rows of pixels in the image. Note
567 * that row stried is undefined for some formats such as {@link AIMAGE_FORMAT_RAW_PRIVATE}, and
568 * calling this method on images of these formats will cause {@link AMEDIA_ERROR_UNSUPPORTED}
569 * being returned.
570 * For formats where row stride is well defined, the row stride is always greater than 0.</p>
571 *
572 * @param image the {@link AImage} of interest.
573 * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
574 * @param rowStride the row stride of the image will be filled here if the method call succeeeds.
575 *
576 * @return <ul>
577 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
578 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image or rowStride is NULL, or planeIdx
579 * is out of the range of [0, numOfPlanes - 1].</li>
580 * <li>{@link AMEDIA_ERROR_UNSUPPORTED} if row stride is undefined for the format of input
581 * image.</li>
582 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
583 * image has been deleted.</li></ul>
584 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800585media_status_t AImage_getPlaneRowStride(
586 const AImage* image, int planeIdx, /*out*/int32_t* rowStride);
587
Yin-Chia Yeh1d0955c2016-05-16 01:14:13 -0700588/**
589 * Get the data pointer of the input image for direct application access.
590 *
591 * <p>Note that once the {@link AImage} or the parent {@link AImageReader} is deleted, the data
592 * pointer from previous AImage_getPlaneData call becomes invalid. Do NOT use it after the
593 * {@link AImage} or the parent {@link AImageReader} is deleted.</p>
594 *
595 * @param image the {@link AImage} of interest.
596 * @param planeIdx the index of the plane. Must be less than the number of planes of input image.
597 * @param data the data pointer of the image will be filled here if the method call succeeeds.
598 * @param dataLength the valid length of data will be filled here if the method call succeeeds.
599 *
600 * @return <ul>
601 * <li>{@link AMEDIA_OK} if the method call succeeds.</li>
602 * <li>{@link AMEDIA_ERROR_INVALID_PARAMETER} if image, data or dataLength is NULL, or
603 * planeIdx is out of the range of [0, numOfPlanes - 1].</li>
604 * <li>{@link AMEDIA_ERROR_INVALID_OBJECT} if the {@link AImageReader} generated this
605 * image has been deleted.</li></ul>
606 */
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800607media_status_t AImage_getPlaneData(
608 const AImage* image, int planeIdx,
609 /*out*/uint8_t** data, /*out*/int* dataLength);
610
Dan Albert2975a242016-09-23 16:17:45 -0700611#endif /* __ANDROID_API__ >= 24 */
612
Yin-Chia Yehc3603822016-01-18 22:11:19 -0800613#ifdef __cplusplus
614} // extern "C"
615#endif
616
617#endif //_NDK_IMAGE_H
Yin-Chia Yeh3e49be12016-04-12 16:00:33 -0700618
619/** @} */