• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_3a_stats_context.h - CL 3a stats context
3  *
4  *  Copyright (c) 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 #ifndef XCAM_CL_3A_STATS_CONTEXT_H
22 #define XCAM_CL_3A_STATS_CONTEXT_H
23 
24 #include <xcam_std.h>
25 #include <x3a_stats_pool.h>
26 #include <ocl/cl_memory.h>
27 #include <ocl/cl_context.h>
28 
29 #define XCAM_CL_3A_STATS_BUFFER_COUNT 6
30 
31 namespace XCam {
32 
33 class CL3AStatsCalculatorContext
34 {
35 public:
36     struct CL3AStatsStruct {
37         uint16_t avg_y;
38         uint16_t avg_r;
39         uint16_t avg_gr;
40         uint16_t avg_gb;
41         uint16_t avg_b;
42         uint16_t valid_wb_count;
43         uint16_t f_value1;
44         uint16_t f_value2;
45     };
46 
47 public:
48     CL3AStatsCalculatorContext (const SmartPtr<CLContext> &context);
49     ~CL3AStatsCalculatorContext ();
50     void set_bit_depth (uint32_t bits);
51 
is_ready()52     bool is_ready () const {
53         return _data_allocated;
54     }
55     bool allocate_data (const VideoBufferInfo &buffer_info, uint32_t width_factor, uint32_t height_factor);
56     void pre_stop ();
57     void clean_up_data ();
58 
59     SmartPtr<CLBuffer> get_buffer ();
60     bool release_buffer (SmartPtr<CLBuffer> &buf);
61     SmartPtr<X3aStats> copy_stats_out (const SmartPtr<CLBuffer> &stats_cl_buf);
62 
63 private:
64     XCAM_DEAD_COPY (CL3AStatsCalculatorContext);
65 
66     bool fill_histogram (XCam3AStats *stats);
67 
68 private:
69     SmartPtr<CLContext>              _context;
70     SmartPtr<X3aStatsPool>           _stats_pool;
71     SafeList<CLBuffer>               _stats_cl_buffers;
72     uint32_t                         _stats_mem_size;
73     uint32_t                         _width_factor;
74     uint32_t                         _height_factor;
75     uint32_t                         _factor_shift;
76     XCam3AStatsInfo                  _stats_info;
77     bool                             _data_allocated;
78 };
79 
80 }
81 #endif //XCAM_CL_3A_STATS_CONTEXT_H
82