mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
hevc: store the VPS list as an AVBufferRef, just like the others *PS
Signed-off-by: Anton Khirnov <anton@khirnov.net>
This commit is contained in:
parent
b769cf4b44
commit
33452aede6
@ -431,7 +431,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
|
||||
}
|
||||
|
||||
s->sps = sps;
|
||||
s->vps = s->vps_list[s->sps->vps_id];
|
||||
s->vps = (HEVCVPS*) s->vps_list[s->sps->vps_id]->data;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
@ -2924,7 +2924,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++)
|
||||
av_freep(&s->vps_list[i]);
|
||||
av_buffer_unref(&s->vps_list[i]);
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++)
|
||||
av_buffer_unref(&s->sps_list[i]);
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++)
|
||||
@ -2999,6 +2999,15 @@ static int hevc_update_thread_context(AVCodecContext *dst,
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->vps_list); i++) {
|
||||
av_buffer_unref(&s->vps_list[i]);
|
||||
if (s0->vps_list[i]) {
|
||||
s->vps_list[i] = av_buffer_ref(s0->vps_list[i]);
|
||||
if (!s->vps_list[i])
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < FF_ARRAY_ELEMS(s->sps_list); i++) {
|
||||
av_buffer_unref(&s->sps_list[i]);
|
||||
if (s0->sps_list[i]) {
|
||||
|
@ -843,7 +843,7 @@ typedef struct HEVCContext {
|
||||
const HEVCVPS *vps;
|
||||
const HEVCSPS *sps;
|
||||
const HEVCPPS *pps;
|
||||
HEVCVPS *vps_list[MAX_VPS_COUNT];
|
||||
AVBufferRef *vps_list[MAX_VPS_COUNT];
|
||||
AVBufferRef *sps_list[MAX_SPS_COUNT];
|
||||
AVBufferRef *pps_list[MAX_PPS_COUNT];
|
||||
|
||||
|
@ -328,13 +328,14 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
||||
GetBitContext *gb = &s->HEVClc.gb;
|
||||
int vps_id = 0;
|
||||
HEVCVPS *vps;
|
||||
AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps));
|
||||
|
||||
if (!vps_buf)
|
||||
return AVERROR(ENOMEM);
|
||||
vps = (HEVCVPS*)vps_buf->data;
|
||||
|
||||
av_log(s->avctx, AV_LOG_DEBUG, "Decoding VPS\n");
|
||||
|
||||
vps = av_mallocz(sizeof(*vps));
|
||||
if (!vps)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
vps_id = get_bits(gb, 4);
|
||||
if (vps_id >= MAX_VPS_COUNT) {
|
||||
av_log(s->avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", vps_id);
|
||||
@ -410,12 +411,12 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
|
||||
}
|
||||
get_bits1(gb); /* vps_extension_flag */
|
||||
|
||||
av_free(s->vps_list[vps_id]);
|
||||
s->vps_list[vps_id] = vps;
|
||||
av_buffer_unref(&s->vps_list[vps_id]);
|
||||
s->vps_list[vps_id] = vps_buf;
|
||||
return 0;
|
||||
|
||||
err:
|
||||
av_free(vps);
|
||||
av_buffer_unref(&vps_buf);
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user