[FFmpeg-devel] [RFC] LOAS (aka LATM) demuxer
Martin Storsjö
martin
Mon Aug 2 19:45:42 CEST 2010
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.
> + }
> +
> + return -1;
> +}
// Martin
More information about the ffmpeg-devel
mailing list