mask mousewheel segv bug, mask opengl sw fallback read to ram, fix tiff config withou...
[goodguy/cinelerra.git] / cinelerra-5.1 / libzmpeg3 / mpeg3ifochk.C
1
2 #include <stdio.h>
3 #include "libzmpeg3.h"
4
5 /* reads a ifo file which must be a dvd, and vaidates the title data */
6 /*   reports title/program sets which appear to be usable */
7
8 int usage(const char *nm)
9 {
10   printf("usage: %s <path>\n"
11     "  <path> = path to dvd mount point\n", nm);
12   return 0;
13 }
14
15 int main(int argc, char **argv)
16 {
17   if( argc < 2 ) 
18     return usage(argv[0]);
19
20   int verbose = 0;
21   int program = -1;
22   int limit = 3;
23   const char *path = 0;
24
25   int i;
26   for( i=1; i<argc; ++i ) {
27     if( !strcmp(argv[i], "-v") ) {
28       verbose = 1;
29     }
30     else if( !strcmp(argv[i], "-p") ) {
31       if( ++i < argc ) program = atoi(argv[i]);
32     }
33     else if( !strcmp(argv[i], "-l") ) {
34       if( ++i < argc ) limit = atoi(argv[i]);
35     }
36     else if(argv[i][0] == '-') {
37       fprintf(stderr, "Unrecognized command %s\n", argv[i]);
38       exit(1);
39     }
40     else if(!path) {
41       path = argv[i];
42     }
43     else {
44       fprintf(stderr, "Unknown argument \"%s\"\n", argv[i]);
45       exit(1);
46     }
47   }
48
49   for( i=1; i<100; ++i ) {
50     char ifo_path[PATH_MAX];
51     strncpy(&ifo_path[0], path, sizeof(ifo_path));
52     int l = strnlen(&ifo_path[0],sizeof(ifo_path));
53     snprintf(&ifo_path[l],sizeof(ifo_path)-l,"/VIDEO_TS/VTS_%02d_0.IFO",i);
54     if( access(&ifo_path[0],R_OK) ) break;
55
56     zmpeg3_t *src = new zmpeg3_t(&ifo_path[0]);
57     if( !src ) break;
58     uint32_t bits = src->fs->read_uint32();
59     if( bits == zmpeg3_t::IFO_PREFIX ) {
60       int fd = src->fs->get_fd();
61       zifo_t *ifo = src->ifo_open(fd, 0);
62       if( !ifo ) {
63         fprintf(stderr,"Error opening ifo in %s\n", &ifo_path[0]);
64         continue;
65       }
66
67       zicell_table_t icell_addrs;
68       ifo->icell_addresses(&icell_addrs);
69       int programs = ifo->max_inlv+1;
70       int angles = -1;
71       if( verbose )
72         printf("processing: %s, %d programs\n",&ifo_path[0], programs);
73
74       for( int title=0; title<100; ++title ) {
75         int listed = 0;
76         for( int pgm=0; pgm<programs; ++pgm ) {
77           int sectors = 0, pcells = 0;
78           int ret = ifo->chk(title, 0, pgm, 0, &icell_addrs, sectors, pcells, angles);
79           if( ret < 0 ) break;
80           if( !ret ) continue;
81           if( pcells < limit ) continue;
82           if( program >= 0 && pgm != program ) continue;
83           if( !listed ) {
84             listed = 1;
85             printf("%s, Title = %d, pcells=%d, sectors = %d, angles %d, program ids=%d",
86               &ifo_path[0], title+1, pcells, sectors, angles+1, title*100+pgm);
87           }
88           else
89             printf(", %d",title*100+pgm);
90         }
91         if( listed ) printf("\n");
92       }
93       ifo->ifo_close();
94     }
95
96     delete src;
97   }
98
99   if( i == 1 ) {
100     printf("cant open %s/VIDEO_TS/VTS_01_0.IFO\n",path);
101     exit(1);
102   }
103
104   return 0;
105 }
106