| 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 | |
| 32 | |
| 33 | int main(int argc, const char** argv) |
| 34 | { |
| 35 | unsigned char buf[80]; |
| 36 | int dif_count = -1; |
| 37 | int packet = -1; |
| 38 | int frame = 0; |
| 39 | |
| 40 | while (read(STDIN_FILENO, buf, 80) == 80) { |
| 41 | int i; |
| 42 | dif_count++; |
| 43 | if ((dif_count % 6) == 0) { |
| 44 | if (buf[0] == 0x1f && buf[1] == 0x07 && packet != -1) { |
| 45 | packet = -1; |
| 46 | dif_count = 0; |
| 47 | frame++; |
| 48 | printf("------------------------\n"); |
| 49 | } |
| 50 | packet++; |
| 51 | } |
| 52 | printf("%04d/%03d/%03d :", dif_count, packet, frame); |
| 53 | for (i = 0; i < 40; i++) { |
| 54 | printf("%02x ", buf[i]); |
| 55 | } |
| 56 | printf("| "); |
| 57 | for (i = 40; i < 80; i++) { |
| 58 | printf("%02x ", buf[i]); |
| 59 | } |
| 60 | printf("\n"); |
| 61 | } |
| 62 | |
| 63 | exit(0); |
| 64 | } |