Using the liba52 API
--------------------
liba52 provides a low-level interface to decoding audio frames encoded
using ATSC standard A/52 aka AC-3. liba52 provides downmixing and
dynamic range compression for the following output configurations:
A52_CHANNEL : Dual mono. Two independant mono channels.
A52_CHANNEL1 : First of the two mono channels above.
A52_CHANNEL2 : Second of the two mono channels above.
A52_MONO : Mono.
A52_STEREO : Stereo.
A52_DOLBY : Dolby surround compatible stereo.
A52_3F : 3 front channels (left, center, right)
A52_2F1R : 2 front, 1 rear surround channel (L, R, S)
A52_3F1R : 3 front, 1 rear surround channel (L, C, R, S)
A52_2F2R : 2 front, 2 rear surround channels (L, R, LS, RS)
A52_3F2R : 3 front, 2 rear surround channels (L, C, R, LS, RS)
A52_LFE : Low frequency effects channel. Normally used to connect a
subwoofer. Can be combined with any of the above channels.
For example: A52_3F2R | A52_LFE -> 3 front, 2 rear, 1 LFE (5.1)
Initialization
--------------
sample_t * a52_init (uint32_t mm_accel);
Initializes the A/52 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, the only accelleration implemented is
MM_ACCEL_MLIB, which uses the 'mlib' library if installed. mlib is
only available on some Sun Microsystems platforms.
The return value is a pointer to a properly-aligned sample buffer used
for output samples.
Probing the bitstream
---------------------
int a52_syncinfo (uint8_t * buf, int * flags,
int * sample_rate, int * bit_rate);
The A/52 bitstream is composed of several a52 frames concatenated one
after each other. An a52 frame is the smallest independantly decodable
unit in the stream.
buf must contain at least 7 bytes from the input stream. If these look
like the start of a valid a52 frame, a52_syncinfo() returns the size
of the coded frame in bytes, and fills flags, sample_rate and bit_rate
with the information encoded in the stream. The returned size is
guaranteed to be an even number between 128 and 3840. 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 A52_LFE bit is set if there is an LFE channel coded in
this stream, and by masking flags with A52_CHANNEL_MASK you will get a
value that describes the full-bandwidth channels, as one of the
A52_CHANNEL...A52_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 a52 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.
It is recommended 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.
Starting to decode a frame
--------------------------
int a52_frame (a52_state_t * state, uint8_t * buf, int * flags,
sample_t * level, sample_t bias);
This starts the work of decoding the A/52 frame (to be completed using
a52_block()). buf should point to the beginning of the complete frame
of the full size returned by a52_syncinfo().
You should pass in the flags the speaker configuration that you
support, and liba52 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
(a52_syncinfo() returned A52_2F2R in the flags), and you have 3+1
speakers (you passed A52_3F1R), then liba52 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. liba52 will
return A52_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 liba52 couldnt give you what you
wanted because some of the channels were not encoded in the stream
though.
Level, bias, and A52_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. liba52 provides two methods of controlling the range of the
output, either before or after the downmix stage.
If you do not set A52_ADJUST_LEVEL, liba52 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 A52_ADJUST_LEVEL flag will instruct liba52 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 A52_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 a52dec 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 a52_dynrng (a52_state_t * state,
sample_t (* call) (sample_t, void *), void * data);
This function is purely optional. If you dont call it, liba52 will
provide the default behaviour, which is to apply the full dynamic
range compression as specified in the A/52 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 a52_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.
Decoding blocks
---------------
int a52_block (a52_state_t * state, sample_t * samples);
Every A/52 frame is composed of 6 blocks, each with an output of 256
samples for each channel. The a52_block() function decodes the next
block in the frame, and should be called 6 times to decode all of the
audio in the frame. After each call, you should extract the audio data
from the sample buffer.
The sample pointer given should be the one a52_init() returned.
After this function returns, the samples buuffer will contain 256
samples for the first channel, followed by 256 samples for the second
channel, etc... the channel order is LFE, left, center, right, left
没有合适的资源?快使用搜索试试~ 我知道了~
a52dec-0.7.4.tar.gz
4星 · 超过85%的资源 需积分: 10 253 下载量 42 浏览量
2014-11-10
13:12:56
上传
评论
收藏 236KB GZ 举报
温馨提示
共87个文件
c:21个
h:13个
in:12个
linux 下安装ffmpeg 所需解码器包 同时可查阅本人博客 “Linux 下完整安装ffmpeg(包括各种解码器)”,提供linux下ffmpeg的安装步骤以及安装过程中出现的问题处理记录。
资源推荐
资源详情
资源评论
收起资源包目录
a52dec-0.7.4.tar.gz (87个子文件)
a52dec-0.7.4
bootstrap 134B
AUTHORS 1KB
autotools
config.guess 38KB
mkinstalldirs 722B
config.sub 29KB
install-sh 5KB
Makefile.am 0B
missing 6KB
Makefile.in 4KB
ltmain.sh 138KB
COPYING 18KB
HISTORY 876B
aclocal.m4 122KB
INSTALL 2KB
vc++
a52dec.dsw 1KB
inttypes.h 299B
Makefile.am 76B
a52dec.dsp 5KB
config.h 3KB
Makefile.in 4KB
liba52.dsp 3KB
libao.dsp 3KB
src
getopt.h 6KB
gettimeofday.c 1KB
extract_a52.1 945B
gettimeofday.h 1KB
Makefile.am 356B
configure.incl 285B
extract_a52.c 9KB
getopt.c 30KB
a52dec.c 14KB
Makefile.in 10KB
a52dec.1 1KB
Makefile.am 91B
doc
liba52.txt 9KB
Makefile.am 24B
Makefile.in 4KB
configure 323KB
libao
audio_out_wav.c 4KB
audio_out_al.c 4KB
audio_out_null.c 2KB
audio_out_aif.c 4KB
Makefile.am 288B
configure.incl 1KB
audio_out_oss.c 5KB
audio_out_peak.c 2KB
float2s16.c 4KB
audio_out_solaris.c 4KB
audio_out_internal.h 1KB
Makefile.in 9KB
audio_out_win.c 6KB
audio_out_float.c 2KB
audio_out.c 3KB
test
globals 589B
Makefile.am 156B
compile 1KB
compare.c 2KB
Makefile.in 8KB
tests 298B
regression 1KB
NEWS 1KB
liba52
imdct.c 12KB
a52_internal.h 4KB
bitstream.h 2KB
Makefile.am 273B
bit_allocate.c 9KB
configure.incl 561B
bitstream.c 2KB
tables.h 9KB
parse.c 22KB
Makefile.in 9KB
downmix.c 16KB
acinclude.m4 4KB
TODO 443B
Makefile.in 11KB
README 6KB
configure.in 3KB
ChangeLog 4KB
include
tendra.h 1KB
a52.h 2KB
audio_out.h 2KB
Makefile.am 86B
config.h.in 3KB
mm_accel.h 1KB
stamp-h.in 0B
Makefile.in 7KB
attributes.h 1KB
共 87 条
- 1
资源评论
- elovehy2016-03-02谢谢, 找了好久
- bnuchenzhiyan1232015-08-29咋就没人把ffmpeg的那些解码器整合一下呢,谢谢
tomas家的小拨浪鼓
- 粉丝: 8
- 资源: 38
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Screenshot_20240430_144340_com.ss.android.ugc.live.jpg
- 回到山沟沟.mp3
- 基于matlab实现自适应波束形成RLS及LMS算法仿真源程序1.rar
- 基于matlab实现自己编写的基于卡尔曼滤波的利用加速度传感器的计步器,测试数据是传感器放在腰部和手臂 .rar
- 基于matlab实现阵列信号处理,波束形成.rar
- 111111111111111111
- 基于matlab实现计步器编程;对当前的计步器装置的数值算法模拟 .rar
- Mdb学习查看PW;access;mdb;pw;password;patch
- 基于matlab实现关于语音信号声源定位DOA估计所用的一些传统算法.rar
- 基于ultralytics-yolov8, 将其检测/分类/分割/姿态等任务移植到rk3588上
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功