Package-Name: dvgrab
Gentoo-Package: media-video/dvgrab
Requires: pkgconfig libraw1394 libavc1394 libiec61883
Suggests: libdv
Homepage: http://kino.schirmacher.de/
Source: sourceforge:///kino/dvgrab-(\d+(.\d+)+).tar.gz $1
#Source: http://kino.schirmacher.de/article/static/1/(filemanager\x2Fdownload\x2F\d+\x2Fdvgrab-(\d+(\.\d+)+)\.tar\.gz)/[\0-\377]*(filemanager\x2Fdownload\x2F\d+\x2Fdvgrab-(\d+(.\d+)+).tar.gz) $2 http://kino.schirmacher.de/$1
Zap-Before-Install: 1
Repack:
	tar xzvfp "$(SOURCE)"
Compile:
	cp -pf AUTHORS COPYING Change* NEWS README TODO "$(PREFIX)/"
	$(MAKE) -f ../Makefile configure
	$(MAKE)
	$(MAKE) install
Install:
	$(MAKE) instbin BIN=dvgrab
	$(MAKE) instman SECTION=1 MAN=dvgrab
Patch: <<EOT
######## begin no-more-junk patch
--- ../dvgrab-3.1-orig/avi.cc	2007-07-07 04:00:36 +0900
+++ avi.cc	2007-12-26 05:40:05 +0900
@@ -1062,11 +1062,13 @@
 	odml_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "odml" ), RIFF_LISTSIZE, hdrl_list );
 	dmlh_chunk = AddDirectoryEntry( make_fourcc( "dmlh" ), 0, 0x00f8, odml_list );
 
+#if 0
 	/* align movi list to block */
 	GetDirectoryEntry( hdrl_list, type, name, length, offset, parent );
 	num_blocks = length / PADDING_SIZE + 1;
 	length = num_blocks * PADDING_SIZE - length - 5 * RIFF_HEADERSIZE; // why 5?
 	junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, length, riff_list );
+#endif
 
 	movi_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "movi" ), RIFF_LISTSIZE, riff_list );
 
@@ -1155,6 +1157,7 @@
 			//junk_chunk = AddDirectoryEntry(make_fourcc("JUNK"), 0, PADDING_1GB - length - 5 * RIFF_HEADERSIZE, riff_list);
 			//WriteChunk(junk_chunk, g_zeroes);
 
+#if 0
 			/* padding for alignment */
 			GetDirectoryEntry( riff_list, type, name, length, offset, parent );
 			num_blocks = ( length + 4 * RIFF_HEADERSIZE ) / PADDING_SIZE + 1;
@@ -1164,6 +1167,7 @@
 				junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, length, riff_list );
 				WriteChunk( junk_chunk, g_zeroes );
 			}
+#endif
 
 			riff_list = AddDirectoryEntry( make_fourcc( "RIFF" ), make_fourcc( "AVIX" ), RIFF_LISTSIZE, file_list );
 			movi_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "movi" ), RIFF_LISTSIZE, riff_list );
@@ -1368,7 +1372,9 @@
 	strl_list[ 1 ] = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "strl" ), RIFF_LISTSIZE, hdrl_list );
 	strh_chunk[ 1 ] = AddDirectoryEntry( make_fourcc( "strh" ), 0, sizeof( AVIStreamHeader ), strl_list[ 1 ] );
 	strf_chunk[ 1 ] = AddDirectoryEntry( make_fourcc( "strf" ), 0, sizeof( WAVEFORMATEX ) - 2, strl_list[ 1 ] );
+#if 0
 	junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, 2, strl_list[ 1 ] );
+#endif
 	if ( index_type & AVI_LARGE_INDEX )
 	{
 		indx_chunk[ 1 ] = AddDirectoryEntry( make_fourcc( "indx" ), 0, sizeof( AVISuperIndex ), strl_list[ 1 ] );
@@ -1379,11 +1385,13 @@
 		dmlh_chunk = AddDirectoryEntry( make_fourcc( "dmlh" ), 0, 0x00f8, odml_list );
 	}
 
+#if 0
 	/* align movi list to block */
 	GetDirectoryEntry( hdrl_list, type, name, length, offset, parent );
 	num_blocks = length / PADDING_SIZE + 1;
 	length = num_blocks * PADDING_SIZE - length - 5 * RIFF_HEADERSIZE; // why 5 headers?
 	junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, length, riff_list );
+#endif
 
 	movi_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "movi" ), RIFF_LISTSIZE, riff_list );
 
@@ -1526,6 +1534,7 @@
 
 		if ( index_type & AVI_LARGE_INDEX )
 		{
+#if 0
 			/* padding for alignment */
 			GetDirectoryEntry( riff_list, type, name, length, offset, parent );
 			num_blocks = ( length + 4 * RIFF_HEADERSIZE ) / PADDING_SIZE + 1;
@@ -1535,6 +1544,7 @@
 				junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, length, riff_list );
 				WriteChunk( junk_chunk, g_zeroes );
 			}
+#endif
 
 			riff_list = AddDirectoryEntry( make_fourcc( "RIFF" ), make_fourcc( "AVIX" ), RIFF_LISTSIZE, file_list );
 			movi_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "movi" ), RIFF_LISTSIZE, riff_list );
######## end no-more-junk patch
EOT
NoPatch: <<EOT
######## begin sanity check patch (version 1.x)
--- ieee1394io.cc.old	2003-11-16 17:30:19.000000000 -0500
+++ ieee1394io.cc	2003-12-19 11:02:29.000000000 -0500
@@ -478,6 +478,12 @@
 		int dif_sequence = p[ 1 ] >> 4;           /* dif sequence number is in bits 4 - 7 */
 		int dif_block = p[ 2 ];
 
+		/* sanity check on dif sequence number */
+		if (dif_sequence >= 12) {
+			cerr << "Invalid packet: dif_sequence = " << dif_sequence << endl;
+			return 0;
+		}
+
 		/* if we are at the beginning of a frame, we put the previous
 		   frame in our output_queue.  Then we try to get an unused
 		   frame_buffer from the buffer_queue for the current frame.
@@ -518,18 +524,34 @@
 				break;
 
 			case 1:    /* 2 Subcode blocks */
+				if (dif_block >= 2) {
+					cerr << "Invalid subcode packet: dif_block = " << dif_block << endl;
+					return 0;
+				}
 				memcpy( currentFrame->data + dif_sequence * 150 * 80 + ( 1 + dif_block ) * 80, p, 480 );
 				break;
 
 			case 2:    /* 3 VAUX blocks */
+				if (dif_block >= 3) {
+					cerr << "Invalid VAUX packet: dif_block = " << dif_block << endl;
+					return 0;
+				}
 				memcpy( currentFrame->data + dif_sequence * 150 * 80 + ( 3 + dif_block ) * 80, p, 480 );
 				break;
 
 			case 3:    /* 9 Audio blocks interleaved with video */
+				if (dif_block >= 9) {
+					cerr << "Invalid audio packet: dif_block = " << dif_block << endl;
+					return 0;
+				}
 				memcpy( currentFrame->data + dif_sequence * 150 * 80 + ( 6 + dif_block * 16 ) * 80, p, 480 );
 				break;
 
 			case 4:    /* 135 Video blocks interleaved with audio */
+				if (dif_block >= 135) {
+					cerr << "Invalid video packet: dif_block = " << dif_block << endl;
+					return 0;
+				}
 				memcpy( currentFrame->data + dif_sequence * 150 * 80 + ( 7 + ( dif_block / 15 ) + dif_block ) * 80, p, 480 );
 				break;
 
######## end sanity check patch
EOT

/pkg/dvgrab/
/usr/bin/dvgrab
/usr/man/man1/dvgrab.1.gz
