1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19 */ 20 21 /** 22 ******************************************************************************* 23 * @file 24 * ih264e_structs.h 25 * 26 * @brief 27 * Structure definitions used in the encoder 28 * 29 * @author 30 * Harish 31 * 32 * @remarks 33 * None 34 * 35 ******************************************************************************* 36 */ 37 38 #ifndef IH264E_STRUCTS_H_ 39 #define IH264E_STRUCTS_H_ 40 41 /*****************************************************************************/ 42 /* Structure definitions */ 43 /*****************************************************************************/ 44 45 /* Early declaration of structs */ 46 typedef struct _codec_t codec_t; 47 typedef struct _proc_t process_ctxt_t; 48 49 50 /*****************************************************************************/ 51 /* Extern Function type definitions */ 52 /*****************************************************************************/ 53 54 /** 55 ****************************************************************************** 56 * @brief intra prediction filters leaf level 57 ****************************************************************************** 58 */ 59 typedef void (*pf_intra_pred)(UWORD8 *pu1_src, UWORD8 *pu1_dst, 60 WORD32 src_strd, WORD32 dst_strd, 61 WORD32 ui_neighboravailability); 62 63 /** 64 ****************************************************************************** 65 * @brief inter prediction filters leaf level 66 ****************************************************************************** 67 */ 68 69 typedef void (*pf_inter_pred_luma_bilinear)(UWORD8 *pu1_src1, UWORD8 *pu1_src2, UWORD8 *pu1_dst, 70 WORD32 src_strd1, WORD32 src_strd2, WORD32 dst_strd, 71 WORD32 height, WORD32 width); 72 73 /** 74 ****************************************************************************** 75 * @brief fwd transform leaf level 76 ****************************************************************************** 77 */ 78 typedef void (*pf_trans_quant)(UWORD8*pu1_src, UWORD8 *pu1_pred, WORD16 *pi2_out, 79 WORD32 i4_src_stride, UWORD32 u4_pred_stride, UWORD32 u4_dst_stride, 80 const UWORD16 *pu2_scale_mat, const UWORD16 *pu2_thresh_mat, 81 UWORD32 u4_qbit, UWORD32 u4_round_fact, UWORD8 *pu1_nnz); 82 83 typedef void (*pf_iquant_itrans)(WORD16 *pi2_src, UWORD8 *pu1_pred, UWORD8 *pu1_out, 84 WORD32 i4_src_stride, UWORD32 u4_pred_stride, UWORD32 u4_out_stride, 85 const UWORD16 *pu2_iscale_mat, const UWORD16 *pu2_weigh_mat, 86 UWORD32 qp_div, WORD32 *pi4_tmp); 87 88 /** 89 ****************************************************************************** 90 * @brief Padding leaf level 91 ****************************************************************************** 92 */ 93 typedef void (*pf_pad)(UWORD8 *pu1_src, WORD32 src_strd, WORD32 wd, WORD32 pad_size); 94 95 /** 96 ****************************************************************************** 97 * @brief memory handling leaf level 98 ****************************************************************************** 99 */ 100 typedef void (*pf_memcpy)(UWORD8 *pu1_dst, UWORD8 *pu1_src, UWORD32 num_bytes); 101 102 typedef void (*pf_memset)(UWORD8 *pu1_dst, UWORD8 value, UWORD32 num_bytes); 103 104 typedef void (*pf_memcpy_mul8)(UWORD8 *pu1_dst, UWORD8 *pu1_src, UWORD32 num_bytes); 105 106 typedef void (*pf_memset_mul8)(UWORD8 *pu1_dst, UWORD8 value, UWORD32 num_bytes); 107 108 /** 109 ****************************************************************************** 110 * @brief Sad computation 111 ****************************************************************************** 112 */ 113 typedef void (*pf_compute_sad)(UWORD8 *pu1_src, UWORD8 *pu1_est, 114 UWORD32 src_strd, UWORD32 est_strd, 115 WORD32 i4_max_sad, WORD32 *pi4_mb_distortion); 116 117 /** 118 ****************************************************************************** 119 * @brief Intra mode eval:encoder level 120 ****************************************************************************** 121 */ 122 typedef void (*pf_evaluate_intra_modes)(UWORD8 *pu1_src, UWORD8 *pu1_ngbr_pels_i16, UWORD8 *pu1_dst, 123 UWORD32 src_strd, UWORD32 dst_strd, 124 WORD32 u4_n_avblty, UWORD32 *u4_intra_mode, 125 WORD32 *pu4_sadmin, 126 UWORD32 u4_valid_intra_modes); 127 128 typedef void (*pf_evaluate_intra_4x4_modes)(UWORD8 *pu1_src, UWORD8 *pu1_ngbr_pels, UWORD8 *pu1_dst, 129 UWORD32 src_strd, UWORD32 dst_strd, 130 WORD32 u4_n_avblty, UWORD32 *u4_intra_mode, 131 WORD32 *pu4_sadmin, 132 UWORD32 u4_valid_intra_modes, UWORD32 u4_lambda, 133 UWORD32 u4_predictd_mode); 134 135 /** 136 ****************************************************************************** 137 * @brief half_pel generation :encoder level 138 ****************************************************************************** 139 */ 140 typedef void (*pf_sixtapfilter_horz)(UWORD8 *pu1_src, UWORD8 *pu1_dst, 141 WORD32 src_strd, WORD32 dst_strd); 142 143 typedef void (*pf_sixtap_filter_2dvh_vert)(UWORD8 *pu1_src, UWORD8 *pu1_dst1, UWORD8 *pu1_dst2, 144 WORD32 src_strd, WORD32 dst_strd, 145 WORD32 *pi16_pred1, 146 WORD32 pi16_pred1_strd); 147 /** 148 ****************************************************************************** 149 * @brief color space conversion 150 ****************************************************************************** 151 */ 152 typedef void (*pf_fmt_conv_420p_to_420sp)(UWORD8 *pu1_y_src, UWORD8 *pu1_u_src, UWORD8 *pu1_v_src, 153 UWORD8 *pu1_y_dst, UWORD8 *pu1_uv_dst, 154 UWORD16 u2_height, UWORD16 u2_width, 155 UWORD16 src_y_strd, UWORD16 src_u_strd, UWORD16 src_v_strd, 156 UWORD16 dst_y_strd, UWORD16 dst_uv_strd, 157 UWORD32 convert_uv_only); 158 159 typedef void (*pf_fmt_conv_422ile_to_420sp)(UWORD8 *pu1_y_buf, UWORD8 *pu1_u_buf, UWORD8 *pu1_v_buf, 160 UWORD8 *pu1_422i_buf, 161 WORD32 u4_y_width, WORD32 u4_y_height, WORD32 u4_y_stride, 162 WORD32 u4_u_stride, WORD32 u4_v_stride, 163 WORD32 u4_422i_stride); 164 165 166 167 /** 168 ****************************************************************************** 169 * @brief ME evaluation 170 ****************************************************************************** 171 */ 172 typedef void ih264e_compute_me_ft(process_ctxt_t *); 173 174 /** 175 ****************************************************************************** 176 * @brief SKIP decision 177 ****************************************************************************** 178 */ 179 typedef WORD32 ih264e_skip_params_ft(process_ctxt_t *, WORD32); 180 181 182 /*****************************************************************************/ 183 /* Enums */ 184 /*****************************************************************************/ 185 186 /** 187 ****************************************************************************** 188 * @enum CODEC_STATE_T 189 * @brief codec state 190 ****************************************************************************** 191 */ 192 typedef enum 193 { 194 INIT_DONE, 195 HEADER_DONE, 196 FIRST_FRAME_DONE, 197 } CODEC_STATE_T; 198 199 200 /** 201 ****************************************************************************** 202 * @enum JOBQ_CMD_T 203 * @brief list of job commands (used during job instantiation) 204 ****************************************************************************** 205 */ 206 typedef enum 207 { 208 CMD_PROCESS, 209 CMD_ENTROPY, 210 CMD_FMTCONV, 211 CMD_ME, 212 }JOBQ_CMD_T; 213 214 215 /*****************************************************************************/ 216 /* Structures */ 217 /*****************************************************************************/ 218 219 /** 220 * PU information 221 */ 222 typedef struct 223 { 224 /** 225 * Motion Vector 226 */ 227 mv_t s_mv; 228 229 /** 230 * Ref index 231 */ 232 WORD8 i1_ref_idx; 233 234 } enc_pu_mv_t; 235 236 237 /* 238 * Total Pu info for an MB 239 */ 240 typedef struct 241 { 242 243 /* Array with ME info for all lists */ 244 enc_pu_mv_t s_me_info[2]; 245 246 /** 247 * PU X position in terms of min PU (4x4) units 248 */ 249 UWORD32 b4_pos_x : 4; 250 251 /** 252 * PU Y position in terms of min PU (4x4) units 253 */ 254 UWORD32 b4_pos_y : 4; 255 256 /** 257 * PU width in pixels = (b4_wd + 1) << 2 258 */ 259 UWORD32 b4_wd : 2; 260 261 /** 262 * PU height in pixels = (b4_ht + 1) << 2 263 */ 264 UWORD32 b4_ht : 2; 265 266 /** 267 * Intra or Inter flag for each partition - 0 or 1 268 */ 269 UWORD32 b1_intra_flag : 1; 270 271 /** 272 * PRED_L0, PRED_L1, PRED_BI 273 */ 274 UWORD32 b2_pred_mode : 2; 275 276 277 } enc_pu_t; 278 279 280 typedef struct 281 { 282 /** Descriptor of raw buffer */ 283 iv_raw_buf_t s_raw_buf; 284 285 /** Lower 32bits of time stamp corresponding to the above buffer */ 286 UWORD32 u4_timestamp_low; 287 288 /** Upper 32bits of time stamp corresponding to the above buffer */ 289 UWORD32 u4_timestamp_high; 290 291 /** Flag to indicate if the current buffer is last buffer */ 292 UWORD32 u4_is_last; 293 294 /** Flag to indicate if mb info is sent along with input buffer */ 295 UWORD32 u4_mb_info_type; 296 297 /** Flag to indicate the size of mb info structure */ 298 UWORD32 u4_mb_info_size; 299 300 /** Buffer containing mb info if mb_info_type is non-zero */ 301 void *pv_mb_info; 302 303 /** Flag to indicate if pic info is sent along with input buffer */ 304 UWORD32 u4_pic_info_type; 305 306 /** Buffer containing pic info if mb_info_type is non-zero */ 307 void *pv_pic_info; 308 309 }inp_buf_t; 310 311 typedef struct 312 { 313 /** Descriptor of bitstream buffer */ 314 iv_bits_buf_t s_bits_buf; 315 316 /** Lower 32bits of time stamp corresponding to the above buffer */ 317 UWORD32 u4_timestamp_low; 318 319 /** Upper 32bits of time stamp corresponding to the above buffer */ 320 UWORD32 u4_timestamp_high; 321 322 /** Flag to indicate if the current buffer is last buffer */ 323 UWORD32 u4_is_last; 324 325 }out_buf_t; 326 327 typedef struct 328 { 329 /** Descriptor of picture buffer */ 330 pic_buf_t s_pic_buf; 331 332 /** Lower 32bits of time stamp corresponding to the above buffer */ 333 UWORD32 u4_timestamp_low; 334 335 /** Upper 32bits of time stamp corresponding to the above buffer */ 336 UWORD32 u4_timestamp_high; 337 338 /** Flag to indicate if the current buffer is last buffer */ 339 UWORD32 u4_is_last; 340 341 /** Picture count corresponding to current picture */ 342 WORD32 i4_pic_cnt; 343 344 }rec_buf_t; 345 346 typedef struct 347 { 348 /** maximum width for which codec should request memory requirements */ 349 UWORD32 u4_max_wd; 350 351 /** maximum height for which codec should request memory requirements */ 352 UWORD32 u4_max_ht; 353 354 /** Maximum number of reference frames */ 355 UWORD32 u4_max_ref_cnt; 356 357 /** Maximum number of reorder frames */ 358 UWORD32 u4_max_reorder_cnt; 359 360 /** Maximum level supported */ 361 UWORD32 u4_max_level; 362 363 /** Input color format */ 364 IV_COLOR_FORMAT_T e_inp_color_fmt; 365 366 /** Flag to enable/disable - To be used only for debugging/testing */ 367 UWORD32 u4_enable_recon; 368 369 /** Recon color format */ 370 IV_COLOR_FORMAT_T e_recon_color_fmt; 371 372 /** Encoder Speed preset - Value between 0 (slowest) and 100 (fastest) */ 373 IVE_SPEED_CONFIG u4_enc_speed_preset; 374 375 /** Rate control mode */ 376 IVE_RC_MODE_T e_rc_mode; 377 378 /** Maximum frame rate to be supported */ 379 UWORD32 u4_max_framerate; 380 381 /** Maximum bitrate to be supported */ 382 UWORD32 u4_max_bitrate; 383 384 /** Maximum number of consecutive B frames */ 385 UWORD32 u4_num_bframes; 386 387 /** Content type Interlaced/Progressive */ 388 IV_CONTENT_TYPE_T e_content_type; 389 390 /** Maximum search range to be used in X direction */ 391 UWORD32 u4_max_srch_rng_x; 392 393 /** Maximum search range to be used in Y direction */ 394 UWORD32 u4_max_srch_rng_y; 395 396 /** Slice Mode */ 397 IVE_SLICE_MODE_T e_slice_mode; 398 399 /** Slice parameter */ 400 UWORD32 u4_slice_param; 401 402 /** Processor architecture */ 403 IV_ARCH_T e_arch; 404 405 /** SOC details */ 406 IV_SOC_T e_soc; 407 408 /** Input width to be sent in bitstream */ 409 UWORD32 u4_disp_wd; 410 411 /** Input height to be sent in bitstream */ 412 UWORD32 u4_disp_ht; 413 414 /** Input width */ 415 UWORD32 u4_wd; 416 417 /** Input height */ 418 UWORD32 u4_ht; 419 420 /** Input stride */ 421 UWORD32 u4_strd; 422 423 /** Source frame rate */ 424 UWORD32 u4_src_frame_rate; 425 426 /** Target frame rate */ 427 UWORD32 u4_tgt_frame_rate; 428 429 /** Target bitrate in kilobits per second */ 430 UWORD32 u4_target_bitrate; 431 432 /** Force current frame type */ 433 IV_PICTURE_CODING_TYPE_T e_frame_type; 434 435 /** Encoder mode */ 436 IVE_ENC_MODE_T e_enc_mode; 437 438 /** Set initial Qp for I pictures */ 439 UWORD32 u4_i_qp; 440 441 /** Set initial Qp for P pictures */ 442 UWORD32 u4_p_qp; 443 444 /** Set initial Qp for B pictures */ 445 UWORD32 u4_b_qp; 446 447 /** Set minimum Qp for I pictures */ 448 UWORD32 u4_i_qp_min; 449 450 /** Set maximum Qp for I pictures */ 451 UWORD32 u4_i_qp_max; 452 453 /** Set minimum Qp for P pictures */ 454 UWORD32 u4_p_qp_min; 455 456 /** Set maximum Qp for P pictures */ 457 UWORD32 u4_p_qp_max; 458 459 /** Set minimum Qp for B pictures */ 460 UWORD32 u4_b_qp_min; 461 462 /** Set maximum Qp for B pictures */ 463 UWORD32 u4_b_qp_max; 464 465 /** Adaptive intra refresh mode */ 466 IVE_AIR_MODE_T e_air_mode; 467 468 /** Adaptive intra refresh period in frames */ 469 UWORD32 u4_air_refresh_period; 470 471 /** VBV buffer delay */ 472 UWORD32 u4_vbv_buffer_delay; 473 474 /** VBV buffer size */ 475 UWORD32 u4_vbv_buf_size; 476 477 /** Number of cores to be used */ 478 UWORD32 u4_num_cores; 479 480 /** ME speed preset - Value between 0 (slowest) and 100 (fastest) */ 481 UWORD32 u4_me_speed_preset; 482 483 /** Flag to enable/disable half pel motion estimation */ 484 UWORD32 u4_enable_hpel; 485 486 /** Flag to enable/disable quarter pel motion estimation */ 487 UWORD32 u4_enable_qpel; 488 489 /** Flag to enable/disable intra 4x4 analysis */ 490 UWORD32 u4_enable_intra_4x4; 491 492 /** Flag to enable/disable intra 8x8 analysis */ 493 UWORD32 u4_enable_intra_8x8; 494 495 /** Flag to enable/disable intra 16x16 analysis */ 496 UWORD32 u4_enable_intra_16x16; 497 498 /** Flag to enable/disable fast SAD approximation */ 499 UWORD32 u4_enable_fast_sad; 500 501 /*flag to enable/disable alternate reference frames */ 502 UWORD32 u4_enable_alt_ref; 503 504 /*Flag to enable/disable computation of SATDQ in ME*/ 505 UWORD32 u4_enable_satqd; 506 507 /*Minimum SAD to search for*/ 508 WORD32 i4_min_sad; 509 510 /** Maximum search range in X direction for farthest reference */ 511 UWORD32 u4_srch_rng_x; 512 513 /** Maximum search range in Y direction for farthest reference */ 514 UWORD32 u4_srch_rng_y; 515 516 /** I frame interval */ 517 UWORD32 u4_i_frm_interval; 518 519 /** IDR frame interval */ 520 UWORD32 u4_idr_frm_interval; 521 522 /** Disable deblock level (0: Enable completely, 3: Disable completely */ 523 UWORD32 u4_disable_deblock_level; 524 525 /** Profile */ 526 IV_PROFILE_T e_profile; 527 528 /** Lower 32bits of time stamp corresponding to input buffer, 529 * from which this command takes effect */ 530 UWORD32 u4_timestamp_low; 531 532 /** Upper 32bits of time stamp corresponding to input buffer, 533 * from which this command takes effect */ 534 UWORD32 u4_timestamp_high; 535 536 /** Flag to say if the current config parameter set is valid 537 * Will be zero to start with and will be set to 1, when configured 538 * Once encoder uses the parameter set, this will be set to zero */ 539 UWORD32 u4_is_valid; 540 541 /** Command associated with this config param set */ 542 IVE_CONTROL_API_COMMAND_TYPE_T e_cmd; 543 544 /** Input width in mbs */ 545 UWORD32 i4_wd_mbs; 546 547 /** Input height in mbs */ 548 UWORD32 i4_ht_mbs; 549 550 /** entropy coding mode flag */ 551 UWORD32 u4_entropy_coding_mode; 552 553 /** enable weighted prediction */ 554 UWORD32 u4_weighted_prediction; 555 556 /** enable constrained intra prediction */ 557 UWORD32 u4_constrained_intra_pred; 558 559 /** Pic info type */ 560 UWORD32 u4_pic_info_type; 561 /** 562 * MB info type 563 */ 564 UWORD32 u4_mb_info_type; 565 566 /** VUI structure */ 567 vui_t s_vui; 568 569 }cfg_params_t; 570 571 572 573 /** Structure to hold format conversion context */ 574 typedef struct 575 { 576 /** Current row for which format conversion should be done */ 577 WORD32 i4_cur_row; 578 579 /** Number of rows for which format conversion should be done */ 580 WORD32 i4_num_rows; 581 582 }fmt_conv_t; 583 584 585 /** 586 * Structure to represent a processing job entry 587 */ 588 typedef struct 589 { 590 /** 591 * Command 592 */ 593 WORD32 i4_cmd; 594 595 /** 596 * MB x of the starting MB 597 */ 598 WORD16 i2_mb_x; 599 600 /** 601 * MB y of the starting MB 602 */ 603 604 WORD16 i2_mb_y; 605 606 /** 607 * Number of MBs that need to be processed in this job 608 */ 609 WORD16 i2_mb_cnt; 610 611 /** 612 * Process contexts base index 613 * Will toggle between 0 and MAX_PROCESS_THREADS 614 */ 615 WORD16 i2_proc_base_idx; 616 617 } job_t; 618 619 620 /** 621 * Structure to represent a MV Bank buffer 622 */ 623 typedef struct 624 { 625 /** 626 * Pointer to hold num PUs each MB in a picture 627 */ 628 UWORD32 *pu4_mb_pu_cnt; 629 630 /** 631 * Pointer to hold enc_pu_t for each PU in a picture 632 */ 633 enc_pu_t *ps_pic_pu; 634 635 /** 636 * Pointer to hold PU map for each MB in a picture 637 */ 638 UWORD8 *pu1_pic_pu_map; 639 640 /** 641 * Pointer to hold the Slice map 642 */ 643 UWORD16 *pu1_pic_slice_map; 644 645 /** 646 * Absolute POC for the current MV Bank 647 */ 648 WORD32 i4_abs_poc; 649 650 /** 651 * Buffer Id 652 */ 653 WORD32 i4_buf_id; 654 655 } mv_buf_t; 656 657 658 /** 659 * Reference set containing pointers to MV buf and pic buf 660 */ 661 typedef struct 662 { 663 /** Picture count */ 664 WORD32 i4_pic_cnt; 665 666 /** POC */ 667 WORD32 i4_poc; 668 669 /** picture buffer */ 670 pic_buf_t *ps_pic_buf; 671 672 /** mv buffer */ 673 mv_buf_t *ps_mv_buf; 674 675 }ref_set_t; 676 677 typedef struct 678 { 679 680 /** 681 * Pointer to current PPS 682 */ 683 pps_t *ps_pps; 684 685 /** 686 * Pointer to current SPS 687 */ 688 sps_t *ps_sps; 689 690 /** 691 * Pointer to current slice header structure 692 */ 693 slice_header_t *ps_slice_hdr; 694 695 /** 696 * MB's x position within a picture in raster scan in MB units 697 */ 698 WORD32 i4_mb_x; 699 700 /** 701 * MB's y position within a picture in raster scan in MB units 702 */ 703 704 WORD32 i4_mb_y; 705 706 /** 707 * Current PU structure - set to MB enc_pu_t pointer at the start of MB processing and incremented 708 * for every TU 709 */ 710 enc_pu_t *ps_pu; 711 712 /** 713 * Pointer to frame level enc_pu_t for the current frame being parsed 714 * where MVs and Intra pred modes will be updated 715 */ 716 enc_pu_t *ps_pic_pu; 717 718 /** 719 * Pointer to hold num PUs each MB in a picture 720 */ 721 UWORD32 *pu4_mb_pu_cnt; 722 723 /** PU Index map per MB. The indices in this map are w.r.t picture pu array and not 724 * w.r.t MB pu array. 725 * This will be used during mv prediction and since neighbors will have different MB pu map 726 * it will be easier if they all have indices w.r.t picture level PU array rather than MB level 727 * PU array. 728 * pu1_pic_pu_map is map w.r.t MB's enc_pu_t array 729 */ 730 UWORD32 *pu4_pic_pu_idx_map; 731 732 /** 733 * Pointer to pu_map for the current frame being parsed 734 * where MVs and Intra pred modes will be updated 735 */ 736 UWORD8 *pu1_pic_pu_map; 737 738 /** 739 * PU count in current MB 740 */ 741 WORD32 i4_mb_pu_cnt; 742 743 /** 744 * PU count in current MB 745 */ 746 WORD32 i4_mb_start_pu_idx; 747 748 /** 749 * Top availability for current MB level 750 */ 751 UWORD8 u1_top_mb_avail; 752 753 /** 754 * Top right availability for current MB level 755 */ 756 UWORD8 u1_top_rt_mb_avail; 757 /** 758 * Top left availability for current MB level 759 */ 760 UWORD8 u1_top_lt_mb_avail; 761 /** 762 * left availability for current MB level 763 */ 764 UWORD8 u1_left_mb_avail; 765 766 }mv_ctxt_t; 767 768 typedef struct 769 { 770 /** 771 * MB's x position within a picture in raster scan in MB units 772 */ 773 WORD32 i4_mb_x; 774 775 /** 776 * MB's y position within a picture in raster scan in MB units 777 */ 778 WORD32 i4_mb_y; 779 780 /** 781 * MB's x position within a Slice in raster scan in MB units 782 */ 783 WORD32 i4_mb_slice_x; 784 785 /** 786 * MB's y position within a Slice in raster scan in MB units 787 */ 788 WORD32 i4_mb_slice_y; 789 790 /** 791 * Vertical strength, Two bits per edge. 792 * Stored in format. BS[15] | BS[14] | .. |BS[0] 793 */ 794 UWORD32 *pu4_pic_vert_bs; 795 796 /** 797 * Boundary strength, Two bits per edge. 798 * Stored in format. BS[15] | BS[14] | .. |BS[0] 799 */ 800 UWORD32 *pu4_pic_horz_bs; 801 802 /** 803 * Qp array stored for each mb 804 */ 805 UWORD8 *pu1_pic_qp; 806 807 }bs_ctxt_t; 808 809 typedef struct 810 { 811 /** 812 * MB's x position within a picture in raster scan in MB units 813 */ 814 WORD32 i4_mb_x; 815 816 /** 817 * MB's y position within a picture in raster scan in MB units 818 */ 819 WORD32 i4_mb_y; 820 821 /** 822 * structure that contains BS and QP frame level arrays 823 */ 824 bs_ctxt_t s_bs_ctxt; 825 826 /** 827 * Pointer to 0th luma pixel in current pic 828 */ 829 UWORD8 *pu1_cur_pic_luma; 830 831 /** 832 * Pointer to 0th chroma pixel in current pic 833 */ 834 UWORD8 *pu1_cur_pic_chroma; 835 836 /** 837 * Points to the array of slice indices which is used to identify the slice 838 * to which each MB in a frame belongs. 839 */ 840 UWORD8 *pu1_slice_idx; 841 842 }deblk_ctxt_t; 843 844 845 /** 846 ****************************************************************************** 847 * @brief Structure to hold data and flags for 'n' mb processing for 848 * deblocking , padding and half pel generation. 849 ****************************************************************************** 850 */ 851 typedef struct 852 { 853 /** 854 * MB's x position last processed + 1 855 */ 856 WORD32 i4_mb_x; 857 858 /** 859 * MB's y position ,current processing. 860 */ 861 WORD32 i4_mb_y; 862 863 /** 864 * Number of MBs processed in a stretch 865 */ 866 WORD32 i4_n_mbs; 867 868 }n_mb_process_ctxt_t; 869 870 871 /** 872 ****************************************************************************** 873 * @brief Structure to hold coefficient info for a 4x4 subblock. 874 * The following can be used to type-cast coefficient data that is stored 875 * per subblock. Note that though i2_level is shown as an array that 876 * holds 16 coefficients, only the first few entries will be valid. Next 877 * subblocks data starts after the valid number of coefficients. Number 878 * of non-zero coefficients will be derived using number of non-zero bits 879 * in sig coeff map 880 ****************************************************************************** 881 */ 882 typedef struct 883 { 884 /** 885 * significant coefficient map and nnz are packed in 886 * to msb (2 bytes) and lsb (2 bytes) respectively 887 */ 888 WORD32 i4_sig_map_nnz; 889 890 /** 891 * array of non zero residue coefficients 892 */ 893 WORD16 ai2_residue[16]; 894 895 }tu_sblk_coeff_data_t; 896 897 /** 898 ****************************************************************************** 899 * @brief Structure contains few common state variables such as MB indices, 900 * current SPS, PPS etc which are to be used in the entropy thread. By keeping 901 * it a different structure it is being explicitly signaled that these 902 * variables are specific to entropy threads context and other threads should 903 * not update these elements 904 ****************************************************************************** 905 */ 906 typedef struct 907 { 908 /** 909 * Pointer to the cabac context 910 */ 911 cabac_ctxt_t *ps_cabac; 912 913 /** 914 * start of frame / start of slice flag 915 */ 916 WORD32 i4_sof; 917 918 /** 919 * end of frame / end of slice flag 920 */ 921 WORD32 i4_eof; 922 923 /** 924 * generate header upon request 925 */ 926 WORD32 i4_gen_header; 927 928 /** 929 * seq_parameter_set_id 930 */ 931 UWORD32 u4_sps_id; 932 933 /** 934 * Pointer to base of sequence parameter set structure array 935 */ 936 sps_t *ps_sps_base; 937 938 /** 939 * pic_parameter_set_id 940 */ 941 UWORD32 u4_pps_id; 942 943 /** 944 * Pointer to base of Picture parameter set structure array 945 */ 946 pps_t *ps_pps_base; 947 948 /** 949 * Current slice idx 950 */ 951 WORD32 i4_cur_slice_idx; 952 953 /** 954 * Points to the array of slice indices which is used to identify the independent slice 955 * to which each MB in a frame belongs. 956 */ 957 UWORD8 *pu1_slice_idx; 958 959 /** 960 * Pointer to base of slice header structure array 961 */ 962 slice_header_t *ps_slice_hdr_base; 963 964 /** 965 * entropy status 966 */ 967 UWORD8 *pu1_entropy_map; 968 969 /** 970 * MB's x position within a picture in raster scan in MB units 971 */ 972 WORD32 i4_mb_x; 973 974 /** 975 * MB's y position within a picture in raster scan in MB units 976 */ 977 WORD32 i4_mb_y; 978 979 /** 980 * MB start address 981 */ 982 WORD32 i4_mb_cnt; 983 984 /** 985 * MB start address 986 */ 987 WORD32 i4_mb_start_add; 988 989 /** 990 * MB end address 991 */ 992 WORD32 i4_mb_end_add; 993 994 /** 995 * Input width in mbs 996 */ 997 WORD32 i4_wd_mbs; 998 999 /** 1000 * Input height in mbs 1001 */ 1002 WORD32 i4_ht_mbs; 1003 1004 /** 1005 * Bitstream structure 1006 */ 1007 bitstrm_t *ps_bitstrm; 1008 1009 /** 1010 * transform_8x8_mode_flag 1011 */ 1012 WORD8 i1_transform_8x8_mode_flag; 1013 1014 /** 1015 * entropy_coding_mode_flag 1016 */ 1017 WORD8 u1_entropy_coding_mode_flag; 1018 1019 /** 1020 * Pointer to the top row nnz for luma 1021 */ 1022 UWORD8 (*pu1_top_nnz_luma)[4]; 1023 1024 /** 1025 * left nnz for luma 1026 */ 1027 UWORD32 u4_left_nnz_luma; 1028 1029 /** 1030 * Pointer to zero runs before for the mb 1031 */ 1032 UWORD8 au1_zero_run[16]; 1033 1034 /** 1035 * Pointer to the top row nnz for chroma 1036 */ 1037 UWORD8 (*pu1_top_nnz_cbcr)[4]; 1038 1039 /** 1040 * left nnz for chroma 1041 */ 1042 UWORD8 u4_left_nnz_cbcr; 1043 1044 /** 1045 * Pointer frame level mb subblock coeff data 1046 */ 1047 void *pv_pic_mb_coeff_data; 1048 1049 /** 1050 * Pointer to mb subblock coeff data and number of subblocks and scan idx 1051 * Incremented each time a coded subblock is processed 1052 */ 1053 void *pv_mb_coeff_data; 1054 1055 /** 1056 * Pointer frame level mb header data 1057 */ 1058 void *pv_pic_mb_header_data; 1059 1060 /** 1061 * Pointer to mb header data and 1062 * incremented each time a coded mb is encoded 1063 */ 1064 void *pv_mb_header_data; 1065 1066 /** 1067 * Error code during parse stage 1068 */ 1069 IH264E_ERROR_T i4_error_code; 1070 1071 /** 1072 * Void pointer to job context 1073 */ 1074 void *pv_proc_jobq, *pv_entropy_jobq; 1075 1076 /** 1077 * Flag to signal end of frame 1078 */ 1079 WORD32 i4_end_of_frame; 1080 1081 /** 1082 * Abs POC count of the frame 1083 */ 1084 WORD32 i4_abs_pic_order_cnt; 1085 1086 /** 1087 * mb skip run 1088 */ 1089 WORD32 *pi4_mb_skip_run; 1090 1091 /** 1092 * Flag to signal end of sequence 1093 */ 1094 UWORD32 u4_is_last; 1095 1096 /** 1097 * Lower 32bits of time-stamp corresponding to the buffer being encoded 1098 */ 1099 UWORD32 u4_timestamp_low; 1100 1101 /** 1102 * Upper 32bits of time-stamp corresponding to the buffer being encoded 1103 */ 1104 UWORD32 u4_timestamp_high; 1105 1106 /** 1107 * Current Picture count - used for synchronization 1108 */ 1109 WORD32 i4_pic_cnt; 1110 1111 /** 1112 * Number of bits consumed by header for I and P mb types 1113 */ 1114 UWORD32 u4_header_bits[MAX_MB_TYPE]; 1115 1116 /** 1117 * Number of bits consumed by residue for I and P mb types 1118 */ 1119 UWORD32 u4_residue_bits[MAX_MB_TYPE]; 1120 1121 } entropy_ctxt_t; 1122 1123 /** 1124 ****************************************************************************** 1125 * @brief macro block info. 1126 ****************************************************************************** 1127 */ 1128 typedef struct 1129 { 1130 /** 1131 * mb type 1132 */ 1133 UWORD16 u2_is_intra; 1134 1135 /** 1136 * mb type 1137 */ 1138 UWORD16 u2_mb_type; 1139 1140 /** 1141 * csbp 1142 */ 1143 UWORD32 u4_csbp; 1144 1145 /** 1146 * mb distortion 1147 */ 1148 WORD32 i4_mb_distortion; 1149 1150 }mb_info_t; 1151 1152 /** 1153 ****************************************************************************** 1154 * @brief structure presenting the neighbor availability of a mb 1155 * or subblk or any other partition 1156 ****************************************************************************** 1157 */ 1158 typedef struct 1159 { 1160 /** 1161 * left blk/subblk/partition 1162 */ 1163 UWORD8 u1_mb_a; 1164 1165 /** 1166 * top blk/subblk/partition 1167 */ 1168 UWORD8 u1_mb_b; 1169 1170 /** 1171 * topright blk/subblk/partition 1172 */ 1173 UWORD8 u1_mb_c; 1174 1175 /** 1176 * topleft blk/subblk/partition 1177 */ 1178 UWORD8 u1_mb_d; 1179 1180 }block_neighbors_t; 1181 1182 /** 1183 ****************************************************************************** 1184 * @brief MB info related variables used during NMB processing 1185 ****************************************************************************** 1186 */ 1187 typedef struct 1188 { 1189 UWORD32 u4_mb_type; 1190 UWORD32 u4_min_sad; 1191 UWORD32 u4_min_sad_reached; 1192 WORD32 i4_mb_cost; 1193 WORD32 i4_mb_distortion; 1194 1195 enc_pu_mv_t as_skip_mv[4]; 1196 1197 enc_pu_mv_t as_pred_mv[2]; 1198 1199 block_neighbors_t s_ngbr_avbl; 1200 1201 /* 1202 * Buffer to hold best subpel buffer in each MB of NMB 1203 */ 1204 UWORD8 *pu1_best_sub_pel_buf; 1205 1206 /* 1207 * Stride for subpel buffer 1208 */ 1209 UWORD32 u4_bst_spel_buf_strd; 1210 1211 }mb_info_nmb_t; 1212 1213 /** 1214 ****************************************************************************** 1215 * @brief Pixel processing thread context 1216 ****************************************************************************** 1217 */ 1218 struct _proc_t 1219 { 1220 /** 1221 * entropy context 1222 */ 1223 entropy_ctxt_t s_entropy; 1224 1225 /** 1226 * me context 1227 */ 1228 me_ctxt_t s_me_ctxt; 1229 1230 /** 1231 * Pointer to codec context 1232 */ 1233 codec_t *ps_codec; 1234 1235 /** 1236 * N mb process contest 1237 */ 1238 n_mb_process_ctxt_t s_n_mb_ctxt; 1239 1240 /** 1241 * Source pointer to current MB luma 1242 */ 1243 UWORD8 *pu1_src_buf_luma; 1244 1245 /** 1246 * Source pointer to current MB chroma 1247 */ 1248 UWORD8 *pu1_src_buf_chroma; 1249 1250 /** 1251 * Recon pointer to current MB luma 1252 */ 1253 UWORD8 *pu1_rec_buf_luma; 1254 1255 /** 1256 * Recon pointer to current MB chroma 1257 */ 1258 UWORD8 *pu1_rec_buf_chroma; 1259 1260 /** 1261 * Ref pointer to current MB luma 1262 */ 1263 UWORD8 *apu1_ref_buf_luma[MAX_REF_PIC_CNT]; 1264 1265 /** 1266 * Ref pointer to current MB chroma 1267 */ 1268 UWORD8 *apu1_ref_buf_chroma[MAX_REF_PIC_CNT]; 1269 1270 /** 1271 * pointer to luma plane of input buffer (base :: mb (0,0)) 1272 */ 1273 UWORD8 *pu1_src_buf_luma_base; 1274 1275 /** 1276 * pointer to luma plane of reconstructed buffer (base :: mb (0,0)) 1277 */ 1278 UWORD8 *pu1_rec_buf_luma_base; 1279 1280 /** 1281 * pointer to luma plane of ref buffer (base :: mb (0,0)) 1282 */ 1283 UWORD8 *apu1_ref_buf_luma_base[MAX_REF_PIC_CNT]; 1284 1285 /** 1286 * pointer to chroma plane of input buffer (base :: mb (0,0)) 1287 */ 1288 UWORD8 *pu1_src_buf_chroma_base; 1289 1290 /* 1291 * Buffer for color space conversion of luma 1292 */ 1293 UWORD8 *pu1_y_csc_buf; 1294 1295 /* 1296 * Buffer for color space conversion of luma 1297 */ 1298 1299 UWORD8 *pu1_uv_csc_buf; 1300 1301 /** 1302 * pointer to chroma plane of reconstructed buffer (base :: mb (0,0)) 1303 */ 1304 UWORD8 *pu1_rec_buf_chroma_base; 1305 1306 /** 1307 * pointer to chroma plane of reconstructed buffer (base :: mb (0,0)) 1308 */ 1309 UWORD8 *apu1_ref_buf_chroma_base[MAX_REF_PIC_CNT]; 1310 1311 /** 1312 * Pointer to ME NMB info 1313 */ 1314 mb_info_nmb_t *ps_nmb_info; 1315 1316 mb_info_nmb_t *ps_cur_mb; 1317 1318 /** 1319 * source luma stride 1320 */ 1321 WORD32 i4_src_strd; 1322 1323 /** 1324 * source chroma stride 1325 */ 1326 WORD32 i4_src_chroma_strd; 1327 1328 /** 1329 * recon stride & ref stride 1330 * (strides for luma and chroma are the same) 1331 */ 1332 WORD32 i4_rec_strd; 1333 1334 /** 1335 * Offset for half pel x plane from the pic buf 1336 */ 1337 UWORD32 u4_half_x_offset; 1338 1339 /** 1340 * Offset for half pel y plane from half x plane 1341 */ 1342 UWORD32 u4_half_y_offset; 1343 1344 /** 1345 * Offset for half pel xy plane from half y plane 1346 */ 1347 UWORD32 u4_half_xy_offset; 1348 1349 /** 1350 * pred buffer pointer (temp buffer 1) 1351 */ 1352 UWORD8 *pu1_pred_mb; 1353 1354 /** 1355 * pred buffer pointer (prediction buffer for intra 16x16 1356 */ 1357 UWORD8 *pu1_pred_mb_intra_16x16; 1358 1359 /** 1360 * pred buffer pointer (prediction buffer for intra 16x16_plane 1361 */ 1362 UWORD8 *pu1_pred_mb_intra_16x16_plane; 1363 1364 /** 1365 * pred buffer pointer (prediction buffer for intra chroma 1366 */ 1367 UWORD8 *pu1_pred_mb_intra_chroma; 1368 1369 /** 1370 * pred buffer pointer (prediction buffer for intra chroma plane 1371 */ 1372 UWORD8 *pu1_pred_mb_intra_chroma_plane; 1373 1374 /** 1375 * temp. reference buffer ptr for intra 4x4 when rdopt is on 1376 */ 1377 UWORD8 *pu1_ref_mb_intra_4x4; 1378 1379 /** 1380 * prediction buffer stride 1381 */ 1382 WORD32 i4_pred_strd; 1383 1384 /** 1385 * transform buffer pointer (temp buffer 2) 1386 */ 1387 WORD16 *pi2_res_buf; 1388 1389 /** 1390 * temp. transform buffer ptr for intra 4x4 when rdopt is on 1391 */ 1392 WORD16 *pi2_res_buf_intra_4x4; 1393 1394 /** 1395 * transform buffer stride 1396 */ 1397 WORD32 i4_res_strd; 1398 1399 /** 1400 * scratch buffer for inverse transform (temp buffer 3) 1401 */ 1402 void *pv_scratch_buff; 1403 1404 /** 1405 * frame num 1406 */ 1407 WORD32 i4_frame_num; 1408 1409 /** 1410 * start address of frame / sub-frame 1411 */ 1412 WORD32 i4_frame_strt_add; 1413 1414 /** 1415 * IDR pic 1416 */ 1417 UWORD32 u4_is_idr; 1418 1419 /** 1420 * idr_pic_id 1421 */ 1422 UWORD32 u4_idr_pic_id; 1423 1424 /** 1425 * Input width in mbs 1426 */ 1427 WORD32 i4_wd_mbs; 1428 1429 /** 1430 * Input height in mbs 1431 */ 1432 WORD32 i4_ht_mbs; 1433 1434 /** 1435 * slice_type 1436 */ 1437 WORD32 i4_slice_type; 1438 1439 /** 1440 * Current slice idx 1441 */ 1442 WORD32 i4_cur_slice_idx; 1443 1444 /** 1445 * MB's x position within a picture in raster scan in MB units 1446 */ 1447 WORD32 i4_mb_x; 1448 1449 /** 1450 * MB's y position within a picture in raster scan in MB units 1451 */ 1452 WORD32 i4_mb_y; 1453 1454 /** 1455 * MB's x position within a Slice in raster scan in MB units 1456 */ 1457 WORD32 i4_mb_slice_x; 1458 1459 /** 1460 * MB's y position within a Slice in raster scan in MB units 1461 */ 1462 WORD32 i4_mb_slice_y; 1463 1464 /** 1465 * mb type 1466 */ 1467 UWORD32 u4_mb_type; 1468 1469 /** 1470 * is intra 1471 */ 1472 UWORD32 u4_is_intra; 1473 1474 /** 1475 * mb neighbor availability pointer 1476 */ 1477 block_neighbors_t *ps_ngbr_avbl; 1478 1479 /** 1480 * lambda (lagrange multiplier for cost computation) 1481 */ 1482 UWORD32 u4_lambda; 1483 1484 /** 1485 * mb distortion 1486 */ 1487 WORD32 i4_mb_distortion; 1488 1489 /** 1490 * mb cost 1491 */ 1492 WORD32 i4_mb_cost; 1493 1494 /********************************************************************/ 1495 /* i4_ngbr_avbl_mb_16 - ngbr avbl of curr mb */ 1496 /* i4_ngbr_avbl_sb_8 - ngbr avbl of all 8x8 sub blocks of curr mb */ 1497 /* i4_ngbr_avbl_sb_4 - ngbr avbl of all 4x4 sub blocks of curr mb */ 1498 /* i4_ngbr_avbl_mb_c - chroma ngbr avbl of curr mb */ 1499 /********************************************************************/ 1500 WORD32 i4_ngbr_avbl_16x16_mb; 1501 WORD32 ai4_neighbor_avail_8x8_subblks[4]; 1502 UWORD8 au1_ngbr_avbl_4x4_subblks[16]; 1503 WORD32 i4_chroma_neighbor_avail_8x8_mb; 1504 1505 /** 1506 * array to store the mode of mb sub blocks 1507 */ 1508 UWORD8 au1_intra_luma_mb_4x4_modes[16]; 1509 1510 /** 1511 * array to store the predicted mode of mb sub blks 1512 */ 1513 UWORD8 au1_predicted_intra_luma_mb_4x4_modes[16]; 1514 1515 /** 1516 * macro block intra 16x16 mode 1517 */ 1518 UWORD8 u1_l_i16_mode; 1519 1520 /** 1521 * array to store the mode of the macro block intra 8x8 4 modes 1522 */ 1523 UWORD8 au1_intra_luma_mb_8x8_modes[4]; 1524 1525 /** 1526 * intra chroma mb mode 1527 */ 1528 UWORD8 u1_c_i8_mode; 1529 1530 /********************************************************************/ 1531 /* array to store pixels from the neighborhood for intra prediction */ 1532 /* i16 - 16 left pels + 1 top left pel + 16 top pels = 33 pels */ 1533 /* i8 - 8 lpels + 1 tlpels + 8 tpels + 8 tr pels = 25 pels */ 1534 /* i4 - 4 lpels + 1 tlpels + 4 tpels + 4 tr pels = 13 pels */ 1535 /* ic - 8 left pels + 1 top left pel + 8 top pels )*2 */ 1536 /********************************************************************/ 1537 UWORD8 au1_ngbr_pels[34]; 1538 1539 /** 1540 * array for 8x8 intra pels filtering (temp buff 4) 1541 */ 1542 UWORD8 au1_neighbor_pels_i8x8_unfiltered[25]; 1543 1544 /** 1545 * Number of sub partitons in the inter pred MB 1546 */ 1547 UWORD32 u4_num_sub_partitions; 1548 1549 /** 1550 * Pointer to hold num PUs each MB in a picture 1551 */ 1552 UWORD32 *pu4_mb_pu_cnt; 1553 1554 /** 1555 * Pointer to the array of structures having motion vectors, size 1556 * and position of sub partitions 1557 */ 1558 enc_pu_t *ps_pu; 1559 1560 /** 1561 * Pointer to the pu of current co-located MB in list 1 1562 */ 1563 enc_pu_t *ps_colpu; 1564 1565 /** 1566 * predicted motion vector 1567 */ 1568 enc_pu_mv_t *ps_skip_mv; 1569 1570 /** 1571 * predicted motion vector 1572 */ 1573 enc_pu_mv_t *ps_pred_mv; 1574 1575 /** 1576 * top row mb syntax information base 1577 * In normal working scenarios, for a given context set, 1578 * the mb syntax info pointer is identical across all process threads. 1579 * But when the hard bound on slices are enabled, in multi core, frame 1580 * is partitioned in to sections equal to set number of cores and each 1581 * partition is run independently. In this scenario, a ctxt set will alone 1582 * appear to run multiple frames at a time. For this to occur, the common 1583 * pointers across the proc ctxt should disappear. 1584 * 1585 * This is done by allocating MAX_PROCESS_THREADS memory and distributing 1586 * across individual ctxts when byte bnd per slice is enabled. 1587 */ 1588 mb_info_t *ps_top_row_mb_syntax_ele_base; 1589 1590 /** 1591 * top row mb syntax information 1592 */ 1593 mb_info_t *ps_top_row_mb_syntax_ele; 1594 1595 /** 1596 * left mb syntax information 1597 */ 1598 mb_info_t s_left_mb_syntax_ele; 1599 1600 /** 1601 * top left mb syntax information 1602 */ 1603 mb_info_t s_top_left_mb_syntax_ele; 1604 1605 /** 1606 * top left mb syntax information 1607 */ 1608 1609 mb_info_t s_top_left_mb_syntax_ME; 1610 1611 /** 1612 * left mb motion vector 1613 */ 1614 enc_pu_t s_left_mb_pu_ME; 1615 1616 /** 1617 * top left mb motion vector 1618 */ 1619 enc_pu_t s_top_left_mb_pu_ME; 1620 1621 /** 1622 * mb neighbor availability pointer 1623 */ 1624 block_neighbors_t s_ngbr_avbl; 1625 1626 /** 1627 * In case the macroblock type is intra, the intra modes of all 1628 * partitions for the left mb are stored in the array below 1629 */ 1630 UWORD8 au1_left_mb_intra_modes[16]; 1631 1632 /** 1633 * In case the macroblock type is intra, the intra modes of all 1634 * partitions for the top mb are stored in the array below 1635 * 1636 * In normal working scenarios, for a given context set, 1637 * the mb syntax info pointer is identical across all process threads. 1638 * But when the hard bound on slices are enabled, in multi core, frame 1639 * is partitioned in to sections equal to set number of cores and each 1640 * partition is run independently. In this scenario, a ctxt set will alone 1641 * appear to run multiple frames at a time. For this to occur, the common 1642 * pointers across the proc ctxt should disappear. 1643 * 1644 * This is done by allocating MAX_PROCESS_THREADS memory and distributing 1645 * across individual ctxts when byte bnd per slice is enabled. 1646 */ 1647 UWORD8 *pu1_top_mb_intra_modes_base; 1648 1649 /** 1650 * In case the macroblock type is intra, the intra modes of all 1651 * partitions for the top mb are stored in the array below 1652 */ 1653 UWORD8 *pu1_top_mb_intra_modes; 1654 1655 /** 1656 * left mb motion vector 1657 */ 1658 enc_pu_t s_left_mb_pu; 1659 1660 /** 1661 * top left mb motion vector 1662 */ 1663 enc_pu_t s_top_left_mb_pu; 1664 1665 /** 1666 * top row motion vector info 1667 * 1668 * In normal working scenarios, for a given context set, 1669 * the top row pu pointer is identical across all process threads. 1670 * But when the hard bound on slices are enabled, in multi core, frame 1671 * is partitioned in to sections equal to set number of cores and each 1672 * partition is run independently. In this scenario, a ctxt set will alone 1673 * appear to run multiple frames at a time. For this to occur, the common 1674 * pointers across the proc ctxt should disappear. 1675 * 1676 * This is done by allocating MAX_PROCESS_THREADS memory and distributing 1677 * across individual ctxts when byte bnd per slice is enabled. 1678 */ 1679 enc_pu_t *ps_top_row_pu_base; 1680 1681 /** 1682 * top row motion vector info 1683 */ 1684 enc_pu_t *ps_top_row_pu; 1685 1686 enc_pu_t *ps_top_row_pu_ME; 1687 1688 /** 1689 * coded block pattern 1690 */ 1691 UWORD32 u4_cbp; 1692 1693 /** 1694 * csbp 1695 */ 1696 UWORD32 u4_csbp; 1697 1698 /** 1699 * number of non zero coeffs 1700 */ 1701 UWORD32 au4_nnz[5]; 1702 1703 /** 1704 * number of non zero coeffs for intra 4x4 when rdopt is on 1705 */ 1706 UWORD32 au4_nnz_intra_4x4[4]; 1707 1708 /** 1709 * frame qp & mb qp 1710 */ 1711 UWORD32 u4_frame_qp, u4_mb_qp; 1712 1713 /** 1714 * mb qp previous 1715 */ 1716 UWORD32 u4_mb_qp_prev; 1717 1718 /** 1719 * quantization parameters for luma & chroma planes 1720 */ 1721 quant_params_t *ps_qp_params[3]; 1722 1723 /** 1724 * Pointer frame level mb subblock coeff data 1725 */ 1726 void *pv_pic_mb_coeff_data; 1727 1728 /** 1729 * Pointer to mb subblock coeff data and number of subblocks and scan idx 1730 * Incremented each time a coded subblock is processed 1731 */ 1732 void *pv_mb_coeff_data; 1733 1734 /** 1735 * Pointer frame level mb header data 1736 */ 1737 void *pv_pic_mb_header_data; 1738 1739 /** 1740 * Pointer to mb header data and 1741 * incremented each time a coded mb is encoded 1742 */ 1743 void *pv_mb_header_data; 1744 1745 /** 1746 * Signal that pic_init is called first time 1747 */ 1748 WORD32 i4_first_pic_init; 1749 1750 /** 1751 * Current MV Bank's buffer ID 1752 */ 1753 WORD32 i4_cur_mv_bank_buf_id; 1754 1755 /** 1756 * Void pointer to job context 1757 */ 1758 void *pv_proc_jobq, *pv_entropy_jobq; 1759 1760 /** 1761 * Number of MBs to be processed in the current Job 1762 */ 1763 WORD32 i4_mb_cnt; 1764 1765 /** 1766 * ID for the current context - Used for debugging 1767 */ 1768 WORD32 i4_id; 1769 1770 /** 1771 * Pointer to current picture buffer structure 1772 */ 1773 pic_buf_t *ps_cur_pic; 1774 1775 /** 1776 * Pointer to current picture's mv buffer structure 1777 */ 1778 mv_buf_t *ps_cur_mv_buf; 1779 1780 /** 1781 * Flag to indicate if ps_proc was initialized at least once in a frame. 1782 * This is needed to handle cases where a core starts to handle format 1783 * conversion jobs directly 1784 */ 1785 WORD32 i4_init_done; 1786 1787 /** 1788 * Process status: one byte per MB 1789 */ 1790 UWORD8 *pu1_proc_map; 1791 1792 /** 1793 * Deblk status: one byte per MB 1794 */ 1795 UWORD8 *pu1_deblk_map; 1796 1797 /** 1798 * Process status: one byte per MB 1799 */ 1800 UWORD8 *pu1_me_map; 1801 1802 /* 1803 * Intra refresh mask. 1804 * Indicates if an Mb is coded in intra mode within the current AIR interval 1805 * NOTE Refreshes after each AIR period 1806 * NOTE The map is shared between process 1807 */ 1808 UWORD8 *pu1_is_intra_coded; 1809 1810 /** 1811 * Disable deblock level (0: Enable completely, 3: Disable completely 1812 */ 1813 UWORD32 u4_disable_deblock_level; 1814 1815 /** 1816 * Pointer to the structure that contains deblock context 1817 */ 1818 deblk_ctxt_t s_deblk_ctxt; 1819 1820 /** 1821 * Points to the array of slice indices which is used to identify the independent 1822 * slice to which each MB in a frame belongs. 1823 */ 1824 UWORD8 *pu1_slice_idx; 1825 1826 /** 1827 * Pointer to base of slice header structure array 1828 */ 1829 slice_header_t *ps_slice_hdr_base; 1830 1831 /** 1832 * Number of mb's to process in one loop 1833 */ 1834 WORD32 i4_nmb_ntrpy; 1835 1836 /** 1837 * Number of mb's to process in one loop 1838 */ 1839 UWORD32 u4_nmb_me; 1840 1841 /** 1842 * Structure for current input buffer 1843 */ 1844 inp_buf_t s_inp_buf; 1845 1846 /** 1847 * api call cnt 1848 */ 1849 WORD32 i4_encode_api_call_cnt; 1850 1851 /** 1852 * Current Picture count - used for synchronization 1853 */ 1854 WORD32 i4_pic_cnt; 1855 1856 /** 1857 * Intermediate buffer for interpred leaf level functions 1858 */ 1859 WORD32 ai16_pred1[HP_BUFF_WD * HP_BUFF_HT]; 1860 1861 /** 1862 * Reference picture for the current picture 1863 * TODO: Only 2 reference assumed currently 1864 */ 1865 pic_buf_t *aps_ref_pic[MAX_REF_PIC_CNT]; 1866 1867 /** 1868 * Reference MV buff for the current picture 1869 */ 1870 mv_buf_t *aps_mv_buf[MAX_REF_PIC_CNT]; 1871 1872 /** 1873 * frame info used by RC 1874 */ 1875 frame_info_t s_frame_info; 1876 1877 /* 1878 * NOTE NOT PERSISTANT INSIDE FUNCTIONS 1879 * Min sad for current MB 1880 * will be populated initially 1881 * Once a sad less than eq to u4_min_sad is reached, the value will be copied to the cariable 1882 */ 1883 UWORD32 u4_min_sad; 1884 1885 /* 1886 * indicates weather we have rached minimum sa or not 1887 */ 1888 UWORD32 u4_min_sad_reached; 1889 1890 /** 1891 * Current error code 1892 */ 1893 WORD32 i4_error_code; 1894 1895 /* 1896 * Enables or disables computation of recon 1897 */ 1898 UWORD32 u4_compute_recon; 1899 1900 /* 1901 * Temporary buffers to be used for subpel computation 1902 */ 1903 UWORD8 *apu1_subpel_buffs[SUBPEL_BUFF_CNT]; 1904 1905 /* 1906 * Buffer holding best sub pel values 1907 */ 1908 UWORD8 *pu1_best_subpel_buf; 1909 1910 /* 1911 * Stride for buffer holding best sub pel 1912 */ 1913 UWORD32 u4_bst_spel_buf_strd; 1914 1915 }; 1916 1917 /** 1918 ****************************************************************************** 1919 * @brief Rate control related variables 1920 ****************************************************************************** 1921 */ 1922 typedef struct 1923 { 1924 void *pps_rate_control_api; 1925 1926 void *pps_frame_time; 1927 1928 void *pps_time_stamp; 1929 1930 void *pps_pd_frm_rate; 1931 1932 /** 1933 * frame rate pull down 1934 */ 1935 WORD32 pre_encode_skip[MAX_CTXT_SETS]; 1936 1937 /** 1938 * skip frame (cbr) 1939 */ 1940 WORD32 post_encode_skip[MAX_CTXT_SETS]; 1941 1942 /** 1943 * rate control type 1944 */ 1945 rc_type_e e_rc_type; 1946 1947 /** 1948 * pic type 1949 */ 1950 picture_type_e e_pic_type; 1951 1952 /** 1953 * intra cnt in previous frame 1954 */ 1955 WORD32 num_intra_in_prev_frame; 1956 1957 /** 1958 * avg activity of prev frame 1959 */ 1960 WORD32 i4_avg_activity; 1961 1962 }rate_control_ctxt_t; 1963 1964 /** 1965 * Codec context 1966 */ 1967 struct _codec_t 1968 { 1969 /** 1970 * Id of current pic (input order) 1971 */ 1972 WORD32 i4_poc; 1973 1974 /** 1975 * Number of encode frame API calls made 1976 * This variable must only be used for context selection [Read only] 1977 */ 1978 WORD32 i4_encode_api_call_cnt; 1979 1980 /** 1981 * Number of pictures encoded 1982 */ 1983 WORD32 i4_pic_cnt; 1984 1985 /** 1986 * Number of threads created 1987 */ 1988 WORD32 i4_proc_thread_cnt; 1989 1990 /** 1991 * Mutex used to keep the control calls thread-safe 1992 */ 1993 void *pv_ctl_mutex; 1994 1995 /** 1996 * Current active config parameters 1997 */ 1998 cfg_params_t s_cfg; 1999 2000 /** 2001 * Array containing the config parameter sets 2002 */ 2003 cfg_params_t as_cfg[MAX_ACTIVE_CONFIG_PARAMS]; 2004 2005 /** 2006 * Color format used by encoder internally 2007 */ 2008 IV_COLOR_FORMAT_T e_codec_color_format; 2009 2010 /** 2011 * recon stride 2012 * (strides for luma and chroma are the same) 2013 */ 2014 WORD32 i4_rec_strd; 2015 2016 /** 2017 * Flag to enable/disable deblocking of a frame 2018 */ 2019 WORD32 i4_disable_deblk_pic; 2020 2021 /** 2022 * Number of continuous frames where deblocking was disabled 2023 */ 2024 WORD32 i4_disable_deblk_pic_cnt; 2025 2026 /** 2027 * frame type 2028 */ 2029 PIC_TYPE_T pic_type; 2030 2031 /** 2032 * frame qp 2033 */ 2034 UWORD32 u4_frame_qp; 2035 2036 /** 2037 * frame num 2038 */ 2039 WORD32 i4_frame_num; 2040 2041 /** 2042 * slice_type 2043 */ 2044 WORD32 i4_slice_type; 2045 2046 /* 2047 * Force current frame to specific type 2048 */ 2049 IV_PICTURE_CODING_TYPE_T force_curr_frame_type; 2050 2051 /** 2052 * IDR pic 2053 */ 2054 UWORD32 u4_is_idr; 2055 2056 /** 2057 * idr_pic_id 2058 */ 2059 WORD32 i4_idr_pic_id; 2060 2061 /** 2062 * Flush mode 2063 */ 2064 WORD32 i4_flush_mode; 2065 2066 /** 2067 * Encode header mode 2068 */ 2069 WORD32 i4_header_mode; 2070 2071 /** 2072 * Flag to indicate if header has already 2073 * been generated when i4_api_call_cnt 0 2074 */ 2075 UWORD32 u4_header_generated; 2076 2077 /** 2078 * Encode generate header 2079 */ 2080 WORD32 i4_gen_header; 2081 2082 /** 2083 * To signal successful completion of init 2084 */ 2085 WORD32 i4_init_done; 2086 2087 /** 2088 * To signal that at least one picture was decoded 2089 */ 2090 WORD32 i4_first_pic_done; 2091 2092 /** 2093 * Reset flag - Codec is reset if this flag is set 2094 */ 2095 WORD32 i4_reset_flag; 2096 2097 /** 2098 * Current error code 2099 */ 2100 WORD32 i4_error_code; 2101 2102 /** 2103 * threshold residue 2104 */ 2105 WORD32 u4_thres_resi; 2106 2107 /** 2108 * disable intra inter gating 2109 */ 2110 UWORD32 u4_inter_gate; 2111 2112 /** 2113 * Holds mem records passed during init. 2114 * This will be used to return the mem records during retrieve call 2115 */ 2116 iv_mem_rec_t *ps_mem_rec_backup; 2117 2118 /** 2119 * Flag to determine if the entropy thread is active 2120 */ 2121 volatile UWORD32 au4_entropy_thread_active[MAX_CTXT_SETS]; 2122 2123 /** 2124 * Mutex used to keep the entropy calls thread-safe 2125 */ 2126 void *pv_entropy_mutex; 2127 2128 /** 2129 * Job queue buffer base 2130 */ 2131 void *pv_proc_jobq_buf, *pv_entropy_jobq_buf; 2132 2133 /** 2134 * Job Queue mem tab size 2135 */ 2136 WORD32 i4_proc_jobq_buf_size, i4_entropy_jobq_buf_size; 2137 2138 /** 2139 * Memory for MV Bank buffer manager 2140 */ 2141 void *pv_mv_buf_mgr_base; 2142 2143 /** 2144 * MV Bank buffer manager 2145 */ 2146 void *pv_mv_buf_mgr; 2147 2148 /** 2149 * Pointer to MV Buf structure array 2150 */ 2151 void *ps_mv_buf; 2152 2153 /** 2154 * Base address for Motion Vector bank buffer 2155 */ 2156 void *pv_mv_bank_buf_base; 2157 2158 /** 2159 * MV Bank size allocated 2160 */ 2161 WORD32 i4_total_mv_bank_size; 2162 2163 /** 2164 * Memory for Picture buffer manager for reference pictures 2165 */ 2166 void *pv_ref_buf_mgr_base; 2167 2168 /** 2169 * Picture buffer manager for reference pictures 2170 */ 2171 void *pv_ref_buf_mgr; 2172 2173 /** 2174 * Number of reference buffers added to the buffer manager 2175 */ 2176 WORD32 i4_ref_buf_cnt; 2177 2178 /** 2179 * Pointer to Pic Buf structure array 2180 */ 2181 void *ps_pic_buf; 2182 2183 /** 2184 * Base address for Picture buffer 2185 */ 2186 void *pv_pic_buf_base; 2187 2188 /** 2189 * Total pic buffer size allocated 2190 */ 2191 WORD32 i4_total_pic_buf_size; 2192 2193 /** 2194 * Memory for Buffer manager for output buffers 2195 */ 2196 void *pv_out_buf_mgr_base; 2197 2198 /** 2199 * Buffer manager for output buffers 2200 */ 2201 void *pv_out_buf_mgr; 2202 2203 /** 2204 * Current output buffer's buffer ID 2205 */ 2206 WORD32 i4_out_buf_id; 2207 2208 /** 2209 * Number of output buffers added to the buffer manager 2210 */ 2211 WORD32 i4_out_buf_cnt; 2212 2213 /** 2214 * Memory for Picture buffer manager for input buffers 2215 */ 2216 void *pv_inp_buf_mgr_base; 2217 2218 /** 2219 * Picture buffer manager for input buffers 2220 */ 2221 void *pv_inp_buf_mgr; 2222 2223 /** 2224 * Current input buffer's buffer ID 2225 */ 2226 WORD32 i4_inp_buf_id; 2227 2228 /** 2229 * Number of input buffers added to the buffer manager 2230 */ 2231 WORD32 i4_inp_buf_cnt; 2232 2233 /** 2234 * Current input buffer 2235 */ 2236 pic_buf_t *ps_inp_buf; 2237 2238 /** 2239 * Pointer to dpb manager structure 2240 */ 2241 void *pv_dpb_mgr; 2242 2243 /** 2244 * Pointer to base of Sequence parameter set structure array 2245 */ 2246 sps_t *ps_sps_base; 2247 2248 /** 2249 * Pointer to base of Picture parameter set structure array 2250 */ 2251 pps_t *ps_pps_base; 2252 2253 /** 2254 * seq_parameter_set_id 2255 */ 2256 WORD32 i4_sps_id; 2257 2258 /** 2259 * pic_parameter_set_id 2260 */ 2261 WORD32 i4_pps_id; 2262 2263 /** 2264 * Pointer to base of slice header structure array 2265 */ 2266 slice_header_t *ps_slice_hdr_base; 2267 2268 /** 2269 * packed residue coeff data size for 1 row of mbs 2270 */ 2271 UWORD32 u4_size_coeff_data; 2272 2273 /** 2274 * packed header data size for 1 row of mbs 2275 */ 2276 UWORD32 u4_size_header_data; 2277 2278 /** 2279 * Processing context - One for each processing thread 2280 * Create two sets, each set used for alternate frames 2281 */ 2282 process_ctxt_t as_process[MAX_PROCESS_CTXT]; 2283 2284 /** 2285 * Thread handle for each of the processing threads 2286 */ 2287 void *apv_proc_thread_handle[MAX_PROCESS_THREADS]; 2288 2289 /** 2290 * Thread created flag for each of the processing threads 2291 */ 2292 WORD32 ai4_process_thread_created[MAX_PROCESS_THREADS]; 2293 2294 /** 2295 * Void pointer to process job context 2296 */ 2297 void *pv_proc_jobq, *pv_entropy_jobq; 2298 2299 /** 2300 * Number of MBs processed together for better instruction cache handling 2301 */ 2302 WORD32 i4_proc_nmb; 2303 2304 /** 2305 * Previous POC lsb 2306 */ 2307 WORD32 i4_prev_poc_lsb; 2308 2309 /** 2310 * Previous POC msb 2311 */ 2312 WORD32 i4_prev_poc_msb; 2313 2314 /** 2315 * Max POC lsb that has arrived till now 2316 */ 2317 WORD32 i4_max_prev_poc_lsb; 2318 2319 /** 2320 * Context for format conversion 2321 */ 2322 fmt_conv_t s_fmt_conv; 2323 2324 /** 2325 * Absolute pic order count 2326 */ 2327 WORD32 i4_abs_pic_order_cnt; 2328 2329 /** 2330 * Pic order count of lsb 2331 */ 2332 WORD32 i4_pic_order_cnt_lsb; 2333 2334 /** 2335 * Array giving current picture being processed in each context set 2336 */ 2337 WORD32 ai4_pic_cnt[MAX_CTXT_SETS]; 2338 2339 /* 2340 * Min sad to search for 2341 */ 2342 UWORD32 u4_min_sad; 2343 2344 /** 2345 * Reference picture set 2346 */ 2347 ref_set_t as_ref_set[MAX_DPB_SIZE + MAX_CTXT_SETS]; 2348 2349 2350 /* 2351 * Air pic cnt 2352 * Contains the number of pictures that have been encoded with air 2353 * This value is moudulo air refresh period 2354 */ 2355 WORD32 i4_air_pic_cnt; 2356 2357 /* 2358 * Intra refresh map 2359 * Stores the frames at which intra refresh should occur for a MB 2360 */ 2361 UWORD16 *pu2_intr_rfrsh_map; 2362 2363 /* 2364 * Indicates if the current frame is used as a reference frame 2365 */ 2366 UWORD32 u4_is_curr_frm_ref; 2367 2368 /* 2369 * Indicates if there can be non reference frames in the stream 2370 */ 2371 WORD32 i4_non_ref_frames_in_stream; 2372 2373 /* 2374 * Memory for color space conversion for luma plane 2375 */ 2376 UWORD8 *pu1_y_csc_buf_base; 2377 2378 /* 2379 * Memory for color space conversion foe chroma plane 2380 */ 2381 UWORD8 *pu1_uv_csc_buf_base; 2382 2383 /** 2384 * Function pointers for intra pred leaf level functions luma 2385 */ 2386 pf_intra_pred apf_intra_pred_16_l[MAX_I16x16]; 2387 pf_intra_pred apf_intra_pred_8_l[MAX_I8x8]; 2388 pf_intra_pred apf_intra_pred_4_l[MAX_I4x4]; 2389 2390 /** 2391 * Function pointers for intra pred leaf level functions chroma 2392 */ 2393 pf_intra_pred apf_intra_pred_c[MAX_CH_I8x8]; 2394 2395 /** 2396 * luma core coding function pointer 2397 */ 2398 UWORD8 (*luma_energy_compaction[4])(process_ctxt_t *ps_proc); 2399 2400 /** 2401 * chroma core coding function pointer 2402 */ 2403 UWORD8 (*chroma_energy_compaction[2])(process_ctxt_t *ps_proc); 2404 2405 /** 2406 * forward transform for intra blk of mb type 16x16 2407 */ 2408 ih264_luma_16x16_resi_trans_dctrans_quant_ft *pf_resi_trans_dctrans_quant_16x16; 2409 2410 /** 2411 * inverse transform for intra blk of mb type 16x16 2412 */ 2413 ih264_luma_16x16_idctrans_iquant_itrans_recon_ft *pf_idctrans_iquant_itrans_recon_16x16; 2414 2415 /** 2416 * forward transform for 4x4 blk luma 2417 */ 2418 ih264_resi_trans_quant_ft *pf_resi_trans_quant_4x4; 2419 2420 /** 2421 * forward transform for 4x4 blk luma 2422 */ 2423 ih264_resi_trans_quant_ft *pf_resi_trans_quant_chroma_4x4; 2424 2425 /* 2426 * hadamard transform and quant for a 4x4 block 2427 */ 2428 ih264_hadamard_quant_ft *pf_hadamard_quant_4x4; 2429 2430 /* 2431 * hadamard transform and quant for a 4x4 block 2432 */ 2433 ih264_hadamard_quant_ft *pf_hadamard_quant_2x2_uv; 2434 2435 /** 2436 * inverse transform for 4x4 blk 2437 */ 2438 ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_4x4; 2439 2440 /** 2441 * inverse transform for chroma 4x4 blk 2442 */ 2443 ih264_iquant_itrans_recon_chroma_ft *pf_iquant_itrans_recon_chroma_4x4; 2444 2445 /** 2446 * inverse transform for 4x4 blk with only single dc coeff 2447 */ 2448 ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_4x4_dc; 2449 2450 /** 2451 * inverse transform for chroma 4x4 blk with only single dc coeff 2452 */ 2453 ih264_iquant_itrans_recon_chroma_ft *pf_iquant_itrans_recon_chroma_4x4_dc; 2454 2455 /* 2456 * Inverse hadamard transform and iquant for a 4x4 block 2457 */ 2458 ih264_ihadamard_scaling_ft *pf_ihadamard_scaling_4x4; 2459 2460 /* 2461 * Inverse hadamard transform and iquant for a 4x4 block 2462 */ 2463 ih264_ihadamard_scaling_ft *pf_ihadamard_scaling_2x2_uv; 2464 2465 /* 2466 * Function for interleave copy* 2467 */ 2468 ih264_interleave_copy_ft *pf_interleave_copy; 2469 2470 /** 2471 * forward transform for 8x8 blk 2472 */ 2473 ih264_resi_trans_quant_ft *pf_resi_trans_quant_8x8; 2474 2475 /** 2476 * inverse transform for 8x8 blk 2477 */ 2478 /** 2479 * inverse transform for 4x4 blk 2480 */ 2481 ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_8x8; 2482 2483 /** 2484 * forward transform for chroma MB 2485 */ 2486 ih264_chroma_8x8_resi_trans_dctrans_quant_ft *pf_resi_trans_dctrans_quant_8x8_chroma; 2487 2488 /** 2489 * inverse transform for chroma MB 2490 */ 2491 ih264_idctrans_iquant_itrans_recon_ft *pf_idctrans_iquant_itrans_recon_8x8_chroma; 2492 2493 /** 2494 * deblock vertical luma edge with blocking strength 4 2495 */ 2496 ih264_deblk_edge_bs4_ft *pf_deblk_luma_vert_bs4; 2497 2498 /** 2499 * deblock vertical chroma edge with blocking strength 4 2500 */ 2501 ih264_deblk_chroma_edge_bs4_ft *pf_deblk_chroma_vert_bs4; 2502 2503 /** 2504 * deblock vertical luma edge with blocking strength less than 4 2505 */ 2506 ih264_deblk_edge_bslt4_ft *pf_deblk_luma_vert_bslt4; 2507 2508 /** 2509 * deblock vertical chroma edge with blocking strength less than 4 2510 */ 2511 ih264_deblk_chroma_edge_bslt4_ft *pf_deblk_chroma_vert_bslt4; 2512 2513 /** 2514 * deblock horizontal luma edge with blocking strength 4 2515 */ 2516 ih264_deblk_edge_bs4_ft *pf_deblk_luma_horz_bs4; 2517 2518 /** 2519 * deblock horizontal chroma edge with blocking strength 4 2520 */ 2521 ih264_deblk_chroma_edge_bs4_ft *pf_deblk_chroma_horz_bs4; 2522 2523 /** 2524 * deblock horizontal luma edge with blocking strength less than 4 2525 */ 2526 ih264_deblk_edge_bslt4_ft *pf_deblk_luma_horz_bslt4; 2527 2528 /** 2529 * deblock horizontal chroma edge with blocking strength less than 4 2530 */ 2531 ih264_deblk_chroma_edge_bslt4_ft *pf_deblk_chroma_horz_bslt4; 2532 2533 2534 /** 2535 * functions for padding 2536 */ 2537 pf_pad pf_pad_top; 2538 pf_pad pf_pad_bottom; 2539 pf_pad pf_pad_left_luma; 2540 pf_pad pf_pad_left_chroma; 2541 pf_pad pf_pad_right_luma; 2542 pf_pad pf_pad_right_chroma; 2543 2544 /** 2545 * Inter pred leaf level functions 2546 */ 2547 ih264_inter_pred_luma_ft *pf_inter_pred_luma_copy; 2548 ih264_inter_pred_luma_ft *pf_inter_pred_luma_horz; 2549 ih264_inter_pred_luma_ft *pf_inter_pred_luma_vert; 2550 pf_inter_pred_luma_bilinear pf_inter_pred_luma_bilinear; 2551 ih264_inter_pred_chroma_ft *pf_inter_pred_chroma; 2552 2553 /** 2554 * fn ptrs for compute sad routines 2555 */ 2556 ime_compute_sad_ft *apf_compute_sad_16x16[2]; 2557 ime_compute_sad_ft *pf_compute_sad_16x8; 2558 2559 2560 /** 2561 * Function pointer for computing ME 2562 * 1 for PSLICE and 1 for BSLICE 2563 */ 2564 ih264e_compute_me_ft *apf_compute_me[2]; 2565 2566 /** 2567 * Function pointers for computing SKIP parameters 2568 */ 2569 ih264e_skip_params_ft *apf_find_skip_params_me[2]; 2570 2571 /** 2572 * fn ptrs for memory handling operations 2573 */ 2574 pf_memcpy pf_mem_cpy; 2575 pf_memset pf_mem_set; 2576 pf_memcpy_mul8 pf_mem_cpy_mul8; 2577 pf_memset_mul8 pf_mem_set_mul8; 2578 2579 /** 2580 * intra mode eval -encoder level function 2581 */ 2582 pf_evaluate_intra_modes pf_ih264e_evaluate_intra16x16_modes; 2583 pf_evaluate_intra_modes pf_ih264e_evaluate_intra_chroma_modes; 2584 pf_evaluate_intra_4x4_modes pf_ih264e_evaluate_intra_4x4_modes; 2585 2586 /* Half pel generation function - encoder level 2587 * 2588 */ 2589 pf_sixtapfilter_horz pf_ih264e_sixtapfilter_horz; 2590 pf_sixtap_filter_2dvh_vert pf_ih264e_sixtap_filter_2dvh_vert; 2591 2592 /** 2593 * color space conversion form YUV 420P to YUV 420Sp 2594 */ 2595 pf_fmt_conv_420p_to_420sp pf_ih264e_conv_420p_to_420sp; 2596 2597 2598 /** 2599 * color space conversion form YUV 420P to YUV 420Sp 2600 */ 2601 pf_fmt_conv_422ile_to_420sp pf_ih264e_fmt_conv_422i_to_420sp; 2602 2603 /** 2604 * write mb layer for a given slice I, P, B 2605 */ 2606 IH264E_ERROR_T (*pf_write_mb_syntax_layer[2][3]) ( entropy_ctxt_t *ps_ent_ctxt ); 2607 2608 /** 2609 * Output buffer 2610 */ 2611 out_buf_t as_out_buf[MAX_CTXT_SETS]; 2612 2613 /** 2614 * recon buffer 2615 */ 2616 rec_buf_t as_rec_buf[MAX_CTXT_SETS]; 2617 2618 /** 2619 * rate control context 2620 */ 2621 rate_control_ctxt_t s_rate_control; 2622 2623 /** 2624 * input buffer queue 2625 */ 2626 inp_buf_t as_inp_list[MAX_NUM_BFRAMES]; 2627 2628 /** 2629 * Flag to indicate if any IDR requests are pending 2630 */ 2631 WORD32 i4_pending_idr_flag; 2632 2633 /* 2634 *Flag to indicate if we have recived the last input frame 2635 */ 2636 WORD32 i4_last_inp_buff_received; 2637 2638 }; 2639 2640 #endif /* IH264E_STRUCTS_H_ */ 2641