finally works now

Originally committed as revision 1966 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Nick Kurshev 22 years ago
parent 971eb237b7
commit 860208a400
  1. 90
      libavcodec/ra288.c

@ -231,12 +231,12 @@ static void unpack(unsigned short *tgt, unsigned char *src, int len)
{ {
int x,y,z; int x,y,z;
int n,temp; int n,temp;
int buffer[38]; int buffer[len];
for (x=0;x<len;tgt[x++]=0) for (x=0;x<len;tgt[x++]=0)
buffer[x]=9+(x&1); buffer[x]=9+(x&1);
for (x=y=z=0;x<38;x++) { for (x=y=z=0;x<len/*was 38*/;x++) {
n=buffer[y]-z; n=buffer[y]-z;
temp=src[x]; temp=src[x];
if (n<8) temp&=255>>(8-n); if (n<8) temp&=255>>(8-n);
@ -386,69 +386,69 @@ static void prodsum(float *tgt, float *src, int len, int n)
} }
} }
#ifndef max void * decode_block(AVCodecContext * avctx, unsigned char *in, signed short int *out)
#define max(a,b) ((a)>(b)?(a):(b)) {
#endif int x,y;
Real288_internal *glob=avctx->priv_data;
int cfs=((short*)(avctx->extradata))[3]; /* coded frame size 38 */
unsigned short int buffer[cfs];
unpack(buffer,in,cfs);
for (x=0;x<32;x++)
{
glob->phasep=(glob->phase=x&7)*5;
decode(glob,buffer[x]);
for (y=0;y<5;*(out++)=8*glob->output[glob->phasep+(y++)]);
if (glob->phase==3) update(glob);
}
return out;
}
/* Decode a block (celp) */ /* Decode a block (celp) */
static int ra288_decode_frame(AVCodecContext * avctx, static int ra288_decode_frame(AVCodecContext * avctx,
void *data, int *data_size, void *data, int *data_size,
uint8_t * buf, int buf_size) uint8_t * buf, int buf_size)
{ {
int x,y,z,bret;
unsigned short int buffer[buf_size];
unsigned char b[buf_size],*bp;
void *datao;
Real288_internal *glob=avctx->priv_data;
if(avctx->extradata_size>=6) if(avctx->extradata_size>=6)
{ {
int w=avctx->block_align; //((short*)(avctx->extradata))[0]; /* subpacket size */
int h=((short*)(avctx->extradata))[1]; //((short*)(avctx->extradata))[1]; /* subpacket height */
int cfs=((short*)(avctx->extradata))[3]; /* coded frame size */ //((short*)(avctx->extradata))[2]; /* subpacket flavour */
//((short*)(avctx->extradata))[3]; /* coded frame size */
//((short*)(avctx->extradata))[4]; /* codec's data length */
//((short*)(avctx->extradata))[5...] /* codec's data */
int z,bret;
void *datao;
int w=avctx->block_align; /* 228 */
int h=((short*)(avctx->extradata))[1]; /* 12 */
int cfs=((short*)(avctx->extradata))[3]; /* coded frame size 38 */
int i,j; int i,j;
unsigned char tb[h*w], *ptb;
if(buf_size<w*h) if(buf_size<w*h)
{ {
fprintf(stderr,"ffra288: warning! Context was not interleaved [%d<%d]\n",buf_size,w*h); fprintf(stderr,"ffra288: Error! Input buffer is too small [%d<%d]\n",buf_size,w*h);
goto no_interleave; return 0;
} }
bp = buf; datao = data;
ptb = buf;
/* Phase 0: deinterleave */
for (j = 0; j < h; j++) for (j = 0; j < h; j++)
for (i = 0; i < h/2; i++) for (i = 0; i < h/2; i++)
{ {
memcpy(&b[i*2*w+j*cfs], bp, cfs); memcpy(&tb[i*2*w+j*cfs],ptb,cfs);
bp += cfs; ptb += cfs;
if(bp-buf>buf_size)
{
fprintf(stderr,"ffra288: warning! Context was partly interleaved [%d<%d]\n",buf_size,w*h);
break;
}
} }
bret=bp-buf; /* Phase 1: decode */
bp = b; bret = ptb-buf;
for(z=0;z<bret;z+=cfs) { decode_block(avctx,&tb[z],(signed short *)data); data += 320; }
*data_size = data - datao;
return bret;
} }
else else
{ {
fprintf(stderr,"ffra288: warning! Context was not interleaved [%d<%d]\n",avctx->extradata_size,6); fprintf(stderr,"ffra288: Error: need extra data!!!\n");
no_interleave: return 0;
bret=buf_size;
bp = buf;
}
datao = data;
z=0;
while(z<bret)
{
unpack(buffer,&bp[z],32);
for (x=0;x<32;x++)
{
glob->phasep=(glob->phase=x&7)*5;
decode(glob,buffer[x]);
for (y=0;y<5;*(((int16_t *)data)++)=8*glob->output[glob->phasep+(y++)]);
if (glob->phase==3) update(glob);
}
z+=32;
} }
*data_size = data - datao;
return bret;
} }
AVCodec ra_288_decoder = AVCodec ra_288_decoder =

Loading…
Cancel
Save