diff options
author | Benjamin Larsson <banan@ludd.ltu.se> | 2007-04-11 13:10:13 +0000 |
---|---|---|
committer | Benjamin Larsson <banan@ludd.ltu.se> | 2007-04-11 13:10:13 +0000 |
commit | d64b88d440bcd2121bce8e7b15505396f0f1d118 (patch) | |
tree | b698e5bb0f9947e1368d3f209f680de93e709830 /libavcodec | |
parent | 3011c6f62e3cd670601f6f70b75dc177dc9a6ffb (diff) | |
download | ffmpeg-streaming-d64b88d440bcd2121bce8e7b15505396f0f1d118.zip ffmpeg-streaming-d64b88d440bcd2121bce8e7b15505396f0f1d118.tar.gz |
Per reference swf/flv adpcm encoder.
Originally committed as revision 8713 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/adpcm.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 57281d1..05cca3f 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -182,6 +182,9 @@ static int adpcm_encode_init(AVCodecContext *avctx) avctx->frame_size = BLKSIZE * avctx->channels; avctx->block_align = BLKSIZE; break; + case CODEC_ID_ADPCM_SWF: + avctx->frame_size = 4*BLKSIZE * avctx->channels; + break; default: return -1; break; @@ -513,6 +516,31 @@ static int adpcm_encode_frame(AVCodecContext *avctx, samples += 8 * avctx->channels; } 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: for(i=0; i<avctx->channels; i++){ int predictor=0; |