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