Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: Bug in software demux still in 2.6.10



HI

Here's only the pusi_seen01.diff patch, 
tabs and comments are still in old style
to be fixed later

Emard
diff -pur dvb-kernel.orig/linux/drivers/media/dvb/dvb-core/dvb_demux.c dvb-kernel/linux/drivers/media/dvb/dvb-core/dvb_demux.c
--- dvb-kernel.orig/linux/drivers/media/dvb/dvb-core/dvb_demux.c	2005-01-05 01:21:33.000000000 +0100
+++ dvb-kernel/linux/drivers/media/dvb/dvb-core/dvb_demux.c	2005-01-05 01:21:55.000000000 +0100
@@ -249,7 +249,22 @@ static void dvb_dmx_swfilter_section_new
 }
 
 /* 
-** Losless Section Demux 1.4 by Emard
+** Losless Section Demux 1.4.1 by Emard
+** Valsecchi Patrick:
+**  - middle of section A  (no PUSI)
+**  - end of section A and start of section B 
+**    (with PUSI pointing to the start of the second section)
+**  
+**  In this case, without feed->pusi_seen you'll receive a garbage section
+**  consisting of the end of section A. Basically because tsfeedp
+**  is incemented and the use=0 condition is not raised
+**  when the second packet arrives.
+**
+** Fix:
+** when demux is started, let feed->pusi_seen = 0 to
+** prevent initial feeding of garbage from the end of
+** previous section. When you for the first time see PUSI=1
+** then set feed->pusi_seen = 1
 */
 static int dvb_dmx_swfilter_section_copy_dump(struct dvb_demux_feed *feed, const u8 *buf, u8 len)
 {
@@ -295,7 +310,12 @@ static int dvb_dmx_swfilter_section_copy
 		sec->seclen = seclen;
 		sec->crc_val = ~0;
 		/* dump [secbuf .. secbuf+seclen) */
-		dvb_dmx_swfilter_section_feed(feed);
+		if(feed->pusi_seen)
+			dvb_dmx_swfilter_section_feed(feed);
+#ifdef DVB_DEMUX_SECTION_LOSS_LOG
+		else
+			printk("dvb_demux.c pusi not seen, discarding section data\n");
+#endif
 		sec->secbufp += seclen; /* secbufp and secbuf moving together is */
 		sec->secbuf += seclen; /* redundand but saves pointer arithmetic */
 	}
@@ -328,6 +348,10 @@ static int dvb_dmx_swfilter_section_pack
 		** in the following dvb_dmx_swfilter_section_new
 		*/
 #endif
+		/* Discontinuity detected. Reset pusi_seen = 0 to
+		** stop feeding of suspicious data until next PUSI=1 arrives
+		*/
+		feed->pusi_seen = 0;
 		dvb_dmx_swfilter_section_new(feed);
 		return 0;
 	}
@@ -343,6 +367,8 @@ static int dvb_dmx_swfilter_section_pack
 			u8 after_len = count-1-before_len;
 
 			dvb_dmx_swfilter_section_copy_dump(feed, before, before_len);
+			/* before start of new section, set pusi_seen = 1 */
+			feed->pusi_seen = 1;
 			dvb_dmx_swfilter_section_new(feed);
 			dvb_dmx_swfilter_section_copy_dump(feed, after, after_len);
 		}
diff -pur dvb-kernel.orig/linux/drivers/media/dvb/dvb-core/dvb_demux.h dvb-kernel/linux/drivers/media/dvb/dvb-core/dvb_demux.h
--- dvb-kernel.orig/linux/drivers/media/dvb/dvb-core/dvb_demux.h	2005-01-05 01:21:33.000000000 +0100
+++ dvb-kernel/linux/drivers/media/dvb/dvb-core/dvb_demux.h	2005-01-05 01:21:55.000000000 +0100
@@ -93,7 +93,8 @@ struct dvb_demux_feed {
         enum dmx_ts_pes pes_type;
 
         int cc;
-
+        int pusi_seen; /* prevents feeding of garbage from previous section */
+        
         u16 peslen;
 
 	struct list_head list_head;
diff -pur dvb-kernel.orig/linux/drivers/media/dvb/ttpci/av7110.c dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.c
--- dvb-kernel.orig/linux/drivers/media/dvb/ttpci/av7110.c	2005-01-05 01:21:33.000000000 +0100
+++ dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.c	2005-01-05 01:21:55.000000000 +0100
@@ -1198,6 +1198,7 @@ static int budget_start_feed(struct dvb_
 		return -EINVAL;
 #endif
 	spin_lock(&budget->feedlock1);
+	feed->pusi_seen = 0; /* have a clean section start */
 	status = start_ts_capture(budget);
 	spin_unlock(&budget->feedlock1);
 	return status;
diff -pur dvb-kernel.orig/linux/drivers/media/dvb/ttpci/budget-core.c dvb-kernel/linux/drivers/media/dvb/ttpci/budget-core.c
--- dvb-kernel.orig/linux/drivers/media/dvb/ttpci/budget-core.c	2005-01-05 01:21:33.000000000 +0100
+++ dvb-kernel/linux/drivers/media/dvb/ttpci/budget-core.c	2005-01-05 01:21:55.000000000 +0100
@@ -246,6 +246,7 @@ static int budget_start_feed(struct dvb_
 		return -EINVAL;
 
 	spin_lock(&budget->feedlock);
+	feed->pusi_seen = 0; /* have a clean section start */
 	status = start_ts_capture(budget);
 	spin_unlock(&budget->feedlock);
 	return status;
Only in dvb-kernel/linux/drivers/media/dvb/ttpci: budget-core.c.orig

Home | Main Index | Thread Index