Using the libdts API
--------------------
libdts provides a low-level interface to decoding audio frames encoded
using DTS Coherent Acoustics. libdts 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
subwoofer. Can be combined with any of the above channels.
For example: DTS_3F2R | DTS_LFE -> 3 front, 2 rear, 1 LFE (5.1)
Initialization
--------------
dts_state_t * dts_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.
Probing the bitstream
---------------------
int dts_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
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
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
value that describes the full-bandwidth channels, as one of the
DTS_CHANNEL...DTS_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
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.
You need to call this function for each frame, for several
reasons: this function detects errors that the other functions will
not double-check, consecutive frames might have different lengths, and
it helps you re-sync with the stream if you get de-synchronized. It will as
well detect the kind of bitstream it is dealing with (big/little endian,
16/14 bits mode)
Starting to decode a frame
--------------------------
int dts_frame (dts_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().
You should pass in the flags the speaker configuration that you
support, and libdts 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
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.
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
wanted because some of the channels were not encoded in the stream
though.
Level, bias, and DTS_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
output, either before or after the downmix stage.
If you do not set DTS_ADJUST_LEVEL, libdts 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
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
overwrite the level value you gave it with that new level value.
The bias represents a value which should be added to the result
regardless:
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
samples to integer format, using a trick based on the IEEE
floating-point format.
This function also initialises the state for that frame, which will be
reused next when decoding blocks.
Dynamic range compression
-------------------------
void dts_dynrng (dts_state_t * state,
sample_t (* call) (sample_t, void *), void * data);
This function is purely optional. If you dont call it, libdts 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
more easily listen to the stream in a noisy environment without
disturbing anyone.
If you do call this function and set a NULL callback, this will
totally disable the dynamic range compression and provide a playback
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
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
for 'x' depending wether c>1 or c<1 - or even something more complex
if this is what you want.
Finding the number of blocks
----------------------------
int dts_blocks_num (dts_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
current frame.
Decoding blocks
---------------
int dts_block (dts_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
decode all of the audio in the frame.
Getting the decoded
没有合适的资源?快使用搜索试试~ 我知道了~
dts.zip_ DTS_DTS DECODER_HD_dts
共83个文件
c:19个
h:16个
in:10个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 42 浏览量
2022-09-19
14:32:37
上传
评论
收藏 277KB ZIP 举报
温馨提示
DTS码流解析, 用于高保真的音频播放
资源详情
资源评论
资源推荐
收起资源包目录
dts.zip (83个子文件)
acinclude.m4 24KB
libao
audio_out_win.c 6KB
audio_out_al.c 4KB
configure.incl 1KB
audio_out_null.c 2KB
audio_out_peak.c 2KB
Makefile.am 317B
audio_out_float.c 2KB
Makefile.in 13KB
audio_out_oss.c 5KB
convert2s16.c 5KB
audio_out_internal.h 2KB
audio_out_aif.c 4KB
audio_out_solaris.c 4KB
audio_out.c 3KB
audio_out_wav.c 10KB
vc++
config.h 4KB
libao.dsp 4KB
Makefile.am 76B
Makefile.in 7KB
dtsdec.dsp 5KB
dtsdec.dsw 1KB
inttypes.h 309B
libdts.dsp 4KB
test
compare.c 2KB
tests 298B
compile 2KB
Makefile.am 186B
Makefile.in 13KB
globals 589B
regression 1KB
include
Makefile.am 59B
dts.h 2KB
Makefile.in 9KB
tendra.h 1KB
audio_out.h 1KB
aclocal.m4 57KB
TODO 935B
Makefile.am 116B
src
getopt.c 30KB
dtsdec.1 1KB
getopt.h 6KB
gettimeofday.c 1KB
configure.incl 339B
Makefile.am 482B
gettimeofday.h 1KB
extract_dts.c 9KB
extract_dts.1 945B
Makefile.in 15KB
dtsdec.c 15KB
README 5KB
Makefile.in 17KB
INSTALL 9KB
doc
libdts.txt 9KB
Makefile.am 24B
Makefile.in 7KB
libdts
dts_internal.h 8KB
tables_fir.h 40KB
bitstream.c 3KB
configure.incl 538B
tables.h 2KB
libdts.pc.in 241B
tables_huffman.h 53KB
tables_quantization.h 4KB
tables_vq.h 132KB
tables_adpcm.h 128KB
Makefile.am 666B
bitstream.h 2KB
Makefile.in 21KB
parse.c 40KB
downmix.c 18KB
NEWS 350B
autotools
mkinstalldirs 2KB
depcomp 14KB
compile 3KB
config.guess 42KB
Makefile.am 0B
config.sub 30KB
Makefile.in 7KB
missing 10KB
install-sh 7KB
COPYING 18KB
configure.ac 4KB
共 83 条
- 1
小波思基
- 粉丝: 70
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0