diff options
author | Jens Arnold <amiconn@rockbox.org> | 2008-12-21 23:49:02 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2008-12-21 23:49:02 +0000 |
commit | dca9f42cdf577f6ca0b2abde6680e495d2a3373a (patch) | |
tree | 994a21216ec011e365b16bd7157cd1bd218e2a42 /apps/codecs/demac | |
parent | 9ea8840b29e778054db61caaef2433dbd51e865e (diff) | |
download | rockbox-dca9f42cdf577f6ca0b2abde6680e495d2a3373a.tar.gz rockbox-dca9f42cdf577f6ca0b2abde6680e495d2a3373a.zip |
Fix decoding of stereo frames with silence in only one channel. * Make the standalone decoder contain debugging information.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19552 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/demac')
-rw-r--r-- | apps/codecs/demac/Makefile | 2 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/decoder.c | 21 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/entropy.c | 7 | ||||
-rw-r--r-- | apps/codecs/demac/libdemac/parser.h | 4 |
4 files changed, 22 insertions, 12 deletions
diff --git a/apps/codecs/demac/Makefile b/apps/codecs/demac/Makefile index c366237480..7843be6e49 100644 --- a/apps/codecs/demac/Makefile +++ b/apps/codecs/demac/Makefile | |||
@@ -4,7 +4,7 @@ FILTERS = libdemac/filter_16_11.o libdemac/filter_64_11.o libdemac/filter_256_13 | |||
4 | LIBOBJS = libdemac/parser.o libdemac/decoder.o libdemac/entropy.o libdemac/predictor.o libdemac/crc.o $(FILTERS) | 4 | LIBOBJS = libdemac/parser.o libdemac/decoder.o libdemac/entropy.o libdemac/predictor.o libdemac/crc.o $(FILTERS) |
5 | OBJS = demac.o wavwrite.o $(LIBOBJS) | 5 | OBJS = demac.o wavwrite.o $(LIBOBJS) |
6 | 6 | ||
7 | CFLAGS = -Wall -O3 -Ilibdemac | 7 | CFLAGS = -Wall -g -O3 -Ilibdemac |
8 | 8 | ||
9 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) | 9 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) |
10 | EXT = .exe | 10 | EXT = .exe |
diff --git a/apps/codecs/demac/libdemac/decoder.c b/apps/codecs/demac/libdemac/decoder.c index 2200faf187..0763c11037 100644 --- a/apps/codecs/demac/libdemac/decoder.c +++ b/apps/codecs/demac/libdemac/decoder.c | |||
@@ -89,14 +89,17 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, | |||
89 | #else | 89 | #else |
90 | #define SCALE(x) (x) | 90 | #define SCALE(x) (x) |
91 | #endif | 91 | #endif |
92 | |||
93 | if ((ape_ctx->channels==1) || ((ape_ctx->frameflags | ||
94 | & (APE_FRAMECODE_PSEUDO_STEREO|APE_FRAMECODE_STEREO_SILENCE)) | ||
95 | == APE_FRAMECODE_PSEUDO_STEREO)) { | ||
92 | 96 | ||
93 | if ((ape_ctx->channels==1) || (ape_ctx->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) { | 97 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, |
94 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { | 98 | decoded0, NULL, count); |
95 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); | 99 | |
100 | if (ape_ctx->frameflags & APE_FRAMECODE_MONO_SILENCE) { | ||
96 | /* We are pure silence, so we're done. */ | 101 | /* We are pure silence, so we're done. */ |
97 | return 0; | 102 | return 0; |
98 | } else { | ||
99 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, NULL, count); | ||
100 | } | 103 | } |
101 | 104 | ||
102 | switch (ape_ctx->compressiontype) | 105 | switch (ape_ctx->compressiontype) |
@@ -142,12 +145,14 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, | |||
142 | } | 145 | } |
143 | #endif | 146 | #endif |
144 | } else { /* Stereo */ | 147 | } else { /* Stereo */ |
145 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { | 148 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, |
149 | decoded0, decoded1, count); | ||
150 | |||
151 | if ((ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) | ||
152 | == APE_FRAMECODE_STEREO_SILENCE) { | ||
146 | /* We are pure silence, so we're done. */ | 153 | /* We are pure silence, so we're done. */ |
147 | return 0; | 154 | return 0; |
148 | } | 155 | } |
149 | |||
150 | entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); | ||
151 | 156 | ||
152 | /* Apply filters - compression type 1000 doesn't have any */ | 157 | /* Apply filters - compression type 1000 doesn't have any */ |
153 | switch (ape_ctx->compressiontype) | 158 | switch (ape_ctx->compressiontype) |
diff --git a/apps/codecs/demac/libdemac/entropy.c b/apps/codecs/demac/libdemac/entropy.c index 54b5cc57b6..24f5932de6 100644 --- a/apps/codecs/demac/libdemac/entropy.c +++ b/apps/codecs/demac/libdemac/entropy.c | |||
@@ -430,10 +430,13 @@ void ICODE_ATTR_DEMAC entropy_decode(struct ape_ctx_t* ape_ctx, | |||
430 | 430 | ||
431 | ape_ctx->blocksdecoded += blockstodecode; | 431 | ape_ctx->blocksdecoded += blockstodecode; |
432 | 432 | ||
433 | if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { | 433 | if ((ape_ctx->frameflags & APE_FRAMECODE_LEFT_SILENCE) |
434 | && ((ape_ctx->frameflags & APE_FRAMECODE_RIGHT_SILENCE) | ||
435 | || (decoded1 == NULL))) { | ||
434 | /* We are pure silence, just memset the output buffer. */ | 436 | /* We are pure silence, just memset the output buffer. */ |
435 | memset(decoded0, 0, blockstodecode * sizeof(int32_t)); | 437 | memset(decoded0, 0, blockstodecode * sizeof(int32_t)); |
436 | memset(decoded1, 0, blockstodecode * sizeof(int32_t)); | 438 | if (decoded1 != NULL) |
439 | memset(decoded1, 0, blockstodecode * sizeof(int32_t)); | ||
437 | } else { | 440 | } else { |
438 | if (ape_ctx->fileversion > 3970) { | 441 | if (ape_ctx->fileversion > 3970) { |
439 | while (LIKELY(blockstodecode--)) { | 442 | while (LIKELY(blockstodecode--)) { |
diff --git a/apps/codecs/demac/libdemac/parser.h b/apps/codecs/demac/libdemac/parser.h index 53157f7681..6f07deac12 100644 --- a/apps/codecs/demac/libdemac/parser.h +++ b/apps/codecs/demac/libdemac/parser.h | |||
@@ -50,7 +50,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA | |||
50 | */ | 50 | */ |
51 | 51 | ||
52 | #define APE_FRAMECODE_MONO_SILENCE 1 | 52 | #define APE_FRAMECODE_MONO_SILENCE 1 |
53 | #define APE_FRAMECODE_STEREO_SILENCE 3 | 53 | #define APE_FRAMECODE_LEFT_SILENCE 1 /* same as mono */ |
54 | #define APE_FRAMECODE_RIGHT_SILENCE 2 | ||
55 | #define APE_FRAMECODE_STEREO_SILENCE 3 /* combined */ | ||
54 | #define APE_FRAMECODE_PSEUDO_STEREO 4 | 56 | #define APE_FRAMECODE_PSEUDO_STEREO 4 |
55 | 57 | ||
56 | #define PREDICTOR_ORDER 8 | 58 | #define PREDICTOR_ORDER 8 |