Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 1 | /* |
| 2 | * test_cl_image.cpp - test cl image |
| 3 | * |
| 4 | * Copyright (c) 2014-2015 Intel Corporation |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | * |
| 18 | * Author: Wind Yuan <feng.yuan@intel.com> |
| 19 | */ |
| 20 | |
| 21 | #include "test_common.h" |
| 22 | #include "cl_device.h" |
| 23 | #include "cl_context.h" |
| 24 | #include "cl_demo_handler.h" |
wangfei | 1198746 | 2015-03-12 15:02:57 +0800 | [diff] [blame] | 25 | #include "cl_hdr_handler.h" |
ShincyTu | 5710f97 | 2015-03-23 23:20:44 +0800 | [diff] [blame] | 26 | #include "cl_blc_handler.h" |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 27 | #include "drm_bo_buffer.h" |
Wind Yuan | 5c96d9f | 2015-03-18 15:32:37 +0800 | [diff] [blame] | 28 | #include "cl_demosaic_handler.h" |
wangfei | 6ea2221 | 2015-03-23 19:10:26 +0800 | [diff] [blame] | 29 | #include "cl_csc_handler.h" |
wangfei | 9842835 | 2015-04-02 10:41:27 +0800 | [diff] [blame] | 30 | #include "cl_wb_handler.h" |
Juan Zhao | ab5e6fe | 2015-04-08 14:12:46 +0800 | [diff] [blame] | 31 | #include "cl_denoise_handler.h" |
wangfei | 7e0436e | 2015-04-15 19:22:36 +0800 | [diff] [blame] | 32 | #include "cl_gamma_handler.h" |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 33 | |
| 34 | using namespace XCam; |
| 35 | |
| 36 | enum TestHandlerType { |
| 37 | TestHandlerUnknown = 0, |
| 38 | TestHandlerDemo, |
| 39 | TestHandlerBlackLevel, |
| 40 | TestHandlerDefect, |
Wind Yuan | 5c96d9f | 2015-03-18 15:32:37 +0800 | [diff] [blame] | 41 | TestHandlerDemosaic, |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 42 | TestHandlerColorConversion, |
| 43 | TestHandlerHDR, |
wangfei | 9842835 | 2015-04-02 10:41:27 +0800 | [diff] [blame] | 44 | TestHandlerWhiteBalance, |
Juan Zhao | ab5e6fe | 2015-04-08 14:12:46 +0800 | [diff] [blame] | 45 | TestHandlerDenoise, |
wangfei | 7e0436e | 2015-04-15 19:22:36 +0800 | [diff] [blame] | 46 | TestHandlerGamma, |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct TestFileHandle { |
| 50 | FILE *fp; |
| 51 | TestFileHandle () |
| 52 | : fp (NULL) |
| 53 | {} |
| 54 | ~TestFileHandle () |
| 55 | { |
| 56 | if (fp) |
| 57 | fclose (fp); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | static XCamReturn |
| 62 | read_buf (SmartPtr<DrmBoBuffer> &buf, TestFileHandle &file) |
| 63 | { |
| 64 | const VideoBufferInfo info = buf->get_video_info (); |
| 65 | uint8_t *memory = NULL; |
| 66 | XCamReturn ret = XCAM_RETURN_NO_ERROR; |
| 67 | |
| 68 | memory = buf->map (); |
| 69 | if (fread (memory, 1, info.size, file.fp) != info.size) { |
| 70 | if (feof (file.fp)) |
| 71 | ret = XCAM_RETURN_BYPASS; |
| 72 | else { |
| 73 | XCAM_LOG_ERROR ("read file failed, size doesn't match"); |
| 74 | ret = XCAM_RETURN_ERROR_FILE; |
| 75 | } |
| 76 | } |
| 77 | buf->unmap (); |
| 78 | return ret; |
| 79 | } |
| 80 | |
| 81 | static XCamReturn |
| 82 | write_buf (SmartPtr<DrmBoBuffer> &buf, TestFileHandle &file) |
| 83 | { |
| 84 | const VideoBufferInfo info = buf->get_video_info (); |
| 85 | uint8_t *memory = NULL; |
| 86 | XCamReturn ret = XCAM_RETURN_NO_ERROR; |
| 87 | |
| 88 | memory = buf->map (); |
| 89 | if (fwrite (memory, 1, info.size, file.fp) != info.size) { |
| 90 | XCAM_LOG_ERROR ("read file failed, size doesn't match"); |
| 91 | ret = XCAM_RETURN_ERROR_FILE; |
| 92 | } |
| 93 | buf->unmap (); |
| 94 | return ret; |
| 95 | } |
| 96 | |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 97 | static XCamReturn |
| 98 | kernel_loop(SmartPtr<CLImageHandler> &image_handler, SmartPtr<DrmBoBuffer> &input_buf, SmartPtr<DrmBoBuffer> &output_buf, uint32_t kernel_loop_count) |
| 99 | { |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 100 | XCamReturn ret = XCAM_RETURN_NO_ERROR; |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 101 | for (uint32_t i = 0; i < kernel_loop_count; i++) { |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 102 | PROFILING_START(cl_kernel); |
| 103 | ret = image_handler->execute (input_buf, output_buf); |
| 104 | PROFILING_END(cl_kernel, kernel_loop_count) |
| 105 | } |
| 106 | return ret; |
| 107 | } |
| 108 | |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 109 | static void |
| 110 | print_help (const char *bin_name) |
| 111 | { |
| 112 | printf ("Usage: %s [-f format] -i input -o output\n" |
| 113 | "\t -t type specify image handler type\n" |
wangfei | 7e0436e | 2015-04-15 19:22:36 +0800 | [diff] [blame] | 114 | "\t select from [demo, blacklevel, defect, demosaic, csc, hdr, wb, denoise, gamma]\n" |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 115 | "\t -f input_format specify a input format\n" |
| 116 | "\t -g output_format specify a output format\n" |
Wind Yuan | 0a1c73e | 2015-03-26 08:50:06 +0800 | [diff] [blame] | 117 | "\t select from [NV12, BA10, RGBA]\n" |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 118 | "\t -i input specify input file path\n" |
| 119 | "\t -o output specify output file path\n" |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 120 | "\t -p count specify cl kernel loop count\n" |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 121 | "\t -c csc_type specify csc type, default:rgba2nv12\n" |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 122 | "\t select from [rgbatonv12, rgbatolab, rgba64torgba]\n" |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 123 | "\t -d hdr_type specify hdr type, default:rgb\n" |
| 124 | "\t select from [rgb, lab]\n" |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 125 | "\t -h help\n" |
| 126 | , bin_name); |
| 127 | } |
| 128 | |
| 129 | int main (int argc, char *argv[]) |
| 130 | { |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 131 | uint32_t input_format = 0; |
| 132 | uint32_t output_format = V4L2_PIX_FMT_RGBA32; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 133 | uint32_t buf_count = 0; |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 134 | uint32_t kernel_loop_count = 0; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 135 | const char *input_file = NULL, *output_file = NULL; |
| 136 | TestFileHandle input_fp, output_fp; |
| 137 | const char *bin_name = argv[0]; |
| 138 | TestHandlerType handler_type = TestHandlerUnknown; |
| 139 | XCamReturn ret = XCAM_RETURN_NO_ERROR; |
| 140 | SmartPtr<CLImageHandler> image_handler; |
| 141 | VideoBufferInfo input_buf_info; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 142 | SmartPtr<CLContext> context; |
| 143 | SmartPtr<DrmDisplay> display; |
Wind Yuan | 4bbe4ec | 2015-04-02 18:00:35 +0800 | [diff] [blame] | 144 | SmartPtr<BufferPool> buf_pool; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 145 | int opt = 0; |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 146 | CLCscType csc_type = CL_CSC_TYPE_RGBATONV12; |
| 147 | CLHdrType hdr_type = CL_HDR_TYPE_RGB; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 148 | |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 149 | while ((opt = getopt(argc, argv, "f:i:o:t:p:c:d:g:h")) != -1) { |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 150 | switch (opt) { |
| 151 | case 'i': |
| 152 | input_file = optarg; |
| 153 | break; |
| 154 | case 'o': |
| 155 | output_file = optarg; |
| 156 | break; |
| 157 | |
| 158 | case 'f': { |
| 159 | if (!strcasecmp (optarg, "nv12")) |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 160 | input_format = V4L2_PIX_FMT_NV12; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 161 | else if (!strcasecmp (optarg, "ba10")) |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 162 | input_format = V4L2_PIX_FMT_SGRBG10; |
wangfei | 6ea2221 | 2015-03-23 19:10:26 +0800 | [diff] [blame] | 163 | else if (! strcasecmp (optarg, "rgba")) |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 164 | input_format = V4L2_PIX_FMT_RGBA32; |
| 165 | else if (! strcasecmp (optarg, "rgba64")) |
| 166 | input_format = XCAM_PIX_FMT_RGBA64; |
| 167 | |
| 168 | else |
| 169 | print_help (bin_name); |
| 170 | break; |
| 171 | } |
| 172 | case 'g': { |
| 173 | if (!strcasecmp (optarg, "nv12")) |
| 174 | output_format = V4L2_PIX_FMT_NV12; |
| 175 | else if (!strcasecmp (optarg, "ba10")) |
| 176 | output_format = V4L2_PIX_FMT_SGRBG10; |
| 177 | else if (! strcasecmp (optarg, "rgba")) |
| 178 | output_format = V4L2_PIX_FMT_RGBA32; |
| 179 | else if (! strcasecmp (optarg, "rgba64")) |
| 180 | output_format = XCAM_PIX_FMT_RGBA64; |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 181 | |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 182 | else |
| 183 | print_help (bin_name); |
| 184 | break; |
| 185 | } |
| 186 | case 't': { |
| 187 | if (!strcasecmp (optarg, "demo")) |
| 188 | handler_type = TestHandlerDemo; |
| 189 | else if (!strcasecmp (optarg, "blacklevel")) |
| 190 | handler_type = TestHandlerBlackLevel; |
| 191 | else if (!strcasecmp (optarg, "defect")) |
| 192 | handler_type = TestHandlerDefect; |
Wind Yuan | 5c96d9f | 2015-03-18 15:32:37 +0800 | [diff] [blame] | 193 | else if (!strcasecmp (optarg, "demosaic")) |
| 194 | handler_type = TestHandlerDemosaic; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 195 | else if (!strcasecmp (optarg, "csc")) |
| 196 | handler_type = TestHandlerColorConversion; |
| 197 | else if (!strcasecmp (optarg, "hdr")) |
| 198 | handler_type = TestHandlerHDR; |
wangfei | 9842835 | 2015-04-02 10:41:27 +0800 | [diff] [blame] | 199 | else if (!strcasecmp (optarg, "wb")) |
| 200 | handler_type = TestHandlerWhiteBalance; |
Juan Zhao | ab5e6fe | 2015-04-08 14:12:46 +0800 | [diff] [blame] | 201 | else if (!strcasecmp (optarg, "denoise")) |
| 202 | handler_type = TestHandlerDenoise; |
wangfei | 7e0436e | 2015-04-15 19:22:36 +0800 | [diff] [blame] | 203 | else if (!strcasecmp (optarg, "gamma")) |
| 204 | handler_type = TestHandlerGamma; |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 205 | else |
| 206 | print_help (bin_name); |
| 207 | break; |
| 208 | } |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 209 | case 'p': |
| 210 | kernel_loop_count = atoi (optarg); |
| 211 | break; |
wangfei | 1a7d9f3 | 2015-03-26 18:30:00 +0800 | [diff] [blame] | 212 | case 'c': |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 213 | if (!strcasecmp (optarg, "rgbatonv12")) |
wangfei | 1a7d9f3 | 2015-03-26 18:30:00 +0800 | [diff] [blame] | 214 | csc_type = CL_CSC_TYPE_RGBATONV12; |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 215 | else if (!strcasecmp (optarg, "rgbatolab")) |
wangfei | 1a7d9f3 | 2015-03-26 18:30:00 +0800 | [diff] [blame] | 216 | csc_type = CL_CSC_TYPE_RGBATOLAB; |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 217 | else if (!strcasecmp (optarg, "rgba64torgba")) |
| 218 | csc_type = CL_CSC_TYPE_RGBA64TORGBA; |
wangfei | 1a7d9f3 | 2015-03-26 18:30:00 +0800 | [diff] [blame] | 219 | else |
| 220 | print_help (bin_name); |
| 221 | break; |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 222 | case 'd': |
| 223 | if (!strcasecmp (optarg, "rgb")) |
| 224 | hdr_type = CL_HDR_TYPE_RGB; |
| 225 | else if (!strcasecmp (optarg, "lab")) |
| 226 | hdr_type = CL_HDR_TYPE_LAB; |
| 227 | else |
| 228 | print_help (bin_name); |
| 229 | break; |
| 230 | |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 231 | case 'h': |
| 232 | print_help (bin_name); |
| 233 | return 0; |
| 234 | |
| 235 | default: |
| 236 | print_help (bin_name); |
| 237 | return -1; |
| 238 | } |
| 239 | } |
| 240 | |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 241 | if (!input_format || !input_file || !output_file || handler_type == TestHandlerUnknown) { |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 242 | print_help (bin_name); |
| 243 | return -1; |
| 244 | } |
| 245 | |
| 246 | input_fp.fp = fopen (input_file, "rb"); |
| 247 | output_fp.fp = fopen (output_file, "wb"); |
| 248 | if (!input_fp.fp || !output_fp.fp) { |
| 249 | XCAM_LOG_ERROR ("open input/output file failed"); |
| 250 | return -1; |
| 251 | } |
| 252 | |
| 253 | context = CLDevice::instance ()->get_context (); |
| 254 | |
| 255 | switch (handler_type) { |
| 256 | case TestHandlerDemo: |
| 257 | image_handler = create_cl_demo_image_handler (context); |
| 258 | break; |
| 259 | case TestHandlerBlackLevel: |
ShincyTu | 5710f97 | 2015-03-23 23:20:44 +0800 | [diff] [blame] | 260 | image_handler = create_cl_blc_image_handler (context); |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 261 | break; |
| 262 | case TestHandlerDefect: |
| 263 | break; |
Wind Yuan | 5c96d9f | 2015-03-18 15:32:37 +0800 | [diff] [blame] | 264 | case TestHandlerDemosaic: { |
| 265 | SmartPtr<CLBayer2RGBImageHandler> ba2rgb_handler; |
| 266 | image_handler = create_cl_demosaic_image_handler (context); |
| 267 | ba2rgb_handler = image_handler.dynamic_cast_ptr<CLBayer2RGBImageHandler> (); |
| 268 | XCAM_ASSERT (ba2rgb_handler.ptr ()); |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 269 | ba2rgb_handler->set_output_format (output_format); |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 270 | break; |
Wind Yuan | 5c96d9f | 2015-03-18 15:32:37 +0800 | [diff] [blame] | 271 | } |
wangfei | 6ea2221 | 2015-03-23 19:10:26 +0800 | [diff] [blame] | 272 | case TestHandlerColorConversion: { |
wangfei | 1a7d9f3 | 2015-03-26 18:30:00 +0800 | [diff] [blame] | 273 | image_handler = create_cl_csc_image_handler (context, csc_type); |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 274 | break; |
wangfei | 6ea2221 | 2015-03-23 19:10:26 +0800 | [diff] [blame] | 275 | } |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 276 | case TestHandlerHDR: |
wangfei | 125221b | 2015-04-08 13:49:20 +0800 | [diff] [blame] | 277 | image_handler = create_cl_hdr_image_handler (context, hdr_type); |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 278 | break; |
Juan Zhao | ab5e6fe | 2015-04-08 14:12:46 +0800 | [diff] [blame] | 279 | case TestHandlerDenoise: |
| 280 | image_handler = create_cl_denoise_image_handler (context); |
| 281 | break; |
wangfei | 9842835 | 2015-04-02 10:41:27 +0800 | [diff] [blame] | 282 | case TestHandlerWhiteBalance: { |
| 283 | XCam3aResultWhiteBalance wb; |
| 284 | wb.r_gain = 1.0; |
| 285 | wb.gr_gain = 1.0; |
| 286 | wb.gb_gain = 1.0; |
| 287 | wb.b_gain = 1.0; |
| 288 | SmartPtr<CLWbImageHandler> wb_handler; |
| 289 | image_handler = create_cl_wb_image_handler (context); |
| 290 | wb_handler = image_handler.dynamic_cast_ptr<CLWbImageHandler> (); |
| 291 | XCAM_ASSERT (wb_handler.ptr ()); |
| 292 | wb_handler->set_wb_config (wb); |
| 293 | break; |
| 294 | } |
wangfei | 7e0436e | 2015-04-15 19:22:36 +0800 | [diff] [blame] | 295 | case TestHandlerGamma: { |
| 296 | XCam3aResultGammaTable gamma_table; |
| 297 | for(int i = 0; i < XCAM_GAMMA_TABLE_SIZE; ++i) |
| 298 | gamma_table.table[i] = (double)(pow(i / 255.0, 1 / 2.2) * 255.0); |
| 299 | SmartPtr<CLGammaImageHandler> gamma_handler; |
| 300 | image_handler = create_cl_gamma_image_handler (context); |
| 301 | gamma_handler = image_handler.dynamic_cast_ptr<CLGammaImageHandler> (); |
| 302 | XCAM_ASSERT (gamma_handler.ptr ()); |
| 303 | gamma_handler->set_gamma_table (gamma_table); |
| 304 | break; |
| 305 | } |
| 306 | |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 307 | default: |
| 308 | XCAM_LOG_ERROR ("unsupported image handler type:%d", handler_type); |
| 309 | return -1; |
| 310 | } |
| 311 | if (!image_handler.ptr ()) { |
| 312 | XCAM_LOG_ERROR ("create image_handler failed"); |
| 313 | return -1; |
| 314 | } |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 315 | |
wangfei | 227ba27 | 2015-04-16 20:58:45 +0800 | [diff] [blame^] | 316 | input_buf_info.init (input_format, 1920, 1080); |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 317 | display = DrmDisplay::instance (); |
| 318 | buf_pool = new DrmBoBufferPool (display); |
Wind Yuan | 4bbe4ec | 2015-04-02 18:00:35 +0800 | [diff] [blame] | 319 | buf_pool->set_video_info (input_buf_info); |
| 320 | if (!buf_pool->reserve (6)) { |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 321 | XCAM_LOG_ERROR ("init buffer pool failed"); |
| 322 | return -1; |
| 323 | } |
| 324 | |
| 325 | while (!feof (input_fp.fp)) { |
Wind Yuan | 4bbe4ec | 2015-04-02 18:00:35 +0800 | [diff] [blame] | 326 | SmartPtr<DrmBoBuffer> input_buf, output_buf; |
| 327 | SmartPtr<BufferProxy> tmp_buf = buf_pool->get_buffer (buf_pool); |
| 328 | input_buf = tmp_buf.dynamic_cast_ptr<DrmBoBuffer> (); |
| 329 | |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 330 | XCAM_ASSERT (input_buf.ptr ()); |
| 331 | ret = read_buf (input_buf, input_fp); |
| 332 | if (ret == XCAM_RETURN_BYPASS) |
| 333 | break; |
| 334 | CHECK (ret, "read buffer from %s failed", input_file); |
wangfei | cf53669 | 2015-03-19 16:44:50 +0800 | [diff] [blame] | 335 | |
| 336 | if (kernel_loop_count != 0) |
| 337 | { |
| 338 | kernel_loop (image_handler, input_buf, output_buf, kernel_loop_count); |
| 339 | CHECK (ret, "execute kernels failed"); |
| 340 | return 0; |
| 341 | } |
| 342 | |
Wind Yuan | 20f67cb | 2015-03-05 16:15:21 +0800 | [diff] [blame] | 343 | ret = image_handler->execute (input_buf, output_buf); |
| 344 | CHECK (ret, "execute kernels failed"); |
| 345 | XCAM_ASSERT (output_buf.ptr ()); |
| 346 | |
| 347 | ret = write_buf (output_buf, output_fp); |
| 348 | CHECK (ret, "read buffer from %s failed", output_file); |
| 349 | |
| 350 | ++buf_count; |
| 351 | } |
| 352 | XCAM_LOG_INFO ("processed %d buffers successfully", buf_count); |
| 353 | return 0; |
| 354 | } |