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;
86 strcpy(fformat,"mp4");
87 ff_format_options[0] = 0;
88 ff_audio_options[0] = 0;
89 ff_sample_format[0] = 0;
91 ff_audio_quality = -1;
92 ff_video_options[0] = 0;
93 ff_pixel_format[0] = 0;
95 ff_video_quality = -1;
101 interlace_mode = ILACE_MODE_UNDETECTED;
105 ampeg_derivative = 3;
108 vorbis_min_bitrate = -1;
109 vorbis_bitrate = 128000;
110 vorbis_max_bitrate = -1;
112 theora_fix_bitrate = 1;
113 theora_bitrate = 860000;
115 theora_sharpness = 2;
116 theora_keyframe_frequency = 64;
117 theora_keyframe_force_frequency = 64;
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;
143 tiff_compression = 0;
153 void Asset::reset_audio()
161 void Asset::reset_video()
165 actual_width = width = 0;
166 actual_height = height = 0;
167 proxy_scale = 0; // not a proxy
170 vmpeg_cmodel = BC_YUV420P;
176 void Asset::boundaries()
178 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
179 // sample_rate & frame_rate are user defined
180 // CLAMP(sample_rate, 1, 1000000);
181 // CLAMP(frame_rate, 0.001, 1000000);
182 CLAMP(channels, 0, 16);
183 CLAMP(width, 0, 10000);
184 CLAMP(height, 0, 10000);
185 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
188 void Asset::copy_from(Asset *asset, int do_index)
190 copy_location(asset);
191 copy_format(asset, do_index);
194 void Asset::copy_location(Asset *asset)
196 strcpy(path, asset->path);
197 folder_no = asset->folder_no;
200 void Asset::copy_format(Asset *asset, int do_index)
202 if(do_index) update_index(asset);
204 audio_data = asset->audio_data;
205 format = asset->format;
206 strcpy(fformat, asset->fformat);
207 strcpy(ff_format_options, asset->ff_format_options);
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_mode = asset->interlace_mode;
220 video_data = asset->video_data;
221 layers = asset->layers;
222 program = asset->program;
223 frame_rate = asset->frame_rate;
224 width = asset->width;
225 height = asset->height;
226 actual_width = asset->actual_width;
227 actual_height = asset->actual_height;
228 proxy_scale = asset->proxy_scale;
229 strcpy(vcodec, asset->vcodec);
230 strcpy(acodec, asset->acodec);
232 strcpy(ff_audio_options, asset->ff_audio_options);
233 strcpy(ff_sample_format, asset->ff_sample_format);
234 ff_audio_bitrate = asset->ff_audio_bitrate;
235 ff_audio_quality = asset->ff_audio_quality;
236 strcpy(ff_video_options, asset->ff_video_options);
237 strcpy(ff_pixel_format, asset->ff_pixel_format);
238 ff_video_bitrate = asset->ff_video_bitrate;
239 ff_video_quality = asset->ff_video_quality;
240 ff_color_space = asset->ff_color_space;
241 ff_color_range = asset->ff_color_range;
243 this->audio_length = asset->audio_length;
244 this->video_length = asset->video_length;
245 this->single_frame = asset->single_frame;
247 ampeg_bitrate = asset->ampeg_bitrate;
248 ampeg_derivative = asset->ampeg_derivative;
251 vorbis_vbr = asset->vorbis_vbr;
252 vorbis_min_bitrate = asset->vorbis_min_bitrate;
253 vorbis_bitrate = asset->vorbis_bitrate;
254 vorbis_max_bitrate = asset->vorbis_max_bitrate;
257 theora_fix_bitrate = asset->theora_fix_bitrate;
258 theora_bitrate = asset->theora_bitrate;
259 theora_quality = asset->theora_quality;
260 theora_sharpness = asset->theora_sharpness;
261 theora_keyframe_frequency = asset->theora_keyframe_frequency;
262 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
265 jpeg_quality = asset->jpeg_quality;
268 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
269 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
270 vmpeg_progressive = asset->vmpeg_progressive;
271 vmpeg_denoise = asset->vmpeg_denoise;
272 vmpeg_bitrate = asset->vmpeg_bitrate;
273 vmpeg_derivative = asset->vmpeg_derivative;
274 vmpeg_quantization = asset->vmpeg_quantization;
275 vmpeg_cmodel = asset->vmpeg_cmodel;
276 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
277 vmpeg_seq_codes = asset->vmpeg_seq_codes;
278 vmpeg_preset = asset->vmpeg_preset;
279 vmpeg_field_order = asset->vmpeg_field_order;
281 ac3_bitrate = asset->ac3_bitrate;
283 png_use_alpha = asset->png_use_alpha;
284 png_depth = asset->png_depth;
285 png_compression = asset->png_compression;
286 exr_use_alpha = asset->exr_use_alpha;
287 exr_compression = asset->exr_compression;
289 tiff_cmodel = asset->tiff_cmodel;
290 tiff_compression = asset->tiff_compression;
292 mov_sphere = asset->mov_sphere;
293 jpeg_sphere = asset->jpeg_sphere;
296 int64_t Asset::get_index_offset(int channel)
298 return index_state->get_index_offset(channel);
301 int64_t Asset::get_index_size(int channel)
303 return index_state->get_index_size(channel);
307 char* Asset::get_compression_text(int audio, int video)
312 if( acodec[0] ) return acodec;
319 if( vcodec[0] ) return vcodec;
326 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
328 int result = format == asset.format ? 1 : 0;
329 if( result && strcmp(asset.path, path) ) {
330 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
331 char *sp = out_path ? strrchr(out_path,'/') : 0;
333 char *apath = FileSystem::basepath(asset.path);
334 char *tpath = FileSystem::basepath(this->path);
336 if( *apath != '/' ) {
337 char *cp = cstrcat(2, out_path, apath);
338 delete [] apath; apath = FileSystem::basepath(cp);
341 if( *tpath != '/' ) {
342 char *cp = cstrcat(2, out_path, tpath);
343 delete [] tpath; tpath = FileSystem::basepath(cp);
347 if( strcmp(apath, tpath) ) result = 0;
353 if( result && format == FILE_FFMPEG &&
354 (strcmp(fformat, asset.fformat) ||
355 strcmp(ff_format_options, asset.ff_format_options)) )
358 if(test_audio && result) {
359 result = (channels == asset.channels &&
360 sample_rate == asset.sample_rate &&
361 bits == asset.bits &&
362 byte_order == asset.byte_order &&
363 signed_ == asset.signed_ &&
364 header == asset.header &&
365 dither == asset.dither &&
366 !strcmp(acodec, asset.acodec));
367 if( result && format == FILE_FFMPEG )
368 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
369 !strcmp(ff_sample_format, asset.ff_sample_format) &&
370 ff_audio_bitrate == asset.ff_audio_bitrate &&
371 ff_audio_quality == asset.ff_audio_quality;
375 if(test_video && result) {
376 result = (layers == asset.layers &&
377 program == asset.program &&
378 frame_rate == asset.frame_rate &&
379 asset.interlace_mode == interlace_mode &&
380 width == asset.width &&
381 height == asset.height &&
382 !strcmp(vcodec, asset.vcodec) &&
383 mov_sphere == asset.mov_sphere &&
384 jpeg_sphere == asset.jpeg_sphere);
385 if( result && format == FILE_FFMPEG )
386 result = !strcmp(ff_video_options, asset.ff_video_options) &&
387 !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
388 ff_video_bitrate == asset.ff_video_bitrate &&
389 ff_video_quality == asset.ff_video_quality &&
390 ff_color_space == asset.ff_color_space &&
391 ff_color_range == asset.ff_color_range;
397 int Asset::test_path(const char *path)
399 if(!strcasecmp(this->path, path))
405 int Asset::read(FileXML *file, int expand_relative)
408 // Check for relative path.
409 if( expand_relative ) {
410 char new_path[BCTEXTLEN];
411 char asset_directory[BCTEXTLEN];
412 char input_directory[BCTEXTLEN];
414 strcpy(new_path, path);
415 fs.set_current_dir("");
416 fs.extract_dir(asset_directory, path);
418 // Take path of XML file.
419 if( !asset_directory[0] ) {
420 fs.extract_dir(input_directory, file->filename);
421 // Input file has a path
422 if(input_directory[0])
423 fs.join_names(path, input_directory, new_path);
427 while( !(result=file->read_tag()) ) {
428 if( file->tag.title_is("/ASSET") ) break;
429 if( file->tag.title_is("AUDIO") ) { read_audio(file); continue; }
430 if( file->tag.title_is("AUDIO_OMIT") ) { read_audio(file); continue; }
431 if( file->tag.title_is("FORMAT") ) { read_format(file); continue; }
432 if( file->tag.title_is("VIDEO") ) { read_video(file); continue; }
433 if( file->tag.title_is("VIDEO_OMIT") ) { read_video(file); continue; }
434 if( file->tag.title_is("INDEX") ) { read_index(file); continue; }
435 if( file->tag.title_is("FOLDER") )
436 folder_no = file->tag.get_property("NUMBER", AW_MEDIA_FOLDER);
440 //printf("Asset::read 2\n");
444 int Asset::read_audio(FileXML *file)
446 if(file->tag.title_is("AUDIO")) audio_data = 1;
447 channels = file->tag.get_property("CHANNELS", 2);
448 // This is loaded from the index file after the EDL but this
449 // should be overridable in the EDL.
450 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
451 bits = file->tag.get_property("BITS", 16);
452 byte_order = file->tag.get_property("BYTE_ORDER", 1);
453 signed_ = file->tag.get_property("SIGNED", 1);
454 header = file->tag.get_property("HEADER", 0);
455 dither = file->tag.get_property("DITHER", 0);
457 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
459 file->tag.get_property("ACODEC", acodec);
463 int Asset::read_video(FileXML *file)
465 char string[BCTEXTLEN];
467 if(file->tag.title_is("VIDEO")) video_data = 1;
468 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
469 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
470 height = file->tag.get_property("HEIGHT", height);
471 width = file->tag.get_property("WIDTH", width);
472 proxy_scale = file->tag.get_property("PROXY_SCALE", 0);
473 layers = file->tag.get_property("LAYERS", layers);
474 program = file->tag.get_property("PROGRAM", program);
475 // This is loaded from the index file after the EDL but this
476 // should be overridable in the EDL.
477 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
479 file->tag.get_property("VCODEC", vcodec);
481 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
482 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
483 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
484 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
485 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
486 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
491 int Asset::read_format(FileXML *file)
493 const char *string = file->tag.get_property("TYPE");
494 format = File::strtoformat(string);
495 use_header = file->tag.get_property("USE_HEADER", use_header);
497 file->tag.get_property("FFORMAT", fformat);
498 ff_format_options[0] = 0;
499 file->tag.get_property("FF_FORMAT_OPTIONS", ff_format_options);
503 int Asset::read_index(FileXML *file)
505 index_state->read_xml(file, channels);
509 // Output path is the path of the output file if name truncation is desired.
510 // It is a "" if complete names should be used.
512 int Asset::write(FileXML *file,
514 const char *output_path)
516 char new_path[BCTEXTLEN];
517 char asset_directory[BCTEXTLEN];
518 char output_directory[BCTEXTLEN];
521 // Make path relative
522 fs.extract_dir(asset_directory, path);
523 if(output_path && output_path[0])
524 fs.extract_dir(output_directory, output_path);
526 output_directory[0] = 0;
528 // Asset and EDL are in same directory. Extract just the name.
529 if(!strcmp(asset_directory, output_directory))
531 fs.extract_name(new_path, path);
535 strcpy(new_path, path);
538 file->tag.set_title("ASSET");
539 file->tag.set_property("SRC", new_path);
541 file->append_newline();
543 file->tag.set_title("FOLDER");
544 file->tag.set_property("NUMBER", folder_no);
546 file->tag.set_title("/FOLDER");
548 file->append_newline();
550 // Write the format information
551 file->tag.set_title("FORMAT");
553 file->tag.set_property("TYPE",
554 File::formattostr(format));
555 file->tag.set_property("USE_HEADER", use_header);
556 file->tag.set_property("FFORMAT", fformat);
557 file->tag.set_property("FF_FORMAT_OPTIONS", ff_format_options);
560 file->tag.set_title("/FORMAT");
562 file->append_newline();
564 // Requiring data to exist caused batch render to lose settings.
565 // But the only way to know if an asset doesn't have audio or video data
566 // is to not write the block.
567 // So change the block name if the asset doesn't have the data.
570 // index goes after source
571 if( include_index && index_state &&
572 index_state->index_status == INDEX_READY )
575 file->tag.set_title("/ASSET");
577 file->append_newline();
581 int Asset::write_audio(FileXML *file)
583 // Let the reader know if the asset has the data by naming the block.
585 file->tag.set_title("AUDIO");
587 file->tag.set_title("AUDIO_OMIT");
588 // Necessary for PCM audio
589 file->tag.set_property("CHANNELS", channels);
590 file->tag.set_property("RATE", sample_rate);
591 file->tag.set_property("BITS", bits);
592 file->tag.set_property("BYTE_ORDER", byte_order);
593 file->tag.set_property("SIGNED", signed_);
594 file->tag.set_property("HEADER", header);
595 file->tag.set_property("DITHER", dither);
597 file->tag.set_property("ACODEC", acodec);
599 file->tag.set_property("AUDIO_LENGTH", audio_length);
603 // Rely on defaults operations for these.
605 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
606 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
608 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
609 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
610 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
611 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
613 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
620 file->tag.set_title("/AUDIO");
622 file->tag.set_title("/AUDIO_OMIT");
624 file->append_newline();
628 int Asset::write_video(FileXML *file)
630 char string[BCTEXTLEN];
633 file->tag.set_title("VIDEO");
635 file->tag.set_title("VIDEO_OMIT");
636 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
637 file->tag.set_property("ACTUAL_WIDTH", actual_width);
638 file->tag.set_property("HEIGHT", height);
639 file->tag.set_property("WIDTH", width);
640 file->tag.set_property("PROXY_SCALE", proxy_scale);
641 file->tag.set_property("LAYERS", layers);
642 file->tag.set_property("PROGRAM", program);
643 file->tag.set_property("FRAMERATE", frame_rate);
645 file->tag.set_property("VCODEC", vcodec);
647 file->tag.set_property("VIDEO_LENGTH", video_length);
648 file->tag.set_property("MOV_SPHERE", mov_sphere);
649 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
650 file->tag.set_property("SINGLE_FRAME", single_frame);
652 ilacemode_to_xmltext(string, interlace_mode);
653 file->tag.set_property("INTERLACE_MODE", string);
657 file->tag.set_title("/VIDEO");
659 file->tag.set_title("/VIDEO_OMIT");
662 file->append_newline();
666 int Asset::write_index(FileXML *file)
668 index_state->write_xml(file);
673 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
676 sprintf(return_value, "%s%s", prefix, param);
678 strcpy(return_value, param);
682 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
683 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
685 void Asset::load_defaults(BC_Hash *defaults,
693 char string[BCTEXTLEN];
695 // Can't save codec here because it's specific to render, record, and effect.
696 // The codec has to be UNKNOWN for file probing to work.
700 GET_DEFAULT("PATH", path);
705 GET_DEFAULT("AUDIO_CODEC", acodec);
706 GET_DEFAULT("VIDEO_CODEC", vcodec);
711 format = GET_DEFAULT("FORMAT", format);
712 use_header = GET_DEFAULT("USE_HEADER", use_header);
713 GET_DEFAULT("FFORMAT", fformat);
714 GET_DEFAULT("FF_FORMAT_OPTIONS", ff_format_options);
719 audio_data = GET_DEFAULT("AUDIO", 1);
720 video_data = GET_DEFAULT("VIDEO", 1);
725 bits = GET_DEFAULT("BITS", 16);
726 dither = GET_DEFAULT("DITHER", 0);
727 signed_ = GET_DEFAULT("SIGNED", 1);
728 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
732 channels = GET_DEFAULT("CHANNELS", 2);
733 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
734 header = GET_DEFAULT("HEADER", 0);
735 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
739 height = GET_DEFAULT("HEIGHT", height);
740 width = GET_DEFAULT("WIDTH", width);
741 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
742 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
743 proxy_scale = GET_DEFAULT("PROXY_SCALE", proxy_scale);
744 program = GET_DEFAULT("PROGRAM", program);
745 layers = GET_DEFAULT("LAYERS", layers);
746 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
747 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
748 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
751 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
752 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
754 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
755 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
756 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
757 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
759 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
760 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
761 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
762 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
763 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
764 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
766 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
767 GET_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
768 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
769 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
770 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
771 GET_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
772 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
773 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
774 ff_color_space = GET_DEFAULT("FF_COLOR_SPACE", ff_color_space);
775 ff_color_range = GET_DEFAULT("FF_COLOR_RANGE", ff_color_range);
776 GET_DEFAULT("FF_FORMAT_OPTIONS", ff_format_options);
778 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
780 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
781 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
782 interlace_mode = ILACE_MODE_UNDETECTED;
784 // MPEG format information
785 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
786 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
787 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
788 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
789 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
790 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
791 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
792 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
793 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
794 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
795 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
796 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
798 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
799 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
800 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
801 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
802 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
803 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
806 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
808 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
809 png_depth = GET_DEFAULT("PNG_DEPTH", png_depth);
810 png_compression = GET_DEFAULT("PNG_COMPRESSION", png_compression);
811 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
812 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
813 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
814 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
816 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
817 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
821 void Asset::save_defaults(BC_Hash *defaults,
829 char string[BCTEXTLEN];
831 UPDATE_DEFAULT("PATH", path);
838 UPDATE_DEFAULT("FORMAT", format);
839 UPDATE_DEFAULT("USE_HEADER", use_header);
840 UPDATE_DEFAULT("FFORMAT", fformat);
841 UPDATE_DEFAULT("FF_FORMAT_OPTIONS", ff_format_options);
846 UPDATE_DEFAULT("AUDIO", audio_data);
847 UPDATE_DEFAULT("VIDEO", video_data);
852 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
853 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
855 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
856 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
858 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
859 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
860 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
861 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
863 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
864 UPDATE_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
865 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
866 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
867 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
868 UPDATE_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
869 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
870 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
871 UPDATE_DEFAULT("FF_COLOR_SPACE", ff_color_space);
872 UPDATE_DEFAULT("FF_COLOR_RANGE", ff_color_range);
874 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
875 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
876 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
877 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
878 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
879 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
883 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
885 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
886 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
888 // MPEG format information
889 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
890 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
891 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
892 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
893 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
894 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
895 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
896 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
897 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
898 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
899 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
900 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
903 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
906 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
907 UPDATE_DEFAULT("PNG_DEPTH", png_depth);
908 UPDATE_DEFAULT("PNG_COMPRESSION", png_compression);
909 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
910 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
911 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
912 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
916 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
917 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
925 UPDATE_DEFAULT("BITS", bits);
926 UPDATE_DEFAULT("DITHER", dither);
927 UPDATE_DEFAULT("SIGNED", signed_);
928 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
935 UPDATE_DEFAULT("CHANNELS", channels);
936 UPDATE_DEFAULT("RATE", sample_rate);
937 UPDATE_DEFAULT("HEADER", header);
938 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
942 UPDATE_DEFAULT("HEIGHT", height);
943 UPDATE_DEFAULT("WIDTH", width);
944 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
945 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
946 UPDATE_DEFAULT("PROXY_SCALE", proxy_scale);
947 UPDATE_DEFAULT("PROGRAM", program);
948 UPDATE_DEFAULT("LAYERS", layers);
949 UPDATE_DEFAULT("FRAMERATE", frame_rate);
950 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
951 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
964 int Asset::dump(FILE *fp)
966 fprintf(fp," asset::dump\n");
967 fprintf(fp," this=%p path=%s\n", this, path);
968 fprintf(fp," index_status %d\n", index_state->index_status);
969 fprintf(fp," format %d\n", format);
970 fprintf(fp," fformat=\"%s\"\n", fformat);
971 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
972 fprintf(fp," ff_sample_format=\"%s\"\n", ff_sample_format);
973 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
974 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
975 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
976 fprintf(fp," ff_pixel_format=\"%s\"\n", ff_pixel_format);
977 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
978 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
979 fprintf(fp," ff_color_space=%d\n", ff_color_space);
980 fprintf(fp," ff_color_range=%d\n", ff_color_range);
981 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
982 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
983 audio_data, channels, sample_rate, bits, byte_order, signed_,
984 header, dither, acodec);
985 fprintf(fp," audio_length %jd\n", audio_length);
986 char string[BCTEXTLEN];
987 ilacemode_to_xmltext(string, interlace_mode);
988 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
989 " height %d vcodec %s aspect_ratio %f ilace_mode %s\n",
990 video_data, layers, program, frame_rate, width, height,
991 vcodec, aspect_ratio,string);
992 fprintf(fp," actual_width %d actual_height %d proxy_scale %d"
993 " video_length %jd repeat %d\n",
994 actual_width, actual_height, proxy_scale, video_length,
996 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
997 fprintf(fp," mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
1003 int Asset::get_audio_channels()
1008 int Asset::get_sample_rate()
1013 int64_t Asset::get_audio_samples()
1015 return audio_length;
1018 int Asset::have_audio()
1023 int Asset::have_video()
1038 double Asset::get_frame_rate()
1044 int Asset::get_video_layers()
1049 int Asset::get_program()
1054 int64_t Asset::get_video_frames()
1056 return video_length;
1059 double Asset::total_length_framealigned(double fps)
1061 if (video_data && audio_data) {
1062 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1063 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1064 return MIN(aud,vid);
1068 return (double)audio_length / sample_rate;
1071 return (double)video_length / frame_rate;