speaker : chungyi wang advisor: quincy wu date : 2007.8.8

21
Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Upload: ezra-mcdonald

Post on 30-Dec-2015

224 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speaker : Chungyi WangAdvisor: Quincy WuDate : 2007.8.8

Page 2: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

outlineIntroductionWhy Speex ?Speex Tools – WindowsSpeex API – LinuxReference

2007/8/8 2

Page 3: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

IntroductionWhat is the Speex ?

One kind of compression software (or API)

What is the main advantage of the Speex ?Good compression ratio (and variable)

What kinds of application need the Speex ?Audio file (ex.ogg, spx)VoIP

2007/8/8 3

Page 4: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Why Speex ? (1/5)

2007/8/8 4

320 bytes

PCMRTP

• 320 x 50 = 16000 (15.625 kb/sec)• Need compression !!

Page 5: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Why Speex ? (2/5)

2007/8/8 5

Good compression ratio !!

Speex encode

Speex decode

PCMRTP

320 bytes

(6~62) bytes

320 bytes

Page 6: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Why Speex ? (3/5)

2007/8/8 6From : http://www.speex.org/comparison/

Page 7: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Why Speex ? (4/5)Speex is based on CELP and is designed to compress

voice at bitrates ranging from 2 to 44 kbps. Some of Speex's features include: - Narrowband (8 kHz), wideband (16 kHz), and

ultrawideband (32 kHz) compression in the same bitstream

- Intensity stereo encoding - Packet loss concealment - Variable bitrate operation (VBR) - Voice Activity Detection (VAD) - Discontinuous Transmission (DTX) - Fixed-point port - Acoustic echo canceller - Noise suppression

2007/8/8 7

Page 8: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Why Speex ? (5/5)Lossy

Depend on quality (and compression ratio)

From : http://en.wikipedia.org/wiki/Lossy_data_compression

2007/8/8 8

Page 9: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex Tools – Windows (1/4)Download

http://downloads.us.xiph.org/releases/speex/speex-tools-win32-v1.2beta1.zip

Speex Toolsspeexenc.exespeexdec.exe

2007/8/8 9

Page 10: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex Tools – Windows (2/4)speexenc.exe

speexenc [input_file] [outfile] input_file : wavoutfile_file : spx

speexenc –quality n [input_file] [outfile]n : Quality (10-0)

2007/8/8 10

Page 11: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex Tools – Windows (3/4)speexdec.exe

speexdec [input_file] [outfile] input_file : spxoutfile_file : wav

2007/8/8 11

Page 12: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex Tools – Windows (4/4)Demo

2007/8/8 12

Page 13: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (1/7)Download

http://downloads.us.xiph.org/releases/speex/speex-1.2beta1.tar.gz

SetupLinphone - 2007/01/08 http://ms11.voip.edu.tw/~webmaster/meeting/

http://ms11.voip.edu.tw/~chungyi/ncnu-research/linphone/install.html

2007/8/8 13

Page 14: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (2/7)#include <speex/speex.h>

For API of encoder and decoder

Compilegcc –lspeex source.c

2007/8/8 14

Page 15: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (3/7)

2007/8/8 15

Encoder Init

One round encode

Destory encoder

void *state = speex_encoder_init(&speex_nb_mode);SpeexBits bits;

speex_bits_init(&bits);speex_encoder_ctl(state, SPEEX_SET_QUALITY,

&quality);

speex_bits_reset(&bits);speex_encode(state, input, &bits);

int nbBytes = speex_bits_write(&bits, cbits, 200);

speex_encoder_destroy(state);speex_bits_destroy(&bits);

Page 16: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (4/7)Quality Frame_Size (Bytes)

0 6

1 10

2 15

3 20

4 20

5 28

6 28

7 38

8 38

9 46

10 62

2007/8/8 16

For every 320-bytes

Page 17: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (5/7)Demo

>>make >>gcc -lspeex speex_encode.c -o encode >>gcc -lspeex speex_decode.c -o decode

>>./encode

ResultMakefilespeex_encode.cspeex_encode.txt

2007/8/8 17

Page 18: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (6/7)

2007/8/8 18

Decoder Init

One round decode

Destory decoder

void *state speex_decoder_init(&speex_nb_mode);SpeexBits bits;

speex_bits_init(&bits);

speex_bits_read_from(&bits, cbits[j], nbBytes);speex_decode(state, &bits, output);

speex_decoder_destroy(state);speex_bits_destroy(&bits);

Page 19: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Speex API – Linux (7/7)Demo

>>./decode

Resultspeex_decode.cspeex_decode.txt

2007/8/8 19

Page 20: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Reference (1/2)Speex - mainhttp://www.speex.org/

Speex - windows toolshttp://downloads.us.xiph.org/releases/speex/speex-tools-

win32-v1.2beta1.zip

Speex - windows libhttp://downloads.us.xiph.org/releases/speex/libspeex-

win32-v1.2beta1.zip

Speex - Development RPMhttp://downloads.us.xiph.org/releases/speex/speex-devel-

1.2beta2-1.i386.rpm

2007/8/8 20

Page 21: Speaker : Chungyi Wang Advisor: Quincy Wu Date : 2007.8.8

Reference (2/2)Speex – API documentation

(The Speex Codec Manual –very good!!)http://www.speex.org/docs/manual/speex-manual/

Speex – wikihttp://en.wikipedia.org/wiki/Speex

This ppt & demohttp://ms11.voip.edu.tw/~chungyi/ncnu-

research/Speex/Speex.zip

2007/8/8 21