9 #include "filesystem.h"
11 #include "quicktime.h"
12 #include "interlacemodes.h"
24 Asset::Asset(Asset &asset)
30 Asset::Asset(const char *path)
33 strcpy(this->path, path);
36 Asset::Asset(const int plugin_type, const char *plugin_title)
43 delete [] index_offsets;
44 delete [] index_sizes;
45 // Don't delete index buffer since it is shared with the index thread.
49 int Asset::init_values()
52 strcpy(folder, MEDIA_FOLDER);
54 // Has to be unknown for file probing to succeed
55 format = FILE_UNKNOWN;
72 strcpy(vcodec, QUICKTIME_YUV2);
73 strcpy(acodec, QUICKTIME_TWOS);
76 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
77 interlace_mode = BC_ILACE_MODE_UNDETECTED;
78 interlace_fixmethod = BC_ILACE_FIXMETHOD_NONE;
84 vorbis_min_bitrate = -1;
85 vorbis_bitrate = 128000;
86 vorbis_max_bitrate = -1;
88 theora_fix_bitrate = 1;
89 theora_bitrate = 860000;
92 theora_keyframe_frequency = 64;
93 theora_keyframe_force_frequency = 64;
98 mp4a_bitrate = 256000;
104 vmpeg_iframe_distance = 45;
105 vmpeg_pframe_distance = 0;
106 vmpeg_progressive = 0;
108 vmpeg_bitrate = 1000000;
109 vmpeg_derivative = 1;
110 vmpeg_quantization = 15;
112 vmpeg_fix_bitrate = 0;
115 vmpeg_field_order = 0;
117 // Divx parameters. BC_Hash from encore2
118 divx_bitrate = 2000000;
120 divx_rc_reaction_ratio = 45;
121 divx_rc_reaction_period = 10;
122 divx_max_key_interval = 250;
123 divx_max_quantizer = 31;
124 divx_min_quantizer = 1;
127 divx_fix_bitrate = 1;
128 divx_use_deblocking = 1;
130 h264_bitrate = 2000000;
132 h264_fix_bitrate = 0;
134 ms_bitrate = 1000000;
135 ms_bitrate_tolerance = 500000;
136 ms_quantization = 10;
148 tiff_compression = 0;
164 int Asset::reset_index()
166 index_status = INDEX_NOTTESTED;
167 index_start = old_index_end = index_end = 0;
176 int Asset::reset_timecode()
178 strcpy(reel_name, "cin0000");
187 void Asset::copy_from(const Asset &asset, int do_index)
189 copy_location(asset);
190 copy_format(asset, do_index);
193 void Asset::copy_location(const Asset &asset)
195 strcpy(this->path, asset.path);
196 strcpy(this->folder, asset.folder);
199 void Asset::copy_format(const Asset &asset, int do_index)
201 if(do_index) update_index(asset);
203 audio_data = asset.audio_data;
204 format = asset.format;
205 channels = asset.channels;
206 sample_rate = asset.sample_rate;
208 byte_order = asset.byte_order;
209 signed_ = asset.signed_;
210 header = asset.header;
211 dither = asset.dither;
212 mp3_bitrate = asset.mp3_bitrate;
213 mp4a_bitrate = asset.mp4a_bitrate;
214 mp4a_quantqual = asset.mp4a_quantqual;
215 use_header = asset.use_header;
216 aspect_ratio = asset.aspect_ratio;
217 interlace_autofixoption = asset.interlace_autofixoption;
218 interlace_mode = asset.interlace_mode;
219 interlace_fixmethod = asset.interlace_fixmethod;
221 video_data = asset.video_data;
222 layers = asset.layers;
223 frame_rate = asset.frame_rate;
225 height = asset.height;
226 strcpy(vcodec, asset.vcodec);
227 strcpy(acodec, asset.acodec);
229 this->audio_length = asset.audio_length;
230 this->video_length = asset.video_length;
233 ampeg_bitrate = asset.ampeg_bitrate;
234 ampeg_derivative = asset.ampeg_derivative;
237 vorbis_vbr = asset.vorbis_vbr;
238 vorbis_min_bitrate = asset.vorbis_min_bitrate;
239 vorbis_bitrate = asset.vorbis_bitrate;
240 vorbis_max_bitrate = asset.vorbis_max_bitrate;
243 theora_fix_bitrate = asset.theora_fix_bitrate;
244 theora_bitrate = asset.theora_bitrate;
245 theora_quality = asset.theora_quality;
246 theora_sharpness = asset.theora_sharpness;
247 theora_keyframe_frequency = asset.theora_keyframe_frequency;
248 theora_keyframe_force_frequency = asset.theora_keyframe_frequency;
251 jpeg_quality = asset.jpeg_quality;
254 vmpeg_iframe_distance = asset.vmpeg_iframe_distance;
255 vmpeg_pframe_distance = asset.vmpeg_pframe_distance;
256 vmpeg_progressive = asset.vmpeg_progressive;
257 vmpeg_denoise = asset.vmpeg_denoise;
258 vmpeg_bitrate = asset.vmpeg_bitrate;
259 vmpeg_derivative = asset.vmpeg_derivative;
260 vmpeg_quantization = asset.vmpeg_quantization;
261 vmpeg_cmodel = asset.vmpeg_cmodel;
262 vmpeg_fix_bitrate = asset.vmpeg_fix_bitrate;
263 vmpeg_seq_codes = asset.vmpeg_seq_codes;
264 vmpeg_preset = asset.vmpeg_preset;
265 vmpeg_field_order = asset.vmpeg_field_order;
268 divx_bitrate = asset.divx_bitrate;
269 divx_rc_period = asset.divx_rc_period;
270 divx_rc_reaction_ratio = asset.divx_rc_reaction_ratio;
271 divx_rc_reaction_period = asset.divx_rc_reaction_period;
272 divx_max_key_interval = asset.divx_max_key_interval;
273 divx_max_quantizer = asset.divx_max_quantizer;
274 divx_min_quantizer = asset.divx_min_quantizer;
275 divx_quantizer = asset.divx_quantizer;
276 divx_quality = asset.divx_quality;
277 divx_fix_bitrate = asset.divx_fix_bitrate;
278 divx_use_deblocking = asset.divx_use_deblocking;
280 h264_bitrate = asset.h264_bitrate;
281 h264_quantizer = asset.h264_quantizer;
282 h264_fix_bitrate = asset.h264_fix_bitrate;
285 ms_bitrate = asset.ms_bitrate;
286 ms_bitrate_tolerance = asset.ms_bitrate_tolerance;
287 ms_interlaced = asset.ms_interlaced;
288 ms_quantization = asset.ms_quantization;
289 ms_gop_size = asset.ms_gop_size;
290 ms_fix_bitrate = asset.ms_fix_bitrate;
293 ac3_bitrate = asset.ac3_bitrate;
295 png_use_alpha = asset.png_use_alpha;
296 exr_use_alpha = asset.exr_use_alpha;
297 exr_compression = asset.exr_compression;
299 tiff_cmodel = asset.tiff_cmodel;
300 tiff_compression = asset.tiff_compression;
302 strcpy(pipe, asset.pipe);
303 use_pipe = asset.use_pipe;
305 strcpy(reel_name, asset.reel_name);
306 reel_number = asset.reel_number;
307 tcstart = asset.tcstart;
309 tcformat = asset.tcformat;
312 int64_t Asset::get_index_offset(int channel)
314 if(channel < channels && index_offsets)
315 return index_offsets[channel];
320 int64_t Asset::get_index_size(int channel)
322 if(channel < channels && index_sizes)
323 return index_sizes[channel];
329 char* Asset::get_compression_text(int audio, int video)
338 return quicktime_acodec_title(acodec);
352 return quicktime_vcodec_title(vcodec);
361 Asset& Asset::operator=(const Asset &asset)
363 copy_location(asset);
364 copy_format(asset, 1);
369 int Asset::equivalent(const Asset &asset,
373 int result = (!strcmp(asset.path, path) &&
374 format == asset.format);
376 if(test_audio && result)
378 result = (channels == asset.channels &&
379 sample_rate == asset.sample_rate &&
380 bits == asset.bits &&
381 byte_order == asset.byte_order &&
382 signed_ == asset.signed_ &&
383 header == asset.header &&
384 dither == asset.dither &&
385 !strcmp(acodec, asset.acodec));
389 if(test_video && result)
391 result = (layers == asset.layers &&
392 frame_rate == asset.frame_rate &&
393 asset.interlace_autofixoption == interlace_autofixoption &&
394 asset.interlace_mode == interlace_mode &&
395 interlace_fixmethod == asset.interlace_fixmethod &&
396 width == asset.width &&
397 height == asset.height &&
398 !strcmp(vcodec, asset.vcodec) &&
399 strcmp(reel_name, asset.reel_name) == 0 &&
400 reel_number == asset.reel_number &&
401 tcstart == asset.tcstart &&
402 tcend == asset.tcend &&
403 tcformat == asset.tcformat);
409 int Asset::operator==(const Asset &asset)
412 return equivalent(asset,
417 int Asset::operator!=(const Asset &asset)
419 return !(*this == asset);
422 int Asset::test_path(const char *path)
424 if(!strcasecmp(this->path, path))
430 int Asset::test_plugin_title(const char *path)
434 int Asset::read(FileXML *file,
439 // Check for relative path.
442 char new_path[BCTEXTLEN];
443 char asset_directory[BCTEXTLEN];
444 char input_directory[BCTEXTLEN];
447 strcpy(new_path, path);
448 fs.set_current_dir("");
450 fs.extract_dir(asset_directory, path);
453 // Take path of XML file.
454 if(!asset_directory[0])
456 fs.extract_dir(input_directory, file->filename);
458 // Input file has a path
459 if(input_directory[0])
461 fs.join_names(path, input_directory, new_path);
469 result = file->read_tag();
472 if(file->tag.title_is("/ASSET"))
477 if(file->tag.title_is("AUDIO"))
482 if(file->tag.title_is("AUDIO_OMIT"))
487 if(file->tag.title_is("FORMAT"))
489 char *string = file->tag.get_property("TYPE");
490 format = File::strtoformat(string);
492 file->tag.get_property("USE_HEADER", use_header);
495 if(file->tag.title_is("FOLDER"))
497 strcpy(folder, file->read_text());
500 if(file->tag.title_is("VIDEO"))
505 if(file->tag.title_is("VIDEO_OMIT"))
510 if(file->tag.title_is("INDEX"))
517 //printf("Asset::read 2\n");
521 int Asset::read_audio(FileXML *file)
523 if(file->tag.title_is("AUDIO")) audio_data = 1;
524 channels = file->tag.get_property("CHANNELS", 2);
525 // This is loaded from the index file after the EDL but this
526 // should be overridable in the EDL.
527 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
528 bits = file->tag.get_property("BITS", 16);
529 byte_order = file->tag.get_property("BYTE_ORDER", 1);
530 signed_ = file->tag.get_property("SIGNED", 1);
531 header = file->tag.get_property("HEADER", 0);
532 dither = file->tag.get_property("DITHER", 0);
534 audio_length = file->tag.get_property("AUDIO_LENGTH", 0);
536 file->tag.get_property("ACODEC", acodec);
540 // ampeg_bitrate = file->tag.get_property("AMPEG_BITRATE", ampeg_bitrate);
541 // ampeg_derivative = file->tag.get_property("AMPEG_DERIVATIVE", ampeg_derivative);
543 // vorbis_vbr = file->tag.get_property("VORBIS_VBR", vorbis_vbr);
544 // vorbis_min_bitrate = file->tag.get_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
545 // vorbis_bitrate = file->tag.get_property("VORBIS_BITRATE", vorbis_bitrate);
546 // vorbis_max_bitrate = file->tag.get_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
548 // mp3_bitrate = file->tag.get_property("MP3_BITRATE", mp3_bitrate);
553 tcend = audio_length;
560 int Asset::read_video(FileXML *file)
562 char string[BCTEXTLEN];
564 if(file->tag.title_is("VIDEO")) video_data = 1;
565 height = file->tag.get_property("HEIGHT", height);
566 width = file->tag.get_property("WIDTH", width);
567 layers = file->tag.get_property("LAYERS", layers);
568 // This is loaded from the index file after the EDL but this
569 // should be overridable in the EDL.
570 if(!frame_rate) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
572 file->tag.get_property("VCODEC", vcodec);
574 video_length = file->tag.get_property("VIDEO_LENGTH", 0);
576 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
578 ilacemode_to_xmltext(string, BC_ILACE_MODE_NOTINTERLACED);
579 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), BC_ILACE_MODE_NOTINTERLACED);
581 ilacefixmethod_to_xmltext(string, BC_ILACE_FIXMETHOD_NONE);
582 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), BC_ILACE_FIXMETHOD_NONE);
584 file->tag.get_property("REEL_NAME", reel_name);
585 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
586 tcstart = file->tag.get_property("TCSTART", tcstart);
587 tcend = file->tag.get_property("TCEND", tcend);
588 tcformat = file->tag.get_property("TCFORMAT", tcformat);
593 int Asset::read_index(FileXML *file)
595 delete [] index_offsets;
596 index_offsets = new int64_t[channels];
597 delete [] index_sizes;
598 index_sizes = new int64_t[channels];
599 for(int i = 0; i < channels; i++)
601 index_offsets[i] = 0;
605 int current_offset = 0;
606 int current_size = 0;
609 index_zoom = file->tag.get_property("ZOOM", 1);
610 index_bytes = file->tag.get_property("BYTES", (int64_t)0);
614 result = file->read_tag();
617 if(file->tag.title_is("/INDEX"))
622 if(file->tag.title_is("OFFSET"))
624 if(current_offset < channels)
626 index_offsets[current_offset++] = file->tag.get_property("FLOAT", 0);
627 //printf("Asset::read_index %d %d\n", current_offset - 1, index_offsets[current_offset - 1]);
631 if(file->tag.title_is("SIZE"))
633 if(current_size < channels)
635 index_sizes[current_size++] = file->tag.get_property("FLOAT", 0);
643 int Asset::write_index(char *path, int data_bytes)
646 if(!(file = fopen(path, "wb")))
648 // failed to create it
649 printf(_("Asset::write_index Couldn't write index file %s to disk.\n"), path);
654 // Pad index start position
655 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
657 index_status = INDEX_READY;
658 // Write encoding information
662 xml.write_to_file(file);
663 index_start = ftell(file);
664 fseek(file, 0, SEEK_SET);
666 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
667 fseek(file, index_start, SEEK_SET);
677 // Force reread of header
678 index_status = INDEX_NOTTESTED;
679 // index_status = INDEX_READY;
680 index_end = audio_length;
685 // Output path is the path of the output file if name truncation is desired.
686 // It is a "" if complete names should be used.
688 int Asset::write(FileXML *file,
692 char new_path[BCTEXTLEN];
693 char asset_directory[BCTEXTLEN];
694 char output_directory[BCTEXTLEN];
697 // Make path relative
698 fs.extract_dir(asset_directory, path);
699 if(output_path && output_path[0])
700 fs.extract_dir(output_directory, output_path);
702 output_directory[0] = 0;
704 // Asset and EDL are in same directory. Extract just the name.
705 if(!strcmp(asset_directory, output_directory))
707 fs.extract_name(new_path, path);
711 strcpy(new_path, path);
714 file->tag.set_title("ASSET");
715 file->tag.set_property("SRC", new_path);
717 file->append_newline();
719 file->tag.set_title("FOLDER");
721 file->append_text(folder);
722 file->tag.set_title("/FOLDER");
724 file->append_newline();
726 // Write the format information
727 file->tag.set_title("FORMAT");
729 file->tag.set_property("TYPE",
730 File::formattostr(format));
731 file->tag.set_property("USE_HEADER", use_header);
734 file->tag.set_title("/FORMAT");
736 file->append_newline();
738 // Requiring data to exist caused batch render to lose settings.
739 // But the only way to know if an asset doesn't have audio or video data
740 // is to not write the block.
741 // So change the block name if the asset doesn't have the data.
742 /* if(audio_data) */ write_audio(file);
743 /* if(video_data) */ write_video(file);
744 if(index_status == 0 && include_index) write_index(file); // index goes after source
746 file->tag.set_title("/ASSET");
748 file->append_newline();
752 int Asset::write_audio(FileXML *file)
754 // Let the reader know if the asset has the data by naming the block.
756 file->tag.set_title("AUDIO");
758 file->tag.set_title("AUDIO_OMIT");
759 // Necessary for PCM audio
760 file->tag.set_property("CHANNELS", channels);
761 file->tag.set_property("RATE", sample_rate);
762 file->tag.set_property("BITS", bits);
763 file->tag.set_property("BYTE_ORDER", byte_order);
764 file->tag.set_property("SIGNED", signed_);
765 file->tag.set_property("HEADER", header);
766 file->tag.set_property("DITHER", dither);
768 file->tag.set_property("ACODEC", acodec);
770 file->tag.set_property("AUDIO_LENGTH", audio_length);
774 // Rely on defaults operations for these.
776 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
777 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
779 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
780 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
781 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
782 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
784 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
791 file->tag.set_title("/AUDIO");
793 file->tag.set_title("/AUDIO_OMIT");
795 file->append_newline();
799 int Asset::write_video(FileXML *file)
801 char string[BCTEXTLEN];
804 file->tag.set_title("VIDEO");
806 file->tag.set_title("VIDEO_OMIT");
807 file->tag.set_property("HEIGHT", height);
808 file->tag.set_property("WIDTH", width);
809 file->tag.set_property("LAYERS", layers);
810 file->tag.set_property("FRAMERATE", frame_rate);
812 file->tag.set_property("VCODEC", vcodec);
814 file->tag.set_property("VIDEO_LENGTH", video_length);
816 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
818 ilacemode_to_xmltext(string, interlace_mode);
819 file->tag.set_property("INTERLACE_MODE", string);
821 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
822 file->tag.set_property("INTERLACE_FIXMETHOD", string);
825 file->tag.set_property("REEL_NAME", reel_name);
826 file->tag.set_property("REEL_NUMBER", reel_number);
827 file->tag.set_property("TCSTART", tcstart);
828 file->tag.set_property("TCEND", tcend);
829 file->tag.set_property("TCFORMAT", tcformat);
833 file->tag.set_title("/VIDEO");
835 file->tag.set_title("/VIDEO_OMIT");
838 file->append_newline();
842 int Asset::write_index(FileXML *file)
844 file->tag.set_title("INDEX");
845 file->tag.set_property("ZOOM", index_zoom);
846 file->tag.set_property("BYTES", index_bytes);
848 file->append_newline();
852 for(int i = 0; i < channels; i++)
854 file->tag.set_title("OFFSET");
855 file->tag.set_property("FLOAT", index_offsets[i]);
857 file->tag.set_title("/OFFSET");
859 file->tag.set_title("SIZE");
860 file->tag.set_property("FLOAT", index_sizes[i]);
862 file->tag.set_title("/SIZE");
867 file->append_newline();
868 file->tag.set_title("/INDEX");
870 file->append_newline();
877 char* Asset::construct_param(char *param, char *prefix, char *return_value)
880 sprintf(return_value, "%s%s", prefix, param);
882 strcpy(return_value, param);
886 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
887 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
889 void Asset::load_defaults(BC_Hash *defaults,
897 char string[BCTEXTLEN];
899 // Can't save codec here because it's specific to render, record, and effect.
900 // The codec has to be UNKNOWN for file probing to work.
904 GET_DEFAULT("PATH", path);
909 GET_DEFAULT("AUDIO_CODEC", acodec);
910 GET_DEFAULT("VIDEO_CODEC", vcodec);
915 format = GET_DEFAULT("FORMAT", format);
920 audio_data = GET_DEFAULT("AUDIO", 1);
921 video_data = GET_DEFAULT("VIDEO", 1);
926 bits = GET_DEFAULT("BITS", 16);
927 dither = GET_DEFAULT("DITHER", 0);
928 signed_ = GET_DEFAULT("SIGNED", 1);
929 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
932 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
933 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
935 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
936 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
937 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
938 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
940 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
941 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
942 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
943 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
944 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
945 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
949 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
950 mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
951 mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
953 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
954 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
956 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
957 interlace_mode = BC_ILACE_MODE_UNDETECTED;
958 interlace_fixmethod = BC_ILACE_FIXMETHOD_UPONE;
960 // MPEG format information
961 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
962 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
963 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
964 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
965 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
966 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
967 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
968 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
969 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
970 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
971 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
972 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
974 h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
975 h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
976 h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
979 divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
980 divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
981 divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
982 divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
983 divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
984 divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
985 divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
986 divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
987 divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
988 divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
989 divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
991 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
992 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
993 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
994 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
995 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
996 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
999 ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
1000 ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
1001 ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
1002 ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
1003 ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
1004 ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
1006 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
1008 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1009 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1010 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
1011 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1012 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1014 // this extra 'FORMAT_' prefix is just here for legacy reasons
1015 use_pipe = GET_DEFAULT("FORMAT_YUV_USE_PIPE", use_pipe);
1016 GET_DEFAULT("FORMAT_YUV_PIPE", pipe);
1018 GET_DEFAULT("REEL_NAME", reel_name);
1019 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
1020 tcstart = GET_DEFAULT("TCSTART", tcstart);
1021 tcend = GET_DEFAULT("TCEND", tcend);
1022 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
1025 void Asset::save_defaults(BC_Hash *defaults,
1033 char string[BCTEXTLEN];
1035 UPDATE_DEFAULT("PATH", path);
1039 UPDATE_DEFAULT("FORMAT", format);
1044 UPDATE_DEFAULT("AUDIO", audio_data);
1045 UPDATE_DEFAULT("VIDEO", video_data);
1050 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
1051 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
1053 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
1054 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
1056 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
1057 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
1058 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
1059 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
1062 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
1063 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
1064 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
1065 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
1066 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
1067 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
1071 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
1072 UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
1073 UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
1079 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
1080 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
1082 // MPEG format information
1083 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
1084 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
1085 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
1086 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
1087 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
1088 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
1089 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
1090 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
1091 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
1092 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
1093 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
1094 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
1096 UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
1097 UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
1098 UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
1100 UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
1101 UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
1102 UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
1103 UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
1104 UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
1105 UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
1106 UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
1107 UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
1108 UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
1109 UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
1110 UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
1113 UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
1114 UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
1115 UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
1116 UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
1117 UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
1118 UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
1120 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
1123 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1124 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1125 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
1126 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1127 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1129 UPDATE_DEFAULT("FORMAT_YUV_USE_PIPE", use_pipe);
1130 UPDATE_DEFAULT("FORMAT_YUV_PIPE", pipe);
1135 UPDATE_DEFAULT("BITS", bits);
1136 UPDATE_DEFAULT("DITHER", dither);
1137 UPDATE_DEFAULT("SIGNED", signed_);
1138 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
1141 UPDATE_DEFAULT("REEL_NAME", reel_name);
1142 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
1143 UPDATE_DEFAULT("TCSTART", tcstart);
1144 UPDATE_DEFAULT("TCEND", tcend);
1145 UPDATE_DEFAULT("TCFORMAT", tcformat);
1156 int Asset::update_path(char *new_path)
1158 strcpy(path, new_path);
1162 double Asset::total_length_framealigned(double fps)
1164 if (video_data && audio_data) {
1165 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1166 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1167 return MIN(aud,vid);
1171 return (double)audio_length / sample_rate;
1174 return (double)video_length / frame_rate;
1177 void Asset::update_index(const Asset &asset)
1179 //printf("Asset::update_index 1 %d\n", index_status);
1180 index_status = asset.index_status;
1181 index_zoom = asset.index_zoom; // zoom factor of index data
1182 index_start = asset.index_start; // byte start of index data in the index file
1183 index_bytes = asset.index_bytes; // Total bytes in source file for comparison before rebuilding the index
1184 index_end = asset.index_end;
1185 old_index_end = asset.old_index_end; // values for index build
1187 delete [] index_offsets;
1188 delete [] index_sizes;
1192 if(asset.index_offsets)
1194 index_offsets = new int64_t[asset.channels];
1195 index_sizes = new int64_t[asset.channels];
1198 for(i = 0; i < asset.channels; i++)
1200 // offsets of channels in index file in floats
1201 index_offsets[i] = asset.index_offsets[i];
1202 index_sizes[i] = asset.index_sizes[i];
1205 index_buffer = asset.index_buffer; // pointer
1208 int Asset::set_timecode(char *tc, int format, int end)
1212 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1213 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1214 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1216 // This needs to be modified to handle drop-frame
1219 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1221 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1229 printf(" asset::dump\n");
1230 printf(" %p %s\n", this, path);
1231 printf(" index_status %d\n", index_status);
1232 printf(" format %d\n", format);
1233 printf(" audio_data %d channels %d samplerate %d bits %d byte_order %d signed %d header %d dither %d acodec %c%c%c%c\n",
1234 audio_data, channels, sample_rate, bits, byte_order, signed_, header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1235 printf(" audio_length %lld\n", audio_length);
1236 char string[BCTEXTLEN];
1237 ilacemode_to_xmltext(string, interlace_mode);
1238 printf(" video_data %d layers %d framerate %f width %d height %d vcodec %c%c%c%c aspect_ratio %f interlace_mode %s\n",
1239 video_data, layers, frame_rate, width, height, vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio, string);
1240 printf(" video_length %lld \n", video_length);
1241 printf(" reel_name %s reel_number %i tcstart %d tcend %d tcf %d\n",
1242 reel_name, reel_number, tcstart, tcend, tcformat);
1251 // c-file-style: "linux"