NagraTV version 1.00 by Gaston
------------------------------

Licence:
-------

This program is for EDUCATIONAL PURPOSE only. It cannot be sold nor
included in a commercial product. The use of this program may be
prohibited in some countries. Provided that the use of this program is
not prohibited in your country, you can copy it whenever you want. If
you use this code to make a new version, the source MUST BE
REDISTRIBUTED free of charge and you must clearly state that your
program is a derivative of this program.

Purpose:
-------

This program shows how it is possible to decode nagravision coded TV
channels on a PC in near realtime (both video AND sound). It works
only under Linux. Its installation may not be easy if you do not know
very well Linux. Even on a lower end PC (Pentium 133), you can get
about ten frames per second.

Installation:
------------

- This program only works with a BT848 based video card (for example a
Miro PCTV). Ensure that your linux driver is working and is compatible
with the 'video 4 linux' API. You can find the driver at:
http://www.thp.uni-koeln.de/~rjkm/linux/bttv.html . Make sure that you
can watch the TV with a normal program such as 'xawtv'. Note that for
some cards the SECAM support of the driver may be broken. The next
version of the BTTV driver may fix it. You should take at least the
version 0.5.6 of the BTTV driver.

- Make sure that you can watch the channel you want to decode with
your standard TV program. Note that in some countries the table
Europe.chan which gives the frequencies for each channel may be wrong
for some channels.

- Make sure you have a sound card which can do full duplex and the
appropriate Linux driver. The SoundBlaster 16 can do it too, but you
need the commercial version of 'OSS/Linux'. Hopefully you can download
a version of it for a limited period at:
http://www.4front-tech.com/linux.html .

- Make sure you have a recent version of XFree86. Your XFree86
distribution MUST handle the DGA extension in order to have a fast
access to the frame buffer.

- Use your X11 server in 16 bit mode (depth = 16). NagraTV works ONLY
with a depth of 16 bits.

- Modify the Makefile to suit your needs. In particular, put the right
path to the BTTV driver include files.

- Type 'make' to compile the program. You get the binary 'nagratv'.

Use:
---

- First, select the channel you want to decode with a Linux TV viewer
such as 'xawtv'.

- Quit the TV viewer.

- Launch NagraTV as suid root (you need to be root to use the DGA
extension). It should decode video and audio. Use the '-h' option to
have a short help. If you want colors, use the '-c' option. If your PC
is fast enough, use the '-f' option to have a full screen decoding. If
you don't want audio, use '-s'. While playing, quit the program with
'q' or 'ESCAPE'. Try to use the smallest resolution your X server can
handle to have a big picture.

- If the program hangs, you may not have a full duplex sound card. Try
to launch it with the option '-s'.

Algorithms:
----------

- The sound decoding consists in mixing the input signal with a 12800
Hz sinusoidal function.

- The video decoding assumes that the 256 entry permutation table is
already known (NOTE THAT IT MAY CHANGE !) (see the file nagra.c to
select the right table). It tries all the possible keys (there are
32768 ones) and select the right one by correlation. It means that the
decoding can be done either in PAL or SECAM.

Notes:
-----

- This program has been reported to work with a SB16, a Miro PCTV
card, the version 0.5.6 of the BTTV driver, the Linux kernel 2.0.33
and the commercial OSS/Linux sound driver version 3.8.1q.

- The sound decoding is done with 8 bit precision because the
OSS/Linux driver can only handle this precision with the SB16.

- The audio decoder supposes that the coded audio comes from the line
input. See the source sound.c to modify it.

- You can still hear the coded audio because I don't know how to mute
the 'line' input while recording. If you know how to do it (I know it
is possible) please send some feedback.

- On some pictures the correlation algorithm may not work, in
particular with dark or uniform pictures or in case of bad
reception. If your computer is fast, try to increase the number of
lines or columns used for the correlation (see nagra.c).

- In SECAM, color is NOT handled properly in this version because we
let the BT848 do the color decoding on the permuted lines. This is NOT
correct and gives many artefacts and may even not work with some
permuting tables. It is quite surprising that the results are not too
bad on some channels. In PAL, the decoding may be better.
