[FFmpeg-devel] [PATCH] RTP depacketizer for AMR
Martin Storsjö
martin
Wed Jan 27 21:16:54 CET 2010
On Wed, 27 Jan 2010, Martin Storsj? wrote:
> On Wed, 27 Jan 2010, Ronald S. Bultje wrote:
>
> > > + /* Make sure we've got a local buffer for storing the packet
> > > + * while returning one frame at a time. */
> > > + if (!data->buf || data->buf_size < len) {
> > > + av_freep(&data->buf);
> > > + data->buf_size = len;
> > > + data->buf = av_malloc(data->buf_size);
> > > + if (!data->buf) {
> > > + av_log(ctx, AV_LOG_ERROR, "Out of memory\n");
> > > + return AVERROR_NOMEM;
> > > + }
> > > + }
> >
> > *_dyn_pkt_buf.
>
> Will have a look at that.
The way this buffer currently is used, is that we malloc one initially and
copy the RTP packet into it. We only free it and malloc a larger one if we
encounter larger packets that don't fit into the current buffer, otherwise
we reuse the current buffer.
With url_open_dyn_packet_buf, wouldn't I have to allocate a new one each
time, write the RTP packet to be buffered into it, then url_close_dyn_buf
to get the pointer to the buffered data, then free it after using it? To
me, that feels like an awful lot of extra overhead compared to keeping one
single buffer and just reallocating it if a bigger one is needed.
// Martin
More information about the ffmpeg-devel
mailing list