Not in hls_slice_header(), as it should only be done once per frame.
Unified · Split
| @@ -594,6 +594,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 593 unmodified lines | |||
| 594 | SliceHeader *sh = &s->sh; | 594 | SliceHeader *sh = &s->sh; |
| 595 | const HEVCPPS *pps; | 595 | const HEVCPPS *pps; |
| 596 | const HEVCSPS *sps; | 596 | const HEVCSPS *sps; |
| 597 | unsigned pps_id; | ||
| 597 | int i, ret; | 598 | int i, ret; |
| 598 | 599 | ||
| 599 | // Coded parameters | 600 | // Coded parameters |
| @@ -612,40 +613,23 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines | |||
| 612 | if (IS_IRAP(s)) | 613 | if (IS_IRAP(s)) |
| 613 | sh->no_output_of_prior_pics_flag = get_bits1(gb); | 614 | sh->no_output_of_prior_pics_flag = get_bits1(gb); |
| 614 | 615 | ||
| 615 | sh->pps_id = get_ue_golomb_long(gb); | 616 | pps_id = get_ue_golomb_long(gb); |
| 616 | if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { | 617 | if (pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[pps_id]) { |
| 617 | av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); | 618 | av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); |
| 618 | return AVERROR_INVALIDDATA; | 619 | return AVERROR_INVALIDDATA; |
| 619 | } | 620 | } |
| 620 | if (!sh->first_slice_in_pic_flag && | 621 | if (!sh->first_slice_in_pic_flag && pps_id != sh->pps_id) { |
| 621 | s->pps != s->ps.pps_list[sh->pps_id]) { | ||
| 622 | av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); | 622 | av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); |
| 623 | return AVERROR_INVALIDDATA; | 623 | return AVERROR_INVALIDDATA; |
| 624 | } | 624 | } |
| 625 | ff_refstruct_replace(&s->pps, s->ps.pps_list[sh->pps_id]); | 625 | sh->pps_id = pps_id; |
| 626 | pps = s->pps; | 626 | |
| 627 | pps = s->ps.pps_list[pps_id]; | ||
| 627 | sps = pps->sps; | 628 | sps = pps->sps; |
| 628 | 629 | ||
| 629 | if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) | 630 | if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) |
| 630 | sh->no_output_of_prior_pics_flag = 1; | 631 | sh->no_output_of_prior_pics_flag = 1; |
| 631 | 632 | ||
| 632 | if (s->ps.sps != sps) { | ||
| 633 | enum AVPixelFormat pix_fmt; | ||
| 634 | |||
| 635 | ff_hevc_clear_refs(s); | ||
| 636 | |||
| 637 | ret = set_sps(s, sps, sps->pix_fmt); | ||
| 638 | if (ret < 0) | ||
| 639 | return ret; | ||
| 640 | |||
| 641 | pix_fmt = get_format(s, sps); | ||
| 642 | if (pix_fmt < 0) | ||
| 643 | return pix_fmt; | ||
| 644 | s->avctx->pix_fmt = pix_fmt; | ||
| 645 | |||
| 646 | s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; | ||
| 647 | } | ||
| 648 | |||
| 649 | sh->dependent_slice_segment_flag = 0; | 633 | sh->dependent_slice_segment_flag = 0; |
| 650 | if (!sh->first_slice_in_pic_flag) { | 634 | if (!sh->first_slice_in_pic_flag) { |
| 651 | int slice_address_length; | 635 | int slice_address_length; |
| @@ -2935,12 +2919,30 @@ static int set_side_data(HEVCContext *s) · 2283 unmodified lines | |||
| 2935 | 2919 | ||
| 2936 | static int hevc_frame_start(HEVCContext *s) | 2920 | static int hevc_frame_start(HEVCContext *s) |
| 2937 | { | 2921 | { |
| 2938 | const HEVCPPS *const pps = s->pps; | 2922 | const HEVCPPS *const pps = s->ps.pps_list[s->sh.pps_id]; |
| 2939 | const HEVCSPS *const sps = pps->sps; | 2923 | const HEVCSPS *const sps = pps->sps; |
| 2940 | int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) * | 2924 | int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) * |
| 2941 | ((sps->height >> sps->log2_min_cb_size) + 1); | 2925 | ((sps->height >> sps->log2_min_cb_size) + 1); |
| 2942 | int ret; | 2926 | int ret; |
| 2943 | 2927 | ||
| 2928 | ff_refstruct_replace(&s->pps, pps); | ||
| 2929 | if (s->ps.sps != sps) { | ||
| 2930 | enum AVPixelFormat pix_fmt; | ||
| 2931 | |||
| 2932 | ff_hevc_clear_refs(s); | ||
| 2933 | |||
| 2934 | ret = set_sps(s, sps, sps->pix_fmt); | ||
| 2935 | if (ret < 0) | ||
| 2936 | return ret; | ||
| 2937 | |||
| 2938 | pix_fmt = get_format(s, sps); | ||
| 2939 | if (pix_fmt < 0) | ||
| 2940 | return pix_fmt; | ||
| 2941 | s->avctx->pix_fmt = pix_fmt; | ||
| 2942 | |||
| 2943 | s->seq_decode = (s->seq_decode + 1) & HEVC_SEQUENCE_COUNTER_MASK; | ||
| 2944 | } | ||
| 2945 | |||
| 2944 | memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); | 2946 | memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); |
| 2945 | memset(s->vertical_bs, 0, s->bs_width * s->bs_height); | 2947 | memset(s->vertical_bs, 0, s->bs_width * s->bs_height); |
| 2946 | memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); | 2948 | memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); |