[Ffmpeg-devel] [PATCH] RTP payload format for AMR
Michael Niedermayer
michaelni
Fri Mar 9 22:10:50 CET 2007
Hi
On Fri, Mar 09, 2007 at 09:31:47PM +0530, Kite Flyer wrote:
> Hi Michael,
>
> Please see inline. New patch is attached.
>
> Thanks,
> Subrata
>
> On 3/8/07, Michael Niedermayer <michaelni at gmx.at> wrote:
> >Hi
> >
> >On Thu, Mar 08, 2007 at 06:21:34PM +0530, Kite Flyer wrote:
> >[...]
> >> >
> >> >
> >> >[...]
> >> >
> >> >> + //TODO: find a way to pack maximum number of frames based on
> >> >max_payload_size
> >> >
> >> >yes
> >> >
> >>
> >> Keeping it as fixed no of frames as of now.
> >>
> >> payload format requires that all speech data frames be written after
> >> all frame headers i.e. ToC. If encoder always generates constant bit
> >> rate frames then offset of data frames can be calculated and maximum
> >> no of frames can be packed. But if encoder can generate variable bit
> >> rate frames, then two memory areas can be taken: one for ToC and
> >> another for data but the memcpy to concatenate the memories would be
> >> expensive per send.
> >
> >no, copying a ToC (that ends at about 50 byte per second is totally
> >negligible)
> >
> >8khz (only one supported by AMR NB) / 160 (frame size) = 50 (1 byte Toc
> >bytes)
> >
> >additionally AMR is low bitrate stuff so copying the encoded bitstream
> >around cannot be timeconsuming, copying part of it even less so ...
> >
>
> OK. Implemented at the cost of having a static buffer in rtp_send_amr
> routine. No more amr specific code in RTPDemuxContext common code. Now
non constant static and global arrays are forbidden in libav* (with exceptions
for debug code and arrays which are initalized once but never changed)
2 RTP instances could not coexist otherwise ...
one easy way to pack the AMR frames is:
uint8_t *toc_buf= s->buf;
uint8_t *buf= s->buf + TOC_MAX;
payload_size= s->buf_ptr - buf + size;
if( s->foobar >= TOC_MAX
|| TOC_MAX + payload_size > sizeof(s->buf)
|| s->foobar + 1 + payload_size > s->max_payload_size){
memmove(buf - s->foobar, toc_buf, s->foobar);
send (buf - s->foobar, s->foobar + s->buf_ptr - buf);
s->buf_ptr= buf;
s->foobar=0;
}
toc_buf[ s->foobar++ ]= toc_byte
memcpy(s->buf_ptr, input, size);
s->buf_ptr+= size;
[...]
> + /* append speech data after ToC and send */
trailing whitespace (this is forbidden in svn)
[...]
> + flen = packed_size[ft];
> + if (flen > 0)
> + {
> + if (size >= flen)
isnt flen always == size if so this code isnt needed, also packed_size[] isnt
needed OTOH if flen can be != size id like to know how that is possible
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070309/763ffafb/attachment.pgp>
More information about the ffmpeg-devel
mailing list