1 /*--------------------------------------------------------------------------
2 Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are
6 met:
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 
17 THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20 ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 --------------------------------------------------------------------------*/
29 #ifndef __OMX_VENC_DEV__
30 #define __OMX_VENC_DEV__
31 
32 #include "OMX_Types.h"
33 #include "OMX_Core.h"
34 #include "OMX_VideoExt.h"
35 #include "QComOMXMetadata.h"
36 #include "OMX_QCOMExtns.h"
37 #include "qc_omx_component.h"
38 #ifdef _VQZIP_
39 #include "VQZip.h"
40 #endif
41 
42 #include "omx_video_common.h"
43 #include "omx_video_base.h"
44 #include "omx_video_encoder.h"
45 #include "vidc_common.h"
46 #include <linux/videodev2.h>
47 #include "media/msm_vidc_utils.h"
48 #include <poll.h>
49 #include <list>
50 #include "color_metadata.h"
51 
52 #define TIMEOUT 5*60*1000
53 #define BIT(num) (1 << (num))
54 #define MAX_HYB_HIERP_LAYERS 6
55 #define MAX_AVC_HP_LAYERS (4)
56 #define MAX_V4L2_BUFS 64 //VB2_MAX_FRAME
57 #define ENABLE_I_QP 0x1
58 #define ENABLE_P_QP 0x2
59 #define ENABLE_B_QP 0x4
60 
61 enum hier_type {
62     HIER_NONE = 0x0,
63     HIER_P = 0x1,
64     HIER_B = 0x2,
65     HIER_P_HYBRID = 0x3,
66 };
67 
68 struct msm_venc_switch {
69     unsigned char    status;
70 };
71 
72 struct msm_venc_allocatorproperty {
73     unsigned long     mincount;
74     unsigned long     actualcount;
75     unsigned long     datasize;
76     unsigned long     suffixsize;
77     unsigned long     alignment;
78     unsigned long     bufpoolid;
79 };
80 
81 struct msm_venc_basecfg {
82     unsigned long    input_width;
83     unsigned long    input_height;
84     unsigned long    dvs_width;
85     unsigned long    dvs_height;
86     unsigned long    codectype;
87     unsigned long    fps_num;
88     unsigned long    fps_den;
89     unsigned long    targetbitrate;
90     unsigned long    inputformat;
91 };
92 
93 struct msm_venc_profile {
94     unsigned long    profile;
95 };
96 struct msm_venc_profilelevel {
97     unsigned long    level;
98 };
99 
100 struct msm_venc_sessionqp {
101     unsigned long    iframeqp;
102     unsigned long    pframeqp;
103     unsigned long    bframeqp;
104     unsigned long    enableqp;
105 };
106 
107 struct msm_venc_ipb_qprange {
108     unsigned long    max_i_qp;
109     unsigned long    min_i_qp;
110     unsigned long    max_p_qp;
111     unsigned long    min_p_qp;
112     unsigned long    max_b_qp;
113     unsigned long    min_b_qp;
114 };
115 
116 struct msm_venc_intraperiod {
117     unsigned long    num_pframes;
118     unsigned long    num_bframes;
119 };
120 struct msm_venc_seqheader {
121     unsigned char *hdrbufptr;
122     unsigned long    bufsize;
123     unsigned long    hdrlen;
124 };
125 
126 struct msm_venc_capability {
127     unsigned long    codec_types;
128     unsigned long    maxframe_width;
129     unsigned long    maxframe_height;
130     unsigned long    maxtarget_bitrate;
131     unsigned long    maxframe_rate;
132     unsigned long    input_formats;
133     unsigned char    dvs;
134 };
135 
136 struct msm_venc_entropycfg {
137     unsigned longentropysel;
138     unsigned long    cabacmodel;
139 };
140 
141 struct msm_venc_dbcfg {
142     unsigned long    db_mode;
143     unsigned long    slicealpha_offset;
144     unsigned long    slicebeta_offset;
145 };
146 
147 struct msm_venc_intrarefresh {
148     unsigned long    irmode;
149     unsigned long    mbcount;
150     unsigned long    framecount;
151 };
152 
153 struct msm_venc_multiclicecfg {
154     unsigned long    mslice_mode;
155     unsigned long    mslice_size;
156 };
157 
158 struct msm_venc_bufferflush {
159     unsigned long    flush_mode;
160 };
161 
162 struct msm_venc_ratectrlcfg {
163     unsigned long    rcmode;
164 };
165 
166 struct    msm_venc_voptimingcfg {
167     unsigned long    voptime_resolution;
168 };
169 struct msm_venc_framerate {
170     unsigned long    fps_denominator;
171     unsigned long    fps_numerator;
172 };
173 
174 struct msm_venc_targetbitrate {
175     unsigned long    target_bitrate;
176 };
177 
178 
179 struct msm_venc_rotation {
180     unsigned long    rotation;
181 };
182 
183 struct msm_venc_timeout {
184     unsigned long    millisec;
185 };
186 
187 struct msm_venc_headerextension {
188     unsigned long    header_extension;
189 };
190 
191 struct msm_venc_video_capability {
192     unsigned int min_width;
193     unsigned int max_width;
194     unsigned int min_height;
195     unsigned int max_height;
196 };
197 
198 struct msm_venc_idrperiod {
199     unsigned long idrperiod;
200 };
201 
202 struct msm_venc_slice_delivery {
203     unsigned long enable;
204 };
205 
206 struct msm_venc_ltrinfo {
207     unsigned int enabled;
208     unsigned int count;
209 };
210 
211 struct msm_venc_vui_timing_info {
212     unsigned int enabled;
213 };
214 
215 struct msm_venc_vqzip_sei_info {
216     unsigned int enabled;
217 };
218 
219 struct msm_venc_peak_bitrate {
220     unsigned int peakbitrate;
221 };
222 
223 struct msm_venc_vpx_error_resilience {
224     unsigned int enable;
225 };
226 
227 struct msm_venc_priority {
228     OMX_U32 priority;
229 };
230 
231 struct msm_venc_color_space {
232     OMX_U32 primaries;
233     OMX_U32 range;
234     OMX_U32 matrix_coeffs;
235     OMX_U32 transfer_chars;
236 };
237 
238 struct msm_venc_temporal_layers {
239     enum hier_type hier_mode;
240     OMX_U32 nMaxLayers;
241     OMX_U32 nMaxBLayers;
242     OMX_U32 nPLayers;
243     OMX_U32 nBLayers;
244     OMX_BOOL bIsBitrateRatioValid;
245     // cumulative ratio: eg [25, 50, 75, 100] means [L0=25%, L1=25%, L2=25%, L3=25%]
246     OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS];
247     // Layerwise ratio: eg [L0=25%, L1=25%, L2=25%, L3=25%]
248     OMX_U32 nTemporalLayerBitrateFraction[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS];
249     OMX_U32 nKeyFrameInterval;
250     OMX_U32 nMinQuantizer;
251     OMX_U32 nMaxQuantizer;
252     OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern;
253 };
254 
255 enum v4l2_ports {
256     CAPTURE_PORT,
257     OUTPUT_PORT,
258     MAX_PORT
259 };
260 
261 struct extradata_buffer_info {
262     unsigned long buffer_size;
263     char* uaddr;
264     int count;
265     int size;
266     OMX_BOOL allocated;
267     enum v4l2_ports port_index;
268 #ifdef USE_ION
269     struct venc_ion ion;
270 #endif
271     bool vqzip_sei_found;
272 };
273 
274 struct statistics {
275     struct timeval prev_tv;
276     int prev_fbd;
277     int bytes_generated;
278 };
279 
280 enum rc_modes {
281     RC_VBR_VFR = BIT(0),
282     RC_VBR_CFR = BIT(1),
283     RC_CBR_VFR = BIT(2),
284     RC_CBR_CFR = BIT(3),
285     RC_MBR_CFR = BIT(4),
286     RC_MBR_VFR = BIT(5),
287     RC_CQ      = BIT(6),
288     RC_ALL = (RC_VBR_VFR | RC_VBR_CFR
289         | RC_CBR_VFR | RC_CBR_CFR | RC_MBR_CFR | RC_MBR_VFR | RC_CQ)
290 };
291 
292 class venc_dev
293 {
294     public:
295         venc_dev(class omx_venc *venc_class); //constructor
296         ~venc_dev(); //des
297 
298         static void* async_venc_message_thread (void *);
299         bool venc_open(OMX_U32);
300         void venc_close();
301         unsigned venc_stop(void);
302         unsigned venc_pause(void);
303         bool is_streamon_done(OMX_U32 port);
304         unsigned venc_start(void);
305         unsigned venc_flush(unsigned);
306 #ifdef _ANDROID_ICS_
307         bool venc_set_meta_mode(bool);
308 #endif
309         unsigned venc_resume(void);
310         unsigned venc_start_done(void);
311         unsigned venc_stop_done(void);
312         unsigned venc_set_message_thread_id(pthread_t);
313         bool allocate_extradata(unsigned);
314         bool venc_free_buf(void*, unsigned);
315         bool venc_empty_buf(void *, void *,unsigned,unsigned);
316         bool venc_fill_buf(void *, void *,unsigned,unsigned);
317         bool venc_get_buf_req(OMX_U32 *,OMX_U32 *,
318                 OMX_U32 *,OMX_U32);
319         bool venc_set_buf_req(OMX_U32 *,OMX_U32 *,
320                 OMX_U32 *,OMX_U32);
321         bool venc_set_param(void *,OMX_INDEXTYPE);
322         bool venc_set_config(void *configData, OMX_INDEXTYPE index);
323         bool venc_h264_transform_8x8(OMX_BOOL enable);
324         bool venc_get_profile_level(OMX_U32 *eProfile,OMX_U32 *eLevel);
325         bool venc_get_seq_hdr(void *, unsigned, unsigned *);
326         bool venc_get_dimensions(OMX_U32 portIndex, OMX_U32 *w, OMX_U32 *h);
327         bool venc_loaded_start(void);
328         bool venc_loaded_stop(void);
329         bool venc_handle_empty_eos_buffer(void);
330         bool venc_loaded_start_done(void);
331         bool venc_loaded_stop_done(void);
332         bool venc_is_video_session_supported(unsigned long width, unsigned long height);
333         bool venc_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width,
334                         OMX_U32 height);
335         bool venc_get_vui_timing_info(OMX_U32 *enabled);
336         bool venc_get_vqzip_sei_info(OMX_U32 *enabled);
337         bool venc_get_peak_bitrate(OMX_U32 *peakbitrate);
338         bool venc_get_batch_size(OMX_U32 *size);
339         bool venc_get_temporal_layer_caps(OMX_U32 * /*nMaxLayers*/,
340                 OMX_U32 * /*nMaxBLayers*/, OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE */*SupportedPattern*/);
341         OMX_ERRORTYPE venc_get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType);
342         bool venc_get_supported_color_format(unsigned index, OMX_U32 *colorFormat);
343         bool venc_check_for_hybrid_hp(OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern);
344         bool venc_check_for_hierp(OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern);
345         int venc_find_hier_type(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
346         OMX_ERRORTYPE venc_disable_hp();
347         OMX_ERRORTYPE venc_disable_hhp();
348         OMX_ERRORTYPE venc_set_hp(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
349         OMX_ERRORTYPE venc_set_hhp(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
350         OMX_ERRORTYPE venc_set_bitrate_ratio(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
351         bool venc_validate_temporal_settings();
352         bool venc_validate_temporal_extn(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
353         OMX_ERRORTYPE venc_set_temporal_settings(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
354         void venc_copy_temporal_settings(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings);
355         bool venc_get_output_log_flag();
356         int venc_output_log_buffers(const char *buffer_addr, int buffer_len, uint64_t timestamp);
357         int venc_input_log_buffers(OMX_BUFFERHEADERTYPE *buffer, int fd, int plane_offset,
358                         unsigned long inputformat, bool interlaced);
359         int venc_extradata_log_buffers(char *buffer_addr, bool input);
360         bool venc_set_bitrate_type(OMX_U32 type);
361         bool venc_get_hevc_profile(OMX_U32* profile);
362         void venc_get_consumer_usage(OMX_U32* usage);
363 
364 #ifdef _VQZIP_
365         class venc_dev_vqzip
366         {
367             public:
368                 venc_dev_vqzip();
369                 ~venc_dev_vqzip();
370                 bool init();
371                 void deinit();
372                 struct VQZipConfig pConfig;
373                 int tempSEI[300];
374                 int fill_stats_data(void* pBuf, void *pStats);
375                 typedef void (*vqzip_deinit_t)(void*);
376                 typedef void* (*vqzip_init_t)(void);
377                 typedef VQZipStatus (*vqzip_compute_stats_t)(void* const , const void * const , const VQZipConfig* ,VQZipStats*);
378             private:
379                 pthread_mutex_t lock;
380                 void *mLibHandle;
381                 void *mVQZIPHandle;
382                 vqzip_init_t mVQZIPInit;
383                 vqzip_deinit_t mVQZIPDeInit;
384                 vqzip_compute_stats_t mVQZIPComputeStats;
385         };
386         venc_dev_vqzip vqzip;
387 #endif
388 
389         struct venc_debug_cap m_debug;
390         OMX_U32 m_nDriver_fd;
391         int m_poll_efd;
392         int num_input_planes, num_output_planes;
393         int etb, ebd, ftb, fbd;
394         struct recon_buffer {
395             unsigned char* virtual_address;
396             int pmem_fd;
397             int size;
398             int alignment;
399             int offset;
400 #ifdef USE_ION
401             int ion_device_fd;
402             struct ion_allocation_data alloc_data;
403 #endif
404         };
405 
406         int nPframes_cache;
407         int stopped;
408         int resume_in_stopped;
409         bool m_max_allowed_bitrate_check;
410         pthread_t m_tid;
411         bool async_thread_created;
412         bool async_thread_force_stop;
413         class omx_venc *venc_handle;
414         OMX_ERRORTYPE allocate_extradata(struct extradata_buffer_info *extradata_info, int flags);
415         void free_extradata_all();
416         void free_extradata(struct extradata_buffer_info *extradata_info);
417         int append_mbi_extradata(void *, struct msm_vidc_extradata_header*);
418         void append_extradata_mbidata(OMX_OTHER_EXTRADATATYPE *, struct msm_vidc_extradata_header *);
419         void append_extradata_ltrinfo(OMX_OTHER_EXTRADATATYPE *, struct msm_vidc_extradata_header *);
420         void append_extradata_none(OMX_OTHER_EXTRADATATYPE *);
421         bool handle_output_extradata(void *, int);
422         bool handle_input_extradata(struct v4l2_buffer);
423         bool venc_handle_client_input_extradata(void *);
424         int venc_set_format(int);
425         bool venc_query_cap(struct v4l2_queryctrl &cap);
426         bool deinterlace_enabled;
427         bool hw_overload;
428         bool is_gralloc_source_ubwc;
429         bool is_camera_source_ubwc;
430         bool is_csc_custom_matrix_enabled;
431         bool csc_enable;
432         bool mIsNativeRecorder;
433         OMX_U32 fd_list[64];
434 
435     private:
436         OMX_U32                             m_codec;
437         struct msm_venc_basecfg             m_sVenc_cfg;
438         struct msm_venc_rotation            m_rotation;
439         struct msm_venc_ratectrlcfg         rate_ctrl;
440         struct msm_venc_targetbitrate       bitrate;
441         struct msm_venc_intraperiod         intra_period;
442         struct msm_venc_profile             codec_profile;
443         struct msm_venc_profilelevel        profile_level;
444         struct msm_venc_switch              set_param;
445         struct msm_venc_voptimingcfg        time_inc;
446         struct msm_venc_allocatorproperty   m_sInput_buff_property;
447         struct msm_venc_allocatorproperty   m_sOutput_buff_property;
448         struct msm_venc_sessionqp           session_qp;
449         struct msm_venc_ipb_qprange         session_ipb_qp_values;
450         struct msm_venc_multiclicecfg       multislice;
451         struct msm_venc_entropycfg          entropy;
452         struct msm_venc_dbcfg               dbkfilter;
453         struct msm_venc_intrarefresh        intra_refresh;
454         struct msm_venc_headerextension     hec;
455         struct msm_venc_voptimingcfg        voptimecfg;
456         struct msm_venc_video_capability    capability;
457         struct msm_venc_idrperiod           idrperiod;
458         struct msm_venc_slice_delivery      slice_mode;
459         struct msm_venc_vui_timing_info     vui_timing_info;
460         struct msm_venc_vqzip_sei_info      vqzip_sei_info;
461         struct msm_venc_peak_bitrate        peak_bitrate;
462         struct msm_venc_ltrinfo             ltrinfo;
463         struct msm_venc_vpx_error_resilience vpx_err_resilience;
464         struct msm_venc_priority            sess_priority;
465         OMX_U32                             operating_rate;
466         struct msm_venc_color_space         color_space;
467         msm_venc_temporal_layers            temporal_layers_config;
468         OMX_BOOL                            downscalar_enabled;
469         bool client_req_disable_bframe;
470         bool bframe_implicitly_enabled;
471         bool client_req_disable_temporal_layers;
472         bool client_req_turbo_mode;
473         char m_platform_name[PROPERTY_VALUE_MAX] = {0};
474 
475         bool venc_validate_range(OMX_S32 id, OMX_S32 val);
476         bool venc_set_profile(OMX_U32 eProfile);
477         bool venc_set_level(OMX_U32 eLevel);
478         bool venc_set_intra_period(OMX_U32 nPFrames, OMX_U32 nBFrames);
479         bool _venc_set_intra_period(OMX_U32 nPFrames, OMX_U32 nBFrames);
480         bool venc_set_target_bitrate(OMX_U32 nTargetBitrate);
481         bool venc_set_ratectrl_cfg(OMX_VIDEO_CONTROLRATETYPE eControlRate);
482         bool venc_set_session_qp_range(OMX_QCOM_VIDEO_PARAM_IPB_QPRANGETYPE *qp_range);
483         bool venc_set_encode_framerate(OMX_U32 encode_framerate);
484         bool venc_set_intra_vop_refresh(OMX_BOOL intra_vop_refresh);
485         bool venc_set_color_format(OMX_COLOR_FORMATTYPE color_format);
486         bool venc_validate_profile_level(OMX_U32 *eProfile, OMX_U32 *eLevel);
487         bool venc_set_multislice_cfg(OMX_U32 slicemode, OMX_U32 slicesize);
488         bool venc_set_entropy_config(OMX_BOOL enable, OMX_U32 i_cabac_level);
489         bool venc_set_inloop_filter(OMX_VIDEO_AVCLOOPFILTERTYPE loop_filter);
490         bool venc_set_intra_refresh ();
491         bool venc_set_error_resilience(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* error_resilience);
492         bool venc_set_voptiming_cfg(OMX_U32 nTimeIncRes);
493         void venc_config_print();
494         bool venc_set_slice_delivery_mode(OMX_U32 enable);
495         bool venc_set_extradata(OMX_U32 extra_data, OMX_BOOL enable);
496         bool venc_set_idr_period(OMX_U32 nIDRPeriod);
497         bool venc_reconfigure_intra_period();
498         bool venc_reconfigure_intra_refresh_period();
499         bool venc_reconfig_reqbufs();
500         bool venc_set_vpe_rotation(OMX_S32 rotation_angle);
501         bool venc_set_mirror(OMX_U32 mirror);
502         bool venc_set_ltrmode(OMX_U32 enable, OMX_U32 count);
503         bool venc_set_useltr(OMX_U32 frameIdx);
504         bool venc_set_markltr(OMX_U32 frameIdx);
505         bool venc_set_inband_video_header(OMX_BOOL enable);
506         bool venc_set_au_delimiter(OMX_BOOL enable);
507         bool venc_set_hier_layers(QOMX_VIDEO_HIERARCHICALCODINGTYPE type, OMX_U32 num_layers);
508         bool venc_set_vui_timing_info(OMX_BOOL enable);
509         bool venc_set_peak_bitrate(OMX_U32 nPeakBitrate);
510         bool venc_set_searchrange();
511         bool venc_set_vpx_error_resilience(OMX_BOOL enable);
512         bool venc_set_vqzip_sei_type(OMX_BOOL enable);
513         bool venc_set_batch_size(OMX_U32 size);
514         bool venc_calibrate_gop();
515         bool venc_set_vqzip_defaults();
516         bool venc_get_index_from_fd(OMX_U32 buffer_fd, OMX_U32 *index);
517         bool venc_set_hierp_layers(OMX_U32 hierp_layers);
518         bool venc_set_baselayerid(OMX_U32 baseid);
519         bool venc_set_qp(OMX_U32 i_frame_qp, OMX_U32 p_frame_qp,OMX_U32 b_frame_qp, OMX_U32 enable);
520         bool venc_set_aspectratio(void *nSar);
521         bool venc_set_priority(OMX_U32 priority);
522         bool venc_set_session_priority(OMX_U32 priority);
523         bool venc_set_operatingrate(OMX_U32 rate);
524         bool venc_set_layer_bitrates(OMX_U32 *pLayerBitrates, OMX_U32 numLayers);
525         bool venc_set_lowlatency_mode(OMX_BOOL enable);
526         bool venc_set_roi_qp_info(OMX_QTI_VIDEO_CONFIG_ROIINFO *roiInfo);
527         bool venc_set_blur_resolution(OMX_QTI_VIDEO_CONFIG_BLURINFO *blurInfo);
528         bool venc_set_colorspace(OMX_U32 primaries, OMX_U32 range, OMX_U32 transfer_chars, OMX_U32 matrix_coeffs);
529         bool venc_reconfigure_temporal_settings();
530         bool venc_reconfigure_ltrmode();
531         bool venc_set_iframesize_type(QOMX_VIDEO_IFRAMESIZE_TYPE type);
532         unsigned long venc_get_color_format(OMX_COLOR_FORMATTYPE eColorFormat);
533         unsigned long venc_get_codectype(OMX_VIDEO_CODINGTYPE eCompressionFormat);
534         bool venc_set_nal_size (OMX_VIDEO_CONFIG_NALSIZE *nalSizeInfo);
535         bool venc_set_grid_enable();
536         bool venc_set_extradata_hdr10metadata();
537 
538         OMX_U32 pmem_free();
539         OMX_U32 pmem_allocate(OMX_U32 size, OMX_U32 alignment, OMX_U32 count);
540         OMX_U32 venc_allocate_recon_buffers();
clip2(int x)541         inline int clip2(int x) {
542             x = x -1;
543             x = x | x >> 1;
544             x = x | x >> 2;
545             x = x | x >> 4;
546             x = x | x >> 8;
547             x = x | x >> 16;
548             x = x + 1;
549             return x;
550         }
551         int metadatamode;
552         bool streaming[MAX_PORT];
553         bool extradata;
554         struct extradata_buffer_info input_extradata_info;
555         struct extradata_buffer_info output_extradata_info;
556         bool m_hdr10meta_enabled;
557         ColorMetaData colorData= {};
558 
559         pthread_mutex_t pause_resume_mlock;
560         pthread_cond_t pause_resume_cond;
561         bool paused;
562         int color_format;
563         bool is_searchrange_set;
564         bool enable_mv_narrow_searchrange;
565         int supported_rc_modes;
566         bool camera_mode_enabled;
567         bool low_latency_mode;
568         struct roidata {
569             bool dirty;
570             OMX_QTI_VIDEO_CONFIG_ROIINFO info;
571         };
572         bool m_roi_enabled;
573         int m_roi_type;
574         pthread_mutex_t m_roilock;
575         std::list<roidata> m_roilist;
576         void get_roi_for_timestamp(struct roidata &roi, OMX_TICKS timestamp);
577         bool venc_empty_batch (OMX_BUFFERHEADERTYPE *buf, unsigned index);
578         static const int kMaxBuffersInBatch = 16;
579         unsigned int mBatchSize;
580         struct BatchInfo {
581             BatchInfo();
582             /* register a buffer and obtain its unique id (v4l2-buf-id)
583              */
584             int registerBuffer(int bufferId);
585             /* retrieve the buffer given its v4l2-buf-id
586              */
587             int retrieveBufferAt(int v4l2Id);
588             bool isPending(int bufferId);
589 
590           private:
591             static const int kMaxBufs = 64;
592             static const int kBufIDFree = -1;
593             pthread_mutex_t mLock;
594             int mBufMap[64];  // Map with slots for each buffer
595             size_t mNumPending;
596 
597         };
598         BatchInfo mBatchInfo;
599         bool mUseAVTimerTimestamps;
600         bool venc_set_hdr_info(const MasteringDisplay&, const ContentLightLevel&);
601         bool mIsGridset;
602         OMX_U32 mUseLinearColorFormat;
603 
604         // the list to contain the region roi info
605         std::list<OMX_QTI_VIDEO_CONFIG_ROI_RECT_REGION_INFO> mRoiRegionList;
606         bool venc_set_roi_region_qp_info(OMX_QTI_VIDEO_CONFIG_ROI_RECT_REGION_INFO *roiRegionInfo);
607         OMX_U32 append_extradata_roi_region_qp_info(OMX_OTHER_EXTRADATATYPE *data,
608                 OMX_TICKS timestamp, OMX_U32 freeSize);
609         bool mBitrateSavingsEnable;
610         bool hdr10metadata_supported;
611 };
612 
613 enum instance_state {
614     MSM_VIDC_CORE_UNINIT_DONE = 0x0001,
615     MSM_VIDC_CORE_INIT,
616     MSM_VIDC_CORE_INIT_DONE,
617     MSM_VIDC_OPEN,
618     MSM_VIDC_OPEN_DONE,
619     MSM_VIDC_LOAD_RESOURCES,
620     MSM_VIDC_LOAD_RESOURCES_DONE,
621     MSM_VIDC_START,
622     MSM_VIDC_START_DONE,
623     MSM_VIDC_STOP,
624     MSM_VIDC_STOP_DONE,
625     MSM_VIDC_RELEASE_RESOURCES,
626     MSM_VIDC_RELEASE_RESOURCES_DONE,
627     MSM_VIDC_CLOSE,
628     MSM_VIDC_CLOSE_DONE,
629     MSM_VIDC_CORE_UNINIT,
630 };
631 #endif
632 
633