[FFmpeg-devel] [PATCH] ADPCM IMA AMV encoder (try 1)

Vladimir Voroshilov voroshil
Sun Oct 7 09:21:12 CEST 2007

2007/10/6, Vladimir Voroshilov <voroshil at gmail.com>:
> Hi, All
> Since no reply was got in "Devel question : how to calculate
> frame_size in audio encoder (adpcm_encode_init) "' thread, i want (as
> suggested by Vitor) show you current version of ADPCM IMA AMV encoder
> in amv-codec-tools project.
> Due to fake codec tag (it uses PCM's 0x01 code) this codec can not be
> easily used outside AMV container.
> Number of 16-bit audio samples  per audio frame and audio frame size are
> calculated by folmulas below:
> samples_per_frame=audio_sample_rate/video_frame_rate
> audio_frame_size=(samples_per_frame/2)+8
> Current code sets frame_size to 0 inside adpcm_encode_init.
> frame_size receives real value at the end of avi_write_header:
> ============CUT=================
>    /*
>      HACK!!!
>      Set correct frame_size for audio stream
>     */
>     if(s->nb_streams > 1 && s->streams[1]->codec->codec_type ==
>             s->streams[1]->codec->frame_size=av_rescale(
>                     s->streams[1]->codec->sample_rate,
>                     s->streams[0]->codec->time_base.num,
>                     s->streams[0]->codec->time_base.den);
>     }
> ===========CUT==================
> I want to know how much attached patch is ugly/hackish and receive
> emproovement sugesstions.

Attached patch adpcm2.diff is updated version with trellis quantization.

> P.S. current code does not rearrange extra samples yet (i,e for
> arate=22050 and fps=16 real audio rate will be 16*(22050/16)=22048,
> proprietary encodec puts this two extra samples in last 16th frame). I
> will be happy to recevie good solution for extra samples.

Attached patch adpcm_samplerate_compensation.diff adds simple
sompensation: putting all extra samples into last frame of the second.

Vladimir Voroshilov     mailto:voroshil at gmail.com
JID: voroshil at gmail.com, voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
A non-text attachment was scrubbed...
Name: adpcm2.diff
Type: text/x-diff
Size: 4448 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071007/28bc6ede/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: adpcm_samplerate_compensate.diff
Type: text/x-diff
Size: 860 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071007/28bc6ede/attachment-0001.diff>

More information about the ffmpeg-devel mailing list