ref: 2f7eb1e9544b0b6f4ed3ff244d6869192b76fb4e
parent: 0bf59f09b246f6266001ef57e5628282a9ea3920
author: Boyuan Xiao <boyuan.xiao@argondesign.com>
date: Mon Oct 15 12:37:08 EDT 2018
Fix parsing segmentation data in parse_frame_hdr The first memset is dead code: if primary_ref_frame is PRIMARY_REF_NONE then segmentation.update_data is always true. The patch removes this memset and explains why the copy in the other branch is correct. The second memset should always fire: if segmentation is not enabled for this frame, the seg_data structure should be set to zero rather than copied from a reference frame (see section 5.9.14 of the AV1 spec).
--- a/src/obu.c
+++ b/src/obu.c
@@ -616,21 +616,17 @@
hdr->segmentation.seg_data.preskip = 1;
}
}
- } else if (hdr->primary_ref_frame == PRIMARY_REF_NONE) {
- memset(&hdr->segmentation.seg_data, 0, sizeof(Av1SegmentationDataSet));
- for (int i = 0; i < NUM_SEGMENTS; i++)
- hdr->segmentation.seg_data.d[i].ref = -1;
} else {
+ // segmentation.update_data was false so we should copy
+ // segmentation data from the reference frame.
+ assert(hdr->primary_ref_frame != PRIMARY_REF_NONE);
const int pri_ref = hdr->refidx[hdr->primary_ref_frame];
hdr->segmentation.seg_data = c->refs[pri_ref].seg_data;
}
- } else if (hdr->primary_ref_frame == PRIMARY_REF_NONE) {
+ } else {
memset(&hdr->segmentation.seg_data, 0, sizeof(Av1SegmentationDataSet));
for (int i = 0; i < NUM_SEGMENTS; i++)
hdr->segmentation.seg_data.d[i].ref = -1;
- } else {
- const int pri_ref = hdr->refidx[hdr->primary_ref_frame];
- hdr->segmentation.seg_data = c->refs[pri_ref].seg_data;
}
#if DEBUG_FRAME_HDR
printf("HDR: post-segmentation: off=%ld\n",