adx: cosmetics: general pretty-printing and comment clean-up

This commit is contained in:
Justin Ruggles
2011-11-19 17:46:15 -05:00
parent fbc79a9101
commit 8db67610c0

View File

@ -38,10 +38,14 @@ static av_cold int adx_decode_init(AVCodecContext *avctx)
return 0;
}
/* 18 bytes <-> 32 samples */
static void adx_decode(int16_t *out,const unsigned char *in,
ADXChannelState *prev)
/**
* Decode 32 samples from 18 bytes.
*
* A 16-bit scalar value is applied to 32 residuals, which then have a
* 2nd-order LPC filter applied to it to form the output signal for a single
* channel.
*/
static void adx_decode(int16_t *out, const uint8_t *in, ADXChannelState *prev)
{
int scale = AV_RB16(in);
int i;
@ -52,14 +56,14 @@ static void adx_decode(int16_t *out,const unsigned char *in,
s2 = prev->s2;
for (i = 0; i < 16; i++) {
d = in[i];
d = ((signed char)d >> 4);
d = (signed char)d >> 4;
s0 = (BASEVOL * d * scale + SCALE1 * s1 - SCALE2 * s2) >> 14;
s2 = s1;
s1 = av_clip_int16(s0);
*out++ = s1;
d = in[i];
d = ((signed char)(d<<4) >> 4);
d = (signed char)(d << 4) >> 4;
s0 = (BASEVOL * d * scale + SCALE1 * s1 - SCALE2 * s2) >> 14;
s2 = s1;
s1 = av_clip_int16(s0);
@ -67,10 +71,9 @@ static void adx_decode(int16_t *out,const unsigned char *in,
}
prev->s1 = s1;
prev->s2 = s2;
}
static void adx_decode_stereo(int16_t *out,const unsigned char *in,
static void adx_decode_stereo(int16_t *out,const uint8_t *in,
ADXChannelState *prev)
{
short tmp[32*2];
@ -84,14 +87,24 @@ static void adx_decode_stereo(int16_t *out,const unsigned char *in,
}
}
/* return data offset or 0 */
static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)
/**
* Decode stream header.
*
* @param avctx codec context
* @param buf packet data
* @param bufsize packet size
* @return data offset or 0 if header is invalid
*/
static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
int bufsize)
{
int offset;
if (buf[0]!=0x80) return 0;
if (buf[0] != 0x80)
return 0;
offset = (AV_RB32(buf) ^ 0x80000000) + 4;
if (bufsize<offset || memcmp(buf+offset-6,"(c)CRI",6)) return 0;
if (bufsize < offset || memcmp(buf + offset - 6, "(c)CRI", 6))
return 0;
avctx->channels = buf[7];
avctx->sample_rate = AV_RB32(buf + 8);
@ -100,8 +113,7 @@ static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size
return offset;
}
static int adx_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
static int adx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf0 = avpkt->data;
@ -113,7 +125,8 @@ static int adx_decode_frame(AVCodecContext *avctx,
if (!c->header_parsed) {
int hdrsize = adx_decode_header(avctx, buf, rest);
if (hdrsize==0) return -1;
if (!hdrsize)
return -1;
c->header_parsed = 1;
buf += hdrsize;
rest -= hdrsize;
@ -172,4 +185,3 @@ AVCodec ff_adpcm_adx_decoder = {
.decode = adx_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"),
};