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
168 proxy_edl = 0; // not proxy from edl
170 timecode = -2; // unknown
172 vmpeg_cmodel = BC_YUV420P;
178 void Asset::boundaries()
180 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
181 // sample_rate & frame_rate are user defined
182 // CLAMP(sample_rate, 1, 1000000);
183 // CLAMP(frame_rate, 0.001, 1000000);
184 CLAMP(channels, 0, 16);
185 CLAMP(width, 0, 10000);
186 CLAMP(height, 0, 10000);
187 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
190 void Asset::copy_from(Asset *asset, int do_index)
192 copy_location(asset);
193 copy_format(asset, do_index);
196 void Asset::copy_location(Asset *asset)
198 strcpy(path, asset->path);
199 folder_no = asset->folder_no;
202 void Asset::copy_format(Asset *asset, int do_index)
204 if(do_index) update_index(asset);
206 audio_data = asset->audio_data;
207 format = asset->format;
208 strcpy(fformat, asset->fformat);
209 strcpy(ff_format_options, asset->ff_format_options);
210 channels = asset->channels;
211 sample_rate = asset->sample_rate;
213 byte_order = asset->byte_order;
214 signed_ = asset->signed_;
215 header = asset->header;
216 dither = asset->dither;
217 mp3_bitrate = asset->mp3_bitrate;
218 use_header = asset->use_header;
219 aspect_ratio = asset->aspect_ratio;
220 interlace_mode = asset->interlace_mode;
221 timecode = asset->timecode;
223 video_data = asset->video_data;
224 layers = asset->layers;
225 program = asset->program;
226 frame_rate = asset->frame_rate;
227 width = asset->width;
228 height = asset->height;
229 actual_width = asset->actual_width;
230 actual_height = asset->actual_height;
231 proxy_scale = asset->proxy_scale;
232 proxy_edl = asset->proxy_edl;
233 strcpy(vcodec, asset->vcodec);
234 strcpy(acodec, asset->acodec);
236 strcpy(ff_audio_options, asset->ff_audio_options);
237 strcpy(ff_sample_format, asset->ff_sample_format);
238 ff_audio_bitrate = asset->ff_audio_bitrate;
239 ff_audio_quality = asset->ff_audio_quality;
240 strcpy(ff_video_options, asset->ff_video_options);
241 strcpy(ff_pixel_format, asset->ff_pixel_format);
242 ff_video_bitrate = asset->ff_video_bitrate;
243 ff_video_quality = asset->ff_video_quality;
244 ff_color_space = asset->ff_color_space;
245 ff_color_range = asset->ff_color_range;
247 this->audio_length = asset->audio_length;
248 this->video_length = asset->video_length;
249 this->single_frame = asset->single_frame;
251 ampeg_bitrate = asset->ampeg_bitrate;
252 ampeg_derivative = asset->ampeg_derivative;
255 vorbis_vbr = asset->vorbis_vbr;
256 vorbis_min_bitrate = asset->vorbis_min_bitrate;
257 vorbis_bitrate = asset->vorbis_bitrate;
258 vorbis_max_bitrate = asset->vorbis_max_bitrate;
261 theora_fix_bitrate = asset->theora_fix_bitrate;
262 theora_bitrate = asset->theora_bitrate;
263 theora_quality = asset->theora_quality;
264 theora_sharpness = asset->theora_sharpness;
265 theora_keyframe_frequency = asset->theora_keyframe_frequency;
266 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
269 jpeg_quality = asset->jpeg_quality;
272 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
273 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
274 vmpeg_progressive = asset->vmpeg_progressive;
275 vmpeg_denoise = asset->vmpeg_denoise;
276 vmpeg_bitrate = asset->vmpeg_bitrate;
277 vmpeg_derivative = asset->vmpeg_derivative;
278 vmpeg_quantization = asset->vmpeg_quantization;
279 vmpeg_cmodel = asset->vmpeg_cmodel;
280 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
281 vmpeg_seq_codes = asset->vmpeg_seq_codes;
282 vmpeg_preset = asset->vmpeg_preset;
283 vmpeg_field_order = asset->vmpeg_field_order;
285 ac3_bitrate = asset->ac3_bitrate;
287 png_use_alpha = asset->png_use_alpha;
288 png_depth = asset->png_depth;
289 png_compression = asset->png_compression;
290 exr_use_alpha = asset->exr_use_alpha;
291 exr_compression = asset->exr_compression;
293 tiff_cmodel = asset->tiff_cmodel;
294 tiff_compression = asset->tiff_compression;
296 mov_sphere = asset->mov_sphere;
297 jpeg_sphere = asset->jpeg_sphere;
300 int64_t Asset::get_index_offset(int channel)
302 return index_state->get_index_offset(channel);
305 int64_t Asset::get_index_size(int channel)
307 return index_state->get_index_size(channel);
311 char* Asset::get_compression_text(int audio, int video)
316 if( acodec[0] ) return acodec;
323 if( vcodec[0] ) return vcodec;
330 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
332 int result = format == asset.format ? 1 : 0;
333 if( result && strcmp(asset.path, path) ) {
334 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
335 char *sp = out_path ? strrchr(out_path,'/') : 0;
337 char *apath = FileSystem::basepath(asset.path);
338 char *tpath = FileSystem::basepath(this->path);
340 if( *apath != '/' ) {
341 char *cp = cstrcat(2, out_path, apath);
342 delete [] apath; apath = FileSystem::basepath(cp);
345 if( *tpath != '/' ) {
346 char *cp = cstrcat(2, out_path, tpath);
347 delete [] tpath; tpath = FileSystem::basepath(cp);
351 if( strcmp(apath, tpath) ) result = 0;
357 if( result && format == FILE_FFMPEG &&
358 (strcmp(fformat, asset.fformat) ||
359 strcmp(ff_format_options, asset.ff_format_options)) )
362 if(test_audio && result) {
363 result = (channels == asset.channels &&
364 sample_rate == asset.sample_rate &&
365 bits == asset.bits &&
366 byte_order == asset.byte_order &&
367 signed_ == asset.signed_ &&
368 header == asset.header &&
369 dither == asset.dither &&
370 !strcmp(acodec, asset.acodec));
371 if( result && format == FILE_FFMPEG )
372 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
373 !strcmp(ff_sample_format, asset.ff_sample_format) &&
374 ff_audio_bitrate == asset.ff_audio_bitrate &&
375 ff_audio_quality == asset.ff_audio_quality;
379 if(test_video && result) {
380 result = (layers == asset.layers &&
381 program == asset.program &&
382 frame_rate == asset.frame_rate &&
383 asset.interlace_mode == interlace_mode &&
384 asset.timecode == timecode &&
385 width == asset.width &&
386 height == asset.height &&
387 !strcmp(vcodec, asset.vcodec) &&
388 mov_sphere == asset.mov_sphere &&
389 jpeg_sphere == asset.jpeg_sphere);
390 if( result && format == FILE_FFMPEG )
391 result = !strcmp(ff_video_options, asset.ff_video_options) &&
392 !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
393 ff_video_bitrate == asset.ff_video_bitrate &&
394 ff_video_quality == asset.ff_video_quality &&
395 ff_color_space == asset.ff_color_space &&
396 ff_color_range == asset.ff_color_range;
402 int Asset::test_path(const char *path)
404 if(!strcasecmp(this->path, path))
410 int Asset::read(FileXML *file, int expand_relative)
413 // Check for relative path.
414 if( expand_relative ) {
415 char new_path[BCTEXTLEN];
416 char asset_directory[BCTEXTLEN];
417 char input_directory[BCTEXTLEN];
419 strcpy(new_path, path);
420 fs.set_current_dir("");
421 fs.extract_dir(asset_directory, path);
423 // Take path of XML file.
424 if( !asset_directory[0] ) {
425 fs.extract_dir(input_directory, file->filename);
426 // Input file has a path
427 if(input_directory[0])
428 fs.join_names(path, input_directory, new_path);
432 while( !(result=file->read_tag()) ) {
433 if( file->tag.title_is("/ASSET") ) break;
434 if( file->tag.title_is("AUDIO") ) { read_audio(file); continue; }
435 if( file->tag.title_is("AUDIO_OMIT") ) { read_audio(file); continue; }
436 if( file->tag.title_is("FORMAT") ) { read_format(file); continue; }
437 if( file->tag.title_is("VIDEO") ) { read_video(file); continue; }
438 if( file->tag.title_is("VIDEO_OMIT") ) { read_video(file); continue; }
439 if( file->tag.title_is("INDEX") ) { read_index(file); continue; }
440 if( file->tag.title_is("FOLDER") )
441 folder_no = file->tag.get_property("NUMBER", AW_MEDIA_FOLDER);
445 //printf("Asset::read 2\n");
449 int Asset::read_audio(FileXML *file)
451 if(file->tag.title_is("AUDIO")) audio_data = 1;
452 channels = file->tag.get_property("CHANNELS", 2);
453 // This is loaded from the index file after the EDL but this
454 // should be overridable in the EDL.
455 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
456 bits = file->tag.get_property("BITS", 16);
457 byte_order = file->tag.get_property("BYTE_ORDER", 1);
458 signed_ = file->tag.get_property("SIGNED", 1);
459 header = file->tag.get_property("HEADER", 0);
460 dither = file->tag.get_property("DITHER", 0);
462 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
464 file->tag.get_property("ACODEC", acodec);
468 int Asset::read_video(FileXML *file)
470 char string[BCTEXTLEN];
472 if(file->tag.title_is("VIDEO")) video_data = 1;
473 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
474 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
475 height = file->tag.get_property("HEIGHT", height);
476 width = file->tag.get_property("WIDTH", width);
477 proxy_scale = file->tag.get_property("PROXY_SCALE", 0);
478 proxy_edl = file->tag.get_property("PROXY_EDL", 0);
479 layers = file->tag.get_property("LAYERS", layers);
480 program = file->tag.get_property("PROGRAM", program);
481 // This is loaded from the index file after the EDL but this
482 // should be overridable in the EDL.
483 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
485 file->tag.get_property("VCODEC", vcodec);
487 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
488 timecode = file->tag.get_property("TIMECODE", -2);
489 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
490 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
491 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
492 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
493 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
498 int Asset::read_format(FileXML *file)
500 const char *string = file->tag.get_property("TYPE");
501 format = File::strtoformat(string);
502 use_header = file->tag.get_property("USE_HEADER", use_header);
504 file->tag.get_property("FFORMAT", fformat);
505 ff_format_options[0] = 0;
506 file->tag.get_property("FF_FORMAT_OPTIONS", ff_format_options);
510 int Asset::read_index(FileXML *file)
512 index_state->read_xml(file, channels);
516 // Output path is the path of the output file if name truncation is desired.
517 // It is a "" if complete names should be used.
519 int Asset::write(FileXML *file,
521 const char *output_path)
523 char new_path[BCTEXTLEN];
524 char asset_directory[BCTEXTLEN];
525 char output_directory[BCTEXTLEN];
528 // Make path relative
529 fs.extract_dir(asset_directory, path);
530 if(output_path && output_path[0])
531 fs.extract_dir(output_directory, output_path);
533 output_directory[0] = 0;
535 // Asset and EDL are in same directory. Extract just the name.
536 if(!strcmp(asset_directory, output_directory))
538 fs.extract_name(new_path, path);
542 strcpy(new_path, path);
545 file->tag.set_title("ASSET");
546 file->tag.set_property("SRC", new_path);
548 file->append_newline();
550 file->tag.set_title("FOLDER");
551 file->tag.set_property("NUMBER", folder_no);
553 file->tag.set_title("/FOLDER");
555 file->append_newline();
557 // Write the format information
558 file->tag.set_title("FORMAT");
560 file->tag.set_property("TYPE",
561 File::formattostr(format));
562 file->tag.set_property("USE_HEADER", use_header);
563 file->tag.set_property("FFORMAT", fformat);
564 file->tag.set_property("FF_FORMAT_OPTIONS", ff_format_options);
567 file->tag.set_title("/FORMAT");
569 file->append_newline();
571 // Requiring data to exist caused batch render to lose settings.
572 // But the only way to know if an asset doesn't have audio or video data
573 // is to not write the block.
574 // So change the block name if the asset doesn't have the data.
577 // index goes after source
578 if( include_index && index_state &&
579 index_state->index_status == INDEX_READY )
582 file->tag.set_title("/ASSET");
584 file->append_newline();
588 int Asset::write_audio(FileXML *file)
590 // Let the reader know if the asset has the data by naming the block.
592 file->tag.set_title("AUDIO");
594 file->tag.set_title("AUDIO_OMIT");
595 // Necessary for PCM audio
596 file->tag.set_property("CHANNELS", channels);
597 file->tag.set_property("RATE", sample_rate);
598 file->tag.set_property("BITS", bits);
599 file->tag.set_property("BYTE_ORDER", byte_order);
600 file->tag.set_property("SIGNED", signed_);
601 file->tag.set_property("HEADER", header);
602 file->tag.set_property("DITHER", dither);
604 file->tag.set_property("ACODEC", acodec);
606 file->tag.set_property("AUDIO_LENGTH", audio_length);
610 // Rely on defaults operations for these.
612 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
613 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
615 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
616 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
617 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
618 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
620 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
627 file->tag.set_title("/AUDIO");
629 file->tag.set_title("/AUDIO_OMIT");
631 file->append_newline();
635 int Asset::write_video(FileXML *file)
637 char string[BCTEXTLEN];
640 file->tag.set_title("VIDEO");
642 file->tag.set_title("VIDEO_OMIT");
643 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
644 file->tag.set_property("ACTUAL_WIDTH", actual_width);
645 file->tag.set_property("HEIGHT", height);
646 file->tag.set_property("WIDTH", width);
647 file->tag.set_property("PROXY_SCALE", proxy_scale);
648 file->tag.set_property("PROXY_EDL", proxy_edl);
649 file->tag.set_property("LAYERS", layers);
650 file->tag.set_property("PROGRAM", program);
651 file->tag.set_property("FRAMERATE", frame_rate);
653 file->tag.set_property("VCODEC", vcodec);
655 file->tag.set_property("VIDEO_LENGTH", video_length);
656 file->tag.set_property("TIMECODE", timecode);
657 file->tag.set_property("MOV_SPHERE", mov_sphere);
658 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
659 file->tag.set_property("SINGLE_FRAME", single_frame);
661 ilacemode_to_xmltext(string, interlace_mode);
662 file->tag.set_property("INTERLACE_MODE", string);
666 file->tag.set_title("/VIDEO");
668 file->tag.set_title("/VIDEO_OMIT");
671 file->append_newline();
675 int Asset::write_index(FileXML *file)
677 index_state->write_xml(file);
682 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
685 sprintf(return_value, "%s%s", prefix, param);
687 strcpy(return_value, param);
691 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
692 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
694 void Asset::load_defaults(BC_Hash *defaults,
702 char string[BCTEXTLEN];
704 // Can't save codec here because it's specific to render, record, and effect.
705 // The codec has to be UNKNOWN for file probing to work.
709 GET_DEFAULT("PATH", path);
714 GET_DEFAULT("AUDIO_CODEC", acodec);
715 GET_DEFAULT("VIDEO_CODEC", vcodec);
720 format = GET_DEFAULT("FORMAT", format);
721 use_header = GET_DEFAULT("USE_HEADER", use_header);
722 GET_DEFAULT("FFORMAT", fformat);
723 GET_DEFAULT("FF_FORMAT_OPTIONS", ff_format_options);
728 audio_data = GET_DEFAULT("AUDIO", 1);
729 video_data = GET_DEFAULT("VIDEO", 1);
734 bits = GET_DEFAULT("BITS", 16);
735 dither = GET_DEFAULT("DITHER", 0);
736 signed_ = GET_DEFAULT("SIGNED", 1);
737 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
741 channels = GET_DEFAULT("CHANNELS", 2);
742 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
743 header = GET_DEFAULT("HEADER", 0);
744 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
748 height = GET_DEFAULT("HEIGHT", height);
749 width = GET_DEFAULT("WIDTH", width);
750 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
751 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
752 proxy_scale = GET_DEFAULT("PROXY_SCALE", proxy_scale);
753 proxy_edl = GET_DEFAULT("PROXY_SCALE", proxy_edl);
754 program = GET_DEFAULT("PROGRAM", program);
755 layers = GET_DEFAULT("LAYERS", layers);
756 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
757 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
758 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
761 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
762 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
764 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
765 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
766 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
767 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
769 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
770 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
771 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
772 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
773 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
774 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
776 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
777 GET_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
778 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
779 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
780 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
781 GET_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
782 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
783 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
784 ff_color_space = GET_DEFAULT("FF_COLOR_SPACE", ff_color_space);
785 ff_color_range = GET_DEFAULT("FF_COLOR_RANGE", ff_color_range);
786 GET_DEFAULT("FF_FORMAT_OPTIONS", ff_format_options);
788 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
790 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
791 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
792 interlace_mode = ILACE_MODE_UNDETECTED;
794 // MPEG format information
795 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
796 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
797 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
798 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
799 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
800 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
801 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
802 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
803 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
804 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
805 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
806 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
808 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
809 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
810 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
811 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
812 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
813 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
816 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
818 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
819 png_depth = GET_DEFAULT("PNG_DEPTH", png_depth);
820 png_compression = GET_DEFAULT("PNG_COMPRESSION", png_compression);
821 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
822 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
823 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
824 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
826 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
827 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
831 void Asset::save_defaults(BC_Hash *defaults,
839 char string[BCTEXTLEN];
841 UPDATE_DEFAULT("PATH", path);
848 UPDATE_DEFAULT("FORMAT", format);
849 UPDATE_DEFAULT("USE_HEADER", use_header);
850 UPDATE_DEFAULT("FFORMAT", fformat);
851 UPDATE_DEFAULT("FF_FORMAT_OPTIONS", ff_format_options);
856 UPDATE_DEFAULT("AUDIO", audio_data);
857 UPDATE_DEFAULT("VIDEO", video_data);
862 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
863 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
865 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
866 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
868 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
869 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
870 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
871 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
873 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
874 UPDATE_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
875 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
876 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
877 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
878 UPDATE_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
879 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
880 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
881 UPDATE_DEFAULT("FF_COLOR_SPACE", ff_color_space);
882 UPDATE_DEFAULT("FF_COLOR_RANGE", ff_color_range);
884 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
885 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
886 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
887 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
888 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
889 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
893 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
895 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
896 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
898 // MPEG format information
899 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
900 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
901 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
902 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
903 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
904 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
905 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
906 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
907 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
908 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
909 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
910 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
913 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
916 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
917 UPDATE_DEFAULT("PNG_DEPTH", png_depth);
918 UPDATE_DEFAULT("PNG_COMPRESSION", png_compression);
919 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
920 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
921 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
922 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
926 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
927 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
935 UPDATE_DEFAULT("BITS", bits);
936 UPDATE_DEFAULT("DITHER", dither);
937 UPDATE_DEFAULT("SIGNED", signed_);
938 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
945 UPDATE_DEFAULT("CHANNELS", channels);
946 UPDATE_DEFAULT("RATE", sample_rate);
947 UPDATE_DEFAULT("HEADER", header);
948 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
952 UPDATE_DEFAULT("HEIGHT", height);
953 UPDATE_DEFAULT("WIDTH", width);
954 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
955 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
956 UPDATE_DEFAULT("PROXY_SCALE", proxy_scale);
957 UPDATE_DEFAULT("PROXY_EDL", proxy_edl);
958 UPDATE_DEFAULT("PROGRAM", program);
959 UPDATE_DEFAULT("LAYERS", layers);
960 UPDATE_DEFAULT("FRAMERATE", frame_rate);
961 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
962 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
975 int Asset::dump(FILE *fp)
977 fprintf(fp," asset::dump\n");
978 fprintf(fp," this=%p path=%s\n", this, path);
979 fprintf(fp," index_status %d\n", index_state->index_status);
980 fprintf(fp," format %d\n", format);
981 fprintf(fp," fformat=\"%s\"\n", fformat);
982 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
983 fprintf(fp," ff_sample_format=\"%s\"\n", ff_sample_format);
984 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
985 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
986 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
987 fprintf(fp," ff_pixel_format=\"%s\"\n", ff_pixel_format);
988 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
989 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
990 fprintf(fp," ff_color_space=%d\n", ff_color_space);
991 fprintf(fp," ff_color_range=%d\n", ff_color_range);
992 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
993 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
994 audio_data, channels, sample_rate, bits, byte_order, signed_,
995 header, dither, acodec);
996 fprintf(fp," audio_length %jd\n", audio_length);
997 char string[BCTEXTLEN];
998 ilacemode_to_xmltext(string, interlace_mode);
999 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1000 " height %d vcodec %s aspect_ratio %f ilace_mode %s\n",
1001 video_data, layers, program, frame_rate, width, height,
1002 vcodec, aspect_ratio,string);
1003 fprintf(fp," actual_width %d actual_height %d proxy_scale %d proxy_edl %d\n",
1004 actual_width, actual_height, proxy_scale, proxy_edl);
1005 fprintf(fp," video_length %jd repeat %d timecode %f\n",
1006 video_length, single_frame, timecode);
1007 fprintf(fp," mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
1013 int Asset::get_audio_channels()
1018 int Asset::get_sample_rate()
1023 int64_t Asset::get_audio_samples()
1025 return audio_length;
1028 int Asset::have_audio()
1033 int Asset::have_video()
1048 double Asset::get_frame_rate()
1054 int Asset::get_video_layers()
1059 int Asset::get_program()
1064 int64_t Asset::get_video_frames()
1066 return video_length;
1069 double Asset::total_length_framealigned(double fps)
1071 if (video_data && audio_data) {
1072 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1073 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1074 return MIN(aud,vid);
1078 return (double)audio_length / sample_rate;
1081 return (double)video_length / frame_rate;