This is easily possible with an X macro. Using an enum for the offsets also allows to remove two arrays which are not really needed and will typically be optimized away by the compiler: The first just exists to count the number of syntax elements*, the second one exists to get offset[CONSTANT]. These constants were of type enum SyntaxElement and this enum was only used in hevc_cabac.c (although it was declared in hevcdec.h); it is now no longer needed at all and has therefore been removed. The first of these arrays led to a warning from Clang which is fixed by this commit: warning: variable 'num_bins_in_se' is not needed and will not be emitted [-Wunneeded-internal-declaration] *: One could also just added a trailing SYNTAX_ELEMENT_NB to the SyntaxElement enum for this purpose.
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -31,114 +31,66 @@ · 30 unmodified lines | ||
| 31 | 31 | |
| 32 | 32 | #define CABAC_MAX_BIN 31 |
| 33 | 33 | |
| 34 | −/** | |
| 35 | − * number of bin by SyntaxElement. | |
| 36 | − */ | |
| 37 | −static const int8_t num_bins_in_se[] = { | |
| 38 | − 1, // sao_merge_flag | |
| 39 | − 1, // sao_type_idx | |
| 40 | − 0, // sao_eo_class | |
| 41 | − 0, // sao_band_position | |
| 42 | − 0, // sao_offset_abs | |
| 43 | − 0, // sao_offset_sign | |
| 44 | − 0, // end_of_slice_flag | |
| 45 | − 3, // split_coding_unit_flag | |
| 46 | − 1, // cu_transquant_bypass_flag | |
| 47 | − 3, // skip_flag | |
| 48 | − 3, // cu_qp_delta | |
| 49 | − 1, // pred_mode | |
| 50 | − 4, // part_mode | |
| 51 | − 0, // pcm_flag | |
| 52 | − 1, // prev_intra_luma_pred_mode | |
| 53 | − 0, // mpm_idx | |
| 54 | − 0, // rem_intra_luma_pred_mode | |
| 55 | − 2, // intra_chroma_pred_mode | |
| 56 | − 1, // merge_flag | |
| 57 | − 1, // merge_idx | |
| 58 | − 5, // inter_pred_idc | |
| 59 | − 2, // ref_idx_l0 | |
| 60 | − 2, // ref_idx_l1 | |
| 61 | − 2, // abs_mvd_greater0_flag | |
| 62 | − 2, // abs_mvd_greater1_flag | |
| 63 | − 0, // abs_mvd_minus2 | |
| 64 | − 0, // mvd_sign_flag | |
| 65 | − 1, // mvp_lx_flag | |
| 66 | − 1, // no_residual_data_flag | |
| 67 | − 3, // split_transform_flag | |
| 68 | − 2, // cbf_luma | |
| 69 | − 5, // cbf_cb, cbf_cr | |
| 70 | − 2, // transform_skip_flag[][] | |
| 71 | − 2, // explicit_rdpcm_flag[][] | |
| 72 | − 2, // explicit_rdpcm_dir_flag[][] | |
| 73 | − 18, // last_significant_coeff_x_prefix | |
| 74 | − 18, // last_significant_coeff_y_prefix | |
| 75 | − 0, // last_significant_coeff_x_suffix | |
| 76 | − 0, // last_significant_coeff_y_suffix | |
| 77 | − 4, // significant_coeff_group_flag | |
| 78 | − 44, // significant_coeff_flag | |
| 79 | − 24, // coeff_abs_level_greater1_flag | |
| 80 | − 6, // coeff_abs_level_greater2_flag | |
| 81 | − 0, // coeff_abs_level_remaining | |
| 82 | − 0, // coeff_sign_flag | |
| 83 | − 8, // log2_res_scale_abs | |
| 84 | − 2, // res_scale_sign_flag | |
| 85 | − 1, // cu_chroma_qp_offset_flag | |
| 86 | − 1, // cu_chroma_qp_offset_idx | |
| 87 | −}; | |
| 34 | +// ELEM(NAME, NUM_BINS) | |
| 35 | +#define CABAC_ELEMS(ELEM) \ | |
| 36 | + ELEM(SAO_MERGE_FLAG, 1) \ | |
| 37 | + ELEM(SAO_TYPE_IDX, 1) \ | |
| 38 | + ELEM(SAO_EO_CLASS, 0) \ | |
| 39 | + ELEM(SAO_BAND_POSITION, 0) \ | |
| 40 | + ELEM(SAO_OFFSET_ABS, 0) \ | |
| 41 | + ELEM(SAO_OFFSET_SIGN, 0) \ | |
| 42 | + ELEM(END_OF_SLICE_FLAG, 0) \ | |
| 43 | + ELEM(SPLIT_CODING_UNIT_FLAG, 3) \ | |
| 44 | + ELEM(CU_TRANSQUANT_BYPASS_FLAG, 1) \ | |
| 45 | + ELEM(SKIP_FLAG, 3) \ | |
| 46 | + ELEM(CU_QP_DELTA, 3) \ | |
| 47 | + ELEM(PRED_MODE_FLAG, 1) \ | |
| 48 | + ELEM(PART_MODE, 4) \ | |
| 49 | + ELEM(PCM_FLAG, 0) \ | |
| 50 | + ELEM(PREV_INTRA_LUMA_PRED_FLAG, 1) \ | |
| 51 | + ELEM(MPM_IDX, 0) \ | |
| 52 | + ELEM(REM_INTRA_LUMA_PRED_MODE, 0) \ | |
| 53 | + ELEM(INTRA_CHROMA_PRED_MODE, 2) \ | |
| 54 | + ELEM(MERGE_FLAG, 1) \ | |
| 55 | + ELEM(MERGE_IDX, 1) \ | |
| 56 | + ELEM(INTER_PRED_IDC, 5) \ | |
| 57 | + ELEM(REF_IDX_L0, 2) \ | |
| 58 | + ELEM(REF_IDX_L1, 2) \ | |
| 59 | + ELEM(ABS_MVD_GREATER0_FLAG, 2) \ | |
| 60 | + ELEM(ABS_MVD_GREATER1_FLAG, 2) \ | |
| 61 | + ELEM(ABS_MVD_MINUS2, 0) \ | |
| 62 | + ELEM(MVD_SIGN_FLAG, 0) \ | |
| 63 | + ELEM(MVP_LX_FLAG, 1) \ | |
| 64 | + ELEM(NO_RESIDUAL_DATA_FLAG, 1) \ | |
| 65 | + ELEM(SPLIT_TRANSFORM_FLAG, 3) \ | |
| 66 | + ELEM(CBF_LUMA, 2) \ | |
| 67 | + ELEM(CBF_CB_CR, 5) \ | |
| 68 | + ELEM(TRANSFORM_SKIP_FLAG, 2) \ | |
| 69 | + ELEM(EXPLICIT_RDPCM_FLAG, 2) \ | |
| 70 | + ELEM(EXPLICIT_RDPCM_DIR_FLAG, 2) \ | |
| 71 | + ELEM(LAST_SIGNIFICANT_COEFF_X_PREFIX, 18) \ | |
| 72 | + ELEM(LAST_SIGNIFICANT_COEFF_Y_PREFIX, 18) \ | |
| 73 | + ELEM(LAST_SIGNIFICANT_COEFF_X_SUFFIX, 0) \ | |
| 74 | + ELEM(LAST_SIGNIFICANT_COEFF_Y_SUFFIX, 0) \ | |
| 75 | + ELEM(SIGNIFICANT_COEFF_GROUP_FLAG, 4) \ | |
| 76 | + ELEM(SIGNIFICANT_COEFF_FLAG, 44) \ | |
| 77 | + ELEM(COEFF_ABS_LEVEL_GREATER1_FLAG, 24) \ | |
| 78 | + ELEM(COEFF_ABS_LEVEL_GREATER2_FLAG, 6) \ | |
| 79 | + ELEM(COEFF_ABS_LEVEL_REMAINING, 0) \ | |
| 80 | + ELEM(COEFF_SIGN_FLAG, 0) \ | |
| 81 | + ELEM(LOG2_RES_SCALE_ABS, 8) \ | |
| 82 | + ELEM(RES_SCALE_SIGN_FLAG, 2) \ | |
| 83 | + ELEM(CU_CHROMA_QP_OFFSET_FLAG, 1) \ | |
| 84 | + ELEM(CU_CHROMA_QP_OFFSET_IDX, 1) \ | |
| 88 | 85 | |
| 89 | 86 | /** |
| 90 | − * Offset to ctxIdx 0 in init_values and states, indexed by SyntaxElement. | |
| 87 | + * Offset to ctxIdx 0 in init_values and states. | |
| 91 | 88 | */ |
| 92 | −static const int elem_offset[sizeof(num_bins_in_se)] = { | |
| 93 | − 0, // sao_merge_flag | |
| 94 | − 1, // sao_type_idx | |
| 95 | − 2, // sao_eo_class | |
| 96 | − 2, // sao_band_position | |
| 97 | − 2, // sao_offset_abs | |
| 98 | − 2, // sao_offset_sign | |
| 99 | − 2, // end_of_slice_flag | |
| 100 | − 2, // split_coding_unit_flag | |
| 101 | − 5, // cu_transquant_bypass_flag | |
| 102 | − 6, // skip_flag | |
| 103 | − 9, // cu_qp_delta | |
| 104 | − 12, // pred_mode | |
| 105 | − 13, // part_mode | |
| 106 | − 17, // pcm_flag | |
| 107 | − 17, // prev_intra_luma_pred_mode | |
| 108 | − 18, // mpm_idx | |
| 109 | − 18, // rem_intra_luma_pred_mode | |
| 110 | − 18, // intra_chroma_pred_mode | |
| 111 | − 20, // merge_flag | |
| 112 | − 21, // merge_idx | |
| 113 | − 22, // inter_pred_idc | |
| 114 | − 27, // ref_idx_l0 | |
| 115 | − 29, // ref_idx_l1 | |
| 116 | − 31, // abs_mvd_greater0_flag | |
| 117 | − 33, // abs_mvd_greater1_flag | |
| 118 | − 35, // abs_mvd_minus2 | |
| 119 | − 35, // mvd_sign_flag | |
| 120 | − 35, // mvp_lx_flag | |
| 121 | − 36, // no_residual_data_flag | |
| 122 | − 37, // split_transform_flag | |
| 123 | − 40, // cbf_luma | |
| 124 | − 42, // cbf_cb, cbf_cr | |
| 125 | − 47, // transform_skip_flag[][] | |
| 126 | − 49, // explicit_rdpcm_flag[][] | |
| 127 | − 51, // explicit_rdpcm_dir_flag[][] | |
| 128 | − 53, // last_significant_coeff_x_prefix | |
| 129 | − 71, // last_significant_coeff_y_prefix | |
| 130 | − 89, // last_significant_coeff_x_suffix | |
| 131 | − 89, // last_significant_coeff_y_suffix | |
| 132 | − 89, // significant_coeff_group_flag | |
| 133 | − 93, // significant_coeff_flag | |
| 134 | − 137, // coeff_abs_level_greater1_flag | |
| 135 | − 161, // coeff_abs_level_greater2_flag | |
| 136 | − 167, // coeff_abs_level_remaining | |
| 137 | − 167, // coeff_sign_flag | |
| 138 | − 167, // log2_res_scale_abs | |
| 139 | − 175, // res_scale_sign_flag | |
| 140 | − 177, // cu_chroma_qp_offset_flag | |
| 141 | − 178, // cu_chroma_qp_offset_idx | |
| 89 | +enum { | |
| 90 | +#define OFFSET(NAME, NUM_BINS) \ | |
| 91 | + NAME ## _OFFSET, \ | |
| 92 | + NAME ## _END = NAME ## _OFFSET + NUM_BINS - 1, | |
| 93 | +CABAC_ELEMS(OFFSET) | |
| 142 | 94 | }; |
| 143 | 95 | |
| 144 | 96 | #define CNU 154 |
| @@ -570,12 +522,12 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts) · 425 unmodified lines | ||
| 570 | 522 | |
| 571 | 523 | int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc) |
| 572 | 524 | { |
| 573 | − return GET_CABAC(elem_offset[SAO_MERGE_FLAG]); | |
| 525 | + return GET_CABAC(SAO_MERGE_FLAG_OFFSET); | |
| 574 | 526 | } |
| 575 | 527 | |
| 576 | 528 | int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc) |
| 577 | 529 | { |
| 578 | − if (!GET_CABAC(elem_offset[SAO_TYPE_IDX])) | |
| 530 | + if (!GET_CABAC(SAO_TYPE_IDX_OFFSET)) | |
| 579 | 531 | return 0; |
| 580 | 532 | |
| 581 | 533 | if (!get_cabac_bypass(&lc->cc)) |
| @@ -622,7 +574,7 @@ int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc) · 40 unmodified lines | ||
| 622 | 574 | |
| 623 | 575 | int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc) |
| 624 | 576 | { |
| 625 | − return GET_CABAC(elem_offset[CU_TRANSQUANT_BYPASS_FLAG]); | |
| 577 | + return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET); | |
| 626 | 578 | } |
| 627 | 579 | |
| 628 | 580 | int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0, int x_cb, int y_cb) |
| @@ -638,7 +590,7 @@ int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0, int x_cb, int · 9 unmodified lines | ||
| 638 | 590 | if (lc->ctb_up_flag || y0b) |
| 639 | 591 | inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb - 1); |
| 640 | 592 | |
| 641 | − return GET_CABAC(elem_offset[SKIP_FLAG] + inc); | |
| 593 | + return GET_CABAC(SKIP_FLAG_OFFSET + inc); | |
| 642 | 594 | } |
| 643 | 595 | |
| 644 | 596 | int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc) |
| @@ -647,7 +599,7 @@ int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc) · 2 unmodified lines | ||
| 647 | 599 | int suffix_val = 0; |
| 648 | 600 | int inc = 0; |
| 649 | 601 | |
| 650 | − while (prefix_val < 5 && GET_CABAC(elem_offset[CU_QP_DELTA] + inc)) { | |
| 602 | + while (prefix_val < 5 && GET_CABAC(CU_QP_DELTA_OFFSET + inc)) { | |
| 651 | 603 | prefix_val++; |
| 652 | 604 | inc = 1; |
| 653 | 605 | } |
| @@ -675,7 +627,7 @@ int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc) · 21 unmodified lines | ||
| 675 | 627 | |
| 676 | 628 | int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc) |
| 677 | 629 | { |
| 678 | − return GET_CABAC(elem_offset[CU_CHROMA_QP_OFFSET_FLAG]); | |
| 630 | + return GET_CABAC(CU_CHROMA_QP_OFFSET_FLAG_OFFSET); | |
| 679 | 631 | } |
| 680 | 632 | |
| 681 | 633 | int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc) |
| @@ -683,7 +635,7 @@ int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc) · 1 unmodified line | ||
| 683 | 635 | int c_max= FFMAX(5, lc->parent->ps.pps->chroma_qp_offset_list_len_minus1); |
| 684 | 636 | int i = 0; |
| 685 | 637 | |
| 686 | − while (i < c_max && GET_CABAC(elem_offset[CU_CHROMA_QP_OFFSET_IDX])) | |
| 638 | + while (i < c_max && GET_CABAC(CU_CHROMA_QP_OFFSET_IDX_OFFSET)) | |
| 687 | 639 | i++; |
| 688 | 640 | |
| 689 | 641 | return i; |
| @@ -691,7 +643,7 @@ int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc) · 1 unmodified line | ||
| 691 | 643 | |
| 692 | 644 | int ff_hevc_pred_mode_decode(HEVCLocalContext *lc) |
| 693 | 645 | { |
| 694 | − return GET_CABAC(elem_offset[PRED_MODE_FLAG]); | |
| 646 | + return GET_CABAC(PRED_MODE_FLAG_OFFSET); | |
| 695 | 647 | } |
| 696 | 648 | |
| 697 | 649 | int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, int ct_depth, int x0, int y0) |
| @@ -712,40 +664,40 @@ int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, int ct_depth, in · 14 unmodified lines | ||
| 712 | 664 | inc += (depth_left > ct_depth); |
| 713 | 665 | inc += (depth_top > ct_depth); |
| 714 | 666 | |
| 715 | − return GET_CABAC(elem_offset[SPLIT_CODING_UNIT_FLAG] + inc); | |
| 667 | + return GET_CABAC(SPLIT_CODING_UNIT_FLAG_OFFSET + inc); | |
| 716 | 668 | } |
| 717 | 669 | |
| 718 | 670 | int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size) |
| 719 | 671 | { |
| 720 | − if (GET_CABAC(elem_offset[PART_MODE])) // 1 | |
| 672 | + if (GET_CABAC(PART_MODE_OFFSET)) // 1 | |
| 721 | 673 | return PART_2Nx2N; |
| 722 | 674 | if (log2_cb_size == lc->parent->ps.sps->log2_min_cb_size) { |
| 723 | 675 | if (lc->cu.pred_mode == MODE_INTRA) // 0 |
| 724 | 676 | return PART_NxN; |
| 725 | − if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01 | |
| 677 | + if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01 | |
| 726 | 678 | return PART_2NxN; |
| 727 | 679 | if (log2_cb_size == 3) // 00 |
| 728 | 680 | return PART_Nx2N; |
| 729 | − if (GET_CABAC(elem_offset[PART_MODE] + 2)) // 001 | |
| 681 | + if (GET_CABAC(PART_MODE_OFFSET + 2)) // 001 | |
| 730 | 682 | return PART_Nx2N; |
| 731 | 683 | return PART_NxN; // 000 |
| 732 | 684 | } |
| 733 | 685 | |
| 734 | 686 | if (!lc->parent->ps.sps->amp_enabled_flag) { |
| 735 | − if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01 | |
| 687 | + if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01 | |
| 736 | 688 | return PART_2NxN; |
| 737 | 689 | return PART_Nx2N; |
| 738 | 690 | } |
| 739 | 691 | |
| 740 | − if (GET_CABAC(elem_offset[PART_MODE] + 1)) { // 01X, 01XX | |
| 741 | − if (GET_CABAC(elem_offset[PART_MODE] + 3)) // 011 | |
| 692 | + if (GET_CABAC(PART_MODE_OFFSET + 1)) { // 01X, 01XX | |
| 693 | + if (GET_CABAC(PART_MODE_OFFSET + 3)) // 011 | |
| 742 | 694 | return PART_2NxN; |
| 743 | 695 | if (get_cabac_bypass(&lc->cc)) // 0101 |
| 744 | 696 | return PART_2NxnD; |
| 745 | 697 | return PART_2NxnU; // 0100 |
| 746 | 698 | } |
| 747 | 699 | |
| 748 | − if (GET_CABAC(elem_offset[PART_MODE] + 3)) // 001 | |
| 700 | + if (GET_CABAC(PART_MODE_OFFSET + 3)) // 001 | |
| 749 | 701 | return PART_Nx2N; |
| 750 | 702 | if (get_cabac_bypass(&lc->cc)) // 0001 |
| 751 | 703 | return PART_nRx2N; |
| @@ -759,7 +711,7 @@ int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc) · 7 unmodified lines | ||
| 759 | 711 | |
| 760 | 712 | int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc) |
| 761 | 713 | { |
| 762 | − return GET_CABAC(elem_offset[PREV_INTRA_LUMA_PRED_FLAG]); | |
| 714 | + return GET_CABAC(PREV_INTRA_LUMA_PRED_FLAG_OFFSET); | |
| 763 | 715 | } |
| 764 | 716 | |
| 765 | 717 | int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc) |
| @@ -783,7 +735,7 @@ int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCLocalContext *lc) · 17 unmodified lines | ||
| 783 | 735 | int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc) |
| 784 | 736 | { |
| 785 | 737 | int ret; |
| 786 | − if (!GET_CABAC(elem_offset[INTRA_CHROMA_PRED_MODE])) | |
| 738 | + if (!GET_CABAC(INTRA_CHROMA_PRED_MODE_OFFSET)) | |
| 787 | 739 | return 4; |
| 788 | 740 | |
| 789 | 741 | ret = get_cabac_bypass(&lc->cc) << 1; |
| @@ -793,7 +745,7 @@ int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc) · 3 unmodified lines | ||
| 793 | 745 | |
| 794 | 746 | int ff_hevc_merge_idx_decode(HEVCLocalContext *lc) |
| 795 | 747 | { |
| 796 | − int i = GET_CABAC(elem_offset[MERGE_IDX]); | |
| 748 | + int i = GET_CABAC(MERGE_IDX_OFFSET); | |
| 797 | 749 | |
| 798 | 750 | if (i != 0) { |
| 799 | 751 | while (i < lc->parent->sh.max_num_merge_cand-1 && get_cabac_bypass(&lc->cc)) |
| @@ -804,17 +756,17 @@ int ff_hevc_merge_idx_decode(HEVCLocalContext *lc) · 4 unmodified lines | ||
| 804 | 756 | |
| 805 | 757 | int ff_hevc_merge_flag_decode(HEVCLocalContext *lc) |
| 806 | 758 | { |
| 807 | − return GET_CABAC(elem_offset[MERGE_FLAG]); | |
| 759 | + return GET_CABAC(MERGE_FLAG_OFFSET); | |
| 808 | 760 | } |
| 809 | 761 | |
| 810 | 762 | int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH) |
| 811 | 763 | { |
| 812 | 764 | if (nPbW + nPbH == 12) |
| 813 | − return GET_CABAC(elem_offset[INTER_PRED_IDC] + 4); | |
| 814 | − if (GET_CABAC(elem_offset[INTER_PRED_IDC] + lc->ct_depth)) | |
| 765 | + return GET_CABAC(INTER_PRED_IDC_OFFSET + 4); | |
| 766 | + if (GET_CABAC(INTER_PRED_IDC_OFFSET + lc->ct_depth)) | |
| 815 | 767 | return PRED_BI; |
| 816 | 768 | |
| 817 | − return GET_CABAC(elem_offset[INTER_PRED_IDC] + 4); | |
| 769 | + return GET_CABAC(INTER_PRED_IDC_OFFSET + 4); | |
| 818 | 770 | } |
| 819 | 771 | |
| 820 | 772 | int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx) |
| @@ -823,7 +775,7 @@ int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx) · 2 unmodified lines | ||
| 823 | 775 | int max = num_ref_idx_lx - 1; |
| 824 | 776 | int max_ctx = FFMIN(max, 2); |
| 825 | 777 | |
| 826 | − while (i < max_ctx && GET_CABAC(elem_offset[REF_IDX_L0] + i)) | |
| 778 | + while (i < max_ctx && GET_CABAC(REF_IDX_L0_OFFSET + i)) | |
| 827 | 779 | i++; |
| 828 | 780 | if (i == 2) { |
| 829 | 781 | while (i < max && get_cabac_bypass(&lc->cc)) |
| @@ -835,22 +787,22 @@ int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx) · 5 unmodified lines | ||
| 835 | 787 | |
| 836 | 788 | int ff_hevc_mvp_lx_flag_decode(HEVCLocalContext *lc) |
| 837 | 789 | { |
| 838 | − return GET_CABAC(elem_offset[MVP_LX_FLAG]); | |
| 790 | + return GET_CABAC(MVP_LX_FLAG_OFFSET); | |
| 839 | 791 | } |
| 840 | 792 | |
| 841 | 793 | int ff_hevc_no_residual_syntax_flag_decode(HEVCLocalContext *lc) |
| 842 | 794 | { |
| 843 | − return GET_CABAC(elem_offset[NO_RESIDUAL_DATA_FLAG]); | |
| 795 | + return GET_CABAC(NO_RESIDUAL_DATA_FLAG_OFFSET); | |
| 844 | 796 | } |
| 845 | 797 | |
| 846 | 798 | static av_always_inline int abs_mvd_greater0_flag_decode(HEVCLocalContext *lc) |
| 847 | 799 | { |
| 848 | − return GET_CABAC(elem_offset[ABS_MVD_GREATER0_FLAG]); | |
| 800 | + return GET_CABAC(ABS_MVD_GREATER0_FLAG_OFFSET); | |
| 849 | 801 | } |
| 850 | 802 | |
| 851 | 803 | static av_always_inline int abs_mvd_greater1_flag_decode(HEVCLocalContext *lc) |
| 852 | 804 | { |
| 853 | − return GET_CABAC(elem_offset[ABS_MVD_GREATER1_FLAG] + 1); | |
| 805 | + return GET_CABAC(ABS_MVD_GREATER1_FLAG_OFFSET + 1); | |
| 854 | 806 | } |
| 855 | 807 | |
| 856 | 808 | static av_always_inline int mvd_decode(HEVCLocalContext *lc) |
| @@ -878,39 +830,39 @@ static av_always_inline int mvd_sign_flag_decode(HEVCLocalContext *lc) · 21 unmodified lines | ||
| 878 | 830 | |
| 879 | 831 | int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size) |
| 880 | 832 | { |
| 881 | − return GET_CABAC(elem_offset[SPLIT_TRANSFORM_FLAG] + 5 - log2_trafo_size); | |
| 833 | + return GET_CABAC(SPLIT_TRANSFORM_FLAG_OFFSET + 5 - log2_trafo_size); | |
| 882 | 834 | } |
| 883 | 835 | |
| 884 | 836 | int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth) |
| 885 | 837 | { |
| 886 | − return GET_CABAC(elem_offset[CBF_CB_CR] + trafo_depth); | |
| 838 | + return GET_CABAC(CBF_CB_CR_OFFSET + trafo_depth); | |
| 887 | 839 | } |
| 888 | 840 | |
| 889 | 841 | int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth) |
| 890 | 842 | { |
| 891 | − return GET_CABAC(elem_offset[CBF_LUMA] + !trafo_depth); | |
| 843 | + return GET_CABAC(CBF_LUMA_OFFSET + !trafo_depth); | |
| 892 | 844 | } |
| 893 | 845 | |
| 894 | 846 | static int hevc_transform_skip_flag_decode(HEVCLocalContext *lc, int c_idx) |
| 895 | 847 | { |
| 896 | − return GET_CABAC(elem_offset[TRANSFORM_SKIP_FLAG] + !!c_idx); | |
| 848 | + return GET_CABAC(TRANSFORM_SKIP_FLAG_OFFSET + !!c_idx); | |
| 897 | 849 | } |
| 898 | 850 | |
| 899 | 851 | static int explicit_rdpcm_flag_decode(HEVCLocalContext *lc, int c_idx) |
| 900 | 852 | { |
| 901 | − return GET_CABAC(elem_offset[EXPLICIT_RDPCM_FLAG] + !!c_idx); | |
| 853 | + return GET_CABAC(EXPLICIT_RDPCM_FLAG_OFFSET + !!c_idx); | |
| 902 | 854 | } |
| 903 | 855 | |
| 904 | 856 | static int explicit_rdpcm_dir_flag_decode(HEVCLocalContext *lc, int c_idx) |
| 905 | 857 | { |
| 906 | − return GET_CABAC(elem_offset[EXPLICIT_RDPCM_DIR_FLAG] + !!c_idx); | |
| 858 | + return GET_CABAC(EXPLICIT_RDPCM_DIR_FLAG_OFFSET + !!c_idx); | |
| 907 | 859 | } |
| 908 | 860 | |
| 909 | 861 | int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx) |
| 910 | 862 | { |
| 911 | 863 | int i =0; |
| 912 | 864 | |
| 913 | − while (i < 4 && GET_CABAC(elem_offset[LOG2_RES_SCALE_ABS] + 4 * idx + i)) | |
| 865 | + while (i < 4 && GET_CABAC(LOG2_RES_SCALE_ABS_OFFSET + 4 * idx + i)) | |
| 914 | 866 | i++; |
| 915 | 867 | |
| 916 | 868 | return i; |
| @@ -918,7 +870,7 @@ int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx) · 1 unmodified line | ||
| 918 | 870 | |
| 919 | 871 | int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx) |
| 920 | 872 | { |
| 921 | − return GET_CABAC(elem_offset[RES_SCALE_SIGN_FLAG] + idx); | |
| 873 | + return GET_CABAC(RES_SCALE_SIGN_FLAG_OFFSET + idx); | |
| 922 | 874 | } |
| 923 | 875 | |
| 924 | 876 | static av_always_inline void last_significant_coeff_xy_prefix_decode(HEVCLocalContext *lc, int c_idx, |
| @@ -936,13 +888,13 @@ static av_always_inline void last_significant_coeff_xy_prefix_decode(HEVCLocalCo · 11 unmodified lines | ||
| 936 | 888 | ctx_shift = log2_size - 2; |
| 937 | 889 | } |
| 938 | 890 | while (i < max && |
| 939 | − GET_CABAC(elem_offset[LAST_SIGNIFICANT_COEFF_X_PREFIX] + (i >> ctx_shift) + ctx_offset)) | |
| 891 | + GET_CABAC(LAST_SIGNIFICANT_COEFF_X_PREFIX_OFFSET + (i >> ctx_shift) + ctx_offset)) | |
| 940 | 892 | i++; |
| 941 | 893 | *last_scx_prefix = i; |
| 942 | 894 | |
| 943 | 895 | i = 0; |
| 944 | 896 | while (i < max && |
| 945 | − GET_CABAC(elem_offset[LAST_SIGNIFICANT_COEFF_Y_PREFIX] + (i >> ctx_shift) + ctx_offset)) | |
| 897 | + GET_CABAC(LAST_SIGNIFICANT_COEFF_Y_PREFIX_OFFSET + (i >> ctx_shift) + ctx_offset)) | |
| 946 | 898 | i++; |
| 947 | 899 | *last_scy_prefix = i; |
| 948 | 900 | } |
| @@ -965,18 +917,18 @@ static av_always_inline int significant_coeff_group_flag_decode(HEVCLocalContext · 16 unmodified lines | ||
| 965 | 917 | |
| 966 | 918 | inc = FFMIN(ctx_cg, 1) + (c_idx>0 ? 2 : 0); |
| 967 | 919 | |
| 968 | − return GET_CABAC(elem_offset[SIGNIFICANT_COEFF_GROUP_FLAG] + inc); | |
| 920 | + return GET_CABAC(SIGNIFICANT_COEFF_GROUP_FLAG_OFFSET + inc); | |
| 969 | 921 | } |
| 970 | 922 | static av_always_inline int significant_coeff_flag_decode(HEVCLocalContext *lc, int x_c, int y_c, |
| 971 | 923 | int offset, const uint8_t *ctx_idx_map) |
| 972 | 924 | { |
| 973 | 925 | int inc = ctx_idx_map[(y_c << 2) + x_c] + offset; |
| 974 | − return GET_CABAC(elem_offset[SIGNIFICANT_COEFF_FLAG] + inc); | |
| 926 | + return GET_CABAC(SIGNIFICANT_COEFF_FLAG_OFFSET + inc); | |
| 975 | 927 | } |
| 976 | 928 | |
| 977 | 929 | static av_always_inline int significant_coeff_flag_decode_0(HEVCLocalContext *lc, int c_idx, int offset) |
| 978 | 930 | { |
| 979 | − return GET_CABAC(elem_offset[SIGNIFICANT_COEFF_FLAG] + offset); | |
| 931 | + return GET_CABAC(SIGNIFICANT_COEFF_FLAG_OFFSET + offset); | |
| 980 | 932 | } |
| 981 | 933 | |
| 982 | 934 | static av_always_inline int coeff_abs_level_greater1_flag_decode(HEVCLocalContext *lc, int c_idx, int inc) |
| @@ -985,7 +937,7 @@ static av_always_inline int coeff_abs_level_greater1_flag_decode(HEVCLocalContex · 2 unmodified lines | ||
| 985 | 937 | if (c_idx > 0) |
| 986 | 938 | inc += 16; |
| 987 | 939 | |
| 988 | − return GET_CABAC(elem_offset[COEFF_ABS_LEVEL_GREATER1_FLAG] + inc); | |
| 940 | + return GET_CABAC(COEFF_ABS_LEVEL_GREATER1_FLAG_OFFSET + inc); | |
| 989 | 941 | } |
| 990 | 942 | |
| 991 | 943 | static av_always_inline int coeff_abs_level_greater2_flag_decode(HEVCLocalContext *lc, int c_idx, int inc) |
| @@ -993,7 +945,7 @@ static av_always_inline int coeff_abs_level_greater2_flag_decode(HEVCLocalContex · 1 unmodified line | ||
| 993 | 945 | if (c_idx > 0) |
| 994 | 946 | inc += 4; |
| 995 | 947 | |
| 996 | − return GET_CABAC(elem_offset[COEFF_ABS_LEVEL_GREATER2_FLAG] + inc); | |
| 948 | + return GET_CABAC(COEFF_ABS_LEVEL_GREATER2_FLAG_OFFSET + inc); | |
| 997 | 949 | } |
| 998 | 950 | |
| 999 | 951 | static av_always_inline int coeff_abs_level_remaining_decode(HEVCLocalContext *lc, int rc_rice_param) |
| @@ -86,58 +86,6 @@ enum RPSType { · 85 unmodified lines | ||
| 86 | 86 | NB_RPS_TYPE, |
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | −enum SyntaxElement { | |
| 90 | − SAO_MERGE_FLAG = 0, | |
| 91 | − SAO_TYPE_IDX, | |
| 92 | − SAO_EO_CLASS, | |
| 93 | − SAO_BAND_POSITION, | |
| 94 | − SAO_OFFSET_ABS, | |
| 95 | − SAO_OFFSET_SIGN, | |
| 96 | − END_OF_SLICE_FLAG, | |
| 97 | − SPLIT_CODING_UNIT_FLAG, | |
| 98 | − CU_TRANSQUANT_BYPASS_FLAG, | |
| 99 | − SKIP_FLAG, | |
| 100 | − CU_QP_DELTA, | |
| 101 | − PRED_MODE_FLAG, | |
| 102 | − PART_MODE, | |
| 103 | − PCM_FLAG, | |
| 104 | − PREV_INTRA_LUMA_PRED_FLAG, | |
| 105 | − MPM_IDX, | |
| 106 | − REM_INTRA_LUMA_PRED_MODE, | |
| 107 | − INTRA_CHROMA_PRED_MODE, | |
| 108 | − MERGE_FLAG, | |
| 109 | − MERGE_IDX, | |
| 110 | − INTER_PRED_IDC, | |
| 111 | − REF_IDX_L0, | |
| 112 | − REF_IDX_L1, | |
| 113 | − ABS_MVD_GREATER0_FLAG, | |
| 114 | − ABS_MVD_GREATER1_FLAG, | |
| 115 | − ABS_MVD_MINUS2, | |
| 116 | − MVD_SIGN_FLAG, | |
| 117 | − MVP_LX_FLAG, | |
| 118 | − NO_RESIDUAL_DATA_FLAG, | |
| 119 | − SPLIT_TRANSFORM_FLAG, | |
| 120 | − CBF_LUMA, | |
| 121 | − CBF_CB_CR, | |
| 122 | − TRANSFORM_SKIP_FLAG, | |
| 123 | − EXPLICIT_RDPCM_FLAG, | |
| 124 | − EXPLICIT_RDPCM_DIR_FLAG, | |
| 125 | − LAST_SIGNIFICANT_COEFF_X_PREFIX, | |
| 126 | − LAST_SIGNIFICANT_COEFF_Y_PREFIX, | |
| 127 | − LAST_SIGNIFICANT_COEFF_X_SUFFIX, | |
| 128 | − LAST_SIGNIFICANT_COEFF_Y_SUFFIX, | |
| 129 | − SIGNIFICANT_COEFF_GROUP_FLAG, | |
| 130 | − SIGNIFICANT_COEFF_FLAG, | |
| 131 | − COEFF_ABS_LEVEL_GREATER1_FLAG, | |
| 132 | − COEFF_ABS_LEVEL_GREATER2_FLAG, | |
| 133 | − COEFF_ABS_LEVEL_REMAINING, | |
| 134 | − COEFF_SIGN_FLAG, | |
| 135 | − LOG2_RES_SCALE_ABS, | |
| 136 | − RES_SCALE_SIGN_FLAG, | |
| 137 | − CU_CHROMA_QP_OFFSET_FLAG, | |
| 138 | − CU_CHROMA_QP_OFFSET_IDX, | |
| 139 | −}; | |
| 140 | − | |
| 141 | 89 | enum PartMode { |
| 142 | 90 | PART_2Nx2N = 0, |
| 143 | 91 | PART_2NxN = 1, |