omx_video_base.h revision a66301743224ed885fc1b5275acd16f4843a03f5
1/*--------------------------------------------------------------------------
2Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
3
4Redistribution and use in source and binary forms, with or without
5modification, are permitted provided that the following conditions are
6met:
7    * Redistributions of source code must retain the above copyright
8      notice, this list of conditions and the following disclaimer.
9    * Redistributions in binary form must reproduce the above
10      copyright notice, this list of conditions and the following
11      disclaimer in the documentation and/or other materials provided
12      with the distribution.
13    * Neither the name of The Linux Foundation nor the names of its
14      contributors may be used to endorse or promote products derived
15      from this software without specific prior written permission.
16
17THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28--------------------------------------------------------------------------*/
29
30#ifndef __OMX_VIDEO_BASE_H__
31#define __OMX_VIDEO_BASE_H__
32/*============================================================================
33                            O p e n M A X   Component
34                                Video Encoder
35
36*//** @file comx_video_base.h
37  This module contains the class definition for openMAX decoder component.
38
39*//*========================================================================*/
40
41//////////////////////////////////////////////////////////////////////////////
42//                             Include Files
43//////////////////////////////////////////////////////////////////////////////
44
45#define LOG_TAG "OMX-VENC"
46#include <stdlib.h>
47#include <stdio.h>
48#include <sys/mman.h>
49#ifdef _ANDROID_
50#include <binder/MemoryHeapBase.h>
51#ifdef _ANDROID_ICS_
52#include "QComOMXMetadata.h"
53#endif
54#endif // _ANDROID_
55#include <pthread.h>
56#include <semaphore.h>
57#include <linux/msm_vidc_enc.h>
58#include "OMX_Core.h"
59#include "OMX_QCOMExtns.h"
60#include "OMX_VideoExt.h"
61#include "OMX_IndexExt.h"
62#include "qc_omx_component.h"
63#include "omx_video_common.h"
64#include "extra_data_handler.h"
65#include <linux/videodev2.h>
66#include <dlfcn.h>
67#include "C2DColorConverter.h"
68#include "vidc_debug.h"
69
70#ifdef _ANDROID_
71using namespace android;
72// local pmem heap object
73class VideoHeap : public MemoryHeapBase
74{
75    public:
76        VideoHeap(int fd, size_t size, void* base);
77        virtual ~VideoHeap() {}
78};
79
80#include <utils/Log.h>
81
82#endif // _ANDROID_
83
84#ifdef USE_ION
85static const char* MEM_DEVICE = "/dev/ion";
86#if defined(MAX_RES_720P) && !defined(_MSM8974_)
87#define MEM_HEAP_ID ION_CAMERA_HEAP_ID
88#else
89#ifdef _MSM8974_
90#define MEM_HEAP_ID ION_IOMMU_HEAP_ID
91#else
92#define MEM_HEAP_ID ION_CP_MM_HEAP_ID
93#endif
94#endif
95#elif MAX_RES_720P
96static const char* MEM_DEVICE = "/dev/pmem_adsp";
97#elif MAX_RES_1080P_EBI
98static const char* MEM_DEVICE  = "/dev/pmem_adsp";
99#elif MAX_RES_1080P
100static const char* MEM_DEVICE = "/dev/pmem_smipool";
101#else
102#error MEM_DEVICE cannot be determined.
103#endif
104
105//////////////////////////////////////////////////////////////////////////////
106//                       Module specific globals
107//////////////////////////////////////////////////////////////////////////////
108
109#define OMX_SPEC_VERSION  0x00000101
110
111
112//////////////////////////////////////////////////////////////////////////////
113//               Macros
114//////////////////////////////////////////////////////////////////////////////
115#define PrintFrameHdr(bufHdr) DEBUG_PRINT("bufHdr %x buf %x size %d TS %d\n",\
116        (unsigned) bufHdr,\
117        (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->pBuffer,\
118        (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->nFilledLen,\
119        (unsigned)((OMX_BUFFERHEADERTYPE *)bufHdr)->nTimeStamp)
120
121// BitMask Management logic
122#define BITS_PER_BYTE        32
123#define BITMASK_SIZE(mIndex) (((mIndex) + BITS_PER_BYTE - 1)/BITS_PER_BYTE)
124#define BITMASK_OFFSET(mIndex) ((mIndex)/BITS_PER_BYTE)
125#define BITMASK_FLAG(mIndex) (1 << ((mIndex) % BITS_PER_BYTE))
126#define BITMASK_CLEAR(mArray,mIndex) (mArray)[BITMASK_OFFSET(mIndex)] \
127    &=  ~(BITMASK_FLAG(mIndex))
128#define BITMASK_SET(mArray,mIndex)  (mArray)[BITMASK_OFFSET(mIndex)] \
129    |=  BITMASK_FLAG(mIndex)
130#define BITMASK_PRESENT(mArray,mIndex) ((mArray)[BITMASK_OFFSET(mIndex)] \
131        & BITMASK_FLAG(mIndex))
132#define BITMASK_ABSENT(mArray,mIndex) (((mArray)[BITMASK_OFFSET(mIndex)] \
133            & BITMASK_FLAG(mIndex)) == 0x0)
134#define BITMASK_PRESENT(mArray,mIndex) ((mArray)[BITMASK_OFFSET(mIndex)] \
135        & BITMASK_FLAG(mIndex))
136#define BITMASK_ABSENT(mArray,mIndex) (((mArray)[BITMASK_OFFSET(mIndex)] \
137            & BITMASK_FLAG(mIndex)) == 0x0)
138#ifdef _ANDROID_ICS_
139#define MAX_NUM_INPUT_BUFFERS 32
140#endif
141void* message_thread(void *);
142
143// OMX video class
144class omx_video: public qc_omx_component
145{
146    protected:
147#ifdef _ANDROID_ICS_
148        bool meta_mode_enable;
149        bool c2d_opened;
150        encoder_media_buffer_type meta_buffers[MAX_NUM_INPUT_BUFFERS];
151        OMX_BUFFERHEADERTYPE *opaque_buffer_hdr[MAX_NUM_INPUT_BUFFERS];
152        bool mUseProxyColorFormat;
153        //RGB or non-native input, and we have pre-allocated conversion buffers
154        bool mUsesColorConversion;
155        bool get_syntaxhdr_enable;
156        OMX_BUFFERHEADERTYPE  *psource_frame;
157        OMX_BUFFERHEADERTYPE  *pdest_frame;
158        bool secure_session;
159        //intermediate conversion buffer queued to encoder in case of invalid EOS input
160        OMX_BUFFERHEADERTYPE  *mEmptyEosBuffer;
161
162        class omx_c2d_conv
163        {
164            public:
165                omx_c2d_conv();
166                ~omx_c2d_conv();
167                bool init();
168                bool open(unsigned int height,unsigned int width,
169                        ColorConvertFormat src,
170                        ColorConvertFormat dest,unsigned int src_stride);
171                bool convert(int src_fd, void *src_base, void *src_viraddr,
172                        int dest_fd, void *dest_base, void *dest_viraddr);
173                bool get_buffer_size(int port,unsigned int &buf_size);
174                int get_src_format();
175                void close();
176            private:
177                C2DColorConverterBase *c2dcc;
178                pthread_mutex_t c_lock;
179                void *mLibHandle;
180                ColorConvertFormat src_format;
181                createC2DColorConverter_t *mConvertOpen;
182                destroyC2DColorConverter_t *mConvertClose;
183        };
184        omx_c2d_conv c2d_conv;
185#endif
186    public:
187        omx_video();  // constructor
188        virtual ~omx_video();  // destructor
189
190        // virtual int async_message_process (void *context, void* message);
191        void process_event_cb(void *ctxt,unsigned char id);
192
193        OMX_ERRORTYPE allocate_buffer(
194                OMX_HANDLETYPE hComp,
195                OMX_BUFFERHEADERTYPE **bufferHdr,
196                OMX_U32 port,
197                OMX_PTR appData,
198                OMX_U32 bytes
199                );
200
201
202        virtual OMX_ERRORTYPE component_deinit(OMX_HANDLETYPE hComp)= 0;
203
204        virtual OMX_ERRORTYPE component_init(OMX_STRING role)= 0;
205
206        virtual OMX_U32 dev_stop(void) = 0;
207        virtual OMX_U32 dev_pause(void) = 0;
208        virtual OMX_U32 dev_start(void) = 0;
209        virtual OMX_U32 dev_flush(unsigned) = 0;
210        virtual OMX_U32 dev_resume(void) = 0;
211        virtual OMX_U32 dev_start_done(void) = 0;
212        virtual OMX_U32 dev_set_message_thread_id(pthread_t) = 0;
213        virtual bool dev_use_buf(void *,unsigned,unsigned) = 0;
214        virtual bool dev_free_buf(void *,unsigned) = 0;
215        virtual bool dev_empty_buf(void *, void *,unsigned,unsigned) = 0;
216        virtual bool dev_fill_buf(void *buffer, void *,unsigned,unsigned) = 0;
217        virtual bool dev_get_buf_req(OMX_U32 *,OMX_U32 *,OMX_U32 *,OMX_U32) = 0;
218        virtual bool dev_get_seq_hdr(void *, unsigned, OMX_U32 *) = 0;
219        virtual bool dev_loaded_start(void) = 0;
220        virtual bool dev_loaded_stop(void) = 0;
221        virtual bool dev_loaded_start_done(void) = 0;
222        virtual bool dev_loaded_stop_done(void) = 0;
223        virtual bool is_secure_session(void) = 0;
224#ifdef _MSM8974_
225        virtual int dev_handle_extradata(void*, int) = 0;
226        virtual int dev_set_format(int) = 0;
227#endif
228        virtual bool dev_is_video_session_supported(OMX_U32 width, OMX_U32 height) = 0;
229        virtual bool dev_get_capability_ltrcount(OMX_U32 *, OMX_U32 *, OMX_U32 *) = 0;
230        virtual bool dev_get_performance_level(OMX_U32 *) = 0;
231        virtual bool dev_get_vui_timing_info(OMX_U32 *) = 0;
232        virtual bool dev_get_peak_bitrate(OMX_U32 *) = 0;
233#ifdef _ANDROID_ICS_
234        void omx_release_meta_buffer(OMX_BUFFERHEADERTYPE *buffer);
235#endif
236        virtual bool dev_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width,
237                        OMX_U32 height) = 0;
238        virtual bool dev_get_output_log_flag() = 0;
239        virtual int dev_output_log_buffers(const char *buffer_addr, int buffer_len) = 0;
240        virtual int dev_extradata_log_buffers(char *buffer_addr) = 0;
241        OMX_ERRORTYPE component_role_enum(
242                OMX_HANDLETYPE hComp,
243                OMX_U8 *role,
244                OMX_U32 index
245                );
246
247        OMX_ERRORTYPE component_tunnel_request(
248                OMX_HANDLETYPE hComp,
249                OMX_U32 port,
250                OMX_HANDLETYPE  peerComponent,
251                OMX_U32 peerPort,
252                OMX_TUNNELSETUPTYPE *tunnelSetup
253                );
254
255        OMX_ERRORTYPE empty_this_buffer(
256                OMX_HANDLETYPE hComp,
257                OMX_BUFFERHEADERTYPE *buffer
258                );
259
260
261
262        OMX_ERRORTYPE fill_this_buffer(
263                OMX_HANDLETYPE hComp,
264                OMX_BUFFERHEADERTYPE *buffer
265                );
266
267
268        OMX_ERRORTYPE free_buffer(
269                OMX_HANDLETYPE hComp,
270                OMX_U32 port,
271                OMX_BUFFERHEADERTYPE *buffer
272                );
273
274        OMX_ERRORTYPE get_component_version(
275                OMX_HANDLETYPE hComp,
276                OMX_STRING componentName,
277                OMX_VERSIONTYPE *componentVersion,
278                OMX_VERSIONTYPE *specVersion,
279                OMX_UUIDTYPE *componentUUID
280                );
281
282        OMX_ERRORTYPE get_config(
283                OMX_HANDLETYPE hComp,
284                OMX_INDEXTYPE configIndex,
285                OMX_PTR configData
286                );
287
288        OMX_ERRORTYPE get_extension_index(
289                OMX_HANDLETYPE hComp,
290                OMX_STRING paramName,
291                OMX_INDEXTYPE *indexType
292                );
293
294        OMX_ERRORTYPE get_parameter(OMX_HANDLETYPE hComp,
295                OMX_INDEXTYPE  paramIndex,
296                OMX_PTR        paramData);
297
298        OMX_ERRORTYPE get_state(OMX_HANDLETYPE hComp,
299                OMX_STATETYPE *state);
300
301
302
303        OMX_ERRORTYPE send_command(OMX_HANDLETYPE  hComp,
304                OMX_COMMANDTYPE cmd,
305                OMX_U32         param1,
306                OMX_PTR         cmdData);
307
308
309        OMX_ERRORTYPE set_callbacks(OMX_HANDLETYPE   hComp,
310                OMX_CALLBACKTYPE *callbacks,
311                OMX_PTR          appData);
312
313        virtual OMX_ERRORTYPE set_config(OMX_HANDLETYPE hComp,
314                OMX_INDEXTYPE  configIndex,
315                OMX_PTR        configData) = 0;
316
317        virtual OMX_ERRORTYPE set_parameter(OMX_HANDLETYPE hComp,
318                OMX_INDEXTYPE  paramIndex,
319                OMX_PTR        paramData) =0;
320
321        OMX_ERRORTYPE use_buffer(OMX_HANDLETYPE      hComp,
322                OMX_BUFFERHEADERTYPE **bufferHdr,
323                OMX_U32              port,
324                OMX_PTR              appData,
325                OMX_U32              bytes,
326                OMX_U8               *buffer);
327
328
329        OMX_ERRORTYPE use_EGL_image(OMX_HANDLETYPE     hComp,
330                OMX_BUFFERHEADERTYPE **bufferHdr,
331                OMX_U32              port,
332                OMX_PTR              appData,
333                void *               eglImage);
334
335
336
337        int  m_pipe_in;
338        int  m_pipe_out;
339
340        pthread_t msg_thread_id;
341        pthread_t async_thread_id;
342        bool async_thread_created;
343        bool msg_thread_created;
344
345        OMX_U8 m_nkind[128];
346
347
348        //int *input_pmem_fd;
349        //int *output_pmem_fd;
350        struct pmem *m_pInput_pmem;
351        struct pmem *m_pOutput_pmem;
352#ifdef USE_ION
353        struct venc_ion *m_pInput_ion;
354        struct venc_ion *m_pOutput_ion;
355#endif
356
357
358
359    public:
360        // Bit Positions
361        enum flags_bit_positions {
362            // Defer transition to IDLE
363            OMX_COMPONENT_IDLE_PENDING            =0x1,
364            // Defer transition to LOADING
365            OMX_COMPONENT_LOADING_PENDING         =0x2,
366            // First  Buffer Pending
367            OMX_COMPONENT_FIRST_BUFFER_PENDING    =0x3,
368            // Second Buffer Pending
369            OMX_COMPONENT_SECOND_BUFFER_PENDING   =0x4,
370            // Defer transition to Enable
371            OMX_COMPONENT_INPUT_ENABLE_PENDING    =0x5,
372            // Defer transition to Enable
373            OMX_COMPONENT_OUTPUT_ENABLE_PENDING   =0x6,
374            // Defer transition to Disable
375            OMX_COMPONENT_INPUT_DISABLE_PENDING   =0x7,
376            // Defer transition to Disable
377            OMX_COMPONENT_OUTPUT_DISABLE_PENDING  =0x8,
378            //defer flush notification
379            OMX_COMPONENT_OUTPUT_FLUSH_PENDING    =0x9,
380            OMX_COMPONENT_INPUT_FLUSH_PENDING    =0xA,
381            OMX_COMPONENT_PAUSE_PENDING          =0xB,
382            OMX_COMPONENT_EXECUTE_PENDING        =0xC,
383            OMX_COMPONENT_LOADED_START_PENDING = 0xD,
384            OMX_COMPONENT_LOADED_STOP_PENDING = 0xF,
385
386        };
387
388        // Deferred callback identifiers
389        enum {
390            //Event Callbacks from the venc component thread context
391            OMX_COMPONENT_GENERATE_EVENT       = 0x1,
392            //Buffer Done callbacks from the venc component thread context
393            OMX_COMPONENT_GENERATE_BUFFER_DONE = 0x2,
394            //Frame Done callbacks from the venc component thread context
395            OMX_COMPONENT_GENERATE_FRAME_DONE  = 0x3,
396            //Buffer Done callbacks from the venc component thread context
397            OMX_COMPONENT_GENERATE_FTB         = 0x4,
398            //Frame Done callbacks from the venc component thread context
399            OMX_COMPONENT_GENERATE_ETB         = 0x5,
400            //Command
401            OMX_COMPONENT_GENERATE_COMMAND     = 0x6,
402            //Push-Pending Buffers
403            OMX_COMPONENT_PUSH_PENDING_BUFS    = 0x7,
404            // Empty Buffer Done callbacks
405            OMX_COMPONENT_GENERATE_EBD         = 0x8,
406            //Flush Event Callbacks from the venc component thread context
407            OMX_COMPONENT_GENERATE_EVENT_FLUSH       = 0x9,
408            OMX_COMPONENT_GENERATE_EVENT_INPUT_FLUSH = 0x0A,
409            OMX_COMPONENT_GENERATE_EVENT_OUTPUT_FLUSH = 0x0B,
410            OMX_COMPONENT_GENERATE_FBD = 0xc,
411            OMX_COMPONENT_GENERATE_START_DONE = 0xD,
412            OMX_COMPONENT_GENERATE_PAUSE_DONE = 0xE,
413            OMX_COMPONENT_GENERATE_RESUME_DONE = 0xF,
414            OMX_COMPONENT_GENERATE_STOP_DONE = 0x10,
415            OMX_COMPONENT_GENERATE_HARDWARE_ERROR = 0x11,
416            OMX_COMPONENT_GENERATE_LTRUSE_FAILED = 0x12,
417            OMX_COMPONENT_GENERATE_ETB_OPQ = 0x13
418        };
419
420        struct omx_event {
421            unsigned long param1;
422            unsigned long param2;
423            unsigned long id;
424        };
425
426        struct omx_cmd_queue {
427            omx_event m_q[OMX_CORE_CONTROL_CMDQ_SIZE];
428            unsigned long m_read;
429            unsigned long m_write;
430            unsigned long m_size;
431
432            omx_cmd_queue();
433            ~omx_cmd_queue();
434            bool insert_entry(unsigned long p1, unsigned long p2, unsigned long id);
435            bool pop_entry(unsigned long *p1,unsigned long *p2, unsigned long *id);
436            // get msgtype of the first ele from the queue
437            unsigned get_q_msg_type();
438
439        };
440
441        bool allocate_done(void);
442        bool allocate_input_done(void);
443        bool allocate_output_done(void);
444
445        OMX_ERRORTYPE free_input_buffer(OMX_BUFFERHEADERTYPE *bufferHdr);
446        OMX_ERRORTYPE free_output_buffer(OMX_BUFFERHEADERTYPE *bufferHdr);
447
448        OMX_ERRORTYPE allocate_input_buffer(OMX_HANDLETYPE       hComp,
449                OMX_BUFFERHEADERTYPE **bufferHdr,
450                OMX_U32              port,
451                OMX_PTR              appData,
452                OMX_U32              bytes);
453#ifdef _ANDROID_ICS_
454        OMX_ERRORTYPE allocate_input_meta_buffer(OMX_HANDLETYPE       hComp,
455                OMX_BUFFERHEADERTYPE **bufferHdr,
456                OMX_PTR              appData,
457                OMX_U32              bytes);
458#endif
459        OMX_ERRORTYPE allocate_output_buffer(OMX_HANDLETYPE       hComp,
460                OMX_BUFFERHEADERTYPE **bufferHdr,
461                OMX_U32 port,OMX_PTR appData,
462                OMX_U32              bytes);
463
464        OMX_ERRORTYPE use_input_buffer(OMX_HANDLETYPE hComp,
465                OMX_BUFFERHEADERTYPE  **bufferHdr,
466                OMX_U32               port,
467                OMX_PTR               appData,
468                OMX_U32               bytes,
469                OMX_U8                *buffer);
470
471        OMX_ERRORTYPE use_output_buffer(OMX_HANDLETYPE hComp,
472                OMX_BUFFERHEADERTYPE   **bufferHdr,
473                OMX_U32                port,
474                OMX_PTR                appData,
475                OMX_U32                bytes,
476                OMX_U8                 *buffer);
477
478        bool execute_omx_flush(OMX_U32);
479        bool execute_output_flush(void);
480        bool execute_input_flush(void);
481#ifdef _MSM8974_
482        bool execute_flush_all(void);
483#endif
484        OMX_ERRORTYPE empty_buffer_done(OMX_HANDLETYPE hComp,
485                OMX_BUFFERHEADERTYPE * buffer);
486
487        OMX_ERRORTYPE fill_buffer_done(OMX_HANDLETYPE hComp,
488                OMX_BUFFERHEADERTYPE * buffer);
489        OMX_ERRORTYPE empty_this_buffer_proxy(OMX_HANDLETYPE hComp,
490                OMX_BUFFERHEADERTYPE *buffer);
491        OMX_ERRORTYPE empty_this_buffer_opaque(OMX_HANDLETYPE hComp,
492                OMX_BUFFERHEADERTYPE *buffer);
493        OMX_ERRORTYPE push_input_buffer(OMX_HANDLETYPE hComp);
494        OMX_ERRORTYPE convert_queue_buffer(OMX_HANDLETYPE hComp,
495                struct pmem &Input_pmem_info,unsigned long &index);
496        OMX_ERRORTYPE queue_meta_buffer(OMX_HANDLETYPE hComp,
497                struct pmem &Input_pmem_info);
498        OMX_ERRORTYPE push_empty_eos_buffer(OMX_HANDLETYPE hComp,
499                OMX_BUFFERHEADERTYPE *buffer);
500        OMX_ERRORTYPE fill_this_buffer_proxy(OMX_HANDLETYPE hComp,
501                OMX_BUFFERHEADERTYPE *buffer);
502        bool release_done();
503
504        bool release_output_done();
505        bool release_input_done();
506
507        OMX_ERRORTYPE send_command_proxy(OMX_HANDLETYPE  hComp,
508                OMX_COMMANDTYPE cmd,
509                OMX_U32         param1,
510                OMX_PTR         cmdData);
511        bool post_event( unsigned long p1,
512                unsigned long p2,
513                unsigned long id
514                   );
515        OMX_ERRORTYPE get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType);
516        inline void omx_report_error () {
517            if (m_pCallbacks.EventHandler && !m_error_propogated) {
518                m_error_propogated = true;
519                m_pCallbacks.EventHandler(&m_cmp,m_app_data,
520                        OMX_EventError,OMX_ErrorHardware,0,NULL);
521            }
522        }
523
524        inline void omx_report_unsupported_setting () {
525            if (m_pCallbacks.EventHandler && !m_error_propogated) {
526                m_error_propogated = true;
527                m_pCallbacks.EventHandler(&m_cmp,m_app_data,
528                        OMX_EventError,OMX_ErrorUnsupportedSetting,0,NULL);
529            }
530        }
531
532        void complete_pending_buffer_done_cbs();
533
534#ifdef USE_ION
535        int alloc_map_ion_memory(int size,
536                                 struct ion_allocation_data *alloc_data,
537                                 struct ion_fd_data *fd_data,int flag);
538        void free_ion_memory(struct venc_ion *buf_ion_info);
539#endif
540
541        //*************************************************************
542        //*******************MEMBER VARIABLES *************************
543        //*************************************************************
544
545        pthread_mutex_t       m_lock;
546        sem_t                 m_cmd_lock;
547        bool              m_error_propogated;
548
549        //sem to handle the minimum procesing of commands
550
551
552        // compression format
553        //OMX_VIDEO_CODINGTYPE eCompressionFormat;
554        // OMX State
555        OMX_STATETYPE m_state;
556        // Application data
557        OMX_PTR m_app_data;
558        OMX_BOOL m_use_input_pmem;
559        OMX_BOOL m_use_output_pmem;
560        // Application callbacks
561        OMX_CALLBACKTYPE m_pCallbacks;
562        OMX_PORT_PARAM_TYPE m_sPortParam;
563        OMX_VIDEO_PARAM_PROFILELEVELTYPE m_sParamProfileLevel;
564        OMX_VIDEO_PARAM_PORTFORMATTYPE m_sInPortFormat;
565        OMX_VIDEO_PARAM_PORTFORMATTYPE m_sOutPortFormat;
566        OMX_PARAM_PORTDEFINITIONTYPE m_sInPortDef;
567        OMX_PARAM_PORTDEFINITIONTYPE m_sOutPortDef;
568        OMX_VIDEO_PARAM_MPEG4TYPE m_sParamMPEG4;
569        OMX_VIDEO_PARAM_H263TYPE m_sParamH263;
570        OMX_VIDEO_PARAM_AVCTYPE m_sParamAVC;
571        OMX_VIDEO_PARAM_VP8TYPE m_sParamVP8;
572        OMX_PORT_PARAM_TYPE m_sPortParam_img;
573        OMX_PORT_PARAM_TYPE m_sPortParam_audio;
574        OMX_VIDEO_CONFIG_BITRATETYPE m_sConfigBitrate;
575        OMX_CONFIG_FRAMERATETYPE m_sConfigFramerate;
576        OMX_VIDEO_PARAM_BITRATETYPE m_sParamBitrate;
577        OMX_PRIORITYMGMTTYPE m_sPriorityMgmt;
578        OMX_PARAM_BUFFERSUPPLIERTYPE m_sInBufSupplier;
579        OMX_PARAM_BUFFERSUPPLIERTYPE m_sOutBufSupplier;
580        OMX_CONFIG_ROTATIONTYPE m_sConfigFrameRotation;
581        OMX_CONFIG_INTRAREFRESHVOPTYPE m_sConfigIntraRefreshVOP;
582        OMX_VIDEO_PARAM_QUANTIZATIONTYPE m_sSessionQuantization;
583        OMX_QCOM_VIDEO_PARAM_QPRANGETYPE m_sSessionQPRange;
584        OMX_VIDEO_PARAM_AVCSLICEFMO m_sAVCSliceFMO;
585        QOMX_VIDEO_INTRAPERIODTYPE m_sIntraperiod;
586        OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE m_sErrorCorrection;
587        OMX_VIDEO_PARAM_INTRAREFRESHTYPE m_sIntraRefresh;
588        QOMX_VIDEO_PARAM_LTRMODE_TYPE m_sParamLTRMode;
589        QOMX_VIDEO_PARAM_LTRCOUNT_TYPE m_sParamLTRCount;
590        QOMX_VIDEO_CONFIG_LTRPERIOD_TYPE m_sConfigLTRPeriod;
591        QOMX_VIDEO_CONFIG_LTRUSE_TYPE m_sConfigLTRUse;
592        OMX_VIDEO_CONFIG_AVCINTRAPERIOD m_sConfigAVCIDRPeriod;
593        OMX_VIDEO_CONFIG_DEINTERLACE m_sConfigDeinterlace;
594        OMX_VIDEO_VP8REFERENCEFRAMETYPE m_sConfigVp8ReferenceFrame;
595        QOMX_VIDEO_HIERARCHICALLAYERS m_sHierLayers;
596        QOMX_EXTNINDEX_VIDEO_INITIALQP m_sParamInitqp;
597        OMX_U32 m_sExtraData;
598        OMX_U32 m_input_msg_id;
599
600        // fill this buffer queue
601        omx_cmd_queue m_ftb_q;
602        // Command Q for rest of the events
603        omx_cmd_queue m_cmd_q;
604        omx_cmd_queue m_etb_q;
605        // Input memory pointer
606        OMX_BUFFERHEADERTYPE *m_inp_mem_ptr;
607        // Output memory pointer
608        OMX_BUFFERHEADERTYPE *m_out_mem_ptr;
609        omx_cmd_queue m_opq_meta_q;
610        omx_cmd_queue m_opq_pmem_q;
611        OMX_BUFFERHEADERTYPE meta_buffer_hdr[MAX_NUM_INPUT_BUFFERS];
612
613        bool input_flush_progress;
614        bool output_flush_progress;
615        bool input_use_buffer;
616        bool output_use_buffer;
617        int pending_input_buffers;
618        int pending_output_buffers;
619
620        unsigned int m_out_bm_count;
621        unsigned int m_inp_bm_count;
622        unsigned int m_flags;
623        unsigned int m_etb_count;
624        unsigned int m_fbd_count;
625#ifdef _ANDROID_
626        // Heap pointer to frame buffers
627        sp<MemoryHeapBase>    m_heap_ptr;
628#endif //_ANDROID_
629        // to know whether Event Port Settings change has been triggered or not.
630        bool m_event_port_settings_sent;
631        OMX_U8                m_cRole[OMX_MAX_STRINGNAME_SIZE];
632        extra_data_handler extra_data_handle;
633
634};
635
636#endif // __OMX_VIDEO_BASE_H__
637