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
767767
768768 if (boundary_upper) {
769769 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) :
771771 s->cur_frame->refPicList;
772772 int yp_pu = (y0 - 1) >> log2_min_pu_size;
773773 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
805805
806806 if (boundary_left) {
807807 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) :
809809 s->cur_frame->refPicList;
810810 int xp_pu = (x0 - 1) >> log2_min_pu_size;
811811 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
35033503 dst->needs_fg = 1;
35043504 }
35053505
3506+ dst->pps = ff_refstruct_ref_c(src->pps);
35063507 dst->tab_mvf = ff_refstruct_ref(src->tab_mvf);
35073508 dst->rpl_tab = ff_refstruct_ref(src->rpl_tab);
35083509 dst->rpl = ff_refstruct_ref(src->rpl);
libavcodec/hevc/hevcdec.h+2−2
@@ -366,6 +366,7 @@ typedef struct HEVCFrame { · 365 unmodified lines
366366 int ctb_count;
367367 int poc;
368368
369+ const HEVCPPS *pps; ///< RefStruct reference
369370 RefPicListTab *rpl; ///< RefStruct reference
370371 int nb_rpl_elems;
371372
@@ -556,8 +557,7 @@ void ff_hevc_clear_refs(HEVCLayerContext *l); · 184 unmodified lines
556557 */
557558 void ff_hevc_flush_dpb(HEVCContext *s);
558559
559−const RefPicList *ff_hevc_get_ref_list(const HEVCContext *s, const HEVCFrame *frame,
560− int x0, int y0);
560+const RefPicList *ff_hevc_get_ref_list(const HEVCFrame *frame, int x0, int y0);
561561
562562 /**
563563 * 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
211211 #define DERIVE_TEMPORAL_COLOCATED_MVS \
212212 derive_temporal_colocated_mvs(s, temp_col, \
213213 refIdxLx, mvLXCol, X, colPic, \
214− ff_hevc_get_ref_list(s, ref, x, y))
214+ ff_hevc_get_ref_list(ref, x, y))
215215
216216 /*
217217 * 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
3838 av_frame_unref(frame->frame_grain);
3939 frame->needs_fg = 0;
4040
41+ ff_refstruct_unref(&frame->pps);
4142 ff_refstruct_unref(&frame->tab_mvf);
4243
4344 ff_refstruct_unref(&frame->rpl);
@@ -49,13 +50,13 @@ void ff_hevc_unref_frame(HEVCFrame *frame, int flags) · 5 unmodified lines
4950 }
5051 }
5152
52−const RefPicList *ff_hevc_get_ref_list(const HEVCContext *s,
53− const HEVCFrame *ref, int x0, int y0)
53+const RefPicList *ff_hevc_get_ref_list(const HEVCFrame *ref, int x0, int y0)
5454 {
55− int x_cb = x0 >> s->ps.sps->log2_ctb_size;
56− int y_cb = y0 >> s->ps.sps->log2_ctb_size;
57− int pic_width_cb = s->ps.sps->ctb_width;
58− int ctb_addr_ts = s->pps->ctb_addr_rs_to_ts[y_cb * pic_width_cb + x_cb];
55+ const HEVCSPS *sps = ref->pps->sps;
56+ int x_cb = x0 >> sps->log2_ctb_size;
57+ int y_cb = y0 >> sps->log2_ctb_size;
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];
5960 return &ref->rpl_tab[ctb_addr_ts]->refPicList[0];
6061 }
6162
@@ -116,6 +117,8 @@ static HEVCFrame *alloc_frame(HEVCContext *s, HEVCLayerContext *l) · 54 unmodified lines
116117 if (ret < 0)
117118 goto fail;
118119
120+ frame->pps = ff_refstruct_ref_c(s->pps);
121+
119122 return frame;
120123 fail:
121124 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