tsdecrypt reads and decrypts CSA encrypted incoming mpeg transport stream over UDP/RTP using code words obtained from OSCAM or similar CAM server. tsdecrypt communicates with CAM server using cs378x (camd35 over tcp) protocol or newcamd protocol. https://georgi.unixsol.org/programs/tsdecrypt/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FFdecsa_init 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/sh
  2. # Compile FFdecsa in different modes to find the fastest
  3. # This script is based on the conigure script from getstream_a84
  4. # Copyright (C) 2012 Unix Solutions Ltd.
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License version 2
  8. # as published by the Free Software Foundation.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  18. cd $(dirname $0)
  19. CROSS="$1"
  20. CC="${2:-cc}"
  21. FFDECSA_CFLAGS="-O3 -fexpensive-optimizations -funroll-loops"
  22. MAX_MODE="PARALLEL_32_INT"
  23. FFDECSA_MODES="PARALLEL_32_INT"
  24. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_64_2INT"
  25. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_64_LONG"
  26. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_64_MMX"
  27. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_2LONG"
  28. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_2MMX"
  29. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_SSE"
  30. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_SSE2"
  31. # Internal variables
  32. OUTPUT_FILE="FFdecsa.opts"
  33. FFDECSA_DIR="FFdecsa"
  34. LPREFIX="[FFdecsa]"
  35. MAX_SPEED=0
  36. TMPDIR=`mktemp -d FFdecsa.build.XXXXXXXX` || exit 1
  37. trap "{ rm -rf $TMPDIR ; exit 1; }" INT TERM
  38. cp $FFDECSA_DIR/Makefile $FFDECSA_DIR/*.{c,h} $TMPDIR
  39. log() { printf "%s %-26s : %s\n" "$LPREFIX" "$1" "$2"; }
  40. logn() { printf "%s %-26s : %s" "$LPREFIX" "$1" "$2"; }
  41. log "Using compiler" "$CROSS$CC"
  42. log "FFdecsa modes" "$FFDECSA_MODES"
  43. cpu_have() {
  44. # Check whether option is supported by the host CPU
  45. grep "^flags.* $1 " /proc/cpuinfo >/dev/null 2>&1
  46. eval test $? -eq 0
  47. }
  48. cc_check() {
  49. # Check whether option is supported by the target CC
  50. $CROSS$CC $1 -xc -o /dev/null - 2>/dev/null << EOF
  51. int main(void) { return 0; }
  52. EOF
  53. eval test $? -eq 0
  54. }
  55. test_ffdecsa_mode() {
  56. MODE="$1"
  57. logn "Testing $MODE"
  58. ERRLOG="FFdecsa_build_$MODE.log"
  59. MAKECMD="make -C $TMPDIR FFdecsa_test PARALLEL_MODE=$MODE FLAGS=\"$FFDECSA_CFLAGS\" COMPILER=\"$CROSS$CC\""
  60. eval $MAKECMD >/dev/null 2>$TMPDIR/$ERRLOG
  61. if [ $? -ne 0 ]
  62. then
  63. echo "ERROR: build failed, check $ERRLOG"
  64. (echo "$MAKECMD" ; echo ; cat $TMPDIR/$ERRLOG) > $ERRLOG
  65. return
  66. fi
  67. if [ "$CROSS" != "" ]
  68. then
  69. cp $TMPDIR/FFdecsa_test FFdecsa_test_$MODE
  70. echo "CROSS COMPILE OK: You can run FFdecsa_test_$MODE on the target machine"
  71. return
  72. fi
  73. RESULTS_FILE="$TMPDIR/test_results.txt"
  74. $TMPDIR/FFdecsa_test >/dev/null 2>$RESULTS_FILE
  75. if [ $? -ne 0 ]
  76. then
  77. echo "ERROR: test run failed"
  78. return
  79. fi
  80. grep FAILED $RESULTS_FILE >/dev/null 2>&1
  81. if test $? -ne 1; then
  82. echo "ERROR: test failed"
  83. return
  84. fi
  85. SPEED=`grep "speed=.*Mbit" $RESULTS_FILE | sed -e 's/^.*=\([0-9]*\)\.[0-9]* Mbit.*$/\1/'`
  86. echo "OK $SPEED Mbit/s"
  87. if [ $SPEED -gt $MAX_SPEED ]
  88. then
  89. MAX_SPEED=$SPEED
  90. MAX_MODE=$MODE
  91. fi
  92. }
  93. # Check CPU and compiler flags
  94. if cc_check -march=native
  95. then
  96. FFDECSA_CFLAGS="$FFDECSA_CFLAGS -march=native"
  97. elif cc_check -march=pentium; then
  98. FFDECSA_CFLAGS="$FFDECSA_CFLAGS -march=pentium"
  99. fi
  100. OPTS=""
  101. FLAGS=""
  102. for flag in mmx sse sse2
  103. do
  104. if cpu_have $flag
  105. then
  106. OPTS="$OPTS $flag"
  107. if cc_check -m$flag
  108. then
  109. FFDECSA_CFLAGS="$FFDECSA_CFLAGS -m$flag"
  110. fi
  111. fi
  112. done
  113. log "Host CPU" "$(uname -m) $OPTS"
  114. log "FFdecsa CFLAGS" "$FFDECSA_CFLAGS"
  115. for MODE in $FFDECSA_MODES
  116. do
  117. test_ffdecsa_mode $MODE
  118. make -C $TMPDIR clean >/dev/null 2>&1
  119. done
  120. log "Choosing PARALLEL_MODE" "$MAX_MODE ($MAX_SPEED Mbps)"
  121. echo "# This file is included from Makefile
  122. DECRYPT_LIB = ffdecsa
  123. FFDECSA_OBJ = FFdecsa/FFdecsa.o" > $OUTPUT_FILE
  124. echo "FFDECSA_MODE = $MAX_MODE" >> $OUTPUT_FILE
  125. echo "FFDECSA_FLAGS = \"$FFDECSA_CFLAGS\"" >> $OUTPUT_FILE
  126. rm -rf $TMPDIR