返回列表 發帖

[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/
複製代碼
RB750G, RB2011UAS-2HnD
IP01, A580IP, AT-610

回復 1# Qnewbie


Gooood, 等我試試先

TOP

去到呢個 step fail  : ./build-astconv.sh
已經改了內裡的folder

TOP

請問有沒有 raspberrypi 造出來的 codec_g72*.so 分享?

TOP

Since it depends on your own asterisk version(defined in build-portable.sh). It is hard to share codec_g72*.so.
RB750G, RB2011UAS-2HnD
IP01, A580IP, AT-610

TOP

Yes, I chaged the setting of build-portable.sh & build-astconv.sh
It show error when ran build-astconv

TOP

本帖最後由 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.
RB750G, RB2011UAS-2HnD
IP01, A580IP, AT-610

TOP

回復 7# Qnewbie

成功嗎?

TOP

Any progress?

TOP

試左唔得,用Version1.8或version 10.0都唔得

TOP

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
複製代碼

TOP

都係唔得
[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’

TOP

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]

TOP

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.

TOP

回復 14# h20555


    Ok, thanks

TOP

返回列表