[FFmpeg-devel] [PATCH] Lego Mindstorms ADPCM IMA codec

Michael Niedermayer michaelni
Tue Aug 24 01:53:02 CEST 2010


On Tue, Aug 03, 2010 at 09:34:32AM +0200, Rafa?l Carr? wrote:
> Add a new codec since it differs a bit from ADPCM IMA WAV
> Pretend to support S16 sample format and do the conversion from/to U8,
> so we can use existing code
> Still untested on real Lego

a new encoder should be tested before commit
we dont want to create invalid files

[...]
> @@ -482,6 +487,28 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
>  /*    n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */
>  
>      switch(avctx->codec->id) {
> +    case CODEC_ID_ADPCM_IMA_RSO:
> +        n = buf_size * 2; /* number of samples (4bits per sample) */
> +
> +        for(i=0; i<n; i++) {
> +            samples[i] += 1<<15;                            /* s16 -> u16 */
> +            samples[i] = (unsigned short)samples[i] >> 8;   /* u16 -> u8  */
> +        }

this isnt modifying the input array is it?


[...]
> @@ -1034,6 +1065,20 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
>              src += 4*st;
>          }
>          break;
> +    case CODEC_ID_ADPCM_IMA_RSO:
> +        while(src < buf + buf_size){
> +            short s;
> +            s = adpcm_ima_expand_nibble(&c->status[0], *src >> 4    , 3);
> +            s <<= 8;    /* u8  -> u16 */
> +            s -= 1<<15; /* u16 -> s16 */
> +            *samples++ = s;

the use of short in this code is likely slow on some cpus


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100824/08b49499/attachment.pgp>



More information about the ffmpeg-devel mailing list