shithub: dumb

Download patch

ref: 1dbeaf67c98af889a5a71fec6ad1e14e470461ac
parent: 2b2f154894d691a18ede7740a2c319d90b47a14d
author: Chris Moeller <[email protected]>
date: Mon Jan 11 04:00:01 EST 2010

{5/31/2006 8:36:12 PM}2006-05-30 03:57 UTC - kode54
- IT reader works around a broken file that has several of the instruments
  offset by two bytes from their indicated file offsets. Since the hack
  only checks for offset by two null bytes, it also assumes that the two
  bytes it can't read from the end are also zero. (bz_ult9.it)
- IT reader treats null instrument/sample/pattern offsets as empty items.
  (flight2.it, sherri.it)

git-tfs-id: [http://localhost:8080/tfs/DefaultCollection/]$/foobar2000/files/plugins.root;C94

--- a/dumb/src/it/itread.c
+++ b/dumb/src/it/itread.c
@@ -520,8 +520,20 @@
 
 static int it_read_sample_header(IT_SAMPLE *sample, unsigned char *convert, long *offset, DUMBFILE *f)
 {
+	/* XXX
 	if (dumbfile_mgetl(f) != IT_SAMPLE_SIGNATURE)
-		return -1;
+		return -1;*/
+	int hax = 0;
+	long s = dumbfile_mgetl(f);
+	if (s != IT_SAMPLE_SIGNATURE) {
+		if ( s == ( IT_SAMPLE_SIGNATURE >> 16 ) ) {
+			s <<= 16;
+			s |= dumbfile_mgetw(f);
+			if ( s != IT_SAMPLE_SIGNATURE )
+				return -1;
+			hax = 1;
+		}
+	}
 
 	dumbfile_getnc(sample->filename, 13, f);
 	sample->filename[13] = 0;
@@ -582,8 +594,13 @@
 
 	sample->vibrato_speed = dumbfile_getc(f);
 	sample->vibrato_depth = dumbfile_getc(f);
-	sample->vibrato_rate = dumbfile_getc(f);
-	sample->vibrato_waveform = dumbfile_getc(f);
+	if ( ! hax ) {
+		sample->vibrato_rate = dumbfile_getc(f);
+		sample->vibrato_waveform = dumbfile_getc(f);
+	} else {
+		sample->vibrato_rate = 0;
+		sample->vibrato_waveform = 0;
+	}
 	sample->max_resampling_quality = -1;
 
 	return dumbfile_error(f);
@@ -1183,6 +1200,27 @@
 	for (n = 0; n < n_components; n++) {
 		long offset;
 		int m;
+
+		/* XXX */
+		if ( component[n].offset == 0 ) {
+			switch (component[n].type) {
+				case IT_COMPONENT_INSTRUMENT:
+					memset( &sigdata->instrument[component[n].n], 0, sizeof(IT_INSTRUMENT) );
+					break;
+				case IT_COMPONENT_SAMPLE:
+					memset( &sigdata->sample[component[n].n], 0, sizeof(IT_SAMPLE) );
+					break;
+				case IT_COMPONENT_PATTERN:
+					{
+						IT_PATTERN * p = &sigdata->pattern[component[n].n];
+						p->entry = 0;
+						p->n_rows = 64;
+						p->n_entries = 0;
+					}
+					break;
+			}
+			continue;
+		}
 
 		if (it_seek(f, component[n].offset)) {
 			free(buffer);