1 /*
2  * Copyright (C) 2022 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 
17 #ifndef HARDWARE_GOOGLE_CAMERA_HAL_UTILS_CAMERA_BLOB_H_
18 #define HARDWARE_GOOGLE_CAMERA_HAL_UTILS_CAMERA_BLOB_H_
19 
20 #include <cstdint>
21 
22 namespace android {
23 namespace google_camera_hal {
24 
25 /**
26  * CameraBlob:
27  *
28  * Transport header for camera blob types; generally compressed JPEG buffers in
29  * output streams.
30  *
31  * To capture JPEG images, a stream is created using the pixel format
32  * HAL_PIXEL_FORMAT_BLOB and dataspace HAL_DATASPACE_V0_JFIF. The buffer size
33  * for the stream is calculated by the framework, based on the static metadata
34  * field android.jpeg.maxSize. Since compressed JPEG images are of variable
35  * size, the HAL needs to include the final size of the compressed image using
36  * this structure inside the output stream buffer. The camera blob ID field must
37  * be set to CameraBlobId::JPEG.
38  *
39  * The transport header must be at the end of the JPEG output stream
40  * buffer. That means the jpegBlobId must start at byte[buffer_size -
41  * sizeof(CameraBlob)], where the buffer_size is the size of gralloc
42  * buffer. Any HAL using this transport header must account for it in
43  * android.jpeg.maxSize. The JPEG data itself starts at the beginning of the
44  * buffer and must be blobSize bytes long.
45  *
46  * Copied from hardware/interfaces/camera/device/aidl/CameraBlobId.aidl
47  */
48 enum CameraBlobId : uint32_t {
49   JPEG = 0x00FF,
50 };
51 
52 struct CameraBlob {
53   CameraBlobId blob_id;
54   uint32_t blob_size;
55 };
56 
57 }  // namespace google_camera_hal
58 }  // namespace android
59 
60 #endif  // HARDWARE_GOOGLE_CAMERA_HAL_UTILS_CAMERA_BLOB_H_
61