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;
90 ff_audio_quality = -1;
92 ff_video_quality = -1;
96 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
97 interlace_mode = ILACE_MODE_UNDETECTED;
98 interlace_fixmethod = ILACE_FIXMETHOD_NONE;
101 ampeg_derivative = 3;
104 vorbis_min_bitrate = -1;
105 vorbis_bitrate = 128000;
106 vorbis_max_bitrate = -1;
108 theora_fix_bitrate = 1;
109 theora_bitrate = 860000;
111 theora_sharpness = 2;
112 theora_keyframe_frequency = 64;
113 theora_keyframe_force_frequency = 64;
116 vmpeg_iframe_distance = 45;
117 vmpeg_pframe_distance = 0;
118 vmpeg_progressive = 0;
120 vmpeg_bitrate = 1000000;
121 vmpeg_derivative = 1;
122 vmpeg_quantization = 15;
123 vmpeg_cmodel = BC_YUV420P;
124 vmpeg_fix_bitrate = 0;
127 vmpeg_field_order = 0;
137 tiff_compression = 0;
147 void Asset::reset_audio()
155 void Asset::reset_video()
159 actual_width = width = 0;
160 actual_height = height = 0;
163 vmpeg_cmodel = BC_YUV420P;
169 void Asset::boundaries()
171 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
172 // sample_rate & frame_rate are user defined
173 // CLAMP(sample_rate, 1, 1000000);
174 // CLAMP(frame_rate, 0.001, 1000000);
175 CLAMP(channels, 0, 16);
176 CLAMP(width, 0, 10000);
177 CLAMP(height, 0, 10000);
178 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
181 void Asset::copy_from(Asset *asset, int do_index)
183 copy_location(asset);
184 copy_format(asset, do_index);
187 void Asset::copy_location(Asset *asset)
189 strcpy(path, asset->path);
190 awindow_folder = asset->awindow_folder;
193 void Asset::copy_format(Asset *asset, int do_index)
195 if(do_index) update_index(asset);
197 audio_data = asset->audio_data;
198 format = asset->format;
199 strcpy(fformat, asset->fformat);
200 channels = asset->channels;
201 sample_rate = asset->sample_rate;
203 byte_order = asset->byte_order;
204 signed_ = asset->signed_;
205 header = asset->header;
206 dither = asset->dither;
207 mp3_bitrate = asset->mp3_bitrate;
208 use_header = asset->use_header;
209 aspect_ratio = asset->aspect_ratio;
210 interlace_autofixoption = asset->interlace_autofixoption;
211 interlace_mode = asset->interlace_mode;
212 interlace_fixmethod = asset->interlace_fixmethod;
214 video_data = asset->video_data;
215 layers = asset->layers;
216 program = asset->program;
217 frame_rate = asset->frame_rate;
218 width = asset->width;
219 height = asset->height;
220 actual_width = asset->actual_width;
221 actual_height = asset->actual_height;
222 strcpy(vcodec, asset->vcodec);
223 strcpy(acodec, asset->acodec);
225 strcpy(ff_audio_options, asset->ff_audio_options);
226 strcpy(ff_video_options, asset->ff_video_options);
227 ff_audio_bitrate = asset->ff_audio_bitrate;
228 ff_audio_quality = asset->ff_audio_quality;
229 ff_video_bitrate = asset->ff_video_bitrate;
230 ff_video_quality = asset->ff_video_quality;
232 this->audio_length = asset->audio_length;
233 this->video_length = asset->video_length;
234 this->single_frame = asset->single_frame;
236 ampeg_bitrate = asset->ampeg_bitrate;
237 ampeg_derivative = asset->ampeg_derivative;
240 vorbis_vbr = asset->vorbis_vbr;
241 vorbis_min_bitrate = asset->vorbis_min_bitrate;
242 vorbis_bitrate = asset->vorbis_bitrate;
243 vorbis_max_bitrate = asset->vorbis_max_bitrate;
246 theora_fix_bitrate = asset->theora_fix_bitrate;
247 theora_bitrate = asset->theora_bitrate;
248 theora_quality = asset->theora_quality;
249 theora_sharpness = asset->theora_sharpness;
250 theora_keyframe_frequency = asset->theora_keyframe_frequency;
251 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
254 jpeg_quality = asset->jpeg_quality;
257 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
258 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
259 vmpeg_progressive = asset->vmpeg_progressive;
260 vmpeg_denoise = asset->vmpeg_denoise;
261 vmpeg_bitrate = asset->vmpeg_bitrate;
262 vmpeg_derivative = asset->vmpeg_derivative;
263 vmpeg_quantization = asset->vmpeg_quantization;
264 vmpeg_cmodel = asset->vmpeg_cmodel;
265 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
266 vmpeg_seq_codes = asset->vmpeg_seq_codes;
267 vmpeg_preset = asset->vmpeg_preset;
268 vmpeg_field_order = asset->vmpeg_field_order;
270 ac3_bitrate = asset->ac3_bitrate;
272 png_use_alpha = asset->png_use_alpha;
273 exr_use_alpha = asset->exr_use_alpha;
274 exr_compression = asset->exr_compression;
276 tiff_cmodel = asset->tiff_cmodel;
277 tiff_compression = asset->tiff_compression;
280 mov_sphere = asset->mov_sphere;
281 jpeg_sphere = asset->jpeg_sphere;
284 int64_t Asset::get_index_offset(int channel)
286 return index_state->get_index_offset(channel);
289 int64_t Asset::get_index_size(int channel)
291 return index_state->get_index_size(channel);
295 char* Asset::get_compression_text(int audio, int video)
300 if( acodec[0] ) return acodec;
307 if( vcodec[0] ) return vcodec;
314 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
316 int result = format == asset.format ? 1 : 0;
317 if( result && strcmp(asset.path, path) ) {
318 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
319 char *sp = out_path ? strrchr(out_path,'/') : 0;
321 char *apath = FileSystem::basepath(asset.path);
322 char *tpath = FileSystem::basepath(this->path);
324 if( *apath != '/' ) {
325 char *cp = cstrcat(2, out_path, apath);
326 delete [] apath; apath = FileSystem::basepath(cp);
329 if( *tpath != '/' ) {
330 char *cp = cstrcat(2, out_path, tpath);
331 delete [] tpath; tpath = FileSystem::basepath(cp);
335 if( strcmp(apath, tpath) ) result = 0;
341 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
344 if(test_audio && result)
346 result = (channels == asset.channels &&
347 sample_rate == asset.sample_rate &&
348 bits == asset.bits &&
349 byte_order == asset.byte_order &&
350 signed_ == asset.signed_ &&
351 header == asset.header &&
352 dither == asset.dither &&
353 !strcmp(acodec, asset.acodec));
354 if(result && format == FILE_FFMPEG)
355 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
356 ff_audio_bitrate == asset.ff_audio_bitrate &&
357 ff_audio_quality == asset.ff_audio_quality;
361 if(test_video && result)
363 result = (layers == asset.layers &&
364 program == asset.program &&
365 frame_rate == asset.frame_rate &&
366 asset.interlace_autofixoption == interlace_autofixoption &&
367 asset.interlace_mode == interlace_mode &&
368 interlace_fixmethod == asset.interlace_fixmethod &&
369 width == asset.width &&
370 height == asset.height &&
371 !strcmp(vcodec, asset.vcodec) &&
372 mov_sphere == asset.mov_sphere &&
373 jpeg_sphere == asset.jpeg_sphere);
374 if(result && format == FILE_FFMPEG)
375 result = !strcmp(ff_video_options, asset.ff_video_options) &&
376 ff_video_bitrate == asset.ff_video_bitrate &&
377 ff_video_quality == asset.ff_video_quality;
383 int Asset::test_path(const char *path)
385 if(!strcasecmp(this->path, path))
391 int Asset::read(FileXML *file,
396 // Check for relative path.
399 char new_path[BCTEXTLEN];
400 char asset_directory[BCTEXTLEN];
401 char input_directory[BCTEXTLEN];
404 strcpy(new_path, path);
405 fs.set_current_dir("");
407 fs.extract_dir(asset_directory, path);
410 // Take path of XML file.
411 if(!asset_directory[0])
413 fs.extract_dir(input_directory, file->filename);
415 // Input file has a path
416 if(input_directory[0])
418 fs.join_names(path, input_directory, new_path);
426 result = file->read_tag();
429 if(file->tag.title_is("/ASSET"))
434 if(file->tag.title_is("AUDIO"))
439 if(file->tag.title_is("AUDIO_OMIT"))
444 if(file->tag.title_is("FORMAT"))
446 const char *string = file->tag.get_property("TYPE");
447 format = File::strtoformat(string);
449 file->tag.get_property("USE_HEADER", use_header);
450 file->tag.get_property("FFORMAT", fformat);
453 if(file->tag.title_is("FOLDER"))
455 const char *string = file->tag.get_property("NUMBER");
456 awindow_folder = string ? atoi(string) :
457 AWindowGUI::folder_number(file->read_text());
460 if(file->tag.title_is("VIDEO"))
465 if(file->tag.title_is("VIDEO_OMIT"))
470 if(file->tag.title_is("INDEX"))
478 //printf("Asset::read 2\n");
482 int Asset::read_audio(FileXML *file)
484 if(file->tag.title_is("AUDIO")) audio_data = 1;
485 channels = file->tag.get_property("CHANNELS", 2);
486 // This is loaded from the index file after the EDL but this
487 // should be overridable in the EDL.
488 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
489 bits = file->tag.get_property("BITS", 16);
490 byte_order = file->tag.get_property("BYTE_ORDER", 1);
491 signed_ = file->tag.get_property("SIGNED", 1);
492 header = file->tag.get_property("HEADER", 0);
493 dither = file->tag.get_property("DITHER", 0);
495 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
497 file->tag.get_property("ACODEC", acodec);
501 int Asset::read_video(FileXML *file)
503 char string[BCTEXTLEN];
505 if(file->tag.title_is("VIDEO")) video_data = 1;
506 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
507 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
508 height = file->tag.get_property("HEIGHT", height);
509 width = file->tag.get_property("WIDTH", width);
510 layers = file->tag.get_property("LAYERS", layers);
511 program = file->tag.get_property("PROGRAM", program);
512 // This is loaded from the index file after the EDL but this
513 // should be overridable in the EDL.
514 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
516 file->tag.get_property("VCODEC", vcodec);
518 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
519 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
520 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
521 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
523 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
525 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
526 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
528 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
529 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
534 int Asset::read_index(FileXML *file)
536 index_state->read_xml(file, channels);
540 // Output path is the path of the output file if name truncation is desired.
541 // It is a "" if complete names should be used.
543 int Asset::write(FileXML *file,
545 const char *output_path)
547 char new_path[BCTEXTLEN];
548 char asset_directory[BCTEXTLEN];
549 char output_directory[BCTEXTLEN];
552 // Make path relative
553 fs.extract_dir(asset_directory, path);
554 if(output_path && output_path[0])
555 fs.extract_dir(output_directory, output_path);
557 output_directory[0] = 0;
559 // Asset and EDL are in same directory. Extract just the name.
560 if(!strcmp(asset_directory, output_directory))
562 fs.extract_name(new_path, path);
566 strcpy(new_path, path);
569 file->tag.set_title("ASSET");
570 file->tag.set_property("SRC", new_path);
572 file->append_newline();
574 file->tag.set_title("FOLDER");
575 file->tag.set_property("NUMBER", awindow_folder);
577 file->tag.set_title("/FOLDER");
579 file->append_newline();
581 // Write the format information
582 file->tag.set_title("FORMAT");
584 file->tag.set_property("TYPE",
585 File::formattostr(format));
586 file->tag.set_property("USE_HEADER", use_header);
587 file->tag.set_property("FFORMAT", fformat);
590 file->tag.set_title("/FORMAT");
592 file->append_newline();
594 // Requiring data to exist caused batch render to lose settings.
595 // But the only way to know if an asset doesn't have audio or video data
596 // is to not write the block.
597 // So change the block name if the asset doesn't have the data.
600 // index goes after source
601 if(index_state->index_status == INDEX_READY && include_index)
604 file->tag.set_title("/ASSET");
606 file->append_newline();
610 int Asset::write_audio(FileXML *file)
612 // Let the reader know if the asset has the data by naming the block.
614 file->tag.set_title("AUDIO");
616 file->tag.set_title("AUDIO_OMIT");
617 // Necessary for PCM audio
618 file->tag.set_property("CHANNELS", channels);
619 file->tag.set_property("RATE", sample_rate);
620 file->tag.set_property("BITS", bits);
621 file->tag.set_property("BYTE_ORDER", byte_order);
622 file->tag.set_property("SIGNED", signed_);
623 file->tag.set_property("HEADER", header);
624 file->tag.set_property("DITHER", dither);
626 file->tag.set_property("ACODEC", acodec);
628 file->tag.set_property("AUDIO_LENGTH", audio_length);
632 // Rely on defaults operations for these.
634 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
635 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
637 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
638 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
639 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
640 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
642 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
649 file->tag.set_title("/AUDIO");
651 file->tag.set_title("/AUDIO_OMIT");
653 file->append_newline();
657 int Asset::write_video(FileXML *file)
659 char string[BCTEXTLEN];
662 file->tag.set_title("VIDEO");
664 file->tag.set_title("VIDEO_OMIT");
665 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
666 file->tag.set_property("ACTUAL_WIDTH", actual_width);
667 file->tag.set_property("HEIGHT", height);
668 file->tag.set_property("WIDTH", width);
669 file->tag.set_property("LAYERS", layers);
670 file->tag.set_property("PROGRAM", program);
671 file->tag.set_property("FRAMERATE", frame_rate);
673 file->tag.set_property("VCODEC", vcodec);
675 file->tag.set_property("VIDEO_LENGTH", video_length);
676 file->tag.set_property("MOV_SPHERE", mov_sphere);
677 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
678 file->tag.set_property("SINGLE_FRAME", single_frame);
680 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
682 ilacemode_to_xmltext(string, interlace_mode);
683 file->tag.set_property("INTERLACE_MODE", string);
685 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
686 file->tag.set_property("INTERLACE_FIXMETHOD", string);
690 file->tag.set_title("/VIDEO");
692 file->tag.set_title("/VIDEO_OMIT");
695 file->append_newline();
699 int Asset::write_index(FileXML *file)
701 index_state->write_xml(file);
706 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
709 sprintf(return_value, "%s%s", prefix, param);
711 strcpy(return_value, param);
715 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
716 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
718 void Asset::load_defaults(BC_Hash *defaults,
726 char string[BCTEXTLEN];
728 // Can't save codec here because it's specific to render, record, and effect.
729 // The codec has to be UNKNOWN for file probing to work.
733 GET_DEFAULT("PATH", path);
738 GET_DEFAULT("AUDIO_CODEC", acodec);
739 GET_DEFAULT("VIDEO_CODEC", vcodec);
744 format = GET_DEFAULT("FORMAT", format);
745 use_header = GET_DEFAULT("USE_HEADER", use_header);
746 GET_DEFAULT("FFORMAT", fformat);
751 audio_data = GET_DEFAULT("AUDIO", 1);
752 video_data = GET_DEFAULT("VIDEO", 1);
757 bits = GET_DEFAULT("BITS", 16);
758 dither = GET_DEFAULT("DITHER", 0);
759 signed_ = GET_DEFAULT("SIGNED", 1);
760 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
764 channels = GET_DEFAULT("CHANNELS", 2);
765 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
766 header = GET_DEFAULT("HEADER", 0);
767 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
771 height = GET_DEFAULT("HEIGHT", height);
772 width = GET_DEFAULT("WIDTH", width);
773 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
774 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
775 program = GET_DEFAULT("PROGRAM", program);
776 layers = GET_DEFAULT("LAYERS", layers);
777 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
778 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
779 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
782 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
783 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
785 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
786 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
787 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
788 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
790 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
791 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
792 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
793 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
794 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
795 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
797 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
798 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
799 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
800 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
801 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
802 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
804 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
806 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
807 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
809 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
810 interlace_mode = ILACE_MODE_UNDETECTED;
811 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
813 // MPEG format information
814 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
815 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
816 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
817 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
818 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
819 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
820 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
821 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
822 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
823 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
824 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
825 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
827 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
828 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
829 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
830 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
831 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
832 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
835 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
837 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
838 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
839 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
840 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
841 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
843 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
844 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
848 void Asset::save_defaults(BC_Hash *defaults,
856 char string[BCTEXTLEN];
858 UPDATE_DEFAULT("PATH", path);
865 UPDATE_DEFAULT("FORMAT", format);
866 UPDATE_DEFAULT("USE_HEADER", use_header);
867 UPDATE_DEFAULT("FFORMAT", fformat);
872 UPDATE_DEFAULT("AUDIO", audio_data);
873 UPDATE_DEFAULT("VIDEO", video_data);
878 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
879 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
881 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
882 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
884 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
885 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
886 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
887 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
889 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
890 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
891 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
892 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
893 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
894 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
896 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
897 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
898 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
899 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
900 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
901 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
905 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
907 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
908 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
910 // MPEG format information
911 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
912 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
913 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
914 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
915 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
916 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
917 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
918 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
919 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
920 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
921 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
922 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
925 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
928 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
929 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
930 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
931 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
932 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
936 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
937 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
945 UPDATE_DEFAULT("BITS", bits);
946 UPDATE_DEFAULT("DITHER", dither);
947 UPDATE_DEFAULT("SIGNED", signed_);
948 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
955 UPDATE_DEFAULT("CHANNELS", channels);
956 UPDATE_DEFAULT("RATE", sample_rate);
957 UPDATE_DEFAULT("HEADER", header);
958 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
962 UPDATE_DEFAULT("HEIGHT", height);
963 UPDATE_DEFAULT("WIDTH", width);
964 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
965 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
966 UPDATE_DEFAULT("PROGRAM", program);
967 UPDATE_DEFAULT("LAYERS", layers);
968 UPDATE_DEFAULT("FRAMERATE", frame_rate);
969 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
970 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
983 int Asset::dump(FILE *fp)
985 fprintf(fp," asset::dump\n");
986 fprintf(fp," this=%p path=%s\n", this, path);
987 fprintf(fp," index_status %d\n", index_state->index_status);
988 fprintf(fp," format %d\n", format);
989 fprintf(fp," fformat=\"%s\"\n", fformat);
990 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
991 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
992 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
993 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
994 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
995 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
996 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
997 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
998 audio_data, channels, sample_rate, bits, byte_order, signed_,
999 header, dither, acodec);
1000 fprintf(fp," audio_length %jd\n", audio_length);
1001 char string[BCTEXTLEN];
1002 ilacemode_to_xmltext(string, interlace_mode);
1003 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1004 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
1005 video_data, layers, program, frame_rate, width, height,
1006 vcodec, aspect_ratio,string);
1007 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
1008 printf(" mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
1014 int Asset::get_audio_channels()
1019 int Asset::get_sample_rate()
1024 int64_t Asset::get_audio_samples()
1026 return audio_length;
1029 int Asset::have_audio()
1034 int Asset::have_video()
1049 double Asset::get_frame_rate()
1055 int Asset::get_video_layers()
1060 int Asset::get_program()
1065 int64_t Asset::get_video_frames()
1067 return video_length;
1070 double Asset::total_length_framealigned(double fps)
1072 if (video_data && audio_data) {
1073 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1074 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1075 return MIN(aud,vid);
1079 return (double)audio_length / sample_rate;
1082 return (double)video_length / frame_rate;