ref: 1ddd4cb83b1a214798a047fcec7b50f4f0234369
parent: 39b35e34c85c07dc21c4242d1372934a674cac22
author: Ronald S. Bultje <[email protected]>
date: Thu Nov 8 11:20:26 EST 2018
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.
--- a/src/decode.c
+++ b/src/decode.c
@@ -3009,8 +3009,12 @@
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];
--- a/src/obu.c
+++ b/src/obu.c
@@ -1046,15 +1046,11 @@
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 @@
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;
--- a/src/ref_mvs.c
+++ b/src/ref_mvs.c
@@ -2054,7 +2054,9 @@
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;
}