[SCM] libgroove/upstream: fingerprint sink: raw fingerprint is int32_t not uint32_t
andrewrk-guest at users.alioth.debian.org
andrewrk-guest at users.alioth.debian.org
Mon Apr 21 07:10:45 UTC 2014
The following commit has been merged in the upstream branch:
commit c08e78d5a1563567fd5b4df9e9185aeacf0fadf7
Author: Andrew Kelley <superjoe30 at gmail.com>
Date: Sun Apr 20 23:56:58 2014 -0700
fingerprint sink: raw fingerprint is int32_t not uint32_t
* add more error checks for chromaprint functions
* change the type of encode/decode from void to int32_t
diff --git a/example/fingerprint.c b/example/fingerprint.c
index c9fb37b..e45a4d8 100644
--- a/example/fingerprint.c
+++ b/example/fingerprint.c
@@ -53,10 +53,10 @@ int main(int argc, char * argv[]) {
info.item->file->filename);
if (raw) {
int size;
- uint32_t *raw_fingerprint;
- groove_fingerprinter_decode(info.fingerprint, (void*)&raw_fingerprint, &size);
+ int32_t *raw_fingerprint;
+ groove_fingerprinter_decode(info.fingerprint, &raw_fingerprint, &size);
for (int i = 0; i < size; i += 1) {
- printf("%"PRIu32"\n", raw_fingerprint[i]);
+ printf("%"PRId32"\n", raw_fingerprint[i]);
}
} else {
printf("%s\n", info.fingerprint);
diff --git a/groovefingerprinter/fingerprinter.c b/groovefingerprinter/fingerprinter.c
index 3907f5c..018b10a 100644
--- a/groovefingerprinter/fingerprinter.c
+++ b/groovefingerprinter/fingerprinter.c
@@ -59,8 +59,14 @@ static int emit_track_info(struct GrooveFingerprinterPrivate *p) {
info->item = p->info_head;
info->duration = p->track_duration;
- chromaprint_finish(p->chroma_ctx);
- chromaprint_get_fingerprint(p->chroma_ctx, &info->fingerprint);
+ if (!chromaprint_finish(p->chroma_ctx)) {
+ av_log(NULL, AV_LOG_ERROR, "unable to finish chromaprint\n");
+ return -1;
+ }
+ if (!chromaprint_get_fingerprint(p->chroma_ctx, &info->fingerprint)) {
+ av_log(NULL, AV_LOG_ERROR, "unable to get fingerprint\n");
+ return -1;
+ }
groove_queue_put(p->info_queue, info);
@@ -122,7 +128,9 @@ static void *print_thread(void *arg) {
if (p->info_head) {
emit_track_info(p);
}
- chromaprint_start(p->chroma_ctx, 44100, 2);
+ if (!chromaprint_start(p->chroma_ctx, 44100, 2)) {
+ av_log(NULL, AV_LOG_ERROR, "unable to start fingerprint\n");
+ }
p->track_duration = 0.0;
p->info_head = buffer->item;
p->info_pos = buffer->pos;
@@ -131,7 +139,9 @@ static void *print_thread(void *arg) {
double buffer_duration = buffer->frame_count / (double)buffer->format.sample_rate;
p->track_duration += buffer_duration;
p->album_duration += buffer_duration;
- chromaprint_feed(p->chroma_ctx, buffer->data[0], buffer->frame_count * 2);
+ if (!chromaprint_feed(p->chroma_ctx, buffer->data[0], buffer->frame_count * 2)) {
+ av_log(NULL, AV_LOG_ERROR, "unable to feed fingerprint\n");
+ }
pthread_mutex_unlock(&p->info_head_mutex);
groove_buffer_unref(buffer);
@@ -283,6 +293,11 @@ int groove_fingerprinter_attach(struct GrooveFingerprinter *printer,
groove_queue_reset(p->info_queue);
p->chroma_ctx = chromaprint_new(CHROMAPRINT_ALGORITHM_DEFAULT);
+ if (!p->chroma_ctx) {
+ groove_fingerprinter_detach(printer);
+ av_log(NULL, AV_LOG_ERROR, "unable to allocate chromaprint\n");
+ return -1;
+ }
if (groove_sink_attach(p->sink, playlist) < 0) {
groove_fingerprinter_detach(printer);
@@ -368,16 +383,16 @@ void groove_fingerprinter_free_info(struct GrooveFingerprinterInfo *info) {
info->fingerprint = NULL;
}
-int groove_fingerprinter_encode(void *fp, int size, char **encoded_fp) {
+int groove_fingerprinter_encode(int32_t *fp, int size, char **encoded_fp) {
int encoded_size;
return chromaprint_encode_fingerprint(fp, size,
CHROMAPRINT_ALGORITHM_DEFAULT, (void*)encoded_fp, &encoded_size, 1);
}
-int groove_fingerprinter_decode(char *encoded_fp, void **fp, int *size) {
+int groove_fingerprinter_decode(char *encoded_fp, int32_t **fp, int *size) {
int algorithm;
int encoded_size = strlen(encoded_fp);
- return chromaprint_decode_fingerprint(encoded_fp, encoded_size, fp, size,
+ return chromaprint_decode_fingerprint(encoded_fp, encoded_size, (void**)fp, size,
&algorithm, 1);
}
diff --git a/groovefingerprinter/fingerprinter.h b/groovefingerprinter/fingerprinter.h
index 2fe6e9a..69aa012 100644
--- a/groovefingerprinter/fingerprinter.h
+++ b/groovefingerprinter/fingerprinter.h
@@ -86,7 +86,7 @@ void groove_fingerprinter_position(struct GrooveFingerprinter *printer,
* groove_fingerprinter_dealloc().
*
* Parameters:
- * - fp: pointer to an array of unsigned 32-bit integers representing the raw
+ * - fp: pointer to an array of signed 32-bit integers representing the raw
* fingerprint to be encoded
* - size: number of items in the raw fingerprint
* - encoded_fp: pointer to a pointer, where the encoded fingerprint will be
@@ -95,7 +95,7 @@ void groove_fingerprinter_position(struct GrooveFingerprinter *printer,
* Returns:
* - 0 on error, 1 on success
*/
-int groove_fingerprinter_encode(void *fp, int size, char **encoded_fp);
+int groove_fingerprinter_encode(int32_t *fp, int size, char **encoded_fp);
/**
* Uncompress and base64-decode an encoded fingerprint
@@ -107,13 +107,13 @@ int groove_fingerprinter_encode(void *fp, int size, char **encoded_fp);
* - encoded_fp: Pointer to an encoded fingerprint
* - encoded_size: Size of the encoded fingerprint in bytes
* - fp: Pointer to a pointer, where the decoded raw fingerprint (array
- * of unsigned 32-bit integers) will be stored
+ * of signed 32-bit integers) will be stored
* - size: Number of items in the returned raw fingerprint
*
* Returns:
* - 0 on error, 1 on success
*/
-int groove_fingerprinter_decode(char *encoded_fp, void **fp, int *size);
+int groove_fingerprinter_decode(char *encoded_fp, int32_t **fp, int *size);
void groove_fingerprinter_dealloc(void *ptr);
--
libgroove packaging
More information about the pkg-multimedia-commits
mailing list