Commit 19101cee authored by banan's avatar banan

Per reference swf/flv adpcm encoder.


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@8713 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent b750b5e5
...@@ -182,6 +182,9 @@ static int adpcm_encode_init(AVCodecContext *avctx) ...@@ -182,6 +182,9 @@ static int adpcm_encode_init(AVCodecContext *avctx)
avctx->frame_size = BLKSIZE * avctx->channels; avctx->frame_size = BLKSIZE * avctx->channels;
avctx->block_align = BLKSIZE; avctx->block_align = BLKSIZE;
break; break;
case CODEC_ID_ADPCM_SWF:
avctx->frame_size = 4*BLKSIZE * avctx->channels;
break;
default: default:
return -1; return -1;
break; break;
...@@ -513,6 +516,31 @@ static int adpcm_encode_frame(AVCodecContext *avctx, ...@@ -513,6 +516,31 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
samples += 8 * avctx->channels; samples += 8 * avctx->channels;
} }
break; break;
case CODEC_ID_ADPCM_SWF:
{
int i;
PutBitContext pb;
init_put_bits(&pb, dst, buf_size*8);
//Store AdpcmCodeSize
put_bits(&pb, 2, 2); //Set 4bits flash adpcm format
//Init the encoder state
for(i=0; i<avctx->channels; i++){
put_bits(&pb, 16, samples[i] & 0xFFFF);
put_bits(&pb, 6, c->status[i].step_index & 0x3F);
c->status[i].prev_sample = (signed short)samples[i];
}
for (i=0 ; i<4096 ; i++) {
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels*i]) & 0xF);
if (avctx->channels == 2)
put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1], samples[2*i+1]) & 0xF);
}
dst += (3 + 2048) * avctx->channels;
break;
}
case CODEC_ID_ADPCM_MS: case CODEC_ID_ADPCM_MS:
for(i=0; i<avctx->channels; i++){ for(i=0; i<avctx->channels; i++){
int predictor=0; int predictor=0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment