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 /** 1165 * SEI parameters 1166 */ 1167 sei_params_t s_sei_params; 1168 }parse_ctxt_t; 1169 1170 /** 1171 * Pixel processing thread context 1172 */ 1173 1174 typedef struct 1175 { 1176 /* Pointer to codec context 1177 * 1178 */ 1179 codec_t *ps_codec; 1180 1181 /** 1182 * CTB's x position within a picture in raster scan in CTB units 1183 */ 1184 WORD32 i4_ctb_x; 1185 1186 /** 1187 * CTB's y position within a picture in raster scan in CTB units 1188 */ 1189 1190 WORD32 i4_ctb_y; 1191 1192 /** 1193 * CTB's x position within a Tile in raster scan in CTB units 1194 */ 1195 WORD32 i4_ctb_tile_x; 1196 1197 /** 1198 * CTB's y position within a Tile in raster scan in CTB units 1199 */ 1200 1201 WORD32 i4_ctb_tile_y; 1202 1203 /** 1204 * CTB's x position within a Slice in raster scan in CTB units 1205 */ 1206 WORD32 i4_ctb_slice_x; 1207 1208 /** 1209 * CTB's y position within a Slice in raster scan in CTB units 1210 */ 1211 1212 WORD32 i4_ctb_slice_y; 1213 1214 /** 1215 * Current tile being processed 1216 */ 1217 tile_t *ps_tile; 1218 1219 /** 1220 * Current slice idx - Used in multi-core cases to store slice index for 1221 * each ctb for sao filtering. 1222 */ 1223 WORD32 i4_cur_slice_idx; 1224 1225 /** 1226 * Current tile idx - Used in multi-core cases to store tile index for 1227 * each ctb for sao filtering. 1228 */ 1229 WORD32 i4_cur_tile_idx; 1230 /** 1231 * Pointer to current PPS 1232 */ 1233 pps_t *ps_pps; 1234 1235 /** 1236 * Pointer to current SPS 1237 */ 1238 sps_t *ps_sps; 1239 1240 /** 1241 * Pointer to current slice header structure 1242 */ 1243 slice_header_t *ps_slice_hdr; 1244 1245 /** 1246 * Error code during parse stage 1247 */ 1248 WORD32 i4_error_code; 1249 1250 /** 1251 * Signal that pic_init is called first time 1252 */ 1253 WORD32 i4_first_pic_init; 1254 1255 /** 1256 * Pointer frame level TU subblock coeff data 1257 */ 1258 void *pv_pic_tu_coeff_data; 1259 1260 /** 1261 * Pointer to TU subblock coeff data and number of subblocks and scan idx 1262 * Incremented each time a coded subblock is processed 1263 * 1264 */ 1265 void *pv_tu_coeff_data; 1266 1267 /** 1268 * Current TU structure - set to CTB tu_t pointer at the start of CTB processing and incremented 1269 * for every TU 1270 */ 1271 tu_t *ps_tu; 1272 1273 /** 1274 * Current ctb's TU map 1275 */ 1276 UWORD8 *pu1_tu_map; 1277 1278 /** 1279 * Current PU structure - set to CTB pu_t pointer at the start of CTB processing and incremented 1280 * for every TU 1281 */ 1282 pu_t *ps_pu; 1283 1284 /** 1285 * Points to an array of TU indices which is used to identify 1286 * start index of tu_t in ps_pic_tu and also to identify number of 1287 * TUs in the current CTB by subtracting current idx from next CTB's 1288 * TU idx 1289 */ 1290 UWORD32 *pu4_pic_tu_idx; 1291 1292 /** 1293 * Points to an array of PU indices which is used to identify 1294 * start index of pu_t in ps_pic_pu and also to identify number of 1295 * PUs in the current CTB by subtracting current idx from next CTB's 1296 * PU idx 1297 */ 1298 UWORD32 *pu4_pic_pu_idx; 1299 1300 /** 1301 * Pointer to tu_map for the current frame being parsed 1302 */ 1303 UWORD8 *pu1_pic_tu_map; 1304 1305 /** 1306 * Pointer to pu_map for the current frame being parsed 1307 * where MVs and Intra pred modes will be updated 1308 */ 1309 UWORD8 *pu1_pic_pu_map; 1310 1311 /** 1312 * Pointer to frame level pu_t for the current frame being parsed 1313 * where MVs and Intra pred modes will be updated 1314 */ 1315 pu_t *ps_pic_pu; 1316 1317 /** PU Index map per CTB. The indices in this map are w.r.t picture pu array and not 1318 * w.r.t CTB pu array. 1319 * This will be used during mv prediction and since neighbours will have different CTB pu map 1320 * it will be easier if they all have indices w.r.t picture level PU array rather than CTB level 1321 * PU array. 1322 * pu1_pic_pu_map is map w.r.t CTB's pu_t array 1323 */ 1324 UWORD32 *pu4_pic_pu_idx_map; 1325 1326 /** 1327 * PU Index of top 4x4 neighbors stored for an entire row 1328 */ 1329 UWORD32 *pu4_pic_pu_idx_top; 1330 1331 /** 1332 * PU Index of left 4x4 neighbors stored for 64 pixels 1333 */ 1334 UWORD32 *pu4_pic_pu_idx_left; 1335 1336 /** 1337 * Holds top left PU index at CTB level - top left gets overwritten 1338 * by left CTB while updating top array. Before updating top at CTB 1339 * level required top-left index is backed up in the following 1340 */ 1341 UWORD32 u4_ctb_top_left_pu_idx; 1342 1343 /** 1344 * Pointer to frame level tu_t for the current frame being parsed 1345 * where transform unit related info will be updated 1346 */ 1347 tu_t *ps_pic_tu; 1348 1349 1350 /** 1351 * Current PU structure - set to CTB pu_map pointer at the start of CTB parsing 1352 */ 1353 UWORD8 *pu1_pu_map; 1354 1355 /** Current MV Bank's buffer ID */ 1356 WORD32 i4_cur_mv_bank_buf_id; 1357 1358 /** 1359 * Current pictures intra mode map at 8x8 level 1360 */ 1361 UWORD8 *pu1_pic_intra_flag; 1362 1363 /** 1364 * Current pictures loop filter flag map at 8x8 level 1365 */ 1366 UWORD8 *pu1_pic_no_loop_filter_flag; 1367 1368 /** 1369 * Void pointer to process job context 1370 */ 1371 1372 void *pv_proc_jobq; 1373 1374 /** 1375 * Number of CTBs to be processed in the current Job 1376 */ 1377 WORD32 i4_ctb_cnt; 1378 /** 1379 * ID for the current context - Used for debugging 1380 */ 1381 WORD32 i4_id; 1382 1383 /** 1384 * Flag to indicate if parsing status has to be checked 1385 * Needed when parsing and processing are done in different threads 1386 */ 1387 WORD32 i4_check_parse_status; 1388 1389 /** 1390 * Flag to indicate if processing status of top row CTBs has to be checked 1391 * Needed when processing of different rows is done in different threads 1392 */ 1393 WORD32 i4_check_proc_status; 1394 1395 /** 1396 * Holds Intra dequantization matrices 1397 */ 1398 WORD16 *api2_dequant_intra_matrix[4]; 1399 1400 /** 1401 * Holds Inter dequantization matrices 1402 */ 1403 WORD16 *api2_dequant_inter_matrix[4]; 1404 1405 1406 /** 1407 * Temporary buffer 1 - Used as a scratch in inter_pred_ctb() 1408 */ 1409 WORD16 *pi2_inter_pred_tmp_buf1; 1410 1411 /** 1412 * Temporary buffer 2 - Used as a scratch in inter_pred_ctb() 1413 */ 1414 WORD16 *pi2_inter_pred_tmp_buf2; 1415 1416 /** 1417 * Temporary buffer 3 - Used as a scratch in inter_pred_ctb() 1418 */ 1419 WORD16 *pi2_inter_pred_tmp_buf3; 1420 1421 /** 1422 * The above temporary buffers' stride 1423 */ 1424 WORD32 i4_inter_pred_tmp_buf_strd; 1425 /** 1426 * Picture stride 1427 * Used as prediction stride, destination stride while computing inverse transform 1428 */ 1429 WORD32 i4_pic_strd; 1430 1431 /** 1432 * Picture qp offset for U 1433 */ 1434 WORD8 i1_pic_cb_qp_offset; 1435 1436 /** 1437 * Slice qp offset for U 1438 */ 1439 WORD32 i1_slice_cb_qp_offset; 1440 1441 /** 1442 * Picture qp offset for V 1443 */ 1444 WORD8 i1_pic_cr_qp_offset; 1445 1446 /** 1447 * Slice qp offset for V 1448 */ 1449 WORD32 i1_slice_cr_qp_offset; 1450 1451 /** Pointer to current picture buffer structure */ 1452 pic_buf_t *ps_cur_pic; 1453 1454 /** Current pic_buf's picture buffer id */ 1455 WORD32 i4_cur_pic_buf_id; 1456 1457 /** Pointer to 0th luma pixel in current pic */ 1458 UWORD8 *pu1_cur_pic_luma; 1459 1460 /** Pointer to 0th chroma pixel in current pic */ 1461 UWORD8 *pu1_cur_pic_chroma; 1462 1463 /** Intermediate buffer to be used during inverse transform */ 1464 WORD16 *pi2_itrans_intrmd_buf; 1465 1466 /** Buffer to hold output of inverse scan */ 1467 WORD16 *pi2_invscan_out; 1468 1469 /** 1470 * Top availability for current CTB level 1471 */ 1472 UWORD8 u1_top_ctb_avail; 1473 1474 /** 1475 * Top right availability for current CTB level 1476 */ 1477 UWORD8 u1_top_rt_ctb_avail; 1478 /** 1479 * Top left availability for current CTB level 1480 */ 1481 UWORD8 u1_top_lt_ctb_avail; 1482 /** 1483 * left availability for current CTB level 1484 */ 1485 UWORD8 u1_left_ctb_avail; 1486 /** 1487 * TU count in current CTB 1488 */ 1489 WORD32 i4_ctb_tu_cnt; 1490 1491 /** 1492 * Recon pointer to current CTB luma 1493 */ 1494 UWORD8 *pu1_cur_ctb_luma; 1495 /** 1496 * Recon pointer to current CTB chroma 1497 */ 1498 UWORD8 *pu1_cur_ctb_chroma; 1499 1500 /** 1501 * PU count in current CTB 1502 */ 1503 WORD32 i4_ctb_pu_cnt; 1504 1505 /** 1506 * PU count in current CTB 1507 */ 1508 WORD32 i4_ctb_start_pu_idx; 1509 1510 /* Pointer to a structure describing output display buffer */ 1511 ivd_out_bufdesc_t *ps_out_buffer; 1512 1513 /** Flag to indicate if ps_proc was intialized at least once in a frame. 1514 * This is needed to handle cases where a core starts to handle format conversion jobs directly 1515 */ 1516 WORD32 i4_init_done; 1517 1518 /** 1519 * Pointer to the structure that contains BS and QP frame level arrays 1520 */ 1521 bs_ctxt_t s_bs_ctxt; 1522 1523 /** 1524 * Pointer to the structure that contains deblock context 1525 */ 1526 deblk_ctxt_t s_deblk_ctxt; 1527 1528 /** 1529 * Pointer to the structure that contains sao context 1530 */ 1531 sao_ctxt_t s_sao_ctxt; 1532 1533 /** 1534 * Points to the array of slice indices which is used to identify the independent 1535 * slice to which each CTB in a frame belongs. 1536 */ 1537 UWORD16 *pu1_slice_idx; 1538 1539 /** 1540 * Points to the array of slice indices which is used to identify the slice 1541 * to which each CTB in a frame belongs. 1542 */ 1543 UWORD16 *pu1_tile_idx; 1544 /** 1545 * Variable to store the next ctb count to compute pu idx 1546 */ 1547 WORD32 i4_next_pu_ctb_cnt; 1548 1549 /** 1550 * Variable to store the next ctb count to compute tu idx 1551 */ 1552 WORD32 i4_next_tu_ctb_cnt; 1553 /** 1554 * Number of ctb's to process in one loop 1555 */ 1556 WORD32 i4_nctb; 1557 }process_ctxt_t; 1558 1559 /** 1560 * Reference mapping from pic_buf_id to pointers to corresponding qp_map and CU_type_map 1561 */ 1562 typedef struct 1563 { 1564 /** 1565 * qp_map buffer 1566 */ 1567 UWORD8 *pu1_qp_map; 1568 1569 /** 1570 * CU_type buffer 1571 */ 1572 UWORD8 *pu1_cu_type_map; 1573 }ref_map_t; 1574 1575 typedef void (*pf_inter_pred)(void *, 1576 void *, 1577 WORD32, 1578 WORD32, 1579 WORD8 *, 1580 WORD32, 1581 WORD32); 1582 1583 1584 typedef void (*pf_intra_pred)(UWORD8 *pu1_ref, 1585 WORD32 src_strd, 1586 UWORD8 *pu1_dst, 1587 WORD32 dst_strd, 1588 WORD32 nt, 1589 WORD32 mode); 1590 1591 typedef void (*pf_itrans_recon)(WORD16 *pi2_src, 1592 WORD16 *pi2_tmp, 1593 UWORD8 *pu1_pred, 1594 UWORD8 *pu1_dst, 1595 WORD32 src_strd, 1596 WORD32 pred_strd, 1597 WORD32 dst_strd, 1598 WORD32 zero_cols, 1599 WORD32 zero_rows); 1600 1601 typedef void (*pf_recon)(WORD16 *pi2_src, 1602 UWORD8 *pu1_pred, 1603 UWORD8 *pu1_dst, 1604 WORD32 src_strd, 1605 WORD32 pred_strd, 1606 WORD32 dst_strd, 1607 WORD32 zero_cols); 1608 1609 typedef void (*pf_itrans_recon_dc)(UWORD8 *pu1_pred, 1610 UWORD8 *pu1_dst, 1611 WORD32 pred_strd, 1612 WORD32 dst_strd, 1613 WORD32 log2_trans_size, 1614 WORD16 i2_coeff_value); 1615 1616 1617 typedef void (*pf_sao_luma)(UWORD8 *, 1618 WORD32, 1619 UWORD8 *, 1620 UWORD8 *, 1621 UWORD8 *, 1622 UWORD8 *, 1623 UWORD8 *, 1624 UWORD8 *, 1625 WORD8 *, 1626 WORD32, 1627 WORD32); 1628 1629 typedef void (*pf_sao_chroma)(UWORD8 *, 1630 WORD32, 1631 UWORD8 *, 1632 UWORD8 *, 1633 UWORD8 *, 1634 UWORD8 *, 1635 UWORD8 *, 1636 UWORD8 *, 1637 WORD8 *, 1638 WORD8 *, 1639 WORD32, 1640 WORD32); 1641 1642 /** 1643 * Codec context 1644 */ 1645 1646 struct _codec_t 1647 { 1648 /** 1649 * Width : pic_width_in_luma_samples 1650 */ 1651 WORD32 i4_wd; 1652 1653 /** 1654 * Height : pic_height_in_luma_samples 1655 */ 1656 WORD32 i4_ht; 1657 1658 /** 1659 * Display width after cropping 1660 */ 1661 WORD32 i4_disp_wd; 1662 1663 /** 1664 * Display height after cropping 1665 */ 1666 WORD32 i4_disp_ht; 1667 1668 /** 1669 * Display stride 1670 */ 1671 WORD32 i4_disp_strd; 1672 1673 /** 1674 * Stride of reference buffers. 1675 * For shared mode even display buffer will use the same stride 1676 */ 1677 WORD32 i4_strd; 1678 1679 /** 1680 * Number of cores to be used 1681 */ 1682 WORD32 i4_num_cores; 1683 1684 /** 1685 * RASL output flag 1686 */ 1687 WORD32 i4_rasl_output_flag; 1688 1689 /** 1690 * 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 1691 * For example, it is set, if an EOS (end of stream) NAL is received 1692 */ 1693 WORD32 i4_cra_as_first_pic; 1694 1695 /** 1696 * Pictures that are are degraded 1697 * 0 : No degrade 1698 * 1 : Only on non-reference frames 1699 * 2 : Use interval specified by u4_nondegrade_interval 1700 * 3 : All non-key frames 1701 * 4 : All frames 1702 */ 1703 WORD32 i4_degrade_pics; 1704 1705 /** 1706 * Interval for pictures which are completely decoded without any degradation 1707 */ 1708 WORD32 i4_nondegrade_interval; 1709 1710 /** 1711 * bit position (lsb is zero): Type of degradation 1712 * 0 : Disable SAO 1713 * 1 : Disable deblocking 1714 * 2 : Faster inter prediction filters 1715 * 3 : Fastest inter prediction filters 1716 */ 1717 WORD32 i4_degrade_type; 1718 1719 /** Degrade pic count, Used to maintain the interval between non-degraded pics 1720 * 1721 */ 1722 WORD32 i4_degrade_pic_cnt; 1723 1724 /** 1725 * Total number of display buffers to be used 1726 * In case of shared mode, this will be number of reference frames 1727 */ 1728 WORD32 i4_num_disp_bufs; 1729 1730 /** 1731 * Flag to enable shared display buffer mode 1732 */ 1733 WORD32 i4_share_disp_buf; 1734 1735 /** 1736 * Chroma format of display buffers. 1737 In shared mode only 420SP_UV and 420SP_VU are supported 1738 */ 1739 IV_COLOR_FORMAT_T e_chroma_fmt; 1740 1741 /** 1742 * Chroma format of reference buffers. 1743 * In non-shared mode it will be 420SP_UV 1744 * In shared mode only 420SP_UV and 420SP_VU are supported 1745 */ 1746 IV_COLOR_FORMAT_T e_ref_chroma_fmt; 1747 1748 /** 1749 * Frame skip mode 1750 */ 1751 IVD_FRAME_SKIP_MODE_T e_pic_skip_mode; 1752 1753 /** 1754 * Display or decode order dump of output 1755 */ 1756 IVD_DISPLAY_FRAME_OUT_MODE_T e_pic_out_order; 1757 1758 /** 1759 * Coding type of the picture that is decoded 1760 */ 1761 IV_PICTURE_CODING_TYPE_T e_dec_pic_type; 1762 1763 /** 1764 * Flag to signal if a frame was decoded in this call 1765 */ 1766 WORD32 i4_pic_decoded; 1767 1768 /** 1769 * Flag to signal if picture data is present in the current input bitstream 1770 */ 1771 WORD32 i4_pic_present; 1772 1773 /** 1774 * Flag to disable deblocking of a frame 1775 */ 1776 WORD32 i4_disable_deblk_pic; 1777 1778 /** 1779 * Flag to disable sao of a frame 1780 */ 1781 WORD32 i4_disable_sao_pic; 1782 1783 /** 1784 * Flag to use full pel MC 1785 */ 1786 WORD32 i4_fullpel_inter_pred; 1787 /** 1788 * Flush mode 1789 */ 1790 WORD32 i4_flush_mode; 1791 1792 /** 1793 * Decode header mode 1794 */ 1795 WORD32 i4_header_mode; 1796 1797 /** 1798 * Header in slice mode 1799 */ 1800 WORD32 i4_header_in_slice_mode; 1801 1802 /** 1803 * Flag to signal sps done 1804 */ 1805 WORD32 i4_sps_done; 1806 1807 /** 1808 * Flag to signal pps done 1809 */ 1810 WORD32 i4_pps_done; 1811 1812 /** 1813 * To signal successful completion of init 1814 */ 1815 WORD32 i4_init_done; 1816 1817 /** 1818 * To signal that at least one picture was decoded 1819 */ 1820 WORD32 i4_first_pic_done; 1821 1822 /** 1823 * To signal error in slice 1824 */ 1825 WORD32 i4_slice_error; 1826 1827 /** 1828 * Reset flag - Codec is reset if this flag is set 1829 */ 1830 WORD32 i4_reset_flag; 1831 1832 /** 1833 * Number of pictures decoded till now 1834 */ 1835 UWORD32 u4_pic_cnt; 1836 1837 /** 1838 * Number of pictures displayed till now 1839 */ 1840 UWORD32 u4_disp_cnt; 1841 1842 /** 1843 * Current error code 1844 */ 1845 WORD32 i4_error_code; 1846 1847 /** 1848 * Pointer to input bitstream. This is incremented everytime a NAL is processed 1849 */ 1850 UWORD8 *pu1_inp_bitsbuf; 1851 1852 /** 1853 * Offset to first byte after the start code in current NAL 1854 */ 1855 WORD32 i4_nal_ofst; 1856 1857 /** 1858 * Length of the NAL unit including the emulation bytes 1859 */ 1860 WORD32 i4_nal_len; 1861 1862 /** 1863 * Number of emulation prevention bytes present in the current NAL 1864 */ 1865 WORD32 i4_num_emln_bytes; 1866 1867 /** 1868 * Number of bytes remaining in the input bitstream 1869 */ 1870 /** 1871 * Decremented everytime a NAL is processed 1872 */ 1873 WORD32 i4_bytes_remaining; 1874 1875 /** 1876 * Pointer to bitstream after emulation prevention 1877 */ 1878 UWORD8 *pu1_bitsbuf; 1879 1880 /** 1881 * Pointer to static bitstream after emulation prevention 1882 * This is a fixed size buffer used initially till SPS is decoded 1883 */ 1884 UWORD8 *pu1_bitsbuf_static; 1885 1886 /** 1887 * Pointer to dynamic bitstream after emulation prevention 1888 * This is allocated after SPS is done, based on width and height 1889 */ 1890 UWORD8 *pu1_bitsbuf_dynamic; 1891 1892 /** 1893 * Size of intermediate bitstream buffer 1894 */ 1895 UWORD32 u4_bitsbuf_size; 1896 1897 /** 1898 * Size of intermediate static bitstream buffer 1899 */ 1900 UWORD32 u4_bitsbuf_size_static; 1901 1902 /** 1903 * Size of intermediate dynamic bitstream buffer 1904 */ 1905 UWORD32 u4_bitsbuf_size_dynamic; 1906 1907 /** 1908 * Pointer to hold TU data for a set of CTBs or a picture 1909 */ 1910 void *pv_tu_data; 1911 1912 /** 1913 * Process Job queue buffer base 1914 */ 1915 void *pv_proc_jobq_buf; 1916 1917 /** 1918 * Process Job Queue mem tab size 1919 */ 1920 WORD32 i4_proc_jobq_buf_size; 1921 1922 /** Parse status: one byte per CTB */ 1923 UWORD8 *pu1_parse_map; 1924 1925 /** Process status: one byte per CTB */ 1926 UWORD8 *pu1_proc_map; 1927 /** 1928 * Current pictures intra mode map at 8x8 level 1929 */ 1930 UWORD8 *pu1_pic_intra_flag; 1931 1932 /** 1933 * No LPF buffer base 1934 */ 1935 UWORD8 *pu1_pic_no_loop_filter_flag_base; 1936 1937 /** 1938 * Current pictures loop filter flag map at 8x8 level 1939 */ 1940 UWORD8 *pu1_pic_no_loop_filter_flag; 1941 /** 1942 * MV Bank buffer manager 1943 */ 1944 void *pv_mv_buf_mgr; 1945 1946 /** 1947 * Pointer to MV Buf structure array 1948 */ 1949 void *ps_mv_buf; 1950 1951 /** Holds the number of mv_buf_t structures allocated */ 1952 WORD32 i4_max_dpb_size; 1953 1954 /** 1955 * Base address for Motion Vector bank buffer 1956 */ 1957 void *pv_mv_bank_buf_base; 1958 1959 /** 1960 * MV Bank size allocated 1961 */ 1962 WORD32 i4_total_mv_bank_size; 1963 1964 /** 1965 * Picture buffer manager 1966 */ 1967 void *pv_pic_buf_mgr; 1968 1969 /** 1970 * Pointer to Pic Buf structure array 1971 */ 1972 void *ps_pic_buf; 1973 1974 /** 1975 * Base address for Picture buffer 1976 */ 1977 void *pv_pic_buf_base; 1978 1979 /** 1980 * Total pic buffer size allocated 1981 */ 1982 WORD32 i4_total_pic_buf_size; 1983 1984 /** 1985 * Current chroma buffer base - used for shared mode with 420p output 1986 */ 1987 UWORD8 *pu1_cur_chroma_ref_buf; 1988 1989 /** 1990 * Picture buffer manager 1991 */ 1992 void *pv_disp_buf_mgr; 1993 1994 /** 1995 * Current display buffer's buffer ID 1996 */ 1997 WORD32 i4_disp_buf_id; 1998 1999 /** 2000 * Current display buffer 2001 */ 2002 pic_buf_t *ps_disp_buf; 2003 2004 /** 2005 * Pointer to dpb manager structure 2006 */ 2007 void *pv_dpb_mgr; 2008 2009 /** 2010 * Scaling matrices for each PPS 2011 */ 2012 WORD16 *pi2_scaling_mat; 2013 2014 /** 2015 * Array containing Tile information for each PPS 2016 */ 2017 tile_t *ps_tile; 2018 2019 /** 2020 * Timestamp associated with the current display output 2021 */ 2022 UWORD32 u4_ts; 2023 2024 /** 2025 * Enable CU_info 2026 */ 2027 UWORD8 u1_enable_cu_info; 2028 2029 /** 2030 * Ref mapping from pic_buf_id to corresponding CU_info maps 2031 */ 2032 ref_map_t as_buf_id_info_map[MAX_CU_INFO_BUF_CNT]; 2033 2034 /** 2035 * Total no of 8x8 blocks in luma samples 2036 */ 2037 WORD32 u4_num_8x8_blks; 2038 2039 /** 2040 * Pointer to base of qp_map buffer array 2041 */ 2042 UWORD8 *pu1_qp_map_base; 2043 2044 /** 2045 * Pointer to base of CU_type_map buffer array 2046 */ 2047 UWORD8 *pu1_cu_type_map_base; 2048 2049 /** 2050 * Pointer to base of Video parameter set structure array 2051 */ 2052 vps_t *ps_vps_base; 2053 2054 /** 2055 * Pointer to base of Sequence parameter set structure array 2056 */ 2057 sps_t *ps_sps_base; 2058 2059 /** 2060 * Pointer to base of Picture parameter set structure array 2061 */ 2062 pps_t *ps_pps_base; 2063 2064 /** 2065 * Pointer to base of slice header structure array 2066 */ 2067 slice_header_t *ps_slice_hdr_base; 2068 /** 2069 * Pointer to base of entry point offsets in a frame 2070 */ 2071 WORD32 *pi4_entry_ofst; 2072 2073 /** 2074 * Current offset in pi4_entry_ofst 2075 */ 2076 WORD32 i4_cur_entry_ofst; 2077 2078 /** 2079 * Parsing context 2080 */ 2081 parse_ctxt_t s_parse; 2082 2083 #ifdef KEEP_THREADS_ACTIVE 2084 /** 2085 * Condition variable to signal process start 2086 */ 2087 void *apv_proc_start_condition[MAX_PROCESS_THREADS]; 2088 2089 /** 2090 * Mutex used to keep the functions thread-safe 2091 */ 2092 void *apv_proc_start_mutex[MAX_PROCESS_THREADS]; 2093 2094 /** 2095 * Process state start- One for each thread 2096 */ 2097 WORD32 ai4_process_start[MAX_PROCESS_THREADS]; 2098 2099 /** 2100 * Condition variable to signal process done 2101 */ 2102 void *apv_proc_done_condition[MAX_PROCESS_THREADS]; 2103 2104 /** 2105 * Mutex used to keep the functions thread-safe 2106 */ 2107 void *apv_proc_done_mutex[MAX_PROCESS_THREADS]; 2108 2109 /** 2110 * Process state end- One for each thread 2111 */ 2112 WORD32 ai4_process_done[MAX_PROCESS_THREADS]; 2113 2114 /** 2115 * Flag to signal processing thread to exit 2116 */ 2117 WORD32 i4_break_threads; 2118 #endif 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 2244 #endif /* _IHEVCD_STRUCTS_H_ */ 2245