/* * cl_geo_map_handler.h - CL geometry map handler * * Copyright (c) 2016 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Wind Yuan */ #ifndef XCAM_CL_GEO_MAP_HANDLER_H #define XCAM_CL_GEO_MAP_HANDLER_H #include #include namespace XCam { struct GeoPos { double x; double y; GeoPos () : x(0), y(0) {} }; class CLGeoMapKernel; class GeoKernelParamCallback { friend class CLGeoMapKernel; public: GeoKernelParamCallback () {} virtual ~GeoKernelParamCallback () {} protected: virtual SmartPtr get_geo_input_image (NV12PlaneIdx index) = 0; virtual SmartPtr get_geo_output_image (NV12PlaneIdx index) = 0; virtual SmartPtr get_geo_map_table () = 0; virtual void get_geo_equivalent_out_size (float &width, float &height) = 0; virtual void get_geo_pixel_out_size (float &width, float &height) = 0; virtual SmartPtr get_lsc_table () = 0; virtual float* get_lsc_gray_threshold() = 0; private: XCAM_DEAD_COPY (GeoKernelParamCallback); }; class CLGeoMapHandler; class CLGeoMapKernel : public CLImageKernel { public: explicit CLGeoMapKernel ( const SmartPtr &context, const SmartPtr handler, bool need_lsc); protected: virtual XCamReturn prepare_arguments (CLArgList &args, CLWorkSize &work_size); private: SmartPtr _handler; bool _need_lsc; }; class CLGeoMapHandler : public CLImageHandler , public GeoKernelParamCallback { public: explicit CLGeoMapHandler (const SmartPtr &context); void set_output_size (uint32_t width, uint32_t height) { _output_width = width; _output_height = height; } void get_output_size (uint32_t &width, uint32_t &height) const { width = _output_width; height = _output_height; } bool set_map_data (GeoPos *data, uint32_t width, uint32_t height); bool set_map_uint (float uint_x, float uint_y); void get_map_uint (float &uint_x, float &uint_y) { uint_x = _uint_x; uint_y = _uint_y; } protected: // derived from GeoKernelParamCallback virtual SmartPtr get_geo_input_image (NV12PlaneIdx index) { XCAM_ASSERT (index < NV12PlaneMax); return _input [index]; } virtual SmartPtr get_geo_output_image (NV12PlaneIdx index) { XCAM_ASSERT (index < NV12PlaneMax); return _output [index]; } virtual SmartPtr get_geo_map_table () { XCAM_ASSERT (_geo_image.ptr ()); return _geo_image; } virtual void get_geo_equivalent_out_size (float &width, float &height); virtual void get_geo_pixel_out_size (float &width, float &height); virtual SmartPtr get_lsc_table () { XCAM_ASSERT (false && "CLGeoMapHandler::lsc table is not supported"); return NULL; } virtual float* get_lsc_gray_threshold () { XCAM_ASSERT (false && "CLGeoMapHandler::lsc gray threshold is not supported"); return NULL; } protected: virtual XCamReturn prepare_buffer_pool_video_info ( const VideoBufferInfo &input, VideoBufferInfo &output); virtual XCamReturn prepare_parameters (SmartPtr &input, SmartPtr &output); virtual XCamReturn execute_done (SmartPtr &output); private: bool normalize_geo_map (uint32_t image_w, uint32_t image_h); bool check_geo_map_buf (uint32_t width, uint32_t height); XCAM_DEAD_COPY (CLGeoMapHandler); private: uint32_t _output_width; uint32_t _output_height; uint32_t _map_width, _map_height; uint32_t _map_aligned_width; float _uint_x, _uint_y; SmartPtr _input[NV12PlaneMax]; SmartPtr _output[NV12PlaneMax]; SmartPtr _geo_map; SmartPtr _geo_image; bool _geo_map_normalized; }; SmartPtr create_geo_map_kernel ( const SmartPtr &context, SmartPtr param_cb, bool need_lsc); SmartPtr create_geo_map_handler (const SmartPtr &context, bool need_lsc = false); } #endif //XCAM_CL_GEO_MAP_HANDLER_H