• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * cl_image_processor.h - CL image processor
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_IMAGE_PROCESSOR_H
22 #define XCAM_CL_IMAGE_PROCESSOR_H
23 
24 #include <xcam_std.h>
25 #include <image_processor.h>
26 #include <ocl/priority_buffer_queue.h>
27 #include <list>
28 
29 namespace XCam {
30 
31 class CLImageHandler;
32 class CLContext;
33 class CLHandlerThread;
34 class CLBufferNotifyThread;
35 
36 class CLImageProcessor
37     : public ImageProcessor
38 {
39 public:
40     typedef std::list<SmartPtr<CLImageHandler>>  ImageHandlerList;
41     typedef std::list<SmartPtr<PriorityBuffer>>  UnsafePriorityBufferList;
42     friend class CLHandlerThread;
43     friend class CLBufferNotifyThread;
44 
45 public:
46     explicit CLImageProcessor (const char* name = NULL);
47     virtual ~CLImageProcessor ();
48 
49     void keep_attached_buf (bool flag);
50 
51     bool add_handler (SmartPtr<CLImageHandler> &handler);
52     ImageHandlerList::iterator handlers_begin ();
53     ImageHandlerList::iterator handlers_end ();
54 
55 protected:
56 
57     //derive from ImageProcessor
58     virtual bool can_process_result (SmartPtr<X3aResult> &result);
59     virtual XCamReturn apply_3a_results (X3aResultList &results);
60     virtual XCamReturn apply_3a_result (SmartPtr<X3aResult> &result);
61     virtual XCamReturn process_buffer (SmartPtr<VideoBuffer> &input, SmartPtr<VideoBuffer> &output);
62     virtual XCamReturn emit_start ();
63     virtual void emit_stop ();
64 
65     SmartPtr<CLContext> get_cl_context ();
66 
67 private:
68     virtual XCamReturn create_handlers ();
69 
70     XCamReturn process_cl_buffer_queue ();
71     XCamReturn process_done_buffer ();
72     uint32_t check_ready_buffers ();
73 
74     XCAM_DEAD_COPY (CLImageProcessor);
75 
76 protected:
77 
78 // STREAM_LOCK only used in class derived from CLImageProcessor
79 #define STREAM_LOCK SmartLock stream_lock (this->_stream_mutex)
80     // stream lock
81     Mutex                          _stream_mutex;
82 
83 private:
84     SmartPtr<CLContext>            _context;
85     ImageHandlerList               _handlers;
86     SmartPtr<CLHandlerThread>      _handler_thread;
87     PriorityBufferQueue            _process_buffer_queue;
88     UnsafePriorityBufferList       _not_ready_buffers;
89     SmartPtr<CLBufferNotifyThread> _done_buf_thread;
90     SafeList<VideoBuffer>          _done_buffer_queue;
91     uint32_t                       _seq_num;
92     bool                           _keep_attached_buffer;  //default false
93     XCAM_OBJ_PROFILING_DEFINES;
94 };
95 
96 };
97 #endif //XCAM_CL_IMAGE_PROCESSOR_H
98