4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "filelist.inc"
28 #include "loadbalance.h"
32 // Any file which is a list of frames.
33 // FileList handles both frame files and indexes of frame files.
40 class FileList : public FileBase
43 FileList(Asset *asset,
45 const char *list_prefix,
46 const char *file_extension,
51 // basic commands for every file interpreter
52 int open_file(int rd, int wr);
55 char* calculate_path(int number, char *string);
56 char* create_path(int number_override);
57 void add_return_value(int amount);
59 int read_list_header();
60 virtual int read_frame_header(char *path) { return 1; };
61 int read_frame(VFrame *frame);
63 // subclass returns whether the asset format is a list or single file
64 virtual int read_frame(VFrame *frame, VFrame *data) { return 0; };
65 virtual int read_frame(VFrame *frame, char *path) { return 0; };
66 virtual int write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit) { return 0; };
67 // Return 1 if read frame should use the path instead of the compressed data
68 virtual int use_path();
70 int write_list_header();
71 int write_frames(VFrame ***frames, int len);
72 VFrame* read_frame(int use_alpha, int use_float);
73 virtual int64_t get_memory_usage();
74 // Get the total writer units for calculating memory usage
76 // Get a writer unit for retrieving temporary usage.
77 FrameWriterUnit* get_unit(int number);
79 virtual FrameWriterUnit* new_writer_unit(FrameWriter *writer);
81 // Temp storage for compressed data
83 // Storage for single frame
87 int read_raw(VFrame *frame,
88 float in_x1, float in_y1, float in_x2, float in_y2,
89 float out_x1, float out_y1, float out_x2, float out_y2,
90 int alpha, int use_alpha, int use_float, int interpolate);
91 int reset_parameters_derived();
92 ArrayList<char*> path_list; // List of files
93 const char *list_prefix;
94 const char *file_extension;
108 class FrameWriterPackage : public LoadPackage
111 FrameWriterPackage();
112 ~FrameWriterPackage();
123 class FrameWriterUnit : public LoadClient
126 FrameWriterUnit(FrameWriter *server);
127 virtual ~FrameWriterUnit();
129 void process_package(LoadPackage *package);
139 class FrameWriter : public LoadServer
142 FrameWriter(FileList *file, int cpus);
145 void write_frames(VFrame ***frames, int len);
146 void init_packages();
147 LoadClient* new_client();
148 LoadPackage* new_package();