diff options
Diffstat (limited to 'lib/rbcodec/codecs/libpcm/ieee_float.c')
-rw-r--r-- | lib/rbcodec/codecs/libpcm/ieee_float.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/rbcodec/codecs/libpcm/ieee_float.c b/lib/rbcodec/codecs/libpcm/ieee_float.c index 639390bcd5..97a7fcecd4 100644 --- a/lib/rbcodec/codecs/libpcm/ieee_float.c +++ b/lib/rbcodec/codecs/libpcm/ieee_float.c | |||
@@ -38,7 +38,7 @@ static bool set_format(struct pcm_format *format) | |||
38 | return false; | 38 | return false; |
39 | } | 39 | } |
40 | 40 | ||
41 | if (fmt->bitspersample != 32 && fmt->bitspersample != 64) | 41 | if (fmt->bitspersample != 16 && fmt->bitspersample != 32 && fmt->bitspersample != 64) |
42 | { | 42 | { |
43 | DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample: %d\n", | 43 | DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample: %d\n", |
44 | fmt->bitspersample); | 44 | fmt->bitspersample); |
@@ -114,6 +114,33 @@ static int decode(const uint8_t *inbuf, size_t inbufsize, | |||
114 | } | 114 | } |
115 | *outbufsize = inbufsize >> 2; | 115 | *outbufsize = inbufsize >> 2; |
116 | } | 116 | } |
117 | else if (fmt->bitspersample == 16) | ||
118 | { | ||
119 | for (i = 0; i < inbufsize; i += 2) | ||
120 | { | ||
121 | pcm = inbuf[0]|((inbuf[1]&0x03)<<8); | ||
122 | exp = ((inbuf[1]&0x7c)>>2)-15; | ||
123 | sgn = (inbuf[1] & 0x80)>>7; | ||
124 | |||
125 | if(exp == -15) | ||
126 | pcm =0; | ||
127 | else | ||
128 | { | ||
129 | pcm+=1<<10; | ||
130 | exp+=2; /*shift by 2 for rockbox fixed format*/ | ||
131 | if(exp>=0) | ||
132 | pcm <<= (exp); | ||
133 | else | ||
134 | pcm >>= (-exp); | ||
135 | |||
136 | if (sgn) | ||
137 | pcm = -pcm; | ||
138 | } | ||
139 | outbuf[i/2] = pcm; | ||
140 | inbuf += 2; | ||
141 | } | ||
142 | *outbufsize = inbufsize >> 1; | ||
143 | } | ||
117 | else | 144 | else |
118 | { | 145 | { |
119 | for (i = 0; i < inbufsize; i += 8) | 146 | for (i = 0; i < inbufsize; i += 8) |