3 * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "awindowgui.h"
26 #include "bcsignals.h"
31 #include "filesystem.h"
33 #include "indexstate.h"
34 #include "interlacemodes.h"
41 : Indexable(1), ListItem<Asset>()
46 Asset::Asset(Asset &asset)
47 : Indexable(1), ListItem<Asset>()
50 this->copy_from(&asset, 1);
53 Asset::Asset(const char *path)
54 : Indexable(1), ListItem<Asset>()
57 strcpy(this->path, path);
60 Asset::Asset(const int plugin_type, const char *plugin_title)
61 : Indexable(1), ListItem<Asset>()
70 int Asset::init_values()
73 // Has to be unknown for file probing to succeed
74 format = FILE_UNKNOWN;
87 ff_audio_options[0] = 0;
88 ff_video_options[0] = 0;
91 ff_video_quality = -1;
95 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
96 interlace_mode = ILACE_MODE_UNDETECTED;
97 interlace_fixmethod = ILACE_FIXMETHOD_NONE;
100 ampeg_derivative = 3;
103 vorbis_min_bitrate = -1;
104 vorbis_bitrate = 128000;
105 vorbis_max_bitrate = -1;
107 theora_fix_bitrate = 1;
108 theora_bitrate = 860000;
110 theora_sharpness = 2;
111 theora_keyframe_frequency = 64;
112 theora_keyframe_force_frequency = 64;
115 vmpeg_iframe_distance = 45;
116 vmpeg_pframe_distance = 0;
117 vmpeg_progressive = 0;
119 vmpeg_bitrate = 1000000;
120 vmpeg_derivative = 1;
121 vmpeg_quantization = 15;
122 vmpeg_cmodel = BC_YUV420P;
123 vmpeg_fix_bitrate = 0;
126 vmpeg_field_order = 0;
136 tiff_compression = 0;
144 void Asset::reset_audio()
152 void Asset::reset_video()
156 actual_width = width = 0;
157 actual_height = height = 0;
160 vmpeg_cmodel = BC_YUV420P;
166 void Asset::boundaries()
168 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
169 // sample_rate & frame_rate are user defined
170 // CLAMP(sample_rate, 1, 1000000);
171 // CLAMP(frame_rate, 0.001, 1000000);
172 CLAMP(channels, 0, 16);
173 CLAMP(width, 0, 10000);
174 CLAMP(height, 0, 10000);
175 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
178 void Asset::copy_from(Asset *asset, int do_index)
180 copy_location(asset);
181 copy_format(asset, do_index);
184 void Asset::copy_location(Asset *asset)
186 strcpy(path, asset->path);
187 awindow_folder = asset->awindow_folder;
190 void Asset::copy_format(Asset *asset, int do_index)
192 if(do_index) update_index(asset);
194 audio_data = asset->audio_data;
195 format = asset->format;
196 strcpy(fformat, asset->fformat);
197 channels = asset->channels;
198 sample_rate = asset->sample_rate;
200 byte_order = asset->byte_order;
201 signed_ = asset->signed_;
202 header = asset->header;
203 dither = asset->dither;
204 mp3_bitrate = asset->mp3_bitrate;
205 use_header = asset->use_header;
206 aspect_ratio = asset->aspect_ratio;
207 interlace_autofixoption = asset->interlace_autofixoption;
208 interlace_mode = asset->interlace_mode;
209 interlace_fixmethod = asset->interlace_fixmethod;
211 video_data = asset->video_data;
212 layers = asset->layers;
213 program = asset->program;
214 frame_rate = asset->frame_rate;
215 width = asset->width;
216 height = asset->height;
217 actual_width = asset->actual_width;
218 actual_height = asset->actual_height;
219 strcpy(vcodec, asset->vcodec);
220 strcpy(acodec, asset->acodec);
222 strcpy(ff_audio_options, asset->ff_audio_options);
223 strcpy(ff_video_options, asset->ff_video_options);
224 ff_audio_bitrate = asset->ff_audio_bitrate;
225 ff_video_bitrate = asset->ff_video_bitrate;
226 ff_video_quality = asset->ff_video_quality;
228 this->audio_length = asset->audio_length;
229 this->video_length = asset->video_length;
230 this->single_frame = asset->single_frame;
232 ampeg_bitrate = asset->ampeg_bitrate;
233 ampeg_derivative = asset->ampeg_derivative;
236 vorbis_vbr = asset->vorbis_vbr;
237 vorbis_min_bitrate = asset->vorbis_min_bitrate;
238 vorbis_bitrate = asset->vorbis_bitrate;
239 vorbis_max_bitrate = asset->vorbis_max_bitrate;
242 theora_fix_bitrate = asset->theora_fix_bitrate;
243 theora_bitrate = asset->theora_bitrate;
244 theora_quality = asset->theora_quality;
245 theora_sharpness = asset->theora_sharpness;
246 theora_keyframe_frequency = asset->theora_keyframe_frequency;
247 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
250 jpeg_quality = asset->jpeg_quality;
253 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
254 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
255 vmpeg_progressive = asset->vmpeg_progressive;
256 vmpeg_denoise = asset->vmpeg_denoise;
257 vmpeg_bitrate = asset->vmpeg_bitrate;
258 vmpeg_derivative = asset->vmpeg_derivative;
259 vmpeg_quantization = asset->vmpeg_quantization;
260 vmpeg_cmodel = asset->vmpeg_cmodel;
261 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
262 vmpeg_seq_codes = asset->vmpeg_seq_codes;
263 vmpeg_preset = asset->vmpeg_preset;
264 vmpeg_field_order = asset->vmpeg_field_order;
266 ac3_bitrate = asset->ac3_bitrate;
268 png_use_alpha = asset->png_use_alpha;
269 exr_use_alpha = asset->exr_use_alpha;
270 exr_compression = asset->exr_compression;
272 tiff_cmodel = asset->tiff_cmodel;
273 tiff_compression = asset->tiff_compression;
276 int64_t Asset::get_index_offset(int channel)
278 return index_state->get_index_offset(channel);
281 int64_t Asset::get_index_size(int channel)
283 return index_state->get_index_size(channel);
287 char* Asset::get_compression_text(int audio, int video)
292 if( acodec[0] ) return acodec;
299 if( vcodec[0] ) return vcodec;
306 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
308 int result = format == asset.format ? 1 : 0;
309 if( result && strcmp(asset.path, path) ) {
310 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
311 char *sp = out_path ? strrchr(out_path,'/') : 0;
313 char *apath = FileSystem::basepath(asset.path);
314 char *tpath = FileSystem::basepath(this->path);
316 if( *apath != '/' ) {
317 char *cp = cstrcat(2, out_path, apath);
318 delete [] apath; apath = FileSystem::basepath(cp);
321 if( *tpath != '/' ) {
322 char *cp = cstrcat(2, out_path, tpath);
323 delete [] tpath; tpath = FileSystem::basepath(cp);
327 if( strcmp(apath, tpath) ) result = 0;
333 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
336 if(test_audio && result)
338 result = (channels == asset.channels &&
339 sample_rate == asset.sample_rate &&
340 bits == asset.bits &&
341 byte_order == asset.byte_order &&
342 signed_ == asset.signed_ &&
343 header == asset.header &&
344 dither == asset.dither &&
345 !strcmp(acodec, asset.acodec));
346 if(result && format == FILE_FFMPEG)
347 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
348 ff_audio_bitrate == asset.ff_audio_bitrate;
353 if(test_video && result)
355 result = (layers == asset.layers &&
356 program == asset.program &&
357 frame_rate == asset.frame_rate &&
358 asset.interlace_autofixoption == interlace_autofixoption &&
359 asset.interlace_mode == interlace_mode &&
360 interlace_fixmethod == asset.interlace_fixmethod &&
361 width == asset.width &&
362 height == asset.height &&
363 !strcmp(vcodec, asset.vcodec));
364 if(result && format == FILE_FFMPEG)
365 result = !strcmp(ff_video_options, asset.ff_video_options) &&
366 ff_video_bitrate == asset.ff_video_bitrate &&
367 ff_video_quality == asset.ff_video_quality;
373 int Asset::test_path(const char *path)
375 if(!strcasecmp(this->path, path))
381 int Asset::read(FileXML *file,
386 // Check for relative path.
389 char new_path[BCTEXTLEN];
390 char asset_directory[BCTEXTLEN];
391 char input_directory[BCTEXTLEN];
394 strcpy(new_path, path);
395 fs.set_current_dir("");
397 fs.extract_dir(asset_directory, path);
400 // Take path of XML file.
401 if(!asset_directory[0])
403 fs.extract_dir(input_directory, file->filename);
405 // Input file has a path
406 if(input_directory[0])
408 fs.join_names(path, input_directory, new_path);
416 result = file->read_tag();
419 if(file->tag.title_is("/ASSET"))
424 if(file->tag.title_is("AUDIO"))
429 if(file->tag.title_is("AUDIO_OMIT"))
434 if(file->tag.title_is("FORMAT"))
436 const char *string = file->tag.get_property("TYPE");
437 format = File::strtoformat(string);
439 file->tag.get_property("USE_HEADER", use_header);
440 file->tag.get_property("FFORMAT", fformat);
443 if(file->tag.title_is("FOLDER"))
445 const char *string = file->tag.get_property("NUMBER");
446 awindow_folder = string ? atoi(string) :
447 AWindowGUI::folder_number(file->read_text());
450 if(file->tag.title_is("VIDEO"))
455 if(file->tag.title_is("VIDEO_OMIT"))
460 if(file->tag.title_is("INDEX"))
468 //printf("Asset::read 2\n");
472 int Asset::read_audio(FileXML *file)
474 if(file->tag.title_is("AUDIO")) audio_data = 1;
475 channels = file->tag.get_property("CHANNELS", 2);
476 // This is loaded from the index file after the EDL but this
477 // should be overridable in the EDL.
478 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
479 bits = file->tag.get_property("BITS", 16);
480 byte_order = file->tag.get_property("BYTE_ORDER", 1);
481 signed_ = file->tag.get_property("SIGNED", 1);
482 header = file->tag.get_property("HEADER", 0);
483 dither = file->tag.get_property("DITHER", 0);
485 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
487 file->tag.get_property("ACODEC", acodec);
491 int Asset::read_video(FileXML *file)
493 char string[BCTEXTLEN];
495 if(file->tag.title_is("VIDEO")) video_data = 1;
496 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
497 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
498 height = file->tag.get_property("HEIGHT", height);
499 width = file->tag.get_property("WIDTH", width);
500 layers = file->tag.get_property("LAYERS", layers);
501 program = file->tag.get_property("PROGRAM", program);
502 // This is loaded from the index file after the EDL but this
503 // should be overridable in the EDL.
504 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
506 file->tag.get_property("VCODEC", vcodec);
508 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
509 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
511 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
513 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
514 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
516 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
517 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
522 int Asset::read_index(FileXML *file)
524 index_state->read_xml(file, channels);
528 // Output path is the path of the output file if name truncation is desired.
529 // It is a "" if complete names should be used.
531 int Asset::write(FileXML *file,
533 const char *output_path)
535 char new_path[BCTEXTLEN];
536 char asset_directory[BCTEXTLEN];
537 char output_directory[BCTEXTLEN];
540 // Make path relative
541 fs.extract_dir(asset_directory, path);
542 if(output_path && output_path[0])
543 fs.extract_dir(output_directory, output_path);
545 output_directory[0] = 0;
547 // Asset and EDL are in same directory. Extract just the name.
548 if(!strcmp(asset_directory, output_directory))
550 fs.extract_name(new_path, path);
554 strcpy(new_path, path);
557 file->tag.set_title("ASSET");
558 file->tag.set_property("SRC", new_path);
560 file->append_newline();
562 file->tag.set_title("FOLDER");
563 file->tag.set_property("NUMBER", awindow_folder);
565 file->tag.set_title("/FOLDER");
567 file->append_newline();
569 // Write the format information
570 file->tag.set_title("FORMAT");
572 file->tag.set_property("TYPE",
573 File::formattostr(format));
574 file->tag.set_property("USE_HEADER", use_header);
575 file->tag.set_property("FFORMAT", fformat);
578 file->tag.set_title("/FORMAT");
580 file->append_newline();
582 // Requiring data to exist caused batch render to lose settings.
583 // But the only way to know if an asset doesn't have audio or video data
584 // is to not write the block.
585 // So change the block name if the asset doesn't have the data.
588 // index goes after source
589 if(index_state->index_status == INDEX_READY && include_index)
592 file->tag.set_title("/ASSET");
594 file->append_newline();
598 int Asset::write_audio(FileXML *file)
600 // Let the reader know if the asset has the data by naming the block.
602 file->tag.set_title("AUDIO");
604 file->tag.set_title("AUDIO_OMIT");
605 // Necessary for PCM audio
606 file->tag.set_property("CHANNELS", channels);
607 file->tag.set_property("RATE", sample_rate);
608 file->tag.set_property("BITS", bits);
609 file->tag.set_property("BYTE_ORDER", byte_order);
610 file->tag.set_property("SIGNED", signed_);
611 file->tag.set_property("HEADER", header);
612 file->tag.set_property("DITHER", dither);
614 file->tag.set_property("ACODEC", acodec);
616 file->tag.set_property("AUDIO_LENGTH", audio_length);
620 // Rely on defaults operations for these.
622 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
623 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
625 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
626 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
627 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
628 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
630 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
637 file->tag.set_title("/AUDIO");
639 file->tag.set_title("/AUDIO_OMIT");
641 file->append_newline();
645 int Asset::write_video(FileXML *file)
647 char string[BCTEXTLEN];
650 file->tag.set_title("VIDEO");
652 file->tag.set_title("VIDEO_OMIT");
653 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
654 file->tag.set_property("ACTUAL_WIDTH", actual_width);
655 file->tag.set_property("HEIGHT", height);
656 file->tag.set_property("WIDTH", width);
657 file->tag.set_property("LAYERS", layers);
658 file->tag.set_property("PROGRAM", program);
659 file->tag.set_property("FRAMERATE", frame_rate);
661 file->tag.set_property("VCODEC", vcodec);
663 file->tag.set_property("VIDEO_LENGTH", video_length);
664 file->tag.set_property("SINGLE_FRAME", single_frame);
666 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
668 ilacemode_to_xmltext(string, interlace_mode);
669 file->tag.set_property("INTERLACE_MODE", string);
671 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
672 file->tag.set_property("INTERLACE_FIXMETHOD", string);
676 file->tag.set_title("/VIDEO");
678 file->tag.set_title("/VIDEO_OMIT");
681 file->append_newline();
685 int Asset::write_index(FileXML *file)
687 index_state->write_xml(file);
692 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
695 sprintf(return_value, "%s%s", prefix, param);
697 strcpy(return_value, param);
701 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
702 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
704 void Asset::load_defaults(BC_Hash *defaults,
712 char string[BCTEXTLEN];
714 // Can't save codec here because it's specific to render, record, and effect.
715 // The codec has to be UNKNOWN for file probing to work.
719 GET_DEFAULT("PATH", path);
724 GET_DEFAULT("AUDIO_CODEC", acodec);
725 GET_DEFAULT("VIDEO_CODEC", vcodec);
730 format = GET_DEFAULT("FORMAT", format);
731 use_header = GET_DEFAULT("USE_HEADER", use_header);
732 GET_DEFAULT("FFORMAT", fformat);
737 audio_data = GET_DEFAULT("AUDIO", 1);
738 video_data = GET_DEFAULT("VIDEO", 1);
743 bits = GET_DEFAULT("BITS", 16);
744 dither = GET_DEFAULT("DITHER", 0);
745 signed_ = GET_DEFAULT("SIGNED", 1);
746 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
750 channels = GET_DEFAULT("CHANNELS", 2);
751 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
752 header = GET_DEFAULT("HEADER", 0);
753 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
757 height = GET_DEFAULT("HEIGHT", height);
758 width = GET_DEFAULT("WIDTH", width);
759 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
760 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
761 program = GET_DEFAULT("PROGRAM", program);
762 layers = GET_DEFAULT("LAYERS", layers);
763 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
764 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
765 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
768 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
769 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
771 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
772 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
773 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
774 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
776 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
777 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
778 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
779 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
780 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
781 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
783 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
784 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
785 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
786 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
787 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
789 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
791 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
792 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
794 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
795 interlace_mode = ILACE_MODE_UNDETECTED;
796 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
798 // MPEG format information
799 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
800 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
801 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
802 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
803 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
804 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
805 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
806 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
807 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
808 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
809 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
810 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
812 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
813 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
814 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
815 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
816 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
817 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
820 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
822 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
823 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
824 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
825 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
826 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
831 void Asset::save_defaults(BC_Hash *defaults,
839 char string[BCTEXTLEN];
841 UPDATE_DEFAULT("PATH", path);
848 UPDATE_DEFAULT("FORMAT", format);
849 UPDATE_DEFAULT("USE_HEADER", use_header);
850 UPDATE_DEFAULT("FFORMAT", fformat);
855 UPDATE_DEFAULT("AUDIO", audio_data);
856 UPDATE_DEFAULT("VIDEO", video_data);
861 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
862 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
864 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
865 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
867 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
868 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
869 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
870 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
872 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
873 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
874 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
875 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
876 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
878 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
879 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
880 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
881 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
882 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
883 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
887 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
889 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
890 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
892 // MPEG format information
893 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
894 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
895 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
896 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
897 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
898 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
899 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
900 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
901 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
902 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
903 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
904 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
907 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
910 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
911 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
912 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
913 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
914 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
919 UPDATE_DEFAULT("BITS", bits);
920 UPDATE_DEFAULT("DITHER", dither);
921 UPDATE_DEFAULT("SIGNED", signed_);
922 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
929 UPDATE_DEFAULT("CHANNELS", channels);
930 UPDATE_DEFAULT("RATE", sample_rate);
931 UPDATE_DEFAULT("HEADER", header);
932 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
936 UPDATE_DEFAULT("HEIGHT", height);
937 UPDATE_DEFAULT("WIDTH", width);
938 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
939 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
940 UPDATE_DEFAULT("PROGRAM", program);
941 UPDATE_DEFAULT("LAYERS", layers);
942 UPDATE_DEFAULT("FRAMERATE", frame_rate);
943 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
944 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
957 int Asset::dump(FILE *fp)
959 fprintf(fp," asset::dump\n");
960 fprintf(fp," this=%p path=%s\n", this, path);
961 fprintf(fp," index_status %d\n", index_state->index_status);
962 fprintf(fp," format %d\n", format);
963 fprintf(fp," fformat=\"%s\"\n", fformat);
964 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
965 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
966 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
967 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
968 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
969 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
970 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
971 audio_data, channels, sample_rate, bits, byte_order, signed_,
972 header, dither, acodec);
973 fprintf(fp," audio_length %jd\n", audio_length);
974 char string[BCTEXTLEN];
975 ilacemode_to_xmltext(string, interlace_mode);
976 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
977 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
978 video_data, layers, program, frame_rate, width, height,
979 vcodec, aspect_ratio,string);
980 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
986 int Asset::get_audio_channels()
991 int Asset::get_sample_rate()
996 int64_t Asset::get_audio_samples()
1001 int Asset::have_audio()
1006 int Asset::have_video()
1021 double Asset::get_frame_rate()
1027 int Asset::get_video_layers()
1032 int Asset::get_program()
1037 int64_t Asset::get_video_frames()
1039 return video_length;
1042 double Asset::total_length_framealigned(double fps)
1044 if (video_data && audio_data) {
1045 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1046 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1047 return MIN(aud,vid);
1051 return (double)audio_length / sample_rate;
1054 return (double)video_length / frame_rate;