ref: a579cb8f538002be9e65bd9c2f43782d28d89282
parent: 7c4cbbf8d9b0deb06f67cd402a22136014abba45
author: James Almer <jamrial@gmail.com>
date: Fri Jul 17 08:49:54 EDT 2020
obu: reduce scope of some variables Cosmetic change.
--- a/src/obu.c
+++ b/src/obu.c
@@ -1198,7 +1198,6 @@
const unsigned init_bit_pos = dav1d_get_bits_pos(&gb);
const unsigned init_byte_pos = init_bit_pos >> 3;
- const unsigned pkt_bytelen = init_byte_pos + len;
// We must have read a whole number of bytes at this point (1 byte
// for the header and whole bytes at a time when reading the
@@ -1342,6 +1341,7 @@
// The current bit position is a multiple of 8 (because we
// just aligned it) and less than 8*pkt_bytelen because
// otherwise the overrun check would have fired.
+ const unsigned pkt_bytelen = init_byte_pos + len;
const unsigned bit_pos = dav1d_get_bits_pos(&gb);
assert((bit_pos & 7) == 0);
assert(pkt_bytelen >= (bit_pos >> 3));
@@ -1368,16 +1368,12 @@
const enum ObuMetaType meta_type = dav1d_get_uleb128(&gb);
const int meta_type_len = (dav1d_get_bits_pos(&gb) - init_bit_pos) >> 3;
if (gb.error) goto error;
- Dav1dRef *ref;
- Dav1dContentLightLevel *content_light;
- Dav1dMasteringDisplay *mastering_display;
- Dav1dITUTT35 *itut_t35_metadata;
switch (meta_type) {
- case OBU_META_HDR_CLL:
- ref = dav1d_ref_create(sizeof(Dav1dContentLightLevel));
+ case OBU_META_HDR_CLL: {
+ Dav1dRef *ref = dav1d_ref_create(sizeof(Dav1dContentLightLevel));
if (!ref) return DAV1D_ERR(ENOMEM);
- content_light = ref->data;
+ Dav1dContentLightLevel *const content_light = ref->data;
memset(content_light, 0, sizeof(*content_light));
content_light->max_content_light_level = dav1d_get_bits(&gb, 16);
@@ -1395,10 +1391,11 @@
c->content_light = content_light;
c->content_light_ref = ref;
break;
+ }
case OBU_META_HDR_MDCV: {
- ref = dav1d_ref_create(sizeof(Dav1dMasteringDisplay));
+ Dav1dRef *ref = dav1d_ref_create(sizeof(Dav1dMasteringDisplay));
if (!ref) return DAV1D_ERR(ENOMEM);
- mastering_display = ref->data;
+ Dav1dMasteringDisplay *const mastering_display = ref->data;
memset(mastering_display, 0, sizeof(*mastering_display));
for (int i = 0; i < 3; i++) {
@@ -1447,9 +1444,9 @@
goto error;
}
- ref = dav1d_ref_create(sizeof(Dav1dITUTT35) + payload_size * sizeof(uint8_t));
+ Dav1dRef *ref = dav1d_ref_create(sizeof(Dav1dITUTT35) + payload_size * sizeof(uint8_t));
if (!ref) return DAV1D_ERR(ENOMEM);
- itut_t35_metadata = ref->data;
+ Dav1dITUTT35 *const itut_t35_metadata = ref->data;
// We need our public headers to be C++ compatible, so payload can't be
// a flexible array member