[FFmpeg-devel] [PATCH 2/3] Add single stream LATM/LOAS decoder

Michael Niedermayer michaelni
Tue Oct 19 10:11:22 CEST 2010


On Mon, Oct 18, 2010 at 07:37:14PM +0200, Janne Grunau wrote:
> The decoder is basicly just a wrapper around the AAC decoder.
> based on patch by Paul Kendall { paul <?t> kcbbs gen nz }
> ---
>  Changelog                |    1 +
>  configure                |    1 +
>  libavcodec/Makefile      |    2 +
>  libavcodec/aacdec.c      |    9 +-
>  libavcodec/aacdec.h      |    3 +
>  libavcodec/aaclatmdec.c  |  419 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/allcodecs.c   |    2 +
>  libavcodec/avcodec.h     |    3 +-
>  libavcodec/latm_parser.c |  119 +++++++++++++
>  9 files changed, 553 insertions(+), 6 deletions(-)
>  create mode 100644 libavcodec/aaclatmdec.c
>  create mode 100644 libavcodec/latm_parser.c
> 
> diff --git a/Changelog b/Changelog
> index 426a92d..b6ada6b 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -47,6 +47,7 @@ version <next>:
>  - SAP (Session Announcement Protocol, RFC 2974) muxer and demuxer
>  - cropdetect filter
>  - ffmpeg -crop* options removed
> +- single stream LATM/LOAS decoder
>  
>  
>  version 0.6:
> diff --git a/configure b/configure
> index 0e6e439..f3e65d4 100755
> --- a/configure
> +++ b/configure
> @@ -1187,6 +1187,7 @@ rdft_select="fft"
>  # decoders / encoders / hardware accelerators
>  aac_decoder_select="mdct rdft"
>  aac_encoder_select="mdct"
> +aac_latm_decoder_select="aac_decoder"
>  ac3_decoder_select="mdct ac3_parser"
>  alac_encoder_select="lpc"
>  amrnb_decoder_select="lsp"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 385ae02..bd5f041 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -52,6 +52,7 @@ OBJS-$(CONFIG_AAC_ENCODER)             += aacenc.o aaccoder.o    \
>                                            aacpsy.o aactab.o      \
>                                            psymodel.o iirfilter.o \
>                                            mpeg4audio.o
> +OBJS-$(CONFIG_AAC_LATM_DECODER)        += aaclatmdec.o
>  OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
>  OBJS-$(CONFIG_AC3_DECODER)             += ac3dec.o ac3dec_data.o ac3.o
>  OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3tab.o ac3.o
> @@ -576,6 +577,7 @@ OBJS-$(CONFIG_H264_PARSER)             += h264_parser.o h264.o            \
>                                            h264_loopfilter.o h264_cabac.o \
>                                            h264_cavlc.o h264_ps.o \
>                                            mpegvideo.o error_resilience.o
> +OBJS-$(CONFIG_AAC_LATM_PARSER)         += latm_parser.o
>  OBJS-$(CONFIG_MJPEG_PARSER)            += mjpeg_parser.o
>  OBJS-$(CONFIG_MLP_PARSER)              += mlp_parser.o mlp.o
>  OBJS-$(CONFIG_MPEG4VIDEO_PARSER)       += mpeg4video_parser.o h263.o \
> diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
> index 4306483..b2cf7b2 100644
> --- a/libavcodec/aacdec.c
> +++ b/libavcodec/aacdec.c
> @@ -516,7 +516,7 @@ static void reset_predictor_group(PredictorState *ps, int group_num)
>          ff_aac_spectral_codes[num], sizeof(ff_aac_spectral_codes[num][0]), sizeof(ff_aac_spectral_codes[num][0]), \
>          size);
>  
> -static av_cold int aac_decode_init(AVCodecContext *avctx)
> +av_cold int ff_aac_decode_init(AVCodecContext *avctx)
>  {
>      AACContext *ac = avctx->priv_data;
>  
> @@ -2068,8 +2068,7 @@ static int aac_decode_frame(AVCodecContext *avctx, void *data,
>  
>      return buf_size > buf_offset ? buf_consumed : buf_size;
>  }
> -
> -static av_cold int aac_decode_close(AVCodecContext *avctx)
> +av_cold int ff_aac_decode_close(AVCodecContext *avctx)
>  {
>      AACContext *ac = avctx->priv_data;
>      int i, type;
> @@ -2092,9 +2091,9 @@ AVCodec aac_decoder = {
>      AVMEDIA_TYPE_AUDIO,
>      CODEC_ID_AAC,
>      sizeof(AACContext),
> -    aac_decode_init,
> +    ff_aac_decode_init,
>      NULL,
> -    aac_decode_close,
> +    ff_aac_decode_close,
>      aac_decode_frame,
>      .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
>      .sample_fmts = (const enum SampleFormat[]) {
> diff --git a/libavcodec/aacdec.h b/libavcodec/aacdec.h
> index a16bfa0..fa1f1d0 100644
> --- a/libavcodec/aacdec.h
> +++ b/libavcodec/aacdec.h

> @@ -28,6 +28,9 @@
>  #include "avcodec.h"
>  #include "get_bits.h"
>  
> +av_cold int ff_aac_decode_init(AVCodecContext *avctx);
> +
> +av_cold int ff_aac_decode_close(AVCodecContext *avctx);
>  
>  int ff_aac_decode_frame_int(AVCodecContext *avctx, void *data,
>                              int *data_size, GetBitContext *gb);

does that av_cold in there have any effect?

[...]

> +struct LATMContext {
> +    AACContext      aac_ctx;
> +    int             initialized;         // initilized after a valid extradata is set
> +
> +    // parser data
> +    int             audio_mux_version_A; // LATM syntax version
> +    int             frame_length_type;   // 0/1 variable/fixed frame length
> +    int             frame_length;        // frame length for fixed frame length

doxy


> +};
> +
> +static inline uint32_t latm_get_value(GetBitContext *b)
> +{
> +    int length = get_bits(b, 2);

> +    uint32_t value = 0;
> +    int i;
> +    for (i = 0; i <= length; i++) {
> +        value <<= 8;
> +        value |= get_bits(b, 8);
> +    }
> +    return value;

isnt this
return get_bits_long((length+1)*8);
?


> +}
> +
> +//copied from ff_copy_pce_data() in mpeg4audio.c
> +static int parse_pce_data(GetBitContext *gb)
> +{
> +    int five_bit_ch, four_bit_ch, comment_size, bits;
> +    int offset = get_bits_count(gb);
> +
> +    skip_bits(gb, 10);                  //Tag, Object Type, Frequency
> +    five_bit_ch  = get_bits(gb, 4);     //Front
> +    five_bit_ch += get_bits(gb, 4);     //Side
> +    five_bit_ch += get_bits(gb, 4);     //Back
> +    four_bit_ch  = get_bits(gb, 2);     //LFE
> +    four_bit_ch += get_bits(gb, 3);     //Data
> +    five_bit_ch += get_bits(gb, 4);     //Coupling
> +    if (get_bits(gb, 1))                //Mono Mixdown
> +        skip_bits(gb, 4);
> +    if (get_bits(gb, 1))                //Stereo Mixdown
> +        skip_bits(gb, 4);
> +    if (get_bits(gb, 1))                //Matrix Mixdown
> +        skip_bits(gb, 3);

> +    for (bits = five_bit_ch*5+four_bit_ch*4; bits > 16; bits -= 16)
> +        skip_bits(gb, 16);
> +    if (bits)
> +        skip_bits(gb, bits);

skip_bits_long() ?


> +    align_get_bits(gb);
> +    comment_size = get_bits(gb, 8);

> +    for (; comment_size > 0; comment_size--)
> +        get_bits(gb, 8);

same



[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101019/cc082fbb/attachment.pgp>



More information about the ffmpeg-devel mailing list