Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenloader/intern/readfile.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 743 Lines • ▼ Show 20 Lines | static void switch_endian_bh4(BHead4 *bhead) | ||||
| if ((bhead->code & 0xFFFF) == 0) { | if ((bhead->code & 0xFFFF) == 0) { | ||||
| bhead->code >>= 16; | bhead->code >>= 16; | ||||
| } | } | ||||
| if (bhead->code != ENDB) { | if (bhead->code != ENDB) { | ||||
| BLI_endian_switch_int32(&bhead->len); | BLI_endian_switch_int32(&bhead->len); | ||||
| BLI_endian_switch_int32(&bhead->SDNAnr); | BLI_endian_switch_int32(&bhead->SDNAnr); | ||||
| BLI_endian_switch_int32(&bhead->nr); | BLI_endian_switch_int32(&bhead->nr); | ||||
| BLI_endian_switch_uint32(&bhead->old); | |||||
| } | } | ||||
| } | } | ||||
| static void switch_endian_bh8(BHead8 *bhead) | static void switch_endian_bh8(BHead8 *bhead) | ||||
| { | { | ||||
| /* the ID_.. codes */ | /* the ID_.. codes */ | ||||
| if ((bhead->code & 0xFFFF) == 0) { | if ((bhead->code & 0xFFFF) == 0) { | ||||
| bhead->code >>= 16; | bhead->code >>= 16; | ||||
| } | } | ||||
| if (bhead->code != ENDB) { | if (bhead->code != ENDB) { | ||||
| BLI_endian_switch_int32(&bhead->len); | BLI_endian_switch_int32(&bhead->len); | ||||
| BLI_endian_switch_int32(&bhead->SDNAnr); | BLI_endian_switch_int32(&bhead->SDNAnr); | ||||
| BLI_endian_switch_int32(&bhead->nr); | BLI_endian_switch_int32(&bhead->nr); | ||||
| BLI_endian_switch_uint64(&bhead->old); | |||||
| } | } | ||||
| } | } | ||||
| static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8, int do_endian_swap) | static void bh4_from_bh8(BHead *bhead, BHead8 *bhead8) | ||||
| { | { | ||||
| BHead4 *bhead4 = (BHead4 *)bhead; | BHead4 *bhead4 = (BHead4 *)bhead; | ||||
| int64_t old; | int64_t old; | ||||
| bhead4->code = bhead8->code; | bhead4->code = bhead8->code; | ||||
| bhead4->len = bhead8->len; | bhead4->len = bhead8->len; | ||||
| if (bhead4->code != ENDB) { | if (bhead4->code != ENDB) { | ||||
| /* perform a endian swap on 64bit pointers, otherwise the pointer might map to zero | |||||
| * 0x0000000000000000000012345678 would become 0x12345678000000000000000000000000 | |||||
JacquesLucke: This is not necessary anymore, because the pointer has been endian switched before. | |||||
| */ | |||||
| if (do_endian_swap) { | |||||
| BLI_endian_switch_uint64(&bhead8->old); | |||||
| } | |||||
| /* this patch is to avoid a long long being read from not-eight aligned positions | /* this patch is to avoid a long long being read from not-eight aligned positions | ||||
| * is necessary on any modern 64bit architecture) */ | * is necessary on any modern 64bit architecture) */ | ||||
| memcpy(&old, &bhead8->old, 8); | memcpy(&old, &bhead8->old, 8); | ||||
| bhead4->old = (int)(old >> 3); | bhead4->old = (int)(old >> 3); | ||||
| bhead4->SDNAnr = bhead8->SDNAnr; | bhead4->SDNAnr = bhead8->SDNAnr; | ||||
| bhead4->nr = bhead8->nr; | bhead4->nr = bhead8->nr; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | if (!fd->is_eof) { | ||||
| readsize = fd->read(fd, &bhead8, sizeof(bhead8), NULL); | readsize = fd->read(fd, &bhead8, sizeof(bhead8), NULL); | ||||
| if (readsize == sizeof(bhead8) || bhead8.code == ENDB) { | if (readsize == sizeof(bhead8) || bhead8.code == ENDB) { | ||||
| if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { | if (fd->flags & FD_FLAGS_SWITCH_ENDIAN) { | ||||
| switch_endian_bh8(&bhead8); | switch_endian_bh8(&bhead8); | ||||
| } | } | ||||
| if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) { | if (fd->flags & FD_FLAGS_POINTSIZE_DIFFERS) { | ||||
| bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN)); | bh4_from_bh8(&bhead, &bhead8); | ||||
| } | } | ||||
| else { | else { | ||||
| /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */ | /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */ | ||||
| BLI_assert(sizeof(bhead) == sizeof(bhead8)); | BLI_assert(sizeof(bhead) == sizeof(bhead8)); | ||||
| memcpy(&bhead, &bhead8, MIN2(sizeof(bhead), sizeof(bhead8))); | memcpy(&bhead, &bhead8, MIN2(sizeof(bhead), sizeof(bhead8))); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 1,633 Lines • ▼ Show 20 Lines | |||||
| static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo) | static void direct_link_ipo(BlendDataReader *reader, Ipo *ipo) | ||||
| { | { | ||||
| BLO_read_list(reader, &(ipo->curve)); | BLO_read_list(reader, &(ipo->curve)); | ||||
| LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { | LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) { | ||||
| BLO_read_data_address(reader, &icu->bezt); | BLO_read_data_address(reader, &icu->bezt); | ||||
| BLO_read_data_address(reader, &icu->bp); | BLO_read_data_address(reader, &icu->bp); | ||||
| BLO_read_data_address(reader, &icu->driver); | BLO_read_data_address(reader, &icu->driver); | ||||
| /* Undo generic endian switching. */ | |||||
| if (BLO_read_requires_endian_switch(reader)) { | |||||
| BLI_endian_switch_int16(&icu->blocktype); | |||||
| if (icu->driver != NULL) { | |||||
| BLI_endian_switch_int16(&icu->driver->blocktype); | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Undo generic endian switching. */ | |||||
| if (BLO_read_requires_endian_switch(reader)) { | |||||
| BLI_endian_switch_int16(&ipo->blocktype); | |||||
| } | } | ||||
| } | } | ||||
| // XXX deprecated - old animation system | // XXX deprecated - old animation system | ||||
| static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist) | static void lib_link_nlastrips(BlendLibReader *reader, ID *id, ListBase *striplist) | ||||
| { | { | ||||
| LISTBASE_FOREACH (bActionStrip *, strip, striplist) { | LISTBASE_FOREACH (bActionStrip *, strip, striplist) { | ||||
| BLO_read_id_address(reader, id->lib, &strip->object); | BLO_read_id_address(reader, id->lib, &strip->object); | ||||
| ▲ Show 20 Lines • Show All 6,676 Lines • Show Last 20 Lines | |||||
This is not necessary anymore, because the pointer has been endian switched before.