File: section.c

package info (click to toggle)
linuxtv-dvb-apps 1.1.1%2Brev1483-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,556 kB
  • sloc: ansic: 48,832; makefile: 792; perl: 236; sh: 110; xml: 13
file content (25 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "section.h"

/* shamelessly stolen from dvbsnoop, but modified */
u32 getBits (const u8 *buf, int startbit, int bitlen)
{
	const u8 *b;
	u32 mask,tmp_long;
	int bitHigh,i;

	b = &buf[startbit / 8];
	startbit %= 8;

	bitHigh = 8;
	tmp_long = b[0];
	for (i = 0; i < ((bitlen-1) >> 3); i++) {
		tmp_long <<= 8;
		tmp_long  |= b[i+1];
		bitHigh   += 8;
	}

	startbit = bitHigh - startbit - bitlen;
	tmp_long = tmp_long >> startbit;
	mask     = (1ULL << bitlen) - 1;
	return tmp_long & mask;
}