Instead, accept PPS/SPS as function arguments. Makes the code shorter and significantly reduces diff in future commits.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -143,7 +143,7 @@ fail: · 142 unmodified lines | |||
| 143 | return AVERROR(ENOMEM); | 143 | return AVERROR(ENOMEM); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | static int pred_weight_table(HEVCContext *s, GetBitContext *gb) | 146 | static int pred_weight_table(HEVCContext *s, const HEVCSPS *sps, GetBitContext *gb) |
| 147 | { | 147 | { |
| 148 | int i = 0; | 148 | int i = 0; |
| 149 | int j = 0; | 149 | int j = 0; |
| @@ -159,7 +159,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 9 unmodified lines | |||
| 159 | return AVERROR_INVALIDDATA; | 159 | return AVERROR_INVALIDDATA; |
| 160 | } | 160 | } |
| 161 | s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); | 161 | s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); |
| 162 | if (s->ps.sps->chroma_format_idc != 0) { | 162 | if (sps->chroma_format_idc != 0) { |
| 163 | int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb); | 163 | int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb); |
| 164 | if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) { | 164 | if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) { |
| 165 | av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom); | 165 | av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom); |
| @@ -175,7 +175,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 9 unmodified lines | |||
| 175 | s->sh.luma_offset_l0[i] = 0; | 175 | s->sh.luma_offset_l0[i] = 0; |
| 176 | } | 176 | } |
| 177 | } | 177 | } |
| 178 | if (s->ps.sps->chroma_format_idc != 0) { | 178 | if (sps->chroma_format_idc != 0) { |
| 179 | for (i = 0; i < s->sh.nb_refs[L0]; i++) | 179 | for (i = 0; i < s->sh.nb_refs[L0]; i++) |
| 180 | chroma_weight_l0_flag[i] = get_bits1(gb); | 180 | chroma_weight_l0_flag[i] = get_bits1(gb); |
| 181 | } else { | 181 | } else { |
| @@ -219,7 +219,7 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 37 unmodified lines | |||
| 219 | s->sh.luma_offset_l1[i] = 0; | 219 | s->sh.luma_offset_l1[i] = 0; |
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | if (s->ps.sps->chroma_format_idc != 0) { | 222 | if (sps->chroma_format_idc != 0) { |
| 223 | for (i = 0; i < s->sh.nb_refs[L1]; i++) | 223 | for (i = 0; i < s->sh.nb_refs[L1]; i++) |
| 224 | chroma_weight_l1_flag[i] = get_bits1(gb); | 224 | chroma_weight_l1_flag[i] = get_bits1(gb); |
| 225 | } else { | 225 | } else { |
| @@ -259,9 +259,9 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb) · 33 unmodified lines | |||
| 259 | return 0; | 259 | return 0; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb) | 262 | static int decode_lt_rps(HEVCContext *s, const HEVCSPS *sps, LongTermRPS *rps, |
| 263 | GetBitContext *gb) | ||
| 263 | { | 264 | { |
| 264 | const HEVCSPS *sps = s->ps.sps; | ||
| 265 | int max_poc_lsb = 1 << sps->log2_max_poc_lsb; | 265 | int max_poc_lsb = 1 << sps->log2_max_poc_lsb; |
| 266 | int prev_delta_msb = 0; | 266 | int prev_delta_msb = 0; |
| 267 | unsigned int nb_sps = 0, nb_sh; | 267 | unsigned int nb_sps = 0, nb_sh; |
| @@ -591,6 +591,8 @@ fail: · 323 unmodified lines | |||
| 591 | static int hls_slice_header(HEVCContext *s, GetBitContext *gb) | 591 | static int hls_slice_header(HEVCContext *s, GetBitContext *gb) |
| 592 | { | 592 | { |
| 593 | SliceHeader *sh = &s->sh; | 593 | SliceHeader *sh = &s->sh; |
| 594 | const HEVCPPS *pps; | ||
| 595 | const HEVCSPS *sps; | ||
| 594 | int i, ret; | 596 | int i, ret; |
| 595 | 597 | ||
| 596 | // Coded parameters | 598 | // Coded parameters |
| @@ -621,11 +623,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 24 unmodified lines | |||
| 621 | return AVERROR_INVALIDDATA; | 623 | return AVERROR_INVALIDDATA; |
| 622 | } | 624 | } |
| 623 | s->ps.pps = s->ps.pps_list[sh->pps_id]; | 625 | s->ps.pps = s->ps.pps_list[sh->pps_id]; |
| 626 | pps = s->ps.pps; | ||
| 627 | sps = pps->sps; | ||
| 628 | |||
| 624 | if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) | 629 | if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) |
| 625 | sh->no_output_of_prior_pics_flag = 1; | 630 | sh->no_output_of_prior_pics_flag = 1; |
| 626 | 631 | ||
| 627 | if (s->ps.sps != s->ps.pps->sps) { | 632 | if (s->ps.sps != sps) { |
| 628 | const HEVCSPS *sps = s->ps.pps->sps; | ||
| 629 | enum AVPixelFormat pix_fmt; | 633 | enum AVPixelFormat pix_fmt; |
| 630 | 634 | ||
| 631 | ff_hevc_clear_refs(s); | 635 | ff_hevc_clear_refs(s); |
| @@ -651,13 +655,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 19 unmodified lines | |||
| 651 | if (!sh->first_slice_in_pic_flag) { | 655 | if (!sh->first_slice_in_pic_flag) { |
| 652 | int slice_address_length; | 656 | int slice_address_length; |
| 653 | 657 | ||
| 654 | if (s->ps.pps->dependent_slice_segments_enabled_flag) | 658 | if (pps->dependent_slice_segments_enabled_flag) |
| 655 | sh->dependent_slice_segment_flag = get_bits1(gb); | 659 | sh->dependent_slice_segment_flag = get_bits1(gb); |
| 656 | 660 | ||
| 657 | slice_address_length = av_ceil_log2(s->ps.sps->ctb_width * | 661 | slice_address_length = av_ceil_log2(sps->ctb_width * |
| 658 | s->ps.sps->ctb_height); | 662 | sps->ctb_height); |
| 659 | sh->slice_segment_addr = get_bitsz(gb, slice_address_length); | 663 | sh->slice_segment_addr = get_bitsz(gb, slice_address_length); |
| 660 | if (sh->slice_segment_addr >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { | 664 | if (sh->slice_segment_addr >= sps->ctb_width * sps->ctb_height) { |
| 661 | av_log(s->avctx, AV_LOG_ERROR, | 665 | av_log(s->avctx, AV_LOG_ERROR, |
| 662 | "Invalid slice segment address: %u.\n", | 666 | "Invalid slice segment address: %u.\n", |
| 663 | sh->slice_segment_addr); | 667 | sh->slice_segment_addr); |
| @@ -677,7 +681,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 13 unmodified lines | |||
| 677 | if (!sh->dependent_slice_segment_flag) { | 681 | if (!sh->dependent_slice_segment_flag) { |
| 678 | s->slice_initialized = 0; | 682 | s->slice_initialized = 0; |
| 679 | 683 | ||
| 680 | for (i = 0; i < s->ps.pps->num_extra_slice_header_bits; i++) | 684 | for (i = 0; i < pps->num_extra_slice_header_bits; i++) |
| 681 | skip_bits(gb, 1); // slice_reserved_undetermined_flag[] | 685 | skip_bits(gb, 1); // slice_reserved_undetermined_flag[] |
| 682 | 686 | ||
| 683 | sh->slice_type = get_ue_golomb_long(gb); | 687 | sh->slice_type = get_ue_golomb_long(gb); |
| @@ -689,24 +693,24 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 5 unmodified lines | |||
| 689 | return AVERROR_INVALIDDATA; | 693 | return AVERROR_INVALIDDATA; |
| 690 | } | 694 | } |
| 691 | if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I && | 695 | if (IS_IRAP(s) && sh->slice_type != HEVC_SLICE_I && |
| 692 | !s->ps.pps->pps_curr_pic_ref_enabled_flag) { | 696 | !pps->pps_curr_pic_ref_enabled_flag) { |
| 693 | av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n"); | 697 | av_log(s->avctx, AV_LOG_ERROR, "Inter slices in an IRAP frame.\n"); |
| 694 | return AVERROR_INVALIDDATA; | 698 | return AVERROR_INVALIDDATA; |
| 695 | } | 699 | } |
| 696 | 700 | ||
| 697 | // when flag is not present, picture is inferred to be output | 701 | // when flag is not present, picture is inferred to be output |
| 698 | sh->pic_output_flag = 1; | 702 | sh->pic_output_flag = 1; |
| 699 | if (s->ps.pps->output_flag_present_flag) | 703 | if (pps->output_flag_present_flag) |
| 700 | sh->pic_output_flag = get_bits1(gb); | 704 | sh->pic_output_flag = get_bits1(gb); |
| 701 | 705 | ||
| 702 | if (s->ps.sps->separate_colour_plane) | 706 | if (sps->separate_colour_plane) |
| 703 | sh->colour_plane_id = get_bits(gb, 2); | 707 | sh->colour_plane_id = get_bits(gb, 2); |
| 704 | 708 | ||
| 705 | if (!IS_IDR(s)) { | 709 | if (!IS_IDR(s)) { |
| 706 | int poc, pos; | 710 | int poc, pos; |
| 707 | 711 | ||
| 708 | sh->pic_order_cnt_lsb = get_bits(gb, s->ps.sps->log2_max_poc_lsb); | 712 | sh->pic_order_cnt_lsb = get_bits(gb, sps->log2_max_poc_lsb); |
| 709 | poc = ff_hevc_compute_poc(s->ps.sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type); | 713 | poc = ff_hevc_compute_poc(sps, s->pocTid0, sh->pic_order_cnt_lsb, s->nal_unit_type); |
| 710 | if (!sh->first_slice_in_pic_flag && poc != s->poc) { | 714 | if (!sh->first_slice_in_pic_flag && poc != s->poc) { |
| 711 | av_log(s->avctx, AV_LOG_WARNING, | 715 | av_log(s->avctx, AV_LOG_WARNING, |
| 712 | "Ignoring POC change between slices: %d -> %d\n", s->poc, poc); | 716 | "Ignoring POC change between slices: %d -> %d\n", s->poc, poc); |
| @@ -719,7 +723,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 6 unmodified lines | |||
| 719 | sh->short_term_ref_pic_set_sps_flag = get_bits1(gb); | 723 | sh->short_term_ref_pic_set_sps_flag = get_bits1(gb); |
| 720 | pos = get_bits_left(gb); | 724 | pos = get_bits_left(gb); |
| 721 | if (!sh->short_term_ref_pic_set_sps_flag) { | 725 | if (!sh->short_term_ref_pic_set_sps_flag) { |
| 722 | ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, s->ps.sps, 1); | 726 | ret = ff_hevc_decode_short_term_rps(gb, s->avctx, &sh->slice_rps, sps, 1); |
| 723 | if (ret < 0) | 727 | if (ret < 0) |
| 724 | return ret; | 728 | return ret; |
| 725 | 729 | ||
| @@ -727,19 +731,19 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line | |||
| 727 | } else { | 731 | } else { |
| 728 | int numbits, rps_idx; | 732 | int numbits, rps_idx; |
| 729 | 733 | ||
| 730 | if (!s->ps.sps->nb_st_rps) { | 734 | if (!sps->nb_st_rps) { |
| 731 | av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n"); | 735 | av_log(s->avctx, AV_LOG_ERROR, "No ref lists in the SPS.\n"); |
| 732 | return AVERROR_INVALIDDATA; | 736 | return AVERROR_INVALIDDATA; |
| 733 | } | 737 | } |
| 734 | 738 | ||
| 735 | numbits = av_ceil_log2(s->ps.sps->nb_st_rps); | 739 | numbits = av_ceil_log2(sps->nb_st_rps); |
| 736 | rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0; | 740 | rps_idx = numbits > 0 ? get_bits(gb, numbits) : 0; |
| 737 | sh->short_term_rps = &s->ps.sps->st_rps[rps_idx]; | 741 | sh->short_term_rps = &sps->st_rps[rps_idx]; |
| 738 | } | 742 | } |
| 739 | sh->short_term_ref_pic_set_size = pos - get_bits_left(gb); | 743 | sh->short_term_ref_pic_set_size = pos - get_bits_left(gb); |
| 740 | 744 | ||
| 741 | pos = get_bits_left(gb); | 745 | pos = get_bits_left(gb); |
| 742 | ret = decode_lt_rps(s, &sh->long_term_rps, gb); | 746 | ret = decode_lt_rps(s, sps, &sh->long_term_rps, gb); |
| 743 | if (ret < 0) { | 747 | if (ret < 0) { |
| 744 | av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n"); | 748 | av_log(s->avctx, AV_LOG_WARNING, "Invalid long term RPS.\n"); |
| 745 | if (s->avctx->err_recognition & AV_EF_EXPLODE) | 749 | if (s->avctx->err_recognition & AV_EF_EXPLODE) |
| @@ -747,7 +751,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line | |||
| 747 | } | 751 | } |
| 748 | sh->long_term_ref_pic_set_size = pos - get_bits_left(gb); | 752 | sh->long_term_ref_pic_set_size = pos - get_bits_left(gb); |
| 749 | 753 | ||
| 750 | if (s->ps.sps->temporal_mvp_enabled) | 754 | if (sps->temporal_mvp_enabled) |
| 751 | sh->slice_temporal_mvp_enabled_flag = get_bits1(gb); | 755 | sh->slice_temporal_mvp_enabled_flag = get_bits1(gb); |
| 752 | else | 756 | else |
| 753 | sh->slice_temporal_mvp_enabled_flag = 0; | 757 | sh->slice_temporal_mvp_enabled_flag = 0; |
| @@ -772,9 +776,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 18 unmodified lines | |||
| 772 | s->nal_unit_type != HEVC_NAL_RASL_R) | 776 | s->nal_unit_type != HEVC_NAL_RASL_R) |
| 773 | s->pocTid0 = s->poc; | 777 | s->pocTid0 = s->poc; |
| 774 | 778 | ||
| 775 | if (s->ps.sps->sao_enabled) { | 779 | if (sps->sao_enabled) { |
| 776 | sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb); | 780 | sh->slice_sample_adaptive_offset_flag[0] = get_bits1(gb); |
| 777 | if (s->ps.sps->chroma_format_idc) { | 781 | if (sps->chroma_format_idc) { |
| 778 | sh->slice_sample_adaptive_offset_flag[1] = | 782 | sh->slice_sample_adaptive_offset_flag[1] = |
| 779 | sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb); | 783 | sh->slice_sample_adaptive_offset_flag[2] = get_bits1(gb); |
| 780 | } | 784 | } |
| @@ -788,9 +792,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 7 unmodified lines | |||
| 788 | if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) { | 792 | if (sh->slice_type == HEVC_SLICE_P || sh->slice_type == HEVC_SLICE_B) { |
| 789 | int nb_refs; | 793 | int nb_refs; |
| 790 | 794 | ||
| 791 | sh->nb_refs[L0] = s->ps.pps->num_ref_idx_l0_default_active; | 795 | sh->nb_refs[L0] = pps->num_ref_idx_l0_default_active; |
| 792 | if (sh->slice_type == HEVC_SLICE_B) | 796 | if (sh->slice_type == HEVC_SLICE_B) |
| 793 | sh->nb_refs[L1] = s->ps.pps->num_ref_idx_l1_default_active; | 797 | sh->nb_refs[L1] = pps->num_ref_idx_l1_default_active; |
| 794 | 798 | ||
| 795 | if (get_bits1(gb)) { // num_ref_idx_active_override_flag | 799 | if (get_bits1(gb)) { // num_ref_idx_active_override_flag |
| 796 | sh->nb_refs[L0] = get_ue_golomb_31(gb) + 1; | 800 | sh->nb_refs[L0] = get_ue_golomb_31(gb) + 1; |
| @@ -811,7 +815,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 14 unmodified lines | |||
| 811 | return AVERROR_INVALIDDATA; | 815 | return AVERROR_INVALIDDATA; |
| 812 | } | 816 | } |
| 813 | 817 | ||
| 814 | if (s->ps.pps->lists_modification_present_flag && nb_refs > 1) { | 818 | if (pps->lists_modification_present_flag && nb_refs > 1) { |
| 815 | sh->rpl_modification_flag[0] = get_bits1(gb); | 819 | sh->rpl_modification_flag[0] = get_bits1(gb); |
| 816 | if (sh->rpl_modification_flag[0]) { | 820 | if (sh->rpl_modification_flag[0]) { |
| 817 | for (i = 0; i < sh->nb_refs[L0]; i++) | 821 | for (i = 0; i < sh->nb_refs[L0]; i++) |
| @@ -829,7 +833,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 11 unmodified lines | |||
| 829 | if (sh->slice_type == HEVC_SLICE_B) | 833 | if (sh->slice_type == HEVC_SLICE_B) |
| 830 | sh->mvd_l1_zero_flag = get_bits1(gb); | 834 | sh->mvd_l1_zero_flag = get_bits1(gb); |
| 831 | 835 | ||
| 832 | if (s->ps.pps->cabac_init_present_flag) | 836 | if (pps->cabac_init_present_flag) |
| 833 | sh->cabac_init_flag = get_bits1(gb); | 837 | sh->cabac_init_flag = get_bits1(gb); |
| 834 | else | 838 | else |
| 835 | sh->cabac_init_flag = 0; | 839 | sh->cabac_init_flag = 0; |
| @@ -851,9 +855,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 15 unmodified lines | |||
| 851 | } | 855 | } |
| 852 | } | 856 | } |
| 853 | 857 | ||
| 854 | if ((s->ps.pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) || | 858 | if ((pps->weighted_pred_flag && sh->slice_type == HEVC_SLICE_P) || |
| 855 | (s->ps.pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) { | 859 | (pps->weighted_bipred_flag && sh->slice_type == HEVC_SLICE_B)) { |
| 856 | int ret = pred_weight_table(s, gb); | 860 | int ret = pred_weight_table(s, sps, gb); |
| 857 | if (ret < 0) | 861 | if (ret < 0) |
| 858 | return ret; | 862 | return ret; |
| 859 | } | 863 | } |
| @@ -867,17 +871,17 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 7 unmodified lines | |||
| 867 | } | 871 | } |
| 868 | 872 | ||
| 869 | // Syntax in 7.3.6.1 | 873 | // Syntax in 7.3.6.1 |
| 870 | if (s->ps.sps->motion_vector_resolution_control_idc == 2) | 874 | if (sps->motion_vector_resolution_control_idc == 2) |
| 871 | sh->use_integer_mv_flag = get_bits1(gb); | 875 | sh->use_integer_mv_flag = get_bits1(gb); |
| 872 | else | 876 | else |
| 873 | // Inferred to be equal to motion_vector_resolution_control_idc if not present | 877 | // Inferred to be equal to motion_vector_resolution_control_idc if not present |
| 874 | sh->use_integer_mv_flag = s->ps.sps->motion_vector_resolution_control_idc; | 878 | sh->use_integer_mv_flag = sps->motion_vector_resolution_control_idc; |
| 875 | 879 | ||
| 876 | } | 880 | } |
| 877 | 881 | ||
| 878 | sh->slice_qp_delta = get_se_golomb(gb); | 882 | sh->slice_qp_delta = get_se_golomb(gb); |
| 879 | 883 | ||
| 880 | if (s->ps.pps->pic_slice_level_chroma_qp_offsets_present_flag) { | 884 | if (pps->pic_slice_level_chroma_qp_offsets_present_flag) { |
| 881 | sh->slice_cb_qp_offset = get_se_golomb(gb); | 885 | sh->slice_cb_qp_offset = get_se_golomb(gb); |
| 882 | sh->slice_cr_qp_offset = get_se_golomb(gb); | 886 | sh->slice_cr_qp_offset = get_se_golomb(gb); |
| 883 | if (sh->slice_cb_qp_offset < -12 || sh->slice_cb_qp_offset > 12 || | 887 | if (sh->slice_cb_qp_offset < -12 || sh->slice_cb_qp_offset > 12 || |
| @@ -890,21 +894,21 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 6 unmodified lines | |||
| 890 | sh->slice_cr_qp_offset = 0; | 894 | sh->slice_cr_qp_offset = 0; |
| 891 | } | 895 | } |
| 892 | 896 | ||
| 893 | if (s->ps.pps->pps_slice_act_qp_offsets_present_flag) { | 897 | if (pps->pps_slice_act_qp_offsets_present_flag) { |
| 894 | sh->slice_act_y_qp_offset = get_se_golomb(gb); | 898 | sh->slice_act_y_qp_offset = get_se_golomb(gb); |
| 895 | sh->slice_act_cb_qp_offset = get_se_golomb(gb); | 899 | sh->slice_act_cb_qp_offset = get_se_golomb(gb); |
| 896 | sh->slice_act_cr_qp_offset = get_se_golomb(gb); | 900 | sh->slice_act_cr_qp_offset = get_se_golomb(gb); |
| 897 | } | 901 | } |
| 898 | 902 | ||
| 899 | if (s->ps.pps->chroma_qp_offset_list_enabled_flag) | 903 | if (pps->chroma_qp_offset_list_enabled_flag) |
| 900 | sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb); | 904 | sh->cu_chroma_qp_offset_enabled_flag = get_bits1(gb); |
| 901 | else | 905 | else |
| 902 | sh->cu_chroma_qp_offset_enabled_flag = 0; | 906 | sh->cu_chroma_qp_offset_enabled_flag = 0; |
| 903 | 907 | ||
| 904 | if (s->ps.pps->deblocking_filter_control_present_flag) { | 908 | if (pps->deblocking_filter_control_present_flag) { |
| 905 | int deblocking_filter_override_flag = 0; | 909 | int deblocking_filter_override_flag = 0; |
| 906 | 910 | ||
| 907 | if (s->ps.pps->deblocking_filter_override_enabled_flag) | 911 | if (pps->deblocking_filter_override_enabled_flag) |
| 908 | deblocking_filter_override_flag = get_bits1(gb); | 912 | deblocking_filter_override_flag = get_bits1(gb); |
| 909 | 913 | ||
| 910 | if (deblocking_filter_override_flag) { | 914 | if (deblocking_filter_override_flag) { |
| @@ -923,9 +927,9 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines | |||
| 923 | sh->tc_offset = tc_offset_div2 * 2; | 927 | sh->tc_offset = tc_offset_div2 * 2; |
| 924 | } | 928 | } |
| 925 | } else { | 929 | } else { |
| 926 | sh->disable_deblocking_filter_flag = s->ps.pps->disable_dbf; | 930 | sh->disable_deblocking_filter_flag = pps->disable_dbf; |
| 927 | sh->beta_offset = s->ps.pps->beta_offset; | 931 | sh->beta_offset = pps->beta_offset; |
| 928 | sh->tc_offset = s->ps.pps->tc_offset; | 932 | sh->tc_offset = pps->tc_offset; |
| 929 | } | 933 | } |
| 930 | } else { | 934 | } else { |
| 931 | sh->disable_deblocking_filter_flag = 0; | 935 | sh->disable_deblocking_filter_flag = 0; |
| @@ -933,13 +937,13 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line | |||
| 933 | sh->tc_offset = 0; | 937 | sh->tc_offset = 0; |
| 934 | } | 938 | } |
| 935 | 939 | ||
| 936 | if (s->ps.pps->seq_loop_filter_across_slices_enabled_flag && | 940 | if (pps->seq_loop_filter_across_slices_enabled_flag && |
| 937 | (sh->slice_sample_adaptive_offset_flag[0] || | 941 | (sh->slice_sample_adaptive_offset_flag[0] || |
| 938 | sh->slice_sample_adaptive_offset_flag[1] || | 942 | sh->slice_sample_adaptive_offset_flag[1] || |
| 939 | !sh->disable_deblocking_filter_flag)) { | 943 | !sh->disable_deblocking_filter_flag)) { |
| 940 | sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb); | 944 | sh->slice_loop_filter_across_slices_enabled_flag = get_bits1(gb); |
| 941 | } else { | 945 | } else { |
| 942 | sh->slice_loop_filter_across_slices_enabled_flag = s->ps.pps->seq_loop_filter_across_slices_enabled_flag; | 946 | sh->slice_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag; |
| 943 | } | 947 | } |
| 944 | } else if (!s->slice_initialized) { | 948 | } else if (!s->slice_initialized) { |
| 945 | av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n"); | 949 | av_log(s->avctx, AV_LOG_ERROR, "Independent slice segment missing.\n"); |
| @@ -947,7 +951,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 1 unmodified line | |||
| 947 | } | 951 | } |
| 948 | 952 | ||
| 949 | sh->num_entry_point_offsets = 0; | 953 | sh->num_entry_point_offsets = 0; |
| 950 | if (s->ps.pps->tiles_enabled_flag || s->ps.pps->entropy_coding_sync_enabled_flag) { | 954 | if (pps->tiles_enabled_flag || pps->entropy_coding_sync_enabled_flag) { |
| 951 | unsigned num_entry_point_offsets = get_ue_golomb_long(gb); | 955 | unsigned num_entry_point_offsets = get_ue_golomb_long(gb); |
| 952 | // It would be possible to bound this tighter but this here is simpler | 956 | // It would be possible to bound this tighter but this here is simpler |
| 953 | if (num_entry_point_offsets > get_bits_left(gb)) { | 957 | if (num_entry_point_offsets > get_bits_left(gb)) { |
| @@ -980,7 +984,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 26 unmodified lines | |||
| 980 | unsigned val = get_bits_long(gb, offset_len); | 984 | unsigned val = get_bits_long(gb, offset_len); |
| 981 | sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size | 985 | sh->entry_point_offset[i] = val + 1; // +1; // +1 to get the size |
| 982 | } | 986 | } |
| 983 | if (s->threads_number > 1 && (s->ps.pps->num_tile_rows > 1 || s->ps.pps->num_tile_columns > 1)) { | 987 | if (s->threads_number > 1 && (pps->num_tile_rows > 1 || pps->num_tile_columns > 1)) { |
| 984 | s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here | 988 | s->enable_parallel_tiles = 0; // TODO: you can enable tiles in parallel here |
| 985 | s->threads_number = 1; | 989 | s->threads_number = 1; |
| 986 | } else | 990 | } else |
| @@ -989,7 +993,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 2 unmodified lines | |||
| 989 | s->enable_parallel_tiles = 0; | 993 | s->enable_parallel_tiles = 0; |
| 990 | } | 994 | } |
| 991 | 995 | ||
| 992 | if (s->ps.pps->slice_header_extension_present_flag) { | 996 | if (pps->slice_header_extension_present_flag) { |
| 993 | unsigned int length = get_ue_golomb_long(gb); | 997 | unsigned int length = get_ue_golomb_long(gb); |
| 994 | if (length*8LL > get_bits_left(gb)) { | 998 | if (length*8LL > get_bits_left(gb)) { |
| 995 | av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n"); | 999 | av_log(s->avctx, AV_LOG_ERROR, "too many slice_header_extension_data_bytes\n"); |
| @@ -1007,14 +1011,14 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 11 unmodified lines | |||
| 1007 | sh->data_offset = align_get_bits(gb) - gb->buffer; | 1011 | sh->data_offset = align_get_bits(gb) - gb->buffer; |
| 1008 | 1012 | ||
| 1009 | // Inferred parameters | 1013 | // Inferred parameters |
| 1010 | sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta; | 1014 | sh->slice_qp = 26U + pps->pic_init_qp_minus26 + sh->slice_qp_delta; |
| 1011 | if (sh->slice_qp > 51 || | 1015 | if (sh->slice_qp > 51 || |
| 1012 | sh->slice_qp < -s->ps.sps->qp_bd_offset) { | 1016 | sh->slice_qp < -sps->qp_bd_offset) { |
| 1013 | av_log(s->avctx, AV_LOG_ERROR, | 1017 | av_log(s->avctx, AV_LOG_ERROR, |
| 1014 | "The slice_qp %d is outside the valid range " | 1018 | "The slice_qp %d is outside the valid range " |
| 1015 | "[%d, 51].\n", | 1019 | "[%d, 51].\n", |
| 1016 | sh->slice_qp, | 1020 | sh->slice_qp, |
| 1017 | -s->ps.sps->qp_bd_offset); | 1021 | -sps->qp_bd_offset); |
| 1018 | return AVERROR_INVALIDDATA; | 1022 | return AVERROR_INVALIDDATA; |
| 1019 | } | 1023 | } |
| 1020 | 1024 | ||
| @@ -1033,7 +1037,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines | |||
| 1033 | 1037 | ||
| 1034 | s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag; | 1038 | s->local_ctx[0].first_qp_group = !s->sh.dependent_slice_segment_flag; |
| 1035 | 1039 | ||
| 1036 | if (!s->ps.pps->cu_qp_delta_enabled_flag) | 1040 | if (!pps->cu_qp_delta_enabled_flag) |
| 1037 | s->local_ctx[0].qp_y = s->sh.slice_qp; | 1041 | s->local_ctx[0].qp_y = s->sh.slice_qp; |
| 1038 | 1042 | ||
| 1039 | s->slice_initialized = 1; | 1043 | s->slice_initialized = 1; |
| @@ -1043,7 +1047,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 3 unmodified lines | |||
| 1043 | return 0; | 1047 | return 0; |
| 1044 | } | 1048 | } |
| 1045 | 1049 | ||
| 1046 | #define CTB(tab, x, y) ((tab)[(y) * s->ps.sps->ctb_width + (x)]) | 1050 | #define CTB(tab, x, y) ((tab)[(y) * sps->ctb_width + (x)]) |
| 1047 | 1051 | ||
| 1048 | #define SET_SAO(elem, value) \ | 1052 | #define SET_SAO(elem, value) \ |
| 1049 | do { \ | 1053 | do { \ |
| @@ -1057,7 +1061,9 @@ do { \ · 7 unmodified lines | |||
| 1057 | sao->elem = 0; \ | 1061 | sao->elem = 0; \ |
| 1058 | } while (0) | 1062 | } while (0) |
| 1059 | 1063 | ||
| 1060 | static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry) | 1064 | static void hls_sao_param(HEVCLocalContext *lc, |
| 1065 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1066 | int rx, int ry) | ||
| 1061 | { | 1067 | { |
| 1062 | const HEVCContext *const s = lc->parent; | 1068 | const HEVCContext *const s = lc->parent; |
| 1063 | int sao_merge_left_flag = 0; | 1069 | int sao_merge_left_flag = 0; |
| @@ -1077,9 +1083,9 @@ static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry) · 13 unmodified lines | |||
| 1077 | } | 1083 | } |
| 1078 | } | 1084 | } |
| 1079 | 1085 | ||
| 1080 | for (c_idx = 0; c_idx < (s->ps.sps->chroma_format_idc ? 3 : 1); c_idx++) { | 1086 | for (c_idx = 0; c_idx < (sps->chroma_format_idc ? 3 : 1); c_idx++) { |
| 1081 | int log2_sao_offset_scale = c_idx == 0 ? s->ps.pps->log2_sao_offset_scale_luma : | 1087 | int log2_sao_offset_scale = c_idx == 0 ? pps->log2_sao_offset_scale_luma : |
| 1082 | s->ps.pps->log2_sao_offset_scale_chroma; | 1088 | pps->log2_sao_offset_scale_chroma; |
| 1083 | 1089 | ||
| 1084 | if (!s->sh.slice_sample_adaptive_offset_flag[c_idx]) { | 1090 | if (!s->sh.slice_sample_adaptive_offset_flag[c_idx]) { |
| 1085 | sao->type_idx[c_idx] = SAO_NOT_APPLIED; | 1091 | sao->type_idx[c_idx] = SAO_NOT_APPLIED; |
| @@ -1097,7 +1103,7 @@ static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry) · 11 unmodified lines | |||
| 1097 | continue; | 1103 | continue; |
| 1098 | 1104 | ||
| 1099 | for (i = 0; i < 4; i++) | 1105 | for (i = 0; i < 4; i++) |
| 1100 | SET_SAO(offset_abs[c_idx][i], ff_hevc_sao_offset_abs_decode(lc, s->ps.sps->bit_depth)); | 1106 | SET_SAO(offset_abs[c_idx][i], ff_hevc_sao_offset_abs_decode(lc, sps->bit_depth)); |
| 1101 | 1107 | ||
| 1102 | if (sao->type_idx[c_idx] == SAO_BAND) { | 1108 | if (sao->type_idx[c_idx] == SAO_BAND) { |
| 1103 | for (i = 0; i < 4; i++) { | 1109 | for (i = 0; i < 4; i++) { |
| @@ -1147,49 +1153,51 @@ static int hls_cross_component_pred(HEVCLocalContext *lc, int idx) · 43 unmodified lines | |||
| 1147 | return 0; | 1153 | return 0; |
| 1148 | } | 1154 | } |
| 1149 | 1155 | ||
| 1150 | static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, | 1156 | static int hls_transform_unit(HEVCLocalContext *lc, |
| 1157 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1158 | int x0, int y0, | ||
| 1151 | int xBase, int yBase, int cb_xBase, int cb_yBase, | 1159 | int xBase, int yBase, int cb_xBase, int cb_yBase, |
| 1152 | int log2_cb_size, int log2_trafo_size, | 1160 | int log2_cb_size, int log2_trafo_size, |
| 1153 | int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr) | 1161 | int blk_idx, int cbf_luma, int *cbf_cb, int *cbf_cr) |
| 1154 | { | 1162 | { |
| 1155 | const HEVCContext *const s = lc->parent; | 1163 | const HEVCContext *const s = lc->parent; |
| 1156 | const int log2_trafo_size_c = log2_trafo_size - s->ps.sps->hshift[1]; | 1164 | const int log2_trafo_size_c = log2_trafo_size - sps->hshift[1]; |
| 1157 | int i; | 1165 | int i; |
| 1158 | 1166 | ||
| 1159 | if (lc->cu.pred_mode == MODE_INTRA) { | 1167 | if (lc->cu.pred_mode == MODE_INTRA) { |
| 1160 | int trafo_size = 1 << log2_trafo_size; | 1168 | int trafo_size = 1 << log2_trafo_size; |
| 1161 | ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, s->ps.sps->log2_ctb_size); | 1169 | ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size, trafo_size, sps->log2_ctb_size); |
| 1162 | 1170 | ||
| 1163 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, x0, y0, 0); | 1171 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, x0, y0, 0); |
| 1164 | } | 1172 | } |
| 1165 | 1173 | ||
| 1166 | if (cbf_luma || cbf_cb[0] || cbf_cr[0] || | 1174 | if (cbf_luma || cbf_cb[0] || cbf_cr[0] || |
| 1167 | (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { | 1175 | (sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { |
| 1168 | int scan_idx = SCAN_DIAG; | 1176 | int scan_idx = SCAN_DIAG; |
| 1169 | int scan_idx_c = SCAN_DIAG; | 1177 | int scan_idx_c = SCAN_DIAG; |
| 1170 | int cbf_chroma = cbf_cb[0] || cbf_cr[0] || | 1178 | int cbf_chroma = cbf_cb[0] || cbf_cr[0] || |
| 1171 | (s->ps.sps->chroma_format_idc == 2 && | 1179 | (sps->chroma_format_idc == 2 && |
| 1172 | (cbf_cb[1] || cbf_cr[1])); | 1180 | (cbf_cb[1] || cbf_cr[1])); |
| 1173 | 1181 | ||
| 1174 | if (s->ps.pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) { | 1182 | if (pps->cu_qp_delta_enabled_flag && !lc->tu.is_cu_qp_delta_coded) { |
| 1175 | lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(lc); | 1183 | lc->tu.cu_qp_delta = ff_hevc_cu_qp_delta_abs(lc); |
| 1176 | if (lc->tu.cu_qp_delta != 0) | 1184 | if (lc->tu.cu_qp_delta != 0) |
| 1177 | if (ff_hevc_cu_qp_delta_sign_flag(lc) == 1) | 1185 | if (ff_hevc_cu_qp_delta_sign_flag(lc) == 1) |
| 1178 | lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta; | 1186 | lc->tu.cu_qp_delta = -lc->tu.cu_qp_delta; |
| 1179 | lc->tu.is_cu_qp_delta_coded = 1; | 1187 | lc->tu.is_cu_qp_delta_coded = 1; |
| 1180 | 1188 | ||
| 1181 | if (lc->tu.cu_qp_delta < -(26 + s->ps.sps->qp_bd_offset / 2) || | 1189 | if (lc->tu.cu_qp_delta < -(26 + sps->qp_bd_offset / 2) || |
| 1182 | lc->tu.cu_qp_delta > (25 + s->ps.sps->qp_bd_offset / 2)) { | 1190 | lc->tu.cu_qp_delta > (25 + sps->qp_bd_offset / 2)) { |
| 1183 | av_log(s->avctx, AV_LOG_ERROR, | 1191 | av_log(s->avctx, AV_LOG_ERROR, |
| 1184 | "The cu_qp_delta %d is outside the valid range " | 1192 | "The cu_qp_delta %d is outside the valid range " |
| 1185 | "[%d, %d].\n", | 1193 | "[%d, %d].\n", |
| 1186 | lc->tu.cu_qp_delta, | 1194 | lc->tu.cu_qp_delta, |
| 1187 | -(26 + s->ps.sps->qp_bd_offset / 2), | 1195 | -(26 + sps->qp_bd_offset / 2), |
| 1188 | (25 + s->ps.sps->qp_bd_offset / 2)); | 1196 | (25 + sps->qp_bd_offset / 2)); |
| 1189 | return AVERROR_INVALIDDATA; | 1197 | return AVERROR_INVALIDDATA; |
| 1190 | } | 1198 | } |
| 1191 | 1199 | ||
| 1192 | ff_hevc_set_qPy(lc, s->ps.pps, cb_xBase, cb_yBase, log2_cb_size); | 1200 | ff_hevc_set_qPy(lc, pps, cb_xBase, cb_yBase, log2_cb_size); |
| 1193 | } | 1201 | } |
| 1194 | 1202 | ||
| 1195 | if (s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma && | 1203 | if (s->sh.cu_chroma_qp_offset_enabled_flag && cbf_chroma && |
| @@ -1197,13 +1205,13 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 1 unmodified line | |||
| 1197 | int cu_chroma_qp_offset_flag = ff_hevc_cu_chroma_qp_offset_flag(lc); | 1205 | int cu_chroma_qp_offset_flag = ff_hevc_cu_chroma_qp_offset_flag(lc); |
| 1198 | if (cu_chroma_qp_offset_flag) { | 1206 | if (cu_chroma_qp_offset_flag) { |
| 1199 | int cu_chroma_qp_offset_idx = 0; | 1207 | int cu_chroma_qp_offset_idx = 0; |
| 1200 | if (s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) { | 1208 | if (pps->chroma_qp_offset_list_len_minus1 > 0) { |
| 1201 | cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(lc, s->ps.pps->chroma_qp_offset_list_len_minus1); | 1209 | cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(lc, pps->chroma_qp_offset_list_len_minus1); |
| 1202 | av_log(s->avctx, AV_LOG_ERROR, | 1210 | av_log(s->avctx, AV_LOG_ERROR, |
| 1203 | "cu_chroma_qp_offset_idx not yet tested.\n"); | 1211 | "cu_chroma_qp_offset_idx not yet tested.\n"); |
| 1204 | } | 1212 | } |
| 1205 | lc->tu.cu_qp_offset_cb = s->ps.pps->cb_qp_offset_list[cu_chroma_qp_offset_idx]; | 1213 | lc->tu.cu_qp_offset_cb = pps->cb_qp_offset_list[cu_chroma_qp_offset_idx]; |
| 1206 | lc->tu.cu_qp_offset_cr = s->ps.pps->cr_qp_offset_list[cu_chroma_qp_offset_idx]; | 1214 | lc->tu.cu_qp_offset_cr = pps->cr_qp_offset_list[cu_chroma_qp_offset_idx]; |
| 1207 | } else { | 1215 | } else { |
| 1208 | lc->tu.cu_qp_offset_cb = 0; | 1216 | lc->tu.cu_qp_offset_cb = 0; |
| 1209 | lc->tu.cu_qp_offset_cr = 0; | 1217 | lc->tu.cu_qp_offset_cr = 0; |
| @@ -1232,37 +1240,37 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 22 unmodified lines | |||
| 1232 | lc->tu.cross_pf = 0; | 1240 | lc->tu.cross_pf = 0; |
| 1233 | 1241 | ||
| 1234 | if (cbf_luma) | 1242 | if (cbf_luma) |
| 1235 | ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0, log2_trafo_size, scan_idx, 0); | 1243 | ff_hevc_hls_residual_coding(lc, pps, x0, y0, log2_trafo_size, scan_idx, 0); |
| 1236 | if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) { | 1244 | if (sps->chroma_format_idc && (log2_trafo_size > 2 || sps->chroma_format_idc == 3)) { |
| 1237 | int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); | 1245 | int trafo_size_h = 1 << (log2_trafo_size_c + sps->hshift[1]); |
| 1238 | int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); | 1246 | int trafo_size_v = 1 << (log2_trafo_size_c + sps->vshift[1]); |
| 1239 | lc->tu.cross_pf = (s->ps.pps->cross_component_prediction_enabled_flag && cbf_luma && | 1247 | lc->tu.cross_pf = (pps->cross_component_prediction_enabled_flag && cbf_luma && |
| 1240 | (lc->cu.pred_mode == MODE_INTER || | 1248 | (lc->cu.pred_mode == MODE_INTER || |
| 1241 | (lc->tu.chroma_mode_c == 4))); | 1249 | (lc->tu.chroma_mode_c == 4))); |
| 1242 | 1250 | ||
| 1243 | if (lc->tu.cross_pf) { | 1251 | if (lc->tu.cross_pf) { |
| 1244 | hls_cross_component_pred(lc, 0); | 1252 | hls_cross_component_pred(lc, 0); |
| 1245 | } | 1253 | } |
| 1246 | for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { | 1254 | for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) { |
| 1247 | if (lc->cu.pred_mode == MODE_INTRA) { | 1255 | if (lc->cu.pred_mode == MODE_INTRA) { |
| 1248 | ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), | 1256 | ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), |
| 1249 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1257 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1250 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), 1); | 1258 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (i << log2_trafo_size_c), 1); |
| 1251 | } | 1259 | } |
| 1252 | if (cbf_cb[i]) | 1260 | if (cbf_cb[i]) |
| 1253 | ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), | 1261 | ff_hevc_hls_residual_coding(lc, pps, x0, y0 + (i << log2_trafo_size_c), |
| 1254 | log2_trafo_size_c, scan_idx_c, 1); | 1262 | log2_trafo_size_c, scan_idx_c, 1); |
| 1255 | else | 1263 | else |
| 1256 | if (lc->tu.cross_pf) { | 1264 | if (lc->tu.cross_pf) { |
| 1257 | ptrdiff_t stride = s->cur_frame->f->linesize[1]; | 1265 | ptrdiff_t stride = s->cur_frame->f->linesize[1]; |
| 1258 | int hshift = s->ps.sps->hshift[1]; | 1266 | int hshift = sps->hshift[1]; |
| 1259 | int vshift = s->ps.sps->vshift[1]; | 1267 | int vshift = sps->vshift[1]; |
| 1260 | const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; | 1268 | const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; |
| 1261 | int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; | 1269 | int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; |
| 1262 | int size = 1 << log2_trafo_size_c; | 1270 | int size = 1 << log2_trafo_size_c; |
| 1263 | 1271 | ||
| 1264 | uint8_t *dst = &s->cur_frame->f->data[1][(y0 >> vshift) * stride + | 1272 | uint8_t *dst = &s->cur_frame->f->data[1][(y0 >> vshift) * stride + |
| 1265 | ((x0 >> hshift) << s->ps.sps->pixel_shift)]; | 1273 | ((x0 >> hshift) << sps->pixel_shift)]; |
| 1266 | for (i = 0; i < (size * size); i++) { | 1274 | for (i = 0; i < (size * size); i++) { |
| 1267 | coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); | 1275 | coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); |
| 1268 | } | 1276 | } |
| @@ -1273,82 +1281,82 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 4 unmodified lines | |||
| 1273 | if (lc->tu.cross_pf) { | 1281 | if (lc->tu.cross_pf) { |
| 1274 | hls_cross_component_pred(lc, 1); | 1282 | hls_cross_component_pred(lc, 1); |
| 1275 | } | 1283 | } |
| 1276 | for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { | 1284 | for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) { |
| 1277 | if (lc->cu.pred_mode == MODE_INTRA) { | 1285 | if (lc->cu.pred_mode == MODE_INTRA) { |
| 1278 | ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), | 1286 | ff_hevc_set_neighbour_available(lc, x0, y0 + (i << log2_trafo_size_c), |
| 1279 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1287 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1280 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), 2); | 1288 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (i << log2_trafo_size_c), 2); |
| 1281 | } | 1289 | } |
| 1282 | if (cbf_cr[i]) | 1290 | if (cbf_cr[i]) |
| 1283 | ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c), | 1291 | ff_hevc_hls_residual_coding(lc, pps, x0, y0 + (i << log2_trafo_size_c), |
| 1284 | log2_trafo_size_c, scan_idx_c, 2); | 1292 | log2_trafo_size_c, scan_idx_c, 2); |
| 1285 | else | 1293 | else |
| 1286 | if (lc->tu.cross_pf) { | 1294 | if (lc->tu.cross_pf) { |
| 1287 | ptrdiff_t stride = s->cur_frame->f->linesize[2]; | 1295 | ptrdiff_t stride = s->cur_frame->f->linesize[2]; |
| 1288 | int hshift = s->ps.sps->hshift[2]; | 1296 | int hshift = sps->hshift[2]; |
| 1289 | int vshift = s->ps.sps->vshift[2]; | 1297 | int vshift = sps->vshift[2]; |
| 1290 | const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; | 1298 | const int16_t *coeffs_y = (int16_t*)lc->edge_emu_buffer; |
| 1291 | int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; | 1299 | int16_t *coeffs = (int16_t*)lc->edge_emu_buffer2; |
| 1292 | int size = 1 << log2_trafo_size_c; | 1300 | int size = 1 << log2_trafo_size_c; |
| 1293 | 1301 | ||
| 1294 | uint8_t *dst = &s->cur_frame->f->data[2][(y0 >> vshift) * stride + | 1302 | uint8_t *dst = &s->cur_frame->f->data[2][(y0 >> vshift) * stride + |
| 1295 | ((x0 >> hshift) << s->ps.sps->pixel_shift)]; | 1303 | ((x0 >> hshift) << sps->pixel_shift)]; |
| 1296 | for (i = 0; i < (size * size); i++) { | 1304 | for (i = 0; i < (size * size); i++) { |
| 1297 | coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); | 1305 | coeffs[i] = ((lc->tu.res_scale_val * coeffs_y[i]) >> 3); |
| 1298 | } | 1306 | } |
| 1299 | s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs, stride); | 1307 | s->hevcdsp.add_residual[log2_trafo_size_c-2](dst, coeffs, stride); |
| 1300 | } | 1308 | } |
| 1301 | } | 1309 | } |
| 1302 | } else if (s->ps.sps->chroma_format_idc && blk_idx == 3) { | 1310 | } else if (sps->chroma_format_idc && blk_idx == 3) { |
| 1303 | int trafo_size_h = 1 << (log2_trafo_size + 1); | 1311 | int trafo_size_h = 1 << (log2_trafo_size + 1); |
| 1304 | int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); | 1312 | int trafo_size_v = 1 << (log2_trafo_size + sps->vshift[1]); |
| 1305 | for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { | 1313 | for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) { |
| 1306 | if (lc->cu.pred_mode == MODE_INTRA) { | 1314 | if (lc->cu.pred_mode == MODE_INTRA) { |
| 1307 | ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size), | 1315 | ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size), |
| 1308 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1316 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1309 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), 1); | 1317 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (i << log2_trafo_size), 1); |
| 1310 | } | 1318 | } |
| 1311 | if (cbf_cb[i]) | 1319 | if (cbf_cb[i]) |
| 1312 | ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), | 1320 | ff_hevc_hls_residual_coding(lc, pps, xBase, yBase + (i << log2_trafo_size), |
| 1313 | log2_trafo_size, scan_idx_c, 1); | 1321 | log2_trafo_size, scan_idx_c, 1); |
| 1314 | } | 1322 | } |
| 1315 | for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) { | 1323 | for (i = 0; i < (sps->chroma_format_idc == 2 ? 2 : 1); i++) { |
| 1316 | if (lc->cu.pred_mode == MODE_INTRA) { | 1324 | if (lc->cu.pred_mode == MODE_INTRA) { |
| 1317 | ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size), | 1325 | ff_hevc_set_neighbour_available(lc, xBase, yBase + (i << log2_trafo_size), |
| 1318 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1326 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1319 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), 2); | 1327 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (i << log2_trafo_size), 2); |
| 1320 | } | 1328 | } |
| 1321 | if (cbf_cr[i]) | 1329 | if (cbf_cr[i]) |
| 1322 | ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size), | 1330 | ff_hevc_hls_residual_coding(lc, pps, xBase, yBase + (i << log2_trafo_size), |
| 1323 | log2_trafo_size, scan_idx_c, 2); | 1331 | log2_trafo_size, scan_idx_c, 2); |
| 1324 | } | 1332 | } |
| 1325 | } | 1333 | } |
| 1326 | } else if (s->ps.sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) { | 1334 | } else if (sps->chroma_format_idc && lc->cu.pred_mode == MODE_INTRA) { |
| 1327 | if (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3) { | 1335 | if (log2_trafo_size > 2 || sps->chroma_format_idc == 3) { |
| 1328 | int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]); | 1336 | int trafo_size_h = 1 << (log2_trafo_size_c + sps->hshift[1]); |
| 1329 | int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]); | 1337 | int trafo_size_v = 1 << (log2_trafo_size_c + sps->vshift[1]); |
| 1330 | ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, trafo_size_v, | 1338 | ff_hevc_set_neighbour_available(lc, x0, y0, trafo_size_h, trafo_size_v, |
| 1331 | s->ps.sps->log2_ctb_size); | 1339 | sps->log2_ctb_size); |
| 1332 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0, 1); | 1340 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0, 1); |
| 1333 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0, 2); | 1341 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0, 2); |
| 1334 | if (s->ps.sps->chroma_format_idc == 2) { | 1342 | if (sps->chroma_format_idc == 2) { |
| 1335 | ff_hevc_set_neighbour_available(lc, x0, y0 + (1 << log2_trafo_size_c), | 1343 | ff_hevc_set_neighbour_available(lc, x0, y0 + (1 << log2_trafo_size_c), |
| 1336 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1344 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1337 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (1 << log2_trafo_size_c), 1); | 1345 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (1 << log2_trafo_size_c), 1); |
| 1338 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, s->ps.pps, x0, y0 + (1 << log2_trafo_size_c), 2); | 1346 | s->hpc.intra_pred[log2_trafo_size_c - 2](lc, pps, x0, y0 + (1 << log2_trafo_size_c), 2); |
| 1339 | } | 1347 | } |
| 1340 | } else if (blk_idx == 3) { | 1348 | } else if (blk_idx == 3) { |
| 1341 | int trafo_size_h = 1 << (log2_trafo_size + 1); | 1349 | int trafo_size_h = 1 << (log2_trafo_size + 1); |
| 1342 | int trafo_size_v = 1 << (log2_trafo_size + s->ps.sps->vshift[1]); | 1350 | int trafo_size_v = 1 << (log2_trafo_size + sps->vshift[1]); |
| 1343 | ff_hevc_set_neighbour_available(lc, xBase, yBase, | 1351 | ff_hevc_set_neighbour_available(lc, xBase, yBase, |
| 1344 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1352 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1345 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase, 1); | 1353 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase, 1); |
| 1346 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase, 2); | 1354 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase, 2); |
| 1347 | if (s->ps.sps->chroma_format_idc == 2) { | 1355 | if (sps->chroma_format_idc == 2) { |
| 1348 | ff_hevc_set_neighbour_available(lc, xBase, yBase + (1 << log2_trafo_size), | 1356 | ff_hevc_set_neighbour_available(lc, xBase, yBase + (1 << log2_trafo_size), |
| 1349 | trafo_size_h, trafo_size_v, s->ps.sps->log2_ctb_size); | 1357 | trafo_size_h, trafo_size_v, sps->log2_ctb_size); |
| 1350 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (1 << log2_trafo_size), 1); | 1358 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (1 << log2_trafo_size), 1); |
| 1351 | s->hpc.intra_pred[log2_trafo_size - 2](lc, s->ps.pps, xBase, yBase + (1 << log2_trafo_size), 2); | 1359 | s->hpc.intra_pred[log2_trafo_size - 2](lc, pps, xBase, yBase + (1 << log2_trafo_size), 2); |
| 1352 | } | 1360 | } |
| 1353 | } | 1361 | } |
| 1354 | } | 1362 | } |
| @@ -1356,14 +1364,15 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0, · 1 unmodified line | |||
| 1356 | return 0; | 1364 | return 0; |
| 1357 | } | 1365 | } |
| 1358 | 1366 | ||
| 1359 | static void set_deblocking_bypass(const HEVCContext *s, int x0, int y0, int log2_cb_size) | 1367 | static void set_deblocking_bypass(const HEVCContext *s, const HEVCSPS *sps, |
| 1368 | int x0, int y0, int log2_cb_size) | ||
| 1360 | { | 1369 | { |
| 1361 | int cb_size = 1 << log2_cb_size; | 1370 | int cb_size = 1 << log2_cb_size; |
| 1362 | int log2_min_pu_size = s->ps.sps->log2_min_pu_size; | 1371 | int log2_min_pu_size = sps->log2_min_pu_size; |
| 1363 | 1372 | ||
| 1364 | int min_pu_width = s->ps.sps->min_pu_width; | 1373 | int min_pu_width = sps->min_pu_width; |
| 1365 | int x_end = FFMIN(x0 + cb_size, s->ps.sps->width); | 1374 | int x_end = FFMIN(x0 + cb_size, sps->width); |
| 1366 | int y_end = FFMIN(y0 + cb_size, s->ps.sps->height); | 1375 | int y_end = FFMIN(y0 + cb_size, sps->height); |
| 1367 | int i, j; | 1376 | int i, j; |
| 1368 | 1377 | ||
| 1369 | for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++) | 1378 | for (j = (y0 >> log2_min_pu_size); j < (y_end >> log2_min_pu_size); j++) |
| @@ -1371,7 +1380,9 @@ static void set_deblocking_bypass(const HEVCContext *s, int x0, int y0, int log2 · 1 unmodified line | |||
| 1371 | s->is_pcm[i + j * min_pu_width] = 2; | 1380 | s->is_pcm[i + j * min_pu_width] = 2; |
| 1372 | } | 1381 | } |
| 1373 | 1382 | ||
| 1374 | static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, | 1383 | static int hls_transform_tree(HEVCLocalContext *lc, |
| 1384 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1385 | int x0, int y0, | ||
| 1375 | int xBase, int yBase, int cb_xBase, int cb_yBase, | 1386 | int xBase, int yBase, int cb_xBase, int cb_yBase, |
| 1376 | int log2_cb_size, int log2_trafo_size, | 1387 | int log2_cb_size, int log2_trafo_size, |
| 1377 | int trafo_depth, int blk_idx, | 1388 | int trafo_depth, int blk_idx, |
| @@ -1391,7 +1402,7 @@ static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, · 13 unmodified lines | |||
| 1391 | if (lc->cu.intra_split_flag) { | 1402 | if (lc->cu.intra_split_flag) { |
| 1392 | if (trafo_depth == 1) { | 1403 | if (trafo_depth == 1) { |
| 1393 | lc->tu.intra_pred_mode = lc->pu.intra_pred_mode[blk_idx]; | 1404 | lc->tu.intra_pred_mode = lc->pu.intra_pred_mode[blk_idx]; |
| 1394 | if (s->ps.sps->chroma_format_idc == 3) { | 1405 | if (sps->chroma_format_idc == 3) { |
| 1395 | lc->tu.intra_pred_mode_c = lc->pu.intra_pred_mode_c[blk_idx]; | 1406 | lc->tu.intra_pred_mode_c = lc->pu.intra_pred_mode_c[blk_idx]; |
| 1396 | lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[blk_idx]; | 1407 | lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[blk_idx]; |
| 1397 | } else { | 1408 | } else { |
| @@ -1405,33 +1416,33 @@ static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, · 7 unmodified lines | |||
| 1405 | lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[0]; | 1416 | lc->tu.chroma_mode_c = lc->pu.chroma_mode_c[0]; |
| 1406 | } | 1417 | } |
| 1407 | 1418 | ||
| 1408 | if (log2_trafo_size <= s->ps.sps->log2_max_trafo_size && | 1419 | if (log2_trafo_size <= sps->log2_max_trafo_size && |
| 1409 | log2_trafo_size > s->ps.sps->log2_min_tb_size && | 1420 | log2_trafo_size > sps->log2_min_tb_size && |
| 1410 | trafo_depth < lc->cu.max_trafo_depth && | 1421 | trafo_depth < lc->cu.max_trafo_depth && |
| 1411 | !(lc->cu.intra_split_flag && trafo_depth == 0)) { | 1422 | !(lc->cu.intra_split_flag && trafo_depth == 0)) { |
| 1412 | split_transform_flag = ff_hevc_split_transform_flag_decode(lc, log2_trafo_size); | 1423 | split_transform_flag = ff_hevc_split_transform_flag_decode(lc, log2_trafo_size); |
| 1413 | } else { | 1424 | } else { |
| 1414 | int inter_split = s->ps.sps->max_transform_hierarchy_depth_inter == 0 && | 1425 | int inter_split = sps->max_transform_hierarchy_depth_inter == 0 && |
| 1415 | lc->cu.pred_mode == MODE_INTER && | 1426 | lc->cu.pred_mode == MODE_INTER && |
| 1416 | lc->cu.part_mode != PART_2Nx2N && | 1427 | lc->cu.part_mode != PART_2Nx2N && |
| 1417 | trafo_depth == 0; | 1428 | trafo_depth == 0; |
| 1418 | 1429 | ||
| 1419 | split_transform_flag = log2_trafo_size > s->ps.sps->log2_max_trafo_size || | 1430 | split_transform_flag = log2_trafo_size > sps->log2_max_trafo_size || |
| 1420 | (lc->cu.intra_split_flag && trafo_depth == 0) || | 1431 | (lc->cu.intra_split_flag && trafo_depth == 0) || |
| 1421 | inter_split; | 1432 | inter_split; |
| 1422 | } | 1433 | } |
| 1423 | 1434 | ||
| 1424 | if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) { | 1435 | if (sps->chroma_format_idc && (log2_trafo_size > 2 || sps->chroma_format_idc == 3)) { |
| 1425 | if (trafo_depth == 0 || cbf_cb[0]) { | 1436 | if (trafo_depth == 0 || cbf_cb[0]) { |
| 1426 | cbf_cb[0] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); | 1437 | cbf_cb[0] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); |
| 1427 | if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { | 1438 | if (sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { |
| 1428 | cbf_cb[1] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); | 1439 | cbf_cb[1] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); |
| 1429 | } | 1440 | } |
| 1430 | } | 1441 | } |
| 1431 | 1442 | ||
| 1432 | if (trafo_depth == 0 || cbf_cr[0]) { | 1443 | if (trafo_depth == 0 || cbf_cr[0]) { |
| 1433 | cbf_cr[0] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); | 1444 | cbf_cr[0] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); |
| 1434 | if (s->ps.sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { | 1445 | if (sps->chroma_format_idc == 2 && (!split_transform_flag || log2_trafo_size == 3)) { |
| 1435 | cbf_cr[1] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); | 1446 | cbf_cr[1] = ff_hevc_cbf_cb_cr_decode(lc, trafo_depth); |
| 1436 | } | 1447 | } |
| 1437 | } | 1448 | } |
| @@ -1444,7 +1455,8 @@ static int hls_transform_tree(HEVCLocalContext *lc, int x0, int y0, · 6 unmodified lines | |||
| 1444 | 1455 | ||
| 1445 | #define SUBDIVIDE(x, y, idx) \ | 1456 | #define SUBDIVIDE(x, y, idx) \ |
| 1446 | do { \ | 1457 | do { \ |
| 1447 | ret = hls_transform_tree(lc, x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size,\ | 1458 | ret = hls_transform_tree(lc, pps, sps, \ |
| 1459 | x, y, x0, y0, cb_xBase, cb_yBase, log2_cb_size, \ | ||
| 1448 | log2_trafo_size - 1, trafo_depth + 1, idx, \ | 1460 | log2_trafo_size - 1, trafo_depth + 1, idx, \ |
| 1449 | cbf_cb, cbf_cr); \ | 1461 | cbf_cb, cbf_cr); \ |
| 1450 | if (ret < 0) \ | 1462 | if (ret < 0) \ |
| @@ -1458,18 +1470,19 @@ do { · 7 unmodified lines | |||
| 1458 | 1470 | ||
| 1459 | #undef SUBDIVIDE | 1471 | #undef SUBDIVIDE |
| 1460 | } else { | 1472 | } else { |
| 1461 | int min_tu_size = 1 << s->ps.sps->log2_min_tb_size; | 1473 | int min_tu_size = 1 << sps->log2_min_tb_size; |
| 1462 | int log2_min_tu_size = s->ps.sps->log2_min_tb_size; | 1474 | int log2_min_tu_size = sps->log2_min_tb_size; |
| 1463 | int min_tu_width = s->ps.sps->min_tb_width; | 1475 | int min_tu_width = sps->min_tb_width; |
| 1464 | int cbf_luma = 1; | 1476 | int cbf_luma = 1; |
| 1465 | 1477 | ||
| 1466 | if (lc->cu.pred_mode == MODE_INTRA || trafo_depth != 0 || | 1478 | if (lc->cu.pred_mode == MODE_INTRA || trafo_depth != 0 || |
| 1467 | cbf_cb[0] || cbf_cr[0] || | 1479 | cbf_cb[0] || cbf_cr[0] || |
| 1468 | (s->ps.sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { | 1480 | (sps->chroma_format_idc == 2 && (cbf_cb[1] || cbf_cr[1]))) { |
| 1469 | cbf_luma = ff_hevc_cbf_luma_decode(lc, trafo_depth); | 1481 | cbf_luma = ff_hevc_cbf_luma_decode(lc, trafo_depth); |
| 1470 | } | 1482 | } |
| 1471 | 1483 | ||
| 1472 | ret = hls_transform_unit(lc, x0, y0, xBase, yBase, cb_xBase, cb_yBase, | 1484 | ret = hls_transform_unit(lc, pps, sps, |
| 1485 | x0, y0, xBase, yBase, cb_xBase, cb_yBase, | ||
| 1473 | log2_cb_size, log2_trafo_size, | 1486 | log2_cb_size, log2_trafo_size, |
| 1474 | blk_idx, cbf_luma, cbf_cb, cbf_cr); | 1487 | blk_idx, cbf_luma, cbf_cb, cbf_cr); |
| 1475 | if (ret < 0) | 1488 | if (ret < 0) |
| @@ -1485,51 +1498,53 @@ do { · 9 unmodified lines | |||
| 1485 | } | 1498 | } |
| 1486 | } | 1499 | } |
| 1487 | if (!s->sh.disable_deblocking_filter_flag) { | 1500 | if (!s->sh.disable_deblocking_filter_flag) { |
| 1488 | ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_trafo_size); | 1501 | ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_trafo_size); |
| 1489 | if (s->ps.pps->transquant_bypass_enable_flag && | 1502 | if (pps->transquant_bypass_enable_flag && |
| 1490 | lc->cu.cu_transquant_bypass_flag) | 1503 | lc->cu.cu_transquant_bypass_flag) |
| 1491 | set_deblocking_bypass(s, x0, y0, log2_trafo_size); | 1504 | set_deblocking_bypass(s, sps, x0, y0, log2_trafo_size); |
| 1492 | } | 1505 | } |
| 1493 | } | 1506 | } |
| 1494 | return 0; | 1507 | return 0; |
| 1495 | } | 1508 | } |
| 1496 | 1509 | ||
| 1497 | static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size) | 1510 | static int hls_pcm_sample(HEVCLocalContext *lc, const HEVCPPS *pps, |
| 1511 | int x0, int y0, int log2_cb_size) | ||
| 1498 | { | 1512 | { |
| 1499 | const HEVCContext *const s = lc->parent; | 1513 | const HEVCContext *const s = lc->parent; |
| 1514 | const HEVCSPS *const sps = pps->sps; | ||
| 1500 | GetBitContext gb; | 1515 | GetBitContext gb; |
| 1501 | int cb_size = 1 << log2_cb_size; | 1516 | int cb_size = 1 << log2_cb_size; |
| 1502 | ptrdiff_t stride0 = s->cur_frame->f->linesize[0]; | 1517 | ptrdiff_t stride0 = s->cur_frame->f->linesize[0]; |
| 1503 | ptrdiff_t stride1 = s->cur_frame->f->linesize[1]; | 1518 | ptrdiff_t stride1 = s->cur_frame->f->linesize[1]; |
| 1504 | ptrdiff_t stride2 = s->cur_frame->f->linesize[2]; | 1519 | ptrdiff_t stride2 = s->cur_frame->f->linesize[2]; |
| 1505 | uint8_t *dst0 = &s->cur_frame->f->data[0][y0 * stride0 + (x0 << s->ps.sps->pixel_shift)]; | 1520 | uint8_t *dst0 = &s->cur_frame->f->data[0][y0 * stride0 + (x0 << sps->pixel_shift)]; |
| 1506 | uint8_t *dst1 = &s->cur_frame->f->data[1][(y0 >> s->ps.sps->vshift[1]) * stride1 + ((x0 >> s->ps.sps->hshift[1]) << s->ps.sps->pixel_shift)]; | 1521 | uint8_t *dst1 = &s->cur_frame->f->data[1][(y0 >> sps->vshift[1]) * stride1 + ((x0 >> sps->hshift[1]) << sps->pixel_shift)]; |
| 1507 | uint8_t *dst2 = &s->cur_frame->f->data[2][(y0 >> s->ps.sps->vshift[2]) * stride2 + ((x0 >> s->ps.sps->hshift[2]) << s->ps.sps->pixel_shift)]; | 1522 | uint8_t *dst2 = &s->cur_frame->f->data[2][(y0 >> sps->vshift[2]) * stride2 + ((x0 >> sps->hshift[2]) << sps->pixel_shift)]; |
| 1508 | 1523 | ||
| 1509 | int length = cb_size * cb_size * s->ps.sps->pcm.bit_depth + | 1524 | int length = cb_size * cb_size * sps->pcm.bit_depth + |
| 1510 | (((cb_size >> s->ps.sps->hshift[1]) * (cb_size >> s->ps.sps->vshift[1])) + | 1525 | (((cb_size >> sps->hshift[1]) * (cb_size >> sps->vshift[1])) + |
| 1511 | ((cb_size >> s->ps.sps->hshift[2]) * (cb_size >> s->ps.sps->vshift[2]))) * | 1526 | ((cb_size >> sps->hshift[2]) * (cb_size >> sps->vshift[2]))) * |
| 1512 | s->ps.sps->pcm.bit_depth_chroma; | 1527 | sps->pcm.bit_depth_chroma; |
| 1513 | const uint8_t *pcm = skip_bytes(&lc->cc, (length + 7) >> 3); | 1528 | const uint8_t *pcm = skip_bytes(&lc->cc, (length + 7) >> 3); |
| 1514 | int ret; | 1529 | int ret; |
| 1515 | 1530 | ||
| 1516 | if (!s->sh.disable_deblocking_filter_flag) | 1531 | if (!s->sh.disable_deblocking_filter_flag) |
| 1517 | ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size); | 1532 | ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_cb_size); |
| 1518 | 1533 | ||
| 1519 | ret = init_get_bits(&gb, pcm, length); | 1534 | ret = init_get_bits(&gb, pcm, length); |
| 1520 | if (ret < 0) | 1535 | if (ret < 0) |
| 1521 | return ret; | 1536 | return ret; |
| 1522 | 1537 | ||
| 1523 | s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, s->ps.sps->pcm.bit_depth); | 1538 | s->hevcdsp.put_pcm(dst0, stride0, cb_size, cb_size, &gb, sps->pcm.bit_depth); |
| 1524 | if (s->ps.sps->chroma_format_idc) { | 1539 | if (sps->chroma_format_idc) { |
| 1525 | s->hevcdsp.put_pcm(dst1, stride1, | 1540 | s->hevcdsp.put_pcm(dst1, stride1, |
| 1526 | cb_size >> s->ps.sps->hshift[1], | 1541 | cb_size >> sps->hshift[1], |
| 1527 | cb_size >> s->ps.sps->vshift[1], | 1542 | cb_size >> sps->vshift[1], |
| 1528 | &gb, s->ps.sps->pcm.bit_depth_chroma); | 1543 | &gb, sps->pcm.bit_depth_chroma); |
| 1529 | s->hevcdsp.put_pcm(dst2, stride2, | 1544 | s->hevcdsp.put_pcm(dst2, stride2, |
| 1530 | cb_size >> s->ps.sps->hshift[2], | 1545 | cb_size >> sps->hshift[2], |
| 1531 | cb_size >> s->ps.sps->vshift[2], | 1546 | cb_size >> sps->vshift[2], |
| 1532 | &gb, s->ps.sps->pcm.bit_depth_chroma); | 1547 | &gb, sps->pcm.bit_depth_chroma); |
| 1533 | } | 1548 | } |
| 1534 | 1549 | ||
| 1535 | return 0; | 1550 | return 0; |
| @@ -1551,32 +1566,34 @@ static int hls_pcm_sample(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size · 15 unmodified lines | |||
| 1551 | * @param luma_offset additive offset applied to the luma prediction value | 1566 | * @param luma_offset additive offset applied to the luma prediction value |
| 1552 | */ | 1567 | */ |
| 1553 | 1568 | ||
| 1554 | static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, | 1569 | static void luma_mc_uni(HEVCLocalContext *lc, |
| 1570 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1571 | uint8_t *dst, ptrdiff_t dststride, | ||
| 1555 | const AVFrame *ref, const Mv *mv, int x_off, int y_off, | 1572 | const AVFrame *ref, const Mv *mv, int x_off, int y_off, |
| 1556 | int block_w, int block_h, int luma_weight, int luma_offset) | 1573 | int block_w, int block_h, int luma_weight, int luma_offset) |
| 1557 | { | 1574 | { |
| 1558 | const HEVCContext *const s = lc->parent; | 1575 | const HEVCContext *const s = lc->parent; |
| 1559 | const uint8_t *src = ref->data[0]; | 1576 | const uint8_t *src = ref->data[0]; |
| 1560 | ptrdiff_t srcstride = ref->linesize[0]; | 1577 | ptrdiff_t srcstride = ref->linesize[0]; |
| 1561 | int pic_width = s->ps.sps->width; | 1578 | int pic_width = sps->width; |
| 1562 | int pic_height = s->ps.sps->height; | 1579 | int pic_height = sps->height; |
| 1563 | int mx = mv->x & 3; | 1580 | int mx = mv->x & 3; |
| 1564 | int my = mv->y & 3; | 1581 | int my = mv->y & 3; |
| 1565 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) || | 1582 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) || |
| 1566 | (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag); | 1583 | (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag); |
| 1567 | int idx = hevc_pel_weight[block_w]; | 1584 | int idx = hevc_pel_weight[block_w]; |
| 1568 | 1585 | ||
| 1569 | x_off += mv->x >> 2; | 1586 | x_off += mv->x >> 2; |
| 1570 | y_off += mv->y >> 2; | 1587 | y_off += mv->y >> 2; |
| 1571 | src += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift)); | 1588 | src += y_off * srcstride + (x_off * (1 << sps->pixel_shift)); |
| 1572 | 1589 | ||
| 1573 | if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER || | 1590 | if (x_off < QPEL_EXTRA_BEFORE || y_off < QPEL_EXTRA_AFTER || |
| 1574 | x_off >= pic_width - block_w - QPEL_EXTRA_AFTER || | 1591 | x_off >= pic_width - block_w - QPEL_EXTRA_AFTER || |
| 1575 | y_off >= pic_height - block_h - QPEL_EXTRA_AFTER || | 1592 | y_off >= pic_height - block_h - QPEL_EXTRA_AFTER || |
| 1576 | ref == s->cur_frame->f) { | 1593 | ref == s->cur_frame->f) { |
| 1577 | const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; | 1594 | const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift; |
| 1578 | int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); | 1595 | int offset = QPEL_EXTRA_BEFORE * srcstride + (QPEL_EXTRA_BEFORE << sps->pixel_shift); |
| 1579 | int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); | 1596 | int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift); |
| 1580 | 1597 | ||
| 1581 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset, | 1598 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src - offset, |
| 1582 | edge_emu_stride, srcstride, | 1599 | edge_emu_stride, srcstride, |
| @@ -1613,7 +1630,9 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 30 unmodified lines | |||
| 1613 | * @param mv1 motion vector1 (relative to block position) to get pixel data from | 1630 | * @param mv1 motion vector1 (relative to block position) to get pixel data from |
| 1614 | * @param current_mv current motion vector structure | 1631 | * @param current_mv current motion vector structure |
| 1615 | */ | 1632 | */ |
| 1616 | static void luma_mc_bi(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, | 1633 | static void luma_mc_bi(HEVCLocalContext *lc, |
| 1634 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1635 | uint8_t *dst, ptrdiff_t dststride, | ||
| 1617 | const AVFrame *ref0, const Mv *mv0, int x_off, int y_off, | 1636 | const AVFrame *ref0, const Mv *mv0, int x_off, int y_off, |
| 1618 | int block_w, int block_h, const AVFrame *ref1, | 1637 | int block_w, int block_h, const AVFrame *ref1, |
| 1619 | const Mv *mv1, struct MvField *current_mv) | 1638 | const Mv *mv1, struct MvField *current_mv) |
| @@ -1621,29 +1640,29 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 1 unmodified line | |||
| 1621 | const HEVCContext *const s = lc->parent; | 1640 | const HEVCContext *const s = lc->parent; |
| 1622 | ptrdiff_t src0stride = ref0->linesize[0]; | 1641 | ptrdiff_t src0stride = ref0->linesize[0]; |
| 1623 | ptrdiff_t src1stride = ref1->linesize[0]; | 1642 | ptrdiff_t src1stride = ref1->linesize[0]; |
| 1624 | int pic_width = s->ps.sps->width; | 1643 | int pic_width = sps->width; |
| 1625 | int pic_height = s->ps.sps->height; | 1644 | int pic_height = sps->height; |
| 1626 | int mx0 = mv0->x & 3; | 1645 | int mx0 = mv0->x & 3; |
| 1627 | int my0 = mv0->y & 3; | 1646 | int my0 = mv0->y & 3; |
| 1628 | int mx1 = mv1->x & 3; | 1647 | int mx1 = mv1->x & 3; |
| 1629 | int my1 = mv1->y & 3; | 1648 | int my1 = mv1->y & 3; |
| 1630 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) || | 1649 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) || |
| 1631 | (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag); | 1650 | (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag); |
| 1632 | int x_off0 = x_off + (mv0->x >> 2); | 1651 | int x_off0 = x_off + (mv0->x >> 2); |
| 1633 | int y_off0 = y_off + (mv0->y >> 2); | 1652 | int y_off0 = y_off + (mv0->y >> 2); |
| 1634 | int x_off1 = x_off + (mv1->x >> 2); | 1653 | int x_off1 = x_off + (mv1->x >> 2); |
| 1635 | int y_off1 = y_off + (mv1->y >> 2); | 1654 | int y_off1 = y_off + (mv1->y >> 2); |
| 1636 | int idx = hevc_pel_weight[block_w]; | 1655 | int idx = hevc_pel_weight[block_w]; |
| 1637 | 1656 | ||
| 1638 | const uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift); | 1657 | const uint8_t *src0 = ref0->data[0] + y_off0 * src0stride + (int)((unsigned)x_off0 << sps->pixel_shift); |
| 1639 | const uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift); | 1658 | const uint8_t *src1 = ref1->data[0] + y_off1 * src1stride + (int)((unsigned)x_off1 << sps->pixel_shift); |
| 1640 | 1659 | ||
| 1641 | if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER || | 1660 | if (x_off0 < QPEL_EXTRA_BEFORE || y_off0 < QPEL_EXTRA_AFTER || |
| 1642 | x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER || | 1661 | x_off0 >= pic_width - block_w - QPEL_EXTRA_AFTER || |
| 1643 | y_off0 >= pic_height - block_h - QPEL_EXTRA_AFTER) { | 1662 | y_off0 >= pic_height - block_h - QPEL_EXTRA_AFTER) { |
| 1644 | const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; | 1663 | const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift; |
| 1645 | int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); | 1664 | int offset = QPEL_EXTRA_BEFORE * src0stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift); |
| 1646 | int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); | 1665 | int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift); |
| 1647 | 1666 | ||
| 1648 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset, | 1667 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset, |
| 1649 | edge_emu_stride, src0stride, | 1668 | edge_emu_stride, src0stride, |
| @@ -1658,9 +1677,9 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 8 unmodified lines | |||
| 1658 | if (x_off1 < QPEL_EXTRA_BEFORE || y_off1 < QPEL_EXTRA_AFTER || | 1677 | if (x_off1 < QPEL_EXTRA_BEFORE || y_off1 < QPEL_EXTRA_AFTER || |
| 1659 | x_off1 >= pic_width - block_w - QPEL_EXTRA_AFTER || | 1678 | x_off1 >= pic_width - block_w - QPEL_EXTRA_AFTER || |
| 1660 | y_off1 >= pic_height - block_h - QPEL_EXTRA_AFTER) { | 1679 | y_off1 >= pic_height - block_h - QPEL_EXTRA_AFTER) { |
| 1661 | const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; | 1680 | const ptrdiff_t edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift; |
| 1662 | int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); | 1681 | int offset = QPEL_EXTRA_BEFORE * src1stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift); |
| 1663 | int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << s->ps.sps->pixel_shift); | 1682 | int buf_offset = QPEL_EXTRA_BEFORE * edge_emu_stride + (QPEL_EXTRA_BEFORE << sps->pixel_shift); |
| 1664 | 1683 | ||
| 1665 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src1 - offset, | 1684 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src1 - offset, |
| 1666 | edge_emu_stride, src1stride, | 1685 | edge_emu_stride, src1stride, |
| @@ -1705,20 +1724,22 @@ static void luma_mc_uni(HEVCLocalContext *lc, uint8_t *dst, ptrdiff_t dststride, · 38 unmodified lines | |||
| 1705 | * @param chroma_offset additive offset applied to the chroma prediction value | 1724 | * @param chroma_offset additive offset applied to the chroma prediction value |
| 1706 | */ | 1725 | */ |
| 1707 | 1726 | ||
| 1708 | static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0, | 1727 | static void chroma_mc_uni(HEVCLocalContext *lc, |
| 1728 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1729 | uint8_t *dst0, | ||
| 1709 | ptrdiff_t dststride, const uint8_t *src0, ptrdiff_t srcstride, int reflist, | 1730 | ptrdiff_t dststride, const uint8_t *src0, ptrdiff_t srcstride, int reflist, |
| 1710 | int x_off, int y_off, int block_w, int block_h, | 1731 | int x_off, int y_off, int block_w, int block_h, |
| 1711 | const struct MvField *current_mv, int chroma_weight, int chroma_offset) | 1732 | const struct MvField *current_mv, int chroma_weight, int chroma_offset) |
| 1712 | { | 1733 | { |
| 1713 | const HEVCContext *const s = lc->parent; | 1734 | const HEVCContext *const s = lc->parent; |
| 1714 | int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; | 1735 | int pic_width = sps->width >> sps->hshift[1]; |
| 1715 | int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; | 1736 | int pic_height = sps->height >> sps->vshift[1]; |
| 1716 | const Mv *mv = ¤t_mv->mv[reflist]; | 1737 | const Mv *mv = ¤t_mv->mv[reflist]; |
| 1717 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) || | 1738 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) || |
| 1718 | (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag); | 1739 | (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag); |
| 1719 | int idx = hevc_pel_weight[block_w]; | 1740 | int idx = hevc_pel_weight[block_w]; |
| 1720 | int hshift = s->ps.sps->hshift[1]; | 1741 | int hshift = sps->hshift[1]; |
| 1721 | int vshift = s->ps.sps->vshift[1]; | 1742 | int vshift = sps->vshift[1]; |
| 1722 | intptr_t mx = av_mod_uintp2(mv->x, 2 + hshift); | 1743 | intptr_t mx = av_mod_uintp2(mv->x, 2 + hshift); |
| 1723 | intptr_t my = av_mod_uintp2(mv->y, 2 + vshift); | 1744 | intptr_t my = av_mod_uintp2(mv->y, 2 + vshift); |
| 1724 | intptr_t _mx = mx << (1 - hshift); | 1745 | intptr_t _mx = mx << (1 - hshift); |
| @@ -1727,16 +1748,16 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0, · 2 unmodified lines | |||
| 1727 | 1748 | ||
| 1728 | x_off += mv->x >> (2 + hshift); | 1749 | x_off += mv->x >> (2 + hshift); |
| 1729 | y_off += mv->y >> (2 + vshift); | 1750 | y_off += mv->y >> (2 + vshift); |
| 1730 | src0 += y_off * srcstride + (x_off * (1 << s->ps.sps->pixel_shift)); | 1751 | src0 += y_off * srcstride + (x_off * (1 << sps->pixel_shift)); |
| 1731 | 1752 | ||
| 1732 | if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER || | 1753 | if (x_off < EPEL_EXTRA_BEFORE || y_off < EPEL_EXTRA_AFTER || |
| 1733 | x_off >= pic_width - block_w - EPEL_EXTRA_AFTER || | 1754 | x_off >= pic_width - block_w - EPEL_EXTRA_AFTER || |
| 1734 | y_off >= pic_height - block_h - EPEL_EXTRA_AFTER || | 1755 | y_off >= pic_height - block_h - EPEL_EXTRA_AFTER || |
| 1735 | emu) { | 1756 | emu) { |
| 1736 | const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; | 1757 | const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift; |
| 1737 | int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << s->ps.sps->pixel_shift)); | 1758 | int offset0 = EPEL_EXTRA_BEFORE * (srcstride + (1 << sps->pixel_shift)); |
| 1738 | int buf_offset0 = EPEL_EXTRA_BEFORE * | 1759 | int buf_offset0 = EPEL_EXTRA_BEFORE * |
| 1739 | (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); | 1760 | (edge_emu_stride + (1 << sps->pixel_shift)); |
| 1740 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset0, | 1761 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src0 - offset0, |
| 1741 | edge_emu_stride, srcstride, | 1762 | edge_emu_stride, srcstride, |
| 1742 | block_w + EPEL_EXTRA, block_h + EPEL_EXTRA, | 1763 | block_w + EPEL_EXTRA, block_h + EPEL_EXTRA, |
| @@ -1773,7 +1794,9 @@ static void chroma_mc_uni(HEVCLocalContext *lc, uint8_t *dst0, · 30 unmodified lines | |||
| 1773 | * @param current_mv current motion vector structure | 1794 | * @param current_mv current motion vector structure |
| 1774 | * @param cidx chroma component(cb, cr) | 1795 | * @param cidx chroma component(cb, cr) |
| 1775 | */ | 1796 | */ |
| 1776 | static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststride, | 1797 | static void chroma_mc_bi(HEVCLocalContext *lc, |
| 1798 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1799 | uint8_t *dst0, ptrdiff_t dststride, | ||
| 1777 | const AVFrame *ref0, const AVFrame *ref1, | 1800 | const AVFrame *ref0, const AVFrame *ref1, |
| 1778 | int x_off, int y_off, int block_w, int block_h, const MvField *current_mv, int cidx) | 1801 | int x_off, int y_off, int block_w, int block_h, const MvField *current_mv, int cidx) |
| 1779 | { | 1802 | { |
| @@ -1782,14 +1805,14 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid · 2 unmodified lines | |||
| 1782 | const uint8_t *src2 = ref1->data[cidx+1]; | 1805 | const uint8_t *src2 = ref1->data[cidx+1]; |
| 1783 | ptrdiff_t src1stride = ref0->linesize[cidx+1]; | 1806 | ptrdiff_t src1stride = ref0->linesize[cidx+1]; |
| 1784 | ptrdiff_t src2stride = ref1->linesize[cidx+1]; | 1807 | ptrdiff_t src2stride = ref1->linesize[cidx+1]; |
| 1785 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && s->ps.pps->weighted_pred_flag) || | 1808 | int weight_flag = (s->sh.slice_type == HEVC_SLICE_P && pps->weighted_pred_flag) || |
| 1786 | (s->sh.slice_type == HEVC_SLICE_B && s->ps.pps->weighted_bipred_flag); | 1809 | (s->sh.slice_type == HEVC_SLICE_B && pps->weighted_bipred_flag); |
| 1787 | int pic_width = s->ps.sps->width >> s->ps.sps->hshift[1]; | 1810 | int pic_width = sps->width >> sps->hshift[1]; |
| 1788 | int pic_height = s->ps.sps->height >> s->ps.sps->vshift[1]; | 1811 | int pic_height = sps->height >> sps->vshift[1]; |
| 1789 | const Mv *const mv0 = ¤t_mv->mv[0]; | 1812 | const Mv *const mv0 = ¤t_mv->mv[0]; |
| 1790 | const Mv *const mv1 = ¤t_mv->mv[1]; | 1813 | const Mv *const mv1 = ¤t_mv->mv[1]; |
| 1791 | int hshift = s->ps.sps->hshift[1]; | 1814 | int hshift = sps->hshift[1]; |
| 1792 | int vshift = s->ps.sps->vshift[1]; | 1815 | int vshift = sps->vshift[1]; |
| 1793 | 1816 | ||
| 1794 | intptr_t mx0 = av_mod_uintp2(mv0->x, 2 + hshift); | 1817 | intptr_t mx0 = av_mod_uintp2(mv0->x, 2 + hshift); |
| 1795 | intptr_t my0 = av_mod_uintp2(mv0->y, 2 + vshift); | 1818 | intptr_t my0 = av_mod_uintp2(mv0->y, 2 + vshift); |
| @@ -1805,16 +1828,16 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid · 9 unmodified lines | |||
| 1805 | int x_off1 = x_off + (mv1->x >> (2 + hshift)); | 1828 | int x_off1 = x_off + (mv1->x >> (2 + hshift)); |
| 1806 | int y_off1 = y_off + (mv1->y >> (2 + vshift)); | 1829 | int y_off1 = y_off + (mv1->y >> (2 + vshift)); |
| 1807 | int idx = hevc_pel_weight[block_w]; | 1830 | int idx = hevc_pel_weight[block_w]; |
| 1808 | src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << s->ps.sps->pixel_shift); | 1831 | src1 += y_off0 * src1stride + (int)((unsigned)x_off0 << sps->pixel_shift); |
| 1809 | src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << s->ps.sps->pixel_shift); | 1832 | src2 += y_off1 * src2stride + (int)((unsigned)x_off1 << sps->pixel_shift); |
| 1810 | 1833 | ||
| 1811 | if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER || | 1834 | if (x_off0 < EPEL_EXTRA_BEFORE || y_off0 < EPEL_EXTRA_AFTER || |
| 1812 | x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER || | 1835 | x_off0 >= pic_width - block_w - EPEL_EXTRA_AFTER || |
| 1813 | y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) { | 1836 | y_off0 >= pic_height - block_h - EPEL_EXTRA_AFTER) { |
| 1814 | const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; | 1837 | const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift; |
| 1815 | int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << s->ps.sps->pixel_shift)); | 1838 | int offset1 = EPEL_EXTRA_BEFORE * (src1stride + (1 << sps->pixel_shift)); |
| 1816 | int buf_offset1 = EPEL_EXTRA_BEFORE * | 1839 | int buf_offset1 = EPEL_EXTRA_BEFORE * |
| 1817 | (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); | 1840 | (edge_emu_stride + (1 << sps->pixel_shift)); |
| 1818 | 1841 | ||
| 1819 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1, | 1842 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer, src1 - offset1, |
| 1820 | edge_emu_stride, src1stride, | 1843 | edge_emu_stride, src1stride, |
| @@ -1830,10 +1853,10 @@ static void chroma_mc_bi(HEVCLocalContext *lc, uint8_t *dst0, ptrdiff_t dststrid · 9 unmodified lines | |||
| 1830 | if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER || | 1853 | if (x_off1 < EPEL_EXTRA_BEFORE || y_off1 < EPEL_EXTRA_AFTER || |
| 1831 | x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER || | 1854 | x_off1 >= pic_width - block_w - EPEL_EXTRA_AFTER || |
| 1832 | y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) { | 1855 | y_off1 >= pic_height - block_h - EPEL_EXTRA_AFTER) { |
| 1833 | const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << s->ps.sps->pixel_shift; | 1856 | const int edge_emu_stride = EDGE_EMU_BUFFER_STRIDE << sps->pixel_shift; |
| 1834 | int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << s->ps.sps->pixel_shift)); | 1857 | int offset1 = EPEL_EXTRA_BEFORE * (src2stride + (1 << sps->pixel_shift)); |
| 1835 | int buf_offset1 = EPEL_EXTRA_BEFORE * | 1858 | int buf_offset1 = EPEL_EXTRA_BEFORE * |
| 1836 | (edge_emu_stride + (1 << s->ps.sps->pixel_shift)); | 1859 | (edge_emu_stride + (1 << sps->pixel_shift)); |
| 1837 | 1860 | ||
| 1838 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1, | 1861 | s->vdsp.emulated_edge_mc(lc->edge_emu_buffer2, src2 - offset1, |
| 1839 | edge_emu_stride, src2stride, | 1862 | edge_emu_stride, src2stride, |
| @@ -1874,7 +1897,9 @@ static void hevc_await_progress(const HEVCContext *s, const HEVCFrame *ref, · 34 unmodified lines | |||
| 1874 | } | 1897 | } |
| 1875 | } | 1898 | } |
| 1876 | 1899 | ||
| 1877 | static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW, | 1900 | static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, |
| 1901 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 1902 | int x0, int y0, int nPbW, | ||
| 1878 | int nPbH, int log2_cb_size, int part_idx, | 1903 | int nPbH, int log2_cb_size, int part_idx, |
| 1879 | int merge_idx, MvField *mv) | 1904 | int merge_idx, MvField *mv) |
| 1880 | { | 1905 | { |
| @@ -1882,7 +1907,7 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW · 1 unmodified line | |||
| 1882 | enum InterPredIdc inter_pred_idc = PRED_L0; | 1907 | enum InterPredIdc inter_pred_idc = PRED_L0; |
| 1883 | int mvp_flag; | 1908 | int mvp_flag; |
| 1884 | 1909 | ||
| 1885 | ff_hevc_set_neighbour_available(lc, x0, y0, nPbW, nPbH, s->ps.sps->log2_ctb_size); | 1910 | ff_hevc_set_neighbour_available(lc, x0, y0, nPbW, nPbH, sps->log2_ctb_size); |
| 1886 | mv->pred_flag = 0; | 1911 | mv->pred_flag = 0; |
| 1887 | if (s->sh.slice_type == HEVC_SLICE_B) | 1912 | if (s->sh.slice_type == HEVC_SLICE_B) |
| 1888 | inter_pred_idc = ff_hevc_inter_pred_idc_decode(lc, nPbW, nPbH); | 1913 | inter_pred_idc = ff_hevc_inter_pred_idc_decode(lc, nPbW, nPbH); |
| @@ -1894,7 +1919,7 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW · 5 unmodified lines | |||
| 1894 | mv->pred_flag = PF_L0; | 1919 | mv->pred_flag = PF_L0; |
| 1895 | ff_hevc_hls_mvd_coding(lc, x0, y0, 0); | 1920 | ff_hevc_hls_mvd_coding(lc, x0, y0, 0); |
| 1896 | mvp_flag = ff_hevc_mvp_lx_flag_decode(lc); | 1921 | mvp_flag = ff_hevc_mvp_lx_flag_decode(lc); |
| 1897 | ff_hevc_luma_mv_mvp_mode(lc, s->ps.pps, x0, y0, nPbW, nPbH, log2_cb_size, | 1922 | ff_hevc_luma_mv_mvp_mode(lc, pps, x0, y0, nPbW, nPbH, log2_cb_size, |
| 1898 | part_idx, merge_idx, mv, mvp_flag, 0); | 1923 | part_idx, merge_idx, mv, mvp_flag, 0); |
| 1899 | mv->mv[0].x += lc->pu.mvd.x; | 1924 | mv->mv[0].x += lc->pu.mvd.x; |
| 1900 | mv->mv[0].y += lc->pu.mvd.y; | 1925 | mv->mv[0].y += lc->pu.mvd.y; |
| @@ -1912,25 +1937,26 @@ static void hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, int x0, int y0, int nPbW · 11 unmodified lines | |||
| 1912 | 1937 | ||
| 1913 | mv->pred_flag += PF_L1; | 1938 | mv->pred_flag += PF_L1; |
| 1914 | mvp_flag = ff_hevc_mvp_lx_flag_decode(lc); | 1939 | mvp_flag = ff_hevc_mvp_lx_flag_decode(lc); |
| 1915 | ff_hevc_luma_mv_mvp_mode(lc, s->ps.pps, x0, y0, nPbW, nPbH, log2_cb_size, | 1940 | ff_hevc_luma_mv_mvp_mode(lc, pps, x0, y0, nPbW, nPbH, log2_cb_size, |
| 1916 | part_idx, merge_idx, mv, mvp_flag, 1); | 1941 | part_idx, merge_idx, mv, mvp_flag, 1); |
| 1917 | mv->mv[1].x += lc->pu.mvd.x; | 1942 | mv->mv[1].x += lc->pu.mvd.x; |
| 1918 | mv->mv[1].y += lc->pu.mvd.y; | 1943 | mv->mv[1].y += lc->pu.mvd.y; |
| 1919 | } | 1944 | } |
| 1920 | } | 1945 | } |
| 1921 | 1946 | ||
| 1922 | static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, | 1947 | static void hls_prediction_unit(HEVCLocalContext *lc, |
| 1923 | int nPbW, int nPbH, | 1948 | const HEVCPPS *pps, const HEVCSPS *sps, |
| 1949 | int x0, int y0, int nPbW, int nPbH, | ||
| 1924 | int log2_cb_size, int partIdx, int idx) | 1950 | int log2_cb_size, int partIdx, int idx) |
| 1925 | { | 1951 | { |
| 1926 | #define POS(c_idx, x, y) \ | 1952 | #define POS(c_idx, x, y) \ |
| 1927 | &s->cur_frame->f->data[c_idx][((y) >> s->ps.sps->vshift[c_idx]) * linesize[c_idx] + \ | 1953 | &s->cur_frame->f->data[c_idx][((y) >> sps->vshift[c_idx]) * linesize[c_idx] + \ |
| 1928 | (((x) >> s->ps.sps->hshift[c_idx]) << s->ps.sps->pixel_shift)] | 1954 | (((x) >> sps->hshift[c_idx]) << sps->pixel_shift)] |
| 1929 | const HEVCContext *const s = lc->parent; | 1955 | const HEVCContext *const s = lc->parent; |
| 1930 | int merge_idx = 0; | 1956 | int merge_idx = 0; |
| 1931 | struct MvField current_mv = {{{ 0 }}}; | 1957 | struct MvField current_mv = {{{ 0 }}}; |
| 1932 | 1958 | ||
| 1933 | int min_pu_width = s->ps.sps->min_pu_width; | 1959 | int min_pu_width = sps->min_pu_width; |
| 1934 | 1960 | ||
| 1935 | MvField *tab_mvf = s->cur_frame->tab_mvf; | 1961 | MvField *tab_mvf = s->cur_frame->tab_mvf; |
| 1936 | const RefPicList *refPicList = s->cur_frame->refPicList; | 1962 | const RefPicList *refPicList = s->cur_frame->refPicList; |
| @@ -1939,8 +1965,8 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 2 unmodified lines | |||
| 1939 | uint8_t *dst0 = POS(0, x0, y0); | 1965 | uint8_t *dst0 = POS(0, x0, y0); |
| 1940 | uint8_t *dst1 = POS(1, x0, y0); | 1966 | uint8_t *dst1 = POS(1, x0, y0); |
| 1941 | uint8_t *dst2 = POS(2, x0, y0); | 1967 | uint8_t *dst2 = POS(2, x0, y0); |
| 1942 | int log2_min_cb_size = s->ps.sps->log2_min_cb_size; | 1968 | int log2_min_cb_size = sps->log2_min_cb_size; |
| 1943 | int min_cb_width = s->ps.sps->min_cb_width; | 1969 | int min_cb_width = sps->min_cb_width; |
| 1944 | int x_cb = x0 >> log2_min_cb_size; | 1970 | int x_cb = x0 >> log2_min_cb_size; |
| 1945 | int y_cb = y0 >> log2_min_cb_size; | 1971 | int y_cb = y0 >> log2_min_cb_size; |
| 1946 | int x_pu, y_pu; | 1972 | int x_pu, y_pu; |
| @@ -1957,18 +1983,18 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 10 unmodified lines | |||
| 1957 | else | 1983 | else |
| 1958 | merge_idx = 0; | 1984 | merge_idx = 0; |
| 1959 | 1985 | ||
| 1960 | ff_hevc_luma_mv_merge_mode(lc, s->ps.pps, x0, y0, nPbW, nPbH, log2_cb_size, | 1986 | ff_hevc_luma_mv_merge_mode(lc, pps, x0, y0, nPbW, nPbH, log2_cb_size, |
| 1961 | partIdx, merge_idx, ¤t_mv); | 1987 | partIdx, merge_idx, ¤t_mv); |
| 1962 | } else { | 1988 | } else { |
| 1963 | hevc_luma_mv_mvp_mode(lc, x0, y0, nPbW, nPbH, log2_cb_size, | 1989 | hevc_luma_mv_mvp_mode(lc, pps, sps, x0, y0, nPbW, nPbH, log2_cb_size, |
| 1964 | partIdx, merge_idx, ¤t_mv); | 1990 | partIdx, merge_idx, ¤t_mv); |
| 1965 | } | 1991 | } |
| 1966 | 1992 | ||
| 1967 | x_pu = x0 >> s->ps.sps->log2_min_pu_size; | 1993 | x_pu = x0 >> sps->log2_min_pu_size; |
| 1968 | y_pu = y0 >> s->ps.sps->log2_min_pu_size; | 1994 | y_pu = y0 >> sps->log2_min_pu_size; |
| 1969 | 1995 | ||
| 1970 | for (j = 0; j < nPbH >> s->ps.sps->log2_min_pu_size; j++) | 1996 | for (j = 0; j < nPbH >> sps->log2_min_pu_size; j++) |
| 1971 | for (i = 0; i < nPbW >> s->ps.sps->log2_min_pu_size; i++) | 1997 | for (i = 0; i < nPbW >> sps->log2_min_pu_size; i++) |
| 1972 | tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; | 1998 | tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; |
| 1973 | 1999 | ||
| 1974 | if (current_mv.pred_flag & PF_L0) { | 2000 | if (current_mv.pred_flag & PF_L0) { |
| @@ -1985,59 +2011,59 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 10 unmodified lines | |||
| 1985 | } | 2011 | } |
| 1986 | 2012 | ||
| 1987 | if (current_mv.pred_flag == PF_L0) { | 2013 | if (current_mv.pred_flag == PF_L0) { |
| 1988 | int x0_c = x0 >> s->ps.sps->hshift[1]; | 2014 | int x0_c = x0 >> sps->hshift[1]; |
| 1989 | int y0_c = y0 >> s->ps.sps->vshift[1]; | 2015 | int y0_c = y0 >> sps->vshift[1]; |
| 1990 | int nPbW_c = nPbW >> s->ps.sps->hshift[1]; | 2016 | int nPbW_c = nPbW >> sps->hshift[1]; |
| 1991 | int nPbH_c = nPbH >> s->ps.sps->vshift[1]; | 2017 | int nPbH_c = nPbH >> sps->vshift[1]; |
| 1992 | 2018 | ||
| 1993 | luma_mc_uni(lc, dst0, linesize[0], ref0->f, | 2019 | luma_mc_uni(lc, pps, sps, dst0, linesize[0], ref0->f, |
| 1994 | ¤t_mv.mv[0], x0, y0, nPbW, nPbH, | 2020 | ¤t_mv.mv[0], x0, y0, nPbW, nPbH, |
| 1995 | s->sh.luma_weight_l0[current_mv.ref_idx[0]], | 2021 | s->sh.luma_weight_l0[current_mv.ref_idx[0]], |
| 1996 | s->sh.luma_offset_l0[current_mv.ref_idx[0]]); | 2022 | s->sh.luma_offset_l0[current_mv.ref_idx[0]]); |
| 1997 | 2023 | ||
| 1998 | if (s->ps.sps->chroma_format_idc) { | 2024 | if (sps->chroma_format_idc) { |
| 1999 | chroma_mc_uni(lc, dst1, linesize[1], ref0->f->data[1], ref0->f->linesize[1], | 2025 | chroma_mc_uni(lc, pps, sps, dst1, linesize[1], ref0->f->data[1], ref0->f->linesize[1], |
| 2000 | 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, | 2026 | 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, |
| 2001 | s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]); | 2027 | s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0]); |
| 2002 | chroma_mc_uni(lc, dst2, linesize[2], ref0->f->data[2], ref0->f->linesize[2], | 2028 | chroma_mc_uni(lc, pps, sps, dst2, linesize[2], ref0->f->data[2], ref0->f->linesize[2], |
| 2003 | 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, | 2029 | 0, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, |
| 2004 | s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]); | 2030 | s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1]); |
| 2005 | } | 2031 | } |
| 2006 | } else if (current_mv.pred_flag == PF_L1) { | 2032 | } else if (current_mv.pred_flag == PF_L1) { |
| 2007 | int x0_c = x0 >> s->ps.sps->hshift[1]; | 2033 | int x0_c = x0 >> sps->hshift[1]; |
| 2008 | int y0_c = y0 >> s->ps.sps->vshift[1]; | 2034 | int y0_c = y0 >> sps->vshift[1]; |
| 2009 | int nPbW_c = nPbW >> s->ps.sps->hshift[1]; | 2035 | int nPbW_c = nPbW >> sps->hshift[1]; |
| 2010 | int nPbH_c = nPbH >> s->ps.sps->vshift[1]; | 2036 | int nPbH_c = nPbH >> sps->vshift[1]; |
| 2011 | 2037 | ||
| 2012 | luma_mc_uni(lc, dst0, linesize[0], ref1->f, | 2038 | luma_mc_uni(lc, pps, sps, dst0, linesize[0], ref1->f, |
| 2013 | ¤t_mv.mv[1], x0, y0, nPbW, nPbH, | 2039 | ¤t_mv.mv[1], x0, y0, nPbW, nPbH, |
| 2014 | s->sh.luma_weight_l1[current_mv.ref_idx[1]], | 2040 | s->sh.luma_weight_l1[current_mv.ref_idx[1]], |
| 2015 | s->sh.luma_offset_l1[current_mv.ref_idx[1]]); | 2041 | s->sh.luma_offset_l1[current_mv.ref_idx[1]]); |
| 2016 | 2042 | ||
| 2017 | if (s->ps.sps->chroma_format_idc) { | 2043 | if (sps->chroma_format_idc) { |
| 2018 | chroma_mc_uni(lc, dst1, linesize[1], ref1->f->data[1], ref1->f->linesize[1], | 2044 | chroma_mc_uni(lc, pps, sps, dst1, linesize[1], ref1->f->data[1], ref1->f->linesize[1], |
| 2019 | 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, | 2045 | 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, |
| 2020 | s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]); | 2046 | s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0]); |
| 2021 | 2047 | ||
| 2022 | chroma_mc_uni(lc, dst2, linesize[2], ref1->f->data[2], ref1->f->linesize[2], | 2048 | chroma_mc_uni(lc, pps, sps, dst2, linesize[2], ref1->f->data[2], ref1->f->linesize[2], |
| 2023 | 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, | 2049 | 1, x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, |
| 2024 | s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]); | 2050 | s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1]); |
| 2025 | } | 2051 | } |
| 2026 | } else if (current_mv.pred_flag == PF_BI) { | 2052 | } else if (current_mv.pred_flag == PF_BI) { |
| 2027 | int x0_c = x0 >> s->ps.sps->hshift[1]; | 2053 | int x0_c = x0 >> sps->hshift[1]; |
| 2028 | int y0_c = y0 >> s->ps.sps->vshift[1]; | 2054 | int y0_c = y0 >> sps->vshift[1]; |
| 2029 | int nPbW_c = nPbW >> s->ps.sps->hshift[1]; | 2055 | int nPbW_c = nPbW >> sps->hshift[1]; |
| 2030 | int nPbH_c = nPbH >> s->ps.sps->vshift[1]; | 2056 | int nPbH_c = nPbH >> sps->vshift[1]; |
| 2031 | 2057 | ||
| 2032 | luma_mc_bi(lc, dst0, linesize[0], ref0->f, | 2058 | luma_mc_bi(lc, pps, sps, dst0, linesize[0], ref0->f, |
| 2033 | ¤t_mv.mv[0], x0, y0, nPbW, nPbH, | 2059 | ¤t_mv.mv[0], x0, y0, nPbW, nPbH, |
| 2034 | ref1->f, ¤t_mv.mv[1], ¤t_mv); | 2060 | ref1->f, ¤t_mv.mv[1], ¤t_mv); |
| 2035 | 2061 | ||
| 2036 | if (s->ps.sps->chroma_format_idc) { | 2062 | if (sps->chroma_format_idc) { |
| 2037 | chroma_mc_bi(lc, dst1, linesize[1], ref0->f, ref1->f, | 2063 | chroma_mc_bi(lc, pps, sps, dst1, linesize[1], ref0->f, ref1->f, |
| 2038 | x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0); | 2064 | x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 0); |
| 2039 | 2065 | ||
| 2040 | chroma_mc_bi(lc, dst2, linesize[2], ref0->f, ref1->f, | 2066 | chroma_mc_bi(lc, pps, sps, dst2, linesize[2], ref0->f, ref1->f, |
| 2041 | x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1); | 2067 | x0_c, y0_c, nPbW_c, nPbH_c, ¤t_mv, 1); |
| 2042 | } | 2068 | } |
| 2043 | } | 2069 | } |
| @@ -2046,23 +2072,24 @@ static void hls_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 2 unmodified lines | |||
| 2046 | /** | 2072 | /** |
| 2047 | * 8.4.1 | 2073 | * 8.4.1 |
| 2048 | */ | 2074 | */ |
| 2049 | static int luma_intra_pred_mode(HEVCLocalContext *lc, int x0, int y0, int pu_size, | 2075 | static int luma_intra_pred_mode(HEVCLocalContext *lc, const HEVCSPS *sps, |
| 2076 | int x0, int y0, int pu_size, | ||
| 2050 | int prev_intra_luma_pred_flag) | 2077 | int prev_intra_luma_pred_flag) |
| 2051 | { | 2078 | { |
| 2052 | const HEVCContext *const s = lc->parent; | 2079 | const HEVCContext *const s = lc->parent; |
| 2053 | int x_pu = x0 >> s->ps.sps->log2_min_pu_size; | 2080 | int x_pu = x0 >> sps->log2_min_pu_size; |
| 2054 | int y_pu = y0 >> s->ps.sps->log2_min_pu_size; | 2081 | int y_pu = y0 >> sps->log2_min_pu_size; |
| 2055 | int min_pu_width = s->ps.sps->min_pu_width; | 2082 | int min_pu_width = sps->min_pu_width; |
| 2056 | int size_in_pus = pu_size >> s->ps.sps->log2_min_pu_size; | 2083 | int size_in_pus = pu_size >> sps->log2_min_pu_size; |
| 2057 | int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); | 2084 | int x0b = av_mod_uintp2(x0, sps->log2_ctb_size); |
| 2058 | int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); | 2085 | int y0b = av_mod_uintp2(y0, sps->log2_ctb_size); |
| 2059 | 2086 | ||
| 2060 | int cand_up = (lc->ctb_up_flag || y0b) ? | 2087 | int cand_up = (lc->ctb_up_flag || y0b) ? |
| 2061 | s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC; | 2088 | s->tab_ipm[(y_pu - 1) * min_pu_width + x_pu] : INTRA_DC; |
| 2062 | int cand_left = (lc->ctb_left_flag || x0b) ? | 2089 | int cand_left = (lc->ctb_left_flag || x0b) ? |
| 2063 | s->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC; | 2090 | s->tab_ipm[y_pu * min_pu_width + x_pu - 1] : INTRA_DC; |
| 2064 | 2091 | ||
| 2065 | int y_ctb = (y0 >> (s->ps.sps->log2_ctb_size)) << (s->ps.sps->log2_ctb_size); | 2092 | int y_ctb = (y0 >> (sps->log2_ctb_size)) << (sps->log2_ctb_size); |
| 2066 | 2093 | ||
| 2067 | MvField *tab_mvf = s->cur_frame->tab_mvf; | 2094 | MvField *tab_mvf = s->cur_frame->tab_mvf; |
| 2068 | int intra_pred_mode; | 2095 | int intra_pred_mode; |
| @@ -2126,16 +2153,17 @@ static int luma_intra_pred_mode(HEVCLocalContext *lc, int x0, int y0, int pu_siz · 57 unmodified lines | |||
| 2126 | return intra_pred_mode; | 2153 | return intra_pred_mode; |
| 2127 | } | 2154 | } |
| 2128 | 2155 | ||
| 2129 | static av_always_inline void set_ct_depth(const HEVCContext *s, int x0, int y0, | 2156 | static av_always_inline void set_ct_depth(const HEVCSPS *sps, uint8_t *tab_ct_depth, |
| 2157 | int x0, int y0, | ||
| 2130 | int log2_cb_size, int ct_depth) | 2158 | int log2_cb_size, int ct_depth) |
| 2131 | { | 2159 | { |
| 2132 | int length = (1 << log2_cb_size) >> s->ps.sps->log2_min_cb_size; | 2160 | int length = (1 << log2_cb_size) >> sps->log2_min_cb_size; |
| 2133 | int x_cb = x0 >> s->ps.sps->log2_min_cb_size; | 2161 | int x_cb = x0 >> sps->log2_min_cb_size; |
| 2134 | int y_cb = y0 >> s->ps.sps->log2_min_cb_size; | 2162 | int y_cb = y0 >> sps->log2_min_cb_size; |
| 2135 | int y; | 2163 | int y; |
| 2136 | 2164 | ||
| 2137 | for (y = 0; y < length; y++) | 2165 | for (y = 0; y < length; y++) |
| 2138 | memset(&s->tab_ct_depth[(y_cb + y) * s->ps.sps->min_cb_width + x_cb], | 2166 | memset(&tab_ct_depth[(y_cb + y) * sps->min_cb_width + x_cb], |
| 2139 | ct_depth, length); | 2167 | ct_depth, length); |
| 2140 | } | 2168 | } |
| 2141 | 2169 | ||
| @@ -2143,10 +2171,10 @@ static const uint8_t tab_mode_idx[] = { · 1 unmodified line | |||
| 2143 | 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, | 2171 | 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, |
| 2144 | 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31}; | 2172 | 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31}; |
| 2145 | 2173 | ||
| 2146 | static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, | 2174 | static void intra_prediction_unit(HEVCLocalContext *lc, const HEVCSPS *sps, |
| 2175 | int x0, int y0, | ||
| 2147 | int log2_cb_size) | 2176 | int log2_cb_size) |
| 2148 | { | 2177 | { |
| 2149 | const HEVCContext *const s = lc->parent; | ||
| 2150 | static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 }; | 2178 | static const uint8_t intra_chroma_table[4] = { 0, 26, 10, 1 }; |
| 2151 | uint8_t prev_intra_luma_pred_flag[4]; | 2179 | uint8_t prev_intra_luma_pred_flag[4]; |
| 2152 | int split = lc->cu.part_mode == PART_NxN; | 2180 | int split = lc->cu.part_mode == PART_NxN; |
| @@ -2167,12 +2195,12 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 14 unmodified lines | |||
| 2167 | lc->pu.rem_intra_luma_pred_mode = ff_hevc_rem_intra_luma_pred_mode_decode(lc); | 2195 | lc->pu.rem_intra_luma_pred_mode = ff_hevc_rem_intra_luma_pred_mode_decode(lc); |
| 2168 | 2196 | ||
| 2169 | lc->pu.intra_pred_mode[2 * i + j] = | 2197 | lc->pu.intra_pred_mode[2 * i + j] = |
| 2170 | luma_intra_pred_mode(lc, x0 + pb_size * j, y0 + pb_size * i, pb_size, | 2198 | luma_intra_pred_mode(lc, sps, x0 + pb_size * j, y0 + pb_size * i, pb_size, |
| 2171 | prev_intra_luma_pred_flag[2 * i + j]); | 2199 | prev_intra_luma_pred_flag[2 * i + j]); |
| 2172 | } | 2200 | } |
| 2173 | } | 2201 | } |
| 2174 | 2202 | ||
| 2175 | if (s->ps.sps->chroma_format_idc == 3) { | 2203 | if (sps->chroma_format_idc == 3) { |
| 2176 | for (i = 0; i < side; i++) { | 2204 | for (i = 0; i < side; i++) { |
| 2177 | for (j = 0; j < side; j++) { | 2205 | for (j = 0; j < side; j++) { |
| 2178 | lc->pu.chroma_mode_c[2 * i + j] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc); | 2206 | lc->pu.chroma_mode_c[2 * i + j] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc); |
| @@ -2186,7 +2214,7 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 7 unmodified lines | |||
| 2186 | } | 2214 | } |
| 2187 | } | 2215 | } |
| 2188 | } | 2216 | } |
| 2189 | } else if (s->ps.sps->chroma_format_idc == 2) { | 2217 | } else if (sps->chroma_format_idc == 2) { |
| 2190 | int mode_idx; | 2218 | int mode_idx; |
| 2191 | lc->pu.chroma_mode_c[0] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc); | 2219 | lc->pu.chroma_mode_c[0] = chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc); |
| 2192 | if (chroma_mode != 4) { | 2220 | if (chroma_mode != 4) { |
| @@ -2198,7 +2226,7 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 5 unmodified lines | |||
| 2198 | mode_idx = lc->pu.intra_pred_mode[0]; | 2226 | mode_idx = lc->pu.intra_pred_mode[0]; |
| 2199 | } | 2227 | } |
| 2200 | lc->pu.intra_pred_mode_c[0] = tab_mode_idx[mode_idx]; | 2228 | lc->pu.intra_pred_mode_c[0] = tab_mode_idx[mode_idx]; |
| 2201 | } else if (s->ps.sps->chroma_format_idc != 0) { | 2229 | } else if (sps->chroma_format_idc != 0) { |
| 2202 | chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc); | 2230 | chroma_mode = ff_hevc_intra_chroma_pred_mode_decode(lc); |
| 2203 | if (chroma_mode != 4) { | 2231 | if (chroma_mode != 4) { |
| 2204 | if (lc->pu.intra_pred_mode[0] == intra_chroma_table[chroma_mode]) | 2232 | if (lc->pu.intra_pred_mode[0] == intra_chroma_table[chroma_mode]) |
| @@ -2212,16 +2240,17 @@ static void intra_prediction_unit(HEVCLocalContext *lc, int x0, int y0, · 7 unmodified lines | |||
| 2212 | } | 2240 | } |
| 2213 | 2241 | ||
| 2214 | static void intra_prediction_unit_default_value(HEVCLocalContext *lc, | 2242 | static void intra_prediction_unit_default_value(HEVCLocalContext *lc, |
| 2243 | const HEVCSPS *sps, | ||
| 2215 | int x0, int y0, | 2244 | int x0, int y0, |
| 2216 | int log2_cb_size) | 2245 | int log2_cb_size) |
| 2217 | { | 2246 | { |
| 2218 | const HEVCContext *const s = lc->parent; | 2247 | const HEVCContext *const s = lc->parent; |
| 2219 | int pb_size = 1 << log2_cb_size; | 2248 | int pb_size = 1 << log2_cb_size; |
| 2220 | int size_in_pus = pb_size >> s->ps.sps->log2_min_pu_size; | 2249 | int size_in_pus = pb_size >> sps->log2_min_pu_size; |
| 2221 | int min_pu_width = s->ps.sps->min_pu_width; | 2250 | int min_pu_width = sps->min_pu_width; |
| 2222 | MvField *tab_mvf = s->cur_frame->tab_mvf; | 2251 | MvField *tab_mvf = s->cur_frame->tab_mvf; |
| 2223 | int x_pu = x0 >> s->ps.sps->log2_min_pu_size; | 2252 | int x_pu = x0 >> sps->log2_min_pu_size; |
| 2224 | int y_pu = y0 >> s->ps.sps->log2_min_pu_size; | 2253 | int y_pu = y0 >> sps->log2_min_pu_size; |
| 2225 | int j, k; | 2254 | int j, k; |
| 2226 | 2255 | ||
| 2227 | if (size_in_pus == 0) | 2256 | if (size_in_pus == 0) |
| @@ -2234,16 +2263,18 @@ static void intra_prediction_unit_default_value(HEVCLocalContext *lc, · 6 unmodified lines | |||
| 2234 | tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].pred_flag = PF_INTRA; | 2263 | tab_mvf[(y_pu + j) * min_pu_width + x_pu + k].pred_flag = PF_INTRA; |
| 2235 | } | 2264 | } |
| 2236 | 2265 | ||
| 2237 | static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, int y0, int log2_cb_size) | 2266 | static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, |
| 2267 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 2268 | int x0, int y0, int log2_cb_size) | ||
| 2238 | { | 2269 | { |
| 2239 | int cb_size = 1 << log2_cb_size; | 2270 | int cb_size = 1 << log2_cb_size; |
| 2240 | int log2_min_cb_size = s->ps.sps->log2_min_cb_size; | 2271 | int log2_min_cb_size = sps->log2_min_cb_size; |
| 2241 | int length = cb_size >> log2_min_cb_size; | 2272 | int length = cb_size >> log2_min_cb_size; |
| 2242 | int min_cb_width = s->ps.sps->min_cb_width; | 2273 | int min_cb_width = sps->min_cb_width; |
| 2243 | int x_cb = x0 >> log2_min_cb_size; | 2274 | int x_cb = x0 >> log2_min_cb_size; |
| 2244 | int y_cb = y0 >> log2_min_cb_size; | 2275 | int y_cb = y0 >> log2_min_cb_size; |
| 2245 | int idx = log2_cb_size - 2; | 2276 | int idx = log2_cb_size - 2; |
| 2246 | int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; | 2277 | int qp_block_mask = (1 << (sps->log2_ctb_size - pps->diff_cu_qp_delta_depth)) - 1; |
| 2247 | int x, y, ret; | 2278 | int x, y, ret; |
| 2248 | 2279 | ||
| 2249 | lc->cu.x = x0; | 2280 | lc->cu.x = x0; |
| @@ -2255,16 +2286,16 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 5 unmodified lines | |||
| 2255 | SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; | 2286 | SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; |
| 2256 | for (x = 0; x < 4; x++) | 2287 | for (x = 0; x < 4; x++) |
| 2257 | lc->pu.intra_pred_mode[x] = 1; | 2288 | lc->pu.intra_pred_mode[x] = 1; |
| 2258 | if (s->ps.pps->transquant_bypass_enable_flag) { | 2289 | if (pps->transquant_bypass_enable_flag) { |
| 2259 | lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(lc); | 2290 | lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(lc); |
| 2260 | if (lc->cu.cu_transquant_bypass_flag) | 2291 | if (lc->cu.cu_transquant_bypass_flag) |
| 2261 | set_deblocking_bypass(s, x0, y0, log2_cb_size); | 2292 | set_deblocking_bypass(s, sps, x0, y0, log2_cb_size); |
| 2262 | } else | 2293 | } else |
| 2263 | lc->cu.cu_transquant_bypass_flag = 0; | 2294 | lc->cu.cu_transquant_bypass_flag = 0; |
| 2264 | 2295 | ||
| 2265 | if (s->sh.slice_type != HEVC_SLICE_I) { | 2296 | if (s->sh.slice_type != HEVC_SLICE_I) { |
| 2266 | const int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size); | 2297 | const int x0b = av_mod_uintp2(x0, sps->log2_ctb_size); |
| 2267 | const int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size); | 2298 | const int y0b = av_mod_uintp2(y0, sps->log2_ctb_size); |
| 2268 | uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb, | 2299 | uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb, |
| 2269 | min_cb_width); | 2300 | min_cb_width); |
| 2270 | 2301 | ||
| @@ -2283,75 +2314,93 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 12 unmodified lines | |||
| 2283 | } | 2314 | } |
| 2284 | 2315 | ||
| 2285 | if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { | 2316 | if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { |
| 2286 | hls_prediction_unit(lc, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); | 2317 | hls_prediction_unit(lc, pps, sps, |
| 2287 | intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size); | 2318 | x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); |
| 2319 | intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); | ||
| 2288 | 2320 | ||
| 2289 | if (!s->sh.disable_deblocking_filter_flag) | 2321 | if (!s->sh.disable_deblocking_filter_flag) |
| 2290 | ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size); | 2322 | ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_cb_size); |
| 2291 | } else { | 2323 | } else { |
| 2292 | int pcm_flag = 0; | 2324 | int pcm_flag = 0; |
| 2293 | 2325 | ||
| 2294 | if (s->sh.slice_type != HEVC_SLICE_I) | 2326 | if (s->sh.slice_type != HEVC_SLICE_I) |
| 2295 | lc->cu.pred_mode = ff_hevc_pred_mode_decode(lc); | 2327 | lc->cu.pred_mode = ff_hevc_pred_mode_decode(lc); |
| 2296 | if (lc->cu.pred_mode != MODE_INTRA || | 2328 | if (lc->cu.pred_mode != MODE_INTRA || |
| 2297 | log2_cb_size == s->ps.sps->log2_min_cb_size) { | 2329 | log2_cb_size == sps->log2_min_cb_size) { |
| 2298 | lc->cu.part_mode = ff_hevc_part_mode_decode(lc, s->ps.sps, log2_cb_size); | 2330 | lc->cu.part_mode = ff_hevc_part_mode_decode(lc, sps, log2_cb_size); |
| 2299 | lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && | 2331 | lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && |
| 2300 | lc->cu.pred_mode == MODE_INTRA; | 2332 | lc->cu.pred_mode == MODE_INTRA; |
| 2301 | } | 2333 | } |
| 2302 | 2334 | ||
| 2303 | if (lc->cu.pred_mode == MODE_INTRA) { | 2335 | if (lc->cu.pred_mode == MODE_INTRA) { |
| 2304 | if (lc->cu.part_mode == PART_2Nx2N && s->ps.sps->pcm_enabled && | 2336 | if (lc->cu.part_mode == PART_2Nx2N && sps->pcm_enabled && |
| 2305 | log2_cb_size >= s->ps.sps->pcm.log2_min_pcm_cb_size && | 2337 | log2_cb_size >= sps->pcm.log2_min_pcm_cb_size && |
| 2306 | log2_cb_size <= s->ps.sps->pcm.log2_max_pcm_cb_size) { | 2338 | log2_cb_size <= sps->pcm.log2_max_pcm_cb_size) { |
| 2307 | pcm_flag = ff_hevc_pcm_flag_decode(lc); | 2339 | pcm_flag = ff_hevc_pcm_flag_decode(lc); |
| 2308 | } | 2340 | } |
| 2309 | if (pcm_flag) { | 2341 | if (pcm_flag) { |
| 2310 | intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size); | 2342 | intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); |
| 2311 | ret = hls_pcm_sample(lc, x0, y0, log2_cb_size); | 2343 | ret = hls_pcm_sample(lc, pps, x0, y0, log2_cb_size); |
| 2312 | if (s->ps.sps->pcm_loop_filter_disabled) | 2344 | if (sps->pcm_loop_filter_disabled) |
| 2313 | set_deblocking_bypass(s, x0, y0, log2_cb_size); | 2345 | set_deblocking_bypass(s, sps, x0, y0, log2_cb_size); |
| 2314 | 2346 | ||
| 2315 | if (ret < 0) | 2347 | if (ret < 0) |
| 2316 | return ret; | 2348 | return ret; |
| 2317 | } else { | 2349 | } else { |
| 2318 | intra_prediction_unit(lc, x0, y0, log2_cb_size); | 2350 | intra_prediction_unit(lc, sps, x0, y0, log2_cb_size); |
| 2319 | } | 2351 | } |
| 2320 | } else { | 2352 | } else { |
| 2321 | intra_prediction_unit_default_value(lc, x0, y0, log2_cb_size); | 2353 | intra_prediction_unit_default_value(lc, sps, x0, y0, log2_cb_size); |
| 2322 | switch (lc->cu.part_mode) { | 2354 | switch (lc->cu.part_mode) { |
| 2323 | case PART_2Nx2N: | 2355 | case PART_2Nx2N: |
| 2324 | hls_prediction_unit(lc, x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); | 2356 | hls_prediction_unit(lc, pps, sps, |
| 2357 | x0, y0, cb_size, cb_size, log2_cb_size, 0, idx); | ||
| 2325 | break; | 2358 | break; |
| 2326 | case PART_2NxN: | 2359 | case PART_2NxN: |
| 2327 | hls_prediction_unit(lc, x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx); | 2360 | hls_prediction_unit(lc, pps, sps, |
| 2328 | hls_prediction_unit(lc, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx); | 2361 | x0, y0, cb_size, cb_size / 2, log2_cb_size, 0, idx); |
| 2362 | hls_prediction_unit(lc, pps, sps, | ||
| 2363 | x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1, idx); | ||
| 2329 | break; | 2364 | break; |
| 2330 | case PART_Nx2N: | 2365 | case PART_Nx2N: |
| 2331 | hls_prediction_unit(lc, x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1); | 2366 | hls_prediction_unit(lc, pps, sps, |
| 2332 | hls_prediction_unit(lc, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1); | 2367 | x0, y0, cb_size / 2, cb_size, log2_cb_size, 0, idx - 1); |
| 2368 | hls_prediction_unit(lc, pps, sps, | ||
| 2369 | x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1, idx - 1); | ||
| 2333 | break; | 2370 | break; |
| 2334 | case PART_2NxnU: | 2371 | case PART_2NxnU: |
| 2335 | hls_prediction_unit(lc, x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx); | 2372 | hls_prediction_unit(lc, pps, sps, |
| 2336 | hls_prediction_unit(lc, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx); | 2373 | x0, y0, cb_size, cb_size / 4, log2_cb_size, 0, idx); |
| 2374 | hls_prediction_unit(lc, pps, sps, | ||
| 2375 | x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1, idx); | ||
| 2337 | break; | 2376 | break; |
| 2338 | case PART_2NxnD: | 2377 | case PART_2NxnD: |
| 2339 | hls_prediction_unit(lc, x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx); | 2378 | hls_prediction_unit(lc, pps, sps, |
| 2340 | hls_prediction_unit(lc, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx); | 2379 | x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0, idx); |
| 2380 | hls_prediction_unit(lc, pps, sps, | ||
| 2381 | x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1, idx); | ||
| 2341 | break; | 2382 | break; |
| 2342 | case PART_nLx2N: | 2383 | case PART_nLx2N: |
| 2343 | hls_prediction_unit(lc, x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2); | 2384 | hls_prediction_unit(lc, pps, sps, |
| 2344 | hls_prediction_unit(lc, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2); | 2385 | x0, y0, cb_size / 4, cb_size, log2_cb_size, 0, idx - 2); |
| 2386 | hls_prediction_unit(lc, pps, sps, | ||
| 2387 | x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1, idx - 2); | ||
| 2345 | break; | 2388 | break; |
| 2346 | case PART_nRx2N: | 2389 | case PART_nRx2N: |
| 2347 | hls_prediction_unit(lc, x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2); | 2390 | hls_prediction_unit(lc, pps, sps, |
| 2348 | hls_prediction_unit(lc, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2); | 2391 | x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0, idx - 2); |
| 2392 | hls_prediction_unit(lc, pps, sps, | ||
| 2393 | x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1, idx - 2); | ||
| 2349 | break; | 2394 | break; |
| 2350 | case PART_NxN: | 2395 | case PART_NxN: |
| 2351 | hls_prediction_unit(lc, x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1); | 2396 | hls_prediction_unit(lc, pps, sps, |
| 2352 | hls_prediction_unit(lc, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1); | 2397 | x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0, idx - 1); |
| 2353 | hls_prediction_unit(lc, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1); | 2398 | hls_prediction_unit(lc, pps, sps, |
| 2354 | hls_prediction_unit(lc, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1); | 2399 | x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1, idx - 1); |
| 2400 | hls_prediction_unit(lc, pps, sps, | ||
| 2401 | x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2, idx - 1); | ||
| 2402 | hls_prediction_unit(lc, pps, sps, | ||
| 2403 | x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3, idx - 1); | ||
| 2355 | break; | 2404 | break; |
| 2356 | } | 2405 | } |
| 2357 | } | 2406 | } |
| @@ -2366,22 +2415,22 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 8 unmodified lines | |||
| 2366 | if (rqt_root_cbf) { | 2415 | if (rqt_root_cbf) { |
| 2367 | const static int cbf[2] = { 0 }; | 2416 | const static int cbf[2] = { 0 }; |
| 2368 | lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? | 2417 | lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? |
| 2369 | s->ps.sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : | 2418 | sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : |
| 2370 | s->ps.sps->max_transform_hierarchy_depth_inter; | 2419 | sps->max_transform_hierarchy_depth_inter; |
| 2371 | ret = hls_transform_tree(lc, x0, y0, x0, y0, x0, y0, | 2420 | ret = hls_transform_tree(lc, pps, sps, x0, y0, x0, y0, x0, y0, |
| 2372 | log2_cb_size, | 2421 | log2_cb_size, |
| 2373 | log2_cb_size, 0, 0, cbf, cbf); | 2422 | log2_cb_size, 0, 0, cbf, cbf); |
| 2374 | if (ret < 0) | 2423 | if (ret < 0) |
| 2375 | return ret; | 2424 | return ret; |
| 2376 | } else { | 2425 | } else { |
| 2377 | if (!s->sh.disable_deblocking_filter_flag) | 2426 | if (!s->sh.disable_deblocking_filter_flag) |
| 2378 | ff_hevc_deblocking_boundary_strengths(lc, s->ps.pps, x0, y0, log2_cb_size); | 2427 | ff_hevc_deblocking_boundary_strengths(lc, pps, x0, y0, log2_cb_size); |
| 2379 | } | 2428 | } |
| 2380 | } | 2429 | } |
| 2381 | } | 2430 | } |
| 2382 | 2431 | ||
| 2383 | if (s->ps.pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) | 2432 | if (pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) |
| 2384 | ff_hevc_set_qPy(lc, s->ps.pps, x0, y0, log2_cb_size); | 2433 | ff_hevc_set_qPy(lc, pps, x0, y0, log2_cb_size); |
| 2385 | 2434 | ||
| 2386 | x = y_cb * min_cb_width + x_cb; | 2435 | x = y_cb * min_cb_width + x_cb; |
| 2387 | for (y = 0; y < length; y++) { | 2436 | for (y = 0; y < length; y++) { |
| @@ -2394,12 +2443,14 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i · 6 unmodified lines | |||
| 2394 | lc->qPy_pred = lc->qp_y; | 2443 | lc->qPy_pred = lc->qp_y; |
| 2395 | } | 2444 | } |
| 2396 | 2445 | ||
| 2397 | set_ct_depth(s, x0, y0, log2_cb_size, lc->ct_depth); | 2446 | set_ct_depth(sps, s->tab_ct_depth, x0, y0, log2_cb_size, lc->ct_depth); |
| 2398 | 2447 | ||
| 2399 | return 0; | 2448 | return 0; |
| 2400 | } | 2449 | } |
| 2401 | 2450 | ||
| 2402 | static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, | 2451 | static int hls_coding_quadtree(HEVCLocalContext *lc, |
| 2452 | const HEVCPPS *pps, const HEVCSPS *sps, | ||
| 2453 | int x0, int y0, | ||
| 2403 | int log2_cb_size, int cb_depth) | 2454 | int log2_cb_size, int cb_depth) |
| 2404 | { | 2455 | { |
| 2405 | const HEVCContext *const s = lc->parent; | 2456 | const HEVCContext *const s = lc->parent; |
| @@ -2408,49 +2459,49 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, · 2 unmodified lines | |||
| 2408 | int split_cu; | 2459 | int split_cu; |
| 2409 | 2460 | ||
| 2410 | lc->ct_depth = cb_depth; | 2461 | lc->ct_depth = cb_depth; |
| 2411 | if (x0 + cb_size <= s->ps.sps->width && | 2462 | if (x0 + cb_size <= sps->width && |
| 2412 | y0 + cb_size <= s->ps.sps->height && | 2463 | y0 + cb_size <= sps->height && |
| 2413 | log2_cb_size > s->ps.sps->log2_min_cb_size) { | 2464 | log2_cb_size > sps->log2_min_cb_size) { |
| 2414 | split_cu = ff_hevc_split_coding_unit_flag_decode(lc, s->ps.sps, cb_depth, x0, y0); | 2465 | split_cu = ff_hevc_split_coding_unit_flag_decode(lc, sps, cb_depth, x0, y0); |
| 2415 | } else { | 2466 | } else { |
| 2416 | split_cu = (log2_cb_size > s->ps.sps->log2_min_cb_size); | 2467 | split_cu = (log2_cb_size > sps->log2_min_cb_size); |
| 2417 | } | 2468 | } |
| 2418 | if (s->ps.pps->cu_qp_delta_enabled_flag && | 2469 | if (pps->cu_qp_delta_enabled_flag && |
| 2419 | log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth) { | 2470 | log2_cb_size >= sps->log2_ctb_size - pps->diff_cu_qp_delta_depth) { |
| 2420 | lc->tu.is_cu_qp_delta_coded = 0; | 2471 | lc->tu.is_cu_qp_delta_coded = 0; |
| 2421 | lc->tu.cu_qp_delta = 0; | 2472 | lc->tu.cu_qp_delta = 0; |
| 2422 | } | 2473 | } |
| 2423 | 2474 | ||
| 2424 | if (s->sh.cu_chroma_qp_offset_enabled_flag && | 2475 | if (s->sh.cu_chroma_qp_offset_enabled_flag && |
| 2425 | log2_cb_size >= s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_chroma_qp_offset_depth) { | 2476 | log2_cb_size >= sps->log2_ctb_size - pps->diff_cu_chroma_qp_offset_depth) { |
| 2426 | lc->tu.is_cu_chroma_qp_offset_coded = 0; | 2477 | lc->tu.is_cu_chroma_qp_offset_coded = 0; |
| 2427 | } | 2478 | } |
| 2428 | 2479 | ||
| 2429 | if (split_cu) { | 2480 | if (split_cu) { |
| 2430 | int qp_block_mask = (1<<(s->ps.sps->log2_ctb_size - s->ps.pps->diff_cu_qp_delta_depth)) - 1; | 2481 | int qp_block_mask = (1 << (sps->log2_ctb_size - pps->diff_cu_qp_delta_depth)) - 1; |
| 2431 | const int cb_size_split = cb_size >> 1; | 2482 | const int cb_size_split = cb_size >> 1; |
| 2432 | const int x1 = x0 + cb_size_split; | 2483 | const int x1 = x0 + cb_size_split; |
| 2433 | const int y1 = y0 + cb_size_split; | 2484 | const int y1 = y0 + cb_size_split; |
| 2434 | 2485 | ||
| 2435 | int more_data = 0; | 2486 | int more_data = 0; |
| 2436 | 2487 | ||
| 2437 | more_data = hls_coding_quadtree(lc, x0, y0, log2_cb_size - 1, cb_depth + 1); | 2488 | more_data = hls_coding_quadtree(lc, pps, sps, x0, y0, log2_cb_size - 1, cb_depth + 1); |
| 2438 | if (more_data < 0) | 2489 | if (more_data < 0) |
| 2439 | return more_data; | 2490 | return more_data; |
| 2440 | 2491 | ||
| 2441 | if (more_data && x1 < s->ps.sps->width) { | 2492 | if (more_data && x1 < sps->width) { |
| 2442 | more_data = hls_coding_quadtree(lc, x1, y0, log2_cb_size - 1, cb_depth + 1); | 2493 | more_data = hls_coding_quadtree(lc, pps, sps, x1, y0, log2_cb_size - 1, cb_depth + 1); |
| 2443 | if (more_data < 0) | 2494 | if (more_data < 0) |
| 2444 | return more_data; | 2495 | return more_data; |
| 2445 | } | 2496 | } |
| 2446 | if (more_data && y1 < s->ps.sps->height) { | 2497 | if (more_data && y1 < sps->height) { |
| 2447 | more_data = hls_coding_quadtree(lc, x0, y1, log2_cb_size - 1, cb_depth + 1); | 2498 | more_data = hls_coding_quadtree(lc, pps, sps, x0, y1, log2_cb_size - 1, cb_depth + 1); |
| 2448 | if (more_data < 0) | 2499 | if (more_data < 0) |
| 2449 | return more_data; | 2500 | return more_data; |
| 2450 | } | 2501 | } |
| 2451 | if (more_data && x1 < s->ps.sps->width && | 2502 | if (more_data && x1 < sps->width && |
| 2452 | y1 < s->ps.sps->height) { | 2503 | y1 < sps->height) { |
| 2453 | more_data = hls_coding_quadtree(lc, x1, y1, log2_cb_size - 1, cb_depth + 1); | 2504 | more_data = hls_coding_quadtree(lc, pps, sps, x1, y1, log2_cb_size - 1, cb_depth + 1); |
| 2454 | if (more_data < 0) | 2505 | if (more_data < 0) |
| 2455 | return more_data; | 2506 | return more_data; |
| 2456 | } | 2507 | } |
| @@ -2460,20 +2511,20 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, · 3 unmodified lines | |||
| 2460 | lc->qPy_pred = lc->qp_y; | 2511 | lc->qPy_pred = lc->qp_y; |
| 2461 | 2512 | ||
| 2462 | if (more_data) | 2513 | if (more_data) |
| 2463 | return ((x1 + cb_size_split) < s->ps.sps->width || | 2514 | return ((x1 + cb_size_split) < sps->width || |
| 2464 | (y1 + cb_size_split) < s->ps.sps->height); | 2515 | (y1 + cb_size_split) < sps->height); |
| 2465 | else | 2516 | else |
| 2466 | return 0; | 2517 | return 0; |
| 2467 | } else { | 2518 | } else { |
| 2468 | ret = hls_coding_unit(lc, s, x0, y0, log2_cb_size); | 2519 | ret = hls_coding_unit(lc, s, pps, sps, x0, y0, log2_cb_size); |
| 2469 | if (ret < 0) | 2520 | if (ret < 0) |
| 2470 | return ret; | 2521 | return ret; |
| 2471 | if ((!((x0 + cb_size) % | 2522 | if ((!((x0 + cb_size) % |
| 2472 | (1 << (s->ps.sps->log2_ctb_size))) || | 2523 | (1 << (sps->log2_ctb_size))) || |
| 2473 | (x0 + cb_size >= s->ps.sps->width)) && | 2524 | (x0 + cb_size >= sps->width)) && |
| 2474 | (!((y0 + cb_size) % | 2525 | (!((y0 + cb_size) % |
| 2475 | (1 << (s->ps.sps->log2_ctb_size))) || | 2526 | (1 << (sps->log2_ctb_size))) || |
| 2476 | (y0 + cb_size >= s->ps.sps->height))) { | 2527 | (y0 + cb_size >= sps->height))) { |
| 2477 | int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(lc); | 2528 | int end_of_slice_flag = ff_hevc_end_of_slice_flag_decode(lc); |
| 2478 | return !end_of_slice_flag; | 2529 | return !end_of_slice_flag; |
| 2479 | } else { | 2530 | } else { |
| @@ -2484,65 +2535,68 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0, · 4 unmodified lines | |||
| 2484 | return 0; | 2535 | return 0; |
| 2485 | } | 2536 | } |
| 2486 | 2537 | ||
| 2487 | static void hls_decode_neighbour(HEVCLocalContext *lc, int x_ctb, int y_ctb, | 2538 | static void hls_decode_neighbour(HEVCLocalContext *lc, |
| 2488 | int ctb_addr_ts) | 2539 | const HEVCPPS *pps, const HEVCSPS *sps, |
| 2540 | int x_ctb, int y_ctb, int ctb_addr_ts) | ||
| 2489 | { | 2541 | { |
| 2490 | const HEVCContext *const s = lc->parent; | 2542 | const HEVCContext *const s = lc->parent; |
| 2491 | int ctb_size = 1 << s->ps.sps->log2_ctb_size; | 2543 | int ctb_size = 1 << sps->log2_ctb_size; |
| 2492 | int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; | 2544 | int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts]; |
| 2493 | int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr; | 2545 | int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr; |
| 2494 | 2546 | ||
| 2495 | s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr; | 2547 | s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr; |
| 2496 | 2548 | ||
| 2497 | if (s->ps.pps->entropy_coding_sync_enabled_flag) { | 2549 | if (pps->entropy_coding_sync_enabled_flag) { |
| 2498 | if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0) | 2550 | if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0) |
| 2499 | lc->first_qp_group = 1; | 2551 | lc->first_qp_group = 1; |
| 2500 | lc->end_of_tiles_x = s->ps.sps->width; | 2552 | lc->end_of_tiles_x = sps->width; |
| 2501 | } else if (s->ps.pps->tiles_enabled_flag) { | 2553 | } else if (pps->tiles_enabled_flag) { |
| 2502 | if (ctb_addr_ts && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) { | 2554 | if (ctb_addr_ts && pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]) { |
| 2503 | int idxX = s->ps.pps->col_idxX[x_ctb >> s->ps.sps->log2_ctb_size]; | 2555 | int idxX = pps->col_idxX[x_ctb >> sps->log2_ctb_size]; |
| 2504 | lc->end_of_tiles_x = x_ctb + (s->ps.pps->column_width[idxX] << s->ps.sps->log2_ctb_size); | 2556 | lc->end_of_tiles_x = x_ctb + (pps->column_width[idxX] << sps->log2_ctb_size); |
| 2505 | lc->first_qp_group = 1; | 2557 | lc->first_qp_group = 1; |
| 2506 | } | 2558 | } |
| 2507 | } else { | 2559 | } else { |
| 2508 | lc->end_of_tiles_x = s->ps.sps->width; | 2560 | lc->end_of_tiles_x = sps->width; |
| 2509 | } | 2561 | } |
| 2510 | 2562 | ||
| 2511 | lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->ps.sps->height); | 2563 | lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, sps->height); |
| 2512 | 2564 | ||
| 2513 | lc->boundary_flags = 0; | 2565 | lc->boundary_flags = 0; |
| 2514 | if (s->ps.pps->tiles_enabled_flag) { | 2566 | if (pps->tiles_enabled_flag) { |
| 2515 | if (x_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) | 2567 | if (x_ctb > 0 && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]]) |
| 2516 | lc->boundary_flags |= BOUNDARY_LEFT_TILE; | 2568 | lc->boundary_flags |= BOUNDARY_LEFT_TILE; |
| 2517 | if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1]) | 2569 | if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1]) |
| 2518 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; | 2570 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; |
| 2519 | if (y_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]]) | 2571 | if (y_ctb > 0 && pps->tile_id[ctb_addr_ts] != pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs - sps->ctb_width]]) |
| 2520 | lc->boundary_flags |= BOUNDARY_UPPER_TILE; | 2572 | lc->boundary_flags |= BOUNDARY_UPPER_TILE; |
| 2521 | if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->ps.sps->ctb_width]) | 2573 | if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - sps->ctb_width]) |
| 2522 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; | 2574 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; |
| 2523 | } else { | 2575 | } else { |
| 2524 | if (ctb_addr_in_slice <= 0) | 2576 | if (ctb_addr_in_slice <= 0) |
| 2525 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; | 2577 | lc->boundary_flags |= BOUNDARY_LEFT_SLICE; |
| 2526 | if (ctb_addr_in_slice < s->ps.sps->ctb_width) | 2578 | if (ctb_addr_in_slice < sps->ctb_width) |
| 2527 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; | 2579 | lc->boundary_flags |= BOUNDARY_UPPER_SLICE; |
| 2528 | } | 2580 | } |
| 2529 | 2581 | ||
| 2530 | lc->ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !(lc->boundary_flags & BOUNDARY_LEFT_TILE)); | 2582 | lc->ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !(lc->boundary_flags & BOUNDARY_LEFT_TILE)); |
| 2531 | lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->ps.sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE)); | 2583 | lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE)); |
| 2532 | lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - s->ps.sps->ctb_width]])); | 2584 | lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= sps->ctb_width) && (pps->tile_id[ctb_addr_ts] == pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - sps->ctb_width]])); |
| 2533 | lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]])); | 2585 | lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= sps->ctb_width) && (pps->tile_id[ctb_addr_ts] == pps->tile_id[pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - sps->ctb_width]])); |
| 2534 | } | 2586 | } |
| 2535 | 2587 | ||
| 2536 | static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) | 2588 | static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) |
| 2537 | { | 2589 | { |
| 2538 | HEVCLocalContext *const lc = &s->local_ctx[0]; | 2590 | HEVCLocalContext *const lc = &s->local_ctx[0]; |
| 2591 | const HEVCPPS *const pps = s->ps.pps; | ||
| 2592 | const HEVCSPS *const sps = pps->sps; | ||
| 2539 | const uint8_t *slice_data = gb->buffer + s->sh.data_offset; | 2593 | const uint8_t *slice_data = gb->buffer + s->sh.data_offset; |
| 2540 | const size_t slice_size = gb->buffer_end - gb->buffer - s->sh.data_offset; | 2594 | const size_t slice_size = gb->buffer_end - gb->buffer - s->sh.data_offset; |
| 2541 | int ctb_size = 1 << s->ps.sps->log2_ctb_size; | 2595 | int ctb_size = 1 << sps->log2_ctb_size; |
| 2542 | int more_data = 1; | 2596 | int more_data = 1; |
| 2543 | int x_ctb = 0; | 2597 | int x_ctb = 0; |
| 2544 | int y_ctb = 0; | 2598 | int y_ctb = 0; |
| 2545 | int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; | 2599 | int ctb_addr_ts = pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]; |
| 2546 | int ret; | 2600 | int ret; |
| 2547 | 2601 | ||
| 2548 | if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) { | 2602 | if (!ctb_addr_ts && s->sh.dependent_slice_segment_flag) { |
| @@ -2551,33 +2605,34 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 2 unmodified lines | |||
| 2551 | } | 2605 | } |
| 2552 | 2606 | ||
| 2553 | if (s->sh.dependent_slice_segment_flag) { | 2607 | if (s->sh.dependent_slice_segment_flag) { |
| 2554 | int prev_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; | 2608 | int prev_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts - 1]; |
| 2555 | if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) { | 2609 | if (s->tab_slice_address[prev_rs] != s->sh.slice_addr) { |
| 2556 | av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); | 2610 | av_log(s->avctx, AV_LOG_ERROR, "Previous slice segment missing\n"); |
| 2557 | return AVERROR_INVALIDDATA; | 2611 | return AVERROR_INVALIDDATA; |
| 2558 | } | 2612 | } |
| 2559 | } | 2613 | } |
| 2560 | 2614 | ||
| 2561 | while (more_data && ctb_addr_ts < s->ps.sps->ctb_size) { | 2615 | while (more_data && ctb_addr_ts < sps->ctb_size) { |
| 2562 | int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; | 2616 | int ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts]; |
| 2563 | 2617 | ||
| 2564 | x_ctb = (ctb_addr_rs % ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; | 2618 | x_ctb = (ctb_addr_rs % ((sps->width + ctb_size - 1) >> sps->log2_ctb_size)) << sps->log2_ctb_size; |
| 2565 | y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size; | 2619 | y_ctb = (ctb_addr_rs / ((sps->width + ctb_size - 1) >> sps->log2_ctb_size)) << sps->log2_ctb_size; |
| 2566 | hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts); | 2620 | hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts); |
| 2567 | 2621 | ||
| 2568 | ret = ff_hevc_cabac_init(lc, s->ps.pps, ctb_addr_ts, slice_data, slice_size); | 2622 | ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, slice_data, slice_size); |
| 2569 | if (ret < 0) { | 2623 | if (ret < 0) { |
| 2570 | s->tab_slice_address[ctb_addr_rs] = -1; | 2624 | s->tab_slice_address[ctb_addr_rs] = -1; |
| 2571 | return ret; | 2625 | return ret; |
| 2572 | } | 2626 | } |
| 2573 | 2627 | ||
| 2574 | hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); | 2628 | hls_sao_param(lc, pps, sps, |
| 2629 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); | ||
| 2575 | 2630 | ||
| 2576 | s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset; | 2631 | s->deblock[ctb_addr_rs].beta_offset = s->sh.beta_offset; |
| 2577 | s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset; | 2632 | s->deblock[ctb_addr_rs].tc_offset = s->sh.tc_offset; |
| 2578 | s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag; | 2633 | s->filter_slice_edges[ctb_addr_rs] = s->sh.slice_loop_filter_across_slices_enabled_flag; |
| 2579 | 2634 | ||
| 2580 | more_data = hls_coding_quadtree(lc, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); | 2635 | more_data = hls_coding_quadtree(lc, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0); |
| 2581 | if (more_data < 0) { | 2636 | if (more_data < 0) { |
| 2582 | s->tab_slice_address[ctb_addr_rs] = -1; | 2637 | s->tab_slice_address[ctb_addr_rs] = -1; |
| 2583 | return more_data; | 2638 | return more_data; |
| @@ -2585,13 +2640,13 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb) · 1 unmodified line | |||
| 2585 | 2640 | ||
| 2586 | 2641 | ||
| 2587 | ctb_addr_ts++; | 2642 | ctb_addr_ts++; |
| 2588 | ff_hevc_save_states(lc, s->ps.pps, ctb_addr_ts); | 2643 | ff_hevc_save_states(lc, pps, ctb_addr_ts); |
| 2589 | ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size); | 2644 | ff_hevc_hls_filters(lc, pps, x_ctb, y_ctb, ctb_size); |
| 2590 | } | 2645 | } |
| 2591 | 2646 | ||
| 2592 | if (x_ctb + ctb_size >= s->ps.sps->width && | 2647 | if (x_ctb + ctb_size >= sps->width && |
| 2593 | y_ctb + ctb_size >= s->ps.sps->height) | 2648 | y_ctb + ctb_size >= sps->height) |
| 2594 | ff_hevc_hls_filter(lc, s->ps.pps, x_ctb, y_ctb, ctb_size); | 2649 | ff_hevc_hls_filter(lc, pps, x_ctb, y_ctb, ctb_size); |
| 2595 | 2650 | ||
| 2596 | return ctb_addr_ts; | 2651 | return ctb_addr_ts; |
| 2597 | } | 2652 | } |
| @@ -2601,11 +2656,13 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 3 unmodified lines | |||
| 2601 | { | 2656 | { |
| 2602 | HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id]; | 2657 | HEVCLocalContext *lc = &((HEVCLocalContext*)hevc_lclist)[self_id]; |
| 2603 | const HEVCContext *const s = lc->parent; | 2658 | const HEVCContext *const s = lc->parent; |
| 2604 | int ctb_size = 1 << s->ps.sps->log2_ctb_size; | 2659 | const HEVCPPS *const pps = s->ps.pps; |
| 2660 | const HEVCSPS *const sps = pps->sps; | ||
| 2661 | int ctb_size = 1 << sps->log2_ctb_size; | ||
| 2605 | int more_data = 1; | 2662 | int more_data = 1; |
| 2606 | int ctb_row = job; | 2663 | int ctb_row = job; |
| 2607 | int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size); | 2664 | int ctb_addr_rs = s->sh.slice_ctb_addr_rs + ctb_row * ((sps->width + ctb_size - 1) >> sps->log2_ctb_size); |
| 2608 | int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs]; | 2665 | int ctb_addr_ts = pps->ctb_addr_rs_to_ts[ctb_addr_rs]; |
| 2609 | int thread = ctb_row % s->threads_number; | 2666 | int thread = ctb_row % s->threads_number; |
| 2610 | 2667 | ||
| 2611 | const uint8_t *data = s->data + s->sh.offset[ctb_row]; | 2668 | const uint8_t *data = s->data + s->sh.offset[ctb_row]; |
| @@ -2616,11 +2673,11 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 4 unmodified lines | |||
| 2616 | if (ctb_row) | 2673 | if (ctb_row) |
| 2617 | ff_init_cabac_decoder(&lc->cc, data, data_size); | 2674 | ff_init_cabac_decoder(&lc->cc, data, data_size); |
| 2618 | 2675 | ||
| 2619 | while(more_data && ctb_addr_ts < s->ps.sps->ctb_size) { | 2676 | while(more_data && ctb_addr_ts < sps->ctb_size) { |
| 2620 | int x_ctb = (ctb_addr_rs % s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; | 2677 | int x_ctb = (ctb_addr_rs % sps->ctb_width) << sps->log2_ctb_size; |
| 2621 | int y_ctb = (ctb_addr_rs / s->ps.sps->ctb_width) << s->ps.sps->log2_ctb_size; | 2678 | int y_ctb = (ctb_addr_rs / sps->ctb_width) << sps->log2_ctb_size; |
| 2622 | 2679 | ||
| 2623 | hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts); | 2680 | hls_decode_neighbour(lc, pps, sps, x_ctb, y_ctb, ctb_addr_ts); |
| 2624 | 2681 | ||
| 2625 | ff_thread_await_progress2(s->avctx, ctb_row, thread, SHIFT_CTB_WPP); | 2682 | ff_thread_await_progress2(s->avctx, ctb_row, thread, SHIFT_CTB_WPP); |
| 2626 | 2683 | ||
| @@ -2632,11 +2689,12 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 5 unmodified lines | |||
| 2632 | return 0; | 2689 | return 0; |
| 2633 | } | 2690 | } |
| 2634 | 2691 | ||
| 2635 | ret = ff_hevc_cabac_init(lc, s->ps.pps, ctb_addr_ts, data, data_size); | 2692 | ret = ff_hevc_cabac_init(lc, pps, ctb_addr_ts, data, data_size); |
| 2636 | if (ret < 0) | 2693 | if (ret < 0) |
| 2637 | goto error; | 2694 | goto error; |
| 2638 | hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size); | 2695 | hls_sao_param(lc, pps, sps, |
| 2639 | more_data = hls_coding_quadtree(lc, x_ctb, y_ctb, s->ps.sps->log2_ctb_size, 0); | 2696 | x_ctb >> sps->log2_ctb_size, y_ctb >> sps->log2_ctb_size); |
| 2697 | more_data = hls_coding_quadtree(lc, pps, sps, x_ctb, y_ctb, sps->log2_ctb_size, 0); | ||
| 2640 | 2698 | ||
| 2641 | if (more_data < 0) { | 2699 | if (more_data < 0) { |
| 2642 | ret = more_data; | 2700 | ret = more_data; |
| @@ -2645,26 +2703,26 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist, · 2 unmodified lines | |||
| 2645 | 2703 | ||
| 2646 | ctb_addr_ts++; | 2704 | ctb_addr_ts++; |
| 2647 | 2705 | ||
| 2648 | ff_hevc_save_states(lc, s->ps.pps, ctb_addr_ts); | 2706 | ff_hevc_save_states(lc, pps, ctb_addr_ts); |
| 2649 | ff_thread_report_progress2(s->avctx, ctb_row, thread, 1); | 2707 | ff_thread_report_progress2(s->avctx, ctb_row, thread, 1); |
| 2650 | ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size); | 2708 | ff_hevc_hls_filters(lc, pps, x_ctb, y_ctb, ctb_size); |
| 2651 | 2709 | ||
| 2652 | if (!more_data && (x_ctb+ctb_size) < s->ps.sps->width && ctb_row != s->sh.num_entry_point_offsets) { | 2710 | if (!more_data && (x_ctb+ctb_size) < sps->width && ctb_row != s->sh.num_entry_point_offsets) { |
| 2653 | /* Casting const away here is safe, because it is an atomic operation. */ | 2711 | /* Casting const away here is safe, because it is an atomic operation. */ |
| 2654 | atomic_store((atomic_int*)&s->wpp_err, 1); | 2712 | atomic_store((atomic_int*)&s->wpp_err, 1); |
| 2655 | ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); | 2713 | ff_thread_report_progress2(s->avctx, ctb_row ,thread, SHIFT_CTB_WPP); |
| 2656 | return 0; | 2714 | return 0; |
| 2657 | } | 2715 | } |
| 2658 | 2716 | ||
| 2659 | if ((x_ctb+ctb_size) >= s->ps.sps->width && (y_ctb+ctb_size) >= s->ps.sps->height ) { | 2717 | if ((x_ctb+ctb_size) >= sps->width && (y_ctb+ctb_size) >= sps->height ) { |
| 2660 | ff_hevc_hls_filter(lc, s->ps.pps, x_ctb, y_ctb, ctb_size); | 2718 | ff_hevc_hls_filter(lc, pps, x_ctb, y_ctb, ctb_size); |
| 2661 | ff_thread_report_progress2(s->avctx, ctb_row , thread, SHIFT_CTB_WPP); | 2719 | ff_thread_report_progress2(s->avctx, ctb_row , thread, SHIFT_CTB_WPP); |
| 2662 | return ctb_addr_ts; | 2720 | return ctb_addr_ts; |
| 2663 | } | 2721 | } |
| 2664 | ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts]; | 2722 | ctb_addr_rs = pps->ctb_addr_ts_to_rs[ctb_addr_ts]; |
| 2665 | x_ctb+=ctb_size; | 2723 | x_ctb+=ctb_size; |
| 2666 | 2724 | ||
| 2667 | if(x_ctb >= s->ps.sps->width) { | 2725 | if(x_ctb >= sps->width) { |
| 2668 | break; | 2726 | break; |
| 2669 | } | 2727 | } |
| 2670 | } | 2728 | } |
| @@ -2681,6 +2739,8 @@ error: · 10 unmodified lines | |||
| 2681 | 2739 | ||
| 2682 | static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) | 2740 | static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) |
| 2683 | { | 2741 | { |
| 2742 | const HEVCPPS *const pps = s->ps.pps; | ||
| 2743 | const HEVCSPS *const sps = pps->sps; | ||
| 2684 | const uint8_t *data = nal->data; | 2744 | const uint8_t *data = nal->data; |
| 2685 | int length = nal->size; | 2745 | int length = nal->size; |
| 2686 | int *ret; | 2746 | int *ret; |
| @@ -2688,10 +2748,10 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 1 unmodified line | |||
| 2688 | int64_t startheader, cmpt = 0; | 2748 | int64_t startheader, cmpt = 0; |
| 2689 | int i, j, res = 0; | 2749 | int i, j, res = 0; |
| 2690 | 2750 | ||
| 2691 | if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * s->ps.sps->ctb_width >= s->ps.sps->ctb_width * s->ps.sps->ctb_height) { | 2751 | if (s->sh.slice_ctb_addr_rs + s->sh.num_entry_point_offsets * sps->ctb_width >= sps->ctb_width * sps->ctb_height) { |
| 2692 | av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n", | 2752 | av_log(s->avctx, AV_LOG_ERROR, "WPP ctb addresses are wrong (%d %d %d %d)\n", |
| 2693 | s->sh.slice_ctb_addr_rs, s->sh.num_entry_point_offsets, | 2753 | s->sh.slice_ctb_addr_rs, s->sh.num_entry_point_offsets, |
| 2694 | s->ps.sps->ctb_width, s->ps.sps->ctb_height | 2754 | sps->ctb_width, sps->ctb_height |
| 2695 | ); | 2755 | ); |
| 2696 | return AVERROR_INVALIDDATA; | 2756 | return AVERROR_INVALIDDATA; |
| 2697 | } | 2757 | } |
| @@ -2769,7 +2829,7 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) · 71 unmodified lines | |||
| 2769 | if (!ret) | 2829 | if (!ret) |
| 2770 | return AVERROR(ENOMEM); | 2830 | return AVERROR(ENOMEM); |
| 2771 | 2831 | ||
| 2772 | if (s->ps.pps->entropy_coding_sync_enabled_flag) | 2832 | if (pps->entropy_coding_sync_enabled_flag) |
| 2773 | s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->local_ctx, ret, s->sh.num_entry_point_offsets + 1); | 2833 | s->avctx->execute2(s->avctx, hls_decode_entry_wpp, s->local_ctx, ret, s->sh.num_entry_point_offsets + 1); |
| 2774 | 2834 | ||
| 2775 | for (i = 0; i <= s->sh.num_entry_point_offsets; i++) | 2835 | for (i = 0; i <= s->sh.num_entry_point_offsets; i++) |
| @@ -2868,14 +2928,16 @@ static int set_side_data(HEVCContext *s) · 92 unmodified lines | |||
| 2868 | 2928 | ||
| 2869 | static int hevc_frame_start(HEVCContext *s) | 2929 | static int hevc_frame_start(HEVCContext *s) |
| 2870 | { | 2930 | { |
| 2871 | int pic_size_in_ctb = ((s->ps.sps->width >> s->ps.sps->log2_min_cb_size) + 1) * | 2931 | const HEVCPPS *const pps = s->ps.pps; |
| 2872 | ((s->ps.sps->height >> s->ps.sps->log2_min_cb_size) + 1); | 2932 | const HEVCSPS *const sps = pps->sps; |
| 2933 | int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) * | ||
| 2934 | ((sps->height >> sps->log2_min_cb_size) + 1); | ||
| 2873 | int ret; | 2935 | int ret; |
| 2874 | 2936 | ||
| 2875 | memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); | 2937 | memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); |
| 2876 | memset(s->vertical_bs, 0, s->bs_width * s->bs_height); | 2938 | memset(s->vertical_bs, 0, s->bs_width * s->bs_height); |
| 2877 | memset(s->cbf_luma, 0, s->ps.sps->min_tb_width * s->ps.sps->min_tb_height); | 2939 | memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); |
| 2878 | memset(s->is_pcm, 0, (s->ps.sps->min_pu_width + 1) * (s->ps.sps->min_pu_height + 1)); | 2940 | memset(s->is_pcm, 0, (sps->min_pu_width + 1) * (sps->min_pu_height + 1)); |
| 2879 | memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); | 2941 | memset(s->tab_slice_address, -1, pic_size_in_ctb * sizeof(*s->tab_slice_address)); |
| 2880 | 2942 | ||
| 2881 | s->is_decoded = 0; | 2943 | s->is_decoded = 0; |
| @@ -2883,8 +2945,8 @@ static int hevc_frame_start(HEVCContext *s) · 1 unmodified line | |||
| 2883 | 2945 | ||
| 2884 | s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos); | 2946 | s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s) || (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos); |
| 2885 | 2947 | ||
| 2886 | if (s->ps.pps->tiles_enabled_flag) | 2948 | if (pps->tiles_enabled_flag) |
| 2887 | s->local_ctx[0].end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size; | 2949 | s->local_ctx[0].end_of_tiles_x = pps->column_width[0] << sps->log2_ctb_size; |
| 2888 | 2950 | ||
| 2889 | ret = ff_hevc_set_new_ref(s, s->poc); | 2951 | ret = ff_hevc_set_new_ref(s, s->poc); |
| 2890 | if (ret < 0) | 2952 | if (ret < 0) |