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 | 594 | SliceHeader *sh = &s->sh; |
| 595 | 595 | const HEVCPPS *pps; |
| 596 | 596 | const HEVCSPS *sps; |
| 597 | + unsigned pps_id; | |
| 597 | 598 | int i, ret; |
| 598 | 599 | |
| 599 | 600 | // Coded parameters |
| @@ -612,40 +613,23 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines | ||
| 612 | 613 | if (IS_IRAP(s)) |
| 613 | 614 | sh->no_output_of_prior_pics_flag = get_bits1(gb); |
| 614 | 615 | |
| 615 | − sh->pps_id = get_ue_golomb_long(gb); | |
| 616 | − if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) { | |
| 617 | − av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id); | |
| 616 | + pps_id = get_ue_golomb_long(gb); | |
| 617 | + if (pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[pps_id]) { | |
| 618 | + av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); | |
| 618 | 619 | return AVERROR_INVALIDDATA; |
| 619 | 620 | } |
| 620 | − if (!sh->first_slice_in_pic_flag && | |
| 621 | − s->pps != s->ps.pps_list[sh->pps_id]) { | |
| 621 | + if (!sh->first_slice_in_pic_flag && pps_id != sh->pps_id) { | |
| 622 | 622 | av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n"); |
| 623 | 623 | return AVERROR_INVALIDDATA; |
| 624 | 624 | } |
| 625 | − ff_refstruct_replace(&s->pps, s->ps.pps_list[sh->pps_id]); | |
| 626 | − pps = s->pps; | |
| 625 | + sh->pps_id = pps_id; | |
| 626 | + | |
| 627 | + pps = s->ps.pps_list[pps_id]; | |
| 627 | 628 | sps = pps->sps; |
| 628 | 629 | |
| 629 | 630 | if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1) |
| 630 | 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 | 633 | sh->dependent_slice_segment_flag = 0; |
| 650 | 634 | if (!sh->first_slice_in_pic_flag) { |
| 651 | 635 | int slice_address_length; |
| @@ -2935,12 +2919,30 @@ static int set_side_data(HEVCContext *s) · 2283 unmodified lines | ||
| 2935 | 2919 | |
| 2936 | 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 | 2923 | const HEVCSPS *const sps = pps->sps; |
| 2940 | 2924 | int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) * |
| 2941 | 2925 | ((sps->height >> sps->log2_min_cb_size) + 1); |
| 2942 | 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 | 2946 | memset(s->horizontal_bs, 0, s->bs_width * s->bs_height); |
| 2945 | 2947 | memset(s->vertical_bs, 0, s->bs_width * s->bs_height); |
| 2946 | 2948 | memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height); |