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;
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 = cp;
337 if( *tpath != '/' ) {
338 char *cp = cstrcat(2, out_path, tpath);
339 delete [] tpath; tpath = cp;
342 if( strcmp(apath, tpath) ) result = 1;
348 if(result && format == FILE_FFMPEG)
349 result = !strcmp(fformat, asset.fformat);
351 if(test_audio && result)
353 result = (channels == asset.channels &&
354 sample_rate == asset.sample_rate &&
355 bits == asset.bits &&
356 byte_order == asset.byte_order &&
357 signed_ == asset.signed_ &&
358 header == asset.header &&
359 dither == asset.dither &&
360 !strcmp(acodec, asset.acodec));
361 if(result && format == FILE_FFMPEG)
362 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
363 ff_audio_bitrate == asset.ff_audio_bitrate;
368 if(test_video && result)
370 result = (layers == asset.layers &&
371 program == asset.program &&
372 frame_rate == asset.frame_rate &&
373 asset.interlace_autofixoption == interlace_autofixoption &&
374 asset.interlace_mode == interlace_mode &&
375 interlace_fixmethod == asset.interlace_fixmethod &&
376 width == asset.width &&
377 height == asset.height &&
378 !strcmp(vcodec, asset.vcodec) &&
379 strcmp(reel_name, asset.reel_name) == 0 &&
380 reel_number == asset.reel_number &&
381 tcstart == asset.tcstart &&
382 tcend == asset.tcend &&
383 tcformat == asset.tcformat);
384 if(result && format == FILE_FFMPEG)
385 result = !strcmp(ff_video_options, asset.ff_video_options) &&
386 ff_video_bitrate == asset.ff_video_bitrate &&
387 ff_video_quality == asset.ff_video_quality;
393 int Asset::test_path(const char *path)
395 if(!strcasecmp(this->path, path))
401 int Asset::read(FileXML *file,
406 // Check for relative path.
409 char new_path[BCTEXTLEN];
410 char asset_directory[BCTEXTLEN];
411 char input_directory[BCTEXTLEN];
414 strcpy(new_path, path);
415 fs.set_current_dir("");
417 fs.extract_dir(asset_directory, path);
420 // Take path of XML file.
421 if(!asset_directory[0])
423 fs.extract_dir(input_directory, file->filename);
425 // Input file has a path
426 if(input_directory[0])
428 fs.join_names(path, input_directory, new_path);
436 result = file->read_tag();
439 if(file->tag.title_is("/ASSET"))
444 if(file->tag.title_is("AUDIO"))
449 if(file->tag.title_is("AUDIO_OMIT"))
454 if(file->tag.title_is("FORMAT"))
456 const char *string = file->tag.get_property("TYPE");
457 format = File::strtoformat(string);
459 file->tag.get_property("USE_HEADER", use_header);
460 file->tag.get_property("FFORMAT", fformat);
463 if(file->tag.title_is("FOLDER"))
465 const char *string = file->tag.get_property("NUMBER");
466 awindow_folder = string ? atoi(string) :
467 AWindowGUI::folder_number(file->read_text());
470 if(file->tag.title_is("VIDEO"))
475 if(file->tag.title_is("VIDEO_OMIT"))
480 if(file->tag.title_is("INDEX"))
488 //printf("Asset::read 2\n");
492 int Asset::read_audio(FileXML *file)
494 if(file->tag.title_is("AUDIO")) audio_data = 1;
495 channels = file->tag.get_property("CHANNELS", 2);
496 // This is loaded from the index file after the EDL but this
497 // should be overridable in the EDL.
498 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
499 bits = file->tag.get_property("BITS", 16);
500 byte_order = file->tag.get_property("BYTE_ORDER", 1);
501 signed_ = file->tag.get_property("SIGNED", 1);
502 header = file->tag.get_property("HEADER", 0);
503 dither = file->tag.get_property("DITHER", 0);
505 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
507 file->tag.get_property("ACODEC", acodec);
512 tcend = audio_length;
518 int Asset::read_video(FileXML *file)
520 char string[BCTEXTLEN];
522 if(file->tag.title_is("VIDEO")) video_data = 1;
523 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
524 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
525 height = file->tag.get_property("HEIGHT", height);
526 width = file->tag.get_property("WIDTH", width);
527 layers = file->tag.get_property("LAYERS", layers);
528 program = file->tag.get_property("PROGRAM", program);
529 // This is loaded from the index file after the EDL but this
530 // should be overridable in the EDL.
531 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
533 file->tag.get_property("VCODEC", vcodec);
535 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
536 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
538 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
540 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
541 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
543 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
544 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
546 file->tag.get_property("REEL_NAME", reel_name);
547 reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
548 tcstart = file->tag.get_property("TCSTART", tcstart);
549 tcend = file->tag.get_property("TCEND", tcend);
550 tcformat = file->tag.get_property("TCFORMAT", tcformat);
555 int Asset::read_index(FileXML *file)
557 index_state->read_xml(file, channels);
561 // Output path is the path of the output file if name truncation is desired.
562 // It is a "" if complete names should be used.
564 int Asset::write(FileXML *file,
566 const char *output_path)
568 char new_path[BCTEXTLEN];
569 char asset_directory[BCTEXTLEN];
570 char output_directory[BCTEXTLEN];
573 // Make path relative
574 fs.extract_dir(asset_directory, path);
575 if(output_path && output_path[0])
576 fs.extract_dir(output_directory, output_path);
578 output_directory[0] = 0;
580 // Asset and EDL are in same directory. Extract just the name.
581 if(!strcmp(asset_directory, output_directory))
583 fs.extract_name(new_path, path);
587 strcpy(new_path, path);
590 file->tag.set_title("ASSET");
591 file->tag.set_property("SRC", new_path);
593 file->append_newline();
595 file->tag.set_title("FOLDER");
596 file->tag.set_property("NUMBER", awindow_folder);
598 file->tag.set_title("/FOLDER");
600 file->append_newline();
602 // Write the format information
603 file->tag.set_title("FORMAT");
605 file->tag.set_property("TYPE",
606 File::formattostr(format));
607 file->tag.set_property("USE_HEADER", use_header);
608 file->tag.set_property("FFORMAT", fformat);
611 file->tag.set_title("/FORMAT");
613 file->append_newline();
615 // Requiring data to exist caused batch render to lose settings.
616 // But the only way to know if an asset doesn't have audio or video data
617 // is to not write the block.
618 // So change the block name if the asset doesn't have the data.
621 // index goes after source
622 if(index_state->index_status == INDEX_READY && include_index)
625 file->tag.set_title("/ASSET");
627 file->append_newline();
631 int Asset::write_audio(FileXML *file)
633 // Let the reader know if the asset has the data by naming the block.
635 file->tag.set_title("AUDIO");
637 file->tag.set_title("AUDIO_OMIT");
638 // Necessary for PCM audio
639 file->tag.set_property("CHANNELS", channels);
640 file->tag.set_property("RATE", sample_rate);
641 file->tag.set_property("BITS", bits);
642 file->tag.set_property("BYTE_ORDER", byte_order);
643 file->tag.set_property("SIGNED", signed_);
644 file->tag.set_property("HEADER", header);
645 file->tag.set_property("DITHER", dither);
647 file->tag.set_property("ACODEC", acodec);
649 file->tag.set_property("AUDIO_LENGTH", audio_length);
653 // Rely on defaults operations for these.
655 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
656 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
658 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
659 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
660 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
661 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
663 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
670 file->tag.set_title("/AUDIO");
672 file->tag.set_title("/AUDIO_OMIT");
674 file->append_newline();
678 int Asset::write_video(FileXML *file)
680 char string[BCTEXTLEN];
683 file->tag.set_title("VIDEO");
685 file->tag.set_title("VIDEO_OMIT");
686 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
687 file->tag.set_property("ACTUAL_WIDTH", actual_width);
688 file->tag.set_property("HEIGHT", height);
689 file->tag.set_property("WIDTH", width);
690 file->tag.set_property("LAYERS", layers);
691 file->tag.set_property("PROGRAM", program);
692 file->tag.set_property("FRAMERATE", frame_rate);
694 file->tag.set_property("VCODEC", vcodec);
696 file->tag.set_property("VIDEO_LENGTH", video_length);
697 file->tag.set_property("SINGLE_FRAME", single_frame);
699 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
701 ilacemode_to_xmltext(string, interlace_mode);
702 file->tag.set_property("INTERLACE_MODE", string);
704 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
705 file->tag.set_property("INTERLACE_FIXMETHOD", string);
708 file->tag.set_property("REEL_NAME", reel_name);
709 file->tag.set_property("REEL_NUMBER", reel_number);
710 file->tag.set_property("TCSTART", tcstart);
711 file->tag.set_property("TCEND", tcend);
712 file->tag.set_property("TCFORMAT", tcformat);
716 file->tag.set_title("/VIDEO");
718 file->tag.set_title("/VIDEO_OMIT");
721 file->append_newline();
725 int Asset::write_index(FileXML *file)
727 index_state->write_xml(file);
732 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
735 sprintf(return_value, "%s%s", prefix, param);
737 strcpy(return_value, param);
741 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
742 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
744 void Asset::load_defaults(BC_Hash *defaults,
752 char string[BCTEXTLEN];
754 // Can't save codec here because it's specific to render, record, and effect.
755 // The codec has to be UNKNOWN for file probing to work.
759 GET_DEFAULT("PATH", path);
764 GET_DEFAULT("AUDIO_CODEC", acodec);
765 GET_DEFAULT("VIDEO_CODEC", vcodec);
770 format = GET_DEFAULT("FORMAT", format);
771 use_header = GET_DEFAULT("USE_HEADER", use_header);
772 GET_DEFAULT("FFORMAT", fformat);
777 audio_data = GET_DEFAULT("AUDIO", 1);
778 video_data = GET_DEFAULT("VIDEO", 1);
783 bits = GET_DEFAULT("BITS", 16);
784 dither = GET_DEFAULT("DITHER", 0);
785 signed_ = GET_DEFAULT("SIGNED", 1);
786 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
790 channels = GET_DEFAULT("CHANNELS", 2);
791 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
792 header = GET_DEFAULT("HEADER", 0);
793 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
797 height = GET_DEFAULT("HEIGHT", height);
798 width = GET_DEFAULT("WIDTH", width);
799 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
800 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
801 program = GET_DEFAULT("PROGRAM", program);
802 layers = GET_DEFAULT("LAYERS", layers);
803 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
804 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
805 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
808 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
809 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
811 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
812 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
813 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
814 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
816 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
817 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
818 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
819 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
820 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
821 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
823 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
824 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
825 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
826 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
827 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
829 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
831 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
832 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
834 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
835 interlace_mode = ILACE_MODE_UNDETECTED;
836 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
838 // MPEG format information
839 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
840 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
841 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
842 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
843 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
844 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
845 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
846 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
847 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
848 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
849 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
850 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
852 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
853 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
854 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
855 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
856 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
857 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
860 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
862 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
863 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
864 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
865 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
866 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
868 GET_DEFAULT("REEL_NAME", reel_name);
869 reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
870 tcstart = GET_DEFAULT("TCSTART", tcstart);
871 tcend = GET_DEFAULT("TCEND", tcend);
872 tcformat = GET_DEFAULT("TCFORMAT", tcformat);
877 void Asset::save_defaults(BC_Hash *defaults,
885 char string[BCTEXTLEN];
887 UPDATE_DEFAULT("PATH", path);
894 UPDATE_DEFAULT("FORMAT", format);
895 UPDATE_DEFAULT("USE_HEADER", use_header);
896 UPDATE_DEFAULT("FFORMAT", fformat);
901 UPDATE_DEFAULT("AUDIO", audio_data);
902 UPDATE_DEFAULT("VIDEO", video_data);
907 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
908 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
910 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
911 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
913 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
914 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
915 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
916 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
918 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
919 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
920 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
921 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
922 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
924 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
925 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
926 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
927 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
928 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
929 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
933 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
935 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
936 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
938 // MPEG format information
939 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
940 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
941 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
942 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
943 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
944 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
945 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
946 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
947 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
948 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
949 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
950 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
953 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
956 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
957 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
958 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
959 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
960 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
965 UPDATE_DEFAULT("BITS", bits);
966 UPDATE_DEFAULT("DITHER", dither);
967 UPDATE_DEFAULT("SIGNED", signed_);
968 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
975 UPDATE_DEFAULT("CHANNELS", channels);
976 UPDATE_DEFAULT("RATE", sample_rate);
977 UPDATE_DEFAULT("HEADER", header);
978 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
982 UPDATE_DEFAULT("HEIGHT", height);
983 UPDATE_DEFAULT("WIDTH", width);
984 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
985 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
986 UPDATE_DEFAULT("PROGRAM", program);
987 UPDATE_DEFAULT("LAYERS", layers);
988 UPDATE_DEFAULT("FRAMERATE", frame_rate);
989 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
990 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
994 UPDATE_DEFAULT("REEL_NAME", reel_name);
995 UPDATE_DEFAULT("REEL_NUMBER", reel_number);
996 UPDATE_DEFAULT("TCSTART", tcstart);
997 UPDATE_DEFAULT("TCEND", tcend);
998 UPDATE_DEFAULT("TCFORMAT", tcformat);
1009 int Asset::dump(FILE *fp)
1011 fprintf(fp," asset::dump\n");
1012 fprintf(fp," this=%p path=%s\n", this, path);
1013 fprintf(fp," index_status %d\n", index_state->index_status);
1014 fprintf(fp," format %d\n", format);
1015 fprintf(fp," fformat=\"%s\"\n", fformat);
1016 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1017 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1018 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1019 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1020 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1021 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1022 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
1023 audio_data, channels, sample_rate, bits, byte_order, signed_,
1024 header, dither, acodec);
1025 fprintf(fp," audio_length %jd\n", audio_length);
1026 char string[BCTEXTLEN];
1027 ilacemode_to_xmltext(string, interlace_mode);
1028 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1029 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
1030 video_data, layers, program, frame_rate, width, height,
1031 vcodec, aspect_ratio,string);
1032 fprintf(fp," reel_name %s reel_number %i tcstart %jd tcend %jd tcf %d\n",
1033 reel_name, reel_number, tcstart, tcend, tcformat);
1034 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
1042 int Asset::get_audio_channels()
1047 int Asset::get_sample_rate()
1052 int64_t Asset::get_audio_samples()
1054 return audio_length;
1057 int Asset::have_audio()
1062 int Asset::have_video()
1077 double Asset::get_frame_rate()
1083 int Asset::get_video_layers()
1088 int Asset::get_program()
1093 int64_t Asset::get_video_frames()
1095 return video_length;
1098 double Asset::total_length_framealigned(double fps)
1100 if (video_data && audio_data) {
1101 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1102 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1103 return MIN(aud,vid);
1107 return (double)audio_length / sample_rate;
1110 return (double)video_length / frame_rate;
1115 int Asset::set_timecode(char *tc, int format, int end)
1119 hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
1120 min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
1121 sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
1123 // This needs to be modified to handle drop-frame
1126 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
1128 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);