Browse Source

Replace short functinos with static inlines in tsfuncs.h

Georgi Chorbadzhiyski 12 years ago
parent
commit
1feb066d7e
2 changed files with 35 additions and 48 deletions
  1. 0
    38
      tsfuncs.c
  2. 35
    10
      tsfuncs.h

+ 0
- 38
tsfuncs.c View File

@@ -16,44 +16,6 @@ void ts_packet_init_null(uint8_t *ts_packet) {
16 16
 	ts_packet[3] = 0x00;
17 17
 }
18 18
 
19
-inline int ts_packet_is_pusi(uint8_t *ts_packet) {
20
-	return (ts_packet[1] &~ 0xbf) >> 6;
21
-}
22
-
23
-inline uint16_t ts_packet_get_pid(uint8_t *ts_packet) {
24
-	return (ts_packet[1] &~ 0xE0) << 8 | ts_packet[2];
25
-}
26
-
27
-inline void ts_packet_set_pid(uint8_t *ts_packet, uint16_t new_pid) {
28
-	ts_packet[1]  = (ts_packet[1] &~ 0x1f) | (new_pid >> 8);	// 111xxxxx xxxxxxxx
29
-	ts_packet[2]  = new_pid &~ 0xff00;
30
-}
31
-
32
-inline uint8_t ts_packet_get_cont(uint8_t *ts_packet) {
33
-	return (ts_packet[3] &~ 0xF0);	// 1111xxxx
34
-}
35
-
36
-inline void ts_packet_set_cont(uint8_t *ts_packet, uint8_t value) {
37
-	// Mask the last 4 bits (continuity), then set the continuity
38
-	ts_packet[3] =  (ts_packet[3] &~ 0x0F) | (value &~ 0xF0);
39
-}
40
-
41
-inline void ts_packet_inc_cont(uint8_t *ts_packet, uint8_t increment) {
42
-	ts_packet_set_cont(ts_packet, ts_packet_get_cont(ts_packet) + increment);
43
-}
44
-
45
-inline int ts_packet_get_scrambled(uint8_t *ts_packet) {
46
-	return ts_packet[3] >> 6; // 0 is not scamlbed, 1 is reserved, 2 or 3 mean scrambled
47
-}
48
-
49
-inline int ts_packet_is_scrambled(uint8_t *ts_packet) {
50
-	return ts_packet_get_scrambled(ts_packet) > 1;
51
-}
52
-
53
-inline void ts_packet_set_not_scrambled(uint8_t *ts_packet) {
54
-	ts_packet[3] = ts_packet[3] &~ 0xc0; // Mask top two bits (11xxxxxx)
55
-}
56
-
57 19
 void ts_packet_set_scrambled(uint8_t *ts_packet, enum ts_scrambled_type stype) {
58 20
 	ts_packet_set_not_scrambled(ts_packet);
59 21
 	if (stype == scrambled_with_even_key)

+ 35
- 10
tsfuncs.h View File

@@ -38,21 +38,46 @@ enum ts_scrambled_type {
38 38
 // Packet manipulation
39 39
 void            ts_packet_init_null (uint8_t *ts_packet);
40 40
 
41
-int             ts_packet_is_pusi   (uint8_t *ts_packet);
41
+static inline int ts_packet_is_pusi(uint8_t *ts_packet) {
42
+	return (ts_packet[1] &~ 0xbf) >> 6;
43
+}
42 44
 
43
-uint16_t        ts_packet_get_pid   (uint8_t *ts_packet);
44
-void            ts_packet_set_pid   (uint8_t *ts_packet, uint16_t new_pid);
45
+static inline uint16_t ts_packet_get_pid(uint8_t *ts_packet) {
46
+	return (ts_packet[1] &~ 0xE0) << 8 | ts_packet[2];
47
+}
45 48
 
46
-uint8_t         ts_packet_get_cont  (uint8_t *ts_packet);
47
-void            ts_packet_set_cont  (uint8_t *ts_packet, uint8_t value);
48
-void            ts_packet_inc_cont  (uint8_t *ts_packet, uint8_t increment);
49
+static inline void ts_packet_set_pid(uint8_t *ts_packet, uint16_t new_pid) {
50
+	ts_packet[1]  = (ts_packet[1] &~ 0x1f) | (new_pid >> 8);	// 111xxxxx xxxxxxxx
51
+	ts_packet[2]  = new_pid &~ 0xff00;
52
+}
49 53
 
50
-uint8_t         ts_packet_get_payload_offset(uint8_t *ts_packet);
54
+static inline uint8_t ts_packet_get_cont(uint8_t *ts_packet) {
55
+	return (ts_packet[3] &~ 0xF0);	// 1111xxxx
56
+}
57
+
58
+static inline void ts_packet_set_cont(uint8_t *ts_packet, uint8_t value) {
59
+	// Mask the last 4 bits (continuity), then set the continuity
60
+	ts_packet[3] =  (ts_packet[3] &~ 0x0F) | (value &~ 0xF0);
61
+}
62
+
63
+static inline void ts_packet_inc_cont(uint8_t *ts_packet, uint8_t increment) {
64
+	ts_packet_set_cont(ts_packet, ts_packet_get_cont(ts_packet) + increment);
65
+}
66
+
67
+static inline int ts_packet_get_scrambled(uint8_t *ts_packet) {
68
+	return ts_packet[3] >> 6; // 0 is not scamlbed, 1 is reserved, 2 or 3 mean scrambled
69
+}
70
+
71
+static inline int ts_packet_is_scrambled(uint8_t *ts_packet) {
72
+	return ts_packet_get_scrambled(ts_packet) > 1;
73
+}
74
+
75
+static inline void ts_packet_set_not_scrambled(uint8_t *ts_packet) {
76
+	ts_packet[3] = ts_packet[3] &~ 0xc0; // Mask top two bits (11xxxxxx)
77
+}
51 78
 
52
-int             ts_packet_is_scrambled(uint8_t *ts_packet);
53
-int             ts_packet_get_scrambled(uint8_t *ts_packet);
54
-void            ts_packet_set_not_scrambled(uint8_t *ts_packet);
55 79
 void            ts_packet_set_scrambled(uint8_t *ts_packet, enum ts_scrambled_type stype);
80
+uint8_t         ts_packet_get_payload_offset(uint8_t *ts_packet);
56 81
 
57 82
 int				ts_packet_has_pcr		(uint8_t *ts_packet);
58 83
 uint64_t		ts_packet_get_pcr_ex	(uint8_t *ts_packet, uint64_t *pcr_base, uint16_t *pcr_ext);

Loading…
Cancel
Save