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

SPS and its dependent PPSes depend on, and are parsed for, specific VPS data.

This will be useful in following commits.
This commit is contained in:
Anton Khirnov 2024-05-31 09:53:28 +02:00
parent c879165b39
commit 2e46d68f55
4 changed files with 14 additions and 8 deletions

View File

@ -319,8 +319,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
static void export_stream_params(HEVCContext *s, const HEVCSPS *sps)
{
AVCodecContext *avctx = s->avctx;
const HEVCParamSets *ps = &s->ps;
const HEVCVPS *vps = ps->vps_list[sps->vps_id];
const HEVCVPS *vps = sps->vps;
const HEVCWindow *ow = &sps->output_window;
unsigned int num = 0, den = 0;
@ -575,7 +574,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps,
}
s->ps.sps = sps;
s->ps.vps = s->ps.vps_list[s->ps.sps->vps_id];
s->ps.vps = sps->vps;
return 0;

View File

@ -82,7 +82,7 @@ static int hevc_parse_slice_header(AVCodecParserContext *s, H2645NAL *nal,
if (ps->sps != ps->pps->sps) {
ps->sps = ps->pps->sps;
ps->vps = ps->vps_list[ps->sps->vps_id];
ps->vps = ps->sps->vps;
}
ow = &ps->sps->output_window;

View File

@ -889,10 +889,13 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
sps->vps_id = get_bits(gb, 4);
if (vps_list && !vps_list[sps->vps_id]) {
av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n",
sps->vps_id);
return AVERROR_INVALIDDATA;
if (vps_list) {
if (!vps_list[sps->vps_id]) {
av_log(avctx, AV_LOG_ERROR, "VPS %d does not exist\n",
sps->vps_id);
return AVERROR_INVALIDDATA;
}
sps->vps = ff_refstruct_ref_c(vps_list[sps->vps_id]);
}
sps->max_sub_layers = get_bits(gb, 3) + 1;
@ -1298,6 +1301,8 @@ static void hevc_sps_free(FFRefStructOpaque opaque, void *obj)
{
HEVCSPS *sps = obj;
ff_refstruct_unref(&sps->vps);
av_freep(&sps->data);
}

View File

@ -302,6 +302,8 @@ typedef struct HEVCSPS {
uint8_t *data;
int data_size;
const HEVCVPS *vps; ///< RefStruct reference
} HEVCSPS;
typedef struct HEVCPPS {