Commit 1ddd4cb8 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Always free references upon sequence header refresh

Also clear refpoc[] for intrabc frames. Fixes #146.

This changes sequence header parsing so that we no longer reset
c->have_seq_hdr to 0 if parsing of the most recent sequence header
failed. Rather, we will just continue with the old sequence header
and test any future sequence headers against this. This may help
error resilience in streams that periodically re-send their sequence
header.
parent 39b35e34
......@@ -3009,8 +3009,12 @@ int dav1d_submit_frame(Dav1dContext *const c) {
f->mvs_ref = dav1d_ref_create(f->sb128h * 32 * f->b4_stride *
sizeof(*f->mvs));
f->mvs = f->mvs_ref->data;
for (int i = 0; i < 7; i++)
f->refpoc[i] = f->refp[i].p.poc;
if (!f->frame_hdr.allow_intrabc) {
for (int i = 0; i < 7; i++)
f->refpoc[i] = f->refp[i].p.poc;
} else {
memset(f->refpoc, 0, sizeof(f->refpoc));
}
if (f->frame_hdr.use_ref_frame_mvs) {
for (int i = 0; i < 7; i++) {
const int refidx = f->frame_hdr.refidx[i];
......
......@@ -1046,15 +1046,11 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
Av1SequenceHeader hdr, *const hdr_ptr = c->have_seq_hdr ? &hdr : &c->seq_hdr;
memset(hdr_ptr, 0, sizeof(*hdr_ptr));
c->have_frame_hdr = 0;
if ((res = parse_seq_hdr(c, &gb, hdr_ptr)) < 0) {
c->have_seq_hdr = 0;
if ((res = parse_seq_hdr(c, &gb, hdr_ptr)) < 0)
return res;
}
if ((unsigned)res != len) {
c->have_seq_hdr = 0;
if ((unsigned)res != len)
goto error;
}
if (c->have_seq_hdr && memcmp(&hdr, &c->seq_hdr, sizeof(hdr))) {
if (!c->have_frame_hdr || memcmp(&hdr, &c->seq_hdr, sizeof(hdr))) {
for (int i = 0; i < 8; i++) {
if (c->refs[i].p.p.data[0])
dav1d_thread_picture_unref(&c->refs[i].p);
......@@ -1063,7 +1059,8 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
if (c->cdf[i].cdf)
dav1d_cdf_thread_unref(&c->cdf[i]);
}
c->seq_hdr = hdr;
if (c->have_seq_hdr)
c->seq_hdr = hdr;
}
c->have_seq_hdr = 1;
break;
......
......@@ -2054,7 +2054,9 @@ int av1_init_ref_mv_common(AV1_COMMON *cm,
const int ref_poc = cm->buffer_pool.frame_bufs[i].cur_frame_offset;
cm->ref_frame_sign_bias[1 + i] = get_relative_dist(cm, ref_poc, cur_poc) > 0;
}
av1_setup_motion_field(cm);
if (allow_ref_frame_mvs) {
av1_setup_motion_field(cm);
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment