ref: c19fb21dcb7d50a2de41eaa03d041d014e1c43cf
parent: 5a4fea2c136464ddbc38f00f98619bea9ca68d19
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Sun Nov 18 04:11:25 EST 2018
Remove entries from c->refs[] that can be retrieved from frame_hdr
--- a/src/decode.c
+++ b/src/decode.c
@@ -3043,6 +3043,7 @@
}
#undef assign_bitdepth_case
+ int ref_coded_width[7];
if (f->frame_hdr->frame_type & 1) {
if (f->frame_hdr->primary_ref_frame != DAV1D_PRIMARY_REF_NONE) {
const int pri_ref = f->frame_hdr->refidx[f->frame_hdr->primary_ref_frame];
@@ -3067,7 +3068,7 @@
goto error;
}
dav1d_thread_picture_ref(&f->refp[i], &c->refs[refidx].p);
- f->ref_coded_width[i] = c->refs[refidx].coded_width;
+ ref_coded_width[i] = c->refs[refidx].p.p.frame_hdr->width[0];
if (f->frame_hdr->width[0] != c->refs[refidx].p.p.p.w ||
f->frame_hdr->height != c->refs[refidx].p.p.p.h)
{
@@ -3182,7 +3183,7 @@
for (int i = 0; i < 7; i++) {
const int refidx = f->frame_hdr->refidx[i];
if (c->refs[refidx].refmvs != NULL &&
- f->ref_coded_width[i] == f->cur.p.w &&
+ ref_coded_width[i] == f->cur.p.w &&
f->refp[i].p.p.h == f->cur.p.h)
{
f->ref_mvs_ref[i] = c->refs[refidx].refmvs;
@@ -3214,7 +3215,7 @@
if (f->frame_hdr->segmentation.temporal || !f->frame_hdr->segmentation.update_map) {
const int pri_ref = f->frame_hdr->primary_ref_frame;
assert(pri_ref != DAV1D_PRIMARY_REF_NONE);
- const int ref_w = ((f->ref_coded_width[pri_ref] + 7) >> 3) << 1;
+ const int ref_w = ((ref_coded_width[pri_ref] + 7) >> 3) << 1;
const int ref_h = ((f->refp[pri_ref].p.p.h + 7) >> 3) << 1;
if (ref_w == f->bw && ref_h == f->bh) {
f->prev_segmap_ref = c->refs[f->frame_hdr->refidx[pri_ref]].segmap;
@@ -3255,7 +3256,6 @@
if (c->refs[i].p.p.data[0])
dav1d_thread_picture_unref(&c->refs[i].p);
dav1d_thread_picture_ref(&c->refs[i].p, &f->sr_cur);
- c->refs[i].coded_width = f->frame_hdr->width[0];
if (c->cdf[i].cdf) dav1d_cdf_thread_unref(&c->cdf[i]);
if (f->frame_hdr->refresh_context) {
@@ -3263,11 +3263,6 @@
} else {
dav1d_cdf_thread_ref(&c->cdf[i], &f->in_cdf);
}
- c->refs[i].lf_mode_ref_deltas =
- f->frame_hdr->loopfilter.mode_ref_deltas;
- c->refs[i].seg_data = f->frame_hdr->segmentation.seg_data;
- memcpy(c->refs[i].gmv, f->frame_hdr->gmv, sizeof(c->refs[i].gmv));
- c->refs[i].film_grain = f->frame_hdr->film_grain.data;
dav1d_ref_dec(&c->refs[i].segmap);
c->refs[i].segmap = f->cur_segmap_ref;
@@ -3280,7 +3275,6 @@
dav1d_ref_inc(f->mvs_ref);
}
memcpy(c->refs[i].refpoc, f->refpoc, sizeof(f->refpoc));
- c->refs[i].qidx = f->frame_hdr->quant.yac;
}
}
--- a/src/internal.h
+++ b/src/internal.h
@@ -94,14 +94,8 @@
struct {
Dav1dThreadPicture p;
Dav1dRef *segmap;
- Dav1dSegmentationDataSet seg_data;
Dav1dRef *refmvs;
unsigned refpoc[7];
- Dav1dWarpedMotionParams gmv[7];
- Dav1dLoopfilterModeRefDeltas lf_mode_ref_deltas;
- Dav1dFilmGrainData film_grain;
- uint8_t qidx;
- unsigned coded_width;
} refs[8];
CdfThreadContext cdf[8];
@@ -138,7 +132,6 @@
uint8_t *cur_segmap;
const uint8_t *prev_segmap;
unsigned refpoc[7], refrefpoc[7][7];
- int ref_coded_width[7];
uint8_t gmv_warp_allowed[7];
CdfThreadContext in_cdf, out_cdf;
struct {
--- a/src/obu.c
+++ b/src/obu.c
@@ -736,7 +736,8 @@
// segmentation data from the reference frame.
assert(hdr->primary_ref_frame != DAV1D_PRIMARY_REF_NONE);
const int pri_ref = hdr->refidx[hdr->primary_ref_frame];
- hdr->segmentation.seg_data = c->refs[pri_ref].seg_data;
+ hdr->segmentation.seg_data =
+ c->refs[pri_ref].p.p.frame_hdr->segmentation.seg_data;
}
} else {
memset(&hdr->segmentation.seg_data, 0, sizeof(Dav1dSegmentationDataSet));
@@ -796,7 +797,8 @@
hdr->loopfilter.mode_ref_deltas = default_mode_ref_deltas;
} else {
const int ref = hdr->refidx[hdr->primary_ref_frame];
- hdr->loopfilter.mode_ref_deltas = c->refs[ref].lf_mode_ref_deltas;
+ hdr->loopfilter.mode_ref_deltas =
+ c->refs[ref].p.p.frame_hdr->loopfilter.mode_ref_deltas;
}
hdr->loopfilter.mode_ref_delta_enabled = dav1d_get_bits(gb, 1);
if (hdr->loopfilter.mode_ref_delta_enabled) {
@@ -970,7 +972,7 @@
const Dav1dWarpedMotionParams *const ref_gmv =
hdr->primary_ref_frame == DAV1D_PRIMARY_REF_NONE ? &dav1d_default_wm_params :
- &c->refs[hdr->refidx[hdr->primary_ref_frame]].gmv[i];
+ &c->refs[hdr->refidx[hdr->primary_ref_frame]].p.p.frame_hdr->gmv[i];
int32_t *const mat = hdr->gmv[i].matrix;
const int32_t *const ref_mat = ref_gmv->matrix;
int bits, shift;
@@ -1018,7 +1020,7 @@
if (hdr->refidx[i] == refidx)
break;
if (i == 7) goto error;
- hdr->film_grain.data = c->refs[refidx].film_grain;
+ hdr->film_grain.data = c->refs[refidx].p.p.frame_hdr->film_grain.data;
hdr->film_grain.data.seed = seed;
} else {
Dav1dFilmGrainData *const fgd = &hdr->film_grain.data;
@@ -1363,20 +1365,13 @@
dav1d_thread_picture_ref(&c->refs[i].p, &c->refs[r].p);
if (c->cdf[i].cdf) dav1d_cdf_thread_unref(&c->cdf[i]);
- dav1d_init_states(&c->cdf[i], c->refs[r].qidx);
+ dav1d_init_states(&c->cdf[i], c->refs[r].p.p.frame_hdr->quant.yac);
- c->refs[i].lf_mode_ref_deltas = c->refs[r].lf_mode_ref_deltas;
- c->refs[i].seg_data = c->refs[r].seg_data;
- for (int j = 0; j < 7; j++)
- c->refs[i].gmv[j] = dav1d_default_wm_params;
- c->refs[i].film_grain = c->refs[r].film_grain;
-
dav1d_ref_dec(&c->refs[i].segmap);
c->refs[i].segmap = c->refs[r].segmap;
if (c->refs[r].segmap)
dav1d_ref_inc(c->refs[r].segmap);
dav1d_ref_dec(&c->refs[i].refmvs);
- c->refs[i].qidx = c->refs[r].qidx;
}
}
c->frame_hdr = NULL;