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;
84 strcpy(vcodec, QUICKTIME_YUV2);
85 strcpy(acodec, QUICKTIME_TWOS);
87 ff_audio_options[0] = 0;
88 ff_video_options[0] = 0;
100 vorbis_min_bitrate = -1;
101 vorbis_bitrate = 128000;
102 vorbis_max_bitrate = -1;
104 theora_fix_bitrate = 1;
105 theora_bitrate = 860000;
107 theora_sharpness = 2;
108 theora_keyframe_frequency = 64;
109 theora_keyframe_force_frequency = 64;
111 mp3_bitrate = 256000;
114 mp4a_bitrate = 256000;
115 mp4a_quantqual = 100;
120 vmpeg_iframe_distance = 45;
121 vmpeg_pframe_distance = 0;
122 vmpeg_progressive = 0;
124 vmpeg_bitrate = 1000000;
125 vmpeg_derivative = 1;
126 vmpeg_quantization = 15;
127 vmpeg_cmodel = BC_YUV420P;
128 vmpeg_fix_bitrate = 0;
131 vmpeg_field_order = 0;
133 // Divx parameters. BC_Hash from encore2
134 divx_bitrate = 2000000;
136 divx_rc_reaction_ratio = 45;
137 divx_rc_reaction_period = 10;
138 divx_max_key_interval = 250;
139 divx_max_quantizer = 31;
140 divx_min_quantizer = 1;
143 divx_fix_bitrate = 1;
144 divx_use_deblocking = 1;
146 h264_bitrate = 2000000;
148 h264_fix_bitrate = 0;
150 ms_bitrate = 1000000;
151 ms_bitrate_tolerance = 500000;
152 ms_quantization = 10;
164 tiff_compression = 0;
173 void Asset::reset_audio()
181 void Asset::reset_video()
185 actual_width = width = 0;
186 actual_height = height = 0;
188 vmpeg_cmodel = BC_YUV420P;
194 void Asset::boundaries()
196 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
197 // sample_rate & frame_rate are user defined
198 // CLAMP(sample_rate, 1, 1000000);
199 // CLAMP(frame_rate, 0.001, 1000000);
200 CLAMP(channels, 0, 16);
201 CLAMP(width, 0, 10000);
202 CLAMP(height, 0, 10000);
203 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
207 void Asset::reset_index()
209 index_state->reset();
212 void Asset::copy_from(Asset *asset, int do_index)
214 copy_location(asset);
215 copy_format(asset, do_index);
218 void Asset::copy_location(Asset *asset)
220 strcpy(this->path, asset->path);
221 strcpy(this->folder, asset->folder);
224 void Asset::copy_format(Asset *asset, int do_index)
226 if(do_index) update_index(asset);
228 audio_data = asset->audio_data;
229 format = asset->format;
230 strcpy(fformat, asset->fformat);
231 channels = asset->channels;
232 sample_rate = asset->sample_rate;
234 byte_order = asset->byte_order;
235 signed_ = asset->signed_;
236 header = asset->header;
237 dither = asset->dither;
238 mp3_bitrate = asset->mp3_bitrate;
239 mp4a_bitrate = asset->mp4a_bitrate;
240 mp4a_quantqual = asset->mp4a_quantqual;
241 use_header = asset->use_header;
242 aspect_ratio = asset->aspect_ratio;
244 video_data = asset->video_data;
245 layers = asset->layers;
246 program = asset->program;
247 frame_rate = asset->frame_rate;
248 width = asset->width;
249 height = asset->height;
250 actual_width = asset->actual_width;
251 actual_height = asset->actual_height;
252 strcpy(vcodec, asset->vcodec);
253 strcpy(acodec, asset->acodec);
255 strcpy(ff_audio_options, asset->ff_audio_options);
256 strcpy(ff_video_options, asset->ff_video_options);
257 ff_audio_bitrate = asset->ff_audio_bitrate;
258 ff_video_bitrate = asset->ff_video_bitrate;
259 ff_video_quality = asset->ff_video_quality;
261 this->audio_length = asset->audio_length;
262 this->video_length = asset->video_length;
265 ampeg_bitrate = asset->ampeg_bitrate;
266 ampeg_derivative = asset->ampeg_derivative;
269 vorbis_vbr = asset->vorbis_vbr;
270 vorbis_min_bitrate = asset->vorbis_min_bitrate;
271 vorbis_bitrate = asset->vorbis_bitrate;
272 vorbis_max_bitrate = asset->vorbis_max_bitrate;
275 theora_fix_bitrate = asset->theora_fix_bitrate;
276 theora_bitrate = asset->theora_bitrate;
277 theora_quality = asset->theora_quality;
278 theora_sharpness = asset->theora_sharpness;
279 theora_keyframe_frequency = asset->theora_keyframe_frequency;
280 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
283 jpeg_quality = asset->jpeg_quality;
286 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
287 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
288 vmpeg_progressive = asset->vmpeg_progressive;
289 vmpeg_denoise = asset->vmpeg_denoise;
290 vmpeg_bitrate = asset->vmpeg_bitrate;
291 vmpeg_derivative = asset->vmpeg_derivative;
292 vmpeg_quantization = asset->vmpeg_quantization;
293 vmpeg_cmodel = asset->vmpeg_cmodel;
294 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
295 vmpeg_seq_codes = asset->vmpeg_seq_codes;
296 vmpeg_preset = asset->vmpeg_preset;
297 vmpeg_field_order = asset->vmpeg_field_order;
300 divx_bitrate = asset->divx_bitrate;
301 divx_rc_period = asset->divx_rc_period;
302 divx_rc_reaction_ratio = asset->divx_rc_reaction_ratio;
303 divx_rc_reaction_period = asset->divx_rc_reaction_period;
304 divx_max_key_interval = asset->divx_max_key_interval;
305 divx_max_quantizer = asset->divx_max_quantizer;
306 divx_min_quantizer = asset->divx_min_quantizer;
307 divx_quantizer = asset->divx_quantizer;
308 divx_quality = asset->divx_quality;
309 divx_fix_bitrate = asset->divx_fix_bitrate;
310 divx_use_deblocking = asset->divx_use_deblocking;
312 h264_bitrate = asset->h264_bitrate;
313 h264_quantizer = asset->h264_quantizer;
314 h264_fix_bitrate = asset->h264_fix_bitrate;
317 ms_bitrate = asset->ms_bitrate;
318 ms_bitrate_tolerance = asset->ms_bitrate_tolerance;
319 ms_interlaced = asset->ms_interlaced;
320 ms_quantization = asset->ms_quantization;
321 ms_gop_size = asset->ms_gop_size;
322 ms_fix_bitrate = asset->ms_fix_bitrate;
325 ac3_bitrate = asset->ac3_bitrate;
327 png_use_alpha = asset->png_use_alpha;
328 exr_use_alpha = asset->exr_use_alpha;
329 exr_compression = asset->exr_compression;
331 tiff_cmodel = asset->tiff_cmodel;
332 tiff_compression = asset->tiff_compression;
335 int64_t Asset::get_index_offset(int channel)
337 return index_state->get_index_offset(channel);
340 int64_t Asset::get_index_size(int channel)
342 return index_state->get_index_size(channel);
346 char* Asset::get_compression_text(int audio, int video)
355 return quicktime_acodec_title(acodec);
369 return quicktime_vcodec_title(vcodec);
378 Asset& Asset::operator=(Asset &asset)
380 printf("Asset::operator=\n");
381 copy_location(&asset);
382 copy_format(&asset, 1);
387 int Asset::equivalent(Asset &asset,
391 int result = (!strcmp(asset.path, path) &&
392 format == asset.format);
394 if(result && format == FILE_FFMPEG)
395 result = !strcmp(fformat, asset.fformat);
397 if(test_audio && result)
399 result = (channels == asset.channels &&
400 sample_rate == asset.sample_rate &&
401 bits == asset.bits &&
402 byte_order == asset.byte_order &&
403 signed_ == asset.signed_ &&
404 header == asset.header &&
405 dither == asset.dither &&
406 !strcmp(acodec, asset.acodec));
407 if(result && format == FILE_FFMPEG)
408 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
409 ff_audio_bitrate == asset.ff_audio_bitrate;
414 if(test_video && result)
416 result = (layers == asset.layers &&
417 program == asset.program &&
418 frame_rate == asset.frame_rate &&
419 width == asset.width &&
420 height == asset.height &&
421 !strcmp(vcodec, asset.vcodec));
422 if(result && format == FILE_FFMPEG)
423 result = !strcmp(ff_video_options, asset.ff_video_options) &&
424 ff_video_bitrate == asset.ff_video_bitrate &&
425 ff_video_quality == asset.ff_video_quality;
431 int Asset::operator==(Asset &asset)
434 return equivalent(asset,
439 int Asset::operator!=(Asset &asset)
441 return !(*this == asset);
444 int Asset::test_path(const char *path)
446 if(!strcasecmp(this->path, path))
452 int Asset::test_plugin_title(const char *path)
457 int Asset::read(FileXML *file,
462 // Check for relative path.
465 char new_path[BCTEXTLEN];
466 char asset_directory[BCTEXTLEN];
467 char input_directory[BCTEXTLEN];
470 strcpy(new_path, path);
471 fs.set_current_dir("");
473 fs.extract_dir(asset_directory, path);
476 // Take path of XML file.
477 if(!asset_directory[0])
479 fs.extract_dir(input_directory, file->filename);
481 // Input file has a path
482 if(input_directory[0])
484 fs.join_names(path, input_directory, new_path);
492 result = file->read_tag();
495 if(file->tag.title_is("/ASSET"))
500 if(file->tag.title_is("AUDIO"))
505 if(file->tag.title_is("AUDIO_OMIT"))
510 if(file->tag.title_is("FORMAT"))
512 const char *string = file->tag.get_property("TYPE");
513 format = File::strtoformat(string);
515 file->tag.get_property("USE_HEADER", use_header);
516 file->tag.get_property("FFORMAT", fformat);
519 if(file->tag.title_is("FOLDER"))
521 strcpy(folder, file->read_text());
524 if(file->tag.title_is("VIDEO"))
529 if(file->tag.title_is("VIDEO_OMIT"))
534 if(file->tag.title_is("INDEX"))
542 //printf("Asset::read 2\n");
546 int Asset::read_audio(FileXML *file)
548 if(file->tag.title_is("AUDIO")) audio_data = 1;
549 channels = file->tag.get_property("CHANNELS", 2);
550 // This is loaded from the index file after the EDL but this
551 // should be overridable in the EDL.
552 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
553 bits = file->tag.get_property("BITS", 16);
554 byte_order = file->tag.get_property("BYTE_ORDER", 1);
555 signed_ = file->tag.get_property("SIGNED", 1);
556 header = file->tag.get_property("HEADER", 0);
557 dither = file->tag.get_property("DITHER", 0);
559 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
561 file->tag.get_property("ACODEC", acodec);
566 int Asset::read_video(FileXML *file)
568 if(file->tag.title_is("VIDEO")) video_data = 1;
569 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
570 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
571 height = file->tag.get_property("HEIGHT", height);
572 width = file->tag.get_property("WIDTH", width);
573 layers = file->tag.get_property("LAYERS", layers);
574 program = file->tag.get_property("PROGRAM", program);
575 // This is loaded from the index file after the EDL but this
576 // should be overridable in the EDL.
577 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
579 file->tag.get_property("VCODEC", vcodec);
581 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
586 int Asset::read_index(FileXML *file)
588 index_state->read_xml(file, channels);
592 int Asset::write_index(const char *path, int data_bytes)
594 return index_state->write_index(path, data_bytes, this, audio_length);
597 // Output path is the path of the output file if name truncation is desired.
598 // It is a "" if complete names should be used.
600 int Asset::write(FileXML *file,
602 const char *output_path)
604 char new_path[BCTEXTLEN];
605 char asset_directory[BCTEXTLEN];
606 char output_directory[BCTEXTLEN];
609 // Make path relative
610 fs.extract_dir(asset_directory, path);
611 if(output_path && output_path[0])
612 fs.extract_dir(output_directory, output_path);
614 output_directory[0] = 0;
616 // Asset and EDL are in same directory. Extract just the name.
617 if(!strcmp(asset_directory, output_directory))
619 fs.extract_name(new_path, path);
623 strcpy(new_path, path);
626 file->tag.set_title("ASSET");
627 file->tag.set_property("SRC", new_path);
629 file->append_newline();
631 file->tag.set_title("FOLDER");
633 file->append_text(folder);
634 file->tag.set_title("/FOLDER");
636 file->append_newline();
638 // Write the format information
639 file->tag.set_title("FORMAT");
641 file->tag.set_property("TYPE",
642 File::formattostr(format));
643 file->tag.set_property("USE_HEADER", use_header);
644 file->tag.set_property("FFORMAT", fformat);
647 file->append_newline();
649 // Requiring data to exist caused batch render to lose settings.
650 // But the only way to know if an asset doesn't have audio or video data
651 // is to not write the block.
652 // So change the block name if the asset doesn't have the data.
655 // index goes after source
656 if(index_state->index_status == INDEX_READY && include_index)
659 file->tag.set_title("/ASSET");
661 file->append_newline();
665 int Asset::write_audio(FileXML *file)
667 // Let the reader know if the asset has the data by naming the block.
669 file->tag.set_title("AUDIO");
671 file->tag.set_title("AUDIO_OMIT");
672 // Necessary for PCM audio
673 file->tag.set_property("CHANNELS", channels);
674 file->tag.set_property("RATE", sample_rate);
675 file->tag.set_property("BITS", bits);
676 file->tag.set_property("BYTE_ORDER", byte_order);
677 file->tag.set_property("SIGNED", signed_);
678 file->tag.set_property("HEADER", header);
679 file->tag.set_property("DITHER", dither);
681 file->tag.set_property("ACODEC", acodec);
683 file->tag.set_property("AUDIO_LENGTH", audio_length);
687 // Rely on defaults operations for these.
689 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
690 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
692 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
693 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
694 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
695 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
697 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
703 file->append_newline();
707 int Asset::write_video(FileXML *file)
710 file->tag.set_title("VIDEO");
712 file->tag.set_title("VIDEO_OMIT");
713 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
714 file->tag.set_property("ACTUAL_WIDTH", actual_width);
715 file->tag.set_property("HEIGHT", height);
716 file->tag.set_property("WIDTH", width);
717 file->tag.set_property("LAYERS", layers);
718 file->tag.set_property("PROGRAM", program);
719 file->tag.set_property("FRAMERATE", frame_rate);
721 file->tag.set_property("VCODEC", vcodec);
723 file->tag.set_property("VIDEO_LENGTH", video_length);
729 file->append_newline();
733 int Asset::write_index(FileXML *file)
735 index_state->write_xml(file);
742 const char* Asset::construct_param(const char *param,
747 sprintf(return_value, "%s%s", prefix, param);
749 strcpy(return_value, param);
753 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
754 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
756 void Asset::load_defaults(BC_Hash *defaults,
764 char string[BCTEXTLEN];
766 // Can't save codec here because it's specific to render, record, and effect.
767 // The codec has to be UNKNOWN for file probing to work.
771 GET_DEFAULT("PATH", path);
776 GET_DEFAULT("AUDIO_CODEC", acodec);
777 GET_DEFAULT("VIDEO_CODEC", vcodec);
782 format = GET_DEFAULT("FORMAT", format);
783 use_header = GET_DEFAULT("USE_HEADER", use_header);
784 GET_DEFAULT("FFORMAT", fformat);
789 audio_data = GET_DEFAULT("AUDIO", 1);
790 video_data = GET_DEFAULT("VIDEO", 1);
795 bits = GET_DEFAULT("BITS", 16);
796 dither = GET_DEFAULT("DITHER", 0);
797 signed_ = GET_DEFAULT("SIGNED", 1);
798 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
803 channels = GET_DEFAULT("CHANNELS", 2);
804 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 44100);
805 header = GET_DEFAULT("HEADER", 0);
806 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
810 height = GET_DEFAULT("HEIGHT", height);
811 width = GET_DEFAULT("WIDTH", width);
812 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
813 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
814 program = GET_DEFAULT("PROGRAM", program);
815 layers = GET_DEFAULT("LAYERS", layers);
816 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
817 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
820 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
821 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
823 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
824 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
825 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
826 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
828 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
829 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
830 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
831 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
832 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
833 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
835 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
836 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
837 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
838 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
839 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
841 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
842 mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
843 mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
845 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
846 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
848 // MPEG format information
849 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
850 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
851 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
852 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
853 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
854 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
855 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
856 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
857 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
858 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
859 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
860 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
862 h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
863 h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
864 h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
867 divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
868 divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
869 divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
870 divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
871 divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
872 divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
873 divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
874 divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
875 divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
876 divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
877 divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
879 ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
880 ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
881 ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
882 ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
883 ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
884 ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
886 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
888 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
889 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
890 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
891 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
892 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
897 void Asset::save_defaults(BC_Hash *defaults,
905 char string[BCTEXTLEN];
907 UPDATE_DEFAULT("PATH", path);
914 UPDATE_DEFAULT("FORMAT", format);
915 UPDATE_DEFAULT("USE_HEADER", use_header);
916 UPDATE_DEFAULT("FFORMAT", fformat);
921 UPDATE_DEFAULT("AUDIO", audio_data);
922 UPDATE_DEFAULT("VIDEO", video_data);
927 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
928 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
930 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
931 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
933 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
934 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
935 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
936 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
938 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
939 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
940 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
941 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
942 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
944 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
945 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
946 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
947 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
948 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
949 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
953 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
954 UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
955 UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
961 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
962 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
964 // MPEG format information
965 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
966 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
967 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
968 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
969 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
970 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
971 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
972 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
973 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
974 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
975 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
976 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
978 UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
979 UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
980 UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
982 UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
983 UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
984 UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
985 UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
986 UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
987 UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
988 UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
989 UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
990 UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
991 UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
992 UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
995 UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
996 UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
997 UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
998 UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
999 UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
1000 UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
1002 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
1005 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
1006 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
1007 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
1008 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
1009 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
1014 UPDATE_DEFAULT("BITS", bits);
1015 UPDATE_DEFAULT("DITHER", dither);
1016 UPDATE_DEFAULT("SIGNED", signed_);
1017 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
1025 UPDATE_DEFAULT("CHANNELS", channels);
1026 UPDATE_DEFAULT("RATE", sample_rate);
1027 UPDATE_DEFAULT("HEADER", header);
1028 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
1032 UPDATE_DEFAULT("HEIGHT", height);
1033 UPDATE_DEFAULT("WIDTH", width);
1034 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
1035 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
1036 UPDATE_DEFAULT("PROGRAM", program);
1037 UPDATE_DEFAULT("LAYERS", layers);
1038 UPDATE_DEFAULT("FRAMERATE", frame_rate);
1039 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
1052 int Asset::update_path(char *new_path)
1054 strcpy(path, new_path);
1058 void Asset::update_index(Asset *asset)
1060 index_state->copy_from(asset->index_state);
1064 int Asset::dump(FILE *fp)
1066 fprintf(fp," asset::dump\n");
1067 fprintf(fp," this=%p path=%s\n", this, path);
1068 fprintf(fp," index_status %d\n", index_state->index_status);
1069 fprintf(fp," format %d\n", format);
1070 fprintf(fp," fformat=\"%s\"\n", fformat);
1071 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1072 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1073 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1074 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1075 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1076 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1077 " byte_order %d signed %d header %d dither %d acodec %c%c%c%c\n",
1078 audio_data, channels, sample_rate, bits, byte_order, signed_,
1079 header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1080 fprintf(fp," audio_length " _LD "\n", audio_length);
1081 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1082 " height %d vcodec %c%c%c%c aspect_ratio %f\n",
1083 video_data, layers, program, frame_rate, width, height,
1084 vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio);
1085 fprintf(fp," video_length " _LD " \n", video_length);
1086 fprintf(fp," ms_bitrate_tolerance=%d\n", ms_bitrate_tolerance);
1087 fprintf(fp," ms_quantization=%d\n", ms_quantization);
1088 fprintf(fp," ms_fix_bitrate=%d\n", ms_fix_bitrate);
1089 fprintf(fp," ms_interlaced=%d\n", ms_interlaced);
1090 fprintf(fp," h264_bitrate=%d\n", h264_bitrate);
1091 fprintf(fp," h264_quantizer=%d\n", h264_quantizer);
1092 fprintf(fp," h264_fix_bitrate=%d\n", h264_fix_bitrate);
1098 int Asset::get_audio_channels()
1103 int Asset::get_sample_rate()
1108 int64_t Asset::get_audio_samples()
1110 return audio_length;
1113 int Asset::have_audio()
1118 int Asset::have_video()
1133 double Asset::get_frame_rate()
1139 int Asset::get_video_layers()
1144 int Asset::get_program()
1149 int64_t Asset::get_video_frames()
1151 return video_length;