summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-08 17:17:49 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-08 17:17:49 -0700
commit1604299a5b4ed183187d7cb13df445d306eda60e (patch)
tree35d61548a77ed5f0a2ded4e603ca9ba50d6788e8 /dive.c
parent3a14076b1d1cbf78587305cc83802a1a9ae4c38c (diff)
downloadsubsurface-1604299a5b4ed183187d7cb13df445d306eda60e.tar.gz
Picture handling: change data structure to store offset instead timestamp
It makes no sense to store a 64bit time stamp with every picture. Even the 32bit offset (in seconds) from the dive start is WAY overkill. But switching to that makes the code much more simple in a number of spots. And makes what is saved to the XML file easier to read, too. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/dive.c b/dive.c
index a04c92198..c1b5cae87 100644
--- a/dive.c
+++ b/dive.c
@@ -2283,13 +2283,14 @@ static bool new_picture_for_dive(struct dive *d, char *filename)
void dive_create_picture(struct dive *d, char *filename, int shift_time)
{
+ timestamp_t timestamp;
if (!new_picture_for_dive(d, filename))
return;
struct picture *p = alloc_picture();
p->filename = filename;
- picture_load_exif_data(p);
- if (p->timestamp)
- p->timestamp += shift_time;
+ picture_load_exif_data(p, &timestamp);
+ if (timestamp)
+ p->offset = timestamp - d->when + shift_time;
dive_add_picture(d, p);
dive_set_geodata_from_picture(d, p);
}
@@ -2298,7 +2299,7 @@ void dive_add_picture(struct dive *d, struct picture *newpic)
{
struct picture **pic_ptr = &d->picture_list;
/* let's keep the list sorted by time */
- while( *pic_ptr && (*pic_ptr)->timestamp < newpic->timestamp )
+ while( *pic_ptr && (*pic_ptr)->offset < newpic->offset )
pic_ptr = &(*pic_ptr)->next;
newpic->next = *pic_ptr;
*pic_ptr = newpic;