Skip to content

Commit 54ab5fa

Browse files
author
synap
committed
2006-02-17 Dennis Smit <[email protected]>
* libvisual/lv_audio.c (visual_audio_normalise_spectrum): Use the standard log scale. * libvisual/lv_hashmap.c: Finally finished the iterator.
1 parent 6e4075e commit 54ab5fa

File tree

4 files changed

+81
-22
lines changed

4 files changed

+81
-22
lines changed

libvisual/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2006-02-17 Dennis Smit <[email protected]>
2+
3+
* libvisual/lv_audio.c (visual_audio_normalise_spectrum): Use the
4+
standard log scale.
5+
6+
* libvisual/lv_hashmap.c: Finally finished the iterator.
7+
18
2006-02-13 Dennis Smit <[email protected]>
29

310
* libvisual/lv_math.c: Added a bit more stuff.

libvisual/libvisual/lv_audio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Authors: Dennis Smit <[email protected]>
66
*
7-
* $Id: lv_audio.c,v 1.42 2006-02-13 20:54:08 synap Exp $
7+
* $Id: lv_audio.c,v 1.43 2006-02-17 22:00:17 synap Exp $
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU Lesser General Public License as
@@ -610,7 +610,7 @@ int visual_audio_normalise_spectrum (VisBuffer *buffer)
610610
{
611611
visual_log_return_val_if_fail (buffer != NULL, -VISUAL_ERROR_BUFFER_NULL);
612612

613-
visual_dft_log_scale (visual_buffer_get_data (buffer),
613+
visual_dft_log_scale_standard (visual_buffer_get_data (buffer),
614614
visual_buffer_get_data (buffer),
615615
visual_buffer_get_size (buffer) / sizeof (float));
616616

libvisual/libvisual/lv_hashmap.c

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Authors: Dennis Smit <[email protected]>
66
*
7-
* $Id: lv_hashmap.c,v 1.10 2006-02-05 18:45:57 synap Exp $
7+
* $Id: lv_hashmap.c,v 1.11 2006-02-17 22:00:17 synap Exp $
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU Lesser General Public License as
@@ -38,6 +38,9 @@ struct _HashmapIterContext {
3838
VisObject *object;
3939

4040
int index;
41+
int retrieved;
42+
int first;
43+
4144
VisListEntry *le;
4245
};
4346

@@ -130,6 +133,8 @@ static VisCollectionIter *hashmap_iter (VisCollection *collection)
130133
visual_object_initialize (VISUAL_OBJECT (context), TRUE, NULL);
131134
context->index = 0;
132135
context->le = NULL;
136+
context->retrieved = FALSE;
137+
context->first = TRUE;
133138

134139
iter = visual_collection_iter_new (hashmap_iter_assign, hashmap_iter_next, hashmap_iter_has_more,
135140
hashmap_iter_get_data, collection, VISUAL_OBJECT (context));
@@ -139,46 +144,91 @@ static VisCollectionIter *hashmap_iter (VisCollection *collection)
139144

140145
static void hashmap_iter_assign (VisCollectionIter *iter, VisCollection *collection, VisObject *itercontext, int index)
141146
{
147+
VisHashmap *hashmap = VISUAL_HASHMAP (collection);
148+
int i;
149+
150+
if (index >= hashmap->tablesize)
151+
return;
142152

153+
for (i = 0; i < index; i++) {
154+
hashmap_iter_next (iter, collection, itercontext);
155+
}
143156
}
144157

145158
static int hashmap_iter_has_more (VisCollectionIter *iter, VisCollection *collection, VisObject *itercontext)
146159
{
160+
VisHashmap *hashmap = VISUAL_HASHMAP (collection);
161+
HashmapIterContext *context = HASHMAP_ITERCONTEXT (itercontext);
162+
163+
if (context->index >= hashmap->tablesize)
164+
return FALSE;
165+
166+
/* First entry */
167+
if (context->first) {
168+
context->first = FALSE;
169+
170+
for (; context->index < hashmap->tablesize; context->index++) {
171+
if (visual_collection_size (VISUAL_COLLECTION (&hashmap->table[context->index].list)) > 0) {
172+
context->le = hashmap->table[context->index].list.head;
173+
context->retrieved = FALSE;
174+
175+
return TRUE;
176+
}
177+
}
178+
}
179+
180+
/* Check for next chain entry */
181+
if (context->le != NULL && context->le->next != NULL) {
182+
context->le = context->le->next;
183+
184+
return TRUE;
185+
}
186+
187+
/* No next in chain, next array entry */
188+
context->index++;
189+
for (; context->index < hashmap->tablesize; context->index++) {
190+
if (visual_collection_size (VISUAL_COLLECTION (&hashmap->table[context->index].list)) > 0) {
191+
context->le = hashmap->table[context->index].list.head;
192+
context->retrieved = FALSE;
193+
194+
return TRUE;
195+
}
196+
}
147197

198+
return FALSE;
148199
}
149200

150201
static void hashmap_iter_next (VisCollectionIter *iter, VisCollection *collection, VisObject *itercontext)
151202
{
152203
VisHashmap *hashmap = VISUAL_HASHMAP (collection);
153204
HashmapIterContext *context = HASHMAP_ITERCONTEXT (itercontext);
154-
int i;
155205

156-
if (context->index >= hashmap->size)
157-
return;
206+
if (context->retrieved == FALSE) {
207+
if (context->first == TRUE) {
208+
hashmap_iter_has_more (iter, collection, itercontext);
209+
210+
context->first = FALSE;
211+
}
158212

159-
/* FIXME initial start case doesn't work */
160-
if (context->le->next != NULL) {
161-
visual_list_next (&hashmap->table[i].list, &context->le);
213+
context->retrieved = TRUE;
162214

163215
return;
164216
}
165217

166-
/* Find the next valid chain */
167-
for (i = context->index; i < hashmap->size; i++) {
168-
VisHashmapEntry *mentry;
169-
170-
mentry = &hashmap->table[i];
171-
172-
173-
174-
}
218+
hashmap_iter_has_more (iter, collection, itercontext);
219+
context->retrieved = TRUE;
175220

176221
return;
177222
}
178223

179224
static void *hashmap_iter_get_data (VisCollectionIter *iter, VisCollection *collection, VisObject *itercontext)
180225
{
226+
HashmapIterContext *context = HASHMAP_ITERCONTEXT (itercontext);
227+
VisHashmapChainEntry *mentry;
228+
229+
mentry = context->le->data;
181230

231+
return mentry->data;
182232
}
183233

184234

libvisual/libvisual/lv_hashmap.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Authors: Dennis Smit <[email protected]>
66
*
7-
* $Id: lv_hashmap.h,v 1.7 2006-01-22 13:23:37 synap Exp $
7+
* $Id: lv_hashmap.h,v 1.8 2006-02-17 22:00:17 synap Exp $
88
*
99
* This program is free software; you can redistribute it and/or modify
1010
* it under the terms of the GNU Lesser General Public License as
@@ -52,19 +52,21 @@ typedef enum {
5252
struct _VisHashmap {
5353
VisCollection collection; /**< The VisCollection data. */
5454

55-
int tablesize;
56-
int size;
55+
int tablesize; /**< Size of the table array. */
56+
int size; /**< Number of entries stored in the VisHashmap. */
5757

58-
VisHashmapEntry *table;
58+
VisHashmapEntry *table; /**< The VisHashmap array. */
5959
};
6060

6161
/**
62+
* Private VisHashmap array entry.
6263
*/
6364
struct _VisHashmapEntry {
6465
VisList list;
6566
};
6667

6768
/**
69+
* Private VisHashmap chain entry.
6870
*/
6971
struct _VisHashmapChainEntry {
7072
VisHashmapKeyType keytype;

0 commit comments

Comments
 (0)