mpeg4audio.c File Reference

#include "bitstream.h"
#include "mpeg4audio.h"

Go to the source code of this file.

Functions

static int get_object_type (GetBitContext *gb)
static int get_sample_rate (GetBitContext *gb, int *index)
int ff_mpeg4audio_get_config (MPEG4AudioConfig *c, const uint8_t *buf, int buf_size)

Variables

const int ff_mpeg4audio_sample_rates [16]
const uint8_t ff_mpeg4audio_channels [8]


Function Documentation

int ff_mpeg4audio_get_config ( MPEG4AudioConfig c,
const uint8_t *  buf,
int  buf_size 
)

Parse MPEG-4 systems extradata to retrieve audio configuration.

Parameters:
[in] c MPEG4AudioConfig structure to fill.
[in] buf Extradata from container.
[in] buf_size Extradata size.
Returns:
On error -1 is returned, on success AudioSpecificConfig bit index in extradata.

Definition at line 49 of file mpeg4audio.c.

References c, get_bits(), get_bits1(), get_bits_count(), get_object_type(), get_sample_rate(), init_get_bits(), and show_bits().

Referenced by mov_read_esds().

00050 {
00051     GetBitContext gb;
00052     int specific_config_bitindex;
00053 
00054     init_get_bits(&gb, buf, buf_size*8);
00055     c->object_type = get_object_type(&gb);
00056     c->sample_rate = get_sample_rate(&gb, &c->sampling_index);
00057     c->chan_config = get_bits(&gb, 4);
00058     c->sbr = -1;
00059     if (c->object_type == 5) {
00060         c->ext_object_type = c->object_type;
00061         c->sbr = 1;
00062         c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
00063         c->object_type = get_object_type(&gb);
00064     } else
00065         c->ext_object_type = 0;
00066 
00067     specific_config_bitindex = get_bits_count(&gb);
00068 
00069     if (c->ext_object_type != 5) {
00070         int bits_left = buf_size*8 - specific_config_bitindex;
00071         for (; bits_left > 15; bits_left--) {
00072             if (show_bits(&gb, 11) == 0x2b7) { // sync extension
00073                 get_bits(&gb, 11);
00074                 c->ext_object_type = get_object_type(&gb);
00075                 if (c->ext_object_type == 5 && (c->sbr = get_bits1(&gb)) == 1)
00076                     c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
00077                 break;
00078             } else
00079                 get_bits1(&gb); // skip 1 bit
00080         }
00081     }
00082     return specific_config_bitindex;
00083 }

static int get_object_type ( GetBitContext gb  )  [inline, static]

Definition at line 34 of file mpeg4audio.c.

References get_bits().

Referenced by ff_mpeg4audio_get_config().

00035 {
00036     int object_type = get_bits(gb, 5);
00037     if (object_type == 31)
00038         object_type = 32 + get_bits(gb, 6);
00039     return object_type;
00040 }

static int get_sample_rate ( GetBitContext gb,
int *  index 
) [inline, static]

Definition at line 42 of file mpeg4audio.c.

References ff_mpeg4audio_sample_rates, and get_bits().

Referenced by ff_mpeg4audio_get_config().

00043 {
00044     *index = get_bits(gb, 4);
00045     return *index == 0x0f ? get_bits(gb, 24) :
00046         ff_mpeg4audio_sample_rates[*index];
00047 }


Variable Documentation

const uint8_t ff_mpeg4audio_channels[8]

Initial value:

 {
    0, 1, 2, 3, 4, 5, 6, 8
}

Definition at line 30 of file mpeg4audio.c.

Referenced by aac_sync(), and mov_read_esds().

const int ff_mpeg4audio_sample_rates[16]

Initial value:

 {
    96000, 88200, 64000, 48000, 44100, 32000,
    24000, 22050, 16000, 12000, 11025, 8000, 7350
}

Definition at line 25 of file mpeg4audio.c.

Referenced by aac_sync(), get_aac_sample_rates(), get_sample_rate(), and matroska_aac_sri().


Generated on Thu Nov 20 08:45:37 2008 for libextractor by  doxygen 1.5.1