Commit | Line | Data |
---|---|---|
5763fb39 T |
1 | /* |
2 | * Copyright Samsung Electronics Co.,LTD. | |
3 | * Copyright (C) 2015 The Android Open Source Project | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | #ifndef __HARDWARE_SAMSUNG_EXYNOS_HWJPEGDECOMPRESSOR_H__ | |
19 | #define __HARDWARE_SAMSUNG_EXYNOS_HWJPEGDECOMPRESSOR_H__ | |
20 | ||
21 | #ifdef __cplusplus | |
22 | extern "C" { | |
23 | ||
24 | /* | |
25 | * hwjpeg_decompress_ptr - handle of decompressor instance | |
26 | */ | |
27 | typedef struct hwjpeg_decompressor_struct { | |
28 | unsigned int image_width; /* width of the compressed image */ | |
29 | unsigned int image_height; /* height of the compressed image */ | |
30 | unsigned char num_components; /* number of components of the compressed image */ | |
31 | unsigned char chroma_h_samp_factor; /* horizontal chroma sampling factor of the compressed image */ | |
32 | unsigned char chroma_v_samp_factor; /* vertical chroma sampling factor of the compressed image */ | |
33 | unsigned char scale_factor; /* down-scaling factor during decompression: one of 1, 2, 4 and 8 */ | |
34 | ||
35 | unsigned int output_width; /* width of the output image (image_width/scale_factor) */ | |
36 | unsigned int output_height; /* height of the output image (image_height/scale_factor) */ | |
37 | __u32 output_format; /* 4CC style format identifier of the output image defined in videodev2.h */ | |
38 | } *hwjpeg_decompress_ptr; | |
39 | ||
40 | /* | |
41 | * hwjpeg_create_decompress - create an instance of decompressor | |
42 | * | |
43 | * @return: the handle of the decompressor instance. NULL on failure. | |
44 | * | |
45 | * The decompresson process starts from calling this function. The return value | |
46 | * is the handle of the decompressor instance. Every step of the decompression | |
47 | * process needs the handle. The handle should be destroyed with | |
48 | * hwjpeg_destroy_decompress() when it is no longer required. | |
49 | */ | |
50 | hwjpeg_decompress_ptr hwjpeg_create_decompress(void); | |
51 | ||
52 | /* | |
53 | * hwjpeg_file_src - configure the path to a file of compressed JPEG stream | |
54 | * | |
55 | * @cinfo: decompressor instance handle | |
56 | * @path: path to the file of compressed JPEG stream. | |
57 | * It is assumed that EOI is at the end of the file. | |
58 | * @return: false on failure | |
59 | */ | |
60 | bool hwjpeg_file_src(hwjpeg_decompress_ptr cinfo, const char *path); | |
61 | ||
62 | /* | |
63 | * hwjpeg_dmabuf_src - configure the buffer file descriptor that contains the compressed JPEG stream | |
64 | * | |
65 | * @cinfo: decompressor instance handle | |
66 | * @infd: the file descriptor exported by ION of the buffer that contains the compressed JPEG stream | |
67 | * @insize: the length in bytes of @infd. It is assumed that EOI is at the end of the buffer. | |
68 | * @dummybytes: The available dummy bytes after @insize. | |
69 | * @return: false on failure | |
70 | */ | |
71 | bool hwjpeg_dmabuf_src(hwjpeg_decompress_ptr cinfo, int infd, size_t insize, size_t dummybytes); | |
72 | ||
73 | /* | |
74 | * hwjpeg_mem_src - configure the buffer that contains the compressed JPEG stream | |
75 | * | |
76 | * @cinfo: decompressor instance handle | |
77 | * @inbuffer: the address of the buffer that contains the compressed JPEG stream | |
78 | * @insize: the length in bytes of @inbuffer. It is assumed that EOI is at the end of the buffer. | |
79 | * @dummybytes: The available dummy bytes after @insize. | |
80 | * @return: false on failure | |
81 | */ | |
82 | bool hwjpeg_mem_src(hwjpeg_decompress_ptr cinfo, unsigned char *inbuffer, size_t insize, size_t dummybytes); | |
83 | ||
84 | /* | |
85 | * hwjpeg_config_image_format - configure output image format | |
86 | * | |
87 | * @cinfo: decompressor instance handle | |
88 | * @v4l2_pix_fmt: fourcc format identifier defined in linux/videodev2.h | |
89 | */ | |
90 | void hwjpeg_config_image_format(hwjpeg_decompress_ptr cinfo, __u32 v4l2_pix_fmt); | |
91 | ||
92 | /* | |
93 | * hwjpeg_mem_dst - configure the buffer to store decompressed image | |
94 | * | |
95 | * @cinfo: decompressor instance handle | |
96 | * @outbuffer: The array of addresses of the buffers to stroe decompressed image | |
97 | * The maximum number of elements of @outbuffer is 3. The number of elements | |
98 | * of @outbuffer depends on the image format configured by hwjpeg_config_image_format(). | |
99 | * @outsize: The lengths in bytes of the buffers of @outbuffer. | |
100 | * @num_buffers: The number of elements in @outsizes and @outbuffer | |
101 | * @return: false on failure. | |
102 | */ | |
103 | bool hwjpeg_mem_dst(hwjpeg_decompress_ptr cinfo, unsigned char *outbuffer[], size_t outsize[], unsigned int num_buffers); | |
104 | ||
105 | /* | |
106 | * hwjpeg_dmabuf_dst - configure the buffer to store decompressed image | |
107 | * | |
108 | * @cinfo: decompressor instance handle | |
109 | * @outfd: The array of file descriptors exported by ION of the buffers to stroe decompressed image | |
110 | * The maximum number of elements of @outfd is 3. The number of elements of @outfd depends | |
111 | * on the image format configured by hwjpeg_config_image_format(). | |
112 | * @outsizes: The lengths in bytes of the buffers of @outfd. | |
113 | * @num_buffers: The number of elements in @outsizes and @outfd | |
114 | * @return: false on failure. | |
115 | */ | |
116 | bool hwjpeg_dmabuf_dst(hwjpeg_decompress_ptr cinfo, int outfd[], size_t outsize[], unsigned int num_buffers); | |
117 | ||
118 | /* | |
119 | * hwjpeg_set_downscale_factor - configure the downscaling factor during decompression | |
120 | * | |
121 | * @cinfo: decompressor instance handle | |
122 | * @factor: downscaling factor. @factor should be one of 1, 2, 4 and 8. | |
123 | * | |
124 | * Downscaling factor is the inverse number of the downscaling ratio. @cinfo->output_width and | |
125 | * @cinfo->output_height is decided by @factor. | |
126 | * - @cinfo->output_width = @cinfo->image_width / @factor | |
127 | * - @cinfo->output_height = @cinfo->image_height / @factor | |
128 | * Note that both of @cinfo->image_width / @factor and @cinfo->image_height / @factor | |
129 | * should be also integers. The results should be also even number according to the | |
130 | * output image format configured by hwjpeg_config_image_format(). | |
131 | * Otherwise, the decompression will fail. | |
132 | */ | |
133 | void hwjpeg_set_downscale_factor(hwjpeg_decompress_ptr cinfo, unsigned int factor); | |
134 | ||
135 | /* | |
136 | * hwjpeg_read_header - reads the headers of the compressed JPEG stream | |
137 | * | |
138 | * @cinfo: decompressor instance handle | |
139 | * @return: false on failure. | |
140 | * | |
141 | * NOTE that the fields of hwjpeg_decompression_ptr is available after hwjpeg_read_header() | |
142 | * returns true. | |
143 | */ | |
144 | bool hwjpeg_read_header(hwjpeg_decompress_ptr cinfo); | |
145 | ||
146 | /* | |
147 | * hwjpeg_has_enough_stream_buffer - Confirm if the stream buffer is enough | |
148 | * | |
149 | * @cinfo: decompressor instance handle | |
150 | * @return: true if the stream buffer is enough to decompress by H/W | |
151 | * | |
152 | * This function should be called after hwjpeg_read_header() is called | |
153 | * successfully. | |
154 | */ | |
155 | bool hwjpeg_has_enough_stream_buffer(hwjpeg_decompress_ptr cinfo); | |
156 | ||
157 | /* | |
158 | * hwjpeg_start_decompress - starts decompression | |
159 | * | |
160 | * @cinfo: decompressor instance handle | |
161 | * @return: false on failure. | |
162 | * | |
163 | * This function blocks until the decompression finishes. | |
164 | */ | |
165 | bool hwjpeg_start_decompress(hwjpeg_decompress_ptr cinfo); | |
166 | ||
167 | /* | |
168 | * hwjpeg_destroy_decompress - releases all resources of the decompressor instance | |
169 | * | |
170 | * @cinfo: decompressor instance handle to destroy | |
171 | */ | |
172 | void hwjpeg_destroy_decompress(hwjpeg_decompress_ptr cinfo); | |
173 | ||
174 | }; /* extern "C" */ | |
175 | #endif /* __cplusplus */ | |
176 | ||
177 | #endif /*__HARDWARE_SAMSUNG_EXYNOS7420_HWJPEGDECOMPRESSOR_H__*/ |