1 /****************************************************************************** 2 * 3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore 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 19 /** 20 ******************************************************************************* 21 * @file 22 * ihevcd_structs.h 23 * 24 * @brief 25 * Structure definitions used in the decoder 26 * 27 * @author 28 * Harish 29 * 30 * @par List of Functions: 31 * 32 * @remarks 33 * None 34 * 35 ******************************************************************************* 36 */ 37 38 #ifndef _IHEVCD_STRUCTS_H_ 39 #define _IHEVCD_STRUCTS_H_ 40 typedef enum 41 { 42 INIT_DONE, HEADER_DONE, FIRST_FRAME_DONE, 43 }CODEC_STATE_T; 44 45 46 47 typedef struct _codec_t codec_t; 48 49 /** Structure to hold format conversion context */ 50 typedef struct 51 { 52 /** Current row for which format conversion should be done */ 53 WORD32 i4_cur_row; 54 55 /** Number of rows for which format conversion should be done */ 56 WORD32 i4_num_rows; 57 }fmt_conv_t; 58 59 /** 60 * Bitstream structure 61 */ 62 typedef struct 63 { 64 /** 65 * Bitstream buffer base pointer 66 */ 67 UWORD8 *pu1_buf_base; 68 69 /** 70 * Bitstream bit offset in current word. Value between 0 and 31 71 */ 72 UWORD32 u4_bit_ofst; 73 74 /** 75 * Current bitstream buffer pointer 76 */ 77 UWORD32 *pu4_buf; 78 79 /** 80 * Current word 81 */ 82 UWORD32 u4_cur_word; 83 84 /** 85 * Next word 86 */ 87 UWORD32 u4_nxt_word; 88 89 /** 90 * Max address for bitstream 91 */ 92 UWORD8 *pu1_buf_max; 93 }bitstrm_t; 94 95 /** 96 ****************************************************************************** 97 * @brief Cabac context for decoder 98 ****************************************************************************** 99 */ 100 typedef struct cab_ctxt 101 { 102 /*********************************************************************/ 103 /* CABAC ENGINE related fields */ 104 /*********************************************************************/ 105 /** cabac interval range R */ 106 UWORD32 u4_range; 107 108 /** cabac interval offset O */ 109 UWORD32 u4_ofst; 110 111 /*********************************************************************/ 112 /* CABAC context models */ 113 /*********************************************************************/ 114 /** All Context models stored in pscked form pState[bits6-1] | MPS[bit0] */ 115 UWORD8 au1_ctxt_models[IHEVC_CAB_CTXT_END]; 116 117 /** Context models memorized after decoding 2nd CTB in a row to be used 118 * during entropy sync cases 119 */ 120 UWORD8 au1_ctxt_models_sync[IHEVC_CAB_CTXT_END]; 121 122 }cab_ctxt_t; 123 124 typedef enum 125 { 126 CMD_PROCESS, 127 CMD_FMTCONV, 128 }JOBQ_CMD_T; 129 130 /** 131 * Structure to represent a processing job entry 132 */ 133 typedef struct 134 { 135 /** 136 * Command 137 * Currently: PROCESS, FMTCONV are the only two jobs 138 */ 139 WORD32 i4_cmd; 140 /** 141 * CTB x of the starting CTB 142 */ 143 WORD16 i2_ctb_x; 144 145 /** 146 * CTB y of the starting CTB 147 */ 148 149 WORD16 i2_ctb_y; 150 151 /** 152 * Number of CTBs that need to be processed in this job 153 */ 154 WORD16 i2_ctb_cnt; 155 156 /** 157 * Slice index for the current CTB 158 */ 159 WORD16 i2_slice_idx; 160 161 /** 162 * TU coefficient data offset for the current job 163 */ 164 WORD32 i4_tu_coeff_data_ofst; 165 }proc_job_t; 166 /** 167 * Structure to represent a MV Bank buffer 168 */ 169 typedef struct 170 { 171 /** 172 * Pointer to hold PU index for each CTB in a picture 173 */ 174 UWORD32 *pu4_pic_pu_idx; 175 176 /** 177 * Pointer to hold pu_t for each PU in a picture 178 */ 179 pu_t *ps_pic_pu; 180 181 /** 182 * Pointer to hold PU map for each CTB in a picture 183 */ 184 UWORD8 *pu1_pic_pu_map; 185 186 /** 187 * Pointer to hold the Slice map 188 */ 189 UWORD16 *pu1_pic_slice_map; 190 191 /** 192 * Absolute POC for the current MV Bank 193 */ 194 WORD32 i4_abs_poc; 195 196 /** 197 * Absolute POCs of reference List 0 for all slices in the frame from which this frame is reconstructed 198 */ 199 WORD32 ai4_l0_collocated_poc[MAX_SLICE_HDR_CNT][MAX_DPB_SIZE]; 200 201 /** 202 * Flag to indicate Long Term reference for POCs of reference List 0 for all slices in the frame from which this frame is reconstructed 203 */ 204 WORD8 ai1_l0_collocated_poc_lt[MAX_SLICE_HDR_CNT][MAX_DPB_SIZE]; 205 206 /** 207 * Absolute POCs of reference List 1 for all slices in the frame from which this frame is reconstructed 208 */ 209 WORD32 ai4_l1_collocated_poc[MAX_SLICE_HDR_CNT][MAX_DPB_SIZE]; 210 /** 211 * Flag to indicate Long Term reference for POCs of reference List 1 for all slices in the frame from which this frame is reconstructed 212 */ 213 WORD8 ai1_l1_collocated_poc_lt[MAX_SLICE_HDR_CNT][MAX_DPB_SIZE]; 214 215 }mv_buf_t; 216 217 typedef struct 218 { 219 /** 220 * Pointer to current PPS 221 */ 222 pps_t *ps_pps; 223 224 /** 225 * Pointer to current SPS 226 */ 227 sps_t *ps_sps; 228 229 /** 230 * Pointer to current slice header structure 231 */ 232 slice_header_t *ps_slice_hdr; 233 234 /** 235 * CTB's x position within a picture in raster scan in CTB units 236 */ 237 WORD32 i4_ctb_x; 238 239 /** 240 * CTB's y position within a picture in raster scan in CTB units 241 */ 242 243 WORD32 i4_ctb_y; 244 245 /** 246 * Current PU structure - set to CTB pu_t pointer at the start of CTB processing and incremented 247 * for every TU 248 */ 249 pu_t *ps_pu; 250 251 /** 252 * Pointer to frame level pu_t for the current frame being parsed 253 * where MVs and Intra pred modes will be updated 254 */ 255 pu_t *ps_pic_pu; 256 257 /** 258 * Store the current tile's information. This is needed for the computation of mvs. 259 */ 260 tile_t *ps_tile; 261 262 /** 263 * Points to an array of PU indices which is used to identify 264 * start index of pu_t in ps_pic_pu and also to identify number of 265 * PUs in the current CTB by subtracting current idx from next CTB's 266 * PU idx 267 */ 268 UWORD32 *pu4_pic_pu_idx; 269 270 /** PU Index map per CTB. The indices in this map are w.r.t picture pu array and not 271 * w.r.t CTB pu array. 272 * This will be used during mv prediction and since neighbours will have different CTB pu map 273 * it will be easier if they all have indices w.r.t picture level PU array rather than CTB level 274 * PU array. 275 * pu1_pic_pu_map is map w.r.t CTB's pu_t array 276 */ 277 UWORD32 *pu4_pic_pu_idx_map; 278 279 /** 280 * Pointer to pu_map for the current frame being parsed 281 * where MVs and Intra pred modes will be updated 282 */ 283 UWORD8 *pu1_pic_pu_map; 284 285 /** 286 * PU count in current CTB 287 */ 288 WORD32 i4_ctb_pu_cnt; 289 290 /** 291 * PU count in current CTB 292 */ 293 WORD32 i4_ctb_start_pu_idx; 294 295 /** 296 * Top availability for current CTB level 297 */ 298 UWORD8 u1_top_ctb_avail; 299 300 /** 301 * Top right availability for current CTB level 302 */ 303 UWORD8 u1_top_rt_ctb_avail; 304 /** 305 * Top left availability for current CTB level 306 */ 307 UWORD8 u1_top_lt_ctb_avail; 308 /** 309 * left availability for current CTB level 310 */ 311 UWORD8 u1_left_ctb_avail; 312 313 }mv_ctxt_t; 314 315 typedef struct 316 { 317 /** 318 * Pointer to current PPS 319 */ 320 pps_t *ps_pps; 321 322 /** 323 * Pointer to current SPS 324 */ 325 sps_t *ps_sps; 326 327 /* 328 * Pointer to codec context 329 */ 330 codec_t *ps_codec; 331 332 /** 333 * Index of the current Tile being parsed 334 */ 335 tile_t *ps_tile; 336 337 /** 338 * Pointer to the current slice header 339 */ 340 slice_header_t *ps_slice_hdr; 341 342 /** 343 * TU count in current CTB 344 */ 345 WORD32 i4_ctb_tu_cnt; 346 347 /** 348 * CTB's x position within a picture in raster scan in CTB units 349 */ 350 WORD32 i4_ctb_x; 351 352 /** 353 * CTB's y position within a picture in raster scan in CTB units 354 */ 355 356 WORD32 i4_ctb_y; 357 358 /** 359 * CTB's x position within a Tile in raster scan in CTB units 360 */ 361 WORD32 i4_ctb_tile_x; 362 363 /** 364 * CTB's y position within a Tile in raster scan in CTB units 365 */ 366 367 WORD32 i4_ctb_tile_y; 368 369 /** 370 * CTB's x position within a Slice in raster scan in CTB units 371 */ 372 WORD32 i4_ctb_slice_x; 373 374 /** 375 * CTB's y position within a Slice in raster scan in CTB units 376 */ 377 378 WORD32 i4_ctb_slice_y; 379 380 /* Two bits per edge. 381 Stored in format. BS[15] | BS[14] | .. |BS[0]*/ 382 UWORD32 *pu4_pic_vert_bs; 383 384 /** 385 * Horizontal Boundary strength 386 */ 387 388 /* Two bits per edge. 389 Stored in format. BS[15] | BS[14] | .. |BS[0]*/ 390 UWORD32 *pu4_pic_horz_bs; 391 392 /** 393 * Flags to indicate if QP is constant through out a CTB - 1 bit for each CTB 394 * The bits are packed from LSB to MSB 395 * To get the flag corresponding to CTB with (ctb_x, ctb_y), use 396 * pu4_qp_const_in_ctb[(ctb_x + pic_wd_in_ctb * ctb_y) >> 3] & (1 << ((ctb_x + pic_wd_in_ctb * ctb_y) & 7)) 397 */ 398 UWORD8 *pu1_pic_qp_const_in_ctb; 399 400 /** 401 * Qp array stored for each 8x8 pixels 402 */ 403 UWORD8 *pu1_pic_qp; 404 405 /** 406 * Current TU structure - set to CTB tu_t pointer at the start of CTB processing and incremented 407 * for every TU 408 */ 409 tu_t *ps_tu; 410 411 /** 412 * Points to an array of TU indices which is used to identify 413 * start index of tu_t in ps_pic_tu and also to identify number of 414 * TUs in the current CTB by subtracting current idx from next CTB's 415 * TU idx 416 */ 417 UWORD32 *pu4_pic_tu_idx; 418 419 /** 420 * Points to an array of PU indices which is used to identify 421 * start index of pu_t in ps_pic_pu and also to identify number of 422 * PUs in the current CTB by subtracting current idx from next CTB's 423 * PU idx 424 */ 425 UWORD32 *pu4_pic_pu_idx; 426 427 /** 428 * Current PU structure - set to CTB pu_t pointer at the start of CTB processing and incremented 429 * for every TU 430 */ 431 pu_t *ps_pu; 432 433 /** 434 * Pointer to frame level pu_t for the current frame being parsed 435 * where MVs and Intra pred modes will be updated 436 */ 437 pu_t *ps_pic_pu; 438 439 /** PU Index map per CTB. The indices in this map are w.r.t picture pu array and not 440 * w.r.t CTB pu array. 441 * This will be used during mv prediction and since neighbours will have different CTB pu map 442 * it will be easier if they all have indices w.r.t picture level PU array rather than CTB level 443 * PU array. 444 * pu1_pic_pu_map is map w.r.t CTB's pu_t array 445 */ 446 UWORD32 *pu4_pic_pu_idx_map; 447 448 /** 449 * Variable to store the next ctb count to compute pu idx 450 */ 451 WORD32 i4_next_pu_ctb_cnt; 452 453 /** 454 * Variable to store the next ctb count to compute tu idx 455 */ 456 WORD32 i4_next_tu_ctb_cnt; 457 /** 458 * Points to the array of slice indices which is used to identify the slice 459 * to which each CTB in a frame belongs. 460 */ 461 UWORD16 *pu1_slice_idx; 462 }bs_ctxt_t; 463 464 typedef struct 465 { 466 /** 467 * Pointer to current PPS 468 */ 469 pps_t *ps_pps; 470 471 /** 472 * Pointer to current SPS 473 */ 474 sps_t *ps_sps; 475 476 /* 477 * Pointer to codec context 478 */ 479 codec_t *ps_codec; 480 481 /** 482 * Pointer to current slice header structure 483 */ 484 slice_header_t *ps_slice_hdr; 485 486 /** 487 * Pointer to the structure that contains BS and QP frame level arrays 488 */ 489 bs_ctxt_t s_bs_ctxt; 490 491 /** 492 * CTB's x position within a picture in raster scan in CTB units 493 */ 494 WORD32 i4_ctb_x; 495 496 /** 497 * CTB's y position within a picture in raster scan in CTB units 498 */ 499 500 WORD32 i4_ctb_y; 501 502 /** 503 * Current pictures loop filter flag map at 8x8 level 504 */ 505 UWORD8 *pu1_pic_no_loop_filter_flag; 506 507 /** 508 * Current CTB's no_loop_filter_flags 509 * each element corresponds to one row - including the left CTB's last 8x8 510 */ 511 UWORD16 au2_ctb_no_loop_filter_flag[9]; 512 513 /* 514 * Pointer to 0th luma pixel in current pic 515 */ 516 UWORD8 *pu1_cur_pic_luma; 517 518 /* 519 * Pointer to 0th chroma pixel in current pic 520 */ 521 UWORD8 *pu1_cur_pic_chroma; 522 523 /* Points to the array of slice indices which is used to identify the slice 524 * to which each CTB in a frame belongs. 525 */ 526 UWORD16 *pu1_slice_idx; 527 528 /* Specifies if the chroma format is yuv420sp_vu */ 529 WORD32 is_chroma_yuv420sp_vu; 530 531 }deblk_ctxt_t; 532 533 typedef struct 534 { 535 /** 536 * Pointer to current PPS 537 */ 538 pps_t *ps_pps; 539 540 /** 541 * Pointer to current SPS 542 */ 543 sps_t *ps_sps; 544 545 /* Pointer to codec context 546 * 547 */ 548 codec_t *ps_codec; 549 550 /** 551 * Pointer to base slice header structure 552 */ 553 slice_header_t *ps_slice_hdr_base; 554 555 /** 556 * Pointer to current slice header structure 557 */ 558 slice_header_t *ps_slice_hdr; 559 560 /** 561 * Pointer to current tile structure 562 */ 563 tile_t *ps_tile; 564 /** 565 * CTB's x position within a picture in raster scan in CTB units 566 */ 567 WORD32 i4_ctb_x; 568 569 /** 570 * CTB's y position within a picture in raster scan in CTB units 571 */ 572 573 WORD32 i4_ctb_y; 574 575 /** 576 * Current pictures loop filter flag map at 8x8 level 577 */ 578 UWORD8 *pu1_pic_no_loop_filter_flag; 579 580 /* 581 * Pointer to 0th luma pixel in current pic 582 */ 583 UWORD8 *pu1_cur_pic_luma; 584 585 /* 586 * Pointer to 0th chroma pixel in current pic 587 */ 588 UWORD8 *pu1_cur_pic_chroma; 589 590 /** 591 * Pointer to frame level sao_t for the current frame being parsed 592 */ 593 sao_t *ps_pic_sao; 594 595 /** 596 * Temporary buffer needed during SAO processing 597 */ 598 UWORD8 *pu1_tmp_buf_luma; 599 600 /** 601 * Temporary buffer needed during SAO processing 602 */ 603 UWORD8 *pu1_tmp_buf_chroma; 604 605 /** 606 * Left column of luma pixels - used by SAO 607 */ 608 UWORD8 *pu1_sao_src_left_luma; 609 610 /** 611 * Top row of luma pixels - used by SAO 612 */ 613 UWORD8 *pu1_sao_src_top_luma; 614 615 /** 616 * Left column of chroma pixels(interleaved) - used by SAO 617 */ 618 UWORD8 *pu1_sao_src_left_chroma; 619 620 /** 621 * Top row of chroma pixels(interleaved) - used by SAO 622 */ 623 UWORD8 *pu1_sao_src_top_chroma; 624 625 /** 626 * Top-left luma pixel - used by SAO (for the top CTB row) 627 */ 628 UWORD8 *pu1_sao_src_luma_top_left_ctb; 629 630 /** 631 * Top-left chroma pixel(interleaved) - used by SAO (for the top CTB row) 632 */ 633 UWORD8 *pu1_sao_src_chroma_top_left_ctb; 634 635 /** 636 * Top-left luma pixel - used by SAO (for the current CTB row) 637 */ 638 UWORD8 *pu1_sao_src_top_left_luma_curr_ctb; 639 640 /** 641 * Top-left chroma pixel(interleaved) - used by SAO (for the current CTB row) 642 */ 643 UWORD8 *pu1_sao_src_top_left_chroma_curr_ctb; 644 645 /** 646 * Top-right luma pixel - used by SAO (for the top CTB row) 647 */ 648 UWORD8 *pu1_sao_src_top_left_luma_top_right; 649 650 /** 651 * Top-right chroma pixel(interleaved) - used by SAO (for the top CTB row) 652 */ 653 UWORD8 *pu1_sao_src_top_left_chroma_top_right; 654 655 /** 656 * Bottom-left luma pixel - used by SAO 657 */ 658 UWORD8 u1_sao_src_top_left_luma_bot_left; 659 /** 660 * Pointer to array that stores bottom left luma pixel per row(interleaved) - used by SAO 661 */ 662 UWORD8 *pu1_sao_src_top_left_luma_bot_left; 663 664 /** 665 * Bottom left chroma pixel(interleaved) - used by SAO 666 */ 667 UWORD8 au1_sao_src_top_left_chroma_bot_left[2]; 668 /** 669 * Pointer to array that stores bottom left chroma pixel per row(interleaved) - used by SAO 670 */ 671 UWORD8 *pu1_sao_src_top_left_chroma_bot_left; 672 673 /* 674 * Slice counter in a picture. 675 */ 676 UWORD32 i4_cur_slice_idx; 677 /** 678 * Points to the array of slice indices which is used to identify the slice 679 * to which each CTB in a frame belongs. 680 */ 681 UWORD16 *pu1_slice_idx; 682 /** 683 * Points to the array of tile indices which is used to identify the slice 684 * to which each CTB in a frame belongs. 685 */ 686 UWORD16 *pu1_tile_idx; 687 688 /* Specifies if the chroma format is yuv420sp_vu */ 689 WORD32 is_chroma_yuv420sp_vu; 690 691 }sao_ctxt_t; 692 693 typedef struct 694 { 695 /** Log2 CU's size */ 696 WORD32 i4_log2_cb_size; 697 698 /** CU's x position */ 699 WORD32 i4_pos_x; 700 701 /** CU's y position */ 702 WORD32 i4_pos_y; 703 /** 704 * Transquant Bypass enable flag at CU level - To be replicated at TU level 705 */ 706 WORD32 i4_cu_transquant_bypass; 707 /** 708 * Prediction mode 709 */ 710 WORD32 i4_pred_mode; 711 712 /** 713 * Partition mode 714 */ 715 WORD32 i4_part_mode; 716 717 /** 718 * Intra luma pred mode for current CU. In case of PART2Nx2N 719 * the first value is replicated to avoid checks later 720 */ 721 WORD32 ai4_intra_luma_pred_mode[4]; 722 723 /** 724 * Previous intra luma pred flag used for intra pred mode computation 725 */ 726 WORD32 ai4_prev_intra_luma_pred_flag[4]; 727 728 /** 729 * mpm index used in intra prediction mode computation 730 */ 731 WORD32 ai4_mpm_idx[4]; 732 /** 733 * Remaining intra pred mode 734 */ 735 WORD32 ai4_rem_intra_luma_pred_mode[4]; 736 /** 737 * Chroma pred mode index to be used to compute intra pred mode for chroma 738 */ 739 WORD32 i4_intra_chroma_pred_mode_idx; 740 /** 741 * Maximum transform depth 742 */ 743 WORD32 i4_max_trafo_depth; 744 745 /** 746 * Luma CBF for current TU 747 */ 748 UWORD8 i1_cbf_luma; 749 750 /** 751 * Cb CBF 752 */ 753 UWORD8 ai1_cbf_cb[MAX_TRAFO_DEPTH]; 754 755 /** 756 * Cr CBF 757 */ 758 UWORD8 ai1_cbf_cr[MAX_TRAFO_DEPTH]; 759 760 /** 761 * Intra split flag 762 */ 763 WORD32 i4_intra_split_flag; 764 765 /** 766 * Current QP 767 */ 768 WORD32 i4_qp; 769 770 /** 771 * Number of TUs in CU parsed before a change in QP is signaled 772 */ 773 WORD32 i4_tu_cnt; 774 775 /** 776 * Cu QP delta 777 */ 778 WORD32 i4_cu_qp_delta; 779 780 }parse_cu_t; 781 /** 782 * Structure contains few common state variables such as CTB positions, current SPS, PPS ids etc which are to be 783 * used in the parsing thread. By keeping it a different structure it is being explicitly signalled that these 784 * variables are specific to Parsing threads context and other threads should not update these elements 785 */ 786 typedef struct 787 { 788 /** 789 * CTB's x position within a picture in raster scan in CTB units 790 */ 791 WORD32 i4_ctb_x; 792 793 /** 794 * CTB's y position within a picture in raster scan in CTB units 795 */ 796 797 WORD32 i4_ctb_y; 798 799 /** 800 * CTB's x position within a Tile in raster scan in CTB units 801 */ 802 WORD32 i4_ctb_tile_x; 803 804 /** 805 * CTB's y position within a Tile in raster scan in CTB units 806 */ 807 808 WORD32 i4_ctb_tile_y; 809 810 /** 811 * CTB's x position within a Slice in raster scan in CTB units 812 */ 813 WORD32 i4_ctb_slice_x; 814 815 /** 816 * CTB's y position within a Slice in raster scan in CTB units 817 */ 818 819 WORD32 i4_ctb_slice_y; 820 821 /** 822 * Index of the current Tile being parsed 823 */ 824 tile_t *ps_tile; 825 826 /** 827 * Current slice idx - Used in multi-core cases to ensure slice header is 828 * preserved till the last CB of the slice is decoded 829 */ 830 WORD32 i4_cur_slice_idx; 831 /** 832 * Current slice idx - Used in multi-core cases to ensure slice header is 833 * preserved till the last CB of the slice is decoded 834 */ 835 WORD32 i4_cur_independent_slice_idx; 836 837 /** 838 * Current slice idx - Used in multi-core cases to ensure slice header is 839 * preserved till the last CB of the slice is decoded 840 */ 841 WORD32 i4_cur_tile_idx; 842 843 /** 844 * Pointer to current PPS 845 */ 846 pps_t *ps_pps; 847 848 /** 849 * Pointer to current SPS 850 */ 851 sps_t *ps_sps; 852 853 /** 854 * Signal that pic_init is called first time 855 */ 856 WORD32 i4_first_pic_init; 857 858 /** 859 * Flag to indicate if CU QP delta is coded. 860 * By default it is set to 0 at the beginning of coding quad tree 861 */ 862 WORD32 i4_is_cu_qp_delta_coded; 863 864 /** 865 * CU Qp delta 866 * By default it is set to 0 at the beginning of coding quad tree 867 */ 868 WORD32 i4_cu_qp_delta; 869 870 /** 871 * Bitstream structure 872 */ 873 bitstrm_t s_bitstrm; 874 875 /** 876 * Pointer frame level TU subblock coeff data 877 */ 878 void *pv_pic_tu_coeff_data; 879 880 /** 881 * Pointer to TU subblock coeff data and number of coded subblocks and scan idx 882 * Incremented each time a coded subblock is parsed 883 * 884 */ 885 void *pv_tu_coeff_data; 886 887 /** 888 * Current TU structure - set to CTB tu_t pointer at the start of CTB parsing and incremented 889 * for every TU 890 */ 891 tu_t *ps_tu; 892 893 /** 894 * Current ctb's TU map 895 */ 896 UWORD8 *pu1_tu_map; 897 898 /** 899 * Current PU structure - set to CTB pu_t pointer at the start of CTB parsing and incremented 900 * for every TU 901 */ 902 pu_t *ps_pu; 903 904 /** 905 * Points to the array of slice indices which is used to identify the independent slice 906 * to which each CTB in a frame belongs. 907 */ 908 UWORD16 *pu1_slice_idx; 909 910 /** 911 * Current PU index in a frame 912 */ 913 WORD32 i4_pic_pu_idx; 914 915 /** 916 * Current TU index in a frame 917 */ 918 WORD32 i4_pic_tu_idx; 919 920 /** 921 * Current PU structure - set to CTB pu_map pointer at the start of CTB parsing 922 */ 923 UWORD8 *pu1_pu_map; 924 925 /** 926 * Current QP 927 */ 928 WORD32 u4_qp; 929 930 /** 931 * Current Group's QP 932 */ 933 WORD32 u4_qpg; 934 935 /** 936 * Number of PCM blocks in current CTB - Needed only during parsing 937 * If needed during recon then move it to ctb_t 938 */ 939 WORD32 i4_ctb_num_pcm_blks; 940 941 /** 942 * PCM flag for the current CU 943 */ 944 WORD32 i4_cu_pcm_flag; 945 946 /** 947 * CU related information to be used to populate tu_t and pu_t during 948 * pred unit and transform tree parsing. 949 */ 950 parse_cu_t s_cu; 951 952 /** 953 * Pointer to pu_map for the current frame being parsed 954 */ 955 UWORD8 *pu1_pic_pu_map; 956 957 /** 958 * Pointer to frame level pu_t for the current frame being parsed 959 * where MVs and Intra pred modes will be updated 960 */ 961 pu_t *ps_pic_pu; 962 963 /** 964 * Pointer to tu_map for the current frame being parsed 965 */ 966 UWORD8 *pu1_pic_tu_map; 967 968 /** 969 * Pointer to frame level tu_t for the current frame being parsed 970 * where transform unit related info will be updated 971 */ 972 tu_t *ps_pic_tu; 973 974 /** 975 * Points to an array of TU indices which is used to identify 976 * start index of tu_t in ps_pic_tu and also to identify number of 977 * TUs in the current CTB by subtracting current idx from next CTB's 978 * TU idx 979 */ 980 UWORD32 *pu4_pic_tu_idx; 981 982 /** 983 * Points to an array of PU indices which is used to identify 984 * start index of pu_t in ps_pic_pu and also to identify number of 985 * PUs in the current CTB by subtracting current idx from next CTB's 986 * PU idx 987 */ 988 UWORD32 *pu4_pic_pu_idx; 989 990 991 /** 992 * Current pictures intra mode map at 8x8 level 993 */ 994 UWORD8 *pu1_pic_intra_flag; 995 996 /** 997 * Current pictures loop filter flag map at 8x8 level 998 */ 999 UWORD8 *pu1_pic_no_loop_filter_flag; 1000 1001 /** 1002 * Array to hold one row (top) of skip_flag flag stored at (8x8) level 1003 * 1 bit per (8x8) 1004 * read and written as a UWORD32 1005 * LSB gives skip_flag for 0th 8x8 and MSB gives skip_flag for 31st 8x8 and so on 1006 * This is independent of CTB size or minCU size 1007 * Packed format requires extra calculations in extracting required bits but makes it easier 1008 * to store skip data for larger sizes such as 32 x 32 where 4 bits need to be set instead of 1009 * 4 bytes or for 64 x 64 where 8 bits need to be set instead of 8 bytes. 1010 */ 1011 UWORD32 *pu4_skip_cu_top; 1012 1013 /** 1014 * Array to hold one 64 pixel column (left) of skip_flag flag stored at (8x8) level 1015 * 1 bit per (8x8) 1016 * read and written as a UWORD32 1017 * LSB gives skip_flag for 0th 8x8 and MSB gives skip for 31st 8x8 and so on 1018 * This is independent of CTB size and allocated to store data for 64 pixels, of 1019 * this only first ctb_size number of bits (starting from MSB) will have valid data 1020 * This is also independent of min CU size and data is stored at 8x8 level. 1021 * Since only 8 bits are needed to represent left 64 pixels at 8x8 level, this is not an array 1022 */ 1023 UWORD32 u4_skip_cu_left; 1024 1025 /** 1026 * Array to hold one row (top) of coding_tree_depth stored at (8x8) level 1027 * 2 bits per (8x8) pixels 1028 * read and written as a WORD32 1029 * 2 LSBits give coding_tree_depth for 0th 8x8 and 2 MSBits give coding_tree_depth for 15th 8x8 and so on 1030 * This is independent of CTB size or minCU size 1031 */ 1032 UWORD32 *pu4_ct_depth_top; 1033 1034 /** 1035 * Array to hold one 64 pixel column (left) of coding_tree_depth stored at (8x8) level 1036 * 2 bits per (8x8) pixels 1037 * read and written as a WORD32 1038 * 2 LSBits give coding_tree_depth for 0th 8x8 and 2 MSBits give coding_tree_depth for 15th 8x8 and so on 1039 * This is independent of CTB size and allocated to store data for 64 pixels, of 1040 * this only first ctb_size * 2 number of bits (starting from MSB) will have valid data 1041 * This is also independent of min CU size and data is stored at 8x8 level. 1042 * Since only 16 bits are needed to represent left 64 pixels at 8x8 level, this is not an array 1043 */ 1044 UWORD32 u4_ct_depth_left; 1045 1046 /** 1047 * Array to hold top (one row) luma_intra_pred_mode stored at (4x4) level for a CTB 1048 * 8 bits per (4x4) pixels 1049 * read and written as a UWORD8 1050 * This is independent of CTB size or minCU size 1051 * This is independent of CTB size and allocated to store data for 64 pixels i.e. 64 bits is the size 1052 * Note this data is used only within a CTB, There is no inter CTB dependencies for this 1053 */ 1054 UWORD8 *pu1_luma_intra_pred_mode_top; 1055 1056 /** 1057 * Array to hold left (one column) luma_intra_pred_mode stored at (4x4) level for a CTB 1058 * 8 bits per (4x4) pixels 1059 * read and written as a UWORD8 1060 * This is independent of CTB size and allocated to store data for 64 pixels i.e. 64 bits is the size 1061 * This is also independent of min CU size and data is stored at 8x8 level. 1062 * This is used for prediction of next CTB within a row in a slice or tile 1063 */ 1064 UWORD8 *pu1_luma_intra_pred_mode_left; 1065 1066 1067 /** 1068 * Pointer to base of Video parameter set structure array 1069 */ 1070 vps_t *ps_vps_base; 1071 1072 /** 1073 * Pointer to base of Sequence parameter set structure array 1074 */ 1075 sps_t *ps_sps_base; 1076 1077 /** 1078 * Pointer to base of Picture parameter set structure array 1079 */ 1080 pps_t *ps_pps_base; 1081 1082 /** 1083 * Pointer to base of slice header structure array 1084 */ 1085 slice_header_t *ps_slice_hdr_base; 1086 1087 /** 1088 * Pointer to current slice header structure 1089 */ 1090 slice_header_t *ps_slice_hdr; 1091 1092 1093 /** 1094 * Error code during parse stage 1095 */ 1096 WORD32 i4_error_code; 1097 1098 /** 1099 * Void pointer to process job context 1100 */ 1101 void *pv_proc_jobq; 1102 1103 /* Cabac context */ 1104 cab_ctxt_t s_cabac; 1105 1106 /* Current Coding tree depth */ 1107 WORD32 i4_ct_depth; 1108 1109 /** Flag to signal end of frame */ 1110 WORD32 i4_end_of_frame; 1111 1112 /** 1113 * Index of the next CTB parsed 1114 */ 1115 WORD32 i4_next_ctb_indx; 1116 1117 /** 1118 * Pointer to the structure that contains BS and QP frame level arrays 1119 */ 1120 bs_ctxt_t s_bs_ctxt; 1121 1122 /** 1123 * Pointer to the structure that contains deblock context 1124 */ 1125 deblk_ctxt_t s_deblk_ctxt; 1126 1127 /** 1128 * Pointer to the structure that contains sao context 1129 */ 1130 sao_ctxt_t s_sao_ctxt; 1131 1132 /** 1133 * QP Array for the current CTB 1134 * Used in QP prediction 1135 */ 1136 WORD8 ai1_8x8_cu_qp[MAX_CU_IN_CTB]; 1137 1138 1139 /** 1140 * Pointer to frame level sao_t for the current frame being parsed 1141 */ 1142 sao_t *ps_pic_sao; 1143 1144 /** 1145 * Abs POC count of the frame 1146 */ 1147 WORD32 i4_abs_pic_order_cnt; 1148 1149 /** 1150 * Pointer points to mv_buffer of current frame 1151 */ 1152 mv_buf_t *ps_cur_mv_buf; 1153 1154 /** 1155 * Variable to store the next ctb count to compute pu idx 1156 */ 1157 WORD32 i4_next_pu_ctb_cnt; 1158 1159 /** 1160 * Variable to store the next ctb count to compute tu idx 1161 */ 1162 WORD32 i4_next_tu_ctb_cnt; 1163 1164 #ifndef DISABLE_SEI 1165 /** 1166 * SEI parameters 1167 */ 1168 sei_params_t s_sei_params; 1169 #endif 1170 }parse_ctxt_t; 1171 1172 /** 1173 * Pixel processing thread context 1174 */ 1175 1176 typedef struct 1177 { 1178 /* Pointer to codec context 1179 * 1180 */ 1181 codec_t *ps_codec; 1182 1183 /** 1184 * CTB's x position within a picture in raster scan in CTB units 1185 */ 1186 WORD32 i4_ctb_x; 1187 1188 /** 1189 * CTB's y position within a picture in raster scan in CTB units 1190 */ 1191 1192 WORD32 i4_ctb_y; 1193 1194 /** 1195 * CTB's x position within a Tile in raster scan in CTB units 1196 */ 1197 WORD32 i4_ctb_tile_x; 1198 1199 /** 1200 * CTB's y position within a Tile in raster scan in CTB units 1201 */ 1202 1203 WORD32 i4_ctb_tile_y; 1204 1205 /** 1206 * CTB's x position within a Slice in raster scan in CTB units 1207 */ 1208 WORD32 i4_ctb_slice_x; 1209 1210 /** 1211 * CTB's y position within a Slice in raster scan in CTB units 1212 */ 1213 1214 WORD32 i4_ctb_slice_y; 1215 1216 /** 1217 * Current tile being processed 1218 */ 1219 tile_t *ps_tile; 1220 1221 /** 1222 * Current slice idx - Used in multi-core cases to store slice index for 1223 * each ctb for sao filtering. 1224 */ 1225 WORD32 i4_cur_slice_idx; 1226 1227 /** 1228 * Current tile idx - Used in multi-core cases to store tile index for 1229 * each ctb for sao filtering. 1230 */ 1231 WORD32 i4_cur_tile_idx; 1232 /** 1233 * Pointer to current PPS 1234 */ 1235 pps_t *ps_pps; 1236 1237 /** 1238 * Pointer to current SPS 1239 */ 1240 sps_t *ps_sps; 1241 1242 /** 1243 * Pointer to current slice header structure 1244 */ 1245 slice_header_t *ps_slice_hdr; 1246 1247 /** 1248 * Error code during parse stage 1249 */ 1250 WORD32 i4_error_code; 1251 1252 /** 1253 * Signal that pic_init is called first time 1254 */ 1255 WORD32 i4_first_pic_init; 1256 1257 /** 1258 * Pointer frame level TU subblock coeff data 1259 */ 1260 void *pv_pic_tu_coeff_data; 1261 1262 /** 1263 * Pointer to TU subblock coeff data and number of subblocks and scan idx 1264 * Incremented each time a coded subblock is processed 1265 * 1266 */ 1267 void *pv_tu_coeff_data; 1268 1269 /** 1270 * Current TU structure - set to CTB tu_t pointer at the start of CTB processing and incremented 1271 * for every TU 1272 */ 1273 tu_t *ps_tu; 1274 1275 /** 1276 * Current ctb's TU map 1277 */ 1278 UWORD8 *pu1_tu_map; 1279 1280 /** 1281 * Current PU structure - set to CTB pu_t pointer at the start of CTB processing and incremented 1282 * for every TU 1283 */ 1284 pu_t *ps_pu; 1285 1286 /** 1287 * Points to an array of TU indices which is used to identify 1288 * start index of tu_t in ps_pic_tu and also to identify number of 1289 * TUs in the current CTB by subtracting current idx from next CTB's 1290 * TU idx 1291 */ 1292 UWORD32 *pu4_pic_tu_idx; 1293 1294 /** 1295 * Points to an array of PU indices which is used to identify 1296 * start index of pu_t in ps_pic_pu and also to identify number of 1297 * PUs in the current CTB by subtracting current idx from next CTB's 1298 * PU idx 1299 */ 1300 UWORD32 *pu4_pic_pu_idx; 1301 1302 /** 1303 * Pointer to tu_map for the current frame being parsed 1304 */ 1305 UWORD8 *pu1_pic_tu_map; 1306 1307 /** 1308 * Pointer to pu_map for the current frame being parsed 1309 * where MVs and Intra pred modes will be updated 1310 */ 1311 UWORD8 *pu1_pic_pu_map; 1312 1313 /** 1314 * Pointer to frame level pu_t for the current frame being parsed 1315 * where MVs and Intra pred modes will be updated 1316 */ 1317 pu_t *ps_pic_pu; 1318 1319 /** PU Index map per CTB. The indices in this map are w.r.t picture pu array and not 1320 * w.r.t CTB pu array. 1321 * This will be used during mv prediction and since neighbours will have different CTB pu map 1322 * it will be easier if they all have indices w.r.t picture level PU array rather than CTB level 1323 * PU array. 1324 * pu1_pic_pu_map is map w.r.t CTB's pu_t array 1325 */ 1326 UWORD32 *pu4_pic_pu_idx_map; 1327 1328 /** 1329 * PU Index of top 4x4 neighbors stored for an entire row 1330 */ 1331 UWORD32 *pu4_pic_pu_idx_top; 1332 1333 /** 1334 * PU Index of left 4x4 neighbors stored for 64 pixels 1335 */ 1336 UWORD32 *pu4_pic_pu_idx_left; 1337 1338 /** 1339 * Holds top left PU index at CTB level - top left gets overwritten 1340 * by left CTB while updating top array. Before updating top at CTB 1341 * level required top-left index is backed up in the following 1342 */ 1343 UWORD32 u4_ctb_top_left_pu_idx; 1344 1345 /** 1346 * Pointer to frame level tu_t for the current frame being parsed 1347 * where transform unit related info will be updated 1348 */ 1349 tu_t *ps_pic_tu; 1350 1351 1352 /** 1353 * Current PU structure - set to CTB pu_map pointer at the start of CTB parsing 1354 */ 1355 UWORD8 *pu1_pu_map; 1356 1357 /** Current MV Bank's buffer ID */ 1358 WORD32 i4_cur_mv_bank_buf_id; 1359 1360 /** 1361 * Current pictures intra mode map at 8x8 level 1362 */ 1363 UWORD8 *pu1_pic_intra_flag; 1364 1365 /** 1366 * Current pictures loop filter flag map at 8x8 level 1367 */ 1368 UWORD8 *pu1_pic_no_loop_filter_flag; 1369 1370 /** 1371 * Void pointer to process job context 1372 */ 1373 1374 void *pv_proc_jobq; 1375 1376 /** 1377 * Number of CTBs to be processed in the current Job 1378 */ 1379 WORD32 i4_ctb_cnt; 1380 /** 1381 * ID for the current context - Used for debugging 1382 */ 1383 WORD32 i4_id; 1384 1385 /** 1386 * Flag to indicate if parsing status has to be checked 1387 * Needed when parsing and processing are done in different threads 1388 */ 1389 WORD32 i4_check_parse_status; 1390 1391 /** 1392 * Flag to indicate if processing status of top row CTBs has to be checked 1393 * Needed when processing of different rows is done in different threads 1394 */ 1395 WORD32 i4_check_proc_status; 1396 1397 /** 1398 * Holds Intra dequantization matrices 1399 */ 1400 WORD16 *api2_dequant_intra_matrix[4]; 1401 1402 /** 1403 * Holds Inter dequantization matrices 1404 */ 1405 WORD16 *api2_dequant_inter_matrix[4]; 1406 1407 1408 /** 1409 * Temporary buffer 1 - Used as a scratch in inter_pred_ctb() 1410 */ 1411 WORD16 *pi2_inter_pred_tmp_buf1; 1412 1413 /** 1414 * Temporary buffer 2 - Used as a scratch in inter_pred_ctb() 1415 */ 1416 WORD16 *pi2_inter_pred_tmp_buf2; 1417 1418 /** 1419 * Temporary buffer 3 - Used as a scratch in inter_pred_ctb() 1420 */ 1421 WORD16 *pi2_inter_pred_tmp_buf3; 1422 1423 /** 1424 * The above temporary buffers' stride 1425 */ 1426 WORD32 i4_inter_pred_tmp_buf_strd; 1427 /** 1428 * Picture stride 1429 * Used as prediction stride, destination stride while computing inverse transform 1430 */ 1431 WORD32 i4_pic_strd; 1432 1433 /** 1434 * Picture qp offset for U 1435 */ 1436 WORD8 i1_pic_cb_qp_offset; 1437 1438 /** 1439 * Slice qp offset for U 1440 */ 1441 WORD32 i1_slice_cb_qp_offset; 1442 1443 /** 1444 * Picture qp offset for V 1445 */ 1446 WORD8 i1_pic_cr_qp_offset; 1447 1448 /** 1449 * Slice qp offset for V 1450 */ 1451 WORD32 i1_slice_cr_qp_offset; 1452 1453 /** Pointer to current picture buffer structure */ 1454 pic_buf_t *ps_cur_pic; 1455 1456 /** Current pic_buf's picture buffer id */ 1457 WORD32 i4_cur_pic_buf_id; 1458 1459 /** Pointer to 0th luma pixel in current pic */ 1460 UWORD8 *pu1_cur_pic_luma; 1461 1462 /** Pointer to 0th chroma pixel in current pic */ 1463 UWORD8 *pu1_cur_pic_chroma; 1464 1465 /** Intermediate buffer to be used during inverse transform */ 1466 WORD16 *pi2_itrans_intrmd_buf; 1467 1468 /** Buffer to hold output of inverse scan */ 1469 WORD16 *pi2_invscan_out; 1470 1471 /** 1472 * Top availability for current CTB level 1473 */ 1474 UWORD8 u1_top_ctb_avail; 1475 1476 /** 1477 * Top right availability for current CTB level 1478 */ 1479 UWORD8 u1_top_rt_ctb_avail; 1480 /** 1481 * Top left availability for current CTB level 1482 */ 1483 UWORD8 u1_top_lt_ctb_avail; 1484 /** 1485 * left availability for current CTB level 1486 */ 1487 UWORD8 u1_left_ctb_avail; 1488 /** 1489 * TU count in current CTB 1490 */ 1491 WORD32 i4_ctb_tu_cnt; 1492 1493 /** 1494 * Recon pointer to current CTB luma 1495 */ 1496 UWORD8 *pu1_cur_ctb_luma; 1497 /** 1498 * Recon pointer to current CTB chroma 1499 */ 1500 UWORD8 *pu1_cur_ctb_chroma; 1501 1502 /** 1503 * PU count in current CTB 1504 */ 1505 WORD32 i4_ctb_pu_cnt; 1506 1507 /** 1508 * PU count in current CTB 1509 */ 1510 WORD32 i4_ctb_start_pu_idx; 1511 1512 /* Pointer to a structure describing output display buffer */ 1513 ivd_out_bufdesc_t *ps_out_buffer; 1514 1515 /** Flag to indicate if ps_proc was intialized at least once in a frame. 1516 * This is needed to handle cases where a core starts to handle format conversion jobs directly 1517 */ 1518 WORD32 i4_init_done; 1519 1520 /** 1521 * Pointer to the structure that contains BS and QP frame level arrays 1522 */ 1523 bs_ctxt_t s_bs_ctxt; 1524 1525 /** 1526 * Pointer to the structure that contains deblock context 1527 */ 1528 deblk_ctxt_t s_deblk_ctxt; 1529 1530 /** 1531 * Pointer to the structure that contains sao context 1532 */ 1533 sao_ctxt_t s_sao_ctxt; 1534 1535 /** 1536 * Points to the array of slice indices which is used to identify the independent 1537 * slice to which each CTB in a frame belongs. 1538 */ 1539 UWORD16 *pu1_slice_idx; 1540 1541 /** 1542 * Points to the array of slice indices which is used to identify the slice 1543 * to which each CTB in a frame belongs. 1544 */ 1545 UWORD16 *pu1_tile_idx; 1546 /** 1547 * Variable to store the next ctb count to compute pu idx 1548 */ 1549 WORD32 i4_next_pu_ctb_cnt; 1550 1551 /** 1552 * Variable to store the next ctb count to compute tu idx 1553 */ 1554 WORD32 i4_next_tu_ctb_cnt; 1555 /** 1556 * Number of ctb's to process in one loop 1557 */ 1558 WORD32 i4_nctb; 1559 }process_ctxt_t; 1560 1561 /** 1562 * Reference mapping from pic_buf_id to pointers to corresponding qp_map and CU_type_map 1563 */ 1564 typedef struct 1565 { 1566 /** 1567 * qp_map buffer 1568 */ 1569 UWORD8 *pu1_qp_map; 1570 1571 /** 1572 * CU_type buffer 1573 */ 1574 UWORD8 *pu1_cu_type_map; 1575 }ref_map_t; 1576 1577 typedef void (*pf_inter_pred)(void *, 1578 void *, 1579 WORD32, 1580 WORD32, 1581 WORD8 *, 1582 WORD32, 1583 WORD32); 1584 1585 1586 typedef void (*pf_intra_pred)(UWORD8 *pu1_ref, 1587 WORD32 src_strd, 1588 UWORD8 *pu1_dst, 1589 WORD32 dst_strd, 1590 WORD32 nt, 1591 WORD32 mode); 1592 1593 typedef void (*pf_itrans_recon)(WORD16 *pi2_src, 1594 WORD16 *pi2_tmp, 1595 UWORD8 *pu1_pred, 1596 UWORD8 *pu1_dst, 1597 WORD32 src_strd, 1598 WORD32 pred_strd, 1599 WORD32 dst_strd, 1600 WORD32 zero_cols, 1601 WORD32 zero_rows); 1602 1603 typedef void (*pf_recon)(WORD16 *pi2_src, 1604 UWORD8 *pu1_pred, 1605 UWORD8 *pu1_dst, 1606 WORD32 src_strd, 1607 WORD32 pred_strd, 1608 WORD32 dst_strd, 1609 WORD32 zero_cols); 1610 1611 typedef void (*pf_itrans_recon_dc)(UWORD8 *pu1_pred, 1612 UWORD8 *pu1_dst, 1613 WORD32 pred_strd, 1614 WORD32 dst_strd, 1615 WORD32 log2_trans_size, 1616 WORD16 i2_coeff_value); 1617 1618 1619 typedef void (*pf_sao_luma)(UWORD8 *, 1620 WORD32, 1621 UWORD8 *, 1622 UWORD8 *, 1623 UWORD8 *, 1624 UWORD8 *, 1625 UWORD8 *, 1626 UWORD8 *, 1627 WORD8 *, 1628 WORD32, 1629 WORD32); 1630 1631 typedef void (*pf_sao_chroma)(UWORD8 *, 1632 WORD32, 1633 UWORD8 *, 1634 UWORD8 *, 1635 UWORD8 *, 1636 UWORD8 *, 1637 UWORD8 *, 1638 UWORD8 *, 1639 WORD8 *, 1640 WORD8 *, 1641 WORD32, 1642 WORD32); 1643 1644 /** 1645 * Codec context 1646 */ 1647 1648 struct _codec_t 1649 { 1650 /** 1651 * Width : pic_width_in_luma_samples 1652 */ 1653 WORD32 i4_wd; 1654 1655 /** 1656 * Height : pic_height_in_luma_samples 1657 */ 1658 WORD32 i4_ht; 1659 1660 /** 1661 * Display width after cropping 1662 */ 1663 WORD32 i4_disp_wd; 1664 1665 /** 1666 * Display height after cropping 1667 */ 1668 WORD32 i4_disp_ht; 1669 1670 /** 1671 * Display stride 1672 */ 1673 WORD32 i4_disp_strd; 1674 1675 /** 1676 * Stride of reference buffers. 1677 * For shared mode even display buffer will use the same stride 1678 */ 1679 WORD32 i4_strd; 1680 1681 /** 1682 * Number of cores to be used 1683 */ 1684 WORD32 i4_num_cores; 1685 1686 /** 1687 * RASL output flag 1688 */ 1689 WORD32 i4_rasl_output_flag; 1690 1691 /** 1692 * This flag is set if the next picture received is a CRA and has to be treated as a first pic in the video sequence 1693 * For example, it is set, if an EOS (end of stream) NAL is received 1694 */ 1695 WORD32 i4_cra_as_first_pic; 1696 1697 /** 1698 * Pictures that are are degraded 1699 * 0 : No degrade 1700 * 1 : Only on non-reference frames 1701 * 2 : Use interval specified by u4_nondegrade_interval 1702 * 3 : All non-key frames 1703 * 4 : All frames 1704 */ 1705 WORD32 i4_degrade_pics; 1706 1707 /** 1708 * Interval for pictures which are completely decoded without any degradation 1709 */ 1710 WORD32 i4_nondegrade_interval; 1711 1712 /** 1713 * bit position (lsb is zero): Type of degradation 1714 * 0 : Disable SAO 1715 * 1 : Disable deblocking 1716 * 2 : Faster inter prediction filters 1717 * 3 : Fastest inter prediction filters 1718 */ 1719 WORD32 i4_degrade_type; 1720 1721 /** Degrade pic count, Used to maintain the interval between non-degraded pics 1722 * 1723 */ 1724 WORD32 i4_degrade_pic_cnt; 1725 1726 /** 1727 * Total number of display buffers to be used 1728 * In case of shared mode, this will be number of reference frames 1729 */ 1730 WORD32 i4_num_disp_bufs; 1731 1732 /** 1733 * Flag to enable shared display buffer mode 1734 */ 1735 WORD32 i4_share_disp_buf; 1736 1737 /** 1738 * Chroma format of display buffers. 1739 In shared mode only 420SP_UV and 420SP_VU are supported 1740 */ 1741 IV_COLOR_FORMAT_T e_chroma_fmt; 1742 1743 /** 1744 * Chroma format of reference buffers. 1745 * In non-shared mode it will be 420SP_UV 1746 * In shared mode only 420SP_UV and 420SP_VU are supported 1747 */ 1748 IV_COLOR_FORMAT_T e_ref_chroma_fmt; 1749 1750 /** 1751 * Frame skip mode 1752 */ 1753 IVD_FRAME_SKIP_MODE_T e_pic_skip_mode; 1754 1755 /** 1756 * Display or decode order dump of output 1757 */ 1758 IVD_DISPLAY_FRAME_OUT_MODE_T e_pic_out_order; 1759 1760 /** 1761 * Coding type of the picture that is decoded 1762 */ 1763 IV_PICTURE_CODING_TYPE_T e_dec_pic_type; 1764 1765 /** 1766 * Flag to signal if a frame was decoded in this call 1767 */ 1768 WORD32 i4_pic_decoded; 1769 1770 /** 1771 * Flag to signal if picture data is present in the current input bitstream 1772 */ 1773 WORD32 i4_pic_present; 1774 1775 /** 1776 * Flag to disable deblocking of a frame 1777 */ 1778 WORD32 i4_disable_deblk_pic; 1779 1780 /** 1781 * Flag to disable sao of a frame 1782 */ 1783 WORD32 i4_disable_sao_pic; 1784 1785 /** 1786 * Flag to use full pel MC 1787 */ 1788 WORD32 i4_fullpel_inter_pred; 1789 /** 1790 * Flush mode 1791 */ 1792 WORD32 i4_flush_mode; 1793 1794 /** 1795 * Decode header mode 1796 */ 1797 WORD32 i4_header_mode; 1798 1799 /** 1800 * Header in slice mode 1801 */ 1802 WORD32 i4_header_in_slice_mode; 1803 1804 /** 1805 * Flag to signal sps done 1806 */ 1807 WORD32 i4_sps_done; 1808 1809 /** 1810 * Flag to signal pps done 1811 */ 1812 WORD32 i4_pps_done; 1813 1814 /** 1815 * To signal successful completion of init 1816 */ 1817 WORD32 i4_init_done; 1818 1819 /** 1820 * To signal that at least one picture was decoded 1821 */ 1822 WORD32 i4_first_pic_done; 1823 1824 /** 1825 * To signal error in slice 1826 */ 1827 WORD32 i4_slice_error; 1828 1829 /** 1830 * Reset flag - Codec is reset if this flag is set 1831 */ 1832 WORD32 i4_reset_flag; 1833 1834 /** 1835 * Number of pictures decoded till now 1836 */ 1837 UWORD32 u4_pic_cnt; 1838 1839 /** 1840 * Number of pictures displayed till now 1841 */ 1842 UWORD32 u4_disp_cnt; 1843 1844 /** 1845 * Current error code 1846 */ 1847 WORD32 i4_error_code; 1848 1849 /** 1850 * Pointer to input bitstream. This is incremented everytime a NAL is processed 1851 */ 1852 UWORD8 *pu1_inp_bitsbuf; 1853 1854 /** 1855 * Offset to first byte after the start code in current NAL 1856 */ 1857 WORD32 i4_nal_ofst; 1858 1859 /** 1860 * Length of the NAL unit including the emulation bytes 1861 */ 1862 WORD32 i4_nal_len; 1863 1864 /** 1865 * Number of emulation prevention bytes present in the current NAL 1866 */ 1867 WORD32 i4_num_emln_bytes; 1868 1869 /** 1870 * Number of bytes remaining in the input bitstream 1871 */ 1872 /** 1873 * Decremented everytime a NAL is processed 1874 */ 1875 WORD32 i4_bytes_remaining; 1876 1877 /** 1878 * Pointer to bitstream after emulation prevention 1879 */ 1880 UWORD8 *pu1_bitsbuf; 1881 1882 /** 1883 * Pointer to static bitstream after emulation prevention 1884 * This is a fixed size buffer used initially till SPS is decoded 1885 */ 1886 UWORD8 *pu1_bitsbuf_static; 1887 1888 /** 1889 * Pointer to dynamic bitstream after emulation prevention 1890 * This is allocated after SPS is done, based on width and height 1891 */ 1892 UWORD8 *pu1_bitsbuf_dynamic; 1893 1894 /** 1895 * Size of intermediate bitstream buffer 1896 */ 1897 UWORD32 u4_bitsbuf_size; 1898 1899 /** 1900 * Size of intermediate static bitstream buffer 1901 */ 1902 UWORD32 u4_bitsbuf_size_static; 1903 1904 /** 1905 * Size of intermediate dynamic bitstream buffer 1906 */ 1907 UWORD32 u4_bitsbuf_size_dynamic; 1908 1909 /** 1910 * Pointer to hold TU data for a set of CTBs or a picture 1911 */ 1912 void *pv_tu_data; 1913 1914 /** 1915 * Process Job queue buffer base 1916 */ 1917 void *pv_proc_jobq_buf; 1918 1919 /** 1920 * Process Job Queue mem tab size 1921 */ 1922 WORD32 i4_proc_jobq_buf_size; 1923 1924 /** Parse status: one byte per CTB */ 1925 UWORD8 *pu1_parse_map; 1926 1927 /** Process status: one byte per CTB */ 1928 UWORD8 *pu1_proc_map; 1929 /** 1930 * Current pictures intra mode map at 8x8 level 1931 */ 1932 UWORD8 *pu1_pic_intra_flag; 1933 1934 /** 1935 * No LPF buffer base 1936 */ 1937 UWORD8 *pu1_pic_no_loop_filter_flag_base; 1938 1939 /** 1940 * Current pictures loop filter flag map at 8x8 level 1941 */ 1942 UWORD8 *pu1_pic_no_loop_filter_flag; 1943 /** 1944 * MV Bank buffer manager 1945 */ 1946 void *pv_mv_buf_mgr; 1947 1948 /** 1949 * Pointer to MV Buf structure array 1950 */ 1951 void *ps_mv_buf; 1952 1953 /** Holds the number of mv_buf_t structures allocated */ 1954 WORD32 i4_max_dpb_size; 1955 1956 /** 1957 * Base address for Motion Vector bank buffer 1958 */ 1959 void *pv_mv_bank_buf_base; 1960 1961 /** 1962 * MV Bank size allocated 1963 */ 1964 WORD32 i4_total_mv_bank_size; 1965 1966 /** 1967 * Picture buffer manager 1968 */ 1969 void *pv_pic_buf_mgr; 1970 1971 /** 1972 * Pointer to Pic Buf structure array 1973 */ 1974 void *ps_pic_buf; 1975 1976 /** 1977 * Base address for Picture buffer 1978 */ 1979 void *pv_pic_buf_base; 1980 1981 /** 1982 * Total pic buffer size allocated 1983 */ 1984 WORD32 i4_total_pic_buf_size; 1985 1986 /** 1987 * Current chroma buffer base - used for shared mode with 420p output 1988 */ 1989 UWORD8 *pu1_cur_chroma_ref_buf; 1990 1991 /** 1992 * Picture buffer manager 1993 */ 1994 void *pv_disp_buf_mgr; 1995 1996 /** 1997 * Current display buffer's buffer ID 1998 */ 1999 WORD32 i4_disp_buf_id; 2000 2001 /** 2002 * Current display buffer 2003 */ 2004 pic_buf_t *ps_disp_buf; 2005 2006 /** 2007 * Pointer to dpb manager structure 2008 */ 2009 void *pv_dpb_mgr; 2010 2011 /** 2012 * Scaling matrices for each PPS 2013 */ 2014 WORD16 *pi2_scaling_mat; 2015 2016 /** 2017 * Array containing Tile information for each PPS 2018 */ 2019 tile_t *ps_tile; 2020 2021 /** 2022 * Timestamp associated with the current display output 2023 */ 2024 UWORD32 u4_ts; 2025 2026 /** 2027 * Enable CU_info 2028 */ 2029 UWORD8 u1_enable_cu_info; 2030 2031 /** 2032 * Ref mapping from pic_buf_id to corresponding CU_info maps 2033 */ 2034 ref_map_t as_buf_id_info_map[MAX_CU_INFO_BUF_CNT]; 2035 2036 /** 2037 * Total no of 8x8 blocks in luma samples 2038 */ 2039 WORD32 u4_num_8x8_blks; 2040 2041 /** 2042 * Pointer to base of qp_map buffer array 2043 */ 2044 UWORD8 *pu1_qp_map_base; 2045 2046 /** 2047 * Pointer to base of CU_type_map buffer array 2048 */ 2049 UWORD8 *pu1_cu_type_map_base; 2050 2051 /** 2052 * Pointer to base of Video parameter set structure array 2053 */ 2054 vps_t *ps_vps_base; 2055 2056 /** 2057 * Pointer to base of Sequence parameter set structure array 2058 */ 2059 sps_t *ps_sps_base; 2060 2061 /** 2062 * Pointer to base of Picture parameter set structure array 2063 */ 2064 pps_t *ps_pps_base; 2065 2066 /** 2067 * Pointer to base of slice header structure array 2068 */ 2069 slice_header_t *ps_slice_hdr_base; 2070 /** 2071 * Pointer to base of entry point offsets in a frame 2072 */ 2073 WORD32 *pi4_entry_ofst; 2074 2075 /** 2076 * Current offset in pi4_entry_ofst 2077 */ 2078 WORD32 i4_cur_entry_ofst; 2079 2080 /** 2081 * Parsing context 2082 */ 2083 parse_ctxt_t s_parse; 2084 2085 /** 2086 * Condition variable to signal process start 2087 */ 2088 void *apv_proc_start_condition[MAX_PROCESS_THREADS]; 2089 2090 /** 2091 * Mutex used to keep the functions thread-safe 2092 */ 2093 void *apv_proc_start_mutex[MAX_PROCESS_THREADS]; 2094 2095 /** 2096 * Process state start- One for each thread 2097 */ 2098 WORD32 ai4_process_start[MAX_PROCESS_THREADS]; 2099 2100 /** 2101 * Condition variable to signal process done 2102 */ 2103 void *apv_proc_done_condition[MAX_PROCESS_THREADS]; 2104 2105 /** 2106 * Mutex used to keep the functions thread-safe 2107 */ 2108 void *apv_proc_done_mutex[MAX_PROCESS_THREADS]; 2109 2110 /** 2111 * Process state end- One for each thread 2112 */ 2113 WORD32 ai4_process_done[MAX_PROCESS_THREADS]; 2114 2115 /** 2116 * Flag to signal processing thread to exit 2117 */ 2118 WORD32 i4_break_threads; 2119 2120 /** 2121 * Processing context - One for each processing thread 2122 */ 2123 process_ctxt_t as_process[MAX_PROCESS_THREADS]; 2124 2125 /** 2126 * Thread handle for each of the processing threads 2127 */ 2128 void *apv_process_thread_handle[MAX_PROCESS_THREADS]; 2129 2130 /** 2131 * Thread created flag for each of the processing threads 2132 */ 2133 WORD32 ai4_process_thread_created[MAX_PROCESS_THREADS]; 2134 2135 /** 2136 * Void pointer to process job context 2137 */ 2138 void *pv_proc_jobq; 2139 2140 /* Number of CTBs processed together for better instruction cache handling */ 2141 WORD32 i4_proc_nctb; 2142 2143 /** 2144 * Previous POC lsb 2145 */ 2146 WORD32 i4_prev_poc_lsb; 2147 2148 /** 2149 * Previous POC msb 2150 */ 2151 WORD32 i4_prev_poc_msb; 2152 2153 /** 2154 * Max POC lsb that has arrived till now 2155 */ 2156 WORD32 i4_max_prev_poc_lsb; 2157 2158 /** Context for format conversion */ 2159 fmt_conv_t s_fmt_conv; 2160 2161 /** Pointer to a structure describing output display buffer */ 2162 ivd_out_bufdesc_t *ps_out_buffer; 2163 /** 2164 * Variable to store the next ctb count to compute pu idx 2165 */ 2166 WORD32 i4_next_pu_ctb_cnt; 2167 2168 /** 2169 * Variable to store the next ctb count to compute tu idx 2170 */ 2171 WORD32 i4_next_tu_ctb_cnt; 2172 2173 /** Active SPS id - mainly to be used during codec initializations in shared mode */ 2174 WORD32 i4_sps_id; 2175 2176 /** Number of ctbs to be decoded in one process call */ 2177 UWORD32 u4_nctb; 2178 2179 /** Flag to enable scheduling of format conversion jobs ahead of processing jobs */ 2180 UWORD32 u4_enable_fmt_conv_ahead; 2181 2182 /** Mask used to change MVs to full pel when configured to run in reduced complexity mode */ 2183 WORD32 i4_mv_frac_mask; 2184 2185 /** Memory holding tile indices */ 2186 UWORD8 *pu1_tile_idx_base; 2187 2188 /** Callback for aligned allocation */ 2189 void *(*pf_aligned_alloc)(void *pv_mem_ctxt, WORD32 alignment, WORD32 size); 2190 2191 /** Callback for aligned free */ 2192 void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf); 2193 2194 /** Memory context passed from application */ 2195 void *pv_mem_ctxt; 2196 2197 /** Base address of reference buffrers allocated */ 2198 UWORD8 *pu1_ref_pic_buf_base; 2199 2200 /** Flag to indicate if dynamic buffers are allocated */ 2201 UWORD32 u4_allocate_dynamic_done; 2202 2203 /** Flag to signal display order */ 2204 IVD_DISPLAY_FRAME_OUT_MODE_T e_frm_out_mode; 2205 2206 /** Funtion pointers for inter_pred leaf level functions */ 2207 pf_inter_pred apf_inter_pred[22]; 2208 2209 /** Funtion pointers for inter_pred_luma leaf level functions */ 2210 pf_intra_pred apf_intra_pred_luma[11]; 2211 2212 /** Funtion pointers for inter_pred_chroma leaf level functions */ 2213 pf_intra_pred apf_intra_pred_chroma[11]; 2214 2215 /** Funtion pointers for itrans_recon leaf level functions */ 2216 pf_itrans_recon apf_itrans_recon[8]; 2217 2218 /** Funtion pointers for recon leaf level functions */ 2219 pf_recon apf_recon[8]; 2220 2221 /** Funtion pointers for itrans_recon_dc leaf level functions */ 2222 pf_itrans_recon_dc apf_itrans_recon_dc[2]; 2223 2224 /** Funtion pointers for sao_luma leaf level functions */ 2225 pf_sao_luma apf_sao_luma[4]; 2226 2227 /** Funtion pointers for sao_chroma leaf level functions */ 2228 pf_sao_chroma apf_sao_chroma[4]; 2229 2230 /** Funtion pointers for all the leaf level functions */ 2231 func_selector_t s_func_selector; 2232 /** Processor architecture */ 2233 IVD_ARCH_T e_processor_arch; 2234 /** Processor soc */ 2235 IVD_SOC_T e_processor_soc; 2236 2237 /** Display buffer array - for shared mode */ 2238 ivd_out_bufdesc_t s_disp_buffer[IVD_VIDDEC_MAX_IO_BUFFERS]; 2239 2240 /** Number of active display buffers - for shared mode */ 2241 WORD32 i4_share_disp_buf_cnt; 2242 2243 WORD32 i4_threads_active; 2244 }; 2245 2246 #endif /* _IHEVCD_STRUCTS_H_ */ 2247