# [FFmpeg-devel] [PATCH 2/3] lavd: add teletext quantizer

Michael Niedermayer michael at niedermayer.cc
Wed Jan 13 20:32:31 CET 2016

```On Wed, Jan 13, 2016 at 05:01:01AM +0300, Andrey Turkin wrote:
> Why not use libzvbi's slicer? It should be pretty robust with
> less-than-ideal signal.
>
> Regarding your code - is there a need to calculate a frequency? I did
> something similar a while back with VBI from TV signal and in my experience:
>
> a) this kind of frequency/phase estimation doesn't work that well on a
> noisy signal.

>  b) there's really no need to estimate frequency - it's a known constant
> (well it depends on a standard but in each standard it is a constant) and
> generators usually don't deviate from it; you just need to get a good phase
> estimation based on, say, local maxima/minima of run-in bits.

to calculate the phase

the area that has alternating 0/1 values can be correlated with a
sin() and a cos(), if you consider the 2 resulting values as x and y
coordinates the angle they form from the origin is the phase.
(this can be worded simpler using complex numbers)

when above is done its essential that a whole multiple of cycles is
used the important part is that the used sin(x) and cos(x) vectors are
orthogonal, that is sum sin(x) * cos(x) over the x values considered is
0 cutting them off randomls would break that
(its also possible to use windowing instead of a exact multiple of cycles)

consider that the phase is 0 so our signal input is exactly
cos(x) (if we define that as 0°), the dot product of that with cos(x)
is "1" and sin(x) is 0
now if our input is shifted by 90deg that is it matches sin(x)
then the dot product with a cos(x) vector is 0 and sin(x) is 1
...
(also i for simpliity normalized the values, sum of cos(x)*cos(x) for
x from 0 to n would of course be larger than 1 for a larger n)

PS: not complaining about calculating the phase by some other means
above is just a suggestion

[...]
--

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160113/f066d7d5/attachment.sig>
```