1a696f5d667227365da732481770767dcb330dd23Mathias Agopian/*
2a696f5d667227365da732481770767dcb330dd23Mathias Agopian * Copyright (C) 2010 The Android Open Source Project
3a696f5d667227365da732481770767dcb330dd23Mathias Agopian *
4a696f5d667227365da732481770767dcb330dd23Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
5a696f5d667227365da732481770767dcb330dd23Mathias Agopian * you may not use this file except in compliance with the License.
6a696f5d667227365da732481770767dcb330dd23Mathias Agopian * You may obtain a copy of the License at
7a696f5d667227365da732481770767dcb330dd23Mathias Agopian *
8a696f5d667227365da732481770767dcb330dd23Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
9a696f5d667227365da732481770767dcb330dd23Mathias Agopian *
10a696f5d667227365da732481770767dcb330dd23Mathias Agopian * Unless required by applicable law or agreed to in writing, software
11a696f5d667227365da732481770767dcb330dd23Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
12a696f5d667227365da732481770767dcb330dd23Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a696f5d667227365da732481770767dcb330dd23Mathias Agopian * See the License for the specific language governing permissions and
14a696f5d667227365da732481770767dcb330dd23Mathias Agopian * limitations under the License.
15a696f5d667227365da732481770767dcb330dd23Mathias Agopian */
16a696f5d667227365da732481770767dcb330dd23Mathias Agopian
17a696f5d667227365da732481770767dcb330dd23Mathias Agopianpackage android.graphics;
18a696f5d667227365da732481770767dcb330dd23Mathias Agopian
19058d0390a44f68b67788021bae9ca1775812997bMathias Agopianpublic class ImageFormat {
20525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /*
21525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * these constants are chosen to be binary compatible with their previous
22525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * location in PixelFormat.java
23525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
24a696f5d667227365da732481770767dcb330dd23Mathias Agopian
25525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int UNKNOWN = 0;
26a696f5d667227365da732481770767dcb330dd23Mathias Agopian
27525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
289184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * RGB format used for pictures encoded as RGB_565. See
29525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * {@link android.hardware.Camera.Parameters#setPictureFormat(int)}.
30525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
31525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int RGB_565 = 4;
32a696f5d667227365da732481770767dcb330dd23Mathias Agopian
33525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
349184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <p>Android YUV format.</p>
3558a7775d3e12efdc5aaaf19d0ac5e487d622cf36Mathias Agopian     *
369184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <p>This format is exposed to software decoders and applications.</p>
3758a7775d3e12efdc5aaaf19d0ac5e487d622cf36Mathias Agopian     *
389184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <p>YV12 is a 4:2:0 YCrCb planar format comprised of a WxH Y plane followed
399184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * by (W/2) x (H/2) Cr and Cb planes.</p>
4058a7775d3e12efdc5aaaf19d0ac5e487d622cf36Mathias Agopian     *
419184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <p>This format assumes
429184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <ul>
439184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <li>an even width</li>
449184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <li>an even height</li>
459184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <li>a horizontal stride multiple of 16 pixels</li>
469184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <li>a vertical stride equal to the height</li>
479184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * </ul>
489184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * </p>
4958a7775d3e12efdc5aaaf19d0ac5e487d622cf36Mathias Agopian     *
509184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * <pre> y_size = stride * height
51951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * c_stride = ALIGN(stride/2, 16)
52951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * c_size = c_stride * height/2
539184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * size = y_size + c_size * 2
549184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * cr_offset = y_size
559184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * cb_offset = y_size + c_size</pre>
5658a7775d3e12efdc5aaaf19d0ac5e487d622cf36Mathias Agopian     *
57b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
58b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * recommended for YUV output instead.</p>
59b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
60b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>For the older camera API, this format is guaranteed to be supported for
61b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * {@link android.hardware.Camera} preview images since API level 12; for earlier API versions,
62b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * check {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
63951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     *
64951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * <p>Note that for camera preview callback use (see
65951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * {@link android.hardware.Camera#setPreviewCallback}), the
66951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * <var>stride</var> value is the smallest possible; that is, it is equal
67951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * to:
68951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     *
69951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * <pre>stride = ALIGN(width, 16)</pre>
70951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     *
71951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * @see android.hardware.Camera.Parameters#setPreviewCallback
72951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * @see android.hardware.Camera.Parameters#setPreviewFormat
73951516358e2841d2425f610bcd0175d9960135d2Eino-Ville Talvala     * @see android.hardware.Camera.Parameters#getSupportedPreviewFormats
749184ec307be30719b2b7bfc3fb3e0a1365ccdf73Eino-Ville Talvala     * </p>
75525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
76525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int YV12 = 0x32315659;
77a696f5d667227365da732481770767dcb330dd23Mathias Agopian
78525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
791eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>Android Y8 format.</p>
801eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
811eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>Y8 is a YUV planar format comprised of a WxH Y plane only, with each pixel
821eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * being represented by 8 bits. It is equivalent to just the Y plane from {@link #YV12}
831eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * format.</p>
841eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
851eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>This format assumes
861eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <ul>
871eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <li>an even width</li>
881eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <li>an even height</li>
891eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <li>a horizontal stride multiple of 16 pixels</li>
901eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * </ul>
911eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * </p>
921eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
931eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <pre> y_size = stride * height </pre>
941eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
951eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>For example, the {@link android.media.Image} object can provide data
962f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * in this format from a {@link android.hardware.camera2.CameraDevice}
971eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * through a {@link android.media.ImageReader} object if this format is
982f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * supported by {@link android.hardware.camera2.CameraDevice}.</p>
991eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1001eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * @see android.media.Image
1011eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * @see android.media.ImageReader
1022f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * @see android.hardware.camera2.CameraDevice
1031eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1041eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * @hide
1051eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     */
1061eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He    public static final int Y8 = 0x20203859;
1071eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He
1081eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He    /**
1091eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>Android Y16 format.</p>
1101eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1111eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * Y16 is a YUV planar format comprised of a WxH Y plane, with each pixel
1121eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * being represented by 16 bits. It is just like {@link #Y8}, but has 16
1131eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * bits per pixel (little endian).</p>
1141eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1151eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>This format assumes
1161eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <ul>
1171eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <li>an even width</li>
1181eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <li>an even height</li>
1191eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <li>a horizontal stride multiple of 16 pixels</li>
1201eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * </ul>
1211eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * </p>
1221eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1231eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <pre> y_size = stride * height </pre>
1241eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1251eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * <p>For example, the {@link android.media.Image} object can provide data
1262f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * in this format from a {@link android.hardware.camera2.CameraDevice}
1271eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * through a {@link android.media.ImageReader} object if this format is
1282f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * supported by {@link android.hardware.camera2.CameraDevice}.</p>
1291eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1301eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * @see android.media.Image
1311eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * @see android.media.ImageReader
1322f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * @see android.hardware.camera2.CameraDevice
1331eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     *
1341eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     * @hide
1351eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He     */
1361eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He    public static final int Y16 = 0x20363159;
1371eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He
1381eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He    /**
139b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * YCbCr format, used for video.
140b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
141b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
142b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * recommended for YUV output instead.</p>
143b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
144b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>Whether this format is supported by the old camera API can be determined by
145b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.</p>
146b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
147525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
148525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int NV16 = 0x10;
149a696f5d667227365da732481770767dcb330dd23Mathias Agopian
150525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
151b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * YCrCb format used for images, which uses the NV21 encoding format.
152b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
153b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>This is the default format
154b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * for {@link android.hardware.Camera} preview images, when not otherwise set with
155b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.</p>
156b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
157b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
158b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * recommended for YUV output instead.</p>
159525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
160525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int NV21 = 0x11;
161a696f5d667227365da732481770767dcb330dd23Mathias Agopian
162525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
163525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * YCbCr format used for images, which uses YUYV (YUY2) encoding format.
164b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
165b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>For the {@link android.hardware.camera2} API, the {@link #YUV_420_888} format is
166b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * recommended for YUV output instead.</p>
167b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
168b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>This is an alternative format for {@link android.hardware.Camera} preview images. Whether
169b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * this format is supported by the camera hardware can be determined by
170b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.</p>
171525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
172525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int YUY2 = 0x14;
173a696f5d667227365da732481770767dcb330dd23Mathias Agopian
174525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
175b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * Compressed JPEG format.
176b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     *
177b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * <p>This format is always supported as an output format for the
178b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * {@link android.hardware.camera2} API, and as a picture format for the older
179b942b05093d2b1cee59ac73196a4b99962f10addEino-Ville Talvala     * {@link android.hardware.Camera} API</p>
180525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
181525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static final int JPEG = 0x100;
182a696f5d667227365da732481770767dcb330dd23Mathias Agopian
183525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    /**
184d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Multi-plane Android YUV 420 format</p>
185b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     *
186b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * <p>This format is a generic YCbCr format, capable of describing any 4:2:0
1877a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * chroma-subsampled planar or semiplanar buffer (but not fully interleaved),
1887a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * with 8 bits per color sample.</p>
189b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     *
190b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * <p>Images in this format are always represented by three separate buffers
191b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * of data, one for each color plane. Additional information always
192b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * accompanies the buffers, describing the row stride and the pixel stride
193b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * for each plane.</p>
194b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     *
1957a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * <p>The order of planes in the array returned by
1967a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that
1977a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr).</p>
1987a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     *
1997a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * <p>The Y-plane is guaranteed not to be interleaved with the U/V planes
2007a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * (in particular, pixel stride is always 1 in
2017a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * {@link android.media.Image.Plane#getPixelStride() yPlane.getPixelStride()}).</p>
2027a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     *
2037a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * <p>The U/V planes are guaranteed to have the same row stride and pixel stride
2047a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * (in particular,
2057a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * {@link android.media.Image.Plane#getRowStride() uPlane.getRowStride()}
2067a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * == {@link android.media.Image.Plane#getRowStride() vPlane.getRowStride()} and
2077a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * {@link android.media.Image.Plane#getPixelStride() uPlane.getPixelStride()}
2087a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * == {@link android.media.Image.Plane#getPixelStride() vPlane.getPixelStride()};
2097a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     * ).</p>
2107a600ff65fa79696a2668c7d33101b6ac6696f04Igor Murashkin     *
211b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * <p>For example, the {@link android.media.Image} object can provide data
2122f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * in this format from a {@link android.hardware.camera2.CameraDevice}
213b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * through a {@link android.media.ImageReader} object.</p>
214b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     *
215b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * @see android.media.Image
216b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * @see android.media.ImageReader
2172f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * @see android.hardware.camera2.CameraDevice
218b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     */
219b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala    public static final int YUV_420_888 = 0x23;
220b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala
221b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala    /**
222d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Multi-plane Android YUV 422 format</p>
223d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
224d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>This format is a generic YCbCr format, capable of describing any 4:2:2
225d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * chroma-subsampled (planar, semiplanar or interleaved) format,
226d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * with 8 bits per color sample.</p>
227d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
228d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Images in this format are always represented by three separate buffers
229d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * of data, one for each color plane. Additional information always
230d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * accompanies the buffers, describing the row stride and the pixel stride
231d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * for each plane.</p>
232d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
233d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>The order of planes in the array returned by
234d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that
235d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr).</p>
236d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
237d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>In contrast to the {@link #YUV_420_888} format, the Y-plane may have a pixel
238d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * stride greater than 1 in
239d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image.Plane#getPixelStride() yPlane.getPixelStride()}.</p>
240d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
241d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>The U/V planes are guaranteed to have the same row stride and pixel stride
242d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * (in particular,
243d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image.Plane#getRowStride() uPlane.getRowStride()}
244d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * == {@link android.media.Image.Plane#getRowStride() vPlane.getRowStride()} and
245d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image.Plane#getPixelStride() uPlane.getPixelStride()}
246d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * == {@link android.media.Image.Plane#getPixelStride() vPlane.getPixelStride()};
247d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * ).</p>
248d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
249d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>For example, the {@link android.media.Image} object can provide data
250d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * in this format from a {@link android.media.MediaCodec}
251d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * through {@link android.media.MediaCodec#getOutputImage} object.</p>
252d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
253d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.Image
254d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.MediaCodec
255d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     */
256d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    public static final int YUV_422_888 = 0x27;
257d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar
258d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    /**
259d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Multi-plane Android YUV 444 format</p>
260d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
261d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>This format is a generic YCbCr format, capable of describing any 4:4:4
262d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * (planar, semiplanar or interleaved) format,
263d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * with 8 bits per color sample.</p>
264d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
265d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Images in this format are always represented by three separate buffers
266d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * of data, one for each color plane. Additional information always
267d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * accompanies the buffers, describing the row stride and the pixel stride
268d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * for each plane.</p>
269d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
270d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>The order of planes in the array returned by
271d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that
272d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * plane #0 is always Y, plane #1 is always U (Cb), and plane #2 is always V (Cr).</p>
273d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
274d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>In contrast to the {@link #YUV_420_888} format, the Y-plane may have a pixel
275d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * stride greater than 1 in
276d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image.Plane#getPixelStride() yPlane.getPixelStride()}.</p>
277d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
278d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>The U/V planes are guaranteed to have the same row stride and pixel stride
279d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * (in particular,
280d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image.Plane#getRowStride() uPlane.getRowStride()}
281d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * == {@link android.media.Image.Plane#getRowStride() vPlane.getRowStride()} and
282d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image.Plane#getPixelStride() uPlane.getPixelStride()}
283d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * == {@link android.media.Image.Plane#getPixelStride() vPlane.getPixelStride()};
284d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * ).</p>
285d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
286d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>For example, the {@link android.media.Image} object can provide data
287d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * in this format from a {@link android.media.MediaCodec}
288d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * through {@link android.media.MediaCodec#getOutputImage} object.</p>
289d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
290d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.Image
291d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.MediaCodec
292d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     */
293d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    public static final int YUV_444_888 = 0x28;
294d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar
295d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    /**
296d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Multi-plane Android RGB format</p>
297d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
298d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>This format is a generic RGB format, capable of describing most RGB formats,
299d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * with 8 bits per color sample.</p>
300d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
301d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Images in this format are always represented by three separate buffers
302d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * of data, one for each color plane. Additional information always
303d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * accompanies the buffers, describing the row stride and the pixel stride
304d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * for each plane.</p>
305d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
306d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>The order of planes in the array returned by
307d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that
308d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * plane #0 is always R (red), plane #1 is always G (green), and plane #2 is always B
309d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * (blue).</p>
310d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
311d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>All three planes are guaranteed to have the same row strides and pixel strides.</p>
312d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
313d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>For example, the {@link android.media.Image} object can provide data
314d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * in this format from a {@link android.media.MediaCodec}
315d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * through {@link android.media.MediaCodec#getOutputImage} object.</p>
316d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
317d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.Image
318d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.MediaCodec
319d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     */
320d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    public static final int FLEX_RGB_888 = 0x29;
321d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar
322d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    /**
323d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Multi-plane Android RGBA format</p>
324d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
325d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>This format is a generic RGBA format, capable of describing most RGBA formats,
326d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * with 8 bits per color sample.</p>
327d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
328d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>Images in this format are always represented by four separate buffers
329d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * of data, one for each color plane. Additional information always
330d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * accompanies the buffers, describing the row stride and the pixel stride
331d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * for each plane.</p>
332d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
333d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>The order of planes in the array returned by
334d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * {@link android.media.Image#getPlanes() Image#getPlanes()} is guaranteed such that
335d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * plane #0 is always R (red), plane #1 is always G (green), plane #2 is always B (blue),
336d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * and plane #3 is always A (alpha). This format may represent pre-multiplied or
337d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * non-premultiplied alpha.</p>
338d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
339d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>All four planes are guaranteed to have the same row strides and pixel strides.</p>
340d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
341d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * <p>For example, the {@link android.media.Image} object can provide data
342d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * in this format from a {@link android.media.MediaCodec}
343d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * through {@link android.media.MediaCodec#getOutputImage} object.</p>
344d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     *
345d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.Image
346d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     * @see android.media.MediaCodec
347d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar     */
348d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    public static final int FLEX_RGBA_8888 = 0x2A;
349d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar
350d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar    /**
351b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * <p>General raw camera sensor image format, usually representing a
352b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * single-channel Bayer-mosaic image. Each pixel color sample is stored with
353b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * 16 bits of precision.</p>
354b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     *
355b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * <p>The layout of the color mosaic, the maximum and minimum encoding
356b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * values of the raw pixel data, the color space of the image, and all other
357b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * needed information to interpret a raw sensor image must be queried from
3582f1a2e423e0fbb64467d6fcfa4e82c6384f31210Eino-Ville Talvala     * the {@link android.hardware.camera2.CameraDevice} which produced the
359b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     * image.</p>
360b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala     */
3611eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He    public static final int RAW_SENSOR = 0x20;
362b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala
363b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala    /**
36444581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     * <p>Private raw camera sensor image format, a single channel image with
36544581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     * implementation depedent pixel layout.</p>
36644581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     *
36744581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     * <p>RAW_PRIVATE is a format for unprocessed raw image buffers coming from an
36844581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     * image sensor. The actual structure of buffers of this format is
36944581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     * implementation-dependent.</p>
37044581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     *
37144581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh     */
37244581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh    public static final int RAW_PRIVATE = 0x24;
37344581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh
37444581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh    /**
375d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <p>
376d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * Android 10-bit raw format
377d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </p>
378d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <p>
3794c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * This is a single-plane, 10-bit per pixel, densely packed (in each row),
3804c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * unprocessed format, usually representing raw Bayer-pattern images coming
3814c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * from an image sensor.
382d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </p>
383d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <p>
3844c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * In an image buffer with this format, starting from the first pixel of
3854c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * each row, each 4 consecutive pixels are packed into 5 bytes (40 bits).
3864c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * Each one of the first 4 bytes contains the top 8 bits of each pixel, The
3874c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * fifth byte contains the 2 least significant bits of the 4 pixels, the
3884c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * exact layout data for each 4 consecutive pixels is illustrated below
3894c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * ({@code Pi[j]} stands for the jth bit of the ith pixel):
390d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </p>
391d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <table>
392d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <thead>
393d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <tr>
394d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center"></th>
395d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 7</th>
396d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 6</th>
397d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 5</th>
398d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 4</th>
399d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 3</th>
400d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 2</th>
401d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 1</th>
402d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <th align="center">bit 0</th>
403d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tr>
404d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </thead> <tbody>
405d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <tr>
406d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">Byte 0:</td>
407d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[9]</td>
408d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[8]</td>
409d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[7]</td>
410d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[6]</td>
411d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[5]</td>
412d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[4]</td>
413d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[3]</td>
414d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[2]</td>
415d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tr>
416d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <tr>
417d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">Byte 1:</td>
418d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[9]</td>
419d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[8]</td>
420d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[7]</td>
421d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[6]</td>
422d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[5]</td>
423d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[4]</td>
424d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[3]</td>
425d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[2]</td>
426d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tr>
427d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <tr>
428d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">Byte 2:</td>
429d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[9]</td>
430d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[8]</td>
431d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[7]</td>
432d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[6]</td>
433d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[5]</td>
434d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[4]</td>
435d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[3]</td>
436d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[2]</td>
437d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tr>
438d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <tr>
439d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">Byte 3:</td>
440d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[9]</td>
441d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[8]</td>
442d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[7]</td>
443d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[6]</td>
444d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[5]</td>
445d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[4]</td>
446d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[3]</td>
447d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[2]</td>
448d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tr>
449d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <tr>
450d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">Byte 4:</td>
451d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[1]</td>
452d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P3[0]</td>
453d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[1]</td>
454d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P2[0]</td>
455d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[1]</td>
456d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P1[0]</td>
457d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[1]</td>
458d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <td align="center">P0[0]</td>
459d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tr>
460d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </tbody>
461d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </table>
462d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <p>
463d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * This format assumes
464d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <ul>
465d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <li>a width multiple of 4 pixels</li>
466d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <li>an even height</li>
467d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </ul>
468d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </p>
469d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     *
4704c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
4714c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * not pixels.
4724c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     *
473d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <p>
4744c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * Since this is a densely packed format, the pixel stride is always 0. The
4754c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * application must use the pixel data layout defined in above table to
4764c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * access each row data. When row stride is equal to {@code width * (10 / 8)}, there
4774c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * will be no padding bytes at the end of each row, the entire image data is
4784c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * densely packed. When stride is larger than {@code width * (10 / 8)}, padding
4794c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * bytes will be present at the end of each row.
480d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </p>
481d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * <p>
482d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * For example, the {@link android.media.Image} object can provide data in
4834c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * this format from a {@link android.hardware.camera2.CameraDevice} (if
4844c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * supported) through a {@link android.media.ImageReader} object. The
485d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * {@link android.media.Image#getPlanes() Image#getPlanes()} will return a
4864c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * single plane containing the pixel data. The pixel stride is always 0 in
4874c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * {@link android.media.Image.Plane#getPixelStride()}, and the
4884c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * {@link android.media.Image.Plane#getRowStride()} describes the vertical
4894c4064fa66f551f49b7e1017b1ebe65a05f9df21Zhijun He     * neighboring pixel distance (in bytes) between adjacent rows.
490d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * </p>
491d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     *
492d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * @see android.media.Image
493d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * @see android.media.ImageReader
494d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     * @see android.hardware.camera2.CameraDevice
495d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He     */
496d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He    public static final int RAW10 = 0x25;
497d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He
498d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He    /**
49911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <p>
50011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * Android 12-bit raw format
50111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </p>
50211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <p>
50311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * This is a single-plane, 12-bit per pixel, densely packed (in each row),
50411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * unprocessed format, usually representing raw Bayer-pattern images coming
50511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * from an image sensor.
50611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </p>
50711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <p>
50811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * In an image buffer with this format, starting from the first pixel of each
50911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * row, each two consecutive pixels are packed into 3 bytes (24 bits). The first
51011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * and second byte contains the top 8 bits of first and second pixel. The third
51111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * byte contains the 4 least significant bits of the two pixels, the exact layout
51211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * data for each two consecutive pixels is illustrated below (Pi[j] stands for
51311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * the jth bit of the ith pixel):
51411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </p>
51511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <table>
51611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <thead>
51711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <tr>
51811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center"></th>
51911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 7</th>
52011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 6</th>
52111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 5</th>
52211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 4</th>
52311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 3</th>
52411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 2</th>
52511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 1</th>
52611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <th align="center">bit 0</th>
52711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </tr>
52811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </thead> <tbody>
52911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <tr>
53011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">Byte 0:</td>
53111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[11]</td>
53211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[10]</td>
53311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 9]</td>
53411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 8]</td>
53511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 7]</td>
53611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 6]</td>
53711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 5]</td>
53811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 4]</td>
53911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </tr>
54011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <tr>
54111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">Byte 1:</td>
54211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[11]</td>
54311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[10]</td>
54411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 9]</td>
54511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 8]</td>
54611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 7]</td>
54711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 6]</td>
54811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 5]</td>
54911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 4]</td>
55011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </tr>
55111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <tr>
55211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">Byte 2:</td>
55311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 3]</td>
55411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 2]</td>
55511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 1]</td>
55611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P1[ 0]</td>
55711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 3]</td>
55811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 2]</td>
55911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 1]</td>
56011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <td align="center">P0[ 0]</td>
56111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </tr>
56211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </tbody>
56311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </table>
56411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <p>
56511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * This format assumes
56611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <ul>
56711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <li>a width multiple of 4 pixels</li>
56811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <li>an even height</li>
56911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </ul>
57011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </p>
57111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     *
57211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <pre>size = row stride * height</pre> where the row stride is in <em>bytes</em>,
57311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * not pixels.
57411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     *
57511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <p>
57611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * Since this is a densely packed format, the pixel stride is always 0. The
57711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * application must use the pixel data layout defined in above table to
57811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * access each row data. When row stride is equal to {@code width * (12 / 8)}, there
57911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * will be no padding bytes at the end of each row, the entire image data is
58011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * densely packed. When stride is larger than {@code width * (12 / 8)}, padding
58111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * bytes will be present at the end of each row.
58211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </p>
58311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * <p>
58411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * For example, the {@link android.media.Image} object can provide data in
58511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * this format from a {@link android.hardware.camera2.CameraDevice} (if
58611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * supported) through a {@link android.media.ImageReader} object. The
58711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * {@link android.media.Image#getPlanes() Image#getPlanes()} will return a
58811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * single plane containing the pixel data. The pixel stride is always 0 in
58911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * {@link android.media.Image.Plane#getPixelStride()}, and the
59011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * {@link android.media.Image.Plane#getRowStride()} describes the vertical
59111d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * neighboring pixel distance (in bytes) between adjacent rows.
59211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * </p>
59311d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     *
59411d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * @see android.media.Image
59511d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * @see android.media.ImageReader
59611d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     * @see android.hardware.camera2.CameraDevice
59711d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh     */
59811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh    public static final int RAW12 = 0x26;
59911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh
60011d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh    /**
601eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>Android dense depth image format.</p>
602eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *
603eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>Each pixel is 16 bits, representing a depth ranging measurement from a depth camera or
604eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * similar sensor. The 16-bit sample consists of a confidence value and the actual ranging
605eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * measurement.</p>
606eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *
607eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>The confidence value is an estimate of correctness for this sample.  It is encoded in the
608eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * 3 most significant bits of the sample, with a value of 0 representing 100% confidence, a
609eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * value of 1 representing 0% confidence, a value of 2 representing 1/7, a value of 3
610eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * representing 2/7, and so on.</p>
611eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *
612eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>As an example, the following sample extracts the range and confidence from the first pixel
613eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * of a DEPTH16-format {@link android.media.Image}, and converts the confidence to a
614eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * floating-point value between 0 and 1.f inclusive, with 1.f representing maximum confidence:
615eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *
616eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <pre>
617eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    ShortBuffer shortDepthBuffer = img.getPlanes()[0].getBuffer().asShortBuffer();
618eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    short depthSample = shortDepthBuffer.get()
619eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    short depthRange = (short) (depthSample & 0x1FFF);
620eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    short depthConfidence = (short) ((depthSample >> 13) & 0x7);
621eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    float depthPercentage = depthConfidence == 0 ? 1.f : (depthConfidence - 1) / 7.f;
622eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * </pre>
623eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * </p>
624805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     *
625805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * <p>This format assumes
626805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * <ul>
627805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * <li>an even width</li>
628805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * <li>an even height</li>
629805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * <li>a horizontal stride multiple of 16 pixels</li>
630805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * </ul>
631805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * </p>
632805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     *
633805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * <pre> y_size = stride * height </pre>
634805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     *
635eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * When produced by a camera, the units for the range are millimeters.
636805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     */
637805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala    public static final int DEPTH16 = 0x44363159;
638805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala
639805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala    /**
640805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     * Android sparse depth point cloud format.
641805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     *
642eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>A variable-length list of 3D points plus a confidence value, with each point represented
643eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * by four floats; first the X, Y, Z position coordinates, and then the confidence value.</p>
644eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *
645eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>The number of points is {@code (size of the buffer in bytes) / 16}.
646eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *
647eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>The coordinate system and units of the position values depend on the source of the point
648eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * cloud data. The confidence value is between 0.f and 1.f, inclusive, with 0 representing 0%
649eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * confidence and 1.f representing 100% confidence in the measured position values.</p>
650805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     *
651eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <p>As an example, the following code extracts the first depth point in a DEPTH_POINT_CLOUD
652eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * format {@link android.media.Image}:
653eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * <pre>
654eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    FloatBuffer floatDepthBuffer = img.getPlanes()[0].getBuffer().asFloatBuffer();
655eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    float x = floatDepthBuffer.get();
656eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    float y = floatDepthBuffer.get();
657eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    float z = floatDepthBuffer.get();
658eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     *    float confidence = floatDepthBuffer.get();
659eebb83493418d8dcd82f33919c41b9a5d2ec898aEino-Ville Talvala     * </pre>
660805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     *
6613e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * For camera devices that support the
6623e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * {@link android.hardware.camera2.CameraCharacteristics#REQUEST_AVAILABLE_CAPABILITIES_DEPTH_OUTPUT DEPTH_OUTPUT}
6633e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * capability, DEPTH_POINT_CLOUD coordinates have units of meters, and the coordinate system is
6643e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * defined by the camera's pose transforms:
6653e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * {@link android.hardware.camera2.CameraCharacteristics#LENS_POSE_TRANSLATION} and
6663e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * {@link android.hardware.camera2.CameraCharacteristics#LENS_POSE_ROTATION}. That means the origin is
6673e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * the optical center of the camera device, and the positive Z axis points along the camera's optical axis,
6683e99a5fcb98070b6794a50a788e7ffc74ba832deEino-Ville Talvala     * toward the scene.
669805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala     */
670805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala    public static final int DEPTH_POINT_CLOUD = 0x101;
671805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala
672805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala    /**
673f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev     * Unprocessed implementation-dependent raw
674f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev     * depth measurements, opaque with 16 bit
675f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev     * samples.
676f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev     *
677f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev     * @hide
678f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev     */
679f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev    public static final int RAW_DEPTH = 0x1002;
680f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev
681f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev    /**
6822f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * Android private opaque image format.
6832f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * <p>
6842f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * The choices of the actual format and pixel data layout are entirely up to
6852f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * the device-specific and framework internal implementations, and may vary
6862f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * depending on use cases even for the same device. The buffers of this
6872f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * format can be produced by components like
6882f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * {@link android.media.ImageWriter ImageWriter} , and interpreted correctly
6892f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * by consumers like {@link android.hardware.camera2.CameraDevice
6902f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * CameraDevice} based on the device/framework private information. However,
6912f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * these buffers are not directly accessible to the application.
6922f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * </p>
6932f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * <p>
6942f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * When an {@link android.media.Image Image} of this format is obtained from
6952f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * an {@link android.media.ImageReader ImageReader} or
6962f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * {@link android.media.ImageWriter ImageWriter}, the
6972f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * {@link android.media.Image#getPlanes() getPlanes()} method will return an
6982f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * empty {@link android.media.Image.Plane Plane} array.
6992f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * </p>
7002f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * <p>
7012f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * If a buffer of this format is to be used as an OpenGL ES texture, the
7022f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * framework will assume that sampling the texture will always return an
7032f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * alpha value of 1.0 (i.e. the buffer contains only opaque pixel values).
7042f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     * </p>
7052f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He     */
7062f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He    public static final int PRIVATE = 0x22;
7072f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He
7082f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He    /**
709525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * Use this function to retrieve the number of bits per pixel of an
710525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * ImageFormat.
71170fb9085044c5e6f52c33c970d238b764cf2373bWu-cheng Li     *
712525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * @param format
713525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     * @return the number of bits per pixel of the given format or -1 if the
714525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     *         format doesn't exist or is not supported.
715525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian     */
716525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    public static int getBitsPerPixel(int format) {
717525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian        switch (format) {
718525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian            case RGB_565:
719525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian                return 16;
720525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian            case NV16:
721525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian                return 16;
722525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian            case YUY2:
723525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian                return 16;
724525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian            case YV12:
725525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian                return 12;
7261eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He            case Y8:
7271eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He                return 8;
7281eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He            case Y16:
729805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala            case DEPTH16:
7301eb818e5b3481ee1c9722ad6b7bd925afdadb441Zhijun He                return 16;
731525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian            case NV21:
732525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian                return 12;
733b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala            case YUV_420_888:
734b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala                return 12;
735d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case YUV_422_888:
736d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar                return 16;
737d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case YUV_444_888:
738d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar                return 24;
739d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case FLEX_RGB_888:
740d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar                return 24;
741d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case FLEX_RGBA_8888:
742d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar                return 32;
743f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev            case RAW_DEPTH:
744b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala            case RAW_SENSOR:
745b2675542c2f414154125b534767ae0903fba581eEino-Ville Talvala                return 16;
746d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He            case RAW10:
747d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He                return 10;
74811d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh            case RAW12:
74911d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh                return 12;
750525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian        }
751525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian        return -1;
752525af5d5b0fcd4de9bac2f4be016cdd2f3534a40Mathias Agopian    }
75394814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin
75494814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin    /**
75594814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     * Determine whether or not this is a public-visible {@code format}.
75694814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     *
75794814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     * <p>In particular, {@code @hide} formats will return {@code false}.</p>
75894814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     *
75994814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     * <p>Any other formats (including UNKNOWN) will return {@code false}.</p>
76094814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     *
76194814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     * @param format an integer format
76294814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     * @return a boolean
76394814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     *
76494814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     * @hide
76594814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin     */
76694814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin    public static boolean isPublicFormat(int format) {
76794814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin        switch (format) {
76894814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case RGB_565:
76994814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case NV16:
77094814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case YUY2:
77194814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case YV12:
7729c595174ccaaf3d36315c4a100e47ee4369073f6Igor Murashkin            case JPEG:
77394814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case NV21:
77494814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case YUV_420_888:
775d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case YUV_422_888:
776d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case YUV_444_888:
777d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case FLEX_RGB_888:
778d1d27c1543a2de464938c068115f2f8dfa5b790aLajos Molnar            case FLEX_RGBA_8888:
77994814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin            case RAW_SENSOR:
78044581ff4db54bbaa30365ed210e67a0369576100Yin-Chia Yeh            case RAW_PRIVATE:
781d1988a98ed69db8c33b77b5c085ab91d22ef3bbcZhijun He            case RAW10:
78211d444f0b789ead8b10506d24956d243274c724bYin-Chia Yeh            case RAW12:
783805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala            case DEPTH16:
784805f3c9428f9ebd5080aec48d3d9d77dbf4b41a9Eino-Ville Talvala            case DEPTH_POINT_CLOUD:
7852f17431194efc5a13981550b004dd8d5d2a42e5eZhijun He            case PRIVATE:
786f7fec7397e37657d08ec6a8c1c214c1f90a77bfdEmilian Peev            case RAW_DEPTH:
78794814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin                return true;
78894814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin        }
78994814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin
79094814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin        return false;
79194814218d2313a989a5a8969f633e3fc33e43071Igor Murashkin    }
792a696f5d667227365da732481770767dcb330dd23Mathias Agopian}
793