Board logo

標題: [Raspberry Pi]Compile your own g729 codec [打印本頁]

作者: Qnewbie    時間: 2014-3-4 23:18     標題: [Raspberry Pi]Compile your own g729 codec

本帖最後由 Qnewbie 於 2014-3-4 23:22 編輯

Following the link:
http://smallhacks.wordpress.com/ ... r-other-arm-device/
Please note: G729 is governed by a patent license. More info: http://www.linphone.org/eng/documentation/dev/bcg729.html

In raspberry:
  1. mkdir /usr/src/bcg729
  2. cd /usr/src/bcg729
  3. wget https://bitbucket.org/samm_hg/asterisk-g72x/get/bcg729.tar.gz
  4. tar xvf bcg729.tar.gz
  5. cd samm_hg-asterisk-g72x-7c924918dff5
複製代碼
Edit the build-portable.sh file and change according to your own setting:
  1. # Asterisk 1.8
  2. inc=/asterisk_source_directory/include
  3. def=-DG72X_ASTERISK=asterisk_version
複製代碼
Uncomment the compiler option:
  1. #o="-march=barcelona -msse -msse2 -msse3 -O3 -fomit-frame-pointer -fPIC"
複製代碼
and change it to raspberry pi option:
  1. o="-march=armv6zk -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -O3 -Wall"
複製代碼
Afterwards, you can simply compile:
  1. ./build-portable.sh
複製代碼
To check if your codec is working(asterisk1.8 or later),
  1. ./build-astconv.sh
  2. cp /var/lib/asterisk/sounds/en/demo-thanks.gsm /tmp/demo-thanks.gsm
  3. rasterisk -x "file convert /tmp/demo-thanks.gsm /tmp/demo-thanks.sln"
  4. ./astconv ./codec_g729.so -e 160 /tmp/demo-thanks.sln demo-thanks.g729
複製代碼
If everything works:
  1. cp codec_g72*.so /usr/lib/asterisk/modules/
複製代碼

作者: orangelau    時間: 2014-3-5 00:11

回復 1# Qnewbie


Gooood, 等我試試先
作者: SuiYan    時間: 2014-3-5 02:11

去到呢個 step fail  : ./build-astconv.sh
已經改了內裡的folder
作者: SuiYan    時間: 2014-3-5 02:13

請問有沒有 raspberrypi 造出來的 codec_g72*.so 分享?
作者: Qnewbie    時間: 2014-3-5 04:32

Since it depends on your own asterisk version(defined in build-portable.sh). It is hard to share codec_g72*.so.
作者: SuiYan    時間: 2014-3-7 00:33

Yes, I chaged the setting of build-portable.sh & build-astconv.sh
It show error when ran build-astconv
作者: Qnewbie    時間: 2014-3-7 06:40

本帖最後由 Qnewbie 於 2014-3-7 19:41 編輯

The codec might be OK.

build-astconv.sh requires the version for asterisk is 1.8 or latter.

Try something like
  1. module load codec_g729.so
複製代碼
in asterisk's cli.
作者: ckleea    時間: 2014-3-15 21:17

回復 7# Qnewbie

成功嗎?
作者: 角色    時間: 2014-3-29 09:44

Any progress?
作者: orangelau    時間: 2014-5-3 01:55

試左唔得,用Version1.8或version 10.0都唔得
作者: ckleea    時間: 2014-5-3 07:14

Try this one for asterisk 11 but not sure it works or not
  1. # choose Asterisk or Callweaver version
  2. # Asterisk 10.0
  3. inc=/usr/src/asterisk/asterisk11/include/
  4. #def=-DG72X_ASTERISK=100

  5. # Asterisk 1.8
  6. inc=/home/arkadi/opt/asterisk-1.8.0/include
  7. def=-DG72X_ASTERISK=18

  8. # Asterisk 1.6
  9. #inc=/home/arkadi/opt/asterisk-1.6.2/include
  10. #def=-DG72X_ASTERISK=16

  11. # Asterisk 1.4
  12. #inc=/home/arkadi/opt/asterisk-1.4/include
  13. #def=-DG72X_ASTERISK=14

  14. # Asterisk TRUNK
  15. #inc=/home/arkadi/opt/asterisk-trunk/include
  16. #def=-DG72X_ASTERISK=19

  17. cc=gcc
  18. #cc=i686-pc-linux-gnu-gcc-4.5.1
  19. #o="-march=i686 -g -fPIC"
  20. o="-march=barcelona -msse -msse2 -msse3 -O3 -fomit-frame-pointer -fPIC"
  21. #o="$o -flto -fwhole-program"

  22. ## Raspberry Pi ARM flags
  23. # o="-march=armv6zk -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -O3 -Wall"

  24. #cc=/opt/intel/cc/bin/icc
  25. #o="-xP -O3 -fomit-frame-pointer -ipo -static-intel -fPIC"

  26. # end of configuration

  27. src3="codec_g72x.c
  28. itu/g.723.1a/basop.c
  29. itu/g.723.1a/cod_cng.c
  30. itu/g.723.1a/coder.c
  31. itu/g.723.1a/dec_cng.c
  32. itu/g.723.1a/decod.c
  33. itu/g.723.1a/exc_lbc.c
  34. itu/g.723.1a/lpc.c
  35. itu/g.723.1a/lsp.c
  36. itu/g.723.1a/tab_lbc.c
  37. itu/g.723.1a/tame.c
  38. itu/g.723.1a/util_cng.c
  39. itu/g.723.1a/util_lbc.c
  40. itu/g.723.1a/vad.c"

  41. src9="codec_g72x.c
  42. bcg729/adaptativeCodebookSearch.c
  43. bcg729/codebooks.c
  44. bcg729/computeAdaptativeCodebookGain.c
  45. bcg729/computeLP.c
  46. bcg729/computeWeightedSpeech.c
  47. bcg729/decodeAdaptativeCodeVector.c
  48. bcg729/decodeFixedCodeVector.c
  49. bcg729/decodeGains.c
  50. bcg729/decodeLSP.c
  51. bcg729/decoder.c
  52. bcg729/encoder.c
  53. bcg729/findOpenLoopPitchDelay.c
  54. bcg729/fixedCodebookSearch.c
  55. bcg729/gainQuantization.c
  56. bcg729/interpolateqLSP.c
  57. bcg729/LP2LSPConversion.c
  58. bcg729/LPSynthesisFilter.c
  59. bcg729/LSPQuantization.c
  60. bcg729/postFilter.c
  61. bcg729/postProcessing.c
  62. bcg729/preProcessing.c
  63. bcg729/qLSP2LP.c
  64. bcg729/utils.c"

  65. compile_cmd="$cc -Wall -shared -Xlinker -x -D_GNU_SOURCE $o -fPIC $def -I$inc"
  66. cmd="$compile_cmd -DG72X_3 -DG72X_ITU -Iitu/g.723.1a -o codec_g723.so $src3"; echo $cmd; $cmd
  67. cmd="$compile_cmd -DG72X_9 -DG72X_ITU -Ibcg729 -o codec_g729.so $src9"; echo $cmd; $cmd

  68. strip codec_g723.so
  69. strip codec_g729.so
複製代碼

作者: orangelau    時間: 2014-5-3 23:48

都係唔得
[code]root@raspberrypi:/usr/src/bcg729# cd /usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# #o="-march=barcelona -msse -msse2 -msse3 -O3 -fomit-frame-pointer -fPIC"
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# o="-march=armv6zk -mcpu=arm1176jzf-s -mfloat-abi=hard -mfpu=vfp -O3 -Wall"
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# ./build-portable.sh
gcc -Wall -shared -Xlinker -x -D_GNU_SOURCE -march=barcelona -msse -msse2 -msse3 -O3 -fomit-frame-pointer -fPIC -fPIC -DG72X_ASTERISK=18 -I/home/arkadi/opt/asterisk-1.8.0/include -DG72X_3 -DG72X_ITU -Iitu/g.723.1a -o codec_g723.so codec_g72x.c itu/g.723.1a/basop.c itu/g.723.1a/cod_cng.c itu/g.723.1a/coder.c itu/g.723.1a/dec_cng.c itu/g.723.1a/decod.c itu/g.723.1a/exc_lbc.c itu/g.723.1a/lpc.c itu/g.723.1a/lsp.c itu/g.723.1a/tab_lbc.c itu/g.723.1a/tame.c itu/g.723.1a/util_cng.c itu/g.723.1a/util_lbc.c itu/g.723.1a/vad.c
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
作者: orangelau    時間: 2014-5-3 23:48

gcc -Wall -shared -Xlinker -x -D_GNU_SOURCE -march=barcelona -msse -msse2 -msse3 -O3 -fomit-frame-pointer -fPIC -fPIC -DG72X_ASTERISK=18 -I/home/arkadi/opt/asterisk-1.8.0/include -DG72X_9 -DG72X_ITU -Ibcg729 -o codec_g729.so codec_g72x.c bcg729/adaptativeCodebookSearch.c bcg729/codebooks.c bcg729/computeAdaptativeCodebookGain.c bcg729/computeLP.c bcg729/computeWeightedSpeech.c bcg729/decodeAdaptativeCodeVector.c bcg729/decodeFixedCodeVector.c bcg729/decodeGains.c bcg729/decodeLSP.c bcg729/decoder.c bcg729/encoder.c bcg729/findOpenLoopPitchDelay.c bcg729/fixedCodebookSearch.c bcg729/gainQuantization.c bcg729/interpolateqLSP.c bcg729/LP2LSPConversion.c bcg729/LPSynthesisFilter.c bcg729/LSPQuantization.c bcg729/postFilter.c bcg729/postProcessing.c bcg729/preProcessing.c bcg729/qLSP2LP.c bcg729/utils.c
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
cc1: error: bad value (barcelona) for -march switch
cc1: error: unrecognized command line option ‘-msse’
cc1: error: unrecognized command line option ‘-msse2’
cc1: error: unrecognized command line option ‘-msse3’
strip: 'codec_g723.so': No such file
strip: 'codec_g729.so': No such file
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# ./build-astconv.sh
astconv.c: In function ‘main’:
astconv.c:110:19: error: ‘union ast_frame_subclass’ has no member named ‘codec’
astconv.c: In function ‘__ast_register_translator’:
astconv.c:203:10: error: ‘struct ast_translator’ has no member named ‘srcfmt’
astconv.c:205:15: error: ‘struct ast_translator’ has no member named ‘dstfmt’
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# cp /var/lib/asterisk/sounds/en/demo-thanks.gsm /tmp/demo-thanks.gsm
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# rasterisk -x "file convert /tmp/demo-thanks.gsm /tmp/demo-thanks.sln"
Converted /tmp/demo-thanks.gsm to /tmp/demo-thanks.sln in 63ms
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5# ./astconv ./codec_g729.so -e 160 /tmp/demo-thanks.sln demo-thanks.g729
-bash: ./astconv: No such file or directory
root@raspberrypi:/usr/src/bcg729/samm_hg-asterisk-g72x-7c924918dff5#
[/code]
作者: h20555    時間: 2014-8-21 23:34

following the same URL...

http://smallhacks.wordpress.com/ ... r-other-arm-device/

I'm able to compile g729 on raspberry pi. The trick is you have to compile and install Bcg729 1st following by compiling asterisk-g72x. That is.
作者: orangelau    時間: 2014-8-22 13:33

回復 14# h20555


    Ok, thanks
作者: SuiYan    時間: 2014-8-23 15:19

成功了嗎?
作者: ttmuskie    時間: 2014-8-23 19:27

Compiled under asterisk 11.10.0:

g729.zip (106.34 KB)

附件: g729.zip (2014-8-23 19:27, 106.34 KB) / 下載次數 937
http://telecom-cafe.com/forum/attachment.php?aid=3332&k=0b193ec9999aef15f44ce16e5ef545c0&t=1732329872&sid=8heMhP
作者: orangelau    時間: 2014-8-25 00:22

回復 16# SuiYan


    呢幾日比較忙,未搞!
作者: orangelau    時間: 2014-8-25 00:23

回復 17# ttmuskie


    Thanks,ching
作者: orangelau    時間: 2014-8-30 14:58

回復 17# ttmuskie

多謝CHING分享,G729 CODEC可用,其安放路徑如下: /usr/lib/asterisk/modules
Screen Shot 2014-08-30 at 2.42.28 pm.jpg

圖片附件: Screen Shot 2014-08-30 at 2.42.28 pm.jpg (2014-8-30 14:58, 379.55 KB) / 下載次數 941
http://telecom-cafe.com/forum/attachment.php?aid=3336&k=301ffefd8252467da7e18650b69789fc&t=1732329872&sid=8heMhP


作者: orangelau    時間: 2014-8-30 14:59

回復 17# ttmuskie


    CHING:

可以寫一個COMPLIE G729既教程出來嗎?
作者: alang    時間: 2014-8-30 18:16

回復 17# ttmuskie

目前網路上可以找到的方式,是透過 Bcg729 library 來編譯而且不能編譯 g723, 只有 g729;不過你的這個更厲害了,還不曾見過有類似的分享。




歡迎光臨 電訊茶室 (http://telecom-cafe.com/forum/) Powered by Discuz! 7.2