13 #include "filesndfile.h"
15 #include "filethread.h"
17 #include "filevorbis.h"
18 #include "formatwindow.h"
19 #include "pluginserver.h"
21 #include "stringfile.h"
26 #define _(String) gettext(String)
27 #define gettext_noop(String) String
28 #define N_(String) gettext_noop (String)
30 FrameCache::FrameCache(int cache_size)
33 this->cache_size = cache_size;
37 FrameCache::~FrameCache()
42 void FrameCache::reset()
45 FrameCacheTree::iterator iterator = cache_tree.begin();
46 while (iterator != cache_tree.end()) {
47 delete iterator->second;
51 cache_tree_bytime.clear();
55 void FrameCache::enable_cache()
61 void FrameCache::disable_cache()
66 void FrameCache::unlock_cache()
71 void FrameCache::lock_cache()
76 inline int FrameCache::compare_with_frame(FrameCacheElement *element,
81 int frame_color_model)
83 if ( element->frame_number == frame_number &&
84 element->frame_layer == frame_layer &&
85 element->frame->get_w() == frame_width &&
86 element->frame->get_h() == frame_height &&
87 element->frame->get_color_model() == frame_color_model)
93 FrameCacheTree::iterator FrameCache::find_element_byframe(long frame_number, int frame_layer, int frame_width, int frame_height, int frame_color_model)
95 FrameCacheTree::iterator iterator = cache_tree.find(frame_number);
96 if(iterator != cache_tree.end()) {
98 if (compare_with_frame(iterator->second,
109 } while (iterator->first == frame_number);
111 return cache_tree.end();
114 FrameCacheTree_ByTime::iterator FrameCache::find_element_bytime(long long frame_time_diff, long frame_number, int frame_layer, int frame_width, int frame_height, int frame_color_model)
116 FrameCacheTree_ByTime::iterator iterator = cache_tree_bytime.find(frame_time_diff);
117 if(iterator != cache_tree_bytime.end()) {
119 if (compare_with_frame(iterator->second,
130 } while (iterator->first == frame_time_diff);
132 return cache_tree_bytime.end();
136 // implicitly locks the class, needs to be unlocked after the call
137 // this is the best behaviour, everything else just complicates things and
138 // causes races (because you don't know the state of cache_enabled during the call).
139 VFrame *FrameCache::get_frame(long frame_number, int frame_layer, int frame_width, int frame_height, int frame_color_model)
143 if (!cache_enabled) return 0;
144 // printf("Looking for - frame: %li, layer: %i, w: %i, h:%i, cm: %i\n", frame_number, frame_layer, frame_width, frame_height, frame_color_model);
145 FrameCacheTree::iterator iterator= find_element_byframe(frame_number,
150 // update timestamp in other tree
151 if (iterator != cache_tree.end())
153 FrameCacheElement *cache_element = iterator->second;
154 FrameCacheTree_ByTime::iterator iterator_bytime;
155 // this tree node always exists
156 iterator_bytime = find_element_bytime(cache_element->time_diff,
162 if (cache_element != iterator_bytime->second)
164 printf("FrameCache: Something severely wrong in the cache engine!! this: %p\n", this);
168 // printf("Cache hit - frame: %li, layer: %i, w: %i, h:%i, cm: %i\n", frame_number, frame_layer, frame_width, frame_height, frame_color_model);
169 // delete & replace with new key
170 cache_tree_bytime.erase(iterator_bytime);
171 cache_element->time_diff = timer.get_difference();
172 cache_tree_bytime.insert(std::pair<long long, FrameCacheElement *> (cache_element->time_diff, cache_element));
173 return (cache_element->frame);
178 void FrameCache::add_frame(long frame_number, int frame_layer, VFrame *frame, int do_not_copy_frame)
181 if (!cache_enabled) return;
184 // printf("%p, adding frame: %li, layer: %i, w: %i, h:%i cm:%i\n",this, frame_number, frame_layer, frame->get_w(),frame->get_h(), frame->get_color_model());
186 FrameCacheElement *cache_element;
188 // currently cache size can only grow, not shrink
189 if (cache_tree.size() >= cache_size)
191 // delete the oldest element
192 FrameCacheTree_ByTime::iterator iterator_bytime = cache_tree_bytime.begin();
193 cache_element = iterator_bytime->second;
194 FrameCacheTree::iterator iterator = find_element_byframe(cache_element->frame_number,
195 cache_element->frame_layer,
196 cache_element->frame->get_w(),
197 cache_element->frame->get_h(),
198 cache_element->frame->get_color_model());
199 // printf("Deleting oldest frame: - frame: %li, layer: %i, w: %i, h:%i, cm: %i\n", cache_element->frame_number, cache_element->frame_layer, cache_element->frame->get_w(), cache_element->frame->get_h(), cache_element->frame->get_color_model());
200 delete cache_element->frame;
201 cache_tree.erase(iterator);
202 cache_tree_bytime.erase(iterator_bytime);
205 cache_element = new FrameCacheElement;
208 if (do_not_copy_frame)
210 cache_element->frame = frame;
213 cache_element->frame = new VFrame(0,
216 frame->get_color_model());
217 cache_element->frame->copy_from(frame);
219 cache_element->frame_layer = frame_layer;
220 cache_element->frame_number = frame_number;
221 cache_element->time_diff = timer.get_difference();
223 // insert the same data into both trees under different keys
225 cache_tree.insert(std::pair<long, FrameCacheElement *> (cache_element->frame_number, cache_element));
226 cache_tree_bytime.insert(std::pair<long long, FrameCacheElement *> (cache_element->time_diff, cache_element));
227 change_lock.unlock();
230 void FrameCache::dump()
232 printf("Dump of frames' cache %p, cache_tree:\n", this);
234 FrameCacheTree::iterator iterator = cache_tree.begin();
235 while (iterator != cache_tree.end()) {
236 FrameCacheElement *cache_element = iterator->second;
237 printf("%p, frame: %li, layer: %i, w: %i, h:%i, cm: %i, time_diff: %i\n", cache_element, cache_element->frame_number, cache_element->frame_layer, cache_element->frame->get_w(), cache_element->frame->get_h(), cache_element->frame->get_color_model(), cache_element->time_diff);
241 printf("cache_tree_bytime:\n", this);
243 FrameCacheTree_ByTime::iterator iterator = cache_tree_bytime.begin();
244 while (iterator != cache_tree_bytime.end()) {
245 FrameCacheElement *cache_element = iterator->second;
246 printf("%p, frame: %li, layer: %i, w: %i, h:%i, cm: %i, time_diff: %li\n", cache_element, cache_element->frame_number, cache_element->frame_layer, cache_element->frame->get_w(), cache_element->frame->get_h(), cache_element->frame->get_color_model(), cache_element->time_diff);
257 frames_cache = new FrameCache();
265 if(format_window) format_window->set_done(0);
266 format_completion.lock();
267 format_completion.unlock();
286 void File::reset_parameters()
300 normalized_sample = 0;
301 normalized_sample_rate = 0;
303 frames_cache->reset();
307 int File::raise_window()
311 format_window->raise_window();
312 format_window->flush();
317 int File::get_options(BC_WindowBase *parent_window,
318 ArrayList<PluginServer*> *plugindb,
325 format_completion.lock();
326 switch(asset->format)
333 FileSndFile::get_parameters(parent_window,
340 FileMOV::get_parameters(parent_window,
349 FileMPEG::get_parameters(parent_window,
356 FileMOV::get_parameters(parent_window,
363 case FILE_AVI_LAVTOOLS:
366 case FILE_AVI_AVIFILE:
367 FileAVI::get_parameters(parent_window,
376 FileJPEG::get_parameters(parent_window,
384 FilePNG::get_parameters(parent_window,
392 FileTGA::get_parameters(parent_window,
400 FileTIFF::get_parameters(parent_window,
407 FileVorbis::get_parameters(parent_window,
419 ErrorBox *errorbox = new ErrorBox(PROGRAM_NAME ": Error",
420 parent_window->get_abs_cursor_x(),
421 parent_window->get_abs_cursor_y());
422 format_window = errorbox;
425 errorbox->create_objects(_("This format doesn't support audio."));
428 errorbox->create_objects(_("This format doesn't support video."));
429 errorbox->run_window();
434 format_completion.unlock();
438 void File::set_asset(Asset *asset)
440 *this->asset = *asset;
443 int File::set_processors(int cpus) // Set the number of cpus for certain codecs
445 //printf("File::set_processors 1 %d\n", cpus);
450 int File::set_preload(int64_t size)
452 this->playback_preload = size;
456 int File::open_file(ArrayList<PluginServer*> *plugindb,
460 int64_t base_samplerate,
461 float base_framerate)
463 *this->asset = *asset;
467 //printf("File::open_file 1 %s %d\n", asset->path, asset->format);
468 switch(this->asset->format)
470 // get the format now
471 // If you add another format to case 0, you also need to add another case for the
472 // file format #define.
475 if(!(stream = fopen(this->asset->path, "rb")))
482 fread(test, 16, 1, stream);
484 // if(FileAVI::check_sig(this->asset))
487 // file = new FileAVI(this->asset, this);
490 if(FileSndFile::check_sig(this->asset))
494 file = new FileSndFile(this->asset, this);
497 if(FilePNG::check_sig(this->asset))
501 file = new FilePNG(this->asset, this);
504 if(FileJPEG::check_sig(this->asset))
508 file = new FileJPEG(this->asset, this);
511 if(FileTGA::check_sig(this->asset))
515 file = new FileTGA(this->asset, this);
518 if(FileTIFF::check_sig(this->asset))
522 file = new FileTIFF(this->asset, this);
525 if(FileVorbis::check_sig(this->asset))
529 file = new FileVorbis(this->asset, this);
532 if(FileMPEG::check_sig(this->asset))
536 file = new FileMPEG(this->asset, this);
539 if(test[0] == '<' && test[1] == 'E' && test[2] == 'D' && test[3] == 'L' && test[4] == '>' ||
540 test[0] == '<' && test[1] == 'H' && test[2] == 'T' && test[3] == 'A' && test[4] == 'L' && test[5] == '>' ||
541 test[0] == '<' && test[1] == '?' && test[2] == 'x' && test[3] == 'm' && test[4] == 'l')
546 } // can't load project file
548 if(FileMOV::check_sig(this->asset))
551 // should be last because quicktime lacks a magic number
553 file = new FileMOV(this->asset, this);
559 return FILE_UNRECOGNIZED_CODEC;
563 // format already determined
569 //printf("File::open_file 1\n");
570 file = new FileSndFile(this->asset, this);
575 file = new FilePNG(this->asset, this);
580 file = new FileJPEG(this->asset, this);
585 file = new FileTGA(this->asset, this);
590 file = new FileTIFF(this->asset, this);
594 file = new FileMOV(this->asset, this);
600 file = new FileMPEG(this->asset, this);
604 file = new FileVorbis(this->asset, this);
608 file = new FileMOV(this->asset, this);
611 case FILE_AVI_LAVTOOLS:
614 case FILE_AVI_AVIFILE:
615 file = new FileAVI(this->asset, this);
623 //printf("File::open_file 2\n");
625 // Reopen file with correct parser and get header.
626 if(file->open_file(rd, wr))
633 // Set extra writing parameters to mandatory settings.
636 if(this->asset->dither) file->set_dither();
639 // Synchronize header parameters
640 *asset = *this->asset;
641 //printf("File::open_file 3\n");
646 return FILE_NOT_FOUND;
649 int File::close_file(int ignore_thread)
659 // The file's asset is a copy of the argument passed to open_file so the
660 // user must copy lengths from the file's asset.
661 if(asset && file->wr)
663 asset->audio_length = current_sample;
664 asset->video_length = current_frame;
670 if(resample) delete resample;
676 int File::start_audio_thread(int64_t buffer_size, int ring_buffers)
678 audio_thread = new FileThread(this, 1, 0);
679 audio_thread->start_writing(buffer_size, 0, ring_buffers, 0);
683 int File::start_video_thread(int64_t buffer_size,
688 video_thread = new FileThread(this, 0, 1);
689 //printf("File::start_video_thread 1\n");
690 video_thread->start_writing(buffer_size,
694 //printf("File::start_video_thread 2\n");
698 int File::stop_audio_thread()
700 //printf("File::stop_audio_thread 1\n");
703 audio_thread->stop_writing();
710 int File::stop_video_thread()
712 //printf("File::stop_video_thread 1\n");
715 video_thread->stop_writing();
722 int File::lock_read()
728 int File::unlock_read()
730 // read_lock.unlock();
734 int File::set_channel(int channel)
736 if(file && channel < asset->channels)
738 current_channel = channel;
745 int File::set_layer(int layer)
747 if(file && layer < asset->layers)
749 current_layer = layer;
750 //printf("File::set_layer 1 %d\n", layer);
757 int64_t File::get_audio_length(int64_t base_samplerate)
759 int64_t result = asset->audio_length;
762 if(base_samplerate > 0)
763 return (int64_t)((double)result / asset->sample_rate * base_samplerate + 0.5);
771 int64_t File::get_video_length(float base_framerate)
773 int64_t result = asset->video_length;
776 if(base_framerate > 0)
777 return (int64_t)((double)result / asset->frame_rate * base_framerate + 0.5);
782 return -1; // infinity
786 int64_t File::get_video_position(float base_framerate)
788 if(base_framerate > 0)
789 return (int64_t)((double)current_frame / asset->frame_rate * base_framerate + 0.5);
791 return current_frame;
794 int64_t File::get_audio_position(int64_t base_samplerate)
796 if(base_samplerate > 0)
798 if(normalized_sample_rate == base_samplerate)
799 return normalized_sample;
801 return (int64_t)((double)current_sample /
807 return current_sample;
812 // The base samplerate must be nonzero if the base samplerate in the calling
813 // function is expected to change as this forces the resampler to reset.
815 int File::set_audio_position(int64_t position, float base_samplerate)
821 #define REPOSITION(x, y) \
822 (labs((x) - (y)) > 1)
826 if((base_samplerate && REPOSITION(normalized_sample, position)) ||
827 (!base_samplerate && REPOSITION(current_sample, position)))
829 // Can't reset resampler since one seek operation is done
830 // for every channel to be read at the same position.
832 // Use a conditional reset for just the case of different base_samplerates
833 if(base_samplerate > 0)
835 if(normalized_sample_rate &&
836 normalized_sample_rate != base_samplerate &&
840 normalized_sample = position;
841 normalized_sample_rate = (int64_t)((base_samplerate > 0) ?
845 // Convert position to file's rate
846 if(base_samplerate > 0)
847 current_sample = Units::round((double)position /
853 current_sample = position;
854 normalized_sample = Units::round((double)position /
856 normalized_sample_rate);
857 // Can not set the normalized sample rate since this would reset the resampler.
860 result = file->set_audio_position(current_sample);
863 printf("File::set_audio_position position=%d base_samplerate=%f asset=%p asset->sample_rate=%d\n",
864 position, base_samplerate, asset, asset->sample_rate);
867 //printf("File::set_audio_position %d %d %d\n", current_channel, current_sample, position);
872 int File::set_video_position(int64_t position, float base_framerate)
876 //printf("File::set_video_position 1 %d\n", position);
878 // Convert to file's rate
879 if(base_framerate > 0)
880 position = (int64_t)((double)position / base_framerate * asset->frame_rate + 0.5);
881 //printf("File::set_video_position 2 %d\n", position);
883 if(current_frame != position && file)
885 current_frame = position;
886 result = file->set_video_position(current_frame);
888 //printf("File::set_video_position 3 %d\n", result);
893 // No resampling here.
894 int File::write_samples(double **buffer, int64_t len)
901 result = file->write_samples(buffer, len);
902 current_sample += len;
903 normalized_sample += len;
904 asset->audio_length += len;
910 // Can't put any cmodel abstraction here because the filebase couldn't be
912 int File::write_frames(VFrame ***frames, int len)
914 // Store the counters in temps so the filebase can choose to overwrite them.
916 int current_frame_temp = current_frame;
917 int video_length_temp = asset->video_length;
923 result = file->write_frames(frames, len);
929 current_frame = current_frame_temp + len;
930 asset->video_length = video_length_temp + len;
935 int File::write_compressed_frame(VFrame *buffer)
939 result = file->write_compressed_frame(buffer);
941 asset->video_length++;
947 int File::write_audio_buffer(int64_t len)
952 result = audio_thread->write_buffer(len);
957 int File::write_video_buffer(int64_t len)
962 result = video_thread->write_buffer(len);
968 double** File::get_audio_buffer()
970 if(audio_thread) return audio_thread->get_audio_buffer();
974 VFrame*** File::get_video_buffer()
976 if(video_thread) return video_thread->get_video_buffer();
981 int File::read_samples(double *buffer, int64_t len, int64_t base_samplerate)
984 //printf("File::read_samples 1\n");
986 // Load with resampling
989 // Resample recursively calls this with the asset sample rate
990 if(base_samplerate == 0) base_samplerate = asset->sample_rate;
992 //printf("File::read_samples 2 %d %d\n", base_samplerate, asset->sample_rate);
993 if(base_samplerate != asset->sample_rate)
995 //printf("File::read_samples 3\n");
998 //printf("File::read_samples 4\n");
999 resample = new Resample(this, asset->channels);
1002 //printf("File::read_samples 5\n");
1003 current_sample += resample->resample(buffer,
1010 //printf("File::read_samples 6\n");
1015 //printf("File::read_samples 7\n");
1016 result = file->read_samples(buffer, len);
1017 //printf("File::read_samples 8\n");
1018 current_sample += len;
1021 normalized_sample += len;
1026 int File::read_compressed_frame(VFrame *buffer)
1030 result = file->read_compressed_frame(buffer);
1035 int64_t File::compressed_frame_size()
1038 return file->compressed_frame_size();
1043 // Return a pointer to a frame in the video file for drawing purposes.
1044 // The temporary frame is created by the file handler so that still frame
1045 // files don't have to copy to a new buffer.
1046 VFrame* File::read_frame(int color_model)
1049 //printf("File::read_frame 1\n");
1052 //printf("File::read_frame 2\n");
1054 (return_frame->get_w() != asset->width ||
1055 return_frame->get_h() != asset->height ||
1056 return_frame->get_color_model() != color_model))
1058 delete return_frame;
1062 //printf("File::read_frame 3\n");
1065 return_frame = new VFrame(0,
1070 //printf("File::read_frame 4\n");
1072 read_frame(return_frame);
1073 //printf("File::read_frame 5\n");
1074 result = return_frame;
1076 //printf("File::read_frame 6\n");
1081 int File::read_frame(VFrame *frame)
1085 //printf("File::read_frame 1\n");
1086 int supported_colormodel = colormodel_supported(frame->get_color_model());
1088 //printf("File::read_frame 1 %d %d\n", supported_colormodel, frame->get_color_model());
1090 //printf("File::read_frame 2\n");
1091 if(frame->get_color_model() != BC_COMPRESSED &&
1092 (supported_colormodel != frame->get_color_model() ||
1093 frame->get_w() != asset->width ||
1094 frame->get_h() != asset->height))
1096 //printf("File::read_frame 3\n");
1099 if(!temp_frame->params_match(asset->width, asset->height, supported_colormodel))
1105 //printf("File::read_frame 4 %p %d %d %d\n", asset , asset->width, asset->height, supported_colormodel);
1109 temp_frame = new VFrame(0,
1112 supported_colormodel);
1115 //printf("File::read_frame 5 %d %d\n",
1116 // temp_frame->get_color_model(),
1117 // frame->get_color_model());
1118 VFrame *temp_frame2 = frames_cache->get_frame(current_frame, current_layer, asset->width, asset->height, supported_colormodel);
1122 frame->copy_from(temp_frame2);
1123 // cache is implicitly locked on cache hit
1124 frames_cache->unlock_cache();
1127 frames_cache->unlock_cache();
1128 file->read_frame(temp_frame);
1130 cmodel_transfer(frame->get_rows(),
1131 temp_frame->get_rows(),
1140 temp_frame->get_w(),
1141 temp_frame->get_h(),
1146 temp_frame->get_color_model(),
1147 frame->get_color_model(),
1149 temp_frame->get_w(),
1151 printf("File::read_frame 6\n");
1152 frames_cache->add_frame(current_frame, current_layer, frame);
1158 //printf("File::read_frame 7\n");
1159 VFrame *temp_frame2 = frames_cache->get_frame(current_frame, current_layer, asset->width, asset->height, frame->get_color_model());
1162 frame->copy_from(temp_frame2);
1163 frames_cache->unlock_cache();
1166 frames_cache->unlock_cache();
1167 file->read_frame(frame);
1168 frames_cache->add_frame(current_frame, current_layer, frame);
1171 //printf("File::read_frame 8\n");
1174 //printf("File::read_frame 9\n");
1175 //printf("File::read_frame 2 %d\n", supported_colormodel);
1182 int File::can_copy_from(Edit *edit, int64_t position, int output_w, int output_h)
1186 return edit->asset->width == output_w &&
1187 edit->asset->height == output_h &&
1188 file->can_copy_from(edit, position);
1194 // Fill in queries about formats when adding formats here.
1198 int File::strtoformat(ArrayList<PluginServer*> *plugindb, char *format)
1200 if(!strcasecmp(format, _(WAV_NAME))) return FILE_WAV;
1202 if(!strcasecmp(format, _(PCM_NAME))) return FILE_PCM;
1204 if(!strcasecmp(format, _(AU_NAME))) return FILE_AU;
1206 if(!strcasecmp(format, _(AIFF_NAME))) return FILE_AIFF;
1208 if(!strcasecmp(format, _(SND_NAME))) return FILE_SND;
1210 if(!strcasecmp(format, _(PNG_NAME))) return FILE_PNG;
1212 if(!strcasecmp(format, _(PNG_LIST_NAME))) return FILE_PNG_LIST;
1214 if(!strcasecmp(format, _(TIFF_NAME))) return FILE_TIFF;
1216 if(!strcasecmp(format, _(TIFF_LIST_NAME))) return FILE_TIFF_LIST;
1218 if(!strcasecmp(format, _(JPEG_NAME))) return FILE_JPEG;
1220 if(!strcasecmp(format, _(JPEG_LIST_NAME))) return FILE_JPEG_LIST;
1222 if(!strcasecmp(format, _(MPEG_NAME))) return FILE_MPEG;
1224 if(!strcasecmp(format, _(AMPEG_NAME))) return FILE_AMPEG;
1226 if(!strcasecmp(format, _(VMPEG_NAME))) return FILE_VMPEG;
1228 if(!strcasecmp(format, _(TGA_NAME))) return FILE_TGA;
1230 if(!strcasecmp(format, _(TGA_LIST_NAME))) return FILE_TGA_LIST;
1232 if(!strcasecmp(format, _(MOV_NAME))) return FILE_MOV;
1234 if(!strcasecmp(format, _(AVI_NAME))) return FILE_AVI;
1236 if(!strcasecmp(format, _(AVI_LAVTOOLS_NAME))) return FILE_AVI_LAVTOOLS;
1238 if(!strcasecmp(format, _(AVI_ARNE2_NAME))) return FILE_AVI_ARNE2;
1240 if(!strcasecmp(format, _(AVI_ARNE1_NAME))) return FILE_AVI_ARNE1;
1242 if(!strcasecmp(format, _(AVI_AVIFILE_NAME))) return FILE_AVI_AVIFILE;
1244 if(!strcasecmp(format, _(VORBIS_NAME))) return FILE_VORBIS;
1249 char* File::formattostr(ArrayList<PluginServer*> *plugindb, int format)
1263 return _(AIFF_NAME);
1272 return _(PNG_LIST_NAME);
1275 return _(JPEG_NAME);
1277 case FILE_JPEG_LIST:
1278 return _(JPEG_LIST_NAME);
1281 return _(MPEG_NAME);
1284 return _(AMPEG_NAME);
1287 return _(VMPEG_NAME);
1293 return _(TGA_LIST_NAME);
1296 return _(TIFF_NAME);
1298 case FILE_TIFF_LIST:
1299 return _(TIFF_LIST_NAME);
1304 case FILE_AVI_LAVTOOLS:
1305 return _(AVI_LAVTOOLS_NAME);
1310 case FILE_AVI_ARNE2:
1311 return _(AVI_ARNE2_NAME);
1313 case FILE_AVI_ARNE1:
1314 return _(AVI_ARNE1_NAME);
1316 case FILE_AVI_AVIFILE:
1317 return _(AVI_AVIFILE_NAME);
1320 return _(VORBIS_NAME);
1324 return _("Unknown");
1330 int File::strtobits(char *bits)
1332 if(!strcasecmp(bits, _(NAME_8BIT))) return BITSLINEAR8;
1333 if(!strcasecmp(bits, _(NAME_16BIT))) return BITSLINEAR16;
1334 if(!strcasecmp(bits, _(NAME_24BIT))) return BITSLINEAR24;
1335 if(!strcasecmp(bits, _(NAME_32BIT))) return BITSLINEAR32;
1336 if(!strcasecmp(bits, _(NAME_ULAW))) return BITSULAW;
1337 if(!strcasecmp(bits, _(NAME_ADPCM))) return BITS_ADPCM;
1338 if(!strcasecmp(bits, _(NAME_FLOAT))) return BITSFLOAT;
1339 if(!strcasecmp(bits, _(NAME_IMA4))) return BITSIMA4;
1340 return BITSLINEAR16;
1343 char* File::bitstostr(int bits)
1345 //printf("File::bitstostr\n");
1352 return (NAME_16BIT);
1355 return (NAME_24BIT);
1358 return (NAME_32BIT);
1364 return (NAME_ADPCM);
1367 return (NAME_FLOAT);
1378 int File::str_to_byteorder(char *string)
1380 if(!strcasecmp(string, _("Lo Hi"))) return 1;
1384 char* File::byteorder_to_str(int byte_order)
1386 if(byte_order) return _("Lo Hi");
1390 int File::bytes_per_sample(int bits)
1420 int File::get_best_colormodel(int driver)
1422 return get_best_colormodel(asset, driver);
1425 int File::get_best_colormodel(Asset *asset, int driver)
1427 switch(asset->format)
1430 return FileMOV::get_best_colormodel(asset, driver);
1434 return FileMPEG::get_best_colormodel(asset, driver);
1438 case FILE_JPEG_LIST:
1439 return FileJPEG::get_best_colormodel(asset, driver);
1444 return FilePNG::get_best_colormodel(asset, driver);
1449 return FileTGA::get_best_colormodel(asset, driver);
1457 int File::colormodel_supported(int colormodel)
1460 return file->colormodel_supported(colormodel);
1469 int File::supports_video(ArrayList<PluginServer*> *plugindb, char *format)
1471 int i, format_i = strtoformat(plugindb, format);
1473 return supports_video(format_i);
1475 // for(i = 0; i < plugindb->total; i++)
1477 // if(plugindb->values[i]->fileio &&
1478 // !strcmp(plugindb->values[i]->title, format))
1480 // if(plugindb->values[i]->video) return 1;
1487 int File::supports_audio(ArrayList<PluginServer*> *plugindb, char *format)
1489 int i, format_i = strtoformat(plugindb, format);
1491 return supports_audio(format_i);
1493 // for(i = 0; i < plugindb->total; i++)
1495 // if(plugindb->values[i]->fileio &&
1496 // !strcmp(plugindb->values[i]->title, format))
1498 // if(plugindb->values[i]->audio) return 1;
1506 int File::supports_video(int format)
1508 //printf("File::supports_video %d\n", format);
1513 case FILE_JPEG_LIST:
1519 case FILE_TIFF_LIST:
1521 case FILE_AVI_LAVTOOLS:
1522 case FILE_AVI_ARNE2:
1524 case FILE_AVI_ARNE1:
1525 case FILE_AVI_AVIFILE:
1535 int File::supports_audio(int format)
1548 case FILE_AVI_LAVTOOLS:
1549 case FILE_AVI_ARNE2:
1550 case FILE_AVI_ARNE1:
1551 case FILE_AVI_AVIFILE: