-/*
- input data size =
- ffmpeg.c: do_audio_out()
- frame_bytes = enc->frame_size * 2 * enc->channels;
-*/
-
-// printf("sz=%d ",buf_size); fflush(stdout);
- if (!c->header_parsed) {
- int hdrsize = adx_encode_header(avctx,dst,buf_size);
- dst+=hdrsize;
- c->header_parsed = 1;
- }
-
- if (avctx->channels==1) {
- while(rest>=32) {
- adx_encode(dst,samples,c->prev);
- dst+=18;
- samples+=32;
- rest-=32;
- }
- } else {
- while(rest>=32*2) {
- short tmpbuf[32*2];
- int i;
-
- for(i=0;i<32;i++) {
- tmpbuf[i] = samples[i*2];
- tmpbuf[i+32] = samples[i*2+1];
- }
-
- adx_encode(dst,tmpbuf,c->prev);
- adx_encode(dst+18,tmpbuf+32,c->prev+1);
- dst+=18*2;
- samples+=32*2;
- rest-=32*2;
- }
- }
- return dst-frame;
-}
-
-#endif //CONFIG_ENCODERS
-
-static int is_adx(const unsigned char *buf,size_t bufsize)
-{
- int offset;
-
- if (buf[0]!=0x80) return 0;
- offset = (AV_RB32(buf)^0x80000000)+4;
- if (bufsize<offset || memcmp(buf+offset-6,"(c)CRI",6)) return 0;
- return offset;
-}
-
-/* return data offset or 6 */
-static int adx_decode_header(AVCodecContext *avctx,const unsigned char *buf,size_t bufsize)
-{
- int offset;
- int channels,freq,size;
-
- offset = is_adx(buf,bufsize);
- if (offset==0) return 0;
-
- channels = buf[7];
- freq = AV_RB32(buf+8);
- size = AV_RB32(buf+12);
-
-// printf("freq=%d ch=%d\n",freq,channels);
-
- avctx->sample_rate = freq;
- avctx->channels = channels;
- avctx->bit_rate = freq*channels*18*8/32;
-// avctx->frame_size = 18*channels;
-
- return offset;
-}
-
-#if 0
-static void dump(unsigned char *buf,size_t len)
-{
- int i;
- for(i=0;i<len;i++) {
- if ((i&15)==0) av_log(NULL, AV_LOG_DEBUG, "%04x ",i);
- av_log(NULL, AV_LOG_DEBUG, "%02x ",buf[i]);
- if ((i&15)==15) av_log(NULL, AV_LOG_DEBUG, "\n");
- }
- av_log(NULL, AV_LOG_ERROR, "\n");
-}
-#endif
-
-static int adx_decode_frame(AVCodecContext *avctx,
- void *data, int *data_size,
- uint8_t *buf0, int buf_size)
-{
- ADXContext *c = avctx->priv_data;
- short *samples = data;
- const uint8_t *buf = buf0;
- int rest = buf_size;
-
- if (!c->header_parsed) {
- int hdrsize = adx_decode_header(avctx,buf,rest);
- if (hdrsize==0) return -1;
- c->header_parsed = 1;
- buf += hdrsize;
- rest -= hdrsize;