Debian Codegraph @

encodedv/steal_header.c

raw symbols SCIP
1 /*
2 * scan_packet_headers.c
3 *
4 * Copyright (C) Peter Schlaile - January 2001
5 *
6 * This file is part of libdv, a free DV (IEC 61834/SMPTE 314M)
7 * codec.
8 *
9 * libdv is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser Public License as published by
11 * the Free Software Foundation; either version 2.1, or (at your
12 * option) any later version.
13 *
14 * libdv is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser Public License
20 * along with libdv; see the file COPYING. If not, write to
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * The libdv homepage is http://libdv.sourceforge.net/.
24 */
25
26 #include "libdv/dv_types.h"
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <assert.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <fcntl.h>
35
36 int main(int argc, const char** argv)
37 {
38 int in_ren;
39 int in_cap;
40 unsigned char buf_ren[80];
41 unsigned char buf_cap[80];
42 int dif_block_count = 0;
43 int vid_count = 0;
44
45 if (argc != 3) {
46 fprintf(stderr, "Usage: steal_header in_rendered in_captured "
47 "> out.dv\n");
48 return -1;
49 }
50
51 in_ren = open(argv[1], O_RDONLY);
52 in_cap = open(argv[2], O_RDONLY);
53
54 assert(in_ren != -1 && in_cap != -1);
55
56 while (read(in_ren, buf_ren, 80) == 80 &&
57 read(in_cap, buf_cap, 80) == 80) {
58 if (dif_block_count < 6) {
59 write(STDOUT_FILENO, buf_cap, 80);
60 } else {
61 if (!vid_count) {
62 write(STDOUT_FILENO, buf_ren, 80);
63 } else {
64 buf_ren[0] = buf_cap[0];
65 buf_ren[1] = buf_cap[1];
66 buf_ren[2] = buf_cap[2];
67 write(STDOUT_FILENO, buf_ren, 80);
68 }
69 vid_count++;
70 vid_count %= 16;
71 }
72
73 dif_block_count++;
74 dif_block_count %= 150;
75 }
76 return 0;
77 }