6 #include "filesystem.h"
9 #include "interlacemodes.h"
15 Asset::Asset() : ListItem<Asset>()
20 Asset::Asset(Asset &asset) : ListItem<Asset>()
26 Asset::Asset(const char *path) : ListItem<Asset>()
29 strcpy(this->path, path);
32 Asset::Asset(const int plugin_type, const char *plugin_title) : ListItem<Asset>()
39 delete [] index_offsets;
40 delete [] index_sizes;
41 // Don't delete index buffer since it is shared with the index thread.
45 int Asset::init_values()
48 strcpy(folder, MEDIA_FOLDER);
50 // Has to be unknown for file probing to succeed
51 format = FILE_UNKNOWN;
68 strcpy(vcodec, QUICKTIME_YUV2);
69 strcpy(acodec, QUICKTIME_TWOS);
72 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
73 interlace_mode = BC_ILACE_MODE_UNDETECTED;
74 interlace_fixmethod = BC_ILACE_FIXMETHOD_NONE;
80 vorbis_min_bitrate = -1;
81 vorbis_bitrate = 128000;
82 vorbis_max_bitrate = -1;
84 theora_fix_bitrate = 1;
85 theora_bitrate = 860000;
88 theora_keyframe_frequency = 64;
89 theora_keyframe_force_frequency = 64;
94 mp4a_bitrate = 256000;
100 vmpeg_iframe_distance = 45;
101 vmpeg_pframe_distance = 0;
102 vmpeg_progressive = 0;
104 vmpeg_bitrate = 1000000;
105 vmpeg_derivative = 1;
106 vmpeg_quantization = 15;
108 vmpeg_fix_bitrate = 0;
111 vmpeg_field_order = 0;
113 // Divx parameters. Defaults from encore2
114 divx_bitrate = 2000000;
116 divx_rc_reaction_ratio = 45;
117 divx_rc_reaction_period = 10;
118 divx_max_key_interval = 250;
119 divx_max_quantizer = 31;
120 divx_min_quantizer = 1;
123 divx_fix_bitrate = 1;
124 divx_use_deblocking = 1;
126 h264_bitrate = 2000000;
128 h264_fix_bitrate = 0;
130 ms_bitrate = 1000000;
131 ms_bitrate_tolerance = 500000;
132 ms_quantization = 10;
144 tiff_compression = 0;
162 int Asset::reset_index()
164 index_status = INDEX_NOTTESTED;
165 index_start = old_index_end = index_end = 0;
174 int Asset::reset_timecode()
176 strcpy(reel_name, "cin0000");
185 void Asset::copy_from(Asset *asset, int do_index)
187 copy_location(asset);
188 copy_format(asset, do_index);
191 void Asset::copy_location(Asset *asset)
193 strcpy(this->path, asset->path);
194 strcpy(this->folder, asset->folder);
197 void Asset::copy_format(Asset *asset, int do_index)
199 if(do_index) update_index(asset);
201 audio_data = asset->audio_data;
202 format = asset->format;
203 channels = asset->channels;
204 sample_rate = asset->sample_rate;
206 byte_order = asset->byte_order;
207 signed_ = asset->signed_;
208 header = asset->header;
209 dither = asset->dither;
210 mp3_bitrate = asset->mp3_bitrate;
211 mp4a_bitrate = asset->mp4a_bitrate;
212 mp4a_quantqual = asset->mp4a_quantqual;
213 use_header = asset->use_header;
214 aspect_ratio = asset->aspect_ratio;
215 interlace_autofixoption = asset->interlace_autofixoption;
216 interlace_mode = asset->interlace_mode;
217 interlace_fixmethod = asset->interlace_fixmethod;
219 video_data = asset->video_data;
220 layers = asset->layers;
221 frame_rate = asset->frame_rate;
222 width = asset->width;
223 height = asset->height;
224 strcpy(vcodec, asset->vcodec);
225 strcpy(acodec, asset->acodec);
227 this->audio_length = asset->audio_length;
228 this->video_length = asset->video_length;
231 ampeg_bitrate = asset->ampeg_bitrate;
232 ampeg_derivative = asset->ampeg_derivative;
235 vorbis_vbr = asset->vorbis_vbr;
236 vorbis_min_bitrate = asset->vorbis_min_bitrate;
237 vorbis_bitrate = asset->vorbis_bitrate;
238 vorbis_max_bitrate = asset->vorbis_max_bitrate;
240 theora_fix_bitrate = asset->theora_fix_bitrate;
241 theora_bitrate = asset->theora_bitrate;
242 theora_quality = asset->theora_quality;
243 theora_sharpness = asset->theora_sharpness;
244 theora_keyframe_frequency = asset->theora_keyframe_frequency;
245 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
248 theora_fix_bitrate = asset->theora_fix_bitrate;
249 theora_bitrate = asset->theora_bitrate;
250 theora_quality = asset->theora_quality;
251 theora_sharpness = asset->theora_sharpness;
252 theora_keyframe_frequency = asset->theora_keyframe_frequency;
253 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
256 jpeg_quality = asset->jpeg_quality;
259 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
260 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
261 vmpeg_progressive = asset->vmpeg_progressive;
262 vmpeg_denoise = asset->vmpeg_denoise;
263 vmpeg_bitrate = asset->vmpeg_bitrate;
264 vmpeg_derivative = asset->vmpeg_derivative;
265 vmpeg_quantization = asset->vmpeg_quantization;
266 vmpeg_cmodel = asset->vmpeg_cmodel;
267 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
268 vmpeg_seq_codes = asset->vmpeg_seq_codes;
269 vmpeg_preset = asset->vmpeg_preset;
270 vmpeg_field_order = asset->vmpeg_field_order;
273 divx_bitrate = asset->divx_bitrate;
274 divx_rc_period = asset->divx_rc_period;
275 divx_rc_reaction_ratio = asset->divx_rc_reaction_ratio;
276 divx_rc_reaction_period = asset->divx_rc_reaction_period;
277 divx_max_key_interval = asset->divx_max_key_interval;
278 divx_max_quantizer = asset->divx_max_quantizer;
279 divx_min_quantizer = asset->divx_min_quantizer;
280 divx_quantizer = asset->divx_quantizer;
281 divx_quality = asset->divx_quality;
282 divx_fix_bitrate = asset->divx_fix_bitrate;
283 divx_use_deblocking = asset->divx_use_deblocking;
285 h264_bitrate = asset->h264_bitrate;
286 h264_quantizer = asset->h264_quantizer;
287 h264_fix_bitrate = asset->h264_fix_bitrate;
290 ms_bitrate = asset->ms_bitrate;
291 ms_bitrate_tolerance = asset->ms_bitrate_tolerance;
292 ms_interlaced = asset->ms_interlaced;
293 ms_quantization = asset->ms_quantization;
294 ms_gop_size = asset->ms_gop_size;
295 ms_fix_bitrate = asset->ms_fix_bitrate;
298 ac3_bitrate = asset->ac3_bitrate;
300 png_use_alpha = asset->png_use_alpha;
301 exr_use_alpha = asset->exr_use_alpha;
302 exr_compression = asset->exr_compression;
304 tiff_cmodel = asset->tiff_cmodel;
305 tiff_compression = asset->tiff_compression;
307 strcpy(pipe, asset->pipe);
308 use_pipe = asset->use_pipe;
310 // FUTURE: should this be here or in copy_from()?
311 strcpy(prefix, asset->prefix);
313 strcpy(reel_name, asset->reel_name);
314 reel_number = asset->reel_number;
315 tcstart = asset->tcstart;
316 tcend = asset->tcend;
317 tcformat = asset->tcformat;
320 int64_t Asset::get_index_offset(int channel)
322 if(channel < channels && index_offsets)
323 return index_offsets[channel];
328 int64_t Asset::get_index_size(int channel)
330 if(channel < channels && index_sizes)
331 return index_sizes[channel];
337 char* Asset::get_compression_text(int audio, int video)
346 return quicktime_acodec_title(acodec);
360 return quicktime_vcodec_title(vcodec);
369 Asset& Asset::operator=(Asset &asset)
371 copy_location(&asset);
377 int Asset::equivalent(Asset &asset,
381 int result = (!strcmp(asset.path, path) &&
382 format == asset.format);
384 if(test_audio && result)
386 result = (channels == asset.channels &&
387 sample_rate == asset.sample_rate &&
388 bits == asset.bits &&
389 byte_order == asset.byte_order &&
390 signed_ == asset.signed_ &&
391 header == asset.header &&
392 dither == asset.dither &&
393 !strcmp(acodec, asset.acodec));
397 if(test_video && result)
399 result = (layers == asset.layers &&
400 frame_rate == asset.frame_rate &&
401 asset.interlace_autofixoption == interlace_autofixoption &&
402 asset.interlace_mode == interlace_mode &&
403 interlace_fixmethod == asset.interlace_fixmethod &&
404 width == asset.width &&
405 height == asset.height &&
406 !strcmp(vcodec, asset.vcodec) &&
407 strcmp(reel_name, asset.reel_name) == 0 &&
408 reel_number == asset.reel_number &&
409 tcstart == asset.tcstart &&
410 tcend == asset.tcend &&
411 tcformat == asset.tcformat);
417 int Asset::operator==(Asset &asset)
420 return equivalent(asset,
425 int Asset::operator!=(Asset &asset)
427 return !(*this == asset);
430 int Asset::test_path(const char *path)
432 if(!strcasecmp(this->path, path))
438 int Asset::test_plugin_title(const char *path)
442 int Asset::read(FileXML *file,
447 // Check for relative path.
450 char new_path[BCTEXTLEN];
451 char asset_directory[BCTEXTLEN];
452 char input_directory[BCTEXTLEN];
455 strcpy(new_path, path);
456 fs.set_current_dir("");
458 fs.extract_dir(asset_directory, path);
461 // Take path of XML file.
462 if(!asset_directory[0])
464 fs.extract_dir(input_directory, file->filename);
466 // Input file has a path
467 if(input_directory[0])
469 fs.join_names(path, input_directory, new_path);
477 result = file->read_tag();
480 if(file->tag.title_is("/ASSET"))
485 if(file->tag.title_is("AUDIO"))
490 if(file->tag.title_is("AUDIO_OMIT"))
495 if(file->tag.title_is("FORMAT"))
497 char *string = file->tag.get_property("TYPE");
498 format = File::strtoformat(string);
500 file->tag.get_property("USE_HEADER", use_header);
503 if(file->tag.title_is("FOLDER"))
505 strcpy(folder, file->read_text());
508 if(file->tag.title_is("VIDEO"))
513 if(file->tag.title_is("VIDEO_OMIT"))
518 if(file->tag.title_is("INDEX"))
525 //printf("Asset::read 2\n");
529 int Asset::read_audio(FileXML *file)
531 if(file->tag.title_is("AUDIO")) audio_data = 1;
532 channels = file->tag.get_property("CHANNELS", 2);
533 // This is loaded from the index file after the EDL but this
534 // should be overridable in the EDL.
535 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
536 bits = file->tag.get_property("BITS", 16);
537 byte_order = file->tag.get_property("BYTE_ORDER", 1);
538 signed_ = file->tag.get_property("SIGNED", 1);
539 header = file->tag.get_property("HEADER", 0);
540 dither = file->tag.get_property("DITHER", 0);
542 audio_length = file->tag.get_property("AUDIO_LENGTH", 0);
544 file->tag.get_property("ACODEC", acodec);
548 // ampeg_bitrate = file->tag.get_property("AMPEG_BITRATE", ampeg_bitrate);
549 // ampeg_derivative = file->tag.get_property("AMPEG_DERIVATIVE", ampeg_derivative);
551 // vorbis_vbr = file->tag.get_property("VORBIS_VBR", vorbis_vbr);
552 // vorbis_min_bitrate = file->tag.get_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
553 // vorbis_bitrate = file->tag.get_property("VORBIS_BITRATE", vorbis_bitrate);
554 // vorbis_max_bitrate = file->tag.get_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
556 // mp3_bitrate = file->tag.get_property("MP3_BITRATE", mp3_bitrate);
561 tcend = audio_length;
568 int Asset::read_video(FileXML *file)
570 if(file->tag.title_is("VIDEO")) video_data = 1;
571 height = file->tag.get_property("HEIGHT", height);
572 width = file->tag.get_property("WIDTH", width);
573 layers = file->tag.get_property("LAYERS", layers);
574 // This is loaded from the index file after the EDL but this
575 // should be overridable in the EDL.
576 if(!frame_rate) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
578 file->tag.get_property("VCODEC", vcodec);
580 video_length = file->tag.get_property("VIDEO_LENGTH", 0);
583 file->tag.get_property("REEL_NAME", reel_name);
584 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
585 tcstart = file->tag.get_property("TCSTART", tcstart);
586 tcend = file->tag.get_property("TCEND", tcend);
587 tcformat = file->tag.get_property("TCFORMAT", tcformat);
592 int Asset::read_index(FileXML *file)
594 delete [] index_offsets;
595 index_offsets = new int64_t[channels];
596 delete [] index_sizes;
597 index_sizes = new int64_t[channels];
598 for(int i = 0; i < channels; i++)
600 index_offsets[i] = 0;
604 int current_offset = 0;
605 int current_size = 0;
608 index_zoom = file->tag.get_property("ZOOM", 1);
609 index_bytes = file->tag.get_property("BYTES", (int64_t)0);
613 result = file->read_tag();
616 if(file->tag.title_is("/INDEX"))
621 if(file->tag.title_is("OFFSET"))
623 if(current_offset < channels)
625 index_offsets[current_offset++] = file->tag.get_property("FLOAT", 0);
626 //printf("Asset::read_index %d %d\n", current_offset - 1, index_offsets[current_offset - 1]);
630 if(file->tag.title_is("SIZE"))
632 if(current_size < channels)
634 index_sizes[current_size++] = file->tag.get_property("FLOAT", 0);
642 int Asset::write_index(char *path, int data_bytes)
645 if(!(file = fopen(path, "wb")))
647 // failed to create it
648 printf(_("Asset::write_index Couldn't write index file %s to disk.\n"), path);
653 // Pad index start position
654 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
656 index_status = INDEX_READY;
657 // Write encoding information
661 xml.write_to_file(file);
662 index_start = ftell(file);
663 fseek(file, 0, SEEK_SET);
665 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
666 fseek(file, index_start, SEEK_SET);
676 // Force reread of header
677 index_status = INDEX_NOTTESTED;
678 // index_status = INDEX_READY;
679 index_end = audio_length;
684 // Output path is the path of the output file if name truncation is desired.
685 // It is a "" if complete names should be used.
687 int Asset::write(FileXML *file,
691 char new_path[BCTEXTLEN];
692 char asset_directory[BCTEXTLEN];
693 char output_directory[BCTEXTLEN];
696 // Make path relative
697 fs.extract_dir(asset_directory, path);
698 if(output_path && output_path[0])
699 fs.extract_dir(output_directory, output_path);
701 output_directory[0] = 0;
703 // Asset and EDL are in same directory. Extract just the name.
704 if(!strcmp(asset_directory, output_directory))
706 fs.extract_name(new_path, path);
710 strcpy(new_path, path);
713 file->tag.set_title("ASSET");
714 file->tag.set_property("SRC", new_path);
716 file->append_newline();
718 file->tag.set_title("FOLDER");
720 file->append_text(folder);
721 file->tag.set_title("/FOLDER");
723 file->append_newline();
725 // Write the format information
726 file->tag.set_title("FORMAT");
728 file->tag.set_property("TYPE",
729 File::formattostr(format));
730 file->tag.set_property("USE_HEADER", use_header);
733 file->tag.set_title("/FORMAT");
735 file->append_newline();
737 // Requiring data to exist caused batch render to lose settings.
738 // But the only way to know if an asset doesn't have audio or video data
739 // is to not write the block.
740 // So change the block name if the asset doesn't have the data.
741 /* if(audio_data) */ write_audio(file);
742 /* if(video_data) */ write_video(file);
743 if(index_status == 0 && include_index) write_index(file); // index goes after source
745 file->tag.set_title("/ASSET");
747 file->append_newline();
751 int Asset::write_audio(FileXML *file)
753 // Let the reader know if the asset has the data by naming the block.
755 file->tag.set_title("AUDIO");
757 file->tag.set_title("AUDIO_OMIT");
758 // Necessary for PCM audio
759 file->tag.set_property("CHANNELS", channels);
760 file->tag.set_property("RATE", sample_rate);
761 file->tag.set_property("BITS", bits);
762 file->tag.set_property("BYTE_ORDER", byte_order);
763 file->tag.set_property("SIGNED", signed_);
764 file->tag.set_property("HEADER", header);
765 file->tag.set_property("DITHER", dither);
767 file->tag.set_property("ACODEC", acodec);
769 file->tag.set_property("AUDIO_LENGTH", audio_length);
773 // Rely on defaults operations for these.
775 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
776 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
778 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
779 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
780 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
781 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
783 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
790 file->tag.set_title("/AUDIO");
792 file->tag.set_title("/AUDIO_OMIT");
794 file->append_newline();
798 int Asset::write_video(FileXML *file)
801 file->tag.set_title("VIDEO");
803 file->tag.set_title("VIDEO_OMIT");
804 file->tag.set_property("HEIGHT", height);
805 file->tag.set_property("WIDTH", width);
806 file->tag.set_property("LAYERS", layers);
807 file->tag.set_property("FRAMERATE", frame_rate);
809 file->tag.set_property("VCODEC", vcodec);
811 file->tag.set_property("VIDEO_LENGTH", video_length);
815 file->tag.set_property("REEL_NAME", reel_name);
816 file->tag.set_property("REEL_NUMBER", reel_number);
817 file->tag.set_property("TCSTART", tcstart);
818 file->tag.set_property("TCEND", tcend);
819 file->tag.set_property("TCFORMAT", tcformat);
823 file->tag.set_title("/VIDEO");
825 file->tag.set_title("/VIDEO_OMIT");
828 file->append_newline();
832 int Asset::write_index(FileXML *file)
834 file->tag.set_title("INDEX");
835 file->tag.set_property("ZOOM", index_zoom);
836 file->tag.set_property("BYTES", index_bytes);
838 file->append_newline();
842 for(int i = 0; i < channels; i++)
844 file->tag.set_title("OFFSET");
845 file->tag.set_property("FLOAT", index_offsets[i]);
847 file->tag.set_title("/OFFSET");
849 file->tag.set_title("SIZE");
850 file->tag.set_property("FLOAT", index_sizes[i]);
852 file->tag.set_title("/SIZE");
857 file->append_newline();
858 file->tag.set_title("/INDEX");
860 file->append_newline();
867 char* Asset::construct_param(char *param, char *prefix, char *return_value)
870 sprintf(return_value, "%s%s", prefix, param);
872 strcpy(return_value, param);
876 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
877 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
879 void Asset::load_defaults(Defaults *defaults,
887 char string[BCTEXTLEN];
889 // Can't save codec here because it's specific to render, record, and effect.
890 // The codec has to be UNKNOWN for file probing to work.
894 GET_DEFAULT("PATH", path);
899 GET_DEFAULT("AUDIO_CODEC", acodec);
900 GET_DEFAULT("VIDEO_CODEC", vcodec);
905 format = GET_DEFAULT("FORMAT", format);
910 audio_data = GET_DEFAULT("AUDIO", 1);
911 video_data = GET_DEFAULT("VIDEO", 1);
916 bits = GET_DEFAULT("BITS", 16);
917 dither = GET_DEFAULT("DITHER", 0);
918 signed_ = GET_DEFAULT("SIGNED", 1);
919 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
922 // NOTE: this should never be saved
923 strcpy(this->prefix, prefix ? prefix : "");
925 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
926 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
928 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
929 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
930 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
931 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
933 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
934 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
935 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
936 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
937 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
938 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
942 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
943 mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
944 mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
946 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
947 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
949 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
950 interlace_mode = BC_ILACE_MODE_UNDETECTED;
951 interlace_fixmethod = BC_ILACE_FIXMETHOD_UPONE;
953 // MPEG format information
954 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
955 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
956 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
957 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
958 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
959 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
960 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
961 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
962 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
963 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
964 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
965 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
967 h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
968 h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
969 h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
972 divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
973 divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
974 divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
975 divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
976 divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
977 divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
978 divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
979 divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
980 divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
981 divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
982 divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
984 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
985 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
986 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
987 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
988 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
989 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
992 ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
993 ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
994 ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
995 ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
996 ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
997 ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
999 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
1001 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1002 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1003 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
1004 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1005 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1007 GET_DEFAULT("REEL_NAME", reel_name);
1008 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
1009 tcstart = GET_DEFAULT("TCSTART", tcstart);
1010 tcend = GET_DEFAULT("TCEND", tcend);
1011 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
1013 load_format_defaults(defaults);
1016 // FUTURE: put more of the format specific variables in here
1017 void Asset::load_format_defaults(Defaults *defaults) {
1018 char temp[BCTEXTLEN];
1019 char string[BCTEXTLEN];
1020 if (! format) return;
1022 // NOTE: old value is used if no init value set before GET_DEFAULT
1024 // override the defaults with those for this format
1025 sprintf(temp, "FORMAT_%s_USE_PIPE", FILE_FORMAT_PREFIX(format));
1027 use_pipe = GET_DEFAULT(temp, use_pipe);
1029 sprintf(temp, "FORMAT_%s_PIPE", FILE_FORMAT_PREFIX(format));
1031 GET_DEFAULT(temp, pipe);
1033 sprintf(temp, "FORMAT_%s_PATH", FILE_FORMAT_PREFIX(format));
1035 GET_DEFAULT(temp, path);
1039 void Asset::save_defaults(Defaults *defaults,
1047 char string[BCTEXTLEN];
1049 UPDATE_DEFAULT("PATH", path);
1053 UPDATE_DEFAULT("FORMAT", format);
1058 UPDATE_DEFAULT("AUDIO", audio_data);
1059 UPDATE_DEFAULT("VIDEO", video_data);
1064 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
1065 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
1070 UPDATE_DEFAULT("BITS", bits);
1071 UPDATE_DEFAULT("DITHER", dither);
1072 UPDATE_DEFAULT("SIGNED", signed_);
1073 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
1076 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
1077 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
1079 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
1080 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
1081 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
1082 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
1085 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
1086 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
1087 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
1088 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
1089 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
1090 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
1094 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
1095 UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
1096 UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
1102 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
1103 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
1104 UPDATE_DEFAULT("INTERLACE_AUTOFIXOPTION", interlace_autofixoption);
1105 UPDATE_DEFAULT("INTERLACE_MODE", interlace_mode);
1106 UPDATE_DEFAULT("INTERLACE_FIXMETHOD", interlace_fixmethod);
1109 // MPEG format information
1110 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
1111 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
1112 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
1113 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
1114 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
1115 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
1116 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
1117 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
1118 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
1119 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
1120 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
1121 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
1123 UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
1124 UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
1125 UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
1127 UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
1128 UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
1129 UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
1130 UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
1131 UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
1132 UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
1133 UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
1134 UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
1135 UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
1136 UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
1137 UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
1139 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
1140 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
1141 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
1142 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
1143 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
1144 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
1147 UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
1148 UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
1149 UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
1150 UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
1151 UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
1152 UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
1154 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
1157 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1158 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1159 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
1160 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1161 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1163 UPDATE_DEFAULT("REEL_NAME", reel_name);
1164 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
1165 UPDATE_DEFAULT("TCSTART", tcstart);
1166 UPDATE_DEFAULT("TCEND", tcend);
1167 UPDATE_DEFAULT("TCFORMAT", tcformat);
1169 save_format_defaults(defaults);
1173 // FUTURE: put more of the format specific variables in here
1174 void Asset::save_format_defaults(Defaults *defaults) {
1175 char temp[BCTEXTLEN];
1176 char string[BCTEXTLEN];
1177 if (! format) return;
1179 sprintf(temp, "FORMAT_%s_USE_PIPE", FILE_FORMAT_PREFIX(format));
1180 UPDATE_DEFAULT(temp, use_pipe);
1182 sprintf(temp, "FORMAT_%s_PIPE", FILE_FORMAT_PREFIX(format));
1183 UPDATE_DEFAULT(temp, pipe);
1185 sprintf(temp, "FORMAT_%s_PATH", FILE_FORMAT_PREFIX(format));
1186 UPDATE_DEFAULT(temp, path);
1190 int Asset::update_path(char *new_path)
1192 strcpy(path, new_path);
1196 void Asset::update_index(Asset *asset)
1198 //printf("Asset::update_index 1 %d\n", index_status);
1199 index_status = asset->index_status;
1200 index_zoom = asset->index_zoom; // zoom factor of index data
1201 index_start = asset->index_start; // byte start of index data in the index file
1202 index_bytes = asset->index_bytes; // Total bytes in source file for comparison before rebuilding the index
1203 index_end = asset->index_end;
1204 old_index_end = asset->old_index_end; // values for index build
1206 delete [] index_offsets;
1207 delete [] index_sizes;
1211 if(asset->index_offsets)
1213 index_offsets = new int64_t[asset->channels];
1214 index_sizes = new int64_t[asset->channels];
1217 for(i = 0; i < asset->channels; i++)
1219 // offsets of channels in index file in floats
1220 index_offsets[i] = asset->index_offsets[i];
1221 index_sizes[i] = asset->index_sizes[i];
1224 index_buffer = asset->index_buffer; // pointer
1227 int Asset::set_timecode(char *tc, int format, int end)
1231 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1232 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1233 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1235 // This needs to be modified to handle drop-frame
1238 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1240 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1248 printf(" asset::dump\n");
1249 printf(" %p %s\n", this, path);
1250 printf(" index_status %d\n", index_status);
1251 printf(" format %d\n", format);
1252 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",
1253 audio_data, channels, sample_rate, bits, byte_order, signed_, header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1254 printf(" audio_length %lld\n", audio_length);
1255 printf(" video_data %d layers %d framerate %f width %d height %d vcodec %c%c%c%c aspect_ratio %f\n",
1256 video_data, layers, frame_rate, width, height, vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio);
1257 printf(" video_length %lld \n", video_length);
1258 printf(" reel_name %s reel_number %i tcstart %d tcend %d tcf %d\n",
1259 reel_name, reel_number, tcstart, tcend, tcformat);