Subversion Repositories shark

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Copyright 1995, Brown University, Providence, RI
3
 *
4
 * Permission to use and modify this software and its documentation for
5
 * any purpose other than its incorporation into a commercial product is
6
 * hereby granted without fee.  Permission to copy and distribute this
7
 * software and its documentation only for non-commercial use is also
8
 * granted without fee, provided, however, that the above copyright notice
9
 * appear in all copies, that both that copyright notice and this permission
10
 * notice appear in supporting documentation, that the name of Brown
11
 * University not be used in advertising or publicity pertaining to
12
 * distribution of the software without specific, written prior permission,
13
 * and that the person doing the distribution notify Brown University of
14
 * such distributions outside of his or her organization. Brown University
15
 * makes no representations about the suitability of this software for
16
 * any purpose.  It is provided "as is" without express or implied warranty.
17
 * Brown University requests notification of any modifications to this
18
 * software or its documentation.
19
 *
20
 * Send the following redistribution information:
21
 *
22
 *      Name:
23
 *      Organization:
24
 *      Address (postal and/or electronic):
25
 *
26
 * To:
27
 *      Software Librarian
28
 *      Computer Science Department, Box 1910
29
 *      Brown University
30
 *      Providence, RI 02912
31
 *
32
 *              or
33
 *
34
 *      brusd@cs.brown.edu
35
 *
36
 * We will acknowledge all electronic notifications.
37
 */
38
#include <stdio.h>
39
#include <iostream.h>
40
#include "ANIMdisplay.H"
41
#include "ANIMmpeg.H"
42
#ifndef NONV
43
#include "ANIMnv.H"
44
#endif
45
 
46
extern unsigned long wpixel[256];
47
extern int quietFlag;
48
 
49
const int NUMMOVIES=20;
50
int numInput=0;
51
 
52
/* Global file pointer to incoming data. */
53
char *inputName[NUMMOVIES];
54
 
55
int buffer=TRUE;
56
int compress=TRUE, cycle=FALSE;
57
#ifndef NOTHREADS
58
int mthread=TRUE;
59
#endif
60
 
61
void
62
displayMovies(ANIMdisplay **theWindows, ANIMbase **theMovies)
63
{
64
   /* Start multithreading after all the images have been init-ed */
65
   int moviesToDisplay=cycle ? 1 : numInput;
66
 
67
   for (int i=0;i<moviesToDisplay;i++) {
68
      theMovies[i]->Buffer(buffer, compress);
69
#ifndef NOTHREADS
70
      theMovies[i]->MultiThread(mthread);
71
#endif
72
   }
73
 
74
   quietFlag=0;
75
   Boolean workToDo=TRUE;
76
 
77
   if (cycle) {
78
      int currentMovie=0, frames=0;
79
      while(1) {
80
        theWindows[0]->display();
81
        frames++;
82
        if (cycle && theWindows[0]->movieDone()) {
83
            ANIMbase *movie= theWindows[0]->_movie;
84
 
85
                printf("%d %dx%d frames, %s\n",
86
                   frames, movie->Width, movie->Height, movie->getName());
87
                fflush(stdout);
88
                frames=0;
89
                currentMovie=++currentMovie % numInput;
90
                theWindows[0]->newMovie(inputName[currentMovie]);
91
        }
92
      }
93
   } else {
94
      while (workToDo) {
95
         for (int whichMovie=0;whichMovie<numInput;whichMovie++) {
96
            theWindows[whichMovie]->display();
97
         }
98
      }
99
   }
100
}
101
 
102
#ifndef __STDC__
103
void
104
#else
105
int
106
#endif
107
main(int argc, char **argv)
108
{
109
    char *filename="/home/lsh/tii/mpeg/eggclock.mpg";
110
    int mark=1;
111
    ANIMbase *theMovie[NUMMOVIES];
112
    ANIMdisplay *theWindow[NUMMOVIES];
113
    char *displayName="";
114
 
115
    /* Initiialize arrays */
116
    for (int i=0;i<NUMMOVIES; i++) {
117
         inputName[i] = filename;
118
         theWindow[i]=NULL;
119
         theMovie[i]=NULL;
120
    }
121
 
122
    //
123
    // Get command line arguments 
124
    //
125
    argc--;
126
 
127
    while (argc) {
128
      if (strcmp(argv[mark], "-display") == 0) {
129
        displayName= argv[++mark];
130
        argc -= 2; mark++;
131
      } else if (strcmp(argv[mark], "-no_buffer") == 0) {
132
         buffer=FALSE;
133
         argc--; mark++;
134
      } else if (strcmp(argv[mark], "-no_compress") == 0) {
135
         compress=FALSE;
136
         argc--; mark++;
137
      } else if (strcmp(argv[mark], "-cycle") == 0) {
138
         cycle=TRUE;
139
         buffer=FALSE; //for now, or we don't know to cycle
140
         argc--; mark++;
141
#ifndef NOTHREADS
142
      } else if (strcmp(argv[mark], "-no_mthread") == 0) {
143
         mthread=FALSE;
144
         argc--; mark++;
145
#endif
146
      } else {
147
        fflush(stdout);
148
        if (numInput<NUMMOVIES) {
149
            inputName[numInput] = argv[mark];
150
            if ((numInput==0) || !cycle) {
151
#ifndef NONV
152
              if (strstr(inputName[numInput],"mbone:")!=NULL) {
153
                 theMovie[numInput]=
154
                       (ANIMbase *) new ANIMnv(inputName[numInput]);
155
              } else
156
#endif
157
                  theMovie[numInput]=
158
                       (ANIMbase *) new ANIMmpeg(inputName[numInput]);
159
              if (!theMovie[numInput]->OkFile()) {
160
                 fprintf(stderr, "%s: %s not found\n", argv[0],argv[mark]);
161
                 /* shouldn't have to delete it each time - reuse!*/
162
                 delete theMovie[numInput];
163
              } else {
164
               if (theMovie[numInput]->open()) {
165
                 if (numInput==0) {
166
                    theWindow[0]=new ANIMdisplay((ANIMbase *) theMovie[0],
167
                                        displayName,!cycle);
168
                 } else {
169
                     theWindow[numInput]=new ANIMdisplay(
170
                                     (ANIMbase *) theMovie[numInput],
171
                                                   theWindow[numInput-1],
172
                                                   !cycle);
173
                 }
174
                 numInput++;
175
               } else {
176
                    fprintf(stderr,"%s: %s not an MPEG file\n",
177
                     argv[0],argv[mark]);
178
                    delete theMovie[numInput];
179
                 }
180
              }
181
            } else if (cycle) {
182
                numInput++;
183
            }
184
        } else {
185
               fprintf(stderr, "Can't load file %s - too many\n", argv[mark]);
186
        }
187
        argc--; mark++;
188
      }
189
    }
190
 
191
    if (numInput) displayMovies(theWindow, (ANIMbase **) theMovie);
192
    else {
193
#ifndef NOTHREADS      
194
       char *threadStr="-no_mthread";
195
#else
196
       char *threadStr="";
197
#endif
198
       fprintf(stderr,"%s: no files entered\n",argv[0]);
199
       fprintf(stderr,
200
         "usage: %s [-display display -no_buffer %s -cycle -no_compress] movie ... \n",
201
                      argv[0],threadStr);
202
       exit(1);
203
    }
204
}