summaryrefslogtreecommitdiff
path: root/packages/libdvb/files/topf2ps.patch
blob: 93503ca92d5c60793bad31aff1dd2d2388b161e6 (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
diff -ruN libdvb-0.5.5/Makefile libdvb-0.5.5-topfield/Makefile
--- libdvb-0.5.5/Makefile	2004-09-16 04:56:21.000000000 +1000
+++ libdvb-0.5.5-topfield/Makefile	2004-12-03 15:53:24.677184191 +1100
@@ -68,7 +68,7 @@
 	make -C libdvbmpeg clean
 	make -C sample_progs clean
 	make -C dvb-mpegtools clean
-	rm include/*~
+	-rm -f include/*~
 
 dist:	
 	mkdir libdvb-$(VERSION)
diff -ruN libdvb-0.5.5/dvb-mpegtools/Makefile libdvb-0.5.5-topfield/dvb-mpegtools/Makefile
--- libdvb-0.5.5/dvb-mpegtools/Makefile	2004-09-16 04:56:21.000000000 +1000
+++ libdvb-0.5.5-topfield/dvb-mpegtools/Makefile	2004-12-03 12:38:58.000000000 +1100
@@ -16,7 +16,7 @@
 	pesplot pes2ts2 pes_repack split_mpg cut_mpg ts2ps ts2es\
 	insert_pat_pmt get_http extract_pes extract_pes_payload\
 	change_aspect_1_1 change_aspect_4_3 change_aspect_16_9 \
-	change_aspect_221_1
+	change_aspect_221_1 topf2ps
 
 .PHONY: depend clean install uninstall
 
diff -ruN libdvb-0.5.5/dvb-mpegtools/main.cc libdvb-0.5.5-topfield/dvb-mpegtools/main.cc
--- libdvb-0.5.5/dvb-mpegtools/main.cc	2004-09-16 04:56:21.000000000 +1000
+++ libdvb-0.5.5-topfield/dvb-mpegtools/main.cc	2004-12-03 12:45:39.000000000 +1100
@@ -52,7 +52,7 @@
         write(STDOUT_FILENO, buf, count);
 }
 
-#define PROGS 29
+#define PROGS 30
 
 char *prognames[PROGS+1] = { "streamtype",    // 0
                              "ts2pes", 	    // 1
@@ -83,6 +83,7 @@
                              "change_aspect_4_3",
                              "change_aspect_16_9",
                              "change_aspect_221_1",	// 28
+                             "topf2ps",
                              " "
                            };
 
@@ -116,6 +117,7 @@
        change_aspect_4_3_,
        change_aspect_16_9_,
        change_aspect_221_1_,	// 28
+       topf2ps_,
        none_,
      };
 
@@ -226,6 +228,11 @@
                 cerr << "or     insert_pat_pmt < <filename> (or pipe)" << endl;
                 break;
 
+        case topf2ps_:
+                cerr << "usage: topf2ps <filename>" << endl;
+                cerr << "or     topf2ps < <filename> (or pipe)" << endl;
+                break;
+
         case get_http_:
                 cerr << "usage: get_http <URL>" << endl;
                 break;
@@ -345,6 +352,10 @@
                         }
                         break;
 
+                case topf2ps_:
+                        topf_to_ps(fd, STDOUT_FILENO);
+                        break;
+
                 case insert_pat_pmt_:
                         insert_pat_pmt( fd, STDOUT_FILENO);
                         break;
diff -ruN libdvb-0.5.5/include/transform.h libdvb-0.5.5-topfield/include/transform.h
--- libdvb-0.5.5/include/transform.h	2004-09-16 04:56:21.000000000 +1000
+++ libdvb-0.5.5-topfield/include/transform.h	2004-12-03 12:49:20.000000000 +1100
@@ -192,6 +192,7 @@
 	void kpes_to_ts( p2p *p,uint8_t *buf ,int count );
 	void setup_ts2pes( p2p *pa, p2p *pv, uint32_t pida, uint32_t pidv, 
 			   void (*pes_write)(uint8_t *buf, int count, void *p));
+    void topf_to_ps(int fdin, int fdout);
 	void kts_to_pes( p2p *p, uint8_t *buf);
 	void pes_repack(p2p *p);
 	void extract_from_pes(int fdin, int fdout, uint8_t id, int es);
diff -ruN libdvb-0.5.5/libdvbmpeg/transform.c libdvb-0.5.5-topfield/libdvbmpeg/transform.c
--- libdvb-0.5.5/libdvbmpeg/transform.c	2004-09-16 04:56:21.000000000 +1000
+++ libdvb-0.5.5-topfield/libdvbmpeg/transform.c	2004-12-03 12:50:55.000000000 +1100
@@ -1247,6 +1247,30 @@
 
 }
 
+void topf_to_ps( int fdin, int fdout)
+{
+
+  uint16_t pida, pidv;
+  uint8_t buf[1880];
+  int count = 1;
+
+  if ((count = save_read(fdin, buf, sizeof(buf))) < 0)
+      perror("reading");
+
+  if ((count != sizeof(buf)) || (buf[0] != 'T') || (buf[1] != 'F') ||
+      (buf[2] != 'r') || (buf[3] != 'c')) {
+
+      fprintf(stderr, "Couldn't read Topfield header\n");
+      return;
+  }
+
+  pida = (buf[24] << 8) + buf[25];
+  pidv = ((buf[26] & 0x7f) << 8) + buf[27];
+
+        fprintf(stderr, "apid %d (0x%02x)\n",pida,pida);
+        fprintf(stderr, "vpid %d (0x%02x)\n",pidv,pidv);
+  ts_to_pes(fdin, pida, pidv, 1);
+}
 
 #define INN_SIZE 2*IN_SIZE
 void insert_pat_pmt( int fdin, int fdout)