diff options
Diffstat (limited to 'apps')
-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 LIBOBJS = libdemac/parser.o libdemac/decoder.o libdemac/entropy.o libdemac/predictor.o libdemac/crc.o $(FILTERS) OBJS = demac.o wavwrite.o $(LIBOBJS) -CFLAGS = -Wall -O3 -Ilibdemac +CFLAGS = -Wall -g -O3 -Ilibdemac ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) 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, #else #define SCALE(x) (x) #endif + + if ((ape_ctx->channels==1) || ((ape_ctx->frameflags + & (APE_FRAMECODE_PSEUDO_STEREO|APE_FRAMECODE_STEREO_SILENCE)) + == APE_FRAMECODE_PSEUDO_STEREO)) { - if ((ape_ctx->channels==1) || (ape_ctx->frameflags & APE_FRAMECODE_PSEUDO_STEREO)) { - if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { - entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); + entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, + decoded0, NULL, count); + + if (ape_ctx->frameflags & APE_FRAMECODE_MONO_SILENCE) { /* We are pure silence, so we're done. */ return 0; - } else { - entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, NULL, count); } switch (ape_ctx->compressiontype) @@ -142,12 +145,14 @@ int ICODE_ATTR_DEMAC decode_chunk(struct ape_ctx_t* ape_ctx, } #endif } else { /* Stereo */ - if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { + entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, + decoded0, decoded1, count); + + if ((ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) + == APE_FRAMECODE_STEREO_SILENCE) { /* We are pure silence, so we're done. */ return 0; } - - entropy_decode(ape_ctx, inbuffer, firstbyte, bytesconsumed, decoded0, decoded1, count); /* Apply filters - compression type 1000 doesn't have any */ 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, ape_ctx->blocksdecoded += blockstodecode; - if (ape_ctx->frameflags & APE_FRAMECODE_STEREO_SILENCE) { + if ((ape_ctx->frameflags & APE_FRAMECODE_LEFT_SILENCE) + && ((ape_ctx->frameflags & APE_FRAMECODE_RIGHT_SILENCE) + || (decoded1 == NULL))) { /* We are pure silence, just memset the output buffer. */ memset(decoded0, 0, blockstodecode * sizeof(int32_t)); - memset(decoded1, 0, blockstodecode * sizeof(int32_t)); + if (decoded1 != NULL) + memset(decoded1, 0, blockstodecode * sizeof(int32_t)); } else { if (ape_ctx->fileversion > 3970) { 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 */ #define APE_FRAMECODE_MONO_SILENCE 1 -#define APE_FRAMECODE_STEREO_SILENCE 3 +#define APE_FRAMECODE_LEFT_SILENCE 1 /* same as mono */ +#define APE_FRAMECODE_RIGHT_SILENCE 2 +#define APE_FRAMECODE_STEREO_SILENCE 3 /* combined */ #define APE_FRAMECODE_PSEUDO_STEREO 4 #define PREDICTOR_ORDER 8 |