1 /*-------------------------------------------------------------------------- 2 Copyright (c) 2012-2018, 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.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 unsigned int m_ion_dev; 271 #endif 272 bool vqzip_sei_found; 273 }; 274 275 struct statistics { 276 struct timeval prev_tv; 277 int prev_fbd; 278 int bytes_generated; 279 }; 280 281 enum rc_modes { 282 RC_VBR_VFR = BIT(0), 283 RC_VBR_CFR = BIT(1), 284 RC_CBR_VFR = BIT(2), 285 RC_CBR_CFR = BIT(3), 286 RC_MBR_CFR = BIT(4), 287 RC_MBR_VFR = BIT(5), 288 RC_CQ = BIT(6), 289 RC_ALL = (RC_VBR_VFR | RC_VBR_CFR 290 | RC_CBR_VFR | RC_CBR_CFR | RC_MBR_CFR | RC_MBR_VFR | RC_CQ) 291 }; 292 293 class venc_dev 294 { 295 public: 296 venc_dev(class omx_venc *venc_class); //constructor 297 ~venc_dev(); //des 298 299 static void* async_venc_message_thread (void *); 300 bool venc_open(OMX_U32); 301 void venc_close(); 302 unsigned venc_stop(void); 303 unsigned venc_pause(void); 304 bool is_streamon_done(OMX_U32 port); 305 unsigned venc_start(void); 306 unsigned venc_flush(unsigned); 307 #ifdef _ANDROID_ICS_ 308 bool venc_set_meta_mode(bool); 309 #endif 310 unsigned venc_resume(void); 311 unsigned venc_start_done(void); 312 unsigned venc_stop_done(void); 313 unsigned venc_set_message_thread_id(pthread_t); 314 bool allocate_extradata(unsigned); 315 bool venc_free_buf(void*, unsigned); 316 bool venc_empty_buf(void *, void *,unsigned,unsigned); 317 bool venc_fill_buf(void *, void *,unsigned,unsigned); 318 bool venc_get_buf_req(OMX_U32 *,OMX_U32 *, 319 OMX_U32 *,OMX_U32); 320 bool venc_set_buf_req(OMX_U32 *,OMX_U32 *, 321 OMX_U32 *,OMX_U32); 322 bool venc_set_param(void *,OMX_INDEXTYPE); 323 bool venc_set_config(void *configData, OMX_INDEXTYPE index); 324 bool venc_h264_transform_8x8(OMX_BOOL enable); 325 bool venc_get_profile_level(OMX_U32 *eProfile,OMX_U32 *eLevel); 326 bool venc_get_seq_hdr(void *, unsigned, unsigned *); 327 bool venc_get_dimensions(OMX_U32 portIndex, OMX_U32 *w, OMX_U32 *h); 328 bool venc_loaded_start(void); 329 bool venc_loaded_stop(void); 330 bool venc_handle_empty_eos_buffer(void); 331 bool venc_loaded_start_done(void); 332 bool venc_loaded_stop_done(void); 333 bool venc_is_video_session_supported(unsigned long width, unsigned long height); 334 bool venc_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width, 335 OMX_U32 height); 336 bool venc_get_vui_timing_info(OMX_U32 *enabled); 337 bool venc_get_vqzip_sei_info(OMX_U32 *enabled); 338 bool venc_get_peak_bitrate(OMX_U32 *peakbitrate); 339 bool venc_get_batch_size(OMX_U32 *size); 340 bool venc_get_temporal_layer_caps(OMX_U32 * /*nMaxLayers*/, 341 OMX_U32 * /*nMaxBLayers*/, OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE */*SupportedPattern*/); 342 OMX_ERRORTYPE venc_get_supported_profile_level(OMX_VIDEO_PARAM_PROFILELEVELTYPE *profileLevelType); 343 bool venc_get_supported_color_format(unsigned index, OMX_U32 *colorFormat); 344 bool venc_check_for_hybrid_hp(OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern); 345 bool venc_check_for_hierp(OMX_VIDEO_ANDROID_TEMPORALLAYERINGPATTERNTYPE ePattern); 346 int venc_find_hier_type(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 347 OMX_ERRORTYPE venc_disable_hp(); 348 OMX_ERRORTYPE venc_disable_hhp(); 349 OMX_ERRORTYPE venc_set_hp(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 350 OMX_ERRORTYPE venc_set_hhp(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 351 OMX_ERRORTYPE venc_set_bitrate_ratio(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 352 bool venc_convert_abs2cum_bitrate(QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE *, 353 OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 354 bool venc_validate_temporal_settings(); 355 bool venc_validate_temporal_extn(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 356 OMX_ERRORTYPE venc_set_temporal_settings(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 357 void venc_copy_temporal_settings(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE &temporalSettings); 358 bool venc_get_output_log_flag(); 359 int venc_output_log_buffers(const char *buffer_addr, int buffer_len, uint64_t timestamp); 360 int venc_input_log_buffers(OMX_BUFFERHEADERTYPE *buffer, int fd, int plane_offset, 361 unsigned long inputformat); 362 int venc_extradata_log_buffers(char *buffer_addr); 363 bool venc_set_bitrate_type(OMX_U32 type); 364 bool venc_get_hevc_profile(OMX_U32* profile); 365 366 #ifdef _VQZIP_ 367 class venc_dev_vqzip 368 { 369 public: 370 venc_dev_vqzip(); 371 ~venc_dev_vqzip(); 372 bool init(); 373 void deinit(); 374 struct VQZipConfig pConfig; 375 int tempSEI[300]; 376 int fill_stats_data(void* pBuf, void *pStats); 377 typedef void (*vqzip_deinit_t)(void*); 378 typedef void* (*vqzip_init_t)(void); 379 typedef VQZipStatus (*vqzip_compute_stats_t)(void* const , const void * const , const VQZipConfig* ,VQZipStats*); 380 private: 381 pthread_mutex_t lock; 382 void *mLibHandle; 383 void *mVQZIPHandle; 384 vqzip_init_t mVQZIPInit; 385 vqzip_deinit_t mVQZIPDeInit; 386 vqzip_compute_stats_t mVQZIPComputeStats; 387 }; 388 venc_dev_vqzip vqzip; 389 #endif 390 391 struct venc_debug_cap m_debug; 392 OMX_U32 m_nDriver_fd; 393 int m_poll_efd; 394 int num_input_planes, num_output_planes; 395 int etb, ebd, ftb, fbd; 396 struct recon_buffer { 397 unsigned char* virtual_address; 398 int pmem_fd; 399 int size; 400 int alignment; 401 int offset; 402 #ifdef USE_ION 403 int ion_device_fd; 404 struct ion_allocation_data alloc_data; 405 struct ion_fd_data ion_alloc_fd; 406 #endif 407 }; 408 409 int nPframes_cache; 410 int stopped; 411 int resume_in_stopped; 412 bool m_max_allowed_bitrate_check; 413 pthread_t m_tid; 414 bool async_thread_created; 415 bool async_thread_force_stop; 416 class omx_venc *venc_handle; 417 OMX_ERRORTYPE allocate_extradata(struct extradata_buffer_info *extradata_info, int flags); 418 void free_extradata_all(); 419 void free_extradata(struct extradata_buffer_info *extradata_info); 420 int append_mbi_extradata(void *, struct msm_vidc_extradata_header*); 421 void append_extradata_mbidata(OMX_OTHER_EXTRADATATYPE *, struct msm_vidc_extradata_header *); 422 void append_extradata_ltrinfo(OMX_OTHER_EXTRADATATYPE *, struct msm_vidc_extradata_header *); 423 void append_extradata_none(OMX_OTHER_EXTRADATATYPE *); 424 bool handle_output_extradata(void *, int); 425 bool handle_input_extradata(struct v4l2_buffer); 426 int venc_set_format(int); 427 bool deinterlace_enabled; 428 bool hw_overload; 429 bool is_gralloc_source_ubwc; 430 bool is_camera_source_ubwc; 431 bool is_csc_custom_matrix_enabled; 432 bool csc_enable; 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 474 bool venc_query_cap(struct v4l2_queryctrl &cap); 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 int venc_get_index_from_fd(OMX_U32 ion_fd, OMX_U32 buffer_fd); 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_tile_dimension(OMX_U32 nTileDimension); 535 536 OMX_U32 pmem_free(); 537 OMX_U32 pmem_allocate(OMX_U32 size, OMX_U32 alignment, OMX_U32 count); 538 OMX_U32 venc_allocate_recon_buffers(); clip2(int x)539 inline int clip2(int x) { 540 x = x -1; 541 x = x | x >> 1; 542 x = x | x >> 2; 543 x = x | x >> 4; 544 x = x | x >> 16; 545 x = x + 1; 546 return x; 547 } 548 int metadatamode; 549 bool streaming[MAX_PORT]; 550 bool extradata; 551 struct extradata_buffer_info input_extradata_info; 552 struct extradata_buffer_info output_extradata_info; 553 554 pthread_mutex_t pause_resume_mlock; 555 pthread_cond_t pause_resume_cond; 556 bool paused; 557 int color_format; 558 bool is_searchrange_set; 559 bool enable_mv_narrow_searchrange; 560 int supported_rc_modes; 561 bool camera_mode_enabled; 562 struct roidata { 563 bool dirty; 564 OMX_TICKS timestamp; 565 OMX_QTI_VIDEO_CONFIG_ROIINFO info; 566 }; 567 bool m_roi_enabled; 568 pthread_mutex_t m_roilock; 569 std::list<roidata> m_roilist; 570 void get_roi_for_timestamp(struct roidata &roi, OMX_TICKS timestamp); 571 bool venc_empty_batch (OMX_BUFFERHEADERTYPE *buf, unsigned index); 572 static const int kMaxBuffersInBatch = 16; 573 unsigned int mBatchSize; 574 struct BatchInfo { 575 BatchInfo(); 576 /* register a buffer and obtain its unique id (v4l2-buf-id) 577 */ 578 int registerBuffer(int bufferId); 579 /* retrieve the buffer given its v4l2-buf-id 580 */ 581 int retrieveBufferAt(int v4l2Id); 582 bool isPending(int bufferId); 583 584 private: 585 static const int kMaxBufs = 64; 586 static const int kBufIDFree = -1; 587 pthread_mutex_t mLock; 588 int mBufMap[64]; // Map with slots for each buffer 589 size_t mNumPending; 590 591 }; 592 BatchInfo mBatchInfo; 593 bool mUseAVTimerTimestamps; 594 bool venc_set_hdr_info(const MasteringDisplay&, const ContentLightLevel&); 595 bool mIsGridset; 596 OMX_U32 mTileDimension; 597 }; 598 599 enum instance_state { 600 MSM_VIDC_CORE_UNINIT_DONE = 0x0001, 601 MSM_VIDC_CORE_INIT, 602 MSM_VIDC_CORE_INIT_DONE, 603 MSM_VIDC_OPEN, 604 MSM_VIDC_OPEN_DONE, 605 MSM_VIDC_LOAD_RESOURCES, 606 MSM_VIDC_LOAD_RESOURCES_DONE, 607 MSM_VIDC_START, 608 MSM_VIDC_START_DONE, 609 MSM_VIDC_STOP, 610 MSM_VIDC_STOP_DONE, 611 MSM_VIDC_RELEASE_RESOURCES, 612 MSM_VIDC_RELEASE_RESOURCES_DONE, 613 MSM_VIDC_CLOSE, 614 MSM_VIDC_CLOSE_DONE, 615 MSM_VIDC_CORE_UNINIT, 616 }; 617 #endif 618 619