mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-27 01:42:20 +00:00
avcodec/hevcdec: Use RefStruct API for RefPicListTab buffer
Given that the RefStruct API relies on the user to know the size of the objects and does not provide a way to get it, we need to store the number of elements allocated ourselves; but this is actually better than deriving it from the size in bytes. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
6695c0af0e
commit
452089ee23
@ -45,7 +45,8 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags)
|
|||||||
av_buffer_unref(&frame->tab_mvf_buf);
|
av_buffer_unref(&frame->tab_mvf_buf);
|
||||||
frame->tab_mvf = NULL;
|
frame->tab_mvf = NULL;
|
||||||
|
|
||||||
av_buffer_unref(&frame->rpl_buf);
|
ff_refstruct_unref(&frame->rpl);
|
||||||
|
frame->nb_rpl_elems = 0;
|
||||||
av_buffer_unref(&frame->rpl_tab_buf);
|
av_buffer_unref(&frame->rpl_tab_buf);
|
||||||
frame->rpl_tab = NULL;
|
frame->rpl_tab = NULL;
|
||||||
frame->refPicList = NULL;
|
frame->refPicList = NULL;
|
||||||
@ -95,9 +96,10 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
frame->rpl_buf = av_buffer_allocz(s->pkt.nb_nals * sizeof(RefPicListTab));
|
frame->rpl = ff_refstruct_allocz(s->pkt.nb_nals * sizeof(*frame->rpl));
|
||||||
if (!frame->rpl_buf)
|
if (!frame->rpl)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
frame->nb_rpl_elems = s->pkt.nb_nals;
|
||||||
|
|
||||||
frame->tab_mvf_buf = av_buffer_pool_get(s->tab_mvf_pool);
|
frame->tab_mvf_buf = av_buffer_pool_get(s->tab_mvf_pool);
|
||||||
if (!frame->tab_mvf_buf)
|
if (!frame->tab_mvf_buf)
|
||||||
@ -110,7 +112,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s)
|
|||||||
frame->rpl_tab = (RefPicListTab **)frame->rpl_tab_buf->data;
|
frame->rpl_tab = (RefPicListTab **)frame->rpl_tab_buf->data;
|
||||||
frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;
|
frame->ctb_count = s->ps.sps->ctb_width * s->ps.sps->ctb_height;
|
||||||
for (j = 0; j < frame->ctb_count; j++)
|
for (j = 0; j < frame->ctb_count; j++)
|
||||||
frame->rpl_tab[j] = (RefPicListTab *)frame->rpl_buf->data;
|
frame->rpl_tab[j] = frame->rpl;
|
||||||
|
|
||||||
if (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
|
if (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
|
||||||
frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
|
frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
|
||||||
@ -295,11 +297,11 @@ static int init_slice_rpl(HEVCContext *s)
|
|||||||
int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
|
int ctb_addr_ts = s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_segment_addr];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (s->slice_idx >= frame->rpl_buf->size / sizeof(RefPicListTab))
|
if (s->slice_idx >= frame->nb_rpl_elems)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
for (i = ctb_addr_ts; i < ctb_count; i++)
|
for (i = ctb_addr_ts; i < ctb_count; i++)
|
||||||
frame->rpl_tab[i] = (RefPicListTab *)frame->rpl_buf->data + s->slice_idx;
|
frame->rpl_tab[i] = frame->rpl + s->slice_idx;
|
||||||
|
|
||||||
frame->refPicList = (RefPicList *)frame->rpl_tab[ctb_addr_ts];
|
frame->refPicList = (RefPicList *)frame->rpl_tab[ctb_addr_ts];
|
||||||
|
|
||||||
|
@ -3414,9 +3414,8 @@ static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src)
|
|||||||
goto fail;
|
goto fail;
|
||||||
dst->rpl_tab = src->rpl_tab;
|
dst->rpl_tab = src->rpl_tab;
|
||||||
|
|
||||||
dst->rpl_buf = av_buffer_ref(src->rpl_buf);
|
dst->rpl = ff_refstruct_ref(src->rpl);
|
||||||
if (!dst->rpl_buf)
|
dst->nb_rpl_elems = src->nb_rpl_elems;
|
||||||
goto fail;
|
|
||||||
|
|
||||||
dst->poc = src->poc;
|
dst->poc = src->poc;
|
||||||
dst->ctb_count = src->ctb_count;
|
dst->ctb_count = src->ctb_count;
|
||||||
|
@ -417,7 +417,8 @@ typedef struct HEVCFrame {
|
|||||||
|
|
||||||
AVBufferRef *tab_mvf_buf;
|
AVBufferRef *tab_mvf_buf;
|
||||||
AVBufferRef *rpl_tab_buf;
|
AVBufferRef *rpl_tab_buf;
|
||||||
AVBufferRef *rpl_buf;
|
RefPicListTab *rpl; ///< RefStruct reference
|
||||||
|
int nb_rpl_elems;
|
||||||
|
|
||||||
void *hwaccel_picture_private; ///< RefStruct reference
|
void *hwaccel_picture_private; ///< RefStruct reference
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user