summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Bryant <bryant@rockbox.org>2006-04-22 21:32:16 +0000
committerDave Bryant <bryant@rockbox.org>2006-04-22 21:32:16 +0000
commit736df4b43bac64e64607efd427543e7678acfed1 (patch)
tree6ff3129ca4f36db3af0d186e70d8312121e673b6
parent83ce56846a65ce14b2410d07da8fcc4790e0b6f7 (diff)
downloadrockbox-736df4b43bac64e64607efd427543e7678acfed1.tar.gz
rockbox-736df4b43bac64e64607efd427543e7678acfed1.tar.bz2
rockbox-736df4b43bac64e64607efd427543e7678acfed1.zip
Revert the previous commit because it seemed to break the 4G Gray Sim,
although I can't figure out why or how, and I can't reproduce problem here... git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9766 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libwavpack/unpack.c33
-rw-r--r--apps/codecs/libwavpack/wavpack.h13
-rw-r--r--apps/codecs/libwavpack/words.c20
-rw-r--r--apps/codecs/libwavpack/wputils.c14
4 files changed, 29 insertions, 51 deletions
diff --git a/apps/codecs/libwavpack/unpack.c b/apps/codecs/libwavpack/unpack.c
index 5bb4467440..dcc9bf5bf9 100644
--- a/apps/codecs/libwavpack/unpack.c
+++ b/apps/codecs/libwavpack/unpack.c
@@ -128,7 +128,7 @@ int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd)
signed char *byteptr = wpmd->data;
struct decorr_pass *dpp;
- if (!(wps->wphdr.flags & MONO_DATA))
+ if (!(wps->wphdr.flags & MONO_FLAG))
termcnt /= 2;
if (termcnt > wps->num_terms)
@@ -140,7 +140,7 @@ int read_decorr_weights (WavpackStream *wps, WavpackMetadata *wpmd)
while (--dpp >= wps->decorr_passes && termcnt--) {
dpp->weight_A = restore_weight (*byteptr++);
- if (!(wps->wphdr.flags & MONO_DATA))
+ if (!(wps->wphdr.flags & MONO_FLAG))
dpp->weight_B = restore_weight (*byteptr++);
}
@@ -170,7 +170,7 @@ int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd)
if (wps->wphdr.version == 0x402 && (wps->wphdr.flags & HYBRID_FLAG)) {
byteptr += 2;
- if (!(wps->wphdr.flags & MONO_DATA))
+ if (!(wps->wphdr.flags & MONO_FLAG))
byteptr += 2;
}
@@ -180,7 +180,7 @@ int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd)
dpp->samples_A [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8)));
byteptr += 4;
- if (!(wps->wphdr.flags & MONO_DATA)) {
+ if (!(wps->wphdr.flags & MONO_FLAG)) {
dpp->samples_B [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
dpp->samples_B [1] = exp2s ((short)(byteptr [2] + (byteptr [3] << 8)));
byteptr += 4;
@@ -198,7 +198,7 @@ int read_decorr_samples (WavpackStream *wps, WavpackMetadata *wpmd)
dpp->samples_A [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
byteptr += 2;
- if (!(wps->wphdr.flags & MONO_DATA)) {
+ if (!(wps->wphdr.flags & MONO_FLAG)) {
dpp->samples_B [m] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
byteptr += 2;
}
@@ -322,7 +322,7 @@ int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_co
///////////////////// handle version 4 mono data /////////////////////////
- if (flags & MONO_DATA) {
+ if (flags & MONO_FLAG) {
eptr = buffer + sample_count;
i = get_words (buffer, sample_count, flags, &wps->w, &wps->wvbits);
@@ -394,20 +394,9 @@ int32_t unpack_samples (WavpackContext *wpc, int32_t *buffer, uint32_t sample_co
fixup_samples (wps, buffer, i);
if (flags & FLOAT_DATA)
- float_normalize (buffer, (flags & MONO_DATA) ? i : i * 2,
+ float_normalize (buffer, (flags & MONO_FLAG) ? i : i * 2,
127 - wps->float_norm_exp + wpc->norm_offset);
- if (flags & FALSE_STEREO) {
- int32_t *dptr = buffer + i * 2;
- int32_t *sptr = buffer + i;
- int32_t c = i;
-
- while (c--) {
- *--dptr = *--sptr;
- *--dptr = *sptr;
- }
- }
-
wps->sample_index += i;
wps->crc = crc;
@@ -706,12 +695,12 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_
shift += 21 - (flags & BYTES_STORED) * 8; // this provides RockBox with 28-bit (+sign)
if (flags & FLOAT_DATA) {
- float_values (wps, buffer, (flags & MONO_DATA) ? sample_count : sample_count * 2);
+ float_values (wps, buffer, (flags & MONO_FLAG) ? sample_count : sample_count * 2);
return;
}
if (flags & INT32_DATA) {
- uint32_t count = (flags & MONO_DATA) ? sample_count : sample_count * 2;
+ uint32_t count = (flags & MONO_FLAG) ? sample_count : sample_count * 2;
int sent_bits = wps->int32_sent_bits, zeros = wps->int32_zeros;
int ones = wps->int32_ones, dups = wps->int32_dups;
int32_t *dptr = buffer;
@@ -732,7 +721,7 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_
}
if (shift > 0) {
- if (!(flags & MONO_DATA))
+ if (!(flags & MONO_FLAG))
sample_count *= 2;
while (sample_count--)
@@ -741,7 +730,7 @@ static void fixup_samples (WavpackStream *wps, int32_t *buffer, uint32_t sample_
else if (shift < 0) {
shift = -shift;
- if (!(flags & MONO_DATA))
+ if (!(flags & MONO_FLAG))
sample_count *= 2;
while (sample_count--)
diff --git a/apps/codecs/libwavpack/wavpack.h b/apps/codecs/libwavpack/wavpack.h
index 3128328e49..593af7831d 100644
--- a/apps/codecs/libwavpack/wavpack.h
+++ b/apps/codecs/libwavpack/wavpack.h
@@ -76,19 +76,11 @@ typedef struct {
#define SRATE_LSB 23
#define SRATE_MASK (0xfL << SRATE_LSB)
-#define FALSE_STEREO 0x40000000 // block is stereo, but data is mono
-
#define IGNORED_FLAGS 0x18000000 // reserved, but ignore if encountered
#define NEW_SHAPING 0x20000000 // use IIR filter for negative shaping
-#define UNKNOWN_FLAGS 0x80000000 // also reserved, but refuse decode if
+#define UNKNOWN_FLAGS 0xC0000000 // also reserved, but refuse decode if
// encountered
-#define MONO_DATA (MONO_FLAG | FALSE_STEREO)
-
-#define MIN_STREAM_VERS 0x402 // lowest stream version we'll decode
-#define MAX_STREAM_VERS 0x410 // highest stream version we'll decode
-#define CUR_STREAM_VERS 0x403 // stream version we are writing now
-
//////////////////////////// WavPack Metadata /////////////////////////////////
// This is an internal representation of metadata.
@@ -434,6 +426,5 @@ void WavpackAddWrapper (WavpackContext *wpc, void *data, uint32_t bcount);
int WavpackStartBlock (WavpackContext *wpc, uchar *begin, uchar *end);
int WavpackPackSamples (WavpackContext *wpc, int32_t *sample_buffer, uint32_t sample_count);
uint32_t WavpackFinishBlock (WavpackContext *wpc);
-void WavpackUpdateNumSamples (WavpackContext *wpc, void *first_block);
-void *WavpackGetWrapperLocation (void *first_block);
+
diff --git a/apps/codecs/libwavpack/words.c b/apps/codecs/libwavpack/words.c
index c7a8047d03..ccbd77f8f9 100644
--- a/apps/codecs/libwavpack/words.c
+++ b/apps/codecs/libwavpack/words.c
@@ -151,14 +151,14 @@ int read_entropy_vars (WavpackStream *wps, WavpackMetadata *wpmd)
{
uchar *byteptr = wpmd->data;
- if (wpmd->byte_length != ((wps->wphdr.flags & MONO_DATA) ? 6 : 12))
+ if (wpmd->byte_length != ((wps->wphdr.flags & MONO_FLAG) ? 6 : 12))
return FALSE;
wps->w.c [0].median [0] = exp2s (byteptr [0] + (byteptr [1] << 8));
wps->w.c [0].median [1] = exp2s (byteptr [2] + (byteptr [3] << 8));
wps->w.c [0].median [2] = exp2s (byteptr [4] + (byteptr [5] << 8));
- if (!(wps->wphdr.flags & MONO_DATA)) {
+ if (!(wps->wphdr.flags & MONO_FLAG)) {
wps->w.c [1].median [0] = exp2s (byteptr [6] + (byteptr [7] << 8));
wps->w.c [1].median [1] = exp2s (byteptr [8] + (byteptr [9] << 8));
wps->w.c [1].median [2] = exp2s (byteptr [10] + (byteptr [11] << 8));
@@ -215,7 +215,7 @@ int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
wps->w.c [0].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8));
byteptr += 2;
- if (!(wps->wphdr.flags & MONO_DATA)) {
+ if (!(wps->wphdr.flags & MONO_FLAG)) {
wps->w.c [1].slow_level = exp2s (byteptr [0] + (byteptr [1] << 8));
byteptr += 2;
}
@@ -224,7 +224,7 @@ int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
wps->w.bitrate_acc [0] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16;
byteptr += 2;
- if (!(wps->wphdr.flags & MONO_DATA)) {
+ if (!(wps->wphdr.flags & MONO_FLAG)) {
wps->w.bitrate_acc [1] = (int32_t)(byteptr [0] + (byteptr [1] << 8)) << 16;
byteptr += 2;
}
@@ -233,7 +233,7 @@ int read_hybrid_profile (WavpackStream *wps, WavpackMetadata *wpmd)
wps->w.bitrate_delta [0] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
byteptr += 2;
- if (!(wps->wphdr.flags & MONO_DATA)) {
+ if (!(wps->wphdr.flags & MONO_FLAG)) {
wps->w.bitrate_delta [1] = exp2s ((short)(byteptr [0] + (byteptr [1] << 8)));
byteptr += 2;
}
@@ -257,7 +257,7 @@ void update_error_limit (struct words_data *w, uint32_t flags)
{
int bitrate_0 = (w->bitrate_acc [0] += w->bitrate_delta [0]) >> 16;
- if (flags & MONO_DATA) {
+ if (flags & MONO_FLAG) {
if (flags & HYBRID_BITRATE) {
int slow_log_0 = (w->c [0].slow_level + SLO) >> SLS;
@@ -326,13 +326,13 @@ int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags,
register struct entropy_data *c = w->c;
int csamples;
- if (!(flags & MONO_DATA))
+ if (!(flags & MONO_FLAG))
nsamples *= 2;
for (csamples = 0; csamples < nsamples; ++csamples) {
uint32_t ones_count, low, mid, high;
- if (!(flags & MONO_DATA))
+ if (!(flags & MONO_FLAG))
c = w->c + (csamples & 1);
if (!(w->c [0].median [0] & ~1) && !w->holding_zero && !w->holding_one && !(w->c [1].median [0] & ~1)) {
@@ -435,7 +435,7 @@ int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags,
w->holding_zero = ~w->holding_one & 1;
}
- if ((flags & HYBRID_FLAG) && ((flags & MONO_DATA) || !(csamples & 1)))
+ if ((flags & HYBRID_FLAG) && ((flags & MONO_FLAG) || !(csamples & 1)))
update_error_limit (w, flags);
if (ones_count == 0) {
@@ -484,7 +484,7 @@ int32_t get_words (int32_t *buffer, int nsamples, uint32_t flags,
c->slow_level = c->slow_level - ((c->slow_level + SLO) >> SLS) + mylog2 (mid);
}
- return (flags & MONO_DATA) ? csamples : (csamples / 2);
+ return (flags & MONO_FLAG) ? csamples : (csamples / 2);
}
// Read a single unsigned value from the specified bitstream with a value
diff --git a/apps/codecs/libwavpack/wputils.c b/apps/codecs/libwavpack/wputils.c
index 7fabc7ab34..7a6cc44ad4 100644
--- a/apps/codecs/libwavpack/wputils.c
+++ b/apps/codecs/libwavpack/wputils.c
@@ -69,10 +69,9 @@ WavpackContext *WavpackOpenFileInput (read_stream infile, char *error)
return NULL;
}
- if ((wps->wphdr.flags & UNKNOWN_FLAGS) || wps->wphdr.version < MIN_STREAM_VERS ||
- wps->wphdr.version > MAX_STREAM_VERS) {
- strcpy_loc (error, "invalid WavPack file!");
- return NULL;
+ if ((wps->wphdr.flags & UNKNOWN_FLAGS) || wps->wphdr.version < 0x402 || wps->wphdr.version > 0x40f) {
+ strcpy_loc (error, "invalid WavPack file!");
+ return NULL;
}
if (wps->wphdr.block_samples && wps->wphdr.total_samples != (uint32_t) -1)
@@ -171,7 +170,7 @@ uint32_t WavpackUnpackSamples (WavpackContext *wpc, int32_t *buffer, uint32_t sa
if (bcount == (uint32_t) -1)
break;
- if (wps->wphdr.version < MIN_STREAM_VERS || wps->wphdr.version > MAX_STREAM_VERS) {
+ if (wps->wphdr.version < 0x402 || wps->wphdr.version > 0x40f) {
strcpy_loc (wpc->error_message, "invalid WavPack file!");
break;
}
@@ -342,8 +341,7 @@ static uint32_t read_next_header (read_stream infile, WavpackHeader *wphdr)
sp = buffer;
if (*sp++ == 'w' && *sp == 'v' && *++sp == 'p' && *++sp == 'k' &&
- !(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 &&
- sp [4] >= (MIN_STREAM_VERS & 0xff) && sp [4] <= (MAX_STREAM_VERS & 0xff)) {
+ !(*++sp & 1) && sp [2] < 16 && !sp [3] && sp [5] == 4 && sp [4] >= 2 && sp [4] <= 0xf) {
memcpy (wphdr, buffer, sizeof (*wphdr));
little_endian_to_native (wphdr, WavpackHeaderFormat);
return bytes_skipped;
@@ -454,7 +452,7 @@ int WavpackSetConfiguration (WavpackContext *wpc, WavpackConfig *config, uint32_
memcpy (wps->wphdr.ckID, "wvpk", 4);
wps->wphdr.ckSize = sizeof (WavpackHeader) - 8;
wps->wphdr.total_samples = wpc->total_samples;
- wps->wphdr.version = CUR_STREAM_VERS;
+ wps->wphdr.version = 0x403;
wps->wphdr.flags = flags;
pack_init (wpc);