Commit 2f7eb1e9 authored by boyuanxiao-argondesign's avatar boyuanxiao-argondesign Committed by Ronald S. Bultje

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).
parent 0bf59f09
......@@ -616,21 +616,17 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
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",
......
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