xine-lib  1.2.9
real_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
6  * xine is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * xine is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19  */
20 
21 static inline void demux_real_sipro_swap (char buffer[], int bs)
22 {
23  /* bs = nybbles per subpacket */
24  static const unsigned char sipr_swaps[38][2] = {
25  {0, 63}, {1, 22}, {2, 44}, {3, 90}, {5, 81}, {7, 31}, {8, 86}, {9, 58},
26  {10, 36}, {12, 68}, {13, 39}, {14, 73}, {15, 53}, {16, 69}, {17, 57},
27  {19, 88}, {20, 34}, {21, 71}, {24, 46}, {25, 94}, {26, 54}, {28, 75},
28  {29, 50}, {32, 70}, {33, 92}, {35, 74}, {38, 85}, {40, 56}, {42, 87},
29  {43, 65}, {45, 59}, {48, 79}, {49, 93}, {51, 89}, {55, 95}, {61, 76},
30  {67, 83}, {77, 80}
31  };
32  int n;
33 
34  for (n = 0; n < 38; ++n)
35  {
36  int j;
37  int i = bs * sipr_swaps[n][0];
38  int o = bs * sipr_swaps[n][1];
39  /* swap nibbles of block 'i' with 'o' TODO: optimize */
40  for (j = 0; j < bs; ++j)
41  {
42  int x = (i & 1) ? (buffer[i >> 1] >> 4) : (buffer[i >> 1] & 0x0F);
43  int y = (o & 1) ? (buffer[o >> 1] >> 4) : (buffer[o >> 1] & 0x0F);
44  if (o & 1)
45  buffer[o >> 1] = (buffer[o >> 1] & 0x0F) | (x << 4);
46  else
47  buffer[o >> 1] = (buffer[o >> 1] & 0xF0) | x;
48  if (i & 1)
49  buffer[i >> 1] = (buffer[i >> 1] & 0x0F) | (y << 4);
50  else
51  buffer[i >> 1] = (buffer[i >> 1] & 0xF0) | y;
52  ++i;
53  ++o;
54  }
55  }
56 }
static void demux_real_sipro_swap(char buffer[], int bs)
Definition: real_common.h:21