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"
32 #include "indexstate.h"
33 #include "quicktime.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()
73 // Has to be unknown for file probing to succeed
74 format = FILE_UNKNOWN;
83 strcpy(vcodec, QUICKTIME_YUV2);
84 strcpy(acodec, QUICKTIME_TWOS);
92 vorbis_min_bitrate = -1;
93 vorbis_bitrate = 128000;
94 vorbis_max_bitrate = -1;
96 theora_fix_bitrate = 1;
97 theora_bitrate = 860000;
100 theora_keyframe_frequency = 64;
101 theora_keyframe_force_frequency = 64;
103 mp3_bitrate = 256000;
106 mp4a_bitrate = 256000;
107 mp4a_quantqual = 100;
112 vmpeg_iframe_distance = 45;
113 vmpeg_pframe_distance = 0;
114 vmpeg_progressive = 0;
116 vmpeg_bitrate = 1000000;
117 vmpeg_derivative = 1;
118 vmpeg_quantization = 15;
119 vmpeg_cmodel = BC_YUV420P;
120 vmpeg_fix_bitrate = 0;
123 vmpeg_field_order = 0;
125 // Divx parameters. BC_Hash from encore2
126 divx_bitrate = 2000000;
128 divx_rc_reaction_ratio = 45;
129 divx_rc_reaction_period = 10;
130 divx_max_key_interval = 250;
131 divx_max_quantizer = 31;
132 divx_min_quantizer = 1;
135 divx_fix_bitrate = 1;
136 divx_use_deblocking = 1;
138 h264_bitrate = 2000000;
140 h264_fix_bitrate = 0;
142 ms_bitrate = 1000000;
143 ms_bitrate_tolerance = 500000;
144 ms_quantization = 10;
156 tiff_compression = 0;
170 void Asset::reset_audio()
178 void Asset::reset_video()
182 actual_width = width = 0;
183 actual_height = height = 0;
185 vmpeg_cmodel = BC_YUV420P;
191 void Asset::boundaries()
193 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
194 // sample_rate & frame_rate are user defined
195 // CLAMP(sample_rate, 1, 1000000);
196 // CLAMP(frame_rate, 0.001, 1000000);
197 CLAMP(channels, 0, 16);
198 CLAMP(width, 0, 10000);
199 CLAMP(height, 0, 10000);
200 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
204 void Asset::reset_index()
206 index_state->reset();
209 int Asset::reset_timecode()
211 strcpy(reel_name, "cin0000");
220 void Asset::copy_from(Asset *asset, int do_index)
222 copy_location(asset);
223 copy_format(asset, do_index);
226 void Asset::copy_location(Asset *asset)
228 strcpy(this->path, asset->path);
229 strcpy(this->folder, asset->folder);
232 void Asset::copy_format(Asset *asset, int do_index)
234 if(do_index) update_index(asset);
236 audio_data = asset->audio_data;
237 format = asset->format;
238 channels = asset->channels;
239 sample_rate = asset->sample_rate;
241 byte_order = asset->byte_order;
242 signed_ = asset->signed_;
243 header = asset->header;
244 dither = asset->dither;
245 mp3_bitrate = asset->mp3_bitrate;
246 mp4a_bitrate = asset->mp4a_bitrate;
247 mp4a_quantqual = asset->mp4a_quantqual;
248 use_header = asset->use_header;
249 aspect_ratio = asset->aspect_ratio;
251 video_data = asset->video_data;
252 layers = asset->layers;
253 program = asset->program;
254 frame_rate = asset->frame_rate;
255 width = asset->width;
256 height = asset->height;
257 actual_width = asset->actual_width;
258 actual_height = asset->actual_height;
259 strcpy(vcodec, asset->vcodec);
260 strcpy(acodec, asset->acodec);
262 this->audio_length = asset->audio_length;
263 this->video_length = asset->video_length;
266 ampeg_bitrate = asset->ampeg_bitrate;
267 ampeg_derivative = asset->ampeg_derivative;
270 vorbis_vbr = asset->vorbis_vbr;
271 vorbis_min_bitrate = asset->vorbis_min_bitrate;
272 vorbis_bitrate = asset->vorbis_bitrate;
273 vorbis_max_bitrate = asset->vorbis_max_bitrate;
276 theora_fix_bitrate = asset->theora_fix_bitrate;
277 theora_bitrate = asset->theora_bitrate;
278 theora_quality = asset->theora_quality;
279 theora_sharpness = asset->theora_sharpness;
280 theora_keyframe_frequency = asset->theora_keyframe_frequency;
281 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
284 jpeg_quality = asset->jpeg_quality;
287 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
288 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
289 vmpeg_progressive = asset->vmpeg_progressive;
290 vmpeg_denoise = asset->vmpeg_denoise;
291 vmpeg_bitrate = asset->vmpeg_bitrate;
292 vmpeg_derivative = asset->vmpeg_derivative;
293 vmpeg_quantization = asset->vmpeg_quantization;
294 vmpeg_cmodel = asset->vmpeg_cmodel;
295 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
296 vmpeg_seq_codes = asset->vmpeg_seq_codes;
297 vmpeg_preset = asset->vmpeg_preset;
298 vmpeg_field_order = asset->vmpeg_field_order;
301 divx_bitrate = asset->divx_bitrate;
302 divx_rc_period = asset->divx_rc_period;
303 divx_rc_reaction_ratio = asset->divx_rc_reaction_ratio;
304 divx_rc_reaction_period = asset->divx_rc_reaction_period;
305 divx_max_key_interval = asset->divx_max_key_interval;
306 divx_max_quantizer = asset->divx_max_quantizer;
307 divx_min_quantizer = asset->divx_min_quantizer;
308 divx_quantizer = asset->divx_quantizer;
309 divx_quality = asset->divx_quality;
310 divx_fix_bitrate = asset->divx_fix_bitrate;
311 divx_use_deblocking = asset->divx_use_deblocking;
313 h264_bitrate = asset->h264_bitrate;
314 h264_quantizer = asset->h264_quantizer;
315 h264_fix_bitrate = asset->h264_fix_bitrate;
318 ms_bitrate = asset->ms_bitrate;
319 ms_bitrate_tolerance = asset->ms_bitrate_tolerance;
320 ms_interlaced = asset->ms_interlaced;
321 ms_quantization = asset->ms_quantization;
322 ms_gop_size = asset->ms_gop_size;
323 ms_fix_bitrate = asset->ms_fix_bitrate;
326 ac3_bitrate = asset->ac3_bitrate;
328 png_use_alpha = asset->png_use_alpha;
329 exr_use_alpha = asset->exr_use_alpha;
330 exr_compression = asset->exr_compression;
332 tiff_cmodel = asset->tiff_cmodel;
333 tiff_compression = asset->tiff_compression;
336 int64_t Asset::get_index_offset(int channel)
338 return index_state->get_index_offset(channel);
341 int64_t Asset::get_index_size(int channel)
343 return index_state->get_index_size(channel);
347 char* Asset::get_compression_text(int audio, int video)
356 return quicktime_acodec_title(acodec);
370 return quicktime_vcodec_title(vcodec);
379 Asset& Asset::operator=(Asset &asset)
381 printf("Asset::operator=\n");
382 copy_location(&asset);
383 copy_format(&asset, 1);
388 int Asset::equivalent(Asset &asset,
392 int result = (!strcmp(asset.path, path) &&
393 format == asset.format);
395 if(test_audio && result)
397 result = (channels == asset.channels &&
398 sample_rate == asset.sample_rate &&
399 bits == asset.bits &&
400 byte_order == asset.byte_order &&
401 signed_ == asset.signed_ &&
402 header == asset.header &&
403 dither == asset.dither &&
404 !strcmp(acodec, asset.acodec));
408 if(test_video && result)
410 result = (layers == asset.layers &&
411 program == asset.program &&
412 frame_rate == asset.frame_rate &&
413 width == asset.width &&
414 height == asset.height &&
415 !strcmp(vcodec, asset.vcodec));
421 int Asset::operator==(Asset &asset)
424 return equivalent(asset,
429 int Asset::operator!=(Asset &asset)
431 return !(*this == asset);
434 int Asset::test_path(const char *path)
436 if(!strcasecmp(this->path, path))
442 int Asset::test_plugin_title(const char *path)
447 int Asset::read(FileXML *file,
452 // Check for relative path.
455 char new_path[BCTEXTLEN];
456 char asset_directory[BCTEXTLEN];
457 char input_directory[BCTEXTLEN];
460 strcpy(new_path, path);
461 fs.set_current_dir("");
463 fs.extract_dir(asset_directory, path);
466 // Take path of XML file.
467 if(!asset_directory[0])
469 fs.extract_dir(input_directory, file->filename);
471 // Input file has a path
472 if(input_directory[0])
474 fs.join_names(path, input_directory, new_path);
482 result = file->read_tag();
485 if(file->tag.title_is("/ASSET"))
490 if(file->tag.title_is("AUDIO"))
495 if(file->tag.title_is("AUDIO_OMIT"))
500 if(file->tag.title_is("FORMAT"))
502 const char *string = file->tag.get_property("TYPE");
503 format = File::strtoformat(string);
505 file->tag.get_property("USE_HEADER", use_header);
508 if(file->tag.title_is("FOLDER"))
510 strcpy(folder, file->read_text());
513 if(file->tag.title_is("VIDEO"))
518 if(file->tag.title_is("VIDEO_OMIT"))
523 if(file->tag.title_is("INDEX"))
531 //printf("Asset::read 2\n");
535 int Asset::read_audio(FileXML *file)
537 if(file->tag.title_is("AUDIO")) audio_data = 1;
538 channels = file->tag.get_property("CHANNELS", 2);
539 // This is loaded from the index file after the EDL but this
540 // should be overridable in the EDL.
541 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
542 bits = file->tag.get_property("BITS", 16);
543 byte_order = file->tag.get_property("BYTE_ORDER", 1);
544 signed_ = file->tag.get_property("SIGNED", 1);
545 header = file->tag.get_property("HEADER", 0);
546 dither = file->tag.get_property("DITHER", 0);
548 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
550 file->tag.get_property("ACODEC", acodec);
558 int Asset::read_video(FileXML *file)
560 if(file->tag.title_is("VIDEO")) video_data = 1;
561 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
562 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
563 height = file->tag.get_property("HEIGHT", height);
564 width = file->tag.get_property("WIDTH", width);
565 layers = file->tag.get_property("LAYERS", layers);
566 program = file->tag.get_property("PROGRAM", program);
567 // This is loaded from the index file after the EDL but this
568 // should be overridable in the EDL.
569 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
571 file->tag.get_property("VCODEC", vcodec);
573 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
578 int Asset::read_index(FileXML *file)
580 index_state->read_xml(file, channels);
584 int Asset::write_index(const char *path, int data_bytes)
586 return index_state->write_index(path, data_bytes, this, audio_length);
589 // Output path is the path of the output file if name truncation is desired.
590 // It is a "" if complete names should be used.
592 int Asset::write(FileXML *file,
594 const char *output_path)
596 char new_path[BCTEXTLEN];
597 char asset_directory[BCTEXTLEN];
598 char output_directory[BCTEXTLEN];
601 // Make path relative
602 fs.extract_dir(asset_directory, path);
603 if(output_path && output_path[0])
604 fs.extract_dir(output_directory, output_path);
606 output_directory[0] = 0;
608 // Asset and EDL are in same directory. Extract just the name.
609 if(!strcmp(asset_directory, output_directory))
611 fs.extract_name(new_path, path);
615 strcpy(new_path, path);
618 file->tag.set_title("ASSET");
619 file->tag.set_property("SRC", new_path);
621 file->append_newline();
623 file->tag.set_title("FOLDER");
625 file->append_text(folder);
626 file->tag.set_title("/FOLDER");
628 file->append_newline();
630 // Write the format information
631 file->tag.set_title("FORMAT");
633 file->tag.set_property("TYPE",
634 File::formattostr(format));
635 file->tag.set_property("USE_HEADER", use_header);
638 file->append_newline();
640 // Requiring data to exist caused batch render to lose settings.
641 // But the only way to know if an asset doesn't have audio or video data
642 // is to not write the block.
643 // So change the block name if the asset doesn't have the data.
646 // index goes after source
647 if(index_state->index_status == INDEX_READY && include_index)
650 file->tag.set_title("/ASSET");
652 file->append_newline();
656 int Asset::write_audio(FileXML *file)
658 // Let the reader know if the asset has the data by naming the block.
660 file->tag.set_title("AUDIO");
662 file->tag.set_title("AUDIO_OMIT");
663 // Necessary for PCM audio
664 file->tag.set_property("CHANNELS", channels);
665 file->tag.set_property("RATE", sample_rate);
666 file->tag.set_property("BITS", bits);
667 file->tag.set_property("BYTE_ORDER", byte_order);
668 file->tag.set_property("SIGNED", signed_);
669 file->tag.set_property("HEADER", header);
670 file->tag.set_property("DITHER", dither);
672 file->tag.set_property("ACODEC", acodec);
674 file->tag.set_property("AUDIO_LENGTH", audio_length);
678 // Rely on defaults operations for these.
680 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
681 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
683 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
684 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
685 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
686 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
688 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
694 file->append_newline();
698 int Asset::write_video(FileXML *file)
701 file->tag.set_title("VIDEO");
703 file->tag.set_title("VIDEO_OMIT");
704 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
705 file->tag.set_property("ACTUAL_WIDTH", actual_width);
706 file->tag.set_property("HEIGHT", height);
707 file->tag.set_property("WIDTH", width);
708 file->tag.set_property("LAYERS", layers);
709 file->tag.set_property("PROGRAM", program);
710 file->tag.set_property("FRAMERATE", frame_rate);
712 file->tag.set_property("VCODEC", vcodec);
714 file->tag.set_property("VIDEO_LENGTH", video_length);
720 file->append_newline();
724 int Asset::write_index(FileXML *file)
726 index_state->write_xml(file);
733 const char* Asset::construct_param(const char *param,
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);
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);
793 channels = GET_DEFAULT("CHANNELS", 2);
794 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 44100);
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);
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_FEQUENCY", theora_keyframe_force_frequency);
827 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
828 mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
829 mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
831 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
832 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
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 h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
849 h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
850 h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
853 divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
854 divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
855 divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
856 divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
857 divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
858 divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
859 divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
860 divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
861 divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
862 divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
863 divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
865 ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
866 ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
867 ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
868 ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
869 ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
870 ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
872 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
874 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
875 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
876 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
877 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
878 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
883 void Asset::save_defaults(BC_Hash *defaults,
891 char string[BCTEXTLEN];
893 UPDATE_DEFAULT("PATH", path);
900 UPDATE_DEFAULT("FORMAT", format);
901 UPDATE_DEFAULT("USE_HEADER", use_header);
906 UPDATE_DEFAULT("AUDIO", audio_data);
907 UPDATE_DEFAULT("VIDEO", video_data);
912 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
913 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
915 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
916 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
918 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
919 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
920 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
921 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
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_FEQUENCY", theora_keyframe_force_frequency);
933 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
934 UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
935 UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
941 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
942 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
944 // MPEG format information
945 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
946 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
947 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
948 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
949 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
950 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
951 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
952 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
953 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
954 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
955 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
956 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
958 UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
959 UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
960 UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
962 UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
963 UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
964 UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
965 UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
966 UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
967 UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
968 UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
969 UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
970 UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
971 UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
972 UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
975 UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
976 UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
977 UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
978 UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
979 UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
980 UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
982 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
985 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
986 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
987 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
988 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
989 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
994 UPDATE_DEFAULT("BITS", bits);
995 UPDATE_DEFAULT("DITHER", dither);
996 UPDATE_DEFAULT("SIGNED", signed_);
997 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
1005 UPDATE_DEFAULT("CHANNELS", channels);
1006 UPDATE_DEFAULT("RATE", sample_rate);
1007 UPDATE_DEFAULT("HEADER", header);
1008 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
1012 UPDATE_DEFAULT("HEIGHT", height);
1013 UPDATE_DEFAULT("WIDTH", width);
1014 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
1015 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
1016 UPDATE_DEFAULT("PROGRAM", program);
1017 UPDATE_DEFAULT("LAYERS", layers);
1018 UPDATE_DEFAULT("FRAMERATE", frame_rate);
1019 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
1032 int Asset::update_path(char *new_path)
1034 strcpy(path, new_path);
1038 void Asset::update_index(Asset *asset)
1040 index_state->copy_from(asset->index_state);
1044 int Asset::dump(FILE *fp)
1046 fprintf(fp," asset::dump\n");
1047 fprintf(fp," this=%p path=%s\n", this, path);
1048 fprintf(fp," index_status %d\n", index_state->index_status);
1049 fprintf(fp," format %d\n", format);
1050 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1051 " byte_order %d signed %d header %d dither %d acodec %c%c%c%c\n",
1052 audio_data, channels, sample_rate, bits, byte_order, signed_,
1053 header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1054 fprintf(fp," audio_length " _LD "\n", audio_length);
1055 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1056 " height %d vcodec %c%c%c%c aspect_ratio %f\n",
1057 video_data, layers, program, frame_rate, width, height,
1058 vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio);
1059 fprintf(fp," video_length " _LD " \n", video_length);
1060 fprintf(fp," ms_bitrate_tolerance=%d\n", ms_bitrate_tolerance);
1061 fprintf(fp," ms_quantization=%d\n", ms_quantization);
1062 fprintf(fp," ms_fix_bitrate=%d\n", ms_fix_bitrate);
1063 fprintf(fp," ms_interlaced=%d\n", ms_interlaced);
1064 fprintf(fp," h264_bitrate=%d\n", h264_bitrate);
1065 fprintf(fp," h264_quantizer=%d\n", h264_quantizer);
1066 fprintf(fp," h264_fix_bitrate=%d\n", h264_fix_bitrate);
1072 int Asset::get_audio_channels()
1077 int Asset::get_sample_rate()
1082 int64_t Asset::get_audio_samples()
1084 return audio_length;
1087 int Asset::have_audio()
1092 int Asset::have_video()
1107 double Asset::get_frame_rate()
1113 int Asset::get_video_layers()
1118 int Asset::get_program()
1123 int64_t Asset::get_video_frames()
1125 return video_length;