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"
39 : Indexable(1), ListItem<Asset>()
44 Asset::Asset(Asset &asset)
45 : Indexable(1), ListItem<Asset>()
48 this->copy_from(&asset, 1);
51 Asset::Asset(const char *path)
52 : Indexable(1), ListItem<Asset>()
55 strcpy(this->path, path);
58 Asset::Asset(const int plugin_type, const char *plugin_title)
59 : Indexable(1), ListItem<Asset>()
68 int Asset::init_values()
71 // Has to be unknown for file probing to succeed
72 format = FILE_UNKNOWN;
85 ff_audio_options[0] = 0;
86 ff_video_options[0] = 0;
98 vorbis_min_bitrate = -1;
99 vorbis_bitrate = 128000;
100 vorbis_max_bitrate = -1;
102 theora_fix_bitrate = 1;
103 theora_bitrate = 860000;
105 theora_sharpness = 2;
106 theora_keyframe_frequency = 64;
107 theora_keyframe_force_frequency = 64;
109 mp3_bitrate = 256000;
112 mp4a_bitrate = 256000;
113 mp4a_quantqual = 100;
118 vmpeg_iframe_distance = 45;
119 vmpeg_pframe_distance = 0;
120 vmpeg_progressive = 0;
122 vmpeg_bitrate = 1000000;
123 vmpeg_derivative = 1;
124 vmpeg_quantization = 15;
125 vmpeg_cmodel = BC_YUV420P;
126 vmpeg_fix_bitrate = 0;
129 vmpeg_field_order = 0;
131 // Divx parameters. BC_Hash from encore2
132 divx_bitrate = 2000000;
134 divx_rc_reaction_ratio = 45;
135 divx_rc_reaction_period = 10;
136 divx_max_key_interval = 250;
137 divx_max_quantizer = 31;
138 divx_min_quantizer = 1;
141 divx_fix_bitrate = 1;
142 divx_use_deblocking = 1;
144 h264_bitrate = 2000000;
146 h264_fix_bitrate = 0;
148 ms_bitrate = 1000000;
149 ms_bitrate_tolerance = 500000;
150 ms_quantization = 10;
162 tiff_compression = 0;
171 void Asset::reset_audio()
179 void Asset::reset_video()
183 actual_width = width = 0;
184 actual_height = height = 0;
186 vmpeg_cmodel = BC_YUV420P;
192 void Asset::boundaries()
194 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
195 // sample_rate & frame_rate are user defined
196 // CLAMP(sample_rate, 1, 1000000);
197 // CLAMP(frame_rate, 0.001, 1000000);
198 CLAMP(channels, 0, 16);
199 CLAMP(width, 0, 10000);
200 CLAMP(height, 0, 10000);
201 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
204 void Asset::copy_from(Asset *asset, int do_index)
206 copy_location(asset);
207 copy_format(asset, do_index);
210 void Asset::copy_location(Asset *asset)
212 strcpy(this->path, asset->path);
213 strcpy(this->folder, asset->folder);
216 void Asset::copy_format(Asset *asset, int do_index)
218 if(do_index) update_index(asset);
220 audio_data = asset->audio_data;
221 format = asset->format;
222 strcpy(fformat, asset->fformat);
223 channels = asset->channels;
224 sample_rate = asset->sample_rate;
226 byte_order = asset->byte_order;
227 signed_ = asset->signed_;
228 header = asset->header;
229 dither = asset->dither;
230 mp3_bitrate = asset->mp3_bitrate;
231 mp4a_bitrate = asset->mp4a_bitrate;
232 mp4a_quantqual = asset->mp4a_quantqual;
233 use_header = asset->use_header;
234 aspect_ratio = asset->aspect_ratio;
236 video_data = asset->video_data;
237 layers = asset->layers;
238 program = asset->program;
239 frame_rate = asset->frame_rate;
240 width = asset->width;
241 height = asset->height;
242 actual_width = asset->actual_width;
243 actual_height = asset->actual_height;
244 strcpy(vcodec, asset->vcodec);
245 strcpy(acodec, asset->acodec);
247 strcpy(ff_audio_options, asset->ff_audio_options);
248 strcpy(ff_video_options, asset->ff_video_options);
249 ff_audio_bitrate = asset->ff_audio_bitrate;
250 ff_video_bitrate = asset->ff_video_bitrate;
251 ff_video_quality = asset->ff_video_quality;
253 this->audio_length = asset->audio_length;
254 this->video_length = asset->video_length;
257 ampeg_bitrate = asset->ampeg_bitrate;
258 ampeg_derivative = asset->ampeg_derivative;
261 vorbis_vbr = asset->vorbis_vbr;
262 vorbis_min_bitrate = asset->vorbis_min_bitrate;
263 vorbis_bitrate = asset->vorbis_bitrate;
264 vorbis_max_bitrate = asset->vorbis_max_bitrate;
267 theora_fix_bitrate = asset->theora_fix_bitrate;
268 theora_bitrate = asset->theora_bitrate;
269 theora_quality = asset->theora_quality;
270 theora_sharpness = asset->theora_sharpness;
271 theora_keyframe_frequency = asset->theora_keyframe_frequency;
272 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
275 jpeg_quality = asset->jpeg_quality;
278 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
279 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
280 vmpeg_progressive = asset->vmpeg_progressive;
281 vmpeg_denoise = asset->vmpeg_denoise;
282 vmpeg_bitrate = asset->vmpeg_bitrate;
283 vmpeg_derivative = asset->vmpeg_derivative;
284 vmpeg_quantization = asset->vmpeg_quantization;
285 vmpeg_cmodel = asset->vmpeg_cmodel;
286 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
287 vmpeg_seq_codes = asset->vmpeg_seq_codes;
288 vmpeg_preset = asset->vmpeg_preset;
289 vmpeg_field_order = asset->vmpeg_field_order;
292 divx_bitrate = asset->divx_bitrate;
293 divx_rc_period = asset->divx_rc_period;
294 divx_rc_reaction_ratio = asset->divx_rc_reaction_ratio;
295 divx_rc_reaction_period = asset->divx_rc_reaction_period;
296 divx_max_key_interval = asset->divx_max_key_interval;
297 divx_max_quantizer = asset->divx_max_quantizer;
298 divx_min_quantizer = asset->divx_min_quantizer;
299 divx_quantizer = asset->divx_quantizer;
300 divx_quality = asset->divx_quality;
301 divx_fix_bitrate = asset->divx_fix_bitrate;
302 divx_use_deblocking = asset->divx_use_deblocking;
304 h264_bitrate = asset->h264_bitrate;
305 h264_quantizer = asset->h264_quantizer;
306 h264_fix_bitrate = asset->h264_fix_bitrate;
309 ms_bitrate = asset->ms_bitrate;
310 ms_bitrate_tolerance = asset->ms_bitrate_tolerance;
311 ms_interlaced = asset->ms_interlaced;
312 ms_quantization = asset->ms_quantization;
313 ms_gop_size = asset->ms_gop_size;
314 ms_fix_bitrate = asset->ms_fix_bitrate;
317 ac3_bitrate = asset->ac3_bitrate;
319 png_use_alpha = asset->png_use_alpha;
320 exr_use_alpha = asset->exr_use_alpha;
321 exr_compression = asset->exr_compression;
323 tiff_cmodel = asset->tiff_cmodel;
324 tiff_compression = asset->tiff_compression;
327 int64_t Asset::get_index_offset(int channel)
329 return index_state->get_index_offset(channel);
332 int64_t Asset::get_index_size(int channel)
334 return index_state->get_index_size(channel);
338 char* Asset::get_compression_text(int audio, int video)
343 if( acodec[0] ) return acodec;
350 if( vcodec[0] ) return vcodec;
357 Asset& Asset::operator=(Asset &asset)
359 printf("Asset::operator=\n");
360 copy_location(&asset);
361 copy_format(&asset, 1);
366 int Asset::equivalent(Asset &asset,
370 int result = (!strcmp(asset.path, path) &&
371 format == asset.format);
373 if(result && format == FILE_FFMPEG)
374 result = !strcmp(fformat, asset.fformat);
376 if(test_audio && result)
378 result = (channels == asset.channels &&
379 sample_rate == asset.sample_rate &&
380 bits == asset.bits &&
381 byte_order == asset.byte_order &&
382 signed_ == asset.signed_ &&
383 header == asset.header &&
384 dither == asset.dither &&
385 !strcmp(acodec, asset.acodec));
386 if(result && format == FILE_FFMPEG)
387 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
388 ff_audio_bitrate == asset.ff_audio_bitrate;
393 if(test_video && result)
395 result = (layers == asset.layers &&
396 program == asset.program &&
397 frame_rate == asset.frame_rate &&
398 width == asset.width &&
399 height == asset.height &&
400 !strcmp(vcodec, asset.vcodec));
401 if(result && format == FILE_FFMPEG)
402 result = !strcmp(ff_video_options, asset.ff_video_options) &&
403 ff_video_bitrate == asset.ff_video_bitrate &&
404 ff_video_quality == asset.ff_video_quality;
410 int Asset::operator==(Asset &asset)
413 return equivalent(asset,
418 int Asset::operator!=(Asset &asset)
420 return !(*this == asset);
423 int Asset::test_path(const char *path)
425 if(!strcasecmp(this->path, path))
431 int Asset::test_plugin_title(const char *path)
436 int Asset::read(FileXML *file,
441 // Check for relative path.
444 char new_path[BCTEXTLEN];
445 char asset_directory[BCTEXTLEN];
446 char input_directory[BCTEXTLEN];
449 strcpy(new_path, path);
450 fs.set_current_dir("");
452 fs.extract_dir(asset_directory, path);
455 // Take path of XML file.
456 if(!asset_directory[0])
458 fs.extract_dir(input_directory, file->filename);
460 // Input file has a path
461 if(input_directory[0])
463 fs.join_names(path, input_directory, new_path);
471 result = file->read_tag();
474 if(file->tag.title_is("/ASSET"))
479 if(file->tag.title_is("AUDIO"))
484 if(file->tag.title_is("AUDIO_OMIT"))
489 if(file->tag.title_is("FORMAT"))
491 const char *string = file->tag.get_property("TYPE");
492 format = File::strtoformat(string);
494 file->tag.get_property("USE_HEADER", use_header);
495 file->tag.get_property("FFORMAT", fformat);
498 if(file->tag.title_is("FOLDER"))
500 strcpy(folder, file->read_text());
503 if(file->tag.title_is("VIDEO"))
508 if(file->tag.title_is("VIDEO_OMIT"))
513 if(file->tag.title_is("INDEX"))
521 //printf("Asset::read 2\n");
525 int Asset::read_audio(FileXML *file)
527 if(file->tag.title_is("AUDIO")) audio_data = 1;
528 channels = file->tag.get_property("CHANNELS", 2);
529 // This is loaded from the index file after the EDL but this
530 // should be overridable in the EDL.
531 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
532 bits = file->tag.get_property("BITS", 16);
533 byte_order = file->tag.get_property("BYTE_ORDER", 1);
534 signed_ = file->tag.get_property("SIGNED", 1);
535 header = file->tag.get_property("HEADER", 0);
536 dither = file->tag.get_property("DITHER", 0);
538 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
540 file->tag.get_property("ACODEC", acodec);
545 int Asset::read_video(FileXML *file)
547 if(file->tag.title_is("VIDEO")) video_data = 1;
548 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
549 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
550 height = file->tag.get_property("HEIGHT", height);
551 width = file->tag.get_property("WIDTH", width);
552 layers = file->tag.get_property("LAYERS", layers);
553 program = file->tag.get_property("PROGRAM", program);
554 // This is loaded from the index file after the EDL but this
555 // should be overridable in the EDL.
556 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
558 file->tag.get_property("VCODEC", vcodec);
560 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
565 int Asset::read_index(FileXML *file)
567 index_state->read_xml(file, channels);
571 // Output path is the path of the output file if name truncation is desired.
572 // It is a "" if complete names should be used.
574 int Asset::write(FileXML *file,
576 const char *output_path)
578 char new_path[BCTEXTLEN];
579 char asset_directory[BCTEXTLEN];
580 char output_directory[BCTEXTLEN];
583 // Make path relative
584 fs.extract_dir(asset_directory, path);
585 if(output_path && output_path[0])
586 fs.extract_dir(output_directory, output_path);
588 output_directory[0] = 0;
590 // Asset and EDL are in same directory. Extract just the name.
591 if(!strcmp(asset_directory, output_directory))
593 fs.extract_name(new_path, path);
597 strcpy(new_path, path);
600 file->tag.set_title("ASSET");
601 file->tag.set_property("SRC", new_path);
603 file->append_newline();
605 file->tag.set_title("FOLDER");
607 file->append_text(folder);
608 file->tag.set_title("/FOLDER");
610 file->append_newline();
612 // Write the format information
613 file->tag.set_title("FORMAT");
615 file->tag.set_property("TYPE",
616 File::formattostr(format));
617 file->tag.set_property("USE_HEADER", use_header);
618 file->tag.set_property("FFORMAT", fformat);
621 file->append_newline();
623 // Requiring data to exist caused batch render to lose settings.
624 // But the only way to know if an asset doesn't have audio or video data
625 // is to not write the block.
626 // So change the block name if the asset doesn't have the data.
629 // index goes after source
630 if(index_state->index_status == INDEX_READY && include_index)
633 file->tag.set_title("/ASSET");
635 file->append_newline();
639 int Asset::write_audio(FileXML *file)
641 // Let the reader know if the asset has the data by naming the block.
643 file->tag.set_title("AUDIO");
645 file->tag.set_title("AUDIO_OMIT");
646 // Necessary for PCM audio
647 file->tag.set_property("CHANNELS", channels);
648 file->tag.set_property("RATE", sample_rate);
649 file->tag.set_property("BITS", bits);
650 file->tag.set_property("BYTE_ORDER", byte_order);
651 file->tag.set_property("SIGNED", signed_);
652 file->tag.set_property("HEADER", header);
653 file->tag.set_property("DITHER", dither);
655 file->tag.set_property("ACODEC", acodec);
657 file->tag.set_property("AUDIO_LENGTH", audio_length);
661 // Rely on defaults operations for these.
663 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
664 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
666 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
667 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
668 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
669 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
671 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
677 file->append_newline();
681 int Asset::write_video(FileXML *file)
684 file->tag.set_title("VIDEO");
686 file->tag.set_title("VIDEO_OMIT");
687 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
688 file->tag.set_property("ACTUAL_WIDTH", actual_width);
689 file->tag.set_property("HEIGHT", height);
690 file->tag.set_property("WIDTH", width);
691 file->tag.set_property("LAYERS", layers);
692 file->tag.set_property("PROGRAM", program);
693 file->tag.set_property("FRAMERATE", frame_rate);
695 file->tag.set_property("VCODEC", vcodec);
697 file->tag.set_property("VIDEO_LENGTH", video_length);
703 file->append_newline();
707 int Asset::write_index(FileXML *file)
709 index_state->write_xml(file);
715 const char* Asset::construct_param(const char *param,
720 sprintf(return_value, "%s%s", prefix, param);
722 strcpy(return_value, param);
726 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
727 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
729 void Asset::load_defaults(BC_Hash *defaults,
737 char string[BCTEXTLEN];
739 // Can't save codec here because it's specific to render, record, and effect.
740 // The codec has to be UNKNOWN for file probing to work.
744 GET_DEFAULT("PATH", path);
749 GET_DEFAULT("AUDIO_CODEC", acodec);
750 GET_DEFAULT("VIDEO_CODEC", vcodec);
755 format = GET_DEFAULT("FORMAT", format);
756 use_header = GET_DEFAULT("USE_HEADER", use_header);
757 GET_DEFAULT("FFORMAT", fformat);
762 audio_data = GET_DEFAULT("AUDIO", 1);
763 video_data = GET_DEFAULT("VIDEO", 1);
768 bits = GET_DEFAULT("BITS", 16);
769 dither = GET_DEFAULT("DITHER", 0);
770 signed_ = GET_DEFAULT("SIGNED", 1);
771 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
776 channels = GET_DEFAULT("CHANNELS", 2);
777 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 44100);
778 header = GET_DEFAULT("HEADER", 0);
779 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
783 height = GET_DEFAULT("HEIGHT", height);
784 width = GET_DEFAULT("WIDTH", width);
785 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
786 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
787 program = GET_DEFAULT("PROGRAM", program);
788 layers = GET_DEFAULT("LAYERS", layers);
789 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
790 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
793 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
794 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
796 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
797 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
798 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
799 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
801 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
802 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
803 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
804 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
805 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
806 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
808 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
809 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
810 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
811 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
812 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
814 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
815 mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
816 mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
818 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
819 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
821 // MPEG format information
822 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
823 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
824 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
825 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
826 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
827 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
828 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
829 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
830 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
831 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
832 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
833 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
835 h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
836 h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
837 h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
840 divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
841 divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
842 divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
843 divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
844 divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
845 divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
846 divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
847 divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
848 divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
849 divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
850 divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
852 ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
853 ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
854 ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
855 ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
856 ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
857 ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
859 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
861 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
862 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
863 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
864 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
865 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
870 void Asset::save_defaults(BC_Hash *defaults,
878 char string[BCTEXTLEN];
880 UPDATE_DEFAULT("PATH", path);
887 UPDATE_DEFAULT("FORMAT", format);
888 UPDATE_DEFAULT("USE_HEADER", use_header);
889 UPDATE_DEFAULT("FFORMAT", fformat);
894 UPDATE_DEFAULT("AUDIO", audio_data);
895 UPDATE_DEFAULT("VIDEO", video_data);
900 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
901 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
903 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
904 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
906 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
907 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
908 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
909 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
911 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
912 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
913 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
914 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
915 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
917 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
918 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
919 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
920 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
921 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
922 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
926 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
927 UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
928 UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
934 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
935 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
937 // MPEG format information
938 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
939 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
940 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
941 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
942 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
943 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
944 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
945 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
946 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
947 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
948 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
949 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
951 UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
952 UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
953 UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
955 UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
956 UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
957 UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
958 UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
959 UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
960 UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
961 UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
962 UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
963 UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
964 UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
965 UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
968 UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
969 UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
970 UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
971 UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
972 UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
973 UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
975 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
978 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
979 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
980 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
981 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
982 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
987 UPDATE_DEFAULT("BITS", bits);
988 UPDATE_DEFAULT("DITHER", dither);
989 UPDATE_DEFAULT("SIGNED", signed_);
990 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
998 UPDATE_DEFAULT("CHANNELS", channels);
999 UPDATE_DEFAULT("RATE", sample_rate);
1000 UPDATE_DEFAULT("HEADER", header);
1001 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
1005 UPDATE_DEFAULT("HEIGHT", height);
1006 UPDATE_DEFAULT("WIDTH", width);
1007 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
1008 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
1009 UPDATE_DEFAULT("PROGRAM", program);
1010 UPDATE_DEFAULT("LAYERS", layers);
1011 UPDATE_DEFAULT("FRAMERATE", frame_rate);
1012 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
1025 int Asset::dump(FILE *fp)
1027 fprintf(fp," asset::dump\n");
1028 fprintf(fp," this=%p path=%s\n", this, path);
1029 fprintf(fp," index_status %d\n", index_state->index_status);
1030 fprintf(fp," format %d\n", format);
1031 fprintf(fp," fformat=\"%s\"\n", fformat);
1032 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1033 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1034 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1035 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1036 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1037 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1038 " byte_order %d signed %d header %d dither %d acodec %c%c%c%c\n",
1039 audio_data, channels, sample_rate, bits, byte_order, signed_,
1040 header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
1041 fprintf(fp," audio_length " _LD "\n", audio_length);
1042 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1043 " height %d vcodec %c%c%c%c aspect_ratio %f\n",
1044 video_data, layers, program, frame_rate, width, height,
1045 vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio);
1046 fprintf(fp," video_length " _LD " \n", video_length);
1047 fprintf(fp," ms_bitrate_tolerance=%d\n", ms_bitrate_tolerance);
1048 fprintf(fp," ms_quantization=%d\n", ms_quantization);
1049 fprintf(fp," ms_fix_bitrate=%d\n", ms_fix_bitrate);
1050 fprintf(fp," ms_interlaced=%d\n", ms_interlaced);
1051 fprintf(fp," h264_bitrate=%d\n", h264_bitrate);
1052 fprintf(fp," h264_quantizer=%d\n", h264_quantizer);
1053 fprintf(fp," h264_fix_bitrate=%d\n", h264_fix_bitrate);
1059 int Asset::get_audio_channels()
1064 int Asset::get_sample_rate()
1069 int64_t Asset::get_audio_samples()
1071 return audio_length;
1074 int Asset::have_audio()
1079 int Asset::have_video()
1094 double Asset::get_frame_rate()
1100 int Asset::get_video_layers()
1105 int Asset::get_program()
1110 int64_t Asset::get_video_frames()
1112 return video_length;