lavc/hevc_ps: make PPS hold a reference to its SPS

PPS depends on, and is parsed for, specific SPS data.

This will be useful in following commits.
release/7.1
Anton Khirnov 6 months ago
parent e12fd62d1d
commit c879165b39
  1. 4
      libavcodec/hevc/hevcdec.c
  2. 8
      libavcodec/hevc/parser.c
  3. 4
      libavcodec/hevc/ps.c
  4. 2
      libavcodec/hevc/ps.h

@ -625,8 +625,8 @@ static int hls_slice_header(HEVCContext *s, GetBitContext *gb)
if (s->nal_unit_type == HEVC_NAL_CRA_NUT && s->last_eos == 1)
sh->no_output_of_prior_pics_flag = 1;
if (s->ps.sps != s->ps.sps_list[s->ps.pps->sps_id]) {
const HEVCSPS *sps = s->ps.sps_list[s->ps.pps->sps_id];
if (s->ps.sps != s->ps.pps->sps) {
const HEVCSPS *sps = s->ps.pps->sps;
enum AVPixelFormat pix_fmt;
ff_hevc_clear_refs(s);

@ -80,12 +80,8 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
}
ps->pps = ps->pps_list[pps_id];
if (ps->pps->sps_id >= HEVC_MAX_SPS_COUNT || !ps->sps_list[ps->pps->sps_id]) {
av_log(avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", ps->pps->sps_id);
return AVERROR_INVALIDDATA;
}
if (ps->sps != ps->sps_list[ps->pps->sps_id]) {
ps->sps = ps->sps_list[ps->pps->sps_id];
if (ps->sps != ps->pps->sps) {
ps->sps = ps->pps->sps;
ps->vps = ps->vps_list[ps->sps->vps_id];
}
ow = &ps->sps->output_window;

@ -1363,6 +1363,8 @@ static void hevc_pps_free(FFRefStructOpaque unused, void *obj)
{
HEVCPPS *pps = obj;
ff_refstruct_unref(&pps->sps);
av_freep(&pps->column_width);
av_freep(&pps->row_height);
av_freep(&pps->col_bd);
@ -1828,6 +1830,8 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx,
sps = ps->sps_list[pps->sps_id];
vps = ps->vps_list[sps->vps_id];
pps->sps = ff_refstruct_ref_c(sps);
pps->dependent_slice_segments_enabled_flag = get_bits1(gb);
pps->output_flag_present_flag = get_bits1(gb);
pps->num_extra_slice_header_bits = get_bits(gb, 3);

@ -437,6 +437,8 @@ typedef struct HEVCPPS {
uint8_t *data;
int data_size;
const HEVCSPS *sps; ///< RefStruct reference
} HEVCPPS;
typedef struct HEVCParamSets {

Loading…
Cancel
Save