[FFmpeg-devel] [RFC] LOAS (aka LATM) demuxer
Janne Grunau
janne-ffmpeg
Mon Aug 2 20:26:14 CEST 2010
On Mon, Aug 02, 2010 at 08:45:42PM +0300, Martin Storsj? wrote:
> On Sun, 1 Aug 2010, Janne Grunau wrote:
>
> > +static int loas_read_audio_sync_stream(AVFormatContext *s,
> > + struct latm_demux_context *latmctx)
> > +{
> > + ByteIOContext *pb = s->pb;
> > + int muxlength;
> > + uint8_t *buf = latmctx->buf + latmctx->pos;
> > + int size = latmctx->len - latmctx->pos;
> > +
> > + while (size >= 3) {
> > +
> > + if ((buf[0] << 3 | buf[1] >> 5) == LOAS_SYNC_WORD) {
> > +
> > + muxlength = ((buf[1] & 0x1f) << 8) | buf[2];
> > + if (muxlength+3 > size) {
> > + memmove(latmctx->buf, buf, size);
> > + buf = latmctx->buf;
> > + latmctx->pos = 0;
> > + latmctx->len = size + get_buffer(pb, latmctx->buf+size,
> > + LATM_MAX_FRAME_SIZE-size);
> > + } else {
> > + //av_log(s, AV_LOG_INFO, "LOAS frame of %d bytes\n", muxlength);
> > + return muxlength+3;
> > + }
> > + } else
> > + latmctx->pos++;
> > +
> > + size = latmctx->len - latmctx->pos;
>
> Wouldn't you want to reinitialize buf to latmctx->buf + latmctx->pos
> here, too? Otherwise, the else branch don't really have much effect.
yes, good catch. fixed and I think I should try to make it less
confusing by using only local vars and setting the buffer state
in the context before returning.
thanks
Janne
More information about the ffmpeg-devel
mailing list