xine-lib 1.2.11
Data Structures | Macros | Enumerations | Functions | Variables
latm.c File Reference
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>

Data Structures

struct  bebf_t
 
struct  bebf_latm_t
 

Macros

#define LOG_MODULE   "latm"
 
#define LOG_VERBOSE
 
#define bebf_UNUSED
 
#define bebf_ADJ32(v)   (((v) >> 24) | (((v) & 0xff0000) >> 8) | (((v) & 0xff00) << 8) | ((v) << 24))
 
#define bebf_shift(nn)
 
#define AOTF_SHORT   0x0001 /* frameLengthFlag */
 
#define AOTF_CORE   0x0002 /* dependsOnCoreCoder */
 
#define AOTF_EXT1   0x0004 /* extensionFlag1 */
 
#define AOTF_LAYER   0x0008 /* layerNr */
 
#define AOTF_CHAN   0x0010 /* custom channel layout */
 
#define AOTF_SUBFR   0x0020 /* subFrames */
 
#define AOTF_RESIL   0x0040 /* errorResilienceFlags */
 
#define AOTF_LDSBR   0x0080 /* lowDelaySbr */
 
#define AOTF_ELD   0x0100 /* enhancedLowDelay */
 
#define AOTF_EPCNF   0x0200 /* epConfig */
 
#define BEBF_LATM_GOT_CONF   1
 
#define BEBF_LATM_GOT_FRAME   2
 
#define BEBF_TEST_MAX   (2 * (0x1fff + 3))
 

Enumerations

enum  bebf_aot_t {
  AOT_AAC_MAIN = 1 , AOT_AAC_LC = 2 , AOT_AAC_SSR = 3 , AOT_AAC_LTP = 4 ,
  AOT_SBR = 5 , AOT_AAC_SCALABLE = 6 , AOT_TWINVQ = 7 , AOT_CELP = 8 ,
  AOT_HVXC = 9 , AOT_ER_AAC_LC = 17 , AOT_ER_AAC_LTP = 19 , AOT_ER_AAC_SCALABLE = 20 ,
  AOT_ER_TWINVQ = 21 , AOT_ER_BSAC = 22 , AOT_ER_AAC_LD = 23 , AOT_ER_CELP = 24 ,
  AOT_ER_HVXC = 25 , AOT_ER_HILN = 26 , AOT_ER_PARAM = 27 , AOT_SSC = 28 ,
  AOT_PS = 29 , AOT_L1 = 32 , AOT_L2 = 33 , AOT_L3 = 34 ,
  AOT_ALS = 36 , AOT_ER_AAC_ELD = 39
}
 
enum  bebf_latm_parser_status_t {
  BEBF_LATM_NEED_MORE_DATA , BEBF_LATM_IS_RAW , BEBF_LATM_IS_ADTS , BEBF_LATM_IS_LATM ,
  BEBF_LATM_IS_UNKNOWN
}
 

Functions

static void bebf_seek (bebf_t *bebf, uint32_t nbits)
 
static void bebf_align (bebf_t *bebf)
 
static void bebf_set_read (bebf_t *bebf, const uint8_t *rp, uint32_t nbytes)
 
static void bebf_set_write (bebf_t *bebf, uint8_t *wp)
 
static uint32_t bebf_get (bebf_t *bebf, uint32_t nbits)
 
static uint32_t bebf_sniff (bebf_t *bebf, uint32_t nbits)
 
static void bebf_skip (bebf_t *bebf, uint32_t nbits)
 
static uint32_t bebf_tell (bebf_t *bebf)
 
static int bebf_sync (bebf_t *bebf, uint32_t pattern, uint32_t pbits)
 
static void bebf_put (bebf_t *bebf, uint32_t bits, uint32_t nbits)
 
static size_t bebf_flush (bebf_t *bebf)
 
static void bebf_copy (bebf_t *bebf, uint32_t nbits)
 
static int bebf_latm_configure (bebf_latm_t *latm, uint32_t nbits)
 
static int bebf_latm_demux (bebf_latm_t *latm, const uint8_t *in, uint32_t nbytes)
 
static void bebf_latm_open (bebf_latm_t *latm)
 
static void bebf_latm_close (bebf_latm_t *latm)
 
static bebf_latm_parser_status_t bebf_latm_test (const uint8_t *in, int nbytes)
 
static int bebf_latm_parse (bebf_latm_t *latm, const uint8_t *in, int *nbytes)
 

Variables

static const uint32_t bebf_latm_flags [40]
 

Macro Definition Documentation

◆ AOTF_CHAN

#define AOTF_CHAN   0x0010 /* custom channel layout */

◆ AOTF_CORE

#define AOTF_CORE   0x0002 /* dependsOnCoreCoder */

◆ AOTF_ELD

#define AOTF_ELD   0x0100 /* enhancedLowDelay */

◆ AOTF_EPCNF

#define AOTF_EPCNF   0x0200 /* epConfig */

◆ AOTF_EXT1

#define AOTF_EXT1   0x0004 /* extensionFlag1 */

◆ AOTF_LAYER

#define AOTF_LAYER   0x0008 /* layerNr */

◆ AOTF_LDSBR

#define AOTF_LDSBR   0x0080 /* lowDelaySbr */

◆ AOTF_RESIL

#define AOTF_RESIL   0x0040 /* errorResilienceFlags */

◆ AOTF_SHORT

#define AOTF_SHORT   0x0001 /* frameLengthFlag */

◆ AOTF_SUBFR

#define AOTF_SUBFR   0x0020 /* subFrames */

◆ bebf_ADJ32

#define bebf_ADJ32 (   v)    (((v) >> 24) | (((v) & 0xff0000) >> 8) | (((v) & 0xff00) << 8) | ((v) << 24))

◆ BEBF_LATM_GOT_CONF

#define BEBF_LATM_GOT_CONF   1

◆ BEBF_LATM_GOT_FRAME

#define BEBF_LATM_GOT_FRAME   2

◆ bebf_shift

#define bebf_shift (   nn)
Value:
{ \
uint64_t b = bebf->readcache; \
do {*q++ = bebf_ADJ32 (b >> 32); b <<= nn; b |= bebf_ADJ32 (*p++); b <<= 32 - nn;} while (--words); \
bebf->readcache = b; \
}
#define bebf_ADJ32(v)
Definition: latm.c:56
#define nn

◆ BEBF_TEST_MAX

#define BEBF_TEST_MAX   (2 * (0x1fff + 3))

◆ bebf_UNUSED

#define bebf_UNUSED

◆ LOG_MODULE

#define LOG_MODULE   "latm"

◆ LOG_VERBOSE

#define LOG_VERBOSE

Enumeration Type Documentation

◆ bebf_aot_t

enum bebf_aot_t
Enumerator
AOT_AAC_MAIN 
AOT_AAC_LC 
AOT_AAC_SSR 
AOT_AAC_LTP 
AOT_SBR 
AOT_AAC_SCALABLE 
AOT_TWINVQ 
AOT_CELP 
AOT_HVXC 
AOT_ER_AAC_LC 
AOT_ER_AAC_LTP 
AOT_ER_AAC_SCALABLE 
AOT_ER_TWINVQ 
AOT_ER_BSAC 
AOT_ER_AAC_LD 
AOT_ER_CELP 
AOT_ER_HVXC 
AOT_ER_HILN 
AOT_ER_PARAM 
AOT_SSC 
AOT_PS 
AOT_L1 
AOT_L2 
AOT_L3 
AOT_ALS 
AOT_ER_AAC_ELD 

◆ bebf_latm_parser_status_t

Enumerator
BEBF_LATM_NEED_MORE_DATA 
BEBF_LATM_IS_RAW 
BEBF_LATM_IS_ADTS 
BEBF_LATM_IS_LATM 
BEBF_LATM_IS_UNKNOWN 

Function Documentation

◆ bebf_align()

static void bebf_align ( bebf_t bebf)
static

Align to next byte boundary.

Parameters
bebfpointer to bebf_t struct to use.

References bebf_t::readbits, and bebf_t::readcache.

Referenced by bebf_latm_configure().

◆ bebf_copy()

static void bebf_copy ( bebf_t bebf,
uint32_t  nbits 
)
static

Copy bits from read stream to write stream verbatim, and try to be fast.

Parameters
bebfpointer to bebf_t struct to use.
nbitsbit count.

References bebf_ADJ32, bebf_shift, bebf_t::readbits, bebf_t::readcache, bebf_t::readptr, bebf_t::writebits, bebf_t::writecache, and bebf_t::writeptr.

Referenced by bebf_latm_configure(), and bebf_latm_demux().

◆ bebf_flush()

static size_t bebf_flush ( bebf_t bebf)
static

Flush out any unsaved data to write stream.

Parameters
bebfpointer to bebf_t struct to use.
Returns
byte count of write buffer so far.

References bebf_ADJ32, bebf_t::writebits, bebf_t::writecache, bebf_t::writeptr, and bebf_t::writestart.

Referenced by bebf_latm_configure(), and bebf_latm_demux().

◆ bebf_get()

static uint32_t bebf_get ( bebf_t bebf,
uint32_t  nbits 
)
static

Get 1 .. 32 bits of data from read stream.

Parameters
bebfpointer to bebf_t struct to use.
nbitsbit count.
Returns
the requested data, right justified.

References bebf_ADJ32, bebf_t::readbits, bebf_t::readcache, bebf_t::readptr, and bebf_t::readstop.

Referenced by bebf_latm_configure(), and bebf_latm_demux().

◆ bebf_latm_close()

static void bebf_latm_close ( bebf_latm_t latm)
static

◆ bebf_latm_configure()

static int bebf_latm_configure ( bebf_latm_t latm,
uint32_t  nbits 
)
static

◆ bebf_latm_demux()

static int bebf_latm_demux ( bebf_latm_t latm,
const uint8_t *  in,
uint32_t  nbytes 
)
static

◆ bebf_latm_open()

static void bebf_latm_open ( bebf_latm_t latm)
static

Referenced by faad_reset(), and open_plugin().

◆ bebf_latm_parse()

static int bebf_latm_parse ( bebf_latm_t latm,
const uint8_t *  in,
int *  nbytes 
)
static

Parse and demux LATM.

Parameters
latmpointer to bebf_latm_t struct.
inpointer to input data.
nbytespointer to byte count, will be adjusted to consumed.
Returns
BEBF_LATM_GOT_* flags.

References bebf_latm_demux().

Referenced by faad_decode_audio().

◆ bebf_latm_test()

static bebf_latm_parser_status_t bebf_latm_test ( const uint8_t *  in,
int  nbytes 
)
static

Test if really LATM.

Parameters
inpointer to input data.
nbytesbyte count.
Returns
status.

References BEBF_LATM_IS_ADTS, BEBF_LATM_IS_LATM, BEBF_LATM_IS_UNKNOWN, BEBF_LATM_NEED_MORE_DATA, and BEBF_TEST_MAX.

Referenced by faad_decode_data().

◆ bebf_put()

static void bebf_put ( bebf_t bebf,
uint32_t  bits,
uint32_t  nbits 
)
static

Write 1 .. 32 bits of data to write stream.

Parameters
bebfpointer to bebf_t struct to use.
bitsThe data to write, right justified.
nbitsbit count.

References bebf_ADJ32, bits, bebf_t::writebits, bebf_t::writecache, and bebf_t::writeptr.

◆ bebf_seek()

static void bebf_seek ( bebf_t bebf,
uint32_t  nbits 
)
static

Jump to stream reader bit position.

Parameters
bebfpointer to bebf_t struct to use.
nbitsnew position in bits from the beginning.

References bebf_ADJ32, bebf_t::readbits, bebf_t::readcache, bebf_t::readptr, bebf_t::readstart, and bebf_t::readstop.

Referenced by bebf_latm_configure(), and bebf_set_read().

◆ bebf_set_read()

static void bebf_set_read ( bebf_t bebf,
const uint8_t *  rp,
uint32_t  nbytes 
)
static

Initialize big endian bit stream reader.

Parameters
bebfpointer to bebf_t struct to use.
rppointer to read stream, padded by at least 8 bytes.
nbytesbyte length of input.

References bebf_seek(), bebf_t::readstart, and bebf_t::readstop.

Referenced by bebf_latm_demux().

◆ bebf_set_write()

static void bebf_set_write ( bebf_t bebf,
uint8_t *  wp 
)
static

Initialize big endian bit stream writer.

Parameters
bebfpointer to bebf_t struct to use.
wppointer to 4 byte aligned write buffer.

References bebf_t::writebits, bebf_t::writecache, bebf_t::writeptr, and bebf_t::writestart.

Referenced by bebf_latm_configure(), and bebf_latm_demux().

◆ bebf_skip()

static void bebf_skip ( bebf_t bebf,
uint32_t  nbits 
)
static

Discard 1 .. 32 bits of data from read stream.

Parameters
bebfpointer to bebf_t struct to use.
nbitsbit count.

References bebf_ADJ32, bebf_t::readbits, bebf_t::readcache, bebf_t::readptr, and bebf_t::readstop.

Referenced by bebf_latm_configure(), and bebf_latm_demux().

◆ bebf_sniff()

static uint32_t bebf_sniff ( bebf_t bebf,
uint32_t  nbits 
)
static

Sniff 1 .. 32 bits of data from read stream, not changing the stream position.

Parameters
bebfpointer to bebf_t struct to use.
nbitsbit count.
Returns
the requested data, right justified.

References bebf_ADJ32, bebf_t::readbits, bebf_t::readcache, bebf_t::readptr, and bebf_t::readstop.

Referenced by bebf_latm_configure().

◆ bebf_sync()

static int bebf_sync ( bebf_t bebf,
uint32_t  pattern,
uint32_t  pbits 
)
static

Seek forward to right after next appearence of sync pattern.

Parameters
bebfpointer to bebf_t struct to use.
patternthe sync pattern to search for, right justified.
pbitsbit length of pattern.
Returns
1 (found), 0 (end of bitfile reached).

References bebf_ADJ32, bebf_t::readbits, bebf_t::readcache, bebf_t::readptr, and bebf_t::readstop.

◆ bebf_tell()

static uint32_t bebf_tell ( bebf_t bebf)
static

Tell current read stream position.

Parameters
bebfpointer to bebf_t struct to use.
Returns
stream position in bits.

References bebf_t::readbits, bebf_t::readptr, and bebf_t::readstart.

Referenced by bebf_latm_configure(), and bebf_latm_demux().

Variable Documentation

◆ bebf_latm_flags

const uint32_t bebf_latm_flags[40]
static

Referenced by bebf_latm_configure().