1/*-------------------------------------------------------------------------- 2Copyright (c) 2012-2017, 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#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#ifdef _PQ_ 43#include "gpustats.h" 44#endif 45#include "omx_video_common.h" 46#include "omx_video_base.h" 47#include "omx_video_encoder.h" 48#include <linux/videodev2.h> 49#include <media/msm_vidc.h> 50#include <poll.h> 51#include <list> 52 53#define TIMEOUT 5*60*1000 54#define BIT(num) (1 << (num)) 55#define MAX_HYB_HIERP_LAYERS 6 56#define MAX_AVC_HP_LAYERS (4) 57#define MAX_V4L2_BUFS 64 //VB2_MAX_FRAME 58 59enum hier_type { 60 HIER_NONE = 0x0, 61 HIER_P = 0x1, 62 HIER_B = 0x2, 63 HIER_P_HYBRID = 0x3, 64}; 65 66struct msm_venc_switch { 67 unsigned char status; 68}; 69 70struct msm_venc_allocatorproperty { 71 unsigned long mincount; 72 unsigned long actualcount; 73 unsigned long datasize; 74 unsigned long suffixsize; 75 unsigned long alignment; 76 unsigned long bufpoolid; 77}; 78 79struct msm_venc_basecfg { 80 unsigned long input_width; 81 unsigned long input_height; 82 unsigned long dvs_width; 83 unsigned long dvs_height; 84 unsigned long codectype; 85 unsigned long fps_num; 86 unsigned long fps_den; 87 unsigned long targetbitrate; 88 unsigned long inputformat; 89}; 90 91struct msm_venc_profile { 92 unsigned long profile; 93}; 94struct msm_venc_profilelevel { 95 unsigned long level; 96}; 97 98struct msm_venc_sessionqp { 99 unsigned long iframeqp; 100 unsigned long pframeqp; 101 unsigned long bframeqp; 102}; 103 104struct msm_venc_initqp { 105 unsigned long iframeqp; 106 unsigned long pframeqp; 107 unsigned long bframeqp; 108 unsigned long enableinitqp; 109}; 110 111struct msm_venc_qprange { 112 unsigned long maxqp; 113 unsigned long minqp; 114}; 115 116struct msm_venc_ipb_qprange { 117 unsigned long max_i_qp; 118 unsigned long min_i_qp; 119 unsigned long max_p_qp; 120 unsigned long min_p_qp; 121 unsigned long max_b_qp; 122 unsigned long min_b_qp; 123}; 124 125struct msm_venc_intraperiod { 126 unsigned long num_pframes; 127 unsigned long num_bframes; 128}; 129struct msm_venc_seqheader { 130 unsigned char *hdrbufptr; 131 unsigned long bufsize; 132 unsigned long hdrlen; 133}; 134 135struct msm_venc_capability { 136 unsigned long codec_types; 137 unsigned long maxframe_width; 138 unsigned long maxframe_height; 139 unsigned long maxtarget_bitrate; 140 unsigned long maxframe_rate; 141 unsigned long input_formats; 142 unsigned char dvs; 143}; 144 145struct msm_venc_entropycfg { 146 unsigned longentropysel; 147 unsigned long cabacmodel; 148}; 149 150struct msm_venc_dbcfg { 151 unsigned long db_mode; 152 unsigned long slicealpha_offset; 153 unsigned long slicebeta_offset; 154}; 155 156struct msm_venc_intrarefresh { 157 unsigned long irmode; 158 unsigned long mbcount; 159}; 160 161struct msm_venc_multiclicecfg { 162 unsigned long mslice_mode; 163 unsigned long mslice_size; 164}; 165 166struct msm_venc_bufferflush { 167 unsigned long flush_mode; 168}; 169 170struct msm_venc_ratectrlcfg { 171 unsigned long rcmode; 172}; 173 174struct msm_venc_voptimingcfg { 175 unsigned long voptime_resolution; 176}; 177struct msm_venc_framerate { 178 unsigned long fps_denominator; 179 unsigned long fps_numerator; 180}; 181 182struct msm_venc_targetbitrate { 183 unsigned long target_bitrate; 184}; 185 186 187struct msm_venc_rotation { 188 unsigned long rotation; 189}; 190 191struct msm_venc_timeout { 192 unsigned long millisec; 193}; 194 195struct msm_venc_headerextension { 196 unsigned long header_extension; 197}; 198 199struct msm_venc_video_capability { 200 unsigned int min_width; 201 unsigned int max_width; 202 unsigned int min_height; 203 unsigned int max_height; 204}; 205 206struct msm_venc_idrperiod { 207 unsigned long idrperiod; 208}; 209 210struct msm_venc_slice_delivery { 211 unsigned long enable; 212}; 213 214struct msm_venc_hierlayers { 215 unsigned int numlayers; 216 enum hier_type hier_mode; 217}; 218 219struct msm_venc_ltrinfo { 220 unsigned int enabled; 221 unsigned int count; 222}; 223 224struct msm_venc_perf_level { 225 unsigned int perflevel; 226}; 227 228struct msm_venc_vui_timing_info { 229 unsigned int enabled; 230}; 231 232struct msm_venc_vqzip_sei_info { 233 unsigned int enabled; 234}; 235 236struct msm_venc_peak_bitrate { 237 unsigned int peakbitrate; 238}; 239 240struct msm_venc_vpx_error_resilience { 241 unsigned int enable; 242}; 243 244struct msm_venc_priority { 245 OMX_U32 priority; 246}; 247 248struct msm_venc_hybrid_hp { 249 unsigned int nSize; 250 unsigned int nKeyFrameInterval; 251 unsigned int nTemporalLayerBitrateRatio[OMX_VIDEO_MAX_HP_LAYERS]; 252 unsigned int nMinQuantizer; 253 unsigned int nMaxQuantizer; 254 unsigned int nHpLayers; 255}; 256 257struct msm_venc_color_space { 258 OMX_U32 primaries; 259 OMX_U32 range; 260 OMX_U32 matrix_coeffs; 261 OMX_U32 transfer_chars; 262}; 263 264struct msm_venc_temporal_layers { 265 enum hier_type hier_mode; 266 OMX_U32 nMaxLayers; 267 OMX_U32 nMaxBLayers; 268 OMX_U32 nPLayers; 269 OMX_U32 nBLayers; 270 OMX_BOOL bIsBitrateRatioValid; 271 // cumulative ratio: eg [25, 50, 75, 100] means [L0=25%, L1=25%, L2=25%, L3=25%] 272 OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS]; 273 // Layerwise ratio: eg [L0=25%, L1=25%, L2=25%, L3=25%] 274 OMX_U32 nTemporalLayerBitrateFraction[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS]; 275}; 276 277enum v4l2_ports { 278 CAPTURE_PORT, 279 OUTPUT_PORT, 280 MAX_PORT 281}; 282 283struct extradata_buffer_info { 284 unsigned long buffer_size; 285 char* uaddr; 286 int count; 287 int size; 288 OMX_BOOL allocated; 289 enum v4l2_ports port_index; 290#ifdef USE_ION 291 struct venc_ion ion; 292 unsigned int m_ion_dev; 293#endif 294 bool vqzip_sei_found; 295}; 296 297struct statistics { 298 struct timeval prev_tv; 299 int prev_fbd; 300 int bytes_generated; 301}; 302 303enum rc_modes { 304 RC_VBR_VFR = BIT(0), 305 RC_VBR_CFR = BIT(1), 306 RC_CBR_VFR = BIT(2), 307 RC_CBR_CFR = BIT(3), 308 RC_MBR_CFR = BIT(4), 309 RC_MBR_VFR = BIT(5), 310 RC_ALL = (RC_VBR_VFR | RC_VBR_CFR 311 | RC_CBR_VFR | RC_CBR_CFR | RC_MBR_CFR | RC_MBR_VFR) 312}; 313 314class venc_dev 315{ 316 public: 317 venc_dev(class omx_venc *venc_class); //constructor 318 ~venc_dev(); //des 319 320 static void* async_venc_message_thread (void *); 321 bool venc_open(OMX_U32); 322 void venc_close(); 323 unsigned venc_stop(void); 324 unsigned venc_pause(void); 325 unsigned venc_start(void); 326 unsigned venc_flush(unsigned); 327#ifdef _ANDROID_ICS_ 328 bool venc_set_meta_mode(bool); 329#endif 330 unsigned venc_resume(void); 331 unsigned venc_start_done(void); 332 unsigned venc_stop_done(void); 333 unsigned venc_set_message_thread_id(pthread_t); 334 bool venc_use_buf(void*, unsigned,unsigned); 335 bool venc_free_buf(void*, unsigned); 336 bool venc_empty_buf(void *, void *,unsigned,unsigned); 337 bool venc_fill_buf(void *, void *,unsigned,unsigned); 338 339 bool venc_get_buf_req(OMX_U32 *,OMX_U32 *, 340 OMX_U32 *,OMX_U32); 341 bool venc_set_buf_req(OMX_U32 *,OMX_U32 *, 342 OMX_U32 *,OMX_U32); 343 bool venc_set_param(void *,OMX_INDEXTYPE); 344 bool venc_set_config(void *configData, OMX_INDEXTYPE index); 345 bool venc_h264_transform_8x8(OMX_BOOL enable); 346 bool venc_get_profile_level(OMX_U32 *eProfile,OMX_U32 *eLevel); 347 bool venc_get_seq_hdr(void *, unsigned, unsigned *); 348 bool venc_loaded_start(void); 349 bool venc_loaded_stop(void); 350 bool venc_loaded_start_done(void); 351 bool venc_loaded_stop_done(void); 352 bool venc_is_video_session_supported(unsigned long width, unsigned long height); 353 bool venc_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width, 354 OMX_U32 height); 355 bool venc_get_performance_level(OMX_U32 *perflevel); 356 bool venc_get_vui_timing_info(OMX_U32 *enabled); 357 bool venc_get_vqzip_sei_info(OMX_U32 *enabled); 358 bool venc_get_peak_bitrate(OMX_U32 *peakbitrate); 359 bool venc_get_batch_size(OMX_U32 *size); 360 bool venc_get_pq_status(OMX_BOOL *pq_status); 361 bool venc_get_temporal_layer_caps(OMX_U32 * /*nMaxLayers*/, 362 OMX_U32 * /*nMaxBLayers*/); 363 bool venc_get_output_log_flag(); 364 bool venc_check_valid_config(); 365 int venc_output_log_buffers(const char *buffer_addr, int buffer_len); 366 int venc_input_log_buffers(OMX_BUFFERHEADERTYPE *buffer, int fd, int plane_offset, 367 unsigned long inputformat); 368 int venc_extradata_log_buffers(char *buffer_addr); 369 bool venc_set_bitrate_type(OMX_U32 type); 370 371#ifdef _VQZIP_ 372 class venc_dev_vqzip 373 { 374 public: 375 venc_dev_vqzip(); 376 ~venc_dev_vqzip(); 377 bool init(); 378 void deinit(); 379 struct VQZipConfig pConfig; 380 int tempSEI[300]; 381 int fill_stats_data(void* pBuf, void *pStats); 382 typedef void (*vqzip_deinit_t)(void*); 383 typedef void* (*vqzip_init_t)(void); 384 typedef VQZipStatus (*vqzip_compute_stats_t)(void* const , const void * const , const VQZipConfig* ,VQZipStats*); 385 private: 386 pthread_mutex_t lock; 387 void *mLibHandle; 388 void *mVQZIPHandle; 389 vqzip_init_t mVQZIPInit; 390 vqzip_deinit_t mVQZIPDeInit; 391 vqzip_compute_stats_t mVQZIPComputeStats; 392 }; 393 venc_dev_vqzip vqzip; 394#endif 395 396#ifdef _PQ_ 397 class venc_dev_pq 398 { 399 public: 400 venc_dev_pq(); 401 ~venc_dev_pq(); 402 bool is_pq_enabled; 403 bool is_pq_force_disable; 404 bool is_YUV_format_uncertain; 405 pthread_mutex_t lock; 406 struct extradata_buffer_info roi_extradata_info; 407 bool init(unsigned long); 408 void deinit(); 409 void get_caps(); 410 int configure(unsigned long width, unsigned long height); 411 bool is_pq_handle_valid(); 412 bool is_color_format_supported(unsigned long); 413 bool reinit(unsigned long); 414 struct gpu_stats_lib_input_config pConfig; 415 int fill_pq_stats(struct v4l2_buffer buf, unsigned int data_offset); 416 gpu_stats_lib_caps_t caps; 417 typedef gpu_stats_lib_op_status (*gpu_stats_lib_init_t)(void**, enum perf_hint gpu_hint, enum color_compression_format format); 418 typedef gpu_stats_lib_op_status (*gpu_stats_lib_deinit_t)(void*); 419 typedef gpu_stats_lib_op_status (*gpu_stats_lib_get_caps_t)(void* handle, gpu_stats_lib_caps_t *caps); 420 typedef gpu_stats_lib_op_status (*gpu_stats_lib_configure_t)(void* handle, gpu_stats_lib_input_config *input_t); 421 typedef gpu_stats_lib_op_status (*gpu_stats_lib_fill_data_t)(void *handle, gpu_stats_lib_buffer_params_t *yuv_input, 422 gpu_stats_lib_buffer_params_t *roi_input, 423 gpu_stats_lib_buffer_params_t *stats_output, void *addr, void *user_data); 424 private: 425 void *mLibHandle; 426 void *mPQHandle; 427 gpu_stats_lib_init_t mPQInit; 428 gpu_stats_lib_get_caps_t mPQGetCaps; 429 gpu_stats_lib_configure_t mPQConfigure; 430 gpu_stats_lib_deinit_t mPQDeInit; 431 gpu_stats_lib_fill_data_t mPQComputeStats; 432 unsigned long configured_format; 433 }; 434 venc_dev_pq m_pq; 435 bool venc_check_for_pq(void); 436 void venc_configure_pq(void); 437 void venc_try_enable_pq(void); 438#endif 439 struct venc_debug_cap m_debug; 440 OMX_U32 m_nDriver_fd; 441 int m_poll_efd; 442 bool m_profile_set; 443 bool m_level_set; 444 int num_input_planes, num_output_planes; 445 int etb, ebd, ftb, fbd; 446 struct recon_buffer { 447 unsigned char* virtual_address; 448 int pmem_fd; 449 int size; 450 int alignment; 451 int offset; 452#ifdef USE_ION 453 int ion_device_fd; 454 struct ion_allocation_data alloc_data; 455 struct ion_fd_data ion_alloc_fd; 456#endif 457 }; 458 459 int stopped; 460 int resume_in_stopped; 461 bool m_max_allowed_bitrate_check; 462 pthread_t m_tid; 463 bool async_thread_created; 464 bool async_thread_force_stop; 465 class omx_venc *venc_handle; 466 OMX_ERRORTYPE allocate_extradata(struct extradata_buffer_info *extradata_info, int flags); 467 void free_extradata_all(); 468 void free_extradata(struct extradata_buffer_info *extradata_info); 469 int append_mbi_extradata(void *, struct msm_vidc_extradata_header*); 470 bool handle_output_extradata(void *, int); 471 bool handle_input_extradata(struct v4l2_buffer); 472 int venc_set_format(int); 473 bool deinterlace_enabled; 474 bool hw_overload; 475 bool is_gralloc_source_ubwc; 476 bool is_camera_source_ubwc; 477 bool is_csc_enabled; 478 OMX_U32 fd_list[64]; 479 480 private: 481 OMX_U32 m_codec; 482 struct msm_venc_basecfg m_sVenc_cfg; 483 struct msm_venc_ratectrlcfg rate_ctrl; 484 struct msm_venc_targetbitrate bitrate; 485 struct msm_venc_intraperiod intra_period; 486 struct msm_venc_profile codec_profile; 487 struct msm_venc_profilelevel profile_level; 488 struct msm_venc_switch set_param; 489 struct msm_venc_voptimingcfg time_inc; 490 struct msm_venc_allocatorproperty m_sInput_buff_property; 491 struct msm_venc_allocatorproperty m_sOutput_buff_property; 492 struct msm_venc_sessionqp session_qp; 493 struct msm_venc_initqp init_qp; 494 struct msm_venc_qprange session_qp_range; 495 struct msm_venc_qprange session_qp_values; 496 struct msm_venc_ipb_qprange session_ipb_qp_values; 497 struct msm_venc_multiclicecfg multislice; 498 struct msm_venc_entropycfg entropy; 499 struct msm_venc_dbcfg dbkfilter; 500 struct msm_venc_intrarefresh intra_refresh; 501 struct msm_venc_headerextension hec; 502 struct msm_venc_voptimingcfg voptimecfg; 503 struct msm_venc_video_capability capability; 504 struct msm_venc_idrperiod idrperiod; 505 struct msm_venc_slice_delivery slice_mode; 506 struct msm_venc_hierlayers hier_layers; 507 struct msm_venc_perf_level performance_level; 508 struct msm_venc_vui_timing_info vui_timing_info; 509 struct msm_venc_vqzip_sei_info vqzip_sei_info; 510 struct msm_venc_peak_bitrate peak_bitrate; 511 struct msm_venc_ltrinfo ltrinfo; 512 struct msm_venc_vpx_error_resilience vpx_err_resilience; 513 struct msm_venc_priority sess_priority; 514 OMX_U32 operating_rate; 515 int rc_off_level; 516 struct msm_venc_hybrid_hp hybrid_hp; 517 struct msm_venc_color_space color_space; 518 msm_venc_temporal_layers temporal_layers_config; 519 520 bool venc_set_profile_level(OMX_U32 eProfile,OMX_U32 eLevel); 521 bool venc_set_intra_period(OMX_U32 nPFrames, OMX_U32 nBFrames); 522 bool venc_set_target_bitrate(OMX_U32 nTargetBitrate, OMX_U32 config); 523 bool venc_set_ratectrl_cfg(OMX_VIDEO_CONTROLRATETYPE eControlRate); 524 bool venc_set_session_qp(OMX_U32 i_frame_qp, OMX_U32 p_frame_qp,OMX_U32 b_frame_qp); 525 bool venc_set_session_qp_range(OMX_U32 min_qp, OMX_U32 max_qp); 526 bool venc_set_session_qp_range_packed(OMX_U32 min_qp, OMX_U32 max_qp); 527 bool venc_set_encode_framerate(OMX_U32 encode_framerate, OMX_U32 config); 528 bool venc_set_intra_vop_refresh(OMX_BOOL intra_vop_refresh); 529 bool venc_set_color_format(OMX_COLOR_FORMATTYPE color_format); 530 bool venc_validate_profile_level(OMX_U32 *eProfile, OMX_U32 *eLevel); 531 bool venc_set_multislice_cfg(OMX_INDEXTYPE codec, OMX_U32 slicesize); 532 bool venc_set_entropy_config(OMX_BOOL enable, OMX_U32 i_cabac_level); 533 bool venc_set_inloop_filter(OMX_VIDEO_AVCLOOPFILTERTYPE loop_filter); 534 bool venc_set_intra_refresh (OMX_VIDEO_INTRAREFRESHTYPE intrarefresh, OMX_U32 nMBs); 535 bool venc_set_error_resilience(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* error_resilience); 536 bool venc_set_voptiming_cfg(OMX_U32 nTimeIncRes); 537 void venc_config_print(); 538 bool venc_set_slice_delivery_mode(OMX_U32 enable); 539 bool venc_set_extradata(OMX_U32 extra_data, OMX_BOOL enable); 540 bool venc_set_idr_period(OMX_U32 nPFrames, OMX_U32 nIDRPeriod); 541 bool venc_reconfig_reqbufs(); 542 bool venc_set_vpe_rotation(OMX_S32 rotation_angle); 543 bool venc_set_deinterlace(OMX_U32 enable); 544 bool venc_set_ltrmode(OMX_U32 enable, OMX_U32 count); 545 bool venc_enable_initial_qp(QOMX_EXTNINDEX_VIDEO_INITIALQP* initqp); 546 bool venc_set_useltr(OMX_U32 frameIdx); 547 bool venc_set_markltr(OMX_U32 frameIdx); 548 bool venc_set_inband_video_header(OMX_BOOL enable); 549 bool venc_set_au_delimiter(OMX_BOOL enable); 550 bool venc_set_hier_layers(QOMX_VIDEO_HIERARCHICALCODINGTYPE type, OMX_U32 num_layers); 551 bool venc_set_perf_level(QOMX_VIDEO_PERF_LEVEL ePerfLevel); 552 bool venc_set_vui_timing_info(OMX_BOOL enable); 553 bool venc_set_peak_bitrate(OMX_U32 nPeakBitrate); 554 bool venc_set_searchrange(); 555 bool venc_set_vpx_error_resilience(OMX_BOOL enable); 556 bool venc_set_perf_mode(OMX_U32 mode); 557 bool venc_set_mbi_statistics_mode(OMX_U32 mode); 558 bool venc_set_vqzip_sei_type(OMX_BOOL enable); 559 bool venc_set_hybrid_hierp(QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE* hhp); 560 bool venc_set_batch_size(OMX_U32 size); 561 bool venc_calibrate_gop(); 562 bool venc_set_vqzip_defaults(); 563 int venc_get_index_from_fd(OMX_U32 ion_fd, OMX_U32 buffer_fd); 564 bool venc_validate_hybridhp_params(OMX_U32 layers, OMX_U32 bFrames, OMX_U32 count, int mode); 565 bool venc_set_hierp_layers(OMX_U32 hierp_layers); 566 bool venc_set_baselayerid(OMX_U32 baseid); 567 bool venc_set_qp(OMX_U32 nQp); 568 bool venc_set_aspectratio(void *nSar); 569 bool venc_set_priority(OMX_U32 priority); 570 bool venc_set_session_priority(OMX_U32 priority); 571 bool venc_set_operatingrate(OMX_U32 rate); 572 bool venc_set_layer_bitrates(OMX_U32 *pLayerBitrates, OMX_U32 numLayers); 573 bool venc_set_lowlatency_mode(OMX_BOOL enable); 574 bool venc_set_low_latency(OMX_BOOL enable); 575 bool venc_set_roi_qp_info(OMX_QTI_VIDEO_CONFIG_ROIINFO *roiInfo); 576 bool venc_set_blur_resolution(OMX_QTI_VIDEO_CONFIG_BLURINFO *blurInfo); 577 bool venc_set_colorspace(OMX_U32 primaries, OMX_U32 range, OMX_U32 transfer_chars, OMX_U32 matrix_coeffs); 578 OMX_ERRORTYPE venc_set_temporal_layers(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE *pTemporalParams); 579 OMX_ERRORTYPE venc_set_temporal_layers_internal(); 580 bool venc_set_iframesize_type(QOMX_VIDEO_IFRAMESIZE_TYPE type); 581 582#ifdef MAX_RES_1080P 583 OMX_U32 pmem_free(); 584 OMX_U32 pmem_allocate(OMX_U32 size, OMX_U32 alignment, OMX_U32 count); 585 OMX_U32 venc_allocate_recon_buffers(); 586 inline int clip2(int x) { 587 x = x -1; 588 x = x | x >> 1; 589 x = x | x >> 2; 590 x = x | x >> 4; 591 x = x | x >> 16; 592 x = x + 1; 593 return x; 594 } 595#endif 596 int metadatamode; 597 bool streaming[MAX_PORT]; 598 bool extradata; 599 struct extradata_buffer_info input_extradata_info; 600 struct extradata_buffer_info output_extradata_info; 601 602 pthread_mutex_t pause_resume_mlock; 603 pthread_cond_t pause_resume_cond; 604 bool paused; 605 int color_format; 606 bool is_searchrange_set; 607 bool enable_mv_narrow_searchrange; 608 int supported_rc_modes; 609 bool is_thulium_v1; 610 bool camera_mode_enabled; 611 OMX_BOOL low_latency_mode; 612 struct roidata { 613 bool dirty; 614 OMX_TICKS timestamp; 615 OMX_QTI_VIDEO_CONFIG_ROIINFO info; 616 }; 617 bool m_roi_enabled; 618 pthread_mutex_t m_roilock; 619 std::list<roidata> m_roilist; 620 void get_roi_for_timestamp(struct roidata &roi, OMX_TICKS timestamp); 621 bool venc_empty_batch (OMX_BUFFERHEADERTYPE *buf, unsigned index); 622 static const int kMaxBuffersInBatch = 16; 623 unsigned int mBatchSize; 624 struct BatchInfo { 625 BatchInfo(); 626 /* register a buffer and obtain its unique id (v4l2-buf-id) 627 */ 628 int registerBuffer(int bufferId); 629 /* retrieve the buffer given its v4l2-buf-id 630 */ 631 int retrieveBufferAt(int v4l2Id); 632 bool isPending(int bufferId); 633 634 private: 635 static const int kMaxBufs = 64; 636 static const int kBufIDFree = -1; 637 pthread_mutex_t mLock; 638 int mBufMap[64]; // Map with slots for each buffer 639 size_t mNumPending; 640 641 }; 642 BatchInfo mBatchInfo; 643}; 644 645enum instance_state { 646 MSM_VIDC_CORE_UNINIT_DONE = 0x0001, 647 MSM_VIDC_CORE_INIT, 648 MSM_VIDC_CORE_INIT_DONE, 649 MSM_VIDC_OPEN, 650 MSM_VIDC_OPEN_DONE, 651 MSM_VIDC_LOAD_RESOURCES, 652 MSM_VIDC_LOAD_RESOURCES_DONE, 653 MSM_VIDC_START, 654 MSM_VIDC_START_DONE, 655 MSM_VIDC_STOP, 656 MSM_VIDC_STOP_DONE, 657 MSM_VIDC_RELEASE_RESOURCES, 658 MSM_VIDC_RELEASE_RESOURCES_DONE, 659 MSM_VIDC_CLOSE, 660 MSM_VIDC_CLOSE_DONE, 661 MSM_VIDC_CORE_UNINIT, 662}; 663#endif 664 665