mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
update brrUtils
This commit is contained in:
parent
8eaddcf070
commit
78baff55e8
2 changed files with 21 additions and 13 deletions
|
@ -22,13 +22,14 @@
|
||||||
|
|
||||||
#include "brrUtils.h"
|
#include "brrUtils.h"
|
||||||
|
|
||||||
void brrEncode(short* buf, unsigned char* out, long len) {
|
long brrEncode(short* buf, unsigned char* out, long len) {
|
||||||
if (len==0) return;
|
if (len==0) return 0;
|
||||||
// TODO
|
// TODO
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DO_ONE_SAMPLE \
|
#define DO_ONE_SAMPLE \
|
||||||
if (next&8) next|=0xfff8; \
|
if (next&8) next|=0xfffffff8; \
|
||||||
\
|
\
|
||||||
next<<=(buf[0]>>4); /* range */ \
|
next<<=(buf[0]>>4); /* range */ \
|
||||||
\
|
\
|
||||||
|
@ -39,10 +40,10 @@ void brrEncode(short* buf, unsigned char* out, long len) {
|
||||||
next+=(last1*15)/16; \
|
next+=(last1*15)/16; \
|
||||||
break; \
|
break; \
|
||||||
case 8: \
|
case 8: \
|
||||||
next+=(last1*61)/32-(last2*15)/16; \
|
next+=((last1*61)/32)-((last2*15)/16); \
|
||||||
break; \
|
break; \
|
||||||
case 12: \
|
case 12: \
|
||||||
next+=(last1*115)/64-(last2*13)/16; \
|
next+=((last1*115)/64)-((last2*13)/16); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
@ -54,8 +55,10 @@ void brrEncode(short* buf, unsigned char* out, long len) {
|
||||||
*out=next; \
|
*out=next; \
|
||||||
out++;
|
out++;
|
||||||
|
|
||||||
void brrDecode(unsigned char* buf, short* out, long len) {
|
long brrDecode(unsigned char* buf, short* out, long len) {
|
||||||
if (len==0) return;
|
if (len==0) return 0;
|
||||||
|
|
||||||
|
long total=0;
|
||||||
|
|
||||||
int last1=0;
|
int last1=0;
|
||||||
int last2=0;
|
int last2=0;
|
||||||
|
@ -68,15 +71,18 @@ void brrDecode(unsigned char* buf, short* out, long len) {
|
||||||
unsigned char control=buf[0];
|
unsigned char control=buf[0];
|
||||||
|
|
||||||
for (unsigned char j=1; j<9; j++) {
|
for (unsigned char j=1; j<9; j++) {
|
||||||
next=buf[j]&15;
|
next=buf[j]>>4;
|
||||||
DO_ONE_SAMPLE;
|
DO_ONE_SAMPLE;
|
||||||
|
|
||||||
next=buf[j]>>4;
|
next=buf[j]&15;
|
||||||
DO_ONE_SAMPLE;
|
DO_ONE_SAMPLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// end bit
|
// end bit
|
||||||
|
total+=16;
|
||||||
if (control&1) break;
|
if (control&1) break;
|
||||||
buf+=9;
|
buf+=9;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
|
@ -32,19 +32,21 @@ extern "C" {
|
||||||
* @param buf input data.
|
* @param buf input data.
|
||||||
* @param out output buffer. shall be at least 9*(len/16) shorts in size.
|
* @param out output buffer. shall be at least 9*(len/16) shorts in size.
|
||||||
* @param len input length (should be a multiple of 16. if it isn't, the output will be padded).
|
* @param len input length (should be a multiple of 16. if it isn't, the output will be padded).
|
||||||
|
* @return number of written samples.
|
||||||
*/
|
*/
|
||||||
void brrEncode(short* buf, unsigned char* out, long len);
|
long brrEncode(short* buf, unsigned char* out, long len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read len bytes from buf, decode BRR and output to out.
|
* read len bytes from buf, decode BRR and output to out.
|
||||||
* @param buf input data.
|
* @param buf input data.
|
||||||
* @param out output buffer. shall be at least 16*(len/9) shorts in size.
|
* @param out output buffer. shall be at least 16*(len/9) shorts in size.
|
||||||
* @param len input length (shall be a multiple of 9).
|
* @param len input length (shall be a multiple of 9).
|
||||||
|
* @return number of written bytes.
|
||||||
*/
|
*/
|
||||||
void brrDecode(unsigned char* buf, short* out, long len);
|
long brrDecode(unsigned char* buf, short* out, long len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue