History

lavc/hevcdec: set active PPS/SPS in hevc_frame_start()

Not in hls_slice_header(), as it should only be done once per frame.

Anton Khirnov committed 2 years ago

Commit a2e77ca1 parent 47d34ba1 file · +27 −25Browse files

Unified · Split

libavcodec/hevc/hevcdec.c+27−25
@@ -594,6 +594,7 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 593 unmodified lines
594594 SliceHeader *sh = &s->sh;
595595 const HEVCPPS *pps;
596596 const HEVCSPS *sps;
597+ unsigned pps_id;
597598 int i, ret;
598599
599600 // Coded parameters
@@ -612,40 +613,23 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb) · 12 unmodified lines
612613 if (IS_IRAP(s))
613614 sh->no_output_of_prior_pics_flag = get_bits1(gb);
614615
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);
618619 return AVERROR_INVALIDDATA;
619620 }
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) {
622622 av_log(s->avctx, AV_LOG_ERROR, "PPS changed between slices.\n");
623623 return AVERROR_INVALIDDATA;
624624 }
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];
627628 sps = pps->sps;
628629
629630 if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
630631 sh->no_output_of_prior_pics_flag = 1;
631632
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−
649633 sh->dependent_slice_segment_flag = 0;
650634 if (!sh->first_slice_in_pic_flag) {
651635 int slice_address_length;
@@ -2935,12 +2919,30 @@ static int set_side_data(HEVCContext *s) · 2283 unmodified lines
29352919
29362920 static int hevc_frame_start(HEVCContext *s)
29372921 {
2938− const HEVCPPS *const pps = s->pps;
2922+ const HEVCPPS *const pps = s->ps.pps_list[s->sh.pps_id];
29392923 const HEVCSPS *const sps = pps->sps;
29402924 int pic_size_in_ctb = ((sps->width >> sps->log2_min_cb_size) + 1) *
29412925 ((sps->height >> sps->log2_min_cb_size) + 1);
29422926 int ret;
29432927
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+
29442946 memset(s->horizontal_bs, 0, s->bs_width * s->bs_height);
29452947 memset(s->vertical_bs, 0, s->bs_width * s->bs_height);
29462948 memset(s->cbf_luma, 0, sps->min_tb_width * sps->min_tb_height);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t