Commit 2416dd33 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Complete API renaming

parent 156dce5c
Using the libdts API
Using the libdca API
--------------------
libdts provides a low-level interface to decoding audio frames encoded
using DTS Coherent Acoustics. libdts provides downmixing and
libdca provides a low-level interface to decoding audio frames encoded
using DTS Coherent Acoustics. libdca provides downmixing and
dynamic range compression for the following output configurations:
DTS_CHANNEL : Dual mono. Two independant mono channels.
DTS_CHANNEL1 : First of the two mono channels above.
DTS_CHANNEL2 : Second of the two mono channels above.
DTS_MONO : Mono.
DTS_STEREO : Stereo.
DTS_DOLBY : Dolby surround compatible stereo.
DTS_3F : 3 front channels (left, center, right)
DTS_2F1R : 2 front, 1 rear surround channel (L, R, S)
DTS_3F1R : 3 front, 1 rear surround channel (L, C, R, S)
DTS_2F2R : 2 front, 2 rear surround channels (L, R, LS, RS)
DTS_3F2R : 3 front, 2 rear surround channels (L, C, R, LS, RS)
DTS_LFE : Low frequency effects channel. Normally used to connect a
DCA_CHANNEL : Dual mono. Two independant mono channels.
DCA_CHANNEL1 : First of the two mono channels above.
DCA_CHANNEL2 : Second of the two mono channels above.
DCA_MONO : Mono.
DCA_STEREO : Stereo.
DCA_DOLBY : Dolby surround compatible stereo.
DCA_3F : 3 front channels (left, center, right)
DCA_2F1R : 2 front, 1 rear surround channel (L, R, S)
DCA_3F1R : 3 front, 1 rear surround channel (L, C, R, S)
DCA_2F2R : 2 front, 2 rear surround channels (L, R, LS, RS)
DCA_3F2R : 3 front, 2 rear surround channels (L, C, R, LS, RS)
DCA_LFE : Low frequency effects channel. Normally used to connect a
subwoofer. Can be combined with any of the above channels.
For example: DTS_3F2R | DTS_LFE -> 3 front, 2 rear, 1 LFE (5.1)
For example: DCA_3F2R | DCA_LFE -> 3 front, 2 rear, 1 LFE (5.1)
Initialization
--------------
dca_state_t * dts_init (uint32_t mm_accel);
dca_state_t * dca_init (uint32_t mm_accel);
Initializes the DTS library. Takes as a parameter the acceptable
optimizations which may be used, such as MMX. These are found in the
included header file 'mm_accel', along with an autodetection function
(mm_accel()). Currently, there is no accelleration implemented.
The return value is a pointer to a dts state object.
The return value is a pointer to a dca state object.
Probing the bitstream
---------------------
int dts_syncinfo (uint8_t * buf, int * flags,
int dca_syncinfo (uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate, int * frame_length);
The DTS bitstream is composed of several dts frames concatenated one
after each other. A dts frame is the smallest independantly decodable
The DTS bitstream is composed of several DTS frames concatenated one
after each other. A DTS frame is the smallest independantly decodable
unit in the stream.
buf must contain at least 14 bytes from the input stream. If these look
like the start of a valid dts frame, dts_syncinfo() returns the size
like the start of a valid DTS frame, dca_syncinfo() returns the size
of the coded frame in bytes, and fills flags, sample_rate, bit_rate and
frame_length with the information encoded in the stream. The returned size
is guaranteed to be an even number between 96 and 16384 for the 16 bits
version of the bitstream and 109 and 18726 for the 14 bits version.
sample_rate will be the sampling frequency in Hz, bit_rate is for the
compressed stream and is in bits per second, and flags is a description of
the coded channels: the DTS_LFE bit is set if there is an LFE channel coded
in this stream, and by masking flags with DTS_CHANNEL_MASK you will get a
the coded channels: the DCA_LFE bit is set if there is an LFE channel coded
in this stream, and by masking flags with DCA_CHANNEL_MASK you will get a
value that describes the full-bandwidth channels, as one of the
DTS_CHANNEL...DTS_3F2R flags.
DCA_CHANNEL...DCA_3F2R flags.
If this can not possibly be a valid frame, then the function returns
0. You should then try to re-synchronize with the dts stream - one way
0. You should then try to re-synchronize with the DTS stream - one way
to try this would be to advance buf by one byte until its contents
looks like a valid frame, but there might be better
application-specific ways to synchronize.
......@@ -75,50 +75,50 @@ well detect the kind of bitstream it is dealing with (big/little endian,
Starting to decode a frame
--------------------------
int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
sample_t * level, sample_t bias);
This starts the work of decoding the DTS frame (to be completed using
dts_block()). buf should point to the beginning of the complete frame
of the full size returned by dts_syncinfo().
dca_block()). buf should point to the beginning of the complete frame
of the full size returned by dca_syncinfo().
You should pass in the flags the speaker configuration that you
support, and libdts will return the speaker configuration it will use
support, and libdca will return the speaker configuration it will use
for its output, based on what is coded in the stream and what you
asked for. For example, if the stream contains 2+2 channels
(dts_syncinfo() returned DTS_2F2R in the flags), and you have 3+1
speakers (you passed DTS_3F1R), then libdts will choose do downmix to
(dca_syncinfo() returned DCA_2F2R in the flags), and you have 3+1
speakers (you passed DCA_3F1R), then libdca will choose do downmix to
2+1 speakers, since there is no center channel to send to your center
speaker. So in that case the left and right channels will be
essentially unmodified by the downmix, and the two surround channels
will be added together and sent to your surround speaker. libdts will
return DTS_2F1R to indicate this.
will be added together and sent to your surround speaker. libdca will
return DCA_2F1R to indicate this.
The good news is that when you downmix to stereo you dont have to
worry about this, you will ALWAYS get a stereo output no matter what
was coded in the stream. For more complex output configurations you
will have to handle the case where libdts couldnt give you what you
will have to handle the case where libdca couldnt give you what you
wanted because some of the channels were not encoded in the stream
though.
Level, bias, and DTS_ADJUST_LEVEL:
Level, bias, and DCA_ADJUST_LEVEL:
Before downmixing, samples are floating point values with a range of
[-1,1]. Most types of downmixing will combine channels together, which
will potentially result in a larger range for the output
samples. libdts provides two methods of controlling the range of the
samples. libdca provides two methods of controlling the range of the
output, either before or after the downmix stage.
If you do not set DTS_ADJUST_LEVEL, libdts will multiply the samples
If you do not set DCA_ADJUST_LEVEL, libdca will multiply the samples
by your level value, so that they fit in the [-level,level]
range. Then it will apply the standardized downmix equations,
potentially making the samples go out of that interval again. The
level parameter is not modified.
Setting the DTS_ADJUST_LEVEL flag will instruct libdts to treat your
Setting the DCA_ADJUST_LEVEL flag will instruct libdca to treat your
level value as the intended range interval after downmixing. It will
then figure out what level to use before the downmix (what you should
have passed if you hadnt used the DTS_ADJUST_LEVEL flag), and
have passed if you hadnt used the DCA_ADJUST_LEVEL flag), and
overwrite the level value you gave it with that new level value.
The bias represents a value which should be added to the result
......@@ -128,7 +128,7 @@ output_sample = (input_sample * level) + bias;
For example, a bias of 384 and a level of 1 tells liba52 you want
samples between 383 and 385 instead of -1 and 1. This is what the
sample program dtsdec does, as it makes it faster to convert the
sample program dcadec does, as it makes it faster to convert the
samples to integer format, using a trick based on the IEEE
floating-point format.
......@@ -139,10 +139,10 @@ reused next when decoding blocks.
Dynamic range compression
-------------------------
void dts_dynrng (dca_state_t * state,
void dca_dynrng (dca_state_t * state,
sample_t (* call) (sample_t, void *), void * data);
This function is purely optional. If you dont call it, libdts will
This function is purely optional. If you dont call it, libdca will
provide the default behaviour, which is to apply the full dynamic
range compression as specified in the DTS stream. This basically
makes the loud sounds softer, and the soft sounds louder, so you can
......@@ -156,7 +156,7 @@ more adapted to a movie theater or a listening room.
If you call this function and specify a callback function, this
callback might be called up to once for each block, with two
arguments: the compression factor 'c' recommended by the bitstream,
and the private data pointer you specified in dts_dynrng(). The
and the private data pointer you specified in dca_dynrng(). The
callback will then return the amount of compression to actually use -
typically pow(c,x) where x is somewhere between 0 and 1. More
elaborate compression functions might want to use a different value
......@@ -167,57 +167,57 @@ if this is what you want.
Finding the number of blocks
----------------------------
int dts_blocks_num (dca_state_t * state);
int dca_blocks_num (dca_state_t * state);
Every DTS frame is composed of a variable number of blocks. Calling
dts_blocks_num() after dts_frame() will give you the number of blocks in the
dca_blocks_num() after dca_frame() will give you the number of blocks in the
current frame.
Decoding blocks
---------------
int dts_block (dca_state_t * state);
int dca_block (dca_state_t * state);
Every DTS frame is composed of a variable number of blocks, each with an
output of 256 samples for each channel. The dts_block() function decodes
the next block in the frame, and should be called dts_blocks_num() times to
output of 256 samples for each channel. The dca_block() function decodes
the next block in the frame, and should be called dca_blocks_num() times to
decode all of the audio in the frame.
Getting the decoded audio samples
---------------------------------
sample_t * dts_samples (dca_state_t * state);
sample_t * dca_samples (dca_state_t * state);
After each call to dts_block(), you should extract the audio data from the
After each call to dca_block(), you should extract the audio data from the
internal samples buffer.
This function returns a pointer to an internal buffer which will contain 256
samples for the first channel, followed by 256 samples for the second
channel, etc... the channel order is center, left, right, left
surround, right surround, LFE. If one of the channels is not present in the
libdts output, as indicated by the flags returned by dts_frame(), then
libdca output, as indicated by the flags returned by dca_frame(), then
this channel is skipped and the following channels are shifted so
libdts does not leave an empty space between channels.
libdca does not leave an empty space between channels.
Pseudocode example
------------------
dca_state_t * state = dts_init (mm_accel());
dca_state_t * state = dca_init (mm_accel());
loop on input bytes:
if at least 14 bytes in the buffer:
bytes_to_get = dts_syncinfo (...)
bytes_to_get = dca_syncinfo (...)
if bytes_to_get == 0:
goto loop to keep looking for sync point
else
get rest of bytes
dts_frame (state, buf, ...)
[dts_dynrng (state, ...); this is only optional]
for i = 1 ... dts_blocks_num():
dts_block (state)
dts_samples (state)
dca_frame (state, buf, ...)
[dca_dynrng (state, ...); this is only optional]
for i = 1 ... dca_blocks_num():
dca_block (state)
dca_samples (state)
convert samples to integer and queue to soundcard
......@@ -64,22 +64,22 @@ typedef struct dca_state_s dca_state_t;
#define DCA_LFE 0x80
#define DCA_ADJUST_LEVEL 0x100
dca_state_t * dts_init (uint32_t mm_accel);
dca_state_t * dca_init (uint32_t mm_accel);
int dts_syncinfo (dca_state_t *state, uint8_t * buf, int * flags,
int dca_syncinfo (dca_state_t *state, uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate, int *frame_length);
int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
level_t * level, sample_t bias);
void dts_dynrng (dca_state_t * state,
void dca_dynrng (dca_state_t * state,
level_t (* call) (level_t, void *), void * data);
int dts_blocks_num (dca_state_t * state);
int dts_block (dca_state_t * state);
int dca_blocks_num (dca_state_t * state);
int dca_block (dca_state_t * state);
sample_t * dts_samples (dca_state_t * state);
sample_t * dca_samples (dca_state_t * state);
void dts_free (dca_state_t * state);
void dca_free (dca_state_t * state);
#endif /* LIBDCA_DCA_H */
......@@ -42,4 +42,13 @@ typedef struct dca_state_s dts_state_t;
# define DTS_CHANNEL_MASK DCA_CHANNEL_MASK
# define DTS_LFE DCA_LFE
# define DTS_ADJUST_LEVEL DCA_ADJUST_LEVEL
# define dts_init dca_init
# define dts_syncinfo dca_syncinfo
# define dts_frame dca_frame
# define dts_dynrng dca_dynrng
# define dts_blocks_num dca_blocks_num
# define dts_block dca_block
# define dts_sampes dca_samples
# define dts_free dca_free
#endif
......@@ -5,7 +5,7 @@ lib_LTLIBRARIES = libdca.la
libdca_la_SOURCES = dca_internal.h tables.h tables_quantization.h \
tables_huffman.h tables_fir.h tables_adpcm.h tables_vq.h \
bitstream.h bitstream.c parse.c downmix.c
libdca_la_LDFLAGS = -no-undefined -version 0:0:0 -export-symbol-regex dts_.*
libdca_la_LDFLAGS = -no-undefined -version 0:0:0 -export-symbol-regex dca_.*
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libdca.pc libdts.pc
......
......@@ -32,7 +32,7 @@
#define BUFFER_SIZE 4096
void dts_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode,
void dca_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode,
int bigendian_mode)
{
intptr_t align;
......@@ -73,7 +73,7 @@ static inline void bitstream_fill_current (dca_state_t * state)
* -ah
*/
uint32_t dts_bitstream_get_bh (dca_state_t * state, uint32_t num_bits)
uint32_t dca_bitstream_get_bh (dca_state_t * state, uint32_t num_bits)
{
uint32_t result;
......
......@@ -47,9 +47,9 @@
#endif
void dts_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode,
void dca_bitstream_init (dca_state_t * state, uint8_t * buf, int word_mode,
int endian_mode);
uint32_t dts_bitstream_get_bh (dca_state_t * state, uint32_t num_bits);
uint32_t dca_bitstream_get_bh (dca_state_t * state, uint32_t num_bits);
static inline uint32_t bitstream_get (dca_state_t * state, uint32_t num_bits)
{
......@@ -63,5 +63,5 @@ static inline uint32_t bitstream_get (dca_state_t * state, uint32_t num_bits)
return result;
}
return dts_bitstream_get_bh (state, num_bits);
return dca_bitstream_get_bh (state, num_bits);
}
......@@ -154,13 +154,13 @@ struct dca_state_s {
#define LEVEL_45DB 0.5946035575013605
#define LEVEL_6DB 0.5
int dts_downmix_init (int input, int flags, level_t * level,
int dca_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev);
int dts_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
int dca_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev);
void dts_downmix (sample_t * samples, int acmod, int output, sample_t bias,
void dca_downmix (sample_t * samples, int acmod, int output, sample_t bias,
level_t clev, level_t slev);
void dts_upmix (sample_t * samples, int acmod, int output);
void dca_upmix (sample_t * samples, int acmod, int output);
#define ROUND(x) ((int)((x) + ((x) > 0 ? 0.5 : -0.5)))
......
......@@ -32,7 +32,7 @@
#define CONVERT(acmod,output) (((output) << DCA_CHANNEL_BITS) + (acmod))
int dts_downmix_init (int input, int flags, level_t * level,
int dca_downmix_init (int input, int flags, level_t * level,
level_t clev, level_t slev)
{
static uint8_t table[11][10] = {
......@@ -183,7 +183,7 @@ int dts_downmix_init (int input, int flags, level_t * level,
return output;
}
int dts_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
int dca_downmix_coeff (level_t * coeff, int acmod, int output, level_t level,
level_t clev, level_t slev)
{
level_t level_3db;
......@@ -491,7 +491,7 @@ static void zero (sample_t * samples)
samples[i] = 0;
}
void dts_downmix (sample_t * samples, int acmod, int output, sample_t bias,
void dca_downmix (sample_t * samples, int acmod, int output, sample_t bias,
level_t clev, level_t slev)
{
switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) {
......@@ -628,7 +628,7 @@ void dts_downmix (sample_t * samples, int acmod, int output, sample_t bias,
}
}
void dts_upmix (sample_t * samples, int acmod, int output)
void dca_upmix (sample_t * samples, int acmod, int output)
{
switch (CONVERT (acmod, output & DCA_CHANNEL_MASK)) {
......
......@@ -67,7 +67,7 @@ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
static void pre_calc_cosmod( dca_state_t * state );
dca_state_t * dts_init (uint32_t mm_accel)
dca_state_t * dca_init (uint32_t mm_accel)
{
dca_state_t * state;
int i;
......@@ -95,12 +95,12 @@ dca_state_t * dts_init (uint32_t mm_accel)
return state;
}
sample_t * dts_samples (dca_state_t * state)
sample_t * dca_samples (dca_state_t * state)
{
return state->samples;
}
int dts_blocks_num (dca_state_t * state)
int dca_blocks_num (dca_state_t * state)
{
/* 8 samples per subsubframe and per subband */
return state->sample_blocks / 8;
......@@ -130,15 +130,15 @@ static int syncinfo (dca_state_t * state, int * flags,
return 0;
*sample_rate = bitstream_get (state, 4);
if (*sample_rate >= sizeof (dts_sample_rates) / sizeof (int))
if (*sample_rate >= sizeof (dca_sample_rates) / sizeof (int))
return 0;
*sample_rate = dts_sample_rates[ *sample_rate ];
*sample_rate = dca_sample_rates[ *sample_rate ];
if (!*sample_rate) return 0;
*bit_rate = bitstream_get (state, 5);
if (*bit_rate >= sizeof (dts_bit_rates) / sizeof (int))
if (*bit_rate >= sizeof (dca_bit_rates) / sizeof (int))
return 0;
*bit_rate = dts_bit_rates[ *bit_rate ];
*bit_rate = dca_bit_rates[ *bit_rate ];
if (!*bit_rate) return 0;
/* LFE */
......@@ -148,7 +148,7 @@ static int syncinfo (dca_state_t * state, int * flags,
return frame_size;
}
int dts_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
int dca_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate, int * frame_length)
{
/*
......@@ -161,7 +161,7 @@ int dts_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
(buf[4] & 0xf0) == 0xf0 && buf[5] == 0x07)
{
int frame_size;
dts_bitstream_init (state, buf, 0, 0);
dca_bitstream_init (state, buf, 0, 0);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
......@@ -173,7 +173,7 @@ int dts_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
buf[4] == 0x07 && (buf[5] & 0xf0) == 0xf0)
{
int frame_size;
dts_bitstream_init (state, buf, 0, 1);
dca_bitstream_init (state, buf, 0, 1);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
......@@ -184,7 +184,7 @@ int dts_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
buf[2] == 0x01 && buf[3] == 0x80)
{
int frame_size;
dts_bitstream_init (state, buf, 1, 0);
dca_bitstream_init (state, buf, 1, 0);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
......@@ -195,7 +195,7 @@ int dts_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
buf[2] == 0x80 && buf[3] == 0x01)
{
int frame_size;
dts_bitstream_init (state, buf, 1, 1);
dca_bitstream_init (state, buf, 1, 1);
frame_size = syncinfo (state, flags, sample_rate,
bit_rate, frame_length);
return frame_size;
......@@ -204,13 +204,13 @@ int dts_syncinfo (dca_state_t * state, uint8_t * buf, int * flags,
return 0;
}
int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
level_t * level, sample_t bias)
{
int i, j;
static float adj_table[] = { 1.0, 1.1250, 1.2500, 1.4375 };
dts_bitstream_init (state, buf, state->word_mode, state->bigendian_mode);
dca_bitstream_init (state, buf, state->word_mode, state->bigendian_mode);
/* Sync code */
bitstream_get (state, 32);
......@@ -249,7 +249,7 @@ int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
/* FIME: channels mixing levels */
state->clev = state->slev = 1;
state->output = dts_downmix_init (state->amode, *flags, level,
state->output = dca_downmix_init (state->amode, *flags, level,
state->clev, state->slev);
if (state->output < 0)
return 1;
......@@ -272,11 +272,11 @@ int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
state->sample_blocks, state->sample_blocks * 32);
fprintf (stderr, "frame size: %i bytes\n", state->frame_size);
fprintf (stderr, "amode: %i (%i channels)\n",
state->amode, dts_channels[state->amode]);
state->amode, dca_channels[state->amode]);
fprintf (stderr, "sample rate: %i (%i Hz)\n",
state->sample_rate, dts_sample_rates[state->sample_rate]);
state->sample_rate, dca_sample_rates[state->sample_rate]);
fprintf (stderr, "bit rate: %i (%i bits/s)\n",
state->bit_rate, dts_bit_rates[state->bit_rate]);
state->bit_rate, dca_bit_rates[state->bit_rate]);
fprintf (stderr, "downmix: %i\n", state->downmix);
fprintf (stderr, "dynrange: %i\n", state->dynrange);
fprintf (stderr, "timestamp: %i\n", state->timestamp);
......@@ -293,7 +293,7 @@ int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
fprintf (stderr, "copy history: %i\n", state->copy_history);
fprintf (stderr, "source pcm resolution: %i (%i bits/sample)\n",
state->source_pcm_res,
dts_bits_per_sample[state->source_pcm_res]);
dca_bits_per_sample[state->source_pcm_res]);
fprintf (stderr, "front sum: %i\n", state->front_sum);
fprintf (stderr, "surround sum: %i\n", state->surround_sum);
fprintf (stderr, "dialog norm: %i\n", state->dialog_norm);
......@@ -440,7 +440,7 @@ int dts_frame (dca_state_t * state, uint8_t * buf, int * flags,
return 0;
}
static int dts_subframe_header (dca_state_t * state)
static int dca_subframe_header (dca_state_t * state)
{
/* Primary audio coding side information */
int j, k;
......@@ -754,7 +754,7 @@ static int dts_subframe_header (dca_state_t * state)
return 0;
}
static int dts_subsubframe (dca_state_t * state)
static int dca_subsubframe (dca_state_t * state)
{
int k, l;
int subsubframe = state->current_subsubframe;
......@@ -990,13 +990,13 @@ static int dts_subsubframe (dca_state_t * state)
}
/* Down/Up mixing */
if (state->prim_channels < dts_channels[state->output & DCA_CHANNEL_MASK])
if (state->prim_channels < dca_channels[state->output & DCA_CHANNEL_MASK])
{
dts_upmix (state->samples, state->amode, state->output);
dca_upmix (state->samples, state->amode, state->output);
} else
if (state->prim_channels > dts_channels[state->output & DCA_CHANNEL_MASK])
if (state->prim_channels > dca_channels[state->output & DCA_CHANNEL_MASK])
{
dts_downmix (state->samples, state->amode, state->output, state->bias,
dca_downmix (state->samples, state->amode, state->output, state->bias,
state->clev, state->slev);
}
......@@ -1004,7 +1004,7 @@ static int dts_subsubframe (dca_state_t * state)
if (state->output & DCA_LFE)
{
int lfe_samples = 2 * state->lfe * state->subsubframes;
int i_channels = dts_channels[state->output & DCA_CHANNEL_MASK];
int i_channels = dca_channels[state->output & DCA_CHANNEL_MASK];
lfe_interpolation_fir (state->lfe, 2 * state->lfe,
state->lfe_data + lfe_samples +
......@@ -1017,7 +1017,7 @@ static int dts_subsubframe (dca_state_t * state)
return 0;
}
static int dts_subframe_footer (dca_state_t * state)
static int dca_subframe_footer (dca_state_t * state)
{
int aux_data_count = 0, i;
int lfe_samples;
......@@ -1054,7 +1054,7 @@ static int dts_subframe_footer (dca_state_t * state)
return 0;
}
int dts_block (dca_state_t * state)
int dca_block (dca_state_t * state)
{
/* Sanity check */
if (state->current_subframe >= state->subframes)
......@@ -1067,17 +1067,17 @@ int dts_block (dca_state_t * state)
if (!state->current_subsubframe)
{
#ifdef DEBUG
fprintf (stderr, "DSYNC dts_subframe_header\n");
fprintf (stderr, "DSYNC dca_subframe_header\n");
#endif
/* Read subframe header */
if (dts_subframe_header (state)) return -1;
if (dca_subframe_header (state)) return -1;
}
/* Read subsubframe */
#ifdef DEBUG
fprintf (stderr, "DSYNC dts_subsubframe\n");
fprintf (stderr, "DSYNC dca_subsubframe\n");
#endif
if (dts_subsubframe (state)) return -1;
if (dca_subsubframe (state)) return -1;
/* Update state */
state->current_subsubframe++;
......@@ -1089,10 +1089,10 @@ int dts_block (dca_state_t * state)
if (state->current_subframe >= state->subframes)
{
#ifdef DEBUG
fprintf(stderr, "DSYNC dts_subframe_footer\n");
fprintf(stderr, "DSYNC dca_subframe_footer\n");
#endif
/* Read subframe footer */
if (dts_subframe_footer (state)) return -1;
if (dca_subframe_footer (state)) return -1;
}
return 0;
......@@ -1272,7 +1272,7 @@ static void lfe_interpolation_fir (int nDecimationSelect, int nNumDeciSample,
}
}
void dts_dynrng (dca_state_t * state,
void dca_dynrng (dca_state_t * state,
level_t (* call) (level_t, void *), void * data)
{
state->dynrange = 0;
......@@ -1283,7 +1283,7 @@ void dts_dynrng (dca_state_t * state,
}
}
void dts_free (dca_state_t * state)
void dca_free (dca_state_t * state)
{
free (state->samples);
free (state);
......
......@@ -20,13 +20,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
static const int dts_sample_rates[] =
static const int dca_sample_rates[] =
{
0, 8000, 16000, 32000, 0, 0, 11025, 22050, 44100, 0, 0,
12000, 24000, 48000, 96000, 192000
};
static const int dts_bit_rates[] =
static const int dca_bit_rates[] =
{
32000, 56000, 64000, 96000, 112000, 128000,
192000, 224000, 256000, 320000, 384000,
......@@ -36,12 +36,12 @@ static const int dts_bit_rates[] =
2048000, 3072000, 3840000, 1/*open*/, 2/*variable*/, 3/*lossless*/
};
static const uint8_t dts_channels[] =
static const uint8_t dca_channels[] =
{
1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8
};
static const uint8_t dts_bits_per_sample[] =
static const uint8_t dca_bits_per_sample[] =
{
16, 16, 20, 20, 0, 24, 24
};
......@@ -238,7 +238,7 @@ static void handle_args (int argc, char ** argv)
in_file = stdin;
}
void dts_decode_data (uint8_t * start, uint8_t * end)
static void dca_decode_data (uint8_t * start, uint8_t * end)
{
static uint8_t buf[BUFFER_SIZE];
static uint8_t * bufptr = buf;
......@@ -246,7 +246,7 @@ void dts_decode_data (uint8_t * start, uint8_t * end)
/*
* sample_rate and flags are static because this routine could
* exit between the dts_syncinfo() and the ao_setup(), and we want
* exit between the dca_syncinfo() and the ao_setup(), and we want
* to have the same values when we get back !
*/
......@@ -269,7 +269,7 @@ void dts_decode_data (uint8_t * start, uint8_t * end)
if (bufpos == buf + HEADER_SIZE) {
int length;
length = dts_syncinfo (state, buf, &flags, &sample_rate,
length = dca_syncinfo (state, buf, &flags, &sample_rate,
&bit_rate, &frame_length);
if (!length) {
fprintf (stderr, "skip\n");
......@@ -288,14 +288,14 @@ void dts_decode_data (uint8_t * start, uint8_t * end)
if (!disable_adjust)
flags |= DCA_ADJUST_LEVEL;
level = (level_t) (level * gain);
if (dts_frame (state, buf, &flags, &level, bias))
if (dca_frame (state, buf, &flags, &level, bias))
goto error;
if (disable_dynrng)
dts_dynrng (state, NULL, NULL);
for (i = 0; i < dts_blocks_num (state); i++) {
if (dts_block (state))
dca_dynrng (state, NULL, NULL);
for (i = 0; i < dca_blocks_num (state); i++) {
if (dca_block (state))
goto error;
if (output->play (output, flags, dts_samples (state)))
if (output->play (output, flags, dca_samples (state)))
goto error;
}
bufptr = buf;
......@@ -388,11 +388,11 @@ static int demux (uint8_t * buf, uint8_t * end, int flags)
break;
case DEMUX_DATA:
if (demux_pid || (state_bytes > end - buf)) {
dts_decode_data (buf, end);
dca_decode_data (buf, end);
state_bytes -= end - buf;
return 0;
}
dts_decode_data (buf, buf + state_bytes);
dca_decode_data (buf, buf + state_bytes);
buf += state_bytes;
break;
case DEMUX_SKIP:
......@@ -444,12 +444,12 @@ static int demux (uint8_t * buf, uint8_t * end, int flags)
DONEBYTES (len);
bytes = 6 + (header[4] << 8) + header[5] - len;
if (bytes > end - buf) {
dts_decode_data (buf, end);
dca_decode_data (buf, end);
state = DEMUX_DATA;
state_bytes = bytes - (end - buf);
return 0;
} else if (bytes > 0) {
dts_decode_data (buf, buf + bytes);
dca_decode_data (buf, buf + bytes);
buf += bytes;
}