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