1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 #ifndef __roq_h__
29 #define __roq_h__
30 
31 //#define JPEG_INTERNALS
32 #include <jpeglib.h>
33 
34 #include "tools/compilers/roqvq/gdefs.h"
35 #include "tools/compilers/roqvq/roqParam.h"
36 #include "tools/compilers/roqvq/quaddefs.h"
37 
38 class codec;
39 class roqParam;
40 
41 class NSBitmapImageRep {
42 public:
43 
44 						NSBitmapImageRep( void );
45 						NSBitmapImageRep( const char *filename );
46 						NSBitmapImageRep( int wide, int high );
47 						~NSBitmapImageRep();
48 
49 	NSBitmapImageRep &	operator=( const NSBitmapImageRep &a );
50 
51 	int					samplesPerPixel( void );
52 	int					pixelsWide( void );
53 	int					pixelsHigh( void );
54 	byte *				bitmapData( void );
55 	bool				hasAlpha( void );
56 	bool				isPlanar( void );
57 
58 private:
59 
60 	byte *				bmap;
61 	int					width;
62 	int					height;
63 	ID_TIME_T				timestamp;
64 
65 };
66 
67 class roq {
68 public:
69 						roq();
70 						~roq();
71 
72 	//void				WriteLossless( void );
73 	void				LoadAndDisplayImage( const char *filename );
74 	void				CloseRoQFile( bool which );
75 	void				InitRoQFile( const char *roqFilename );
76 	void				InitRoQPatterns( void );
77 	void				EncodeStream( const char *paramInputFile );
78 	void				EncodeQuietly( bool which );
79 	bool				IsQuiet( void );
80 	bool				IsLastFrame( void );
81 	NSBitmapImageRep *	CurrentImage( void );
82 	void				MarkQuadx( int xat, int yat, int size, float cerror, int choice );
83 	void				WritePuzzleFrame( quadcel *pquad );
84 	void				WriteFrame( quadcel *pquad );
85 	void				WriteCodeBook( byte *codebook );
86 	void				WwriteCodeBookToStream( byte *codes, int csize, word cflags );
87 	int					PreviousFrameSize( void );
88 	bool				MakingVideo( void );
89 	bool				ParamNoAlpha( void );
90 	bool				SearchType( void );
91 	bool				HasSound( void );
92 	const char *		CurrentFilename( void );
93 	int					NormalFrameSize( void );
94 	int					FirstFrameSize( void );
95 	bool				Scaleable( void );
96 	void				WriteHangFrame( void );
97 	int					NumberOfFrames( void );
98 private:
99 	void				Write16Word( word *aWord, idFile *stream );
100 	void				Write32Word( unsigned int *aWord, idFile *stream );
101 	int					SizeFile( idFile *ftosize );
102 	void				CloseRoQFile( void );
103 	void				WriteCodeBookToStream( byte *codebook, int csize, word cflags );
104 
105 #if 0
106 	static	void		JPEGInitDestination( j_compress_ptr cinfo );
107 	static	boolean		JPEGEmptyOutputBuffer( j_compress_ptr cinfo );
108 	static	void		JPEGTermDestination( j_compress_ptr cinfo );
109 
110 	void				JPEGStartCompress( j_compress_ptr cinfo, bool write_all_tables );
111 	JDIMENSION			JPEGWriteScanlines( j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines );
112 	void				JPEGDest( j_compress_ptr cinfo, byte* outfile, int size );
113 	void				JPEGSave( char * filename, int quality, int image_width, int image_height, unsigned char *image_buffer );
114 #endif
115 
116 	codec *				encoder;
117 	roqParam *			paramFile;
118 
119 	idFile *			RoQFile;
120 	NSBitmapImageRep *	image;
121 	int					numQuadCels;
122 	bool				quietMode;
123 	bool				lastFrame;
124 	idStr				roqOutfile;
125 	idStr				currentFile;
126 	int					numberOfFrames;
127 	int					previousSize;
128 	byte				codes[4096];
129 	bool				dataStuff;
130 
131 };
132 
133 extern roq *theRoQ;				// current roq
134 
135 #endif /* !__roq_h__ */
136