History

lavc/hevcdec: make a HEVCFrame hold a reference to its PPS

ff_hevc_get_ref_list() needs the PPS of a previously decoded frame, which may be different from the currently active one.

Anton Khirnov committed 2 years ago

Commit 9bccc631 parent 67271375 files · +15 −11Browse files

Unified · Split

5 files
  1. libavcodec/hevc/filter.c +2 −2
  2. libavcodec/hevc/hevcdec.c +1 −0
  3. libavcodec/hevc/hevcdec.h +2 −2
  4. libavcodec/hevc/mvs.c +1 −1
  5. libavcodec/hevc/refs.c +9 −6
libavcodec/hevc/filter.c+2−2
@@ -767,7 +767,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer · 766 unmodified lines
767 767
768 if (boundary_upper) {768 if (boundary_upper) {
769 const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?769 const RefPicList *rpl_top = (lc->boundary_flags & BOUNDARY_UPPER_SLICE) ?
770 ff_hevc_get_ref_list(s, s->cur_frame, x0, y0 - 1) :770 ff_hevc_get_ref_list(s->cur_frame, x0, y0 - 1) :
771 s->cur_frame->refPicList;771 s->cur_frame->refPicList;
772 int yp_pu = (y0 - 1) >> log2_min_pu_size;772 int yp_pu = (y0 - 1) >> log2_min_pu_size;
773 int yq_pu = y0 >> log2_min_pu_size;773 int yq_pu = y0 >> log2_min_pu_size;
@@ -805,7 +805,7 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayer · 31 unmodified lines
805 805
806 if (boundary_left) {806 if (boundary_left) {
807 const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?807 const RefPicList *rpl_left = (lc->boundary_flags & BOUNDARY_LEFT_SLICE) ?
808 ff_hevc_get_ref_list(s, s->cur_frame, x0 - 1, y0) :808 ff_hevc_get_ref_list(s->cur_frame, x0 - 1, y0) :
809 s->cur_frame->refPicList;809 s->cur_frame->refPicList;
810 int xp_pu = (x0 - 1) >> log2_min_pu_size;810 int xp_pu = (x0 - 1) >> log2_min_pu_size;
811 int xq_pu = x0 >> log2_min_pu_size;811 int xq_pu = x0 >> log2_min_pu_size;
libavcodec/hevc/hevcdec.c+1−0
@@ -3503,6 +3503,7 @@ static int hevc_ref_frame(HEVCFrame *dst, const HEVCFrame *src) · 3502 unmodified lines
3503 dst->needs_fg = 1;3503 dst->needs_fg = 1;
3504 }3504 }
3505 3505
3506 dst->pps = ff_refstruct_ref_c(src->pps);
3506 dst->tab_mvf = ff_refstruct_ref(src->tab_mvf);3507 dst->tab_mvf = ff_refstruct_ref(src->tab_mvf);
3507 dst->rpl_tab = ff_refstruct_ref(src->rpl_tab);3508 dst->rpl_tab = ff_refstruct_ref(src->rpl_tab);
3508 dst->rpl = ff_refstruct_ref(src->rpl);3509 dst->rpl = ff_refstruct_ref(src->rpl);
libavcodec/hevc/hevcdec.h+2−2
@@ -366,6 +366,7 @@ typedef struct HEVCFrame { · 365 unmodified lines
366 int ctb_count;366 int ctb_count;
367 int poc;367 int poc;
368 368
369 const HEVCPPS *pps; ///< RefStruct reference
369 RefPicListTab *rpl; ///< RefStruct reference370 RefPicListTab *rpl; ///< RefStruct reference
370 int nb_rpl_elems;371 int nb_rpl_elems;
371 372
@@ -556,8 +557,7 @@ void ff_hevc_clear_refs(HEVCLayerContext *l); · 184 unmodified lines
556 */557 */
557void ff_hevc_flush_dpb(HEVCContext *s);558void ff_hevc_flush_dpb(HEVCContext *s);
558 559
559const RefPicList *ff_hevc_get_ref_list(const HEVCContext *s, const HEVCFrame *frame,560const RefPicList *ff_hevc_get_ref_list(const HEVCFrame *frame, int x0, int y0);
560 int x0, int y0);
561 561
562/**562/**
563 * Construct the reference picture sets for the current frame.563 * Construct the reference picture sets for the current frame.
libavcodec/hevc/mvs.c+1−1
@@ -211,7 +211,7 @@ static int derive_temporal_colocated_mvs(const HEVCContext *s, MvField temp_col, · 210 unmodified lines
211#define DERIVE_TEMPORAL_COLOCATED_MVS \211#define DERIVE_TEMPORAL_COLOCATED_MVS \
212 derive_temporal_colocated_mvs(s, temp_col, \212 derive_temporal_colocated_mvs(s, temp_col, \
213 refIdxLx, mvLXCol, X, colPic, \213 refIdxLx, mvLXCol, X, colPic, \
214 ff_hevc_get_ref_list(s, ref, x, y))214 ff_hevc_get_ref_list(ref, x, y))
215 215
216/*216/*
217 * 8.5.3.1.7 temporal luma motion vector prediction217 * 8.5.3.1.7 temporal luma motion vector prediction
libavcodec/hevc/refs.c+9−6
@@ -38,6 +38,7 @@ void ff_hevc_unref_frame(HEVCFrame *frame, int flags) · 37 unmodified lines
38 av_frame_unref(frame->frame_grain);38 av_frame_unref(frame->frame_grain);
39 frame->needs_fg = 0;39 frame->needs_fg = 0;
40 40
41 ff_refstruct_unref(&frame->pps);
41 ff_refstruct_unref(&frame->tab_mvf);42 ff_refstruct_unref(&frame->tab_mvf);
42 43
43 ff_refstruct_unref(&frame->rpl);44 ff_refstruct_unref(&frame->rpl);
@@ -49,13 +50,13 @@ void ff_hevc_unref_frame(HEVCFrame *frame, int flags) · 5 unmodified lines
49 }50 }
50}51}
51 52
52const RefPicList *ff_hevc_get_ref_list(const HEVCContext *s,53const RefPicList *ff_hevc_get_ref_list(const HEVCFrame *ref, int x0, int y0)
53 const HEVCFrame *ref, int x0, int y0)
54{54{
55 int x_cb = x0 >> s->ps.sps->log2_ctb_size;55 const HEVCSPS *sps = ref->pps->sps;
56 int y_cb = y0 >> s->ps.sps->log2_ctb_size;56 int x_cb = x0 >> sps->log2_ctb_size;
57 int pic_width_cb = s->ps.sps->ctb_width;57 int y_cb = y0 >> sps->log2_ctb_size;
58 int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];58 int pic_width_cb = sps->ctb_width;
59 int ctb_addr_ts = ref->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
59 return &ref->rpl_tab[ctb_addr_ts]->refPicList[0];60 return &ref->rpl_tab[ctb_addr_ts]->refPicList[0];
60}61}
61 62
@@ -116,6 +117,8 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) · 54 unmodified lines
116 if (ret < 0)117 if (ret < 0)
117 goto fail;118 goto fail;
118 119
120 frame->pps = ff_refstruct_ref_c(s->pps);
121
119 return frame;122 return frame;
120fail:123fail:
121 ff_hevc_unref_frame(frame, ~0);124 ff_hevc_unref_frame(frame, ~0);

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