3 * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "awindowgui.h"
26 #include "bcsignals.h"
30 #include "filesystem.h"
32 #include "indexstate.h"
33 #include "interlacemodes.h"
40 : Indexable(1), ListItem<Asset>()
45 Asset::Asset(Asset &asset)
46 : Indexable(1), ListItem<Asset>()
49 this->copy_from(&asset, 1);
52 Asset::Asset(const char *path)
53 : Indexable(1), ListItem<Asset>()
56 strcpy(this->path, path);
59 Asset::Asset(const int plugin_type, const char *plugin_title)
60 : Indexable(1), ListItem<Asset>()
69 int Asset::init_values()
72 // Has to be unknown for file probing to succeed
73 format = FILE_UNKNOWN;
86 ff_audio_options[0] = 0;
87 ff_video_options[0] = 0;
94 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
95 interlace_mode = ILACE_MODE_UNDETECTED;
96 interlace_fixmethod = ILACE_FIXMETHOD_NONE;
102 vorbis_min_bitrate = -1;
103 vorbis_bitrate = 128000;
104 vorbis_max_bitrate = -1;
106 theora_fix_bitrate = 1;
107 theora_bitrate = 860000;
109 theora_sharpness = 2;
110 theora_keyframe_frequency = 64;
111 theora_keyframe_force_frequency = 64;
114 vmpeg_iframe_distance = 45;
115 vmpeg_pframe_distance = 0;
116 vmpeg_progressive = 0;
118 vmpeg_bitrate = 1000000;
119 vmpeg_derivative = 1;
120 vmpeg_quantization = 15;
121 vmpeg_cmodel = BC_YUV420P;
122 vmpeg_fix_bitrate = 0;
125 vmpeg_field_order = 0;
134 tiff_compression = 0;
143 void Asset::reset_audio()
151 void Asset::reset_video()
155 actual_width = width = 0;
156 actual_height = height = 0;
159 vmpeg_cmodel = BC_YUV420P;
165 void Asset::boundaries()
167 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
168 // sample_rate & frame_rate are user defined
169 // CLAMP(sample_rate, 1, 1000000);
170 // CLAMP(frame_rate, 0.001, 1000000);
171 CLAMP(channels, 0, 16);
172 CLAMP(width, 0, 10000);
173 CLAMP(height, 0, 10000);
174 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
177 int Asset::reset_timecode()
179 strcpy(reel_name, "cin0000");
188 void Asset::copy_from(Asset *asset, int do_index)
190 copy_location(asset);
191 copy_format(asset, do_index);
194 void Asset::copy_location(Asset *asset)
196 strcpy(path, asset->path);
197 awindow_folder = asset->awindow_folder;
200 void Asset::copy_format(Asset *asset, int do_index)
202 if(do_index) update_index(asset);
204 audio_data = asset->audio_data;
205 format = asset->format;
206 strcpy(fformat, asset->fformat);
207 channels = asset->channels;
208 sample_rate = asset->sample_rate;
210 byte_order = asset->byte_order;
211 signed_ = asset->signed_;
212 header = asset->header;
213 dither = asset->dither;
214 mp3_bitrate = asset->mp3_bitrate;
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 program = asset->program;
224 frame_rate = asset->frame_rate;
225 width = asset->width;
226 height = asset->height;
227 actual_width = asset->actual_width;
228 actual_height = asset->actual_height;
229 strcpy(vcodec, asset->vcodec);
230 strcpy(acodec, asset->acodec);
232 strcpy(ff_audio_options, asset->ff_audio_options);
233 strcpy(ff_video_options, asset->ff_video_options);
234 ff_audio_bitrate = asset->ff_audio_bitrate;
235 ff_video_bitrate = asset->ff_video_bitrate;
236 ff_video_quality = asset->ff_video_quality;
238 this->audio_length = asset->audio_length;
239 this->video_length = asset->video_length;
240 this->single_frame = asset->single_frame;
242 ampeg_bitrate = asset->ampeg_bitrate;
243 ampeg_derivative = asset->ampeg_derivative;
246 vorbis_vbr = asset->vorbis_vbr;
247 vorbis_min_bitrate = asset->vorbis_min_bitrate;
248 vorbis_bitrate = asset->vorbis_bitrate;
249 vorbis_max_bitrate = asset->vorbis_max_bitrate;
252 theora_fix_bitrate = asset->theora_fix_bitrate;
253 theora_bitrate = asset->theora_bitrate;
254 theora_quality = asset->theora_quality;
255 theora_sharpness = asset->theora_sharpness;
256 theora_keyframe_frequency = asset->theora_keyframe_frequency;
257 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
260 jpeg_quality = asset->jpeg_quality;
263 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
264 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
265 vmpeg_progressive = asset->vmpeg_progressive;
266 vmpeg_denoise = asset->vmpeg_denoise;
267 vmpeg_bitrate = asset->vmpeg_bitrate;
268 vmpeg_derivative = asset->vmpeg_derivative;
269 vmpeg_quantization = asset->vmpeg_quantization;
270 vmpeg_cmodel = asset->vmpeg_cmodel;
271 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
272 vmpeg_seq_codes = asset->vmpeg_seq_codes;
273 vmpeg_preset = asset->vmpeg_preset;
274 vmpeg_field_order = asset->vmpeg_field_order;
276 ac3_bitrate = asset->ac3_bitrate;
278 png_use_alpha = asset->png_use_alpha;
279 exr_use_alpha = asset->exr_use_alpha;
280 exr_compression = asset->exr_compression;
282 tiff_cmodel = asset->tiff_cmodel;
283 tiff_compression = asset->tiff_compression;
285 strcpy(reel_name, asset->reel_name);
286 reel_number = asset->reel_number;
287 tcstart = asset->tcstart;
288 tcend = asset->tcend;
289 tcformat = asset->tcformat;
292 int64_t Asset::get_index_offset(int channel)
294 return index_state->get_index_offset(channel);
297 int64_t Asset::get_index_size(int channel)
299 return index_state->get_index_size(channel);
303 char* Asset::get_compression_text(int audio, int video)
308 if( acodec[0] ) return acodec;
315 if( vcodec[0] ) return vcodec;
322 Asset& Asset::operator=(Asset &asset)
324 printf("Asset::operator=\n");
325 copy_location(&asset);
326 copy_format(&asset, 1);
331 int Asset::equivalent(Asset &asset,
335 int result = (!strcmp(asset.path, path) &&
336 format == asset.format);
338 if(result && format == FILE_FFMPEG)
339 result = !strcmp(fformat, asset.fformat);
341 if(test_audio && result)
343 result = (channels == asset.channels &&
344 sample_rate == asset.sample_rate &&
345 bits == asset.bits &&
346 byte_order == asset.byte_order &&
347 signed_ == asset.signed_ &&
348 header == asset.header &&
349 dither == asset.dither &&
350 !strcmp(acodec, asset.acodec));
351 if(result && format == FILE_FFMPEG)
352 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
353 ff_audio_bitrate == asset.ff_audio_bitrate;
358 if(test_video && result)
360 result = (layers == asset.layers &&
361 program == asset.program &&
362 frame_rate == asset.frame_rate &&
363 asset.interlace_autofixoption == interlace_autofixoption &&
364 asset.interlace_mode == interlace_mode &&
365 interlace_fixmethod == asset.interlace_fixmethod &&
366 width == asset.width &&
367 height == asset.height &&
368 !strcmp(vcodec, asset.vcodec) &&
369 strcmp(reel_name, asset.reel_name) == 0 &&
370 reel_number == asset.reel_number &&
371 tcstart == asset.tcstart &&
372 tcend == asset.tcend &&
373 tcformat == asset.tcformat);
374 if(result && format == FILE_FFMPEG)
375 result = !strcmp(ff_video_options, asset.ff_video_options) &&
376 ff_video_bitrate == asset.ff_video_bitrate &&
377 ff_video_quality == asset.ff_video_quality;
383 int Asset::operator==(Asset &asset)
386 return equivalent(asset,
391 int Asset::operator!=(Asset &asset)
393 return !(*this == asset);
396 int Asset::test_path(const char *path)
398 if(!strcasecmp(this->path, path))
404 int Asset::read(FileXML *file,
409 // Check for relative path.
412 char new_path[BCTEXTLEN];
413 char asset_directory[BCTEXTLEN];
414 char input_directory[BCTEXTLEN];
417 strcpy(new_path, path);
418 fs.set_current_dir("");
420 fs.extract_dir(asset_directory, path);
423 // Take path of XML file.
424 if(!asset_directory[0])
426 fs.extract_dir(input_directory, file->filename);
428 // Input file has a path
429 if(input_directory[0])
431 fs.join_names(path, input_directory, new_path);
439 result = file->read_tag();
442 if(file->tag.title_is("/ASSET"))
447 if(file->tag.title_is("AUDIO"))
452 if(file->tag.title_is("AUDIO_OMIT"))
457 if(file->tag.title_is("FORMAT"))
459 const char *string = file->tag.get_property("TYPE");
460 format = File::strtoformat(string);
462 file->tag.get_property("USE_HEADER", use_header);
463 file->tag.get_property("FFORMAT", fformat);
466 if(file->tag.title_is("FOLDER"))
468 const char *string = file->tag.get_property("NUMBER");
469 awindow_folder = string ? atoi(string) :
470 AWindowGUI::folder_number(file->read_text());
473 if(file->tag.title_is("VIDEO"))
478 if(file->tag.title_is("VIDEO_OMIT"))
483 if(file->tag.title_is("INDEX"))
491 //printf("Asset::read 2\n");
495 int Asset::read_audio(FileXML *file)
497 if(file->tag.title_is("AUDIO")) audio_data = 1;
498 channels = file->tag.get_property("CHANNELS", 2);
499 // This is loaded from the index file after the EDL but this
500 // should be overridable in the EDL.
501 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
502 bits = file->tag.get_property("BITS", 16);
503 byte_order = file->tag.get_property("BYTE_ORDER", 1);
504 signed_ = file->tag.get_property("SIGNED", 1);
505 header = file->tag.get_property("HEADER", 0);
506 dither = file->tag.get_property("DITHER", 0);
508 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
510 file->tag.get_property("ACODEC", acodec);
515 tcend = audio_length;
521 int Asset::read_video(FileXML *file)
523 char string[BCTEXTLEN];
525 if(file->tag.title_is("VIDEO")) video_data = 1;
526 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
527 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
528 height = file->tag.get_property("HEIGHT", height);
529 width = file->tag.get_property("WIDTH", width);
530 layers = file->tag.get_property("LAYERS", layers);
531 program = file->tag.get_property("PROGRAM", program);
532 // This is loaded from the index file after the EDL but this
533 // should be overridable in the EDL.
534 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
536 file->tag.get_property("VCODEC", vcodec);
538 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
539 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
541 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
543 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
544 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
546 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
547 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
549 file->tag.get_property("REEL_NAME", reel_name);
550 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
551 tcstart = file->tag.get_property("TCSTART", tcstart);
552 tcend = file->tag.get_property("TCEND", tcend);
553 tcformat = file->tag.get_property("TCFORMAT", tcformat);
558 int Asset::read_index(FileXML *file)
560 index_state->read_xml(file, channels);
564 // Output path is the path of the output file if name truncation is desired.
565 // It is a "" if complete names should be used.
567 int Asset::write(FileXML *file,
569 const char *output_path)
571 char new_path[BCTEXTLEN];
572 char asset_directory[BCTEXTLEN];
573 char output_directory[BCTEXTLEN];
576 // Make path relative
577 fs.extract_dir(asset_directory, path);
578 if(output_path && output_path[0])
579 fs.extract_dir(output_directory, output_path);
581 output_directory[0] = 0;
583 // Asset and EDL are in same directory. Extract just the name.
584 if(!strcmp(asset_directory, output_directory))
586 fs.extract_name(new_path, path);
590 strcpy(new_path, path);
593 file->tag.set_title("ASSET");
594 file->tag.set_property("SRC", new_path);
596 file->append_newline();
598 file->tag.set_title("FOLDER");
599 file->tag.set_property("NUMBER", awindow_folder);
601 file->tag.set_title("/FOLDER");
603 file->append_newline();
605 // Write the format information
606 file->tag.set_title("FORMAT");
608 file->tag.set_property("TYPE",
609 File::formattostr(format));
610 file->tag.set_property("USE_HEADER", use_header);
611 file->tag.set_property("FFORMAT", fformat);
614 file->tag.set_title("/FORMAT");
616 file->append_newline();
618 // Requiring data to exist caused batch render to lose settings.
619 // But the only way to know if an asset doesn't have audio or video data
620 // is to not write the block.
621 // So change the block name if the asset doesn't have the data.
624 // index goes after source
625 if(index_state->index_status == INDEX_READY && include_index)
628 file->tag.set_title("/ASSET");
630 file->append_newline();
634 int Asset::write_audio(FileXML *file)
636 // Let the reader know if the asset has the data by naming the block.
638 file->tag.set_title("AUDIO");
640 file->tag.set_title("AUDIO_OMIT");
641 // Necessary for PCM audio
642 file->tag.set_property("CHANNELS", channels);
643 file->tag.set_property("RATE", sample_rate);
644 file->tag.set_property("BITS", bits);
645 file->tag.set_property("BYTE_ORDER", byte_order);
646 file->tag.set_property("SIGNED", signed_);
647 file->tag.set_property("HEADER", header);
648 file->tag.set_property("DITHER", dither);
650 file->tag.set_property("ACODEC", acodec);
652 file->tag.set_property("AUDIO_LENGTH", audio_length);
656 // Rely on defaults operations for these.
658 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
659 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
661 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
662 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
663 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
664 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
666 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
673 file->tag.set_title("/AUDIO");
675 file->tag.set_title("/AUDIO_OMIT");
677 file->append_newline();
681 int Asset::write_video(FileXML *file)
683 char string[BCTEXTLEN];
686 file->tag.set_title("VIDEO");
688 file->tag.set_title("VIDEO_OMIT");
689 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
690 file->tag.set_property("ACTUAL_WIDTH", actual_width);
691 file->tag.set_property("HEIGHT", height);
692 file->tag.set_property("WIDTH", width);
693 file->tag.set_property("LAYERS", layers);
694 file->tag.set_property("PROGRAM", program);
695 file->tag.set_property("FRAMERATE", frame_rate);
697 file->tag.set_property("VCODEC", vcodec);
699 file->tag.set_property("VIDEO_LENGTH", video_length);
700 file->tag.set_property("SINGLE_FRAME", single_frame);
702 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
704 ilacemode_to_xmltext(string, interlace_mode);
705 file->tag.set_property("INTERLACE_MODE", string);
707 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
708 file->tag.set_property("INTERLACE_FIXMETHOD", string);
711 file->tag.set_property("REEL_NAME", reel_name);
712 file->tag.set_property("REEL_NUMBER", reel_number);
713 file->tag.set_property("TCSTART", tcstart);
714 file->tag.set_property("TCEND", tcend);
715 file->tag.set_property("TCFORMAT", tcformat);
719 file->tag.set_title("/VIDEO");
721 file->tag.set_title("/VIDEO_OMIT");
724 file->append_newline();
728 int Asset::write_index(FileXML *file)
730 index_state->write_xml(file);
735 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
738 sprintf(return_value, "%s%s", prefix, param);
740 strcpy(return_value, param);
744 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
745 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
747 void Asset::load_defaults(BC_Hash *defaults,
755 char string[BCTEXTLEN];
757 // Can't save codec here because it's specific to render, record, and effect.
758 // The codec has to be UNKNOWN for file probing to work.
762 GET_DEFAULT("PATH", path);
767 GET_DEFAULT("AUDIO_CODEC", acodec);
768 GET_DEFAULT("VIDEO_CODEC", vcodec);
773 format = GET_DEFAULT("FORMAT", format);
774 use_header = GET_DEFAULT("USE_HEADER", use_header);
775 GET_DEFAULT("FFORMAT", fformat);
780 audio_data = GET_DEFAULT("AUDIO", 1);
781 video_data = GET_DEFAULT("VIDEO", 1);
786 bits = GET_DEFAULT("BITS", 16);
787 dither = GET_DEFAULT("DITHER", 0);
788 signed_ = GET_DEFAULT("SIGNED", 1);
789 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
793 channels = GET_DEFAULT("CHANNELS", 2);
794 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
795 header = GET_DEFAULT("HEADER", 0);
796 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
800 height = GET_DEFAULT("HEIGHT", height);
801 width = GET_DEFAULT("WIDTH", width);
802 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
803 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
804 program = GET_DEFAULT("PROGRAM", program);
805 layers = GET_DEFAULT("LAYERS", layers);
806 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
807 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
808 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
811 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
812 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
814 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
815 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
816 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
817 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
819 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
820 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
821 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
822 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
823 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
824 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
826 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
827 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
828 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
829 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
830 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
832 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
834 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
835 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
837 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
838 interlace_mode = ILACE_MODE_UNDETECTED;
839 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
841 // MPEG format information
842 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
843 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
844 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
845 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
846 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
847 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
848 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
849 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
850 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
851 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
852 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
853 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
855 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
856 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
857 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
858 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
859 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
860 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
863 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
865 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
866 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
867 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
868 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
869 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
871 GET_DEFAULT("REEL_NAME", reel_name);
872 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
873 tcstart = GET_DEFAULT("TCSTART", tcstart);
874 tcend = GET_DEFAULT("TCEND", tcend);
875 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
880 void Asset::save_defaults(BC_Hash *defaults,
888 char string[BCTEXTLEN];
890 UPDATE_DEFAULT("PATH", path);
897 UPDATE_DEFAULT("FORMAT", format);
898 UPDATE_DEFAULT("USE_HEADER", use_header);
899 UPDATE_DEFAULT("FFORMAT", fformat);
904 UPDATE_DEFAULT("AUDIO", audio_data);
905 UPDATE_DEFAULT("VIDEO", video_data);
910 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
911 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
913 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
914 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
916 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
917 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
918 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
919 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
921 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
922 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
923 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
924 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
925 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
927 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
928 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
929 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
930 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
931 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
932 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
936 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
938 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
939 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
941 // MPEG format information
942 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
943 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
944 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
945 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
946 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
947 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
948 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
949 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
950 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
951 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
952 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
953 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
956 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
959 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
960 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
961 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
962 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
963 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
968 UPDATE_DEFAULT("BITS", bits);
969 UPDATE_DEFAULT("DITHER", dither);
970 UPDATE_DEFAULT("SIGNED", signed_);
971 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
978 UPDATE_DEFAULT("CHANNELS", channels);
979 UPDATE_DEFAULT("RATE", sample_rate);
980 UPDATE_DEFAULT("HEADER", header);
981 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
985 UPDATE_DEFAULT("HEIGHT", height);
986 UPDATE_DEFAULT("WIDTH", width);
987 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
988 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
989 UPDATE_DEFAULT("PROGRAM", program);
990 UPDATE_DEFAULT("LAYERS", layers);
991 UPDATE_DEFAULT("FRAMERATE", frame_rate);
992 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
993 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
997 UPDATE_DEFAULT("REEL_NAME", reel_name);
998 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
999 UPDATE_DEFAULT("TCSTART", tcstart);
1000 UPDATE_DEFAULT("TCEND", tcend);
1001 UPDATE_DEFAULT("TCFORMAT", tcformat);
1012 int Asset::dump(FILE *fp)
1014 fprintf(fp," asset::dump\n");
1015 fprintf(fp," this=%p path=%s\n", this, path);
1016 fprintf(fp," index_status %d\n", index_state->index_status);
1017 fprintf(fp," format %d\n", format);
1018 fprintf(fp," fformat=\"%s\"\n", fformat);
1019 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1020 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1021 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1022 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1023 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1024 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1025 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
1026 audio_data, channels, sample_rate, bits, byte_order, signed_,
1027 header, dither, acodec);
1028 fprintf(fp," audio_length %jd\n", audio_length);
1029 char string[BCTEXTLEN];
1030 ilacemode_to_xmltext(string, interlace_mode);
1031 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1032 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
1033 video_data, layers, program, frame_rate, width, height,
1034 vcodec, aspect_ratio,string);
1035 fprintf(fp," reel_name %s reel_number %i tcstart %jd tcend %jd tcf %d\n",
1036 reel_name, reel_number, tcstart, tcend, tcformat);
1037 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
1045 int Asset::get_audio_channels()
1050 int Asset::get_sample_rate()
1055 int64_t Asset::get_audio_samples()
1057 return audio_length;
1060 int Asset::have_audio()
1065 int Asset::have_video()
1080 double Asset::get_frame_rate()
1086 int Asset::get_video_layers()
1091 int Asset::get_program()
1096 int64_t Asset::get_video_frames()
1098 return video_length;
1101 double Asset::total_length_framealigned(double fps)
1103 if (video_data && audio_data) {
1104 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1105 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1106 return MIN(aud,vid);
1110 return (double)audio_length / sample_rate;
1113 return (double)video_length / frame_rate;
1118 int Asset::set_timecode(char *tc, int format, int end)
1122 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1123 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1124 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1126 // This needs to be modified to handle drop-frame
1129 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1131 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);