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
25 #include "bcsignals.h"
29 #include "filesystem.h"
31 #include "indexstate.h"
32 #include "interlacemodes.h"
39 : Indexable(1), ListItem<Asset>()
44 Asset::Asset(Asset &asset)
45 : Indexable(1), ListItem<Asset>()
48 this->copy_from(&asset, 1);
51 Asset::Asset(const char *path)
52 : Indexable(1), ListItem<Asset>()
55 strcpy(this->path, path);
58 Asset::Asset(const int plugin_type, const char *plugin_title)
59 : Indexable(1), ListItem<Asset>()
68 int Asset::init_values()
71 // Has to be unknown for file probing to succeed
72 format = FILE_UNKNOWN;
85 ff_audio_options[0] = 0;
86 ff_video_options[0] = 0;
93 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
94 interlace_mode = BC_ILACE_MODE_UNDETECTED;
95 interlace_fixmethod = BC_ILACE_FIXMETHOD_NONE;
101 vorbis_min_bitrate = -1;
102 vorbis_bitrate = 128000;
103 vorbis_max_bitrate = -1;
105 theora_fix_bitrate = 1;
106 theora_bitrate = 860000;
108 theora_sharpness = 2;
109 theora_keyframe_frequency = 64;
110 theora_keyframe_force_frequency = 64;
113 vmpeg_iframe_distance = 45;
114 vmpeg_pframe_distance = 0;
115 vmpeg_progressive = 0;
117 vmpeg_bitrate = 1000000;
118 vmpeg_derivative = 1;
119 vmpeg_quantization = 15;
120 vmpeg_cmodel = BC_YUV420P;
121 vmpeg_fix_bitrate = 0;
124 vmpeg_field_order = 0;
133 tiff_compression = 0;
142 void Asset::reset_audio()
150 void Asset::reset_video()
154 actual_width = width = 0;
155 actual_height = height = 0;
157 vmpeg_cmodel = BC_YUV420P;
163 void Asset::boundaries()
165 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
166 // sample_rate & frame_rate are user defined
167 // CLAMP(sample_rate, 1, 1000000);
168 // CLAMP(frame_rate, 0.001, 1000000);
169 CLAMP(channels, 0, 16);
170 CLAMP(width, 0, 10000);
171 CLAMP(height, 0, 10000);
172 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
175 int Asset::reset_timecode()
177 strcpy(reel_name, "cin0000");
186 void Asset::copy_from(Asset *asset, int do_index)
188 copy_location(asset);
189 copy_format(asset, do_index);
192 void Asset::copy_location(Asset *asset)
194 strcpy(this->path, asset->path);
195 strcpy(this->folder, asset->folder);
198 void Asset::copy_format(Asset *asset, int do_index)
200 if(do_index) update_index(asset);
202 audio_data = asset->audio_data;
203 format = asset->format;
204 strcpy(fformat, asset->fformat);
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 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 program = asset->program;
222 frame_rate = asset->frame_rate;
223 width = asset->width;
224 height = asset->height;
225 actual_width = asset->actual_width;
226 actual_height = asset->actual_height;
227 strcpy(vcodec, asset->vcodec);
228 strcpy(acodec, asset->acodec);
230 strcpy(ff_audio_options, asset->ff_audio_options);
231 strcpy(ff_video_options, asset->ff_video_options);
232 ff_audio_bitrate = asset->ff_audio_bitrate;
233 ff_video_bitrate = asset->ff_video_bitrate;
234 ff_video_quality = asset->ff_video_quality;
236 this->audio_length = asset->audio_length;
237 this->video_length = asset->video_length;
240 ampeg_bitrate = asset->ampeg_bitrate;
241 ampeg_derivative = asset->ampeg_derivative;
244 vorbis_vbr = asset->vorbis_vbr;
245 vorbis_min_bitrate = asset->vorbis_min_bitrate;
246 vorbis_bitrate = asset->vorbis_bitrate;
247 vorbis_max_bitrate = asset->vorbis_max_bitrate;
250 theora_fix_bitrate = asset->theora_fix_bitrate;
251 theora_bitrate = asset->theora_bitrate;
252 theora_quality = asset->theora_quality;
253 theora_sharpness = asset->theora_sharpness;
254 theora_keyframe_frequency = asset->theora_keyframe_frequency;
255 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
258 jpeg_quality = asset->jpeg_quality;
261 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
262 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
263 vmpeg_progressive = asset->vmpeg_progressive;
264 vmpeg_denoise = asset->vmpeg_denoise;
265 vmpeg_bitrate = asset->vmpeg_bitrate;
266 vmpeg_derivative = asset->vmpeg_derivative;
267 vmpeg_quantization = asset->vmpeg_quantization;
268 vmpeg_cmodel = asset->vmpeg_cmodel;
269 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
270 vmpeg_seq_codes = asset->vmpeg_seq_codes;
271 vmpeg_preset = asset->vmpeg_preset;
272 vmpeg_field_order = asset->vmpeg_field_order;
274 ac3_bitrate = asset->ac3_bitrate;
276 png_use_alpha = asset->png_use_alpha;
277 exr_use_alpha = asset->exr_use_alpha;
278 exr_compression = asset->exr_compression;
280 tiff_cmodel = asset->tiff_cmodel;
281 tiff_compression = asset->tiff_compression;
283 strcpy(reel_name, asset->reel_name);
284 reel_number = asset->reel_number;
285 tcstart = asset->tcstart;
286 tcend = asset->tcend;
287 tcformat = asset->tcformat;
290 int64_t Asset::get_index_offset(int channel)
292 return index_state->get_index_offset(channel);
295 int64_t Asset::get_index_size(int channel)
297 return index_state->get_index_size(channel);
301 char* Asset::get_compression_text(int audio, int video)
306 if( acodec[0] ) return acodec;
313 if( vcodec[0] ) return vcodec;
320 Asset& Asset::operator=(Asset &asset)
322 printf("Asset::operator=\n");
323 copy_location(&asset);
324 copy_format(&asset, 1);
329 int Asset::equivalent(Asset &asset,
333 int result = (!strcmp(asset.path, path) &&
334 format == asset.format);
336 if(result && format == FILE_FFMPEG)
337 result = !strcmp(fformat, asset.fformat);
339 if(test_audio && result)
341 result = (channels == asset.channels &&
342 sample_rate == asset.sample_rate &&
343 bits == asset.bits &&
344 byte_order == asset.byte_order &&
345 signed_ == asset.signed_ &&
346 header == asset.header &&
347 dither == asset.dither &&
348 !strcmp(acodec, asset.acodec));
349 if(result && format == FILE_FFMPEG)
350 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
351 ff_audio_bitrate == asset.ff_audio_bitrate;
356 if(test_video && result)
358 result = (layers == asset.layers &&
359 program == asset.program &&
360 frame_rate == asset.frame_rate &&
361 asset.interlace_autofixoption == interlace_autofixoption &&
362 asset.interlace_mode == interlace_mode &&
363 interlace_fixmethod == asset.interlace_fixmethod &&
364 width == asset.width &&
365 height == asset.height &&
366 !strcmp(vcodec, asset.vcodec) &&
367 strcmp(reel_name, asset.reel_name) == 0 &&
368 reel_number == asset.reel_number &&
369 tcstart == asset.tcstart &&
370 tcend == asset.tcend &&
371 tcformat == asset.tcformat);
372 if(result && format == FILE_FFMPEG)
373 result = !strcmp(ff_video_options, asset.ff_video_options) &&
374 ff_video_bitrate == asset.ff_video_bitrate &&
375 ff_video_quality == asset.ff_video_quality;
381 int Asset::operator==(Asset &asset)
384 return equivalent(asset,
389 int Asset::operator!=(Asset &asset)
391 return !(*this == asset);
394 int Asset::test_path(const char *path)
396 if(!strcasecmp(this->path, path))
402 int Asset::read(FileXML *file,
407 // Check for relative path.
410 char new_path[BCTEXTLEN];
411 char asset_directory[BCTEXTLEN];
412 char input_directory[BCTEXTLEN];
415 strcpy(new_path, path);
416 fs.set_current_dir("");
418 fs.extract_dir(asset_directory, path);
421 // Take path of XML file.
422 if(!asset_directory[0])
424 fs.extract_dir(input_directory, file->filename);
426 // Input file has a path
427 if(input_directory[0])
429 fs.join_names(path, input_directory, new_path);
437 result = file->read_tag();
440 if(file->tag.title_is("/ASSET"))
445 if(file->tag.title_is("AUDIO"))
450 if(file->tag.title_is("AUDIO_OMIT"))
455 if(file->tag.title_is("FORMAT"))
457 const char *string = file->tag.get_property("TYPE");
458 format = File::strtoformat(string);
460 file->tag.get_property("USE_HEADER", use_header);
461 file->tag.get_property("FFORMAT", fformat);
464 if(file->tag.title_is("FOLDER"))
466 strcpy(folder, file->read_text());
469 if(file->tag.title_is("VIDEO"))
474 if(file->tag.title_is("VIDEO_OMIT"))
479 if(file->tag.title_is("INDEX"))
487 //printf("Asset::read 2\n");
491 int Asset::read_audio(FileXML *file)
493 if(file->tag.title_is("AUDIO")) audio_data = 1;
494 channels = file->tag.get_property("CHANNELS", 2);
495 // This is loaded from the index file after the EDL but this
496 // should be overridable in the EDL.
497 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
498 bits = file->tag.get_property("BITS", 16);
499 byte_order = file->tag.get_property("BYTE_ORDER", 1);
500 signed_ = file->tag.get_property("SIGNED", 1);
501 header = file->tag.get_property("HEADER", 0);
502 dither = file->tag.get_property("DITHER", 0);
504 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
506 file->tag.get_property("ACODEC", acodec);
511 tcend = audio_length;
517 int Asset::read_video(FileXML *file)
519 char string[BCTEXTLEN];
521 if(file->tag.title_is("VIDEO")) video_data = 1;
522 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
523 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
524 height = file->tag.get_property("HEIGHT", height);
525 width = file->tag.get_property("WIDTH", width);
526 layers = file->tag.get_property("LAYERS", layers);
527 program = file->tag.get_property("PROGRAM", program);
528 // This is loaded from the index file after the EDL but this
529 // should be overridable in the EDL.
530 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
532 file->tag.get_property("VCODEC", vcodec);
534 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
536 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
538 ilacemode_to_xmltext(string, BC_ILACE_MODE_NOTINTERLACED);
539 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), BC_ILACE_MODE_NOTINTERLACED);
541 ilacefixmethod_to_xmltext(string, BC_ILACE_FIXMETHOD_NONE);
542 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), BC_ILACE_FIXMETHOD_NONE);
544 file->tag.get_property("REEL_NAME", reel_name);
545 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
546 tcstart = file->tag.get_property("TCSTART", tcstart);
547 tcend = file->tag.get_property("TCEND", tcend);
548 tcformat = file->tag.get_property("TCFORMAT", tcformat);
553 int Asset::read_index(FileXML *file)
555 index_state->read_xml(file, channels);
559 // Output path is the path of the output file if name truncation is desired.
560 // It is a "" if complete names should be used.
562 int Asset::write(FileXML *file,
564 const char *output_path)
566 char new_path[BCTEXTLEN];
567 char asset_directory[BCTEXTLEN];
568 char output_directory[BCTEXTLEN];
571 // Make path relative
572 fs.extract_dir(asset_directory, path);
573 if(output_path && output_path[0])
574 fs.extract_dir(output_directory, output_path);
576 output_directory[0] = 0;
578 // Asset and EDL are in same directory. Extract just the name.
579 if(!strcmp(asset_directory, output_directory))
581 fs.extract_name(new_path, path);
585 strcpy(new_path, path);
588 file->tag.set_title("ASSET");
589 file->tag.set_property("SRC", new_path);
591 file->append_newline();
593 file->tag.set_title("FOLDER");
595 file->append_text(folder);
596 file->tag.set_title("/FOLDER");
598 file->append_newline();
600 // Write the format information
601 file->tag.set_title("FORMAT");
603 file->tag.set_property("TYPE",
604 File::formattostr(format));
605 file->tag.set_property("USE_HEADER", use_header);
606 file->tag.set_property("FFORMAT", fformat);
609 file->tag.set_title("/FORMAT");
611 file->append_newline();
613 // Requiring data to exist caused batch render to lose settings.
614 // But the only way to know if an asset doesn't have audio or video data
615 // is to not write the block.
616 // So change the block name if the asset doesn't have the data.
619 // index goes after source
620 if(index_state->index_status == INDEX_READY && include_index)
623 file->tag.set_title("/ASSET");
625 file->append_newline();
629 int Asset::write_audio(FileXML *file)
631 // Let the reader know if the asset has the data by naming the block.
633 file->tag.set_title("AUDIO");
635 file->tag.set_title("AUDIO_OMIT");
636 // Necessary for PCM audio
637 file->tag.set_property("CHANNELS", channels);
638 file->tag.set_property("RATE", sample_rate);
639 file->tag.set_property("BITS", bits);
640 file->tag.set_property("BYTE_ORDER", byte_order);
641 file->tag.set_property("SIGNED", signed_);
642 file->tag.set_property("HEADER", header);
643 file->tag.set_property("DITHER", dither);
645 file->tag.set_property("ACODEC", acodec);
647 file->tag.set_property("AUDIO_LENGTH", audio_length);
651 // Rely on defaults operations for these.
653 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
654 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
656 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
657 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
658 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
659 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
661 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
668 file->tag.set_title("/AUDIO");
670 file->tag.set_title("/AUDIO_OMIT");
672 file->append_newline();
676 int Asset::write_video(FileXML *file)
678 char string[BCTEXTLEN];
681 file->tag.set_title("VIDEO");
683 file->tag.set_title("VIDEO_OMIT");
684 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
685 file->tag.set_property("ACTUAL_WIDTH", actual_width);
686 file->tag.set_property("HEIGHT", height);
687 file->tag.set_property("WIDTH", width);
688 file->tag.set_property("LAYERS", layers);
689 file->tag.set_property("PROGRAM", program);
690 file->tag.set_property("FRAMERATE", frame_rate);
692 file->tag.set_property("VCODEC", vcodec);
694 file->tag.set_property("VIDEO_LENGTH", video_length);
696 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
698 ilacemode_to_xmltext(string, interlace_mode);
699 file->tag.set_property("INTERLACE_MODE", string);
701 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
702 file->tag.set_property("INTERLACE_FIXMETHOD", string);
705 file->tag.set_property("REEL_NAME", reel_name);
706 file->tag.set_property("REEL_NUMBER", reel_number);
707 file->tag.set_property("TCSTART", tcstart);
708 file->tag.set_property("TCEND", tcend);
709 file->tag.set_property("TCFORMAT", tcformat);
713 file->tag.set_title("/VIDEO");
715 file->tag.set_title("/VIDEO_OMIT");
718 file->append_newline();
722 int Asset::write_index(FileXML *file)
724 index_state->write_xml(file);
729 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
732 sprintf(return_value, "%s%s", prefix, param);
734 strcpy(return_value, param);
738 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
739 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
741 void Asset::load_defaults(BC_Hash *defaults,
749 char string[BCTEXTLEN];
751 // Can't save codec here because it's specific to render, record, and effect.
752 // The codec has to be UNKNOWN for file probing to work.
756 GET_DEFAULT("PATH", path);
761 GET_DEFAULT("AUDIO_CODEC", acodec);
762 GET_DEFAULT("VIDEO_CODEC", vcodec);
767 format = GET_DEFAULT("FORMAT", format);
768 use_header = GET_DEFAULT("USE_HEADER", use_header);
769 GET_DEFAULT("FFORMAT", fformat);
774 audio_data = GET_DEFAULT("AUDIO", 1);
775 video_data = GET_DEFAULT("VIDEO", 1);
780 bits = GET_DEFAULT("BITS", 16);
781 dither = GET_DEFAULT("DITHER", 0);
782 signed_ = GET_DEFAULT("SIGNED", 1);
783 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
787 channels = GET_DEFAULT("CHANNELS", 2);
788 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
789 header = GET_DEFAULT("HEADER", 0);
790 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
794 height = GET_DEFAULT("HEIGHT", height);
795 width = GET_DEFAULT("WIDTH", width);
796 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
797 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
798 program = GET_DEFAULT("PROGRAM", program);
799 layers = GET_DEFAULT("LAYERS", layers);
800 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
801 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
804 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
805 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
807 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
808 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
809 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
810 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
812 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
813 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
814 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
815 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
816 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
817 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
819 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
820 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
821 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
822 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
823 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
825 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
827 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
828 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
830 interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
831 interlace_mode = BC_ILACE_MODE_UNDETECTED;
832 interlace_fixmethod = BC_ILACE_FIXMETHOD_UPONE;
834 // MPEG format information
835 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
836 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
837 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
838 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
839 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
840 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
841 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
842 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
843 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
844 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
845 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
846 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
848 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
849 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
850 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
851 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
852 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
853 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
856 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
858 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
859 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
860 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
861 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
862 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
864 GET_DEFAULT("REEL_NAME", reel_name);
865 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
866 tcstart = GET_DEFAULT("TCSTART", tcstart);
867 tcend = GET_DEFAULT("TCEND", tcend);
868 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
873 void Asset::save_defaults(BC_Hash *defaults,
881 char string[BCTEXTLEN];
883 UPDATE_DEFAULT("PATH", path);
890 UPDATE_DEFAULT("FORMAT", format);
891 UPDATE_DEFAULT("USE_HEADER", use_header);
892 UPDATE_DEFAULT("FFORMAT", fformat);
897 UPDATE_DEFAULT("AUDIO", audio_data);
898 UPDATE_DEFAULT("VIDEO", video_data);
903 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
904 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
906 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
907 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
909 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
910 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
911 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
912 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
914 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
915 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
916 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
917 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
918 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
920 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
921 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
922 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
923 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
924 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
925 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
929 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
931 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
932 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
934 // MPEG format information
935 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
936 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
937 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
938 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
939 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
940 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
941 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
942 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
943 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
944 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
945 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
946 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
949 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
952 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
953 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
954 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
955 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
956 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
961 UPDATE_DEFAULT("BITS", bits);
962 UPDATE_DEFAULT("DITHER", dither);
963 UPDATE_DEFAULT("SIGNED", signed_);
964 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
971 UPDATE_DEFAULT("CHANNELS", channels);
972 UPDATE_DEFAULT("RATE", sample_rate);
973 UPDATE_DEFAULT("HEADER", header);
974 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
978 UPDATE_DEFAULT("HEIGHT", height);
979 UPDATE_DEFAULT("WIDTH", width);
980 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
981 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
982 UPDATE_DEFAULT("PROGRAM", program);
983 UPDATE_DEFAULT("LAYERS", layers);
984 UPDATE_DEFAULT("FRAMERATE", frame_rate);
985 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
989 UPDATE_DEFAULT("REEL_NAME", reel_name);
990 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
991 UPDATE_DEFAULT("TCSTART", tcstart);
992 UPDATE_DEFAULT("TCEND", tcend);
993 UPDATE_DEFAULT("TCFORMAT", tcformat);
1004 int Asset::dump(FILE *fp)
1006 fprintf(fp," asset::dump\n");
1007 fprintf(fp," this=%p path=%s\n", this, path);
1008 fprintf(fp," index_status %d\n", index_state->index_status);
1009 fprintf(fp," format %d\n", format);
1010 fprintf(fp," fformat=\"%s\"\n", fformat);
1011 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1012 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1013 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1014 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1015 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1016 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1017 " byte_order %d signed %d header %d dither %d acodec %c%c%c%c\n",
1018 audio_data, channels, sample_rate, bits, byte_order, signed_,
1019 header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1020 fprintf(fp," audio_length %jd\n", audio_length);
1021 char string[BCTEXTLEN];
1022 ilacemode_to_xmltext(string, interlace_mode);
1023 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1024 " height %d vcodec %c%c%c%c aspect_ratio %f ilace_mode %s\n",
1025 video_data, layers, program, frame_rate, width, height,
1026 vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio,string);
1027 printf(" reel_name %s reel_number %i tcstart %jd tcend %jd tcf %d\n",
1028 reel_name, reel_number, tcstart, tcend, tcformat);
1029 fprintf(fp," video_length %jd \n", video_length);
1037 int Asset::get_audio_channels()
1042 int Asset::get_sample_rate()
1047 int64_t Asset::get_audio_samples()
1049 return audio_length;
1052 int Asset::have_audio()
1057 int Asset::have_video()
1072 double Asset::get_frame_rate()
1078 int Asset::get_video_layers()
1083 int Asset::get_program()
1088 int64_t Asset::get_video_frames()
1090 return video_length;
1093 double Asset::total_length_framealigned(double fps)
1095 if (video_data && audio_data) {
1096 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1097 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1098 return MIN(aud,vid);
1102 return (double)audio_length / sample_rate;
1105 return (double)video_length / frame_rate;
1110 int Asset::set_timecode(char *tc, int format, int end)
1114 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1115 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1116 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1118 // This needs to be modified to handle drop-frame
1121 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1123 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);