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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 (COPYING file) for more details.
  14. cd $(dirname $0)
  15. CROSS="$1"
  16. CC="${2:-cc}"
  17. FFDECSA_CFLAGS="-O3 -fexpensive-optimizations -funroll-loops"
  18. MAX_MODE="PARALLEL_32_INT"
  19. FFDECSA_MODES="PARALLEL_32_INT"
  20. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_64_2INT"
  21. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_64_LONG"
  22. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_64_MMX"
  23. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_2LONG"
  24. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_2MMX"
  25. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_SSE"
  26. FFDECSA_MODES="$FFDECSA_MODES PARALLEL_128_SSE2"
  27. # Internal variables
  28. OUTPUT_FILE="FFdecsa.opts"
  29. FFDECSA_DIR="FFdecsa"
  30. LPREFIX="[FFdecsa]"
  31. MAX_SPEED=0
  32. TMPDIR=`mktemp -d FFdecsa.build.XXXXXXXX` || exit 1
  33. trap "{ rm -rf $TMPDIR ; exit 1; }" INT TERM
  34. cp $FFDECSA_DIR/Makefile $FFDECSA_DIR/*.c $FFDECSA_DIR/*.h $TMPDIR
  35. log() { printf "%s %-26s : %s\n" "$LPREFIX" "$1" "$2"; }
  36. logn() { printf "%s %-26s : %s" "$LPREFIX" "$1" "$2"; }
  37. log "Using compiler" "$CROSS$CC"
  38. log "FFdecsa modes" "$FFDECSA_MODES"
  39. cpu_have() {
  40. # Check whether option is supported by the host CPU
  41. grep "^flags.* $1 " /proc/cpuinfo >/dev/null 2>&1
  42. eval test $? -eq 0
  43. }
  44. cc_check() {
  45. # Check whether option is supported by the target CC
  46. $CROSS$CC $1 -xc -o /dev/null - 2>/dev/null << EOF
  47. int main(void) { return 0; }
  48. EOF
  49. eval test $? -eq 0
  50. }
  51. test_ffdecsa_mode() {
  52. MODE="$1"
  53. logn "Testing $MODE"
  54. ERRLOG="FFdecsa_build_$MODE.log"
  55. MAKECMD="make -C $TMPDIR FFdecsa_test PARALLEL_MODE=$MODE FLAGS=\"$FFDECSA_CFLAGS\" COMPILER=\"$CROSS$CC\""
  56. eval $MAKECMD >/dev/null 2>$TMPDIR/$ERRLOG
  57. if [ $? -ne 0 ]
  58. then
  59. echo "ERROR: build failed, check $ERRLOG"
  60. (echo "$MAKECMD" ; echo ; cat $TMPDIR/$ERRLOG) > $ERRLOG
  61. return
  62. fi
  63. if [ "$CROSS" != "" ]
  64. then
  65. cp $TMPDIR/FFdecsa_test FFdecsa_test_$MODE
  66. echo "CROSS COMPILE OK: You can run FFdecsa_test_$MODE on the target machine"
  67. return
  68. fi
  69. RESULTS_FILE="$TMPDIR/test_results.txt"
  70. $TMPDIR/FFdecsa_test >/dev/null 2>$RESULTS_FILE
  71. if [ $? -ne 0 ]
  72. then
  73. echo "ERROR: test run failed"
  74. return
  75. fi
  76. grep FAILED $RESULTS_FILE >/dev/null 2>&1
  77. if test $? -ne 1; then
  78. echo "ERROR: test failed"
  79. return
  80. fi
  81. SPEED=`grep "speed=.*Mbit" $RESULTS_FILE | sed -e 's/^.*=\([0-9]*\)\.[0-9]* Mbit.*$/\1/'`
  82. echo "OK $SPEED Mbit/s"
  83. if [ $SPEED -gt $MAX_SPEED ]
  84. then
  85. MAX_SPEED=$SPEED
  86. MAX_MODE=$MODE
  87. fi
  88. }
  89. # Check CPU and compiler flags
  90. if cc_check -march=native
  91. then
  92. FFDECSA_CFLAGS="$FFDECSA_CFLAGS -march=native"
  93. elif cc_check -march=pentium; then
  94. FFDECSA_CFLAGS="$FFDECSA_CFLAGS -march=pentium"
  95. fi
  96. OPTS=""
  97. FLAGS=""
  98. for flag in mmx sse sse2
  99. do
  100. if cpu_have $flag
  101. then
  102. OPTS="$OPTS $flag"
  103. if cc_check -m$flag
  104. then
  105. FFDECSA_CFLAGS="$FFDECSA_CFLAGS -m$flag"
  106. fi
  107. fi
  108. done
  109. log "Host CPU" "$(uname -m) $OPTS"
  110. log "FFdecsa CFLAGS" "$FFDECSA_CFLAGS"
  111. for MODE in $FFDECSA_MODES
  112. do
  113. test_ffdecsa_mode $MODE
  114. make -C $TMPDIR clean >/dev/null 2>&1
  115. done
  116. log "Choosing PARALLEL_MODE" "$MAX_MODE ($MAX_SPEED Mbps)"
  117. echo "# This file is included from Makefile
  118. DECRYPT_LIB = ffdecsa
  119. FFDECSA_OBJ = FFdecsa/FFdecsa.o" > $OUTPUT_FILE
  120. echo "FFDECSA_MODE = $MAX_MODE" >> $OUTPUT_FILE
  121. echo "FFDECSA_FLAGS = \"$FFDECSA_CFLAGS\"" >> $OUTPUT_FILE
  122. rm -rf $TMPDIR