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

Alex Converse alex.converse
Wed Oct 20 05:35:32 CEST 2010


On Mon, Oct 18, 2010 at 10:37 AM, Janne Grunau <janne-ffmpeg at jannau.net> wrote:
> The decoder is basicly just a wrapper around the AAC decoder.
> based on patch by Paul Kendall { paul <?t> kcbbs gen nz }
> ---

...

> diff --git a/libavcodec/aaclatmdec.c b/libavcodec/aaclatmdec.c
> new file mode 100644
> index 0000000..229e486
> --- /dev/null
> +++ b/libavcodec/aaclatmdec.c

...

> +static void latm_read_ga_specific_config(int audio_object_type,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MPEG4AudioConfig *c,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? GetBitContext *gb)
> +{
> + ? ?int ext_flag;
> +
> + ? ?skip_bits(gb, 1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? // framelen_flag
> + ? ?if (get_bits(gb, 1)) ? ? ? ? ? ? ? ? ? ? ? ? ?// depends_on_coder
> + ? ? ? ?skip_bits(gb, 14); ? ? ? ? ? ? ? ? ? ? ? ?// delay
> + ? ?ext_flag = get_bits(gb, 1);
> +
> + ? ?if (!c->chan_config)
> + ? ? ? ?parse_pce_data(gb); ? ? ? ? ? ? ? ? ? ? ? // program_config_element
> +
> + ? ?if (audio_object_type == AOT_AAC_SCALABLE ||
> + ? ? ? ?audio_object_type == AOT_ER_AAC_SCALABLE)
> + ? ? ? ?skip_bits(gb, 3); ? ? ? ? ? ? ? ? ? ? ? ? // layer number
> +
> + ? ?if (!ext_flag)
> + ? ? ? ?return;
> +
> + ? ?if (audio_object_type == AOT_ER_BSAC) {
> + ? ? ? ?skip_bits(gb, 5); ? ? ? ? ? ? ? ? ? ? ? ? // numOfSubFrame
> + ? ? ? ?skip_bits(gb, 11); ? ? ? ? ? ? ? ? ? ? ? ?// layer_length
> + ? ?} else if (audio_object_type == AOT_ER_AAC_LC ? ? ? ||
> + ? ? ? ? ? ? ? audio_object_type == AOT_ER_AAC_LTP ? ? ?||
> + ? ? ? ? ? ? ? audio_object_type == AOT_ER_AAC_SCALABLE ||
> + ? ? ? ? ? ? ? audio_object_type == AOT_ER_AAC_LD)
> + ? ? ? ?skip_bits(gb, 3); ? ? ? ? ? ? ? ? ? ? ? ? // stuff
> + ? ?skip_bits(gb, 1); ? ? ? ? ? ? ? ? ? ? ? ? ? ? // extflag3
> +}
> +
> +static int latm_read_audio_specific_config(GetBitContext *gb)
> +{
> + ? ?int num_bits = get_bits_count(gb);
> + ? ?int audio_object_type;
> +
> + ? ?MPEG4AudioConfig b, *c;
> + ? ?c = &b;
> +
> + ? ?c->sbr = -1;
> +
> + ? ?audio_object_type = get_bits(gb, 5);
> + ? ?if (audio_object_type == AOT_ESCAPE) {
> + ? ? ? ?audio_object_type = AOT_ESCAPE + get_bits(gb, 6) + 1;
> + ? ?}
> + ? ?c->object_type = audio_object_type;
> +
> + ? ?c->sampling_index = get_bits(gb, 4);
> + ? ?c->sample_rate ? ?= ff_mpeg4audio_sample_rates[c->sampling_index];
> + ? ?if (c->sampling_index == 0x0f) {
> + ? ? ? ?c->sample_rate = get_bits(gb, 24);
> + ? ?}
> + ? ?c->chan_config = get_bits(gb, 4);
> +
> + ? ?if (c->chan_config < FF_ARRAY_ELEMS(ff_mpeg4audio_channels))
> + ? ? ? ?c->channels = ff_mpeg4audio_channels[c->chan_config];
> +
> + ? ?if (audio_object_type == AOT_AAC_MAIN ? ? ||
> + ? ? ? ?audio_object_type == AOT_AAC_LC ? ? ? ||
> + ? ? ? ?audio_object_type == AOT_AAC_SSR ? ? ?||
> + ? ? ? ?audio_object_type == AOT_AAC_LTP ? ? ?||
> + ? ? ? ?audio_object_type == AOT_AAC_SCALABLE ||
> + ? ? ? ?audio_object_type == AOT_TWINVQ) {
> + ? ? ? ?latm_read_ga_specific_config(audio_object_type, c, gb);
> + ? ?} else if (audio_object_type == AOT_SBR) {
> + ? ? ? ?c->sbr ? ? ? ? ? ? ? ?= 1;
> + ? ? ? ?c->ext_sampling_index = get_bits(gb, 4);
> + ? ? ? ?c->ext_sample_rate ? ?= ff_mpeg4audio_sample_rates[c->ext_sampling_index];
> + ? ? ? ?if (c->ext_sampling_index == 0x0f) {
> + ? ? ? ? ? ?c->ext_sample_rate = get_bits(gb, 24);
> + ? ? ? ?}
> + ? ? ? ?c->object_type = get_bits(gb, 5);
> + ? ?} else if (audio_object_type >= AOT_ER_AAC_LC) {
> + ? ? ? ?latm_read_ga_specific_config(audio_object_type, c, gb);
> + ? ? ? ?skip_bits(gb, 2); ? ? ? ? ? ? ? ? ? ? ? ? // epConfig
> + ? ?}
> +
> + ? ?if (c->sbr == -1 && c->sample_rate <= 24000)
> + ? ? ? ?c->sample_rate *= 2;
> +
> + ? ?// count the extradata
> + ? ?return get_bits_count(gb) - num_bits;
> +}
> +

It seems like these can be shared with the regular AAC decoder with a
little bit of factoring.



More information about the ffmpeg-devel mailing list