1 /*-------------------------------------------------------------------------- 2 Copyright (c) 2012-2016, 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 "OMX_QCOMExtns.h" 36 #include "qc_omx_component.h" 37 #ifdef _VQZIP_ 38 #include "VQZip.h" 39 #endif 40 #include "omx_video_common.h" 41 #include "omx_video_base.h" 42 #include "omx_video_encoder.h" 43 #include <linux/videodev2.h> 44 #include <media/msm_vidc.h> 45 #include <poll.h> 46 47 #define TIMEOUT 5*60*1000 48 #define BIT(num) (1 << (num)) 49 #define MAX_HYB_HIERP_LAYERS 6 50 #define MAX_AVC_HP_LAYERS (4) 51 #define MAX_V4L2_BUFS 64 //VB2_MAX_FRAME 52 53 enum hier_type { 54 HIER_NONE = 0x0, 55 HIER_P = 0x1, 56 HIER_B = 0x2, 57 HIER_P_HYBRID = 0x3, 58 }; 59 60 struct msm_venc_switch { 61 unsigned char status; 62 }; 63 64 struct msm_venc_allocatorproperty { 65 unsigned long mincount; 66 unsigned long actualcount; 67 unsigned long datasize; 68 unsigned long suffixsize; 69 unsigned long alignment; 70 unsigned long bufpoolid; 71 }; 72 73 struct msm_venc_basecfg { 74 unsigned long input_width; 75 unsigned long input_height; 76 unsigned long dvs_width; 77 unsigned long dvs_height; 78 unsigned long codectype; 79 unsigned long fps_num; 80 unsigned long fps_den; 81 unsigned long targetbitrate; 82 unsigned long inputformat; 83 }; 84 85 struct msm_venc_profile { 86 unsigned long profile; 87 }; 88 struct msm_venc_profilelevel { 89 unsigned long level; 90 }; 91 92 struct msm_venc_sessionqp { 93 unsigned long iframeqp; 94 unsigned long pframeqp; 95 unsigned long bframeqp; 96 }; 97 98 struct msm_venc_initqp { 99 unsigned long iframeqp; 100 unsigned long pframeqp; 101 unsigned long bframeqp; 102 unsigned long enableinitqp; 103 }; 104 105 struct msm_venc_qprange { 106 unsigned long maxqp; 107 unsigned long minqp; 108 }; 109 struct msm_venc_intraperiod { 110 unsigned long num_pframes; 111 unsigned long num_bframes; 112 }; 113 struct msm_venc_seqheader { 114 unsigned char *hdrbufptr; 115 unsigned long bufsize; 116 unsigned long hdrlen; 117 }; 118 119 struct msm_venc_capability { 120 unsigned long codec_types; 121 unsigned long maxframe_width; 122 unsigned long maxframe_height; 123 unsigned long maxtarget_bitrate; 124 unsigned long maxframe_rate; 125 unsigned long input_formats; 126 unsigned char dvs; 127 }; 128 129 struct msm_venc_entropycfg { 130 unsigned longentropysel; 131 unsigned long cabacmodel; 132 }; 133 134 struct msm_venc_dbcfg { 135 unsigned long db_mode; 136 unsigned long slicealpha_offset; 137 unsigned long slicebeta_offset; 138 }; 139 140 struct msm_venc_intrarefresh { 141 unsigned long irmode; 142 unsigned long mbcount; 143 }; 144 145 struct msm_venc_multiclicecfg { 146 unsigned long mslice_mode; 147 unsigned long mslice_size; 148 }; 149 150 struct msm_venc_bufferflush { 151 unsigned long flush_mode; 152 }; 153 154 struct msm_venc_ratectrlcfg { 155 unsigned long rcmode; 156 }; 157 158 struct msm_venc_voptimingcfg { 159 unsigned long voptime_resolution; 160 }; 161 struct msm_venc_framerate { 162 unsigned long fps_denominator; 163 unsigned long fps_numerator; 164 }; 165 166 struct msm_venc_targetbitrate { 167 unsigned long target_bitrate; 168 }; 169 170 171 struct msm_venc_rotation { 172 unsigned long rotation; 173 }; 174 175 struct msm_venc_timeout { 176 unsigned long millisec; 177 }; 178 179 struct msm_venc_headerextension { 180 unsigned long header_extension; 181 }; 182 183 struct msm_venc_video_capability { 184 unsigned int min_width; 185 unsigned int max_width; 186 unsigned int min_height; 187 unsigned int max_height; 188 }; 189 190 struct msm_venc_idrperiod { 191 unsigned long idrperiod; 192 }; 193 194 struct msm_venc_slice_delivery { 195 unsigned long enable; 196 }; 197 198 struct msm_venc_hierlayers { 199 unsigned int numlayers; 200 enum hier_type hier_mode; 201 }; 202 203 struct msm_venc_ltrinfo { 204 unsigned int enabled; 205 unsigned int count; 206 }; 207 208 struct msm_venc_perf_level { 209 unsigned int perflevel; 210 }; 211 212 struct msm_venc_vui_timing_info { 213 unsigned int enabled; 214 }; 215 216 struct msm_venc_vqzip_sei_info { 217 unsigned int enabled; 218 }; 219 220 struct msm_venc_peak_bitrate { 221 unsigned int peakbitrate; 222 }; 223 224 struct msm_venc_vpx_error_resilience { 225 unsigned int enable; 226 }; 227 228 struct msm_venc_priority { 229 OMX_U32 priority; 230 }; 231 232 struct msm_venc_hybrid_hp { 233 unsigned int nSize; 234 unsigned int nKeyFrameInterval; 235 unsigned int nTemporalLayerBitrateRatio[OMX_VIDEO_MAX_HP_LAYERS]; 236 unsigned int nMinQuantizer; 237 unsigned int nMaxQuantizer; 238 unsigned int nHpLayers; 239 }; 240 241 struct msm_venc_temporal_layers { 242 enum hier_type hier_mode; 243 OMX_U32 nMaxLayers; 244 OMX_U32 nMaxBLayers; 245 OMX_U32 nPLayers; 246 OMX_U32 nBLayers; 247 OMX_BOOL bIsBitrateRatioValid; 248 // cumulative ratio: eg [25, 50, 75, 100] means [L0=25%, L1=25%, L2=25%, L3=25%] 249 OMX_U32 nTemporalLayerBitrateRatio[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS]; 250 // Layerwise ratio: eg [L0=25%, L1=25%, L2=25%, L3=25%] 251 OMX_U32 nTemporalLayerBitrateFraction[OMX_VIDEO_ANDROID_MAXTEMPORALLAYERS]; 252 }; 253 254 struct msm_venc_color_space { 255 OMX_U32 primaries; 256 OMX_U32 range; 257 OMX_U32 matrix_coeffs; 258 OMX_U32 transfer_chars; 259 }; 260 261 enum v4l2_ports { 262 CAPTURE_PORT, 263 OUTPUT_PORT, 264 MAX_PORT 265 }; 266 267 class encExtradata { 268 private: 269 enum { 270 FREE, 271 BUSY, 272 FOR_CONFIG, 273 }; 274 struct info { 275 int status; 276 void *cookie; 277 }; 278 pthread_mutex_t lock; 279 unsigned int mCount; 280 ssize_t mSize; 281 char *mUaddr; 282 struct venc_ion mIon; 283 struct info mIndex[MAX_V4L2_BUFS]; 284 class omx_venc *mVencHandle; 285 int __get(char **userptr, int *fd, unsigned *offset, ssize_t *size, int type); 286 OMX_ERRORTYPE __allocate(); 287 void __free(); 288 void __debug(); 289 public: 290 unsigned int mDbgEtbCount; 291 encExtradata(class omx_venc *venc_handle); 292 ~encExtradata(); 293 void update(unsigned int count, ssize_t size); 294 /* Get extradata whose status is FREE. */ 295 OMX_ERRORTYPE get(char **userptr, int *fd, unsigned *offset, ssize_t *size); 296 /* Get extradata which is tagged with cookie via setCookieForConfigExtradata. If no extradata is tagged with this cookie then get extradata whose status is FREE. */ 297 OMX_ERRORTYPE get(void *cookie, char **userptr, int *fd, unsigned *offset, ssize_t *size); 298 /* return the extradata back to the pool of FREE extradata. */ 299 OMX_ERRORTYPE put(char *userptr); 300 /* If there is already an extradata with status FOR_CONFIG, return that else return FREE extradata. */ 301 OMX_ERRORTYPE getForConfig(char **userptr, int *fd, unsigned *offset, ssize_t *size); 302 /* Return the extradata pointer corresponding to the index. Does not change status of extradata. */ 303 OMX_ERRORTYPE peek(unsigned index, char **userptr, int *fd, unsigned* offset, ssize_t *size); 304 /* Attach a cookie to extradata. Extradata with this cookie can be retrieved via getExtradata call.*/ 305 void setCookieForConfig(void *cookie); 306 ssize_t getBufferSize(); 307 unsigned int getBufferCount(); 308 bool vqzip_sei_found; 309 }; 310 311 struct statistics { 312 struct timeval prev_tv; 313 int prev_fbd; 314 int bytes_generated; 315 }; 316 317 enum rc_modes { 318 RC_VBR_VFR = BIT(0), 319 RC_VBR_CFR = BIT(1), 320 RC_CBR_VFR = BIT(2), 321 RC_CBR_CFR = BIT(3), 322 RC_ALL = (RC_VBR_VFR | RC_VBR_CFR 323 | RC_CBR_VFR | RC_CBR_CFR) 324 }; 325 326 class venc_dev 327 { 328 public: 329 venc_dev(class omx_venc *venc_class); //constructor 330 ~venc_dev(); //des 331 332 static void* async_venc_message_thread (void *); 333 bool venc_open(OMX_U32); 334 void venc_close(); 335 unsigned venc_stop(void); 336 unsigned venc_pause(void); 337 unsigned venc_start(void); 338 unsigned venc_flush(unsigned); 339 #ifdef _ANDROID_ICS_ 340 bool venc_set_meta_mode(bool); 341 #endif 342 unsigned venc_resume(void); 343 unsigned venc_start_done(void); 344 unsigned venc_stop_done(void); 345 unsigned venc_set_message_thread_id(pthread_t); 346 bool venc_use_buf(void*, unsigned,unsigned); 347 bool venc_free_buf(void*, unsigned); 348 bool venc_empty_buf(void *, void *,unsigned,unsigned); 349 bool venc_fill_buf(void *, void *,unsigned,unsigned); 350 351 bool venc_get_buf_req(OMX_U32 *,OMX_U32 *, 352 OMX_U32 *,OMX_U32); 353 bool venc_set_buf_req(OMX_U32 *,OMX_U32 *, 354 OMX_U32 *,OMX_U32); 355 bool venc_set_param(void *,OMX_INDEXTYPE); 356 bool venc_set_config(void *configData, OMX_INDEXTYPE index); 357 bool venc_get_profile_level(OMX_U32 *eProfile,OMX_U32 *eLevel); 358 bool venc_get_seq_hdr(void *, unsigned, unsigned *); 359 bool venc_get_dimensions(OMX_U32 portIndex, OMX_U32 *w, OMX_U32 *h); 360 bool venc_loaded_start(void); 361 bool venc_loaded_stop(void); 362 bool venc_loaded_start_done(void); 363 bool venc_loaded_stop_done(void); 364 bool venc_is_video_session_supported(unsigned long width, unsigned long height); 365 bool venc_color_align(OMX_BUFFERHEADERTYPE *buffer, OMX_U32 width, 366 OMX_U32 height); 367 bool venc_get_performance_level(OMX_U32 *perflevel); 368 bool venc_get_vui_timing_info(OMX_U32 *enabled); 369 bool venc_get_vqzip_sei_info(OMX_U32 *enabled); 370 bool venc_get_peak_bitrate(OMX_U32 *peakbitrate); 371 bool venc_get_batch_size(OMX_U32 *size); 372 bool venc_get_temporal_layer_caps(OMX_U32 * /*nMaxLayers*/, 373 OMX_U32 * /*nMaxBLayers*/); 374 bool venc_get_output_log_flag(); 375 bool venc_check_valid_config(); 376 int venc_output_log_buffers(const char *buffer_addr, int buffer_len); 377 int venc_input_log_buffers(OMX_BUFFERHEADERTYPE *buffer, int fd, int plane_offset, 378 unsigned long inputformat); 379 int venc_extradata_log_buffers(char *buffer_addr); 380 bool venc_set_bitrate_type(OMX_U32 type); 381 int venc_roiqp_log_buffers(OMX_QTI_VIDEO_CONFIG_ROIINFO *roiInfo); 382 383 #ifdef _VQZIP_ 384 class venc_dev_vqzip 385 { 386 public: 387 venc_dev_vqzip(); 388 ~venc_dev_vqzip(); 389 bool init(); 390 void deinit(); 391 struct VQZipConfig pConfig; 392 int tempSEI[300]; 393 int fill_stats_data(void* pBuf, void *pStats); 394 typedef void (*vqzip_deinit_t)(void*); 395 typedef void* (*vqzip_init_t)(void); 396 typedef VQZipStatus (*vqzip_compute_stats_t)(void* const , const void * const , const VQZipConfig* ,VQZipStats*); 397 private: 398 pthread_mutex_t lock; 399 void *mLibHandle; 400 void *mVQZIPHandle; 401 vqzip_init_t mVQZIPInit; 402 vqzip_deinit_t mVQZIPDeInit; 403 vqzip_compute_stats_t mVQZIPComputeStats; 404 }; 405 venc_dev_vqzip vqzip; 406 #endif 407 struct venc_debug_cap m_debug; 408 OMX_U32 m_nDriver_fd; 409 int m_poll_efd; 410 bool m_profile_set; 411 bool m_level_set; 412 int num_input_planes, num_output_planes; 413 int etb, ebd, ftb, fbd; 414 struct recon_buffer { 415 unsigned char* virtual_address; 416 int pmem_fd; 417 int size; 418 int alignment; 419 int offset; 420 #ifdef USE_ION 421 int ion_device_fd; 422 struct ion_allocation_data alloc_data; 423 struct ion_fd_data ion_alloc_fd; 424 #endif 425 }; 426 427 int stopped; 428 int resume_in_stopped; 429 bool m_max_allowed_bitrate_check; 430 pthread_t m_tid; 431 bool async_thread_created; 432 bool async_thread_force_stop; 433 class omx_venc *venc_handle; 434 int append_mbi_extradata(void *, struct msm_vidc_extradata_header*); 435 bool handle_output_extradata(void *); 436 bool handle_input_extradata(void *, int); 437 int venc_set_format(int); 438 bool deinterlace_enabled; 439 bool hw_overload; 440 bool is_gralloc_source_ubwc; 441 bool is_camera_source_ubwc; 442 bool is_csc_enabled; 443 OMX_U32 fd_list[64]; 444 encExtradata mInputExtradata; 445 encExtradata mOutputExtradata; 446 447 private: 448 OMX_U32 m_codec; 449 struct msm_venc_basecfg m_sVenc_cfg; 450 struct msm_venc_ratectrlcfg rate_ctrl; 451 struct msm_venc_targetbitrate bitrate; 452 struct msm_venc_intraperiod intra_period; 453 struct msm_venc_profile codec_profile; 454 struct msm_venc_profilelevel profile_level; 455 struct msm_venc_switch set_param; 456 struct msm_venc_voptimingcfg time_inc; 457 struct msm_venc_allocatorproperty m_sInput_buff_property; 458 struct msm_venc_allocatorproperty m_sOutput_buff_property; 459 struct msm_venc_sessionqp session_qp; 460 struct msm_venc_initqp init_qp; 461 struct msm_venc_qprange session_qp_range; 462 struct msm_venc_qprange session_qp_values; 463 struct msm_venc_multiclicecfg multislice; 464 struct msm_venc_entropycfg entropy; 465 struct msm_venc_dbcfg dbkfilter; 466 struct msm_venc_intrarefresh intra_refresh; 467 struct msm_venc_headerextension hec; 468 struct msm_venc_voptimingcfg voptimecfg; 469 struct msm_venc_video_capability capability; 470 struct msm_venc_idrperiod idrperiod; 471 struct msm_venc_slice_delivery slice_mode; 472 struct msm_venc_hierlayers hier_layers; 473 struct msm_venc_perf_level performance_level; 474 struct msm_venc_vui_timing_info vui_timing_info; 475 struct msm_venc_vqzip_sei_info vqzip_sei_info; 476 struct msm_venc_peak_bitrate peak_bitrate; 477 struct msm_venc_ltrinfo ltrinfo; 478 struct msm_venc_vpx_error_resilience vpx_err_resilience; 479 struct msm_venc_priority sess_priority; 480 OMX_U32 operating_rate; 481 int rc_off_level; 482 struct msm_venc_hybrid_hp hybrid_hp; 483 msm_venc_temporal_layers temporal_layers_config; 484 struct msm_venc_color_space color_space; 485 486 bool venc_set_profile_level(OMX_U32 eProfile,OMX_U32 eLevel); 487 bool venc_set_intra_period_config(OMX_U32 nPFrames, OMX_U32 nBFrames); 488 bool venc_set_intra_period(OMX_U32 nPFrames, OMX_U32 nBFrames); 489 bool venc_set_target_bitrate(OMX_U32 nTargetBitrate, OMX_U32 config); 490 bool venc_set_ratectrl_cfg(OMX_VIDEO_CONTROLRATETYPE eControlRate); 491 bool venc_set_session_qp(OMX_U32 i_frame_qp, OMX_U32 p_frame_qp,OMX_U32 b_frame_qp); 492 bool venc_set_session_qp_range(OMX_U32 min_qp, OMX_U32 max_qp); 493 bool venc_set_encode_framerate(OMX_U32 encode_framerate, OMX_U32 config); 494 bool venc_set_intra_vop_refresh(OMX_BOOL intra_vop_refresh); 495 bool venc_set_color_format(OMX_COLOR_FORMATTYPE color_format); 496 bool venc_validate_profile_level(OMX_U32 *eProfile, OMX_U32 *eLevel); 497 bool venc_set_multislice_cfg(OMX_INDEXTYPE codec, OMX_U32 slicesize); 498 bool venc_set_entropy_config(OMX_BOOL enable, OMX_U32 i_cabac_level); 499 bool venc_set_inloop_filter(OMX_VIDEO_AVCLOOPFILTERTYPE loop_filter); 500 bool venc_set_intra_refresh (OMX_VIDEO_INTRAREFRESHTYPE intrarefresh, OMX_U32 nMBs); 501 bool venc_set_error_resilience(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* error_resilience); 502 bool venc_set_voptiming_cfg(OMX_U32 nTimeIncRes); 503 void venc_config_print(); 504 bool venc_set_slice_delivery_mode(OMX_U32 enable); 505 bool venc_set_extradata(OMX_U32 extra_data, OMX_BOOL enable); 506 bool venc_set_idr_period(OMX_U32 nPFrames, OMX_U32 nIDRPeriod); 507 bool venc_reconfig_reqbufs(); 508 bool venc_set_vpe_rotation(OMX_S32 rotation_angle); 509 bool venc_set_deinterlace(OMX_U32 enable); 510 bool venc_set_ltrmode(OMX_U32 enable, OMX_U32 count); 511 bool venc_enable_initial_qp(QOMX_EXTNINDEX_VIDEO_INITIALQP* initqp); 512 bool venc_set_useltr(OMX_U32 frameIdx); 513 bool venc_set_markltr(OMX_U32 frameIdx); 514 bool venc_set_inband_video_header(OMX_BOOL enable); 515 bool venc_set_au_delimiter(OMX_BOOL enable); 516 bool venc_set_hier_layers(QOMX_VIDEO_HIERARCHICALCODINGTYPE type, OMX_U32 num_layers); 517 bool venc_set_perf_level(QOMX_VIDEO_PERF_LEVEL ePerfLevel); 518 bool venc_set_vui_timing_info(OMX_BOOL enable); 519 bool venc_set_peak_bitrate(OMX_U32 nPeakBitrate); 520 bool venc_set_searchrange(); 521 bool venc_set_vpx_error_resilience(OMX_BOOL enable); 522 bool venc_set_perf_mode(OMX_U32 mode); 523 bool venc_set_mbi_statistics_mode(OMX_U32 mode); 524 bool venc_set_vqzip_sei_type(OMX_BOOL enable); 525 bool venc_set_hybrid_hierp(QOMX_EXTNINDEX_VIDEO_HYBRID_HP_MODE* hhp); 526 bool venc_set_batch_size(OMX_U32 size); 527 bool venc_calibrate_gop(); 528 bool venc_set_vqzip_defaults(); 529 bool venc_validate_hybridhp_params(OMX_U32 layers, OMX_U32 bFrames, OMX_U32 count, int mode); 530 bool venc_set_hierp_layers(OMX_U32 hierp_layers); 531 bool venc_set_baselayerid(OMX_U32 baseid); 532 bool venc_set_qp(OMX_U32 nQp); 533 bool venc_set_aspectratio(void *nSar); 534 bool venc_set_priority(OMX_U32 priority); 535 bool venc_set_session_priority(OMX_U32 priority); 536 bool venc_set_operatingrate(OMX_U32 rate); 537 bool venc_set_layer_bitrates(OMX_U32 *pLayerBitrates, OMX_U32 numLayers); 538 bool venc_set_roi_qp_info(OMX_QTI_VIDEO_CONFIG_ROIINFO *roiInfo); 539 OMX_ERRORTYPE venc_set_temporal_layers(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE *pTemporalParams); 540 OMX_ERRORTYPE venc_set_temporal_layers_internal(); 541 bool venc_set_colorspace(OMX_U32 primaries, OMX_U32 range, OMX_U32 transfer_chars, OMX_U32 matrix_coeffs); 542 543 #ifdef MAX_RES_1080P 544 OMX_U32 pmem_free(); 545 OMX_U32 pmem_allocate(OMX_U32 size, OMX_U32 alignment, OMX_U32 count); 546 OMX_U32 venc_allocate_recon_buffers(); clip2(int x)547 inline int clip2(int x) { 548 x = x -1; 549 x = x | x >> 1; 550 x = x | x >> 2; 551 x = x | x >> 4; 552 x = x | x >> 16; 553 x = x + 1; 554 return x; 555 } 556 #endif 557 int metadatamode; 558 bool streaming[MAX_PORT]; 559 bool extradata; 560 561 pthread_mutex_t pause_resume_mlock; 562 pthread_cond_t pause_resume_cond; 563 bool paused; 564 int color_format; 565 bool is_searchrange_set; 566 bool enable_mv_narrow_searchrange; 567 int supported_rc_modes; 568 bool is_thulium_v1; 569 bool camera_mode_enabled; 570 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 public: 592 // utility methods to parse entities in batch 593 // payload format for batch of 3 594 //| fd0 | fd1 | fd2 | off0 | off1 | off2 | len0 | len1 | len2 | csc0 | csc1 | csc2 | dTS0 | dTS1 | dTS2| 595 static inline int getFdAt(native_handle_t *, int index); 596 static inline int getOffsetAt(native_handle_t *, int index); 597 static inline int getSizeAt(native_handle_t *, int index); 598 static inline int getColorFormatAt(native_handle_t *, int index); 599 static inline int getTimeStampAt(native_handle_t *, int index); 600 }; 601 BatchInfo mBatchInfo; 602 bool mUseAVTimerTimestamps; 603 }; 604 605 enum instance_state { 606 MSM_VIDC_CORE_UNINIT_DONE = 0x0001, 607 MSM_VIDC_CORE_INIT, 608 MSM_VIDC_CORE_INIT_DONE, 609 MSM_VIDC_OPEN, 610 MSM_VIDC_OPEN_DONE, 611 MSM_VIDC_LOAD_RESOURCES, 612 MSM_VIDC_LOAD_RESOURCES_DONE, 613 MSM_VIDC_START, 614 MSM_VIDC_START_DONE, 615 MSM_VIDC_STOP, 616 MSM_VIDC_STOP_DONE, 617 MSM_VIDC_RELEASE_RESOURCES, 618 MSM_VIDC_RELEASE_RESOURCES_DONE, 619 MSM_VIDC_CLOSE, 620 MSM_VIDC_CLOSE_DONE, 621 MSM_VIDC_CORE_UNINIT, 622 }; 623 #endif 624 625