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_audio_options[0] = 0;
88 ff_sample_format[0] = 0;
90 ff_audio_quality = -1;
91 ff_video_options[0] = 0;
92 ff_pixel_format[0] = 0;
94 ff_video_quality = -1;
98 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
99 interlace_mode = ILACE_MODE_UNDETECTED;
100 interlace_fixmethod = ILACE_FIXMETHOD_NONE;
104 ampeg_derivative = 3;
107 vorbis_min_bitrate = -1;
108 vorbis_bitrate = 128000;
109 vorbis_max_bitrate = -1;
111 theora_fix_bitrate = 1;
112 theora_bitrate = 860000;
114 theora_sharpness = 2;
115 theora_keyframe_frequency = 64;
116 theora_keyframe_force_frequency = 64;
119 vmpeg_iframe_distance = 45;
120 vmpeg_pframe_distance = 0;
121 vmpeg_progressive = 0;
123 vmpeg_bitrate = 1000000;
124 vmpeg_derivative = 1;
125 vmpeg_quantization = 15;
126 vmpeg_cmodel = BC_YUV420P;
127 vmpeg_fix_bitrate = 0;
130 vmpeg_field_order = 0;
140 tiff_compression = 0;
150 void Asset::reset_audio()
158 void Asset::reset_video()
162 actual_width = width = 0;
163 actual_height = height = 0;
166 vmpeg_cmodel = BC_YUV420P;
172 void Asset::boundaries()
174 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
175 // sample_rate & frame_rate are user defined
176 // CLAMP(sample_rate, 1, 1000000);
177 // CLAMP(frame_rate, 0.001, 1000000);
178 CLAMP(channels, 0, 16);
179 CLAMP(width, 0, 10000);
180 CLAMP(height, 0, 10000);
181 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
184 void Asset::copy_from(Asset *asset, int do_index)
186 copy_location(asset);
187 copy_format(asset, do_index);
190 void Asset::copy_location(Asset *asset)
192 strcpy(path, asset->path);
193 folder_no = asset->folder_no;
196 void Asset::copy_format(Asset *asset, int do_index)
198 if(do_index) update_index(asset);
200 audio_data = asset->audio_data;
201 format = asset->format;
202 strcpy(fformat, asset->fformat);
203 channels = asset->channels;
204 sample_rate = asset->sample_rate;
206 byte_order = asset->byte_order;
207 signed_ = asset->signed_;
208 header = asset->header;
209 dither = asset->dither;
210 mp3_bitrate = asset->mp3_bitrate;
211 use_header = asset->use_header;
212 aspect_ratio = asset->aspect_ratio;
213 interlace_autofixoption = asset->interlace_autofixoption;
214 interlace_mode = asset->interlace_mode;
215 interlace_fixmethod = asset->interlace_fixmethod;
217 video_data = asset->video_data;
218 layers = asset->layers;
219 program = asset->program;
220 frame_rate = asset->frame_rate;
221 width = asset->width;
222 height = asset->height;
223 actual_width = asset->actual_width;
224 actual_height = asset->actual_height;
225 strcpy(vcodec, asset->vcodec);
226 strcpy(acodec, asset->acodec);
228 strcpy(ff_audio_options, asset->ff_audio_options);
229 strcpy(ff_sample_format, asset->ff_sample_format);
230 ff_audio_bitrate = asset->ff_audio_bitrate;
231 ff_audio_quality = asset->ff_audio_quality;
232 strcpy(ff_video_options, asset->ff_video_options);
233 strcpy(ff_pixel_format, asset->ff_pixel_format);
234 ff_video_bitrate = asset->ff_video_bitrate;
235 ff_video_quality = asset->ff_video_quality;
237 this->audio_length = asset->audio_length;
238 this->video_length = asset->video_length;
239 this->single_frame = asset->single_frame;
241 ampeg_bitrate = asset->ampeg_bitrate;
242 ampeg_derivative = asset->ampeg_derivative;
245 vorbis_vbr = asset->vorbis_vbr;
246 vorbis_min_bitrate = asset->vorbis_min_bitrate;
247 vorbis_bitrate = asset->vorbis_bitrate;
248 vorbis_max_bitrate = asset->vorbis_max_bitrate;
251 theora_fix_bitrate = asset->theora_fix_bitrate;
252 theora_bitrate = asset->theora_bitrate;
253 theora_quality = asset->theora_quality;
254 theora_sharpness = asset->theora_sharpness;
255 theora_keyframe_frequency = asset->theora_keyframe_frequency;
256 theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
259 jpeg_quality = asset->jpeg_quality;
262 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
263 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
264 vmpeg_progressive = asset->vmpeg_progressive;
265 vmpeg_denoise = asset->vmpeg_denoise;
266 vmpeg_bitrate = asset->vmpeg_bitrate;
267 vmpeg_derivative = asset->vmpeg_derivative;
268 vmpeg_quantization = asset->vmpeg_quantization;
269 vmpeg_cmodel = asset->vmpeg_cmodel;
270 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
271 vmpeg_seq_codes = asset->vmpeg_seq_codes;
272 vmpeg_preset = asset->vmpeg_preset;
273 vmpeg_field_order = asset->vmpeg_field_order;
275 ac3_bitrate = asset->ac3_bitrate;
277 png_use_alpha = asset->png_use_alpha;
278 exr_use_alpha = asset->exr_use_alpha;
279 exr_compression = asset->exr_compression;
281 tiff_cmodel = asset->tiff_cmodel;
282 tiff_compression = asset->tiff_compression;
285 mov_sphere = asset->mov_sphere;
286 jpeg_sphere = asset->jpeg_sphere;
289 int64_t Asset::get_index_offset(int channel)
291 return index_state->get_index_offset(channel);
294 int64_t Asset::get_index_size(int channel)
296 return index_state->get_index_size(channel);
300 char* Asset::get_compression_text(int audio, int video)
305 if( acodec[0] ) return acodec;
312 if( vcodec[0] ) return vcodec;
319 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
321 int result = format == asset.format ? 1 : 0;
322 if( result && strcmp(asset.path, path) ) {
323 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
324 char *sp = out_path ? strrchr(out_path,'/') : 0;
326 char *apath = FileSystem::basepath(asset.path);
327 char *tpath = FileSystem::basepath(this->path);
329 if( *apath != '/' ) {
330 char *cp = cstrcat(2, out_path, apath);
331 delete [] apath; apath = FileSystem::basepath(cp);
334 if( *tpath != '/' ) {
335 char *cp = cstrcat(2, out_path, tpath);
336 delete [] tpath; tpath = FileSystem::basepath(cp);
340 if( strcmp(apath, tpath) ) result = 0;
346 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
349 if(test_audio && result)
351 result = (channels == asset.channels &&
352 sample_rate == asset.sample_rate &&
353 bits == asset.bits &&
354 byte_order == asset.byte_order &&
355 signed_ == asset.signed_ &&
356 header == asset.header &&
357 dither == asset.dither &&
358 !strcmp(acodec, asset.acodec));
359 if(result && format == FILE_FFMPEG)
360 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
361 !strcmp(ff_sample_format, asset.ff_sample_format) &&
362 ff_audio_bitrate == asset.ff_audio_bitrate &&
363 ff_audio_quality == asset.ff_audio_quality;
367 if(test_video && result)
369 result = (layers == asset.layers &&
370 program == asset.program &&
371 frame_rate == asset.frame_rate &&
372 asset.interlace_autofixoption == interlace_autofixoption &&
373 asset.interlace_mode == interlace_mode &&
374 interlace_fixmethod == asset.interlace_fixmethod &&
375 width == asset.width &&
376 height == asset.height &&
377 !strcmp(vcodec, asset.vcodec) &&
378 mov_sphere == asset.mov_sphere &&
379 jpeg_sphere == asset.jpeg_sphere);
380 if(result && format == FILE_FFMPEG)
381 result = !strcmp(ff_video_options, asset.ff_video_options) &&
382 !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
383 ff_video_bitrate == asset.ff_video_bitrate &&
384 ff_video_quality == asset.ff_video_quality;
390 int Asset::test_path(const char *path)
392 if(!strcasecmp(this->path, path))
398 int Asset::read(FileXML *file,
403 // Check for relative path.
406 char new_path[BCTEXTLEN];
407 char asset_directory[BCTEXTLEN];
408 char input_directory[BCTEXTLEN];
411 strcpy(new_path, path);
412 fs.set_current_dir("");
414 fs.extract_dir(asset_directory, path);
417 // Take path of XML file.
418 if(!asset_directory[0])
420 fs.extract_dir(input_directory, file->filename);
422 // Input file has a path
423 if(input_directory[0])
425 fs.join_names(path, input_directory, new_path);
433 result = file->read_tag();
436 if(file->tag.title_is("/ASSET"))
441 if(file->tag.title_is("AUDIO"))
446 if(file->tag.title_is("AUDIO_OMIT"))
451 if(file->tag.title_is("FORMAT"))
453 const char *string = file->tag.get_property("TYPE");
454 format = File::strtoformat(string);
456 file->tag.get_property("USE_HEADER", use_header);
457 file->tag.get_property("FFORMAT", fformat);
460 if(file->tag.title_is("FOLDER"))
462 folder_no = file->tag.get_property("NUMBER", AW_MEDIA_FOLDER);
465 if(file->tag.title_is("VIDEO"))
470 if(file->tag.title_is("VIDEO_OMIT"))
475 if(file->tag.title_is("INDEX"))
483 //printf("Asset::read 2\n");
487 int Asset::read_audio(FileXML *file)
489 if(file->tag.title_is("AUDIO")) audio_data = 1;
490 channels = file->tag.get_property("CHANNELS", 2);
491 // This is loaded from the index file after the EDL but this
492 // should be overridable in the EDL.
493 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
494 bits = file->tag.get_property("BITS", 16);
495 byte_order = file->tag.get_property("BYTE_ORDER", 1);
496 signed_ = file->tag.get_property("SIGNED", 1);
497 header = file->tag.get_property("HEADER", 0);
498 dither = file->tag.get_property("DITHER", 0);
500 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
502 file->tag.get_property("ACODEC", acodec);
506 int Asset::read_video(FileXML *file)
508 char string[BCTEXTLEN];
510 if(file->tag.title_is("VIDEO")) video_data = 1;
511 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
512 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
513 height = file->tag.get_property("HEIGHT", height);
514 width = file->tag.get_property("WIDTH", width);
515 layers = file->tag.get_property("LAYERS", layers);
516 program = file->tag.get_property("PROGRAM", program);
517 // This is loaded from the index file after the EDL but this
518 // should be overridable in the EDL.
519 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
521 file->tag.get_property("VCODEC", vcodec);
523 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
524 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
525 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
526 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
528 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
530 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
531 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
533 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
534 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
539 int Asset::read_index(FileXML *file)
541 index_state->read_xml(file, channels);
545 // Output path is the path of the output file if name truncation is desired.
546 // It is a "" if complete names should be used.
548 int Asset::write(FileXML *file,
550 const char *output_path)
552 char new_path[BCTEXTLEN];
553 char asset_directory[BCTEXTLEN];
554 char output_directory[BCTEXTLEN];
557 // Make path relative
558 fs.extract_dir(asset_directory, path);
559 if(output_path && output_path[0])
560 fs.extract_dir(output_directory, output_path);
562 output_directory[0] = 0;
564 // Asset and EDL are in same directory. Extract just the name.
565 if(!strcmp(asset_directory, output_directory))
567 fs.extract_name(new_path, path);
571 strcpy(new_path, path);
574 file->tag.set_title("ASSET");
575 file->tag.set_property("SRC", new_path);
577 file->append_newline();
579 file->tag.set_title("FOLDER");
580 file->tag.set_property("NUMBER", folder_no);
582 file->tag.set_title("/FOLDER");
584 file->append_newline();
586 // Write the format information
587 file->tag.set_title("FORMAT");
589 file->tag.set_property("TYPE",
590 File::formattostr(format));
591 file->tag.set_property("USE_HEADER", use_header);
592 file->tag.set_property("FFORMAT", fformat);
595 file->tag.set_title("/FORMAT");
597 file->append_newline();
599 // Requiring data to exist caused batch render to lose settings.
600 // But the only way to know if an asset doesn't have audio or video data
601 // is to not write the block.
602 // So change the block name if the asset doesn't have the data.
605 // index goes after source
606 if( include_index && index_state &&
607 index_state->index_status == INDEX_READY )
610 file->tag.set_title("/ASSET");
612 file->append_newline();
616 int Asset::write_audio(FileXML *file)
618 // Let the reader know if the asset has the data by naming the block.
620 file->tag.set_title("AUDIO");
622 file->tag.set_title("AUDIO_OMIT");
623 // Necessary for PCM audio
624 file->tag.set_property("CHANNELS", channels);
625 file->tag.set_property("RATE", sample_rate);
626 file->tag.set_property("BITS", bits);
627 file->tag.set_property("BYTE_ORDER", byte_order);
628 file->tag.set_property("SIGNED", signed_);
629 file->tag.set_property("HEADER", header);
630 file->tag.set_property("DITHER", dither);
632 file->tag.set_property("ACODEC", acodec);
634 file->tag.set_property("AUDIO_LENGTH", audio_length);
638 // Rely on defaults operations for these.
640 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
641 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
643 // file->tag.set_property("VORBIS_VBR", vorbis_vbr);
644 // file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
645 // file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
646 // file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
648 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
655 file->tag.set_title("/AUDIO");
657 file->tag.set_title("/AUDIO_OMIT");
659 file->append_newline();
663 int Asset::write_video(FileXML *file)
665 char string[BCTEXTLEN];
668 file->tag.set_title("VIDEO");
670 file->tag.set_title("VIDEO_OMIT");
671 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
672 file->tag.set_property("ACTUAL_WIDTH", actual_width);
673 file->tag.set_property("HEIGHT", height);
674 file->tag.set_property("WIDTH", width);
675 file->tag.set_property("LAYERS", layers);
676 file->tag.set_property("PROGRAM", program);
677 file->tag.set_property("FRAMERATE", frame_rate);
679 file->tag.set_property("VCODEC", vcodec);
681 file->tag.set_property("VIDEO_LENGTH", video_length);
682 file->tag.set_property("MOV_SPHERE", mov_sphere);
683 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
684 file->tag.set_property("SINGLE_FRAME", single_frame);
686 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
688 ilacemode_to_xmltext(string, interlace_mode);
689 file->tag.set_property("INTERLACE_MODE", string);
691 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
692 file->tag.set_property("INTERLACE_FIXMETHOD", string);
696 file->tag.set_title("/VIDEO");
698 file->tag.set_title("/VIDEO_OMIT");
701 file->append_newline();
705 int Asset::write_index(FileXML *file)
707 index_state->write_xml(file);
712 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
715 sprintf(return_value, "%s%s", prefix, param);
717 strcpy(return_value, param);
721 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
722 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
724 void Asset::load_defaults(BC_Hash *defaults,
732 char string[BCTEXTLEN];
734 // Can't save codec here because it's specific to render, record, and effect.
735 // The codec has to be UNKNOWN for file probing to work.
739 GET_DEFAULT("PATH", path);
744 GET_DEFAULT("AUDIO_CODEC", acodec);
745 GET_DEFAULT("VIDEO_CODEC", vcodec);
750 format = GET_DEFAULT("FORMAT", format);
751 use_header = GET_DEFAULT("USE_HEADER", use_header);
752 GET_DEFAULT("FFORMAT", fformat);
757 audio_data = GET_DEFAULT("AUDIO", 1);
758 video_data = GET_DEFAULT("VIDEO", 1);
763 bits = GET_DEFAULT("BITS", 16);
764 dither = GET_DEFAULT("DITHER", 0);
765 signed_ = GET_DEFAULT("SIGNED", 1);
766 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
770 channels = GET_DEFAULT("CHANNELS", 2);
771 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
772 header = GET_DEFAULT("HEADER", 0);
773 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
777 height = GET_DEFAULT("HEIGHT", height);
778 width = GET_DEFAULT("WIDTH", width);
779 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
780 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
781 program = GET_DEFAULT("PROGRAM", program);
782 layers = GET_DEFAULT("LAYERS", layers);
783 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
784 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
785 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
788 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
789 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
791 vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
792 vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
793 vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
794 vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
796 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
797 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
798 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
799 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
800 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
801 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
803 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
804 GET_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
805 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
806 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
807 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
808 GET_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
809 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
810 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
812 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
814 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
815 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
817 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
818 interlace_mode = ILACE_MODE_UNDETECTED;
819 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
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 theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
836 theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
837 theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
838 theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
839 theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
840 theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
843 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
845 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
846 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
847 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
848 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
849 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
851 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
852 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
856 void Asset::save_defaults(BC_Hash *defaults,
864 char string[BCTEXTLEN];
866 UPDATE_DEFAULT("PATH", path);
873 UPDATE_DEFAULT("FORMAT", format);
874 UPDATE_DEFAULT("USE_HEADER", use_header);
875 UPDATE_DEFAULT("FFORMAT", fformat);
880 UPDATE_DEFAULT("AUDIO", audio_data);
881 UPDATE_DEFAULT("VIDEO", video_data);
886 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
887 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
889 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
890 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
892 UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
893 UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
894 UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
895 UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
897 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
898 UPDATE_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
899 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
900 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
901 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
902 UPDATE_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
903 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
904 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
906 UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
907 UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
908 UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
909 UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
910 UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
911 UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FREQUENCY", theora_keyframe_force_frequency);
915 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
917 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
918 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
920 // MPEG format information
921 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
922 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
923 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
924 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
925 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
926 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
927 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
928 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
929 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
930 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
931 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
932 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
935 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
938 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
939 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
940 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
941 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
942 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
946 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
947 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
955 UPDATE_DEFAULT("BITS", bits);
956 UPDATE_DEFAULT("DITHER", dither);
957 UPDATE_DEFAULT("SIGNED", signed_);
958 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
965 UPDATE_DEFAULT("CHANNELS", channels);
966 UPDATE_DEFAULT("RATE", sample_rate);
967 UPDATE_DEFAULT("HEADER", header);
968 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
972 UPDATE_DEFAULT("HEIGHT", height);
973 UPDATE_DEFAULT("WIDTH", width);
974 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
975 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
976 UPDATE_DEFAULT("PROGRAM", program);
977 UPDATE_DEFAULT("LAYERS", layers);
978 UPDATE_DEFAULT("FRAMERATE", frame_rate);
979 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
980 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
993 int Asset::dump(FILE *fp)
995 fprintf(fp," asset::dump\n");
996 fprintf(fp," this=%p path=%s\n", this, path);
997 fprintf(fp," index_status %d\n", index_state->index_status);
998 fprintf(fp," format %d\n", format);
999 fprintf(fp," fformat=\"%s\"\n", fformat);
1000 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
1001 fprintf(fp," ff_sample_format=\"%s\"\n", ff_sample_format);
1002 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
1003 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
1004 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
1005 fprintf(fp," ff_pixel_format=\"%s\"\n", ff_pixel_format);
1006 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
1007 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
1008 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
1009 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
1010 audio_data, channels, sample_rate, bits, byte_order, signed_,
1011 header, dither, acodec);
1012 fprintf(fp," audio_length %jd\n", audio_length);
1013 char string[BCTEXTLEN];
1014 ilacemode_to_xmltext(string, interlace_mode);
1015 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
1016 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
1017 video_data, layers, program, frame_rate, width, height,
1018 vcodec, aspect_ratio,string);
1019 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
1020 printf(" mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
1026 int Asset::get_audio_channels()
1031 int Asset::get_sample_rate()
1036 int64_t Asset::get_audio_samples()
1038 return audio_length;
1041 int Asset::have_audio()
1046 int Asset::have_video()
1061 double Asset::get_frame_rate()
1067 int Asset::get_video_layers()
1072 int Asset::get_program()
1077 int64_t Asset::get_video_frames()
1079 return video_length;
1082 double Asset::total_length_framealigned(double fps)
1084 if (video_data && audio_data) {
1085 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1086 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1087 return MIN(aud,vid);
1091 return (double)audio_length / sample_rate;
1094 return (double)video_length / frame_rate;