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"
31 #include "filesystem.h"
33 #include "indexstate.h"
34 #include "interlacemodes.h"
41 : Indexable(1), ListItem<Asset>()
46 Asset::Asset(Asset &asset)
47 : Indexable(1), ListItem<Asset>()
50 this->copy_from(&asset, 1);
53 Asset::Asset(const char *path)
54 : Indexable(1), ListItem<Asset>()
57 strcpy(this->path, path);
60 Asset::Asset(const int plugin_type, const char *plugin_title)
61 : Indexable(1), ListItem<Asset>()
70 int Asset::init_values()
73 // Has to be unknown for file probing to succeed
74 format = FILE_UNKNOWN;
87 ff_audio_options[0] = 0;
88 ff_video_options[0] = 0;
91 ff_video_quality = -1;
95 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
96 interlace_mode = ILACE_MODE_UNDETECTED;
97 interlace_fixmethod = ILACE_FIXMETHOD_NONE;
100 ampeg_derivative = 3;
103 vorbis_min_bitrate = -1;
104 vorbis_bitrate = 128000;
105 vorbis_max_bitrate = -1;
107 theora_fix_bitrate = 1;
108 theora_bitrate = 860000;
110 theora_sharpness = 2;
111 theora_keyframe_frequency = 64;
112 theora_keyframe_force_frequency = 64;
115 vmpeg_iframe_distance = 45;
116 vmpeg_pframe_distance = 0;
117 vmpeg_progressive = 0;
119 vmpeg_bitrate = 1000000;
120 vmpeg_derivative = 1;
121 vmpeg_quantization = 15;
122 vmpeg_cmodel = BC_YUV420P;
123 vmpeg_fix_bitrate = 0;
126 vmpeg_field_order = 0;
135 tiff_compression = 0;
144 void Asset::reset_audio()
152 void Asset::reset_video()
156 actual_width = width = 0;
157 actual_height = height = 0;
160 vmpeg_cmodel = BC_YUV420P;
166 void Asset::boundaries()
168 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
169 // sample_rate & frame_rate are user defined
170 // CLAMP(sample_rate, 1, 1000000);
171 // CLAMP(frame_rate, 0.001, 1000000);
172 CLAMP(channels, 0, 16);
173 CLAMP(width, 0, 10000);
174 CLAMP(height, 0, 10000);
175 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
178 int Asset::reset_timecode()
180 strcpy(reel_name, "cin0000");
189 void Asset::copy_from(Asset *asset, int do_index)
191 copy_location(asset);
192 copy_format(asset, do_index);
195 void Asset::copy_location(Asset *asset)
197 strcpy(path, asset->path);
198 awindow_folder = asset->awindow_folder;
201 void Asset::copy_format(Asset *asset, int do_index)
203 if(do_index) update_index(asset);
205 audio_data = asset->audio_data;
206 format = asset->format;
207 strcpy(fformat, asset->fformat);
208 channels = asset->channels;
209 sample_rate = asset->sample_rate;
211 byte_order = asset->byte_order;
212 signed_ = asset->signed_;
213 header = asset->header;
214 dither = asset->dither;
215 mp3_bitrate = asset->mp3_bitrate;
216 use_header = asset->use_header;
217 aspect_ratio = asset->aspect_ratio;
218 interlace_autofixoption = asset->interlace_autofixoption;
219 interlace_mode = asset->interlace_mode;
220 interlace_fixmethod = asset->interlace_fixmethod;
222 video_data = asset->video_data;
223 layers = asset->layers;
224 program = asset->program;
225 frame_rate = asset->frame_rate;
226 width = asset->width;
227 height = asset->height;
228 actual_width = asset->actual_width;
229 actual_height = asset->actual_height;
230 strcpy(vcodec, asset->vcodec);
231 strcpy(acodec, asset->acodec);
233 strcpy(ff_audio_options, asset->ff_audio_options);
234 strcpy(ff_video_options, asset->ff_video_options);
235 ff_audio_bitrate = asset->ff_audio_bitrate;
236 ff_video_bitrate = asset->ff_video_bitrate;
237 ff_video_quality = asset->ff_video_quality;
239 this->audio_length = asset->audio_length;
240 this->video_length = asset->video_length;
241 this->single_frame = asset->single_frame;
243 ampeg_bitrate = asset->ampeg_bitrate;
244 ampeg_derivative = asset->ampeg_derivative;
247 vorbis_vbr = asset->vorbis_vbr;
248 vorbis_min_bitrate = asset->vorbis_min_bitrate;
249 vorbis_bitrate = asset->vorbis_bitrate;
250 vorbis_max_bitrate = asset->vorbis_max_bitrate;
253 theora_fix_bitrate = asset->theora_fix_bitrate;
254 theora_bitrate = asset->theora_bitrate;
255 theora_quality = asset->theora_quality;
256 theora_sharpness = asset->theora_sharpness;
257 theora_keyframe_frequency = asset->theora_keyframe_frequency;
258 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
261 jpeg_quality = asset->jpeg_quality;
264 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
265 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
266 vmpeg_progressive = asset->vmpeg_progressive;
267 vmpeg_denoise = asset->vmpeg_denoise;
268 vmpeg_bitrate = asset->vmpeg_bitrate;
269 vmpeg_derivative = asset->vmpeg_derivative;
270 vmpeg_quantization = asset->vmpeg_quantization;
271 vmpeg_cmodel = asset->vmpeg_cmodel;
272 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
273 vmpeg_seq_codes = asset->vmpeg_seq_codes;
274 vmpeg_preset = asset->vmpeg_preset;
275 vmpeg_field_order = asset->vmpeg_field_order;
277 ac3_bitrate = asset->ac3_bitrate;
279 png_use_alpha = asset->png_use_alpha;
280 exr_use_alpha = asset->exr_use_alpha;
281 exr_compression = asset->exr_compression;
283 tiff_cmodel = asset->tiff_cmodel;
284 tiff_compression = asset->tiff_compression;
286 strcpy(reel_name, asset->reel_name);
287 reel_number = asset->reel_number;
288 tcstart = asset->tcstart;
289 tcend = asset->tcend;
290 tcformat = asset->tcformat;
293 int64_t Asset::get_index_offset(int channel)
295 return index_state->get_index_offset(channel);
298 int64_t Asset::get_index_size(int channel)
300 return index_state->get_index_size(channel);
304 char* Asset::get_compression_text(int audio, int video)
309 if( acodec[0] ) return acodec;
316 if( vcodec[0] ) return vcodec;
323 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
325 int result = format == asset.format ? 1 : 0;
326 if( result && strcmp(asset.path, path) ) {
327 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
328 char *sp = out_path ? strrchr(out_path,'/') : 0;
330 char *apath = FileSystem::basepath(asset.path);
331 char *tpath = FileSystem::basepath(this->path);
333 if( *apath != '/' ) {
334 char *cp = cstrcat(2, out_path, apath);
335 delete [] apath; apath = FileSystem::basepath(cp);
338 if( *tpath != '/' ) {
339 char *cp = cstrcat(2, out_path, tpath);
340 delete [] tpath; tpath = FileSystem::basepath(cp);
344 if( strcmp(apath, tpath) ) result = 1;
350 if(result && format == FILE_FFMPEG)
351 result = !strcmp(fformat, asset.fformat);
353 if(test_audio && result)
355 result = (channels == asset.channels &&
356 sample_rate == asset.sample_rate &&
357 bits == asset.bits &&
358 byte_order == asset.byte_order &&
359 signed_ == asset.signed_ &&
360 header == asset.header &&
361 dither == asset.dither &&
362 !strcmp(acodec, asset.acodec));
363 if(result && format == FILE_FFMPEG)
364 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
365 ff_audio_bitrate == asset.ff_audio_bitrate;
370 if(test_video && result)
372 result = (layers == asset.layers &&
373 program == asset.program &&
374 frame_rate == asset.frame_rate &&
375 asset.interlace_autofixoption == interlace_autofixoption &&
376 asset.interlace_mode == interlace_mode &&
377 interlace_fixmethod == asset.interlace_fixmethod &&
378 width == asset.width &&
379 height == asset.height &&
380 !strcmp(vcodec, asset.vcodec) &&
381 strcmp(reel_name, asset.reel_name) == 0 &&
382 reel_number == asset.reel_number &&
383 tcstart == asset.tcstart &&
384 tcend == asset.tcend &&
385 tcformat == asset.tcformat);
386 if(result && format == FILE_FFMPEG)
387 result = !strcmp(ff_video_options, asset.ff_video_options) &&
388 ff_video_bitrate == asset.ff_video_bitrate &&
389 ff_video_quality == asset.ff_video_quality;
395 int Asset::test_path(const char *path)
397 if(!strcasecmp(this->path, path))
403 int Asset::read(FileXML *file,
408 // Check for relative path.
411 char new_path[BCTEXTLEN];
412 char asset_directory[BCTEXTLEN];
413 char input_directory[BCTEXTLEN];
416 strcpy(new_path, path);
417 fs.set_current_dir("");
419 fs.extract_dir(asset_directory, path);
422 // Take path of XML file.
423 if(!asset_directory[0])
425 fs.extract_dir(input_directory, file->filename);
427 // Input file has a path
428 if(input_directory[0])
430 fs.join_names(path, input_directory, new_path);
438 result = file->read_tag();
441 if(file->tag.title_is("/ASSET"))
446 if(file->tag.title_is("AUDIO"))
451 if(file->tag.title_is("AUDIO_OMIT"))
456 if(file->tag.title_is("FORMAT"))
458 const char *string = file->tag.get_property("TYPE");
459 format = File::strtoformat(string);
461 file->tag.get_property("USE_HEADER", use_header);
462 file->tag.get_property("FFORMAT", fformat);
465 if(file->tag.title_is("FOLDER"))
467 const char *string = file->tag.get_property("NUMBER");
468 awindow_folder = string ? atoi(string) :
469 AWindowGUI::folder_number(file->read_text());
472 if(file->tag.title_is("VIDEO"))
477 if(file->tag.title_is("VIDEO_OMIT"))
482 if(file->tag.title_is("INDEX"))
490 //printf("Asset::read 2\n");
494 int Asset::read_audio(FileXML *file)
496 if(file->tag.title_is("AUDIO")) audio_data = 1;
497 channels = file->tag.get_property("CHANNELS", 2);
498 // This is loaded from the index file after the EDL but this
499 // should be overridable in the EDL.
500 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
501 bits = file->tag.get_property("BITS", 16);
502 byte_order = file->tag.get_property("BYTE_ORDER", 1);
503 signed_ = file->tag.get_property("SIGNED", 1);
504 header = file->tag.get_property("HEADER", 0);
505 dither = file->tag.get_property("DITHER", 0);
507 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
509 file->tag.get_property("ACODEC", acodec);
514 tcend = audio_length;
520 int Asset::read_video(FileXML *file)
522 char string[BCTEXTLEN];
524 if(file->tag.title_is("VIDEO")) video_data = 1;
525 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
526 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
527 height = file->tag.get_property("HEIGHT", height);
528 width = file->tag.get_property("WIDTH", width);
529 layers = file->tag.get_property("LAYERS", layers);
530 program = file->tag.get_property("PROGRAM", program);
531 // This is loaded from the index file after the EDL but this
532 // should be overridable in the EDL.
533 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
535 file->tag.get_property("VCODEC", vcodec);
537 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
538 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
540 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
542 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
543 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
545 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
546 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
548 file->tag.get_property("REEL_NAME", reel_name);
549 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
550 tcstart = file->tag.get_property("TCSTART", tcstart);
551 tcend = file->tag.get_property("TCEND", tcend);
552 tcformat = file->tag.get_property("TCFORMAT", tcformat);
557 int Asset::read_index(FileXML *file)
559 index_state->read_xml(file, channels);
563 // Output path is the path of the output file if name truncation is desired.
564 // It is a "" if complete names should be used.
566 int Asset::write(FileXML *file,
568 const char *output_path)
570 char new_path[BCTEXTLEN];
571 char asset_directory[BCTEXTLEN];
572 char output_directory[BCTEXTLEN];
575 // Make path relative
576 fs.extract_dir(asset_directory, path);
577 if(output_path && output_path[0])
578 fs.extract_dir(output_directory, output_path);
580 output_directory[0] = 0;
582 // Asset and EDL are in same directory. Extract just the name.
583 if(!strcmp(asset_directory, output_directory))
585 fs.extract_name(new_path, path);
589 strcpy(new_path, path);
592 file->tag.set_title("ASSET");
593 file->tag.set_property("SRC", new_path);
595 file->append_newline();
597 file->tag.set_title("FOLDER");
598 file->tag.set_property("NUMBER", awindow_folder);
600 file->tag.set_title("/FOLDER");
602 file->append_newline();
604 // Write the format information
605 file->tag.set_title("FORMAT");
607 file->tag.set_property("TYPE",
608 File::formattostr(format));
609 file->tag.set_property("USE_HEADER", use_header);
610 file->tag.set_property("FFORMAT", fformat);
613 file->tag.set_title("/FORMAT");
615 file->append_newline();
617 // Requiring data to exist caused batch render to lose settings.
618 // But the only way to know if an asset doesn't have audio or video data
619 // is to not write the block.
620 // So change the block name if the asset doesn't have the data.
623 // index goes after source
624 if(index_state->index_status == INDEX_READY && include_index)
627 file->tag.set_title("/ASSET");
629 file->append_newline();
633 int Asset::write_audio(FileXML *file)
635 // Let the reader know if the asset has the data by naming the block.
637 file->tag.set_title("AUDIO");
639 file->tag.set_title("AUDIO_OMIT");
640 // Necessary for PCM audio
641 file->tag.set_property("CHANNELS", channels);
642 file->tag.set_property("RATE", sample_rate);
643 file->tag.set_property("BITS", bits);
644 file->tag.set_property("BYTE_ORDER", byte_order);
645 file->tag.set_property("SIGNED", signed_);
646 file->tag.set_property("HEADER", header);
647 file->tag.set_property("DITHER", dither);
649 file->tag.set_property("ACODEC", acodec);
651 file->tag.set_property("AUDIO_LENGTH", audio_length);
655 // Rely on defaults operations for these.
657 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
658 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
660 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
661 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
662 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
663 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
665 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
672 file->tag.set_title("/AUDIO");
674 file->tag.set_title("/AUDIO_OMIT");
676 file->append_newline();
680 int Asset::write_video(FileXML *file)
682 char string[BCTEXTLEN];
685 file->tag.set_title("VIDEO");
687 file->tag.set_title("VIDEO_OMIT");
688 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
689 file->tag.set_property("ACTUAL_WIDTH", actual_width);
690 file->tag.set_property("HEIGHT", height);
691 file->tag.set_property("WIDTH", width);
692 file->tag.set_property("LAYERS", layers);
693 file->tag.set_property("PROGRAM", program);
694 file->tag.set_property("FRAMERATE", frame_rate);
696 file->tag.set_property("VCODEC", vcodec);
698 file->tag.set_property("VIDEO_LENGTH", video_length);
699 file->tag.set_property("SINGLE_FRAME", single_frame);
701 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
703 ilacemode_to_xmltext(string, interlace_mode);
704 file->tag.set_property("INTERLACE_MODE", string);
706 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
707 file->tag.set_property("INTERLACE_FIXMETHOD", string);
710 file->tag.set_property("REEL_NAME", reel_name);
711 file->tag.set_property("REEL_NUMBER", reel_number);
712 file->tag.set_property("TCSTART", tcstart);
713 file->tag.set_property("TCEND", tcend);
714 file->tag.set_property("TCFORMAT", tcformat);
718 file->tag.set_title("/VIDEO");
720 file->tag.set_title("/VIDEO_OMIT");
723 file->append_newline();
727 int Asset::write_index(FileXML *file)
729 index_state->write_xml(file);
734 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
737 sprintf(return_value, "%s%s", prefix, param);
739 strcpy(return_value, param);
743 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
744 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
746 void Asset::load_defaults(BC_Hash *defaults,
754 char string[BCTEXTLEN];
756 // Can't save codec here because it's specific to render, record, and effect.
757 // The codec has to be UNKNOWN for file probing to work.
761 GET_DEFAULT("PATH", path);
766 GET_DEFAULT("AUDIO_CODEC", acodec);
767 GET_DEFAULT("VIDEO_CODEC", vcodec);
772 format = GET_DEFAULT("FORMAT", format);
773 use_header = GET_DEFAULT("USE_HEADER", use_header);
774 GET_DEFAULT("FFORMAT", fformat);
779 audio_data = GET_DEFAULT("AUDIO", 1);
780 video_data = GET_DEFAULT("VIDEO", 1);
785 bits = GET_DEFAULT("BITS", 16);
786 dither = GET_DEFAULT("DITHER", 0);
787 signed_ = GET_DEFAULT("SIGNED", 1);
788 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
792 channels = GET_DEFAULT("CHANNELS", 2);
793 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
794 header = GET_DEFAULT("HEADER", 0);
795 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
799 height = GET_DEFAULT("HEIGHT", height);
800 width = GET_DEFAULT("WIDTH", width);
801 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
802 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
803 program = GET_DEFAULT("PROGRAM", program);
804 layers = GET_DEFAULT("LAYERS", layers);
805 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
806 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
807 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
810 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
811 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
813 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
814 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
815 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
816 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
818 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
819 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
820 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
821 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
822 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
823 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
825 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
826 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
827 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
828 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
829 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
831 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
833 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
834 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
836 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
837 interlace_mode = ILACE_MODE_UNDETECTED;
838 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
840 // MPEG format information
841 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
842 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
843 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
844 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
845 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
846 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
847 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
848 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
849 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
850 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
851 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
852 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
854 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
855 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
856 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
857 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
858 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
859 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
862 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
864 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
865 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
866 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
867 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
868 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
870 GET_DEFAULT("REEL_NAME", reel_name);
871 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
872 tcstart = GET_DEFAULT("TCSTART", tcstart);
873 tcend = GET_DEFAULT("TCEND", tcend);
874 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
879 void Asset::save_defaults(BC_Hash *defaults,
887 char string[BCTEXTLEN];
889 UPDATE_DEFAULT("PATH", path);
896 UPDATE_DEFAULT("FORMAT", format);
897 UPDATE_DEFAULT("USE_HEADER", use_header);
898 UPDATE_DEFAULT("FFORMAT", fformat);
903 UPDATE_DEFAULT("AUDIO", audio_data);
904 UPDATE_DEFAULT("VIDEO", video_data);
909 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
910 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
912 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
913 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
915 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
916 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
917 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
918 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
920 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
921 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
922 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
923 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
924 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
926 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
927 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
928 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
929 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
930 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
931 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
935 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
937 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
938 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
940 // MPEG format information
941 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
942 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
943 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
944 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
945 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
946 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
947 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
948 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
949 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
950 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
951 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
952 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
955 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
958 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
959 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
960 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
961 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
962 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
967 UPDATE_DEFAULT("BITS", bits);
968 UPDATE_DEFAULT("DITHER", dither);
969 UPDATE_DEFAULT("SIGNED", signed_);
970 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
977 UPDATE_DEFAULT("CHANNELS", channels);
978 UPDATE_DEFAULT("RATE", sample_rate);
979 UPDATE_DEFAULT("HEADER", header);
980 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
984 UPDATE_DEFAULT("HEIGHT", height);
985 UPDATE_DEFAULT("WIDTH", width);
986 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
987 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
988 UPDATE_DEFAULT("PROGRAM", program);
989 UPDATE_DEFAULT("LAYERS", layers);
990 UPDATE_DEFAULT("FRAMERATE", frame_rate);
991 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
992 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
996 UPDATE_DEFAULT("REEL_NAME", reel_name);
997 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
998 UPDATE_DEFAULT("TCSTART", tcstart);
999 UPDATE_DEFAULT("TCEND", tcend);
1000 UPDATE_DEFAULT("TCFORMAT", tcformat);
1011 int Asset::dump(FILE *fp)
1013 fprintf(fp," asset::dump\n");
1014 fprintf(fp," this=%p path=%s\n", this, path);
1015 fprintf(fp," index_status %d\n", index_state->index_status);
1016 fprintf(fp," format %d\n", format);
1017 fprintf(fp," fformat=\"%s\"\n", fformat);
1018 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1019 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1020 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1021 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1022 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1023 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1024 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
1025 audio_data, channels, sample_rate, bits, byte_order, signed_,
1026 header, dither, acodec);
1027 fprintf(fp," audio_length %jd\n", audio_length);
1028 char string[BCTEXTLEN];
1029 ilacemode_to_xmltext(string, interlace_mode);
1030 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1031 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
1032 video_data, layers, program, frame_rate, width, height,
1033 vcodec, aspect_ratio,string);
1034 fprintf(fp," reel_name %s reel_number %i tcstart %jd tcend %jd tcf %d\n",
1035 reel_name, reel_number, tcstart, tcend, tcformat);
1036 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
1044 int Asset::get_audio_channels()
1049 int Asset::get_sample_rate()
1054 int64_t Asset::get_audio_samples()
1056 return audio_length;
1059 int Asset::have_audio()
1064 int Asset::have_video()
1079 double Asset::get_frame_rate()
1085 int Asset::get_video_layers()
1090 int Asset::get_program()
1095 int64_t Asset::get_video_frames()
1097 return video_length;
1100 double Asset::total_length_framealigned(double fps)
1102 if (video_data && audio_data) {
1103 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1104 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1105 return MIN(aud,vid);
1109 return (double)audio_length / sample_rate;
1112 return (double)video_length / frame_rate;
1117 int Asset::set_timecode(char *tc, int format, int end)
1121 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1122 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1123 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1125 // This needs to be modified to handle drop-frame
1128 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1130 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);