Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoyuan Xiao <boyuan.xiao@argondesign.com>2018-10-15 18:37:08 +0300
committerRonald S. Bultje <rsbultje@gmail.com>2018-11-14 16:39:19 +0300
commit2f7eb1e9544b0b6f4ed3ff244d6869192b76fb4e (patch)
tree881a33cee893eca99b114843c3c9724e7f6482a7
parent0bf59f09b246f6266001ef57e5628282a9ea3920 (diff)
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).
-rw-r--r--src/obu.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/obu.c b/src/obu.c
index 5e901db..a62f34f 100644
--- a/src/obu.c
+++ b/src/obu.c
@@ -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",