[MPlayer-dev-eng] [PATCH] Proper teletext language support

Michael Niedermayer michaelni at gmx.at
Mon Aug 27 01:07:13 CEST 2007


Hi

On Sun, Aug 26, 2007 at 11:14:22PM +0200, Michael Niedermayer wrote:
> Hi
> 
> On Mon, Aug 27, 2007 at 02:39:18AM +0700, Vladimir Voroshilov wrote:
> > Here is patch for proper teletext language support.
> > 
> > It adds support for X/28/0 packet carrying primary and secondary charset info.
> > 
> > I want to add later (in separate patch) new "default charset code"
> > option for cases when X/28/0 is not transmitted by network provider.
> > 
> > Please anybody look at patch and say is it ok to commit ?
> [...]
> 
[...]
> use the following, untested but the description in the spec is clear enough so
> you should not have a problem with fixing any silly +-1 errors i made :)
> 
> /**
>  *
>  * Note, bits must be correctly ordered, that is for 8,4
>  * P1 P2 D1 P3 D2 D3 D4 P4
>  * and for 24,18
>  * P1 P2 D1 P3 D2 D3 D4 P4  D5 D6 D7 D8 D9 DA DB P5  DC DD DE DF DG DH DI P6
>  * @param len the length of the hamming code for example 7 (for 8,4) or 23 for (24,8)

i of course meant 24,18 here, not 24,8


>  * @param ext 1 if the code is a extended hamming code 0 of not (all in teletext are extended)
>  */
> int decode_hamm(unsigned codeword, int len, int ext){
>     unsigned syndrom=0;
>     unsigned data=0;
>     int i;
> 
>     for(i=0; i<len; i++)
>         syndrom ^= (((codeword>>i)&1)*(i+1);

btw, i dont know how often these 24bit hamming codes occur, so if they are
frequent then you can try something like:

cw=codeword;
cw ^= (cw>> 1) & 0xAAAAAAAA;
cw ^= (cw>> 2) & 0x99999999;
cw ^= (cw>> 4) & 0x87878787;
cw ^= (cw>> 8) & 0x807F807F;
cw ^=  cw>>16;
cw&=3+8+128+32768;
if(!cw)
    no error

syndrom= (cw&3) + ((cw&8)>>1) + ((cw&128)>>4) + (cw>>11);


[...]
>     for(i=len; i>0; i--){
>         if(i & (i-1))
>             data= 2*data + ((codeword>>(i-1))&1);
>     }

and this can be done like:
((codeword>>2)&1) + ((codeword>>3)&0xE) + ...

which would be faster

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20070827/532b7645/attachment.pgp>


More information about the MPlayer-dev-eng mailing list