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;
135 tiff_compression = 0;
143 void Asset::reset_audio()
151 void Asset::reset_video()
155 actual_width = width = 0;
156 actual_height = height = 0;
159 vmpeg_cmodel = BC_YUV420P;
165 void Asset::boundaries()
167 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
168 // sample_rate & frame_rate are user defined
169 // CLAMP(sample_rate, 1, 1000000);
170 // CLAMP(frame_rate, 0.001, 1000000);
171 CLAMP(channels, 0, 16);
172 CLAMP(width, 0, 10000);
173 CLAMP(height, 0, 10000);
174 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
177 void Asset::copy_from(Asset *asset, int do_index)
179 copy_location(asset);
180 copy_format(asset, do_index);
183 void Asset::copy_location(Asset *asset)
185 strcpy(path, asset->path);
186 awindow_folder = asset->awindow_folder;
189 void Asset::copy_format(Asset *asset, int do_index)
191 if(do_index) update_index(asset);
193 audio_data = asset->audio_data;
194 format = asset->format;
195 strcpy(fformat, asset->fformat);
196 channels = asset->channels;
197 sample_rate = asset->sample_rate;
199 byte_order = asset->byte_order;
200 signed_ = asset->signed_;
201 header = asset->header;
202 dither = asset->dither;
203 mp3_bitrate = asset->mp3_bitrate;
204 use_header = asset->use_header;
205 aspect_ratio = asset->aspect_ratio;
206 interlace_autofixoption = asset->interlace_autofixoption;
207 interlace_mode = asset->interlace_mode;
208 interlace_fixmethod = asset->interlace_fixmethod;
210 video_data = asset->video_data;
211 layers = asset->layers;
212 program = asset->program;
213 frame_rate = asset->frame_rate;
214 width = asset->width;
215 height = asset->height;
216 actual_width = asset->actual_width;
217 actual_height = asset->actual_height;
218 strcpy(vcodec, asset->vcodec);
219 strcpy(acodec, asset->acodec);
221 strcpy(ff_audio_options, asset->ff_audio_options);
222 strcpy(ff_video_options, asset->ff_video_options);
223 ff_audio_bitrate = asset->ff_audio_bitrate;
224 ff_video_bitrate = asset->ff_video_bitrate;
225 ff_video_quality = asset->ff_video_quality;
227 this->audio_length = asset->audio_length;
228 this->video_length = asset->video_length;
229 this->single_frame = asset->single_frame;
231 ampeg_bitrate = asset->ampeg_bitrate;
232 ampeg_derivative = asset->ampeg_derivative;
235 vorbis_vbr = asset->vorbis_vbr;
236 vorbis_min_bitrate = asset->vorbis_min_bitrate;
237 vorbis_bitrate = asset->vorbis_bitrate;
238 vorbis_max_bitrate = asset->vorbis_max_bitrate;
241 theora_fix_bitrate = asset->theora_fix_bitrate;
242 theora_bitrate = asset->theora_bitrate;
243 theora_quality = asset->theora_quality;
244 theora_sharpness = asset->theora_sharpness;
245 theora_keyframe_frequency = asset->theora_keyframe_frequency;
246 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
249 jpeg_quality = asset->jpeg_quality;
252 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
253 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
254 vmpeg_progressive = asset->vmpeg_progressive;
255 vmpeg_denoise = asset->vmpeg_denoise;
256 vmpeg_bitrate = asset->vmpeg_bitrate;
257 vmpeg_derivative = asset->vmpeg_derivative;
258 vmpeg_quantization = asset->vmpeg_quantization;
259 vmpeg_cmodel = asset->vmpeg_cmodel;
260 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
261 vmpeg_seq_codes = asset->vmpeg_seq_codes;
262 vmpeg_preset = asset->vmpeg_preset;
263 vmpeg_field_order = asset->vmpeg_field_order;
265 ac3_bitrate = asset->ac3_bitrate;
267 png_use_alpha = asset->png_use_alpha;
268 exr_use_alpha = asset->exr_use_alpha;
269 exr_compression = asset->exr_compression;
271 tiff_cmodel = asset->tiff_cmodel;
272 tiff_compression = asset->tiff_compression;
275 int64_t Asset::get_index_offset(int channel)
277 return index_state->get_index_offset(channel);
280 int64_t Asset::get_index_size(int channel)
282 return index_state->get_index_size(channel);
286 char* Asset::get_compression_text(int audio, int video)
291 if( acodec[0] ) return acodec;
298 if( vcodec[0] ) return vcodec;
305 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
307 int result = format == asset.format ? 1 : 0;
308 if( result && strcmp(asset.path, path) ) {
309 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
310 char *sp = out_path ? strrchr(out_path,'/') : 0;
312 char *apath = FileSystem::basepath(asset.path);
313 char *tpath = FileSystem::basepath(this->path);
315 if( *apath != '/' ) {
316 char *cp = cstrcat(2, out_path, apath);
317 delete [] apath; apath = FileSystem::basepath(cp);
320 if( *tpath != '/' ) {
321 char *cp = cstrcat(2, out_path, tpath);
322 delete [] tpath; tpath = FileSystem::basepath(cp);
326 if( strcmp(apath, tpath) ) result = 0;
332 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
335 if(test_audio && result)
337 result = (channels == asset.channels &&
338 sample_rate == asset.sample_rate &&
339 bits == asset.bits &&
340 byte_order == asset.byte_order &&
341 signed_ == asset.signed_ &&
342 header == asset.header &&
343 dither == asset.dither &&
344 !strcmp(acodec, asset.acodec));
345 if(result && format == FILE_FFMPEG)
346 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
347 ff_audio_bitrate == asset.ff_audio_bitrate;
352 if(test_video && result)
354 result = (layers == asset.layers &&
355 program == asset.program &&
356 frame_rate == asset.frame_rate &&
357 asset.interlace_autofixoption == interlace_autofixoption &&
358 asset.interlace_mode == interlace_mode &&
359 interlace_fixmethod == asset.interlace_fixmethod &&
360 width == asset.width &&
361 height == asset.height &&
362 !strcmp(vcodec, asset.vcodec));
363 if(result && format == FILE_FFMPEG)
364 result = !strcmp(ff_video_options, asset.ff_video_options) &&
365 ff_video_bitrate == asset.ff_video_bitrate &&
366 ff_video_quality == asset.ff_video_quality;
372 int Asset::test_path(const char *path)
374 if(!strcasecmp(this->path, path))
380 int Asset::read(FileXML *file,
385 // Check for relative path.
388 char new_path[BCTEXTLEN];
389 char asset_directory[BCTEXTLEN];
390 char input_directory[BCTEXTLEN];
393 strcpy(new_path, path);
394 fs.set_current_dir("");
396 fs.extract_dir(asset_directory, path);
399 // Take path of XML file.
400 if(!asset_directory[0])
402 fs.extract_dir(input_directory, file->filename);
404 // Input file has a path
405 if(input_directory[0])
407 fs.join_names(path, input_directory, new_path);
415 result = file->read_tag();
418 if(file->tag.title_is("/ASSET"))
423 if(file->tag.title_is("AUDIO"))
428 if(file->tag.title_is("AUDIO_OMIT"))
433 if(file->tag.title_is("FORMAT"))
435 const char *string = file->tag.get_property("TYPE");
436 format = File::strtoformat(string);
438 file->tag.get_property("USE_HEADER", use_header);
439 file->tag.get_property("FFORMAT", fformat);
442 if(file->tag.title_is("FOLDER"))
444 const char *string = file->tag.get_property("NUMBER");
445 awindow_folder = string ? atoi(string) :
446 AWindowGUI::folder_number(file->read_text());
449 if(file->tag.title_is("VIDEO"))
454 if(file->tag.title_is("VIDEO_OMIT"))
459 if(file->tag.title_is("INDEX"))
467 //printf("Asset::read 2\n");
471 int Asset::read_audio(FileXML *file)
473 if(file->tag.title_is("AUDIO")) audio_data = 1;
474 channels = file->tag.get_property("CHANNELS", 2);
475 // This is loaded from the index file after the EDL but this
476 // should be overridable in the EDL.
477 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
478 bits = file->tag.get_property("BITS", 16);
479 byte_order = file->tag.get_property("BYTE_ORDER", 1);
480 signed_ = file->tag.get_property("SIGNED", 1);
481 header = file->tag.get_property("HEADER", 0);
482 dither = file->tag.get_property("DITHER", 0);
484 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
486 file->tag.get_property("ACODEC", acodec);
490 int Asset::read_video(FileXML *file)
492 char string[BCTEXTLEN];
494 if(file->tag.title_is("VIDEO")) video_data = 1;
495 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
496 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
497 height = file->tag.get_property("HEIGHT", height);
498 width = file->tag.get_property("WIDTH", width);
499 layers = file->tag.get_property("LAYERS", layers);
500 program = file->tag.get_property("PROGRAM", program);
501 // This is loaded from the index file after the EDL but this
502 // should be overridable in the EDL.
503 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
505 file->tag.get_property("VCODEC", vcodec);
507 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
508 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
510 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
512 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
513 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
515 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
516 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
521 int Asset::read_index(FileXML *file)
523 index_state->read_xml(file, channels);
527 // Output path is the path of the output file if name truncation is desired.
528 // It is a "" if complete names should be used.
530 int Asset::write(FileXML *file,
532 const char *output_path)
534 char new_path[BCTEXTLEN];
535 char asset_directory[BCTEXTLEN];
536 char output_directory[BCTEXTLEN];
539 // Make path relative
540 fs.extract_dir(asset_directory, path);
541 if(output_path && output_path[0])
542 fs.extract_dir(output_directory, output_path);
544 output_directory[0] = 0;
546 // Asset and EDL are in same directory. Extract just the name.
547 if(!strcmp(asset_directory, output_directory))
549 fs.extract_name(new_path, path);
553 strcpy(new_path, path);
556 file->tag.set_title("ASSET");
557 file->tag.set_property("SRC", new_path);
559 file->append_newline();
561 file->tag.set_title("FOLDER");
562 file->tag.set_property("NUMBER", awindow_folder);
564 file->tag.set_title("/FOLDER");
566 file->append_newline();
568 // Write the format information
569 file->tag.set_title("FORMAT");
571 file->tag.set_property("TYPE",
572 File::formattostr(format));
573 file->tag.set_property("USE_HEADER", use_header);
574 file->tag.set_property("FFORMAT", fformat);
577 file->tag.set_title("/FORMAT");
579 file->append_newline();
581 // Requiring data to exist caused batch render to lose settings.
582 // But the only way to know if an asset doesn't have audio or video data
583 // is to not write the block.
584 // So change the block name if the asset doesn't have the data.
587 // index goes after source
588 if(index_state->index_status == INDEX_READY && include_index)
591 file->tag.set_title("/ASSET");
593 file->append_newline();
597 int Asset::write_audio(FileXML *file)
599 // Let the reader know if the asset has the data by naming the block.
601 file->tag.set_title("AUDIO");
603 file->tag.set_title("AUDIO_OMIT");
604 // Necessary for PCM audio
605 file->tag.set_property("CHANNELS", channels);
606 file->tag.set_property("RATE", sample_rate);
607 file->tag.set_property("BITS", bits);
608 file->tag.set_property("BYTE_ORDER", byte_order);
609 file->tag.set_property("SIGNED", signed_);
610 file->tag.set_property("HEADER", header);
611 file->tag.set_property("DITHER", dither);
613 file->tag.set_property("ACODEC", acodec);
615 file->tag.set_property("AUDIO_LENGTH", audio_length);
619 // Rely on defaults operations for these.
621 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
622 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
624 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
625 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
626 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
627 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
629 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
636 file->tag.set_title("/AUDIO");
638 file->tag.set_title("/AUDIO_OMIT");
640 file->append_newline();
644 int Asset::write_video(FileXML *file)
646 char string[BCTEXTLEN];
649 file->tag.set_title("VIDEO");
651 file->tag.set_title("VIDEO_OMIT");
652 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
653 file->tag.set_property("ACTUAL_WIDTH", actual_width);
654 file->tag.set_property("HEIGHT", height);
655 file->tag.set_property("WIDTH", width);
656 file->tag.set_property("LAYERS", layers);
657 file->tag.set_property("PROGRAM", program);
658 file->tag.set_property("FRAMERATE", frame_rate);
660 file->tag.set_property("VCODEC", vcodec);
662 file->tag.set_property("VIDEO_LENGTH", video_length);
663 file->tag.set_property("SINGLE_FRAME", single_frame);
665 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
667 ilacemode_to_xmltext(string, interlace_mode);
668 file->tag.set_property("INTERLACE_MODE", string);
670 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
671 file->tag.set_property("INTERLACE_FIXMETHOD", string);
675 file->tag.set_title("/VIDEO");
677 file->tag.set_title("/VIDEO_OMIT");
680 file->append_newline();
684 int Asset::write_index(FileXML *file)
686 index_state->write_xml(file);
691 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
694 sprintf(return_value, "%s%s", prefix, param);
696 strcpy(return_value, param);
700 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
701 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
703 void Asset::load_defaults(BC_Hash *defaults,
711 char string[BCTEXTLEN];
713 // Can't save codec here because it's specific to render, record, and effect.
714 // The codec has to be UNKNOWN for file probing to work.
718 GET_DEFAULT("PATH", path);
723 GET_DEFAULT("AUDIO_CODEC", acodec);
724 GET_DEFAULT("VIDEO_CODEC", vcodec);
729 format = GET_DEFAULT("FORMAT", format);
730 use_header = GET_DEFAULT("USE_HEADER", use_header);
731 GET_DEFAULT("FFORMAT", fformat);
736 audio_data = GET_DEFAULT("AUDIO", 1);
737 video_data = GET_DEFAULT("VIDEO", 1);
742 bits = GET_DEFAULT("BITS", 16);
743 dither = GET_DEFAULT("DITHER", 0);
744 signed_ = GET_DEFAULT("SIGNED", 1);
745 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
749 channels = GET_DEFAULT("CHANNELS", 2);
750 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
751 header = GET_DEFAULT("HEADER", 0);
752 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
756 height = GET_DEFAULT("HEIGHT", height);
757 width = GET_DEFAULT("WIDTH", width);
758 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
759 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
760 program = GET_DEFAULT("PROGRAM", program);
761 layers = GET_DEFAULT("LAYERS", layers);
762 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
763 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
764 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
767 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
768 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
770 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
771 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
772 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
773 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
775 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
776 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
777 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
778 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
779 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
780 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
782 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
783 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
784 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
785 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
786 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
788 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
790 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
791 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
793 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
794 interlace_mode = ILACE_MODE_UNDETECTED;
795 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
797 // MPEG format information
798 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
799 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
800 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
801 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
802 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
803 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
804 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
805 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
806 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
807 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
808 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
809 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
811 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
812 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
813 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
814 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
815 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
816 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
819 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
821 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
822 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
823 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
824 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
825 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
830 void Asset::save_defaults(BC_Hash *defaults,
838 char string[BCTEXTLEN];
840 UPDATE_DEFAULT("PATH", path);
847 UPDATE_DEFAULT("FORMAT", format);
848 UPDATE_DEFAULT("USE_HEADER", use_header);
849 UPDATE_DEFAULT("FFORMAT", fformat);
854 UPDATE_DEFAULT("AUDIO", audio_data);
855 UPDATE_DEFAULT("VIDEO", video_data);
860 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
861 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
863 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
864 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
866 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
867 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
868 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
869 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
871 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
872 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
873 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
874 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
875 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
877 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
878 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
879 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
880 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
881 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
882 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
886 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
888 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
889 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
891 // MPEG format information
892 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
893 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
894 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
895 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
896 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
897 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
898 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
899 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
900 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
901 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
902 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
903 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
906 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
909 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
910 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
911 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
912 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
913 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
918 UPDATE_DEFAULT("BITS", bits);
919 UPDATE_DEFAULT("DITHER", dither);
920 UPDATE_DEFAULT("SIGNED", signed_);
921 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
928 UPDATE_DEFAULT("CHANNELS", channels);
929 UPDATE_DEFAULT("RATE", sample_rate);
930 UPDATE_DEFAULT("HEADER", header);
931 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
935 UPDATE_DEFAULT("HEIGHT", height);
936 UPDATE_DEFAULT("WIDTH", width);
937 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
938 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
939 UPDATE_DEFAULT("PROGRAM", program);
940 UPDATE_DEFAULT("LAYERS", layers);
941 UPDATE_DEFAULT("FRAMERATE", frame_rate);
942 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
943 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
956 int Asset::dump(FILE *fp)
958 fprintf(fp," asset::dump\n");
959 fprintf(fp," this=%p path=%s\n", this, path);
960 fprintf(fp," index_status %d\n", index_state->index_status);
961 fprintf(fp," format %d\n", format);
962 fprintf(fp," fformat=\"%s\"\n", fformat);
963 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
964 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
965 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
966 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
967 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
968 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
969 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
970 audio_data, channels, sample_rate, bits, byte_order, signed_,
971 header, dither, acodec);
972 fprintf(fp," audio_length %jd\n", audio_length);
973 char string[BCTEXTLEN];
974 ilacemode_to_xmltext(string, interlace_mode);
975 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
976 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
977 video_data, layers, program, frame_rate, width, height,
978 vcodec, aspect_ratio,string);
979 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
985 int Asset::get_audio_channels()
990 int Asset::get_sample_rate()
995 int64_t Asset::get_audio_samples()
1000 int Asset::have_audio()
1005 int Asset::have_video()
1020 double Asset::get_frame_rate()
1026 int Asset::get_video_layers()
1031 int Asset::get_program()
1036 int64_t Asset::get_video_frames()
1038 return video_length;
1041 double Asset::total_length_framealigned(double fps)
1043 if (video_data && audio_data) {
1044 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1045 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1046 return MIN(aud,vid);
1050 return (double)audio_length / sample_rate;
1053 return (double)video_length / frame_rate;