Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed

/*
 * Copyright (c) 1994 by Gregory P. Ward.
 * All rights reserved.
 *
 * This file is part of the MNI front end of the Berkeley MPEG decoder.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice and the following
 * two paragraphs appear in all copies of this software.
 *
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE
 * UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER
 * IS ON AN "AS IS" BASIS, AND THE AUTHOR HAS NO OBLIGATION TO PROVIDE
 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.  
 */


/*
 * Portions of this software Copyright (c) 1995 Brown University.
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement
 * is hereby granted, provided that the above copyright notice and the
 * following two paragraphs appear in all copies of this software.
 *
 * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR DIRECT,
 * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN
 * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
 * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
 * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 */


/*
 * This is the abstract base class on which to easily build animation objects
 * for animation objects (MPEG, Quicktime, etc.)
 *
 * Original C version of the MPEG wrapper by Greg Ward <greg@pet.mni.mcgill.ca>,
 * reentrant C++ version by Loring Holden <lsh@cs.brown.edu>
 *
 */


#ifndef CPLUSPLUS_ANIM_WRAPPER
#include <stdio.h>
#include <errno.h>
#include <string.h>
//Originally from the MPEG Wrapper by Greg Ward
#ifndef BOOLEAN_TYPE_EXISTS
typedef char Boolean;
#define BOOLEAN_TYPE_EXISTS
#endif

#if (!defined(TRUE) || !defined(FALSE))
# define TRUE (char) 1
# define FALSE (char) 0
#endif

#ifndef NOTHREADS
#include "thread_mp.H"
#endif
#include "buffer.H"

class ANIMbase {
  public:
     ANIMbase();
     ANIMbase(const ANIMbase& rhs);    //Copy constructor (same
                                               //animation, but at start)
     virtual void newMovie(const char * const infile) = 0;
     const char * const getName() const {return fileName;};
     virtual Boolean open() = 0;
     virtual void rewind() = 0;
     virtual Boolean GetFrame(char **Frame, Boolean *newFrame) = 0;
     virtual Boolean OkFile() {return filePtr!=NULL;};
     virtual void InitDither(unsigned long /*red_mask*/,
                unsigned long /*green_mask*/,
                unsigned long /*blue_mask*/) {};
#ifndef NOTHREADS
     virtual void MultiThread(Boolean mt);
#endif
     virtual void Buffer(Boolean buff, Boolean compress=TRUE);
     virtual ~ANIMbase();

     int  Height;               // in pixels
     int  Width;
     int  Size;                 // bytes for whole image
     int  frames;               // Frames so far

     Boolean moreFrames;        // Are there more frames in the movie?

   protected:
     int threadNumber;          // the number of the thread we're using
     char *fileName;            // Name of the animation file

     FILE *filePtr;
     Boolean buffering,         // Are we buffering frames?
             allBuffered;       // We can stop if we have buffered all frames
     BUFFER *frameBuffer;       // Buffer object to hold frames
#ifndef NOTHREADS
     Boolean MultiThreaded;
     static THREADmp_manager *mp_man;
#endif
     void *(*thread_routine)(void *,void *);//Routine to run when multi-threaded
   private:
     ANIMbase& operator=(const ANIMbase& rhs);
};

#define CPLUSPLUS_ANIM_WRAPPER
#endif