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 can_scale_input() { return 1; }
62 int read_frame(VFrame *frame);
64 // subclass returns whether the asset format is a list or single file
65 virtual int read_frame(VFrame *frame, VFrame *data) { return 0; };
66 virtual int read_frame(VFrame *frame, char *path) { return 0; };
67 virtual int write_frame(VFrame *frame, VFrame *data, FrameWriterUnit *unit) { return 0; };
68 // Return 1 if read frame should use the path instead of the compressed data
69 virtual int use_path();
71 int write_list_header();
72 int write_frames(VFrame ***frames, int len);
73 VFrame* read_frame(int use_alpha, int use_float);
74 virtual int64_t get_memory_usage();
75 // Get the total writer units for calculating memory usage
77 // Get a writer unit for retrieving temporary usage.
78 FrameWriterUnit* get_unit(int number);
80 virtual FrameWriterUnit* new_writer_unit(FrameWriter *writer);
82 // Temp storage for compressed data
84 // Storage for single frame
88 int read_raw(VFrame *frame,
89 float in_x1, float in_y1, float in_x2, float in_y2,
90 float out_x1, float out_y1, float out_x2, float out_y2,
91 int alpha, int use_alpha, int use_float, int interpolate);
92 int reset_parameters_derived();
93 ArrayList<char*> path_list; // List of files
94 const char *list_prefix;
95 const char *file_extension;
109 class FrameWriterPackage : public LoadPackage
112 FrameWriterPackage();
113 ~FrameWriterPackage();
124 class FrameWriterUnit : public LoadClient
127 FrameWriterUnit(FrameWriter *server);
128 virtual ~FrameWriterUnit();
130 void process_package(LoadPackage *package);
140 class FrameWriter : public LoadServer
143 FrameWriter(FileList *file, int cpus);
146 void write_frames(VFrame ***frames, int len);
147 void init_packages();
148 LoadClient* new_client();
149 LoadPackage* new_package();