[FFmpeg-devel] [PATCH] ADPCM IMA AMV encoder (try 1)
Vladimir Voroshilov
voroshil
Sat Oct 6 14:14:41 CEST 2007
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.
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.
--
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: adpcm.diff
Type: text/x-diff
Size: 3119 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071006/4ce19e4f/attachment.diff>
More information about the ffmpeg-devel
mailing list