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;
146 void Asset::reset_audio()
154 void Asset::reset_video()
158 actual_width = width = 0;
159 actual_height = height = 0;
162 vmpeg_cmodel = BC_YUV420P;
168 void Asset::boundaries()
170 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
171 // sample_rate & frame_rate are user defined
172 // CLAMP(sample_rate, 1, 1000000);
173 // CLAMP(frame_rate, 0.001, 1000000);
174 CLAMP(channels, 0, 16);
175 CLAMP(width, 0, 10000);
176 CLAMP(height, 0, 10000);
177 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
180 void Asset::copy_from(Asset *asset, int do_index)
182 copy_location(asset);
183 copy_format(asset, do_index);
186 void Asset::copy_location(Asset *asset)
188 strcpy(path, asset->path);
189 awindow_folder = asset->awindow_folder;
192 void Asset::copy_format(Asset *asset, int do_index)
194 if(do_index) update_index(asset);
196 audio_data = asset->audio_data;
197 format = asset->format;
198 strcpy(fformat, asset->fformat);
199 channels = asset->channels;
200 sample_rate = asset->sample_rate;
202 byte_order = asset->byte_order;
203 signed_ = asset->signed_;
204 header = asset->header;
205 dither = asset->dither;
206 mp3_bitrate = asset->mp3_bitrate;
207 use_header = asset->use_header;
208 aspect_ratio = asset->aspect_ratio;
209 interlace_autofixoption = asset->interlace_autofixoption;
210 interlace_mode = asset->interlace_mode;
211 interlace_fixmethod = asset->interlace_fixmethod;
213 video_data = asset->video_data;
214 layers = asset->layers;
215 program = asset->program;
216 frame_rate = asset->frame_rate;
217 width = asset->width;
218 height = asset->height;
219 actual_width = asset->actual_width;
220 actual_height = asset->actual_height;
221 strcpy(vcodec, asset->vcodec);
222 strcpy(acodec, asset->acodec);
224 strcpy(ff_audio_options, asset->ff_audio_options);
225 strcpy(ff_video_options, asset->ff_video_options);
226 ff_audio_bitrate = asset->ff_audio_bitrate;
227 ff_video_bitrate = asset->ff_video_bitrate;
228 ff_video_quality = asset->ff_video_quality;
230 this->audio_length = asset->audio_length;
231 this->video_length = asset->video_length;
232 this->single_frame = asset->single_frame;
234 ampeg_bitrate = asset->ampeg_bitrate;
235 ampeg_derivative = asset->ampeg_derivative;
238 vorbis_vbr = asset->vorbis_vbr;
239 vorbis_min_bitrate = asset->vorbis_min_bitrate;
240 vorbis_bitrate = asset->vorbis_bitrate;
241 vorbis_max_bitrate = asset->vorbis_max_bitrate;
244 theora_fix_bitrate = asset->theora_fix_bitrate;
245 theora_bitrate = asset->theora_bitrate;
246 theora_quality = asset->theora_quality;
247 theora_sharpness = asset->theora_sharpness;
248 theora_keyframe_frequency = asset->theora_keyframe_frequency;
249 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
252 jpeg_quality = asset->jpeg_quality;
255 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
256 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
257 vmpeg_progressive = asset->vmpeg_progressive;
258 vmpeg_denoise = asset->vmpeg_denoise;
259 vmpeg_bitrate = asset->vmpeg_bitrate;
260 vmpeg_derivative = asset->vmpeg_derivative;
261 vmpeg_quantization = asset->vmpeg_quantization;
262 vmpeg_cmodel = asset->vmpeg_cmodel;
263 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
264 vmpeg_seq_codes = asset->vmpeg_seq_codes;
265 vmpeg_preset = asset->vmpeg_preset;
266 vmpeg_field_order = asset->vmpeg_field_order;
268 ac3_bitrate = asset->ac3_bitrate;
270 png_use_alpha = asset->png_use_alpha;
271 exr_use_alpha = asset->exr_use_alpha;
272 exr_compression = asset->exr_compression;
274 tiff_cmodel = asset->tiff_cmodel;
275 tiff_compression = asset->tiff_compression;
278 mov_sphere = asset->mov_sphere;
279 jpeg_sphere = asset->jpeg_sphere;
282 int64_t Asset::get_index_offset(int channel)
284 return index_state->get_index_offset(channel);
287 int64_t Asset::get_index_size(int channel)
289 return index_state->get_index_size(channel);
293 char* Asset::get_compression_text(int audio, int video)
298 if( acodec[0] ) return acodec;
305 if( vcodec[0] ) return vcodec;
312 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
314 int result = format == asset.format ? 1 : 0;
315 if( result && strcmp(asset.path, path) ) {
316 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
317 char *sp = out_path ? strrchr(out_path,'/') : 0;
319 char *apath = FileSystem::basepath(asset.path);
320 char *tpath = FileSystem::basepath(this->path);
322 if( *apath != '/' ) {
323 char *cp = cstrcat(2, out_path, apath);
324 delete [] apath; apath = FileSystem::basepath(cp);
327 if( *tpath != '/' ) {
328 char *cp = cstrcat(2, out_path, tpath);
329 delete [] tpath; tpath = FileSystem::basepath(cp);
333 if( strcmp(apath, tpath) ) result = 0;
339 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
342 if(test_audio && result)
344 result = (channels == asset.channels &&
345 sample_rate == asset.sample_rate &&
346 bits == asset.bits &&
347 byte_order == asset.byte_order &&
348 signed_ == asset.signed_ &&
349 header == asset.header &&
350 dither == asset.dither &&
351 !strcmp(acodec, asset.acodec));
352 if(result && format == FILE_FFMPEG)
353 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
354 ff_audio_bitrate == asset.ff_audio_bitrate;
359 if(test_video && result)
361 result = (layers == asset.layers &&
362 program == asset.program &&
363 frame_rate == asset.frame_rate &&
364 asset.interlace_autofixoption == interlace_autofixoption &&
365 asset.interlace_mode == interlace_mode &&
366 interlace_fixmethod == asset.interlace_fixmethod &&
367 width == asset.width &&
368 height == asset.height &&
369 !strcmp(vcodec, asset.vcodec) &&
370 mov_sphere == asset.mov_sphere &&
371 jpeg_sphere == asset.jpeg_sphere);
372 if(result && format == FILE_FFMPEG)
373 result = !strcmp(ff_video_options, asset.ff_video_options) &&
374 ff_video_bitrate == asset.ff_video_bitrate &&
375 ff_video_quality == asset.ff_video_quality;
381 int Asset::test_path(const char *path)
383 if(!strcasecmp(this->path, path))
389 int Asset::read(FileXML *file,
394 // Check for relative path.
397 char new_path[BCTEXTLEN];
398 char asset_directory[BCTEXTLEN];
399 char input_directory[BCTEXTLEN];
402 strcpy(new_path, path);
403 fs.set_current_dir("");
405 fs.extract_dir(asset_directory, path);
408 // Take path of XML file.
409 if(!asset_directory[0])
411 fs.extract_dir(input_directory, file->filename);
413 // Input file has a path
414 if(input_directory[0])
416 fs.join_names(path, input_directory, new_path);
424 result = file->read_tag();
427 if(file->tag.title_is("/ASSET"))
432 if(file->tag.title_is("AUDIO"))
437 if(file->tag.title_is("AUDIO_OMIT"))
442 if(file->tag.title_is("FORMAT"))
444 const char *string = file->tag.get_property("TYPE");
445 format = File::strtoformat(string);
447 file->tag.get_property("USE_HEADER", use_header);
448 file->tag.get_property("FFORMAT", fformat);
451 if(file->tag.title_is("FOLDER"))
453 const char *string = file->tag.get_property("NUMBER");
454 awindow_folder = string ? atoi(string) :
455 AWindowGUI::folder_number(file->read_text());
458 if(file->tag.title_is("VIDEO"))
463 if(file->tag.title_is("VIDEO_OMIT"))
468 if(file->tag.title_is("INDEX"))
476 //printf("Asset::read 2\n");
480 int Asset::read_audio(FileXML *file)
482 if(file->tag.title_is("AUDIO")) audio_data = 1;
483 channels = file->tag.get_property("CHANNELS", 2);
484 // This is loaded from the index file after the EDL but this
485 // should be overridable in the EDL.
486 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
487 bits = file->tag.get_property("BITS", 16);
488 byte_order = file->tag.get_property("BYTE_ORDER", 1);
489 signed_ = file->tag.get_property("SIGNED", 1);
490 header = file->tag.get_property("HEADER", 0);
491 dither = file->tag.get_property("DITHER", 0);
493 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
495 file->tag.get_property("ACODEC", acodec);
499 int Asset::read_video(FileXML *file)
501 char string[BCTEXTLEN];
503 if(file->tag.title_is("VIDEO")) video_data = 1;
504 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
505 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
506 height = file->tag.get_property("HEIGHT", height);
507 width = file->tag.get_property("WIDTH", width);
508 layers = file->tag.get_property("LAYERS", layers);
509 program = file->tag.get_property("PROGRAM", program);
510 // This is loaded from the index file after the EDL but this
511 // should be overridable in the EDL.
512 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
514 file->tag.get_property("VCODEC", vcodec);
516 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
517 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
518 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
519 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
521 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
523 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
524 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
526 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
527 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
532 int Asset::read_index(FileXML *file)
534 index_state->read_xml(file, channels);
538 // Output path is the path of the output file if name truncation is desired.
539 // It is a "" if complete names should be used.
541 int Asset::write(FileXML *file,
543 const char *output_path)
545 char new_path[BCTEXTLEN];
546 char asset_directory[BCTEXTLEN];
547 char output_directory[BCTEXTLEN];
550 // Make path relative
551 fs.extract_dir(asset_directory, path);
552 if(output_path && output_path[0])
553 fs.extract_dir(output_directory, output_path);
555 output_directory[0] = 0;
557 // Asset and EDL are in same directory. Extract just the name.
558 if(!strcmp(asset_directory, output_directory))
560 fs.extract_name(new_path, path);
564 strcpy(new_path, path);
567 file->tag.set_title("ASSET");
568 file->tag.set_property("SRC", new_path);
570 file->append_newline();
572 file->tag.set_title("FOLDER");
573 file->tag.set_property("NUMBER", awindow_folder);
575 file->tag.set_title("/FOLDER");
577 file->append_newline();
579 // Write the format information
580 file->tag.set_title("FORMAT");
582 file->tag.set_property("TYPE",
583 File::formattostr(format));
584 file->tag.set_property("USE_HEADER", use_header);
585 file->tag.set_property("FFORMAT", fformat);
588 file->tag.set_title("/FORMAT");
590 file->append_newline();
592 // Requiring data to exist caused batch render to lose settings.
593 // But the only way to know if an asset doesn't have audio or video data
594 // is to not write the block.
595 // So change the block name if the asset doesn't have the data.
598 // index goes after source
599 if(index_state->index_status == INDEX_READY && include_index)
602 file->tag.set_title("/ASSET");
604 file->append_newline();
608 int Asset::write_audio(FileXML *file)
610 // Let the reader know if the asset has the data by naming the block.
612 file->tag.set_title("AUDIO");
614 file->tag.set_title("AUDIO_OMIT");
615 // Necessary for PCM audio
616 file->tag.set_property("CHANNELS", channels);
617 file->tag.set_property("RATE", sample_rate);
618 file->tag.set_property("BITS", bits);
619 file->tag.set_property("BYTE_ORDER", byte_order);
620 file->tag.set_property("SIGNED", signed_);
621 file->tag.set_property("HEADER", header);
622 file->tag.set_property("DITHER", dither);
624 file->tag.set_property("ACODEC", acodec);
626 file->tag.set_property("AUDIO_LENGTH", audio_length);
630 // Rely on defaults operations for these.
632 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
633 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
635 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
636 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
637 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
638 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
640 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
647 file->tag.set_title("/AUDIO");
649 file->tag.set_title("/AUDIO_OMIT");
651 file->append_newline();
655 int Asset::write_video(FileXML *file)
657 char string[BCTEXTLEN];
660 file->tag.set_title("VIDEO");
662 file->tag.set_title("VIDEO_OMIT");
663 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
664 file->tag.set_property("ACTUAL_WIDTH", actual_width);
665 file->tag.set_property("HEIGHT", height);
666 file->tag.set_property("WIDTH", width);
667 file->tag.set_property("LAYERS", layers);
668 file->tag.set_property("PROGRAM", program);
669 file->tag.set_property("FRAMERATE", frame_rate);
671 file->tag.set_property("VCODEC", vcodec);
673 file->tag.set_property("VIDEO_LENGTH", video_length);
674 file->tag.set_property("MOV_SPHERE", mov_sphere);
675 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
676 file->tag.set_property("SINGLE_FRAME", single_frame);
678 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
680 ilacemode_to_xmltext(string, interlace_mode);
681 file->tag.set_property("INTERLACE_MODE", string);
683 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
684 file->tag.set_property("INTERLACE_FIXMETHOD", string);
688 file->tag.set_title("/VIDEO");
690 file->tag.set_title("/VIDEO_OMIT");
693 file->append_newline();
697 int Asset::write_index(FileXML *file)
699 index_state->write_xml(file);
704 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
707 sprintf(return_value, "%s%s", prefix, param);
709 strcpy(return_value, param);
713 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
714 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
716 void Asset::load_defaults(BC_Hash *defaults,
724 char string[BCTEXTLEN];
726 // Can't save codec here because it's specific to render, record, and effect.
727 // The codec has to be UNKNOWN for file probing to work.
731 GET_DEFAULT("PATH", path);
736 GET_DEFAULT("AUDIO_CODEC", acodec);
737 GET_DEFAULT("VIDEO_CODEC", vcodec);
742 format = GET_DEFAULT("FORMAT", format);
743 use_header = GET_DEFAULT("USE_HEADER", use_header);
744 GET_DEFAULT("FFORMAT", fformat);
749 audio_data = GET_DEFAULT("AUDIO", 1);
750 video_data = GET_DEFAULT("VIDEO", 1);
755 bits = GET_DEFAULT("BITS", 16);
756 dither = GET_DEFAULT("DITHER", 0);
757 signed_ = GET_DEFAULT("SIGNED", 1);
758 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
762 channels = GET_DEFAULT("CHANNELS", 2);
763 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
764 header = GET_DEFAULT("HEADER", 0);
765 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
769 height = GET_DEFAULT("HEIGHT", height);
770 width = GET_DEFAULT("WIDTH", width);
771 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
772 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
773 program = GET_DEFAULT("PROGRAM", program);
774 layers = GET_DEFAULT("LAYERS", layers);
775 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
776 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
777 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
780 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
781 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
783 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
784 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
785 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
786 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
788 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
789 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
790 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
791 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
792 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
793 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
795 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
796 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
797 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
798 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
799 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
801 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
803 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
804 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
806 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
807 interlace_mode = ILACE_MODE_UNDETECTED;
808 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
810 // MPEG format information
811 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
812 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
813 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
814 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
815 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
816 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
817 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
818 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
819 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
820 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
821 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
822 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
824 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
825 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
826 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
827 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
828 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
829 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
832 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
834 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
835 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
836 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
837 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
838 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
840 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
841 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
845 void Asset::save_defaults(BC_Hash *defaults,
853 char string[BCTEXTLEN];
855 UPDATE_DEFAULT("PATH", path);
862 UPDATE_DEFAULT("FORMAT", format);
863 UPDATE_DEFAULT("USE_HEADER", use_header);
864 UPDATE_DEFAULT("FFORMAT", fformat);
869 UPDATE_DEFAULT("AUDIO", audio_data);
870 UPDATE_DEFAULT("VIDEO", video_data);
875 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
876 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
878 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
879 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
881 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
882 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
883 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
884 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
886 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
887 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
888 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
889 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
890 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
892 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
893 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
894 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
895 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
896 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
897 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
901 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
903 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
904 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
906 // MPEG format information
907 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
908 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
909 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
910 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
911 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
912 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
913 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
914 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
915 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
916 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
917 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
918 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
921 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
924 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
925 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
926 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
927 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
928 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
932 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
933 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
941 UPDATE_DEFAULT("BITS", bits);
942 UPDATE_DEFAULT("DITHER", dither);
943 UPDATE_DEFAULT("SIGNED", signed_);
944 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
951 UPDATE_DEFAULT("CHANNELS", channels);
952 UPDATE_DEFAULT("RATE", sample_rate);
953 UPDATE_DEFAULT("HEADER", header);
954 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
958 UPDATE_DEFAULT("HEIGHT", height);
959 UPDATE_DEFAULT("WIDTH", width);
960 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
961 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
962 UPDATE_DEFAULT("PROGRAM", program);
963 UPDATE_DEFAULT("LAYERS", layers);
964 UPDATE_DEFAULT("FRAMERATE", frame_rate);
965 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
966 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
979 int Asset::dump(FILE *fp)
981 fprintf(fp," asset::dump\n");
982 fprintf(fp," this=%p path=%s\n", this, path);
983 fprintf(fp," index_status %d\n", index_state->index_status);
984 fprintf(fp," format %d\n", format);
985 fprintf(fp," fformat=\"%s\"\n", fformat);
986 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
987 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
988 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
989 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
990 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
991 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
992 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
993 audio_data, channels, sample_rate, bits, byte_order, signed_,
994 header, dither, acodec);
995 fprintf(fp," audio_length %jd\n", audio_length);
996 char string[BCTEXTLEN];
997 ilacemode_to_xmltext(string, interlace_mode);
998 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
999 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
1000 video_data, layers, program, frame_rate, width, height,
1001 vcodec, aspect_ratio,string);
1002 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
1003 printf(" mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
1009 int Asset::get_audio_channels()
1014 int Asset::get_sample_rate()
1019 int64_t Asset::get_audio_samples()
1021 return audio_length;
1024 int Asset::have_audio()
1029 int Asset::have_video()
1044 double Asset::get_frame_rate()
1050 int Asset::get_video_layers()
1055 int Asset::get_program()
1060 int64_t Asset::get_video_frames()
1062 return video_length;
1065 double Asset::total_length_framealigned(double fps)
1067 if (video_data && audio_data) {
1068 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1069 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1070 return MIN(aud,vid);
1074 return (double)audio_length / sample_rate;
1077 return (double)video_length / frame_rate;