[NUT-devel] r61 - trunk/libnut

ods15 at mplayerhq.hu ods15 at mplayerhq.hu
Sat Feb 11 18:20:03 CET 2006


Author: ods15
Date: 2006-02-11 18:20:03 +0100 (Sat, 11 Feb 2006)
New Revision: 61

Modified:
   trunk/libnut/demuxer.c
Log:
adding checksum checking in find_syncpoint()


Modified: trunk/libnut/demuxer.c
===================================================================
--- trunk/libnut/demuxer.c	2006-02-11 17:04:36 UTC (rev 60)
+++ trunk/libnut/demuxer.c	2006-02-11 17:20:03 UTC (rev 61)
@@ -575,10 +575,25 @@
 		tmp = (tmp << 8) | *(nut->i->buf_ptr++);
 		if (tmp != SYNCPOINT_STARTCODE) continue;
 		if (res) {
+			int i, scrap;
 			res->pos = bctello(nut->i) - 8;
 			GET_V(nut->i, res->pts);
 			GET_V(nut->i, tmp);
 			res->back_ptr = (tmp * 8 + 7) << 1;
+
+			CHECK(get_bytes(nut->i, 1, &tmp));
+			if (!nut->ft[tmp].stream_plus1) GET_V(nut->i, scrap);
+			if (!nut->ft[tmp].pts_delta) GET_V(nut->i, scrap);
+			if (nut->ft[tmp].flags & MSB_CODED_FLAG) GET_V(nut->i, scrap);
+			if (nut->ft[tmp].flags & STREAM_CODED_FLAG) GET_V(nut->i, scrap);
+			for (i = 0; i < nut->ft[tmp].reserved; i++) GET_V(nut->i, scrap);
+			CHECK(get_bytes(nut->i, 4, &tmp));
+
+			if (tmp != crc32(nut->i->buf_ptr - (bctello(nut->i) - res->pos - 8), bctello(nut->i) - 4 - res->pos - 8)) {
+				tmp = 0;
+				nut->i->buf_ptr -= bctello(nut->i) - res->pos - 8; // rewind to right after the startcode
+				continue;
+			}
 		}
 		if (!backwards) return 0;
 		else ptr = nut->i->buf_ptr;




More information about the NUT-devel mailing list