History

avcodec/hevc_cabac: Let compiler count offsets

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.

Andreas Rheinhardt committed 2 years ago

Commit c1cdaef1 parent 98a2ade2 files · +100 −200Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/hevc_cabac.c +100 −148
  2. libavcodec/hevcdec.h +0 −52
libavcodec/hevc_cabac.c+100−148
@@ -31,114 +31,66 @@ · 30 unmodified lines
31 31
32#define CABAC_MAX_BIN 3132#define CABAC_MAX_BIN 31
33 33
34/**34// ELEM(NAME, NUM_BINS)
35 * number of bin by SyntaxElement.35#define CABAC_ELEMS(ELEM) \
36 */36 ELEM(SAO_MERGE_FLAG, 1) \
37static const int8_t num_bins_in_se[] = {37 ELEM(SAO_TYPE_IDX, 1) \
38 1, // sao_merge_flag38 ELEM(SAO_EO_CLASS, 0) \
39 1, // sao_type_idx39 ELEM(SAO_BAND_POSITION, 0) \
40 0, // sao_eo_class40 ELEM(SAO_OFFSET_ABS, 0) \
41 0, // sao_band_position41 ELEM(SAO_OFFSET_SIGN, 0) \
42 0, // sao_offset_abs42 ELEM(END_OF_SLICE_FLAG, 0) \
43 0, // sao_offset_sign43 ELEM(SPLIT_CODING_UNIT_FLAG, 3) \
44 0, // end_of_slice_flag44 ELEM(CU_TRANSQUANT_BYPASS_FLAG, 1) \
45 3, // split_coding_unit_flag45 ELEM(SKIP_FLAG, 3) \
46 1, // cu_transquant_bypass_flag46 ELEM(CU_QP_DELTA, 3) \
47 3, // skip_flag47 ELEM(PRED_MODE_FLAG, 1) \
48 3, // cu_qp_delta48 ELEM(PART_MODE, 4) \
49 1, // pred_mode49 ELEM(PCM_FLAG, 0) \
50 4, // part_mode50 ELEM(PREV_INTRA_LUMA_PRED_FLAG, 1) \
51 0, // pcm_flag51 ELEM(MPM_IDX, 0) \
52 1, // prev_intra_luma_pred_mode52 ELEM(REM_INTRA_LUMA_PRED_MODE, 0) \
53 0, // mpm_idx53 ELEM(INTRA_CHROMA_PRED_MODE, 2) \
54 0, // rem_intra_luma_pred_mode54 ELEM(MERGE_FLAG, 1) \
55 2, // intra_chroma_pred_mode55 ELEM(MERGE_IDX, 1) \
56 1, // merge_flag56 ELEM(INTER_PRED_IDC, 5) \
57 1, // merge_idx57 ELEM(REF_IDX_L0, 2) \
58 5, // inter_pred_idc58 ELEM(REF_IDX_L1, 2) \
59 2, // ref_idx_l059 ELEM(ABS_MVD_GREATER0_FLAG, 2) \
60 2, // ref_idx_l160 ELEM(ABS_MVD_GREATER1_FLAG, 2) \
61 2, // abs_mvd_greater0_flag61 ELEM(ABS_MVD_MINUS2, 0) \
62 2, // abs_mvd_greater1_flag62 ELEM(MVD_SIGN_FLAG, 0) \
63 0, // abs_mvd_minus263 ELEM(MVP_LX_FLAG, 1) \
64 0, // mvd_sign_flag64 ELEM(NO_RESIDUAL_DATA_FLAG, 1) \
65 1, // mvp_lx_flag65 ELEM(SPLIT_TRANSFORM_FLAG, 3) \
66 1, // no_residual_data_flag66 ELEM(CBF_LUMA, 2) \
67 3, // split_transform_flag67 ELEM(CBF_CB_CR, 5) \
68 2, // cbf_luma68 ELEM(TRANSFORM_SKIP_FLAG, 2) \
69 5, // cbf_cb, cbf_cr69 ELEM(EXPLICIT_RDPCM_FLAG, 2) \
70 2, // transform_skip_flag[][]70 ELEM(EXPLICIT_RDPCM_DIR_FLAG, 2) \
71 2, // explicit_rdpcm_flag[][]71 ELEM(LAST_SIGNIFICANT_COEFF_X_PREFIX, 18) \
72 2, // explicit_rdpcm_dir_flag[][]72 ELEM(LAST_SIGNIFICANT_COEFF_Y_PREFIX, 18) \
73 18, // last_significant_coeff_x_prefix73 ELEM(LAST_SIGNIFICANT_COEFF_X_SUFFIX, 0) \
74 18, // last_significant_coeff_y_prefix74 ELEM(LAST_SIGNIFICANT_COEFF_Y_SUFFIX, 0) \
75 0, // last_significant_coeff_x_suffix75 ELEM(SIGNIFICANT_COEFF_GROUP_FLAG, 4) \
76 0, // last_significant_coeff_y_suffix76 ELEM(SIGNIFICANT_COEFF_FLAG, 44) \
77 4, // significant_coeff_group_flag77 ELEM(COEFF_ABS_LEVEL_GREATER1_FLAG, 24) \
78 44, // significant_coeff_flag78 ELEM(COEFF_ABS_LEVEL_GREATER2_FLAG, 6) \
79 24, // coeff_abs_level_greater1_flag79 ELEM(COEFF_ABS_LEVEL_REMAINING, 0) \
80 6, // coeff_abs_level_greater2_flag80 ELEM(COEFF_SIGN_FLAG, 0) \
81 0, // coeff_abs_level_remaining81 ELEM(LOG2_RES_SCALE_ABS, 8) \
82 0, // coeff_sign_flag82 ELEM(RES_SCALE_SIGN_FLAG, 2) \
83 8, // log2_res_scale_abs83 ELEM(CU_CHROMA_QP_OFFSET_FLAG, 1) \
84 2, // res_scale_sign_flag84 ELEM(CU_CHROMA_QP_OFFSET_IDX, 1) \
85 1, // cu_chroma_qp_offset_flag
86 1, // cu_chroma_qp_offset_idx
87};
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 */
92static const int elem_offset[sizeof(num_bins_in_se)] = {89enum {
93 0, // sao_merge_flag90#define OFFSET(NAME, NUM_BINS) \
94 1, // sao_type_idx91 NAME ## _OFFSET, \
95 2, // sao_eo_class92 NAME ## _END = NAME ## _OFFSET + NUM_BINS - 1,
96 2, // sao_band_position93CABAC_ELEMS(OFFSET)
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
142};94};
143 95
144#define CNU 15496#define CNU 154
@@ -570,12 +522,12 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts) · 425 unmodified lines
570 522
571int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc)523int 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
576int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc)528int 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 return 0;531 return 0;
580 532
581 if (!get_cabac_bypass(&lc->cc))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
623int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)575int 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
628int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0, int x_cb, int y_cb)580int 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 if (lc->ctb_up_flag || y0b)590 if (lc->ctb_up_flag || y0b)
639 inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb - 1);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
644int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc)596int 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 int suffix_val = 0;599 int suffix_val = 0;
648 int inc = 0;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 prefix_val++;603 prefix_val++;
652 inc = 1;604 inc = 1;
653 }605 }
@@ -675,7 +627,7 @@ int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc) · 21 unmodified lines
675 627
676int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)628int 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
681int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc)633int 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 int c_max= FFMAX(5, lc->parent->ps.pps->chroma_qp_offset_list_len_minus1);635 int c_max= FFMAX(5, lc->parent->ps.pps->chroma_qp_offset_list_len_minus1);
684 int i = 0;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 i++;639 i++;
688 640
689 return i;641 return i;
@@ -691,7 +643,7 @@ int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc) · 1 unmodified line
691 643
692int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)644int 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
697int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, int ct_depth, int x0, int y0)649int 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 inc += (depth_left > ct_depth);664 inc += (depth_left > ct_depth);
713 inc += (depth_top > ct_depth);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
718int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size)670int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size)
719{671{
720 if (GET_CABAC(elem_offset[PART_MODE])) // 1672 if (GET_CABAC(PART_MODE_OFFSET)) // 1
721 return PART_2Nx2N;673 return PART_2Nx2N;
722 if (log2_cb_size == lc->parent->ps.sps->log2_min_cb_size) {674 if (log2_cb_size == lc->parent->ps.sps->log2_min_cb_size) {
723 if (lc->cu.pred_mode == MODE_INTRA) // 0675 if (lc->cu.pred_mode == MODE_INTRA) // 0
724 return PART_NxN;676 return PART_NxN;
725 if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01677 if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01
726 return PART_2NxN;678 return PART_2NxN;
727 if (log2_cb_size == 3) // 00679 if (log2_cb_size == 3) // 00
728 return PART_Nx2N;680 return PART_Nx2N;
729 if (GET_CABAC(elem_offset[PART_MODE] + 2)) // 001681 if (GET_CABAC(PART_MODE_OFFSET + 2)) // 001
730 return PART_Nx2N;682 return PART_Nx2N;
731 return PART_NxN; // 000683 return PART_NxN; // 000
732 }684 }
733 685
734 if (!lc->parent->ps.sps->amp_enabled_flag) {686 if (!lc->parent->ps.sps->amp_enabled_flag) {
735 if (GET_CABAC(elem_offset[PART_MODE] + 1)) // 01687 if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01
736 return PART_2NxN;688 return PART_2NxN;
737 return PART_Nx2N;689 return PART_Nx2N;
738 }690 }
739 691
740 if (GET_CABAC(elem_offset[PART_MODE] + 1)) { // 01X, 01XX692 if (GET_CABAC(PART_MODE_OFFSET + 1)) { // 01X, 01XX
741 if (GET_CABAC(elem_offset[PART_MODE] + 3)) // 011693 if (GET_CABAC(PART_MODE_OFFSET + 3)) // 011
742 return PART_2NxN;694 return PART_2NxN;
743 if (get_cabac_bypass(&lc->cc)) // 0101695 if (get_cabac_bypass(&lc->cc)) // 0101
744 return PART_2NxnD;696 return PART_2NxnD;
745 return PART_2NxnU; // 0100697 return PART_2NxnU; // 0100
746 }698 }
747 699
748 if (GET_CABAC(elem_offset[PART_MODE] + 3)) // 001700 if (GET_CABAC(PART_MODE_OFFSET + 3)) // 001
749 return PART_Nx2N;701 return PART_Nx2N;
750 if (get_cabac_bypass(&lc->cc)) // 0001702 if (get_cabac_bypass(&lc->cc)) // 0001
751 return PART_nRx2N;703 return PART_nRx2N;
@@ -759,7 +711,7 @@ int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc) · 7 unmodified lines
759 711
760int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc)712int 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
765int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc)717int 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
783int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)735int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)
784{736{
785 int ret;737 int ret;
786 if (!GET_CABAC(elem_offset[INTRA_CHROMA_PRED_MODE]))738 if (!GET_CABAC(INTRA_CHROMA_PRED_MODE_OFFSET))
787 return 4;739 return 4;
788 740
789 ret = get_cabac_bypass(&lc->cc) << 1;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
794int ff_hevc_merge_idx_decode(HEVCLocalContext *lc)746int 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 if (i != 0) {750 if (i != 0) {
799 while (i < lc->parent->sh.max_num_merge_cand-1 && get_cabac_bypass(&lc->cc))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
805int ff_hevc_merge_flag_decode(HEVCLocalContext *lc)757int 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
810int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)762int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)
811{763{
812 if (nPbW + nPbH == 12)764 if (nPbW + nPbH == 12)
813 return GET_CABAC(elem_offset[INTER_PRED_IDC] + 4);765 return GET_CABAC(INTER_PRED_IDC_OFFSET + 4);
814 if (GET_CABAC(elem_offset[INTER_PRED_IDC] + lc->ct_depth))766 if (GET_CABAC(INTER_PRED_IDC_OFFSET + lc->ct_depth))
815 return PRED_BI;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
820int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)772int 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 int max = num_ref_idx_lx - 1;775 int max = num_ref_idx_lx - 1;
824 int max_ctx = FFMIN(max, 2);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 i++;779 i++;
828 if (i == 2) {780 if (i == 2) {
829 while (i < max && get_cabac_bypass(&lc->cc))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
836int ff_hevc_mvp_lx_flag_decode(HEVCLocalContext *lc)788int 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
841int ff_hevc_no_residual_syntax_flag_decode(HEVCLocalContext *lc)793int 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
846static av_always_inline int abs_mvd_greater0_flag_decode(HEVCLocalContext *lc)798static 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
851static av_always_inline int abs_mvd_greater1_flag_decode(HEVCLocalContext *lc)803static 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
856static av_always_inline int mvd_decode(HEVCLocalContext *lc)808static 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
879int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size)831int 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
884int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth)836int 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
889int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth)841int 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
894static int hevc_transform_skip_flag_decode(HEVCLocalContext *lc, int c_idx)846static 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
899static int explicit_rdpcm_flag_decode(HEVCLocalContext *lc, int c_idx)851static 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
904static int explicit_rdpcm_dir_flag_decode(HEVCLocalContext *lc, int c_idx)856static 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
909int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)861int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)
910{862{
911 int i =0;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 i++;866 i++;
915 867
916 return i;868 return i;
@@ -918,7 +870,7 @@ int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx) · 1 unmodified line
918 870
919int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx)871int 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
924static av_always_inline void last_significant_coeff_xy_prefix_decode(HEVCLocalContext *lc, int c_idx,876static 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 ctx_shift = log2_size - 2;888 ctx_shift = log2_size - 2;
937 }889 }
938 while (i < max &&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 i++;892 i++;
941 *last_scx_prefix = i;893 *last_scx_prefix = i;
942 894
943 i = 0;895 i = 0;
944 while (i < max &&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 i++;898 i++;
947 *last_scy_prefix = i;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 inc = FFMIN(ctx_cg, 1) + (c_idx>0 ? 2 : 0);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}
970static av_always_inline int significant_coeff_flag_decode(HEVCLocalContext *lc, int x_c, int y_c,922static av_always_inline int significant_coeff_flag_decode(HEVCLocalContext *lc, int x_c, int y_c,
971 int offset, const uint8_t *ctx_idx_map)923 int offset, const uint8_t *ctx_idx_map)
972{924{
973 int inc = ctx_idx_map[(y_c << 2) + x_c] + offset;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
977static av_always_inline int significant_coeff_flag_decode_0(HEVCLocalContext *lc, int c_idx, int offset)929static 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
982static av_always_inline int coeff_abs_level_greater1_flag_decode(HEVCLocalContext *lc, int c_idx, int inc)934static 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 if (c_idx > 0)937 if (c_idx > 0)
986 inc += 16;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
991static av_always_inline int coeff_abs_level_greater2_flag_decode(HEVCLocalContext *lc, int c_idx, int inc)943static 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 if (c_idx > 0)945 if (c_idx > 0)
994 inc += 4;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
999static av_always_inline int coeff_abs_level_remaining_decode(HEVCLocalContext *lc, int rc_rice_param)951static av_always_inline int coeff_abs_level_remaining_decode(HEVCLocalContext *lc, int rc_rice_param)
libavcodec/hevcdec.h+0−52
@@ -86,58 +86,6 @@ enum RPSType { · 85 unmodified lines
86 NB_RPS_TYPE,86 NB_RPS_TYPE,
87};87};
88 88
89enum 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
141enum PartMode {89enum PartMode {
142 PART_2Nx2N = 0,90 PART_2Nx2N = 0,
143 PART_2NxN = 1,91 PART_2NxN = 1,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t