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

Vladimir Voroshilov voroshil
Thu Oct 11 17:59:30 CEST 2007


2007/10/8, Benjamin Larsson <banan at ludd.ltu.se>:
> Hi.
>
> Vladimir Voroshilov wrote:
> > 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 ==
> >> CODEC_TYPE_AUDIO) {
> >>             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.
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> >
> > --- ffmpeg.orig/libavcodec/adpcm.c    2007-10-04 22:21:14.000000000 +0700
> > +++ ffmpeg/libavcodec/adpcm.c 2007-10-07 13:10:50.000000000 +0700
> > @@ -146,6 +146,7 @@
> >      int channel; /* for stereo MOVs, decode left, then decode right, then tell it's decoded */
> >      ADPCMChannelStatus status[2];
> >      short sample_buffer[32]; /* hold left samples while waiting for right samples */
> > +    int extra_samples_count; //number of samples to put into next frame
> >
>
> Maybe name this extra_amv_samples instead. And can you submit doxygen
> comments for adpcm_compress_trellis() ?
>

Variable is renamed,  trellis implemented.
Patch in attachement.


-- 
Regards,
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: adpcm4.diff
Type: text/x-diff
Size: 4770 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071011/7dcd0d37/attachment.diff>



More information about the ffmpeg-devel mailing list