9 #include "filesystem.h"
11 #include "quicktime.h"
12 #include "interlacemodes.h"
20 : ListItem<Asset>(), GarbageObject("Asset")
25 Asset::Asset(Asset &asset)
26 : ListItem<Asset>(), GarbageObject("Asset")
32 Asset::Asset(const char *path)
33 : ListItem<Asset>(), GarbageObject("Asset")
36 strcpy(this->path, path);
39 Asset::Asset(const int plugin_type, const char *plugin_title)
40 : ListItem<Asset>(), GarbageObject("Asset")
47 delete [] index_offsets;
48 delete [] index_sizes;
49 // Don't delete index buffer since it is shared with the index thread.
53 int Asset::init_values()
56 strcpy(folder, MEDIA_FOLDER);
58 // Has to be unknown for file probing to succeed
59 format = FILE_UNKNOWN;
76 strcpy(vcodec, QUICKTIME_YUV2);
77 strcpy(acodec, QUICKTIME_TWOS);
80 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
81 interlace_mode = BC_ILACE_MODE_UNDETECTED;
82 interlace_fixmethod = BC_ILACE_FIXMETHOD_NONE;
88 vorbis_min_bitrate = -1;
89 vorbis_bitrate = 128000;
90 vorbis_max_bitrate = -1;
92 theora_fix_bitrate = 1;
93 theora_bitrate = 860000;
96 theora_keyframe_frequency = 64;
97 theora_keyframe_force_frequency = 64;
102 mp4a_bitrate = 256000;
103 mp4a_quantqual = 100;
108 vmpeg_iframe_distance = 45;
109 vmpeg_pframe_distance = 0;
110 vmpeg_progressive = 0;
112 vmpeg_bitrate = 1000000;
113 vmpeg_derivative = 1;
114 vmpeg_quantization = 15;
116 vmpeg_fix_bitrate = 0;
119 vmpeg_field_order = 0;
121 // Divx parameters. BC_Hash from encore2
122 divx_bitrate = 2000000;
124 divx_rc_reaction_ratio = 45;
125 divx_rc_reaction_period = 10;
126 divx_max_key_interval = 250;
127 divx_max_quantizer = 31;
128 divx_min_quantizer = 1;
131 divx_fix_bitrate = 1;
132 divx_use_deblocking = 1;
134 h264_bitrate = 2000000;
136 h264_fix_bitrate = 0;
138 ms_bitrate = 1000000;
139 ms_bitrate_tolerance = 500000;
140 ms_quantization = 10;
152 tiff_compression = 0;
168 int Asset::reset_index()
170 index_status = INDEX_NOTTESTED;
171 index_start = old_index_end = index_end = 0;
180 int Asset::reset_timecode()
182 strcpy(reel_name, "cin0000");
191 void Asset::copy_from(Asset *asset, int do_index)
193 copy_location(asset);
194 copy_format(asset, do_index);
197 void Asset::copy_location(Asset *asset)
199 strcpy(this->path, asset->path);
200 strcpy(this->folder, asset->folder);
203 void Asset::copy_format(Asset *asset, int do_index)
205 if(do_index) update_index(asset);
207 audio_data = asset->audio_data;
208 format = asset->format;
209 channels = asset->channels;
210 sample_rate = asset->sample_rate;
212 byte_order = asset->byte_order;
213 signed_ = asset->signed_;
214 header = asset->header;
215 dither = asset->dither;
216 mp3_bitrate = asset->mp3_bitrate;
217 mp4a_bitrate = asset->mp4a_bitrate;
218 mp4a_quantqual = asset->mp4a_quantqual;
219 use_header = asset->use_header;
220 aspect_ratio = asset->aspect_ratio;
221 interlace_autofixoption = asset->interlace_autofixoption;
222 interlace_mode = asset->interlace_mode;
223 interlace_fixmethod = asset->interlace_fixmethod;
225 video_data = asset->video_data;
226 layers = asset->layers;
227 frame_rate = asset->frame_rate;
228 width = asset->width;
229 height = asset->height;
230 strcpy(vcodec, asset->vcodec);
231 strcpy(acodec, asset->acodec);
233 this->audio_length = asset->audio_length;
234 this->video_length = asset->video_length;
237 ampeg_bitrate = asset->ampeg_bitrate;
238 ampeg_derivative = asset->ampeg_derivative;
241 vorbis_vbr = asset->vorbis_vbr;
242 vorbis_min_bitrate = asset->vorbis_min_bitrate;
243 vorbis_bitrate = asset->vorbis_bitrate;
244 vorbis_max_bitrate = asset->vorbis_max_bitrate;
247 theora_fix_bitrate = asset->theora_fix_bitrate;
248 theora_bitrate = asset->theora_bitrate;
249 theora_quality = asset->theora_quality;
250 theora_sharpness = asset->theora_sharpness;
251 theora_keyframe_frequency = asset->theora_keyframe_frequency;
252 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
255 jpeg_quality = asset->jpeg_quality;
258 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
259 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
260 vmpeg_progressive = asset->vmpeg_progressive;
261 vmpeg_denoise = asset->vmpeg_denoise;
262 vmpeg_bitrate = asset->vmpeg_bitrate;
263 vmpeg_derivative = asset->vmpeg_derivative;
264 vmpeg_quantization = asset->vmpeg_quantization;
265 vmpeg_cmodel = asset->vmpeg_cmodel;
266 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
267 vmpeg_seq_codes = asset->vmpeg_seq_codes;
268 vmpeg_preset = asset->vmpeg_preset;
269 vmpeg_field_order = asset->vmpeg_field_order;
272 divx_bitrate = asset->divx_bitrate;
273 divx_rc_period = asset->divx_rc_period;
274 divx_rc_reaction_ratio = asset->divx_rc_reaction_ratio;
275 divx_rc_reaction_period = asset->divx_rc_reaction_period;
276 divx_max_key_interval = asset->divx_max_key_interval;
277 divx_max_quantizer = asset->divx_max_quantizer;
278 divx_min_quantizer = asset->divx_min_quantizer;
279 divx_quantizer = asset->divx_quantizer;
280 divx_quality = asset->divx_quality;
281 divx_fix_bitrate = asset->divx_fix_bitrate;
282 divx_use_deblocking = asset->divx_use_deblocking;
284 h264_bitrate = asset->h264_bitrate;
285 h264_quantizer = asset->h264_quantizer;
286 h264_fix_bitrate = asset->h264_fix_bitrate;
289 ms_bitrate = asset->ms_bitrate;
290 ms_bitrate_tolerance = asset->ms_bitrate_tolerance;
291 ms_interlaced = asset->ms_interlaced;
292 ms_quantization = asset->ms_quantization;
293 ms_gop_size = asset->ms_gop_size;
294 ms_fix_bitrate = asset->ms_fix_bitrate;
297 ac3_bitrate = asset->ac3_bitrate;
299 png_use_alpha = asset->png_use_alpha;
300 exr_use_alpha = asset->exr_use_alpha;
301 exr_compression = asset->exr_compression;
303 tiff_cmodel = asset->tiff_cmodel;
304 tiff_compression = asset->tiff_compression;
306 strcpy(pipe, asset->pipe);
307 use_pipe = asset->use_pipe;
309 strcpy(reel_name, asset->reel_name);
310 reel_number = asset->reel_number;
311 tcstart = asset->tcstart;
312 tcend = asset->tcend;
313 tcformat = asset->tcformat;
316 int64_t Asset::get_index_offset(int channel)
318 if(channel < channels && index_offsets)
319 return index_offsets[channel];
324 int64_t Asset::get_index_size(int channel)
326 if(channel < channels && index_sizes)
327 return index_sizes[channel];
333 char* Asset::get_compression_text(int audio, int video)
342 return quicktime_acodec_title(acodec);
356 return quicktime_vcodec_title(vcodec);
365 Asset& Asset::operator=(Asset &asset)
367 copy_location(&asset);
368 copy_format(&asset, 1);
373 int Asset::equivalent(Asset &asset,
377 int result = (!strcmp(asset.path, path) &&
378 format == asset.format);
380 if(test_audio && result)
382 result = (channels == asset.channels &&
383 sample_rate == asset.sample_rate &&
384 bits == asset.bits &&
385 byte_order == asset.byte_order &&
386 signed_ == asset.signed_ &&
387 header == asset.header &&
388 dither == asset.dither &&
389 !strcmp(acodec, asset.acodec));
393 if(test_video && result)
395 result = (layers == asset.layers &&
396 frame_rate == asset.frame_rate &&
397 asset.interlace_autofixoption == interlace_autofixoption &&
398 asset.interlace_mode == interlace_mode &&
399 interlace_fixmethod == asset.interlace_fixmethod &&
400 width == asset.width &&
401 height == asset.height &&
402 !strcmp(vcodec, asset.vcodec) &&
403 strcmp(reel_name, asset.reel_name) == 0 &&
404 reel_number == asset.reel_number &&
405 tcstart == asset.tcstart &&
406 tcend == asset.tcend &&
407 tcformat == asset.tcformat);
413 int Asset::operator==(Asset &asset)
416 return equivalent(asset,
421 int Asset::operator!=(Asset &asset)
423 return !(*this == asset);
426 int Asset::test_path(const char *path)
428 if(!strcasecmp(this->path, path))
434 int Asset::test_plugin_title(const char *path)
438 int Asset::read(FileXML *file,
443 // Check for relative path.
446 char new_path[BCTEXTLEN];
447 char asset_directory[BCTEXTLEN];
448 char input_directory[BCTEXTLEN];
451 strcpy(new_path, path);
452 fs.set_current_dir("");
454 fs.extract_dir(asset_directory, path);
457 // Take path of XML file.
458 if(!asset_directory[0])
460 fs.extract_dir(input_directory, file->filename);
462 // Input file has a path
463 if(input_directory[0])
465 fs.join_names(path, input_directory, new_path);
473 result = file->read_tag();
476 if(file->tag.title_is("/ASSET"))
481 if(file->tag.title_is("AUDIO"))
486 if(file->tag.title_is("AUDIO_OMIT"))
491 if(file->tag.title_is("FORMAT"))
493 char *string = file->tag.get_property("TYPE");
494 format = File::strtoformat(string);
496 file->tag.get_property("USE_HEADER", use_header);
499 if(file->tag.title_is("FOLDER"))
501 strcpy(folder, file->read_text());
504 if(file->tag.title_is("VIDEO"))
509 if(file->tag.title_is("VIDEO_OMIT"))
514 if(file->tag.title_is("INDEX"))
521 //printf("Asset::read 2\n");
525 int Asset::read_audio(FileXML *file)
527 if(file->tag.title_is("AUDIO")) audio_data = 1;
528 channels = file->tag.get_property("CHANNELS", 2);
529 // This is loaded from the index file after the EDL but this
530 // should be overridable in the EDL.
531 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
532 bits = file->tag.get_property("BITS", 16);
533 byte_order = file->tag.get_property("BYTE_ORDER", 1);
534 signed_ = file->tag.get_property("SIGNED", 1);
535 header = file->tag.get_property("HEADER", 0);
536 dither = file->tag.get_property("DITHER", 0);
538 audio_length = file->tag.get_property("AUDIO_LENGTH", 0);
540 file->tag.get_property("ACODEC", acodec);
544 // ampeg_bitrate = file->tag.get_property("AMPEG_BITRATE", ampeg_bitrate);
545 // ampeg_derivative = file->tag.get_property("AMPEG_DERIVATIVE", ampeg_derivative);
547 // vorbis_vbr = file->tag.get_property("VORBIS_VBR", vorbis_vbr);
548 // vorbis_min_bitrate = file->tag.get_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
549 // vorbis_bitrate = file->tag.get_property("VORBIS_BITRATE", vorbis_bitrate);
550 // vorbis_max_bitrate = file->tag.get_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
552 // mp3_bitrate = file->tag.get_property("MP3_BITRATE", mp3_bitrate);
557 tcend = audio_length;
564 int Asset::read_video(FileXML *file)
566 char string[BCTEXTLEN];
568 if(file->tag.title_is("VIDEO")) video_data = 1;
569 height = file->tag.get_property("HEIGHT", height);
570 width = file->tag.get_property("WIDTH", width);
571 layers = file->tag.get_property("LAYERS", layers);
572 // This is loaded from the index file after the EDL but this
573 // should be overridable in the EDL.
574 if(!frame_rate) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
576 file->tag.get_property("VCODEC", vcodec);
578 video_length = file->tag.get_property("VIDEO_LENGTH", 0);
580 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
582 ilacemode_to_xmltext(string, BC_ILACE_MODE_NOTINTERLACED);
583 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), BC_ILACE_MODE_NOTINTERLACED);
585 ilacefixmethod_to_xmltext(string, BC_ILACE_FIXMETHOD_NONE);
586 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), BC_ILACE_FIXMETHOD_NONE);
588 file->tag.get_property("REEL_NAME", reel_name);
589 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
590 tcstart = file->tag.get_property("TCSTART", tcstart);
591 tcend = file->tag.get_property("TCEND", tcend);
592 tcformat = file->tag.get_property("TCFORMAT", tcformat);
597 int Asset::read_index(FileXML *file)
599 delete [] index_offsets;
600 index_offsets = new int64_t[channels];
601 delete [] index_sizes;
602 index_sizes = new int64_t[channels];
603 for(int i = 0; i < channels; i++)
605 index_offsets[i] = 0;
609 int current_offset = 0;
610 int current_size = 0;
613 index_zoom = file->tag.get_property("ZOOM", 1);
614 index_bytes = file->tag.get_property("BYTES", (int64_t)0);
618 result = file->read_tag();
621 if(file->tag.title_is("/INDEX"))
626 if(file->tag.title_is("OFFSET"))
628 if(current_offset < channels)
630 index_offsets[current_offset++] = file->tag.get_property("FLOAT", 0);
631 //printf("Asset::read_index %d %d\n", current_offset - 1, index_offsets[current_offset - 1]);
635 if(file->tag.title_is("SIZE"))
637 if(current_size < channels)
639 index_sizes[current_size++] = file->tag.get_property("FLOAT", 0);
647 int Asset::write_index(char *path, int data_bytes)
650 if(!(file = fopen(path, "wb")))
652 // failed to create it
653 printf(_("Asset::write_index Couldn't write index file %s to disk.\n"), path);
658 // Pad index start position
659 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
661 index_status = INDEX_READY;
662 // Write encoding information
666 xml.write_to_file(file);
667 index_start = ftell(file);
668 fseek(file, 0, SEEK_SET);
670 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
671 fseek(file, index_start, SEEK_SET);
681 // Force reread of header
682 index_status = INDEX_NOTTESTED;
683 // index_status = INDEX_READY;
684 index_end = audio_length;
689 // Output path is the path of the output file if name truncation is desired.
690 // It is a "" if complete names should be used.
692 int Asset::write(FileXML *file,
696 char new_path[BCTEXTLEN];
697 char asset_directory[BCTEXTLEN];
698 char output_directory[BCTEXTLEN];
701 // Make path relative
702 fs.extract_dir(asset_directory, path);
703 if(output_path && output_path[0])
704 fs.extract_dir(output_directory, output_path);
706 output_directory[0] = 0;
708 // Asset and EDL are in same directory. Extract just the name.
709 if(!strcmp(asset_directory, output_directory))
711 fs.extract_name(new_path, path);
715 strcpy(new_path, path);
718 file->tag.set_title("ASSET");
719 file->tag.set_property("SRC", new_path);
721 file->append_newline();
723 file->tag.set_title("FOLDER");
725 file->append_text(folder);
726 file->tag.set_title("/FOLDER");
728 file->append_newline();
730 // Write the format information
731 file->tag.set_title("FORMAT");
733 file->tag.set_property("TYPE",
734 File::formattostr(format));
735 file->tag.set_property("USE_HEADER", use_header);
738 file->tag.set_title("/FORMAT");
740 file->append_newline();
742 // Requiring data to exist caused batch render to lose settings.
743 // But the only way to know if an asset doesn't have audio or video data
744 // is to not write the block.
745 // So change the block name if the asset doesn't have the data.
746 /* if(audio_data) */ write_audio(file);
747 /* if(video_data) */ write_video(file);
748 if(index_status == 0 && include_index) write_index(file); // index goes after source
750 file->tag.set_title("/ASSET");
752 file->append_newline();
756 int Asset::write_audio(FileXML *file)
758 // Let the reader know if the asset has the data by naming the block.
760 file->tag.set_title("AUDIO");
762 file->tag.set_title("AUDIO_OMIT");
763 // Necessary for PCM audio
764 file->tag.set_property("CHANNELS", channels);
765 file->tag.set_property("RATE", sample_rate);
766 file->tag.set_property("BITS", bits);
767 file->tag.set_property("BYTE_ORDER", byte_order);
768 file->tag.set_property("SIGNED", signed_);
769 file->tag.set_property("HEADER", header);
770 file->tag.set_property("DITHER", dither);
772 file->tag.set_property("ACODEC", acodec);
774 file->tag.set_property("AUDIO_LENGTH", audio_length);
778 // Rely on defaults operations for these.
780 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
781 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
783 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
784 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
785 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
786 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
788 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
795 file->tag.set_title("/AUDIO");
797 file->tag.set_title("/AUDIO_OMIT");
799 file->append_newline();
803 int Asset::write_video(FileXML *file)
805 char string[BCTEXTLEN];
808 file->tag.set_title("VIDEO");
810 file->tag.set_title("VIDEO_OMIT");
811 file->tag.set_property("HEIGHT", height);
812 file->tag.set_property("WIDTH", width);
813 file->tag.set_property("LAYERS", layers);
814 file->tag.set_property("FRAMERATE", frame_rate);
816 file->tag.set_property("VCODEC", vcodec);
818 file->tag.set_property("VIDEO_LENGTH", video_length);
820 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
822 ilacemode_to_xmltext(string, interlace_mode);
823 file->tag.set_property("INTERLACE_MODE", string);
825 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
826 file->tag.set_property("INTERLACE_FIXMETHOD", string);
829 file->tag.set_property("REEL_NAME", reel_name);
830 file->tag.set_property("REEL_NUMBER", reel_number);
831 file->tag.set_property("TCSTART", tcstart);
832 file->tag.set_property("TCEND", tcend);
833 file->tag.set_property("TCFORMAT", tcformat);
837 file->tag.set_title("/VIDEO");
839 file->tag.set_title("/VIDEO_OMIT");
842 file->append_newline();
846 int Asset::write_index(FileXML *file)
848 file->tag.set_title("INDEX");
849 file->tag.set_property("ZOOM", index_zoom);
850 file->tag.set_property("BYTES", index_bytes);
852 file->append_newline();
856 for(int i = 0; i < channels; i++)
858 file->tag.set_title("OFFSET");
859 file->tag.set_property("FLOAT", index_offsets[i]);
861 file->tag.set_title("/OFFSET");
863 file->tag.set_title("SIZE");
864 file->tag.set_property("FLOAT", index_sizes[i]);
866 file->tag.set_title("/SIZE");
871 file->append_newline();
872 file->tag.set_title("/INDEX");
874 file->append_newline();
881 char* Asset::construct_param(char *param, char *prefix, char *return_value)
884 sprintf(return_value, "%s%s", prefix, param);
886 strcpy(return_value, param);
890 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
891 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
893 void Asset::load_defaults(BC_Hash *defaults,
901 char string[BCTEXTLEN];
903 // Can't save codec here because it's specific to render, record, and effect.
904 // The codec has to be UNKNOWN for file probing to work.
908 GET_DEFAULT("PATH", path);
913 GET_DEFAULT("AUDIO_CODEC", acodec);
914 GET_DEFAULT("VIDEO_CODEC", vcodec);
919 format = GET_DEFAULT("FORMAT", format);
924 audio_data = GET_DEFAULT("AUDIO", 1);
925 video_data = GET_DEFAULT("VIDEO", 1);
930 bits = GET_DEFAULT("BITS", 16);
931 dither = GET_DEFAULT("DITHER", 0);
932 signed_ = GET_DEFAULT("SIGNED", 1);
933 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
936 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
937 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
939 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
940 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
941 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
942 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
944 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
945 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
946 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
947 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
948 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
949 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
953 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
954 mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
955 mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
957 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
958 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
960 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
961 interlace_mode = BC_ILACE_MODE_UNDETECTED;
962 interlace_fixmethod = BC_ILACE_FIXMETHOD_UPONE;
964 // MPEG format information
965 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
966 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
967 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
968 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
969 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
970 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
971 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
972 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
973 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
974 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
975 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
976 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
978 h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
979 h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
980 h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
983 divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
984 divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
985 divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
986 divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
987 divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
988 divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
989 divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
990 divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
991 divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
992 divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
993 divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
995 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
996 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
997 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
998 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
999 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
1000 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
1003 ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
1004 ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
1005 ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
1006 ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
1007 ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
1008 ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
1010 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
1012 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1013 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1014 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
1015 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1016 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1018 // this extra 'FORMAT_' prefix is just here for legacy reasons
1019 use_pipe = GET_DEFAULT("FORMAT_YUV_USE_PIPE", use_pipe);
1020 GET_DEFAULT("FORMAT_YUV_PIPE", pipe);
1022 GET_DEFAULT("REEL_NAME", reel_name);
1023 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
1024 tcstart = GET_DEFAULT("TCSTART", tcstart);
1025 tcend = GET_DEFAULT("TCEND", tcend);
1026 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
1029 void Asset::save_defaults(BC_Hash *defaults,
1037 char string[BCTEXTLEN];
1039 UPDATE_DEFAULT("PATH", path);
1043 UPDATE_DEFAULT("FORMAT", format);
1048 UPDATE_DEFAULT("AUDIO", audio_data);
1049 UPDATE_DEFAULT("VIDEO", video_data);
1054 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
1055 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
1057 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
1058 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
1060 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
1061 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
1062 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
1063 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
1066 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
1067 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
1068 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
1069 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
1070 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
1071 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
1075 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
1076 UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
1077 UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
1083 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
1084 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
1086 // MPEG format information
1087 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
1088 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
1089 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
1090 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
1091 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
1092 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
1093 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
1094 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
1095 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
1096 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
1097 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
1098 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
1100 UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
1101 UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
1102 UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
1104 UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
1105 UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
1106 UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
1107 UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
1108 UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
1109 UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
1110 UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
1111 UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
1112 UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
1113 UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
1114 UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
1117 UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
1118 UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
1119 UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
1120 UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
1121 UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
1122 UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
1124 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
1127 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1128 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1129 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
1130 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1131 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1133 UPDATE_DEFAULT("FORMAT_YUV_USE_PIPE", use_pipe);
1134 UPDATE_DEFAULT("FORMAT_YUV_PIPE", pipe);
1139 UPDATE_DEFAULT("BITS", bits);
1140 UPDATE_DEFAULT("DITHER", dither);
1141 UPDATE_DEFAULT("SIGNED", signed_);
1142 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
1145 UPDATE_DEFAULT("REEL_NAME", reel_name);
1146 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
1147 UPDATE_DEFAULT("TCSTART", tcstart);
1148 UPDATE_DEFAULT("TCEND", tcend);
1149 UPDATE_DEFAULT("TCFORMAT", tcformat);
1160 int Asset::update_path(char *new_path)
1162 strcpy(path, new_path);
1166 double Asset::total_length_framealigned(double fps)
1168 if (video_data && audio_data) {
1169 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1170 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1171 return MIN(aud,vid);
1175 return (double)audio_length / sample_rate;
1178 return (double)video_length / frame_rate;
1181 void Asset::update_index(Asset *asset)
1183 //printf("Asset::update_index 1 %d\n", index_status);
1184 index_status = asset->index_status;
1185 index_zoom = asset->index_zoom; // zoom factor of index data
1186 index_start = asset->index_start; // byte start of index data in the index file
1187 index_bytes = asset->index_bytes; // Total bytes in source file for comparison before rebuilding the index
1188 index_end = asset->index_end;
1189 old_index_end = asset->old_index_end; // values for index build
1191 delete [] index_offsets;
1192 delete [] index_sizes;
1196 if(asset->index_offsets)
1198 index_offsets = new int64_t[asset->channels];
1199 index_sizes = new int64_t[asset->channels];
1202 for(i = 0; i < asset->channels; i++)
1204 // offsets of channels in index file in floats
1205 index_offsets[i] = asset->index_offsets[i];
1206 index_sizes[i] = asset->index_sizes[i];
1209 index_buffer = asset->index_buffer; // pointer
1212 int Asset::set_timecode(char *tc, int format, int end)
1216 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1217 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1218 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1220 // This needs to be modified to handle drop-frame
1223 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1225 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1233 printf(" asset::dump\n");
1234 printf(" %p %s\n", this, path);
1235 printf(" index_status %d\n", index_status);
1236 printf(" format %d\n", format);
1237 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",
1238 audio_data, channels, sample_rate, bits, byte_order, signed_, header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1239 printf(" audio_length %lld\n", audio_length);
1240 char string[BCTEXTLEN];
1241 ilacemode_to_xmltext(string, interlace_mode);
1242 printf(" video_data %d layers %d framerate %f width %d height %d vcodec %c%c%c%c aspect_ratio %f interlace_mode %s\n",
1243 video_data, layers, frame_rate, width, height, vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio, string);
1244 printf(" video_length %lld \n", video_length);
1245 printf(" reel_name %s reel_number %i tcstart %d tcend %d tcf %d\n",
1246 reel_name, reel_number, tcstart, tcend, tcformat);