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