[FFmpeg-devel] [PATCH] LATM Parser & LATM/AAC Decoder

Diego Biurrun diego
Mon Apr 20 13:22:49 CEST 2009


On Mon, Apr 20, 2009 at 07:11:41PM +1200, Paul Kendall wrote:
> After a long delay and some thinking...
> The first patch is for a LATM Parser and LATM/AAC Decoder using
> libfaad2. The second patch is to add support for LATM to mpegts & 
> mpeg.

Why use libfaad when we now have a native AAC decoder?

> Please comment and I'll endeavor to to get any fixes done ASAP.
> 
> --- libavcodec/latmaac.c	(revision 0)
> +++ libavcodec/latmaac.c	(revision 0)
> @@ -0,0 +1,398 @@
> +/**
> + * @file latmaac.c

libavcodec/ prefix

> +#define min(a,b) ((a)<(b) ? (a) : (b))

FFMIN

> +typedef struct AACDecoder
> +{

{ on the same line

> +static void readGASpecificConfig(int audioObjectType, GetBitContext *b, PutBitContext *o)

Please break overly long lines, same below.

> +        if (audioObjectType == 17 ||
> +                audioObjectType == 19 ||
> +                audioObjectType == 20 ||
> +                audioObjectType == 23) {

weird indentation

> +    if (audioObjectType == 1 || audioObjectType == 2 || audioObjectType == 3
> +            || audioObjectType == 4 || audioObjectType == 6 || audioObjectType == 7) {
> +        readGASpecificConfig(audioObjectType, b, &o);

ditto

> +    if (audio_mux_version == 1) {                // audioMuxVersion
> +        parser->audio_mux_version_A = get_bits(b, 1);
> +    }

pointless {}

> +        if (audio_mux_version == 1) {
> +            // taraFullness
> +            latm_get_value(b);
> +        }

pointless {}

> +    if (!NeAACDecDecode2(decoder->aac_decoder, &info, tempbuf, bufsize, &out, max_size)) {
> +        return -1;
> +    }

ditto

> +    if (!decoder->aac_decoder) {
> +        return -1;
> +    }

ditto

> --- libavcodec/latm_parser.c	(revision 0)
> +++ libavcodec/latm_parser.c	(revision 0)
> @@ -0,0 +1,119 @@
> +
> +/**
> + * @file latm_parser.c

libavcodec/ prefix

> +typedef struct LATMParseContext{

nit: space before {

> +static int latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf,
> +                               int buf_size) {

{ on the next line

> +    LATMParseContext *s = s1->priv_data;
> +    ParseContext *pc = &s->pc;
> +    int pic_found, i;
> +    uint32_t state;
> +
> +    pic_found = pc->frame_start_found;
> +    state = pc->state;

Some of this could be aligned.

> +    if(!pic_found){
> +        for(i=0; i<buf_size; i++){
> +            state = (state<<8) | buf[i];
> +            if((state & LATM_MASK) == LATM_HEADER) {
> +                i++;
> +                s->count = - i;
> +                pic_found=1;
> +                break;
> +            }
> +        }
> +    }
> +
> +    if(pic_found){
> +        /* EOF considered as end of frame */
> +        if (buf_size == 0)
> +            return 0;
> +        if((state & LATM_SIZE_MASK) - s->count <= buf_size) {
> +            pc->frame_start_found = 0;
> +            pc->state = -1;
> +            return (state & LATM_SIZE_MASK) - s->count;

space between if/for and (, same below

> +	}
> +    }

wrong indent

> +    pc->frame_start_found = pic_found;
> +    pc->state = state;

align

> +static int latm_parse(AVCodecParserContext *s1,
> +                           AVCodecContext *avctx,
> +                           const uint8_t **poutbuf, int *poutbuf_size,
> +                           const uint8_t *buf, int buf_size)

weird indentation

> +        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
> +            *poutbuf = NULL;
> +            *poutbuf_size = 0;
> +            return buf_size;
> +        }
> +    }
> +    *poutbuf = buf;
> +    *poutbuf_size = buf_size;
> +    return next;

align

Diego



More information about the ffmpeg-devel mailing list