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 vmpeg_iframe_distance = 45;
108 vmpeg_pframe_distance = 0;
109 vmpeg_progressive = 0;
111 vmpeg_bitrate = 1000000;
112 vmpeg_derivative = 1;
113 vmpeg_quantization = 15;
114 vmpeg_cmodel = BC_YUV420P;
115 vmpeg_fix_bitrate = 0;
118 vmpeg_field_order = 0;
128 tiff_compression = 0;
138 void Asset::reset_audio()
146 void Asset::reset_video()
150 actual_width = width = 0;
151 actual_height = height = 0;
154 vmpeg_cmodel = BC_YUV420P;
160 void Asset::boundaries()
162 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
163 // sample_rate & frame_rate are user defined
164 // CLAMP(sample_rate, 1, 1000000);
165 // CLAMP(frame_rate, 0.001, 1000000);
166 CLAMP(channels, 0, 16);
167 CLAMP(width, 0, 10000);
168 CLAMP(height, 0, 10000);
169 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
172 void Asset::copy_from(Asset *asset, int do_index)
174 copy_location(asset);
175 copy_format(asset, do_index);
178 void Asset::copy_location(Asset *asset)
180 strcpy(path, asset->path);
181 folder_no = asset->folder_no;
184 void Asset::copy_format(Asset *asset, int do_index)
186 if(do_index) update_index(asset);
188 audio_data = asset->audio_data;
189 format = asset->format;
190 strcpy(fformat, asset->fformat);
191 channels = asset->channels;
192 sample_rate = asset->sample_rate;
194 byte_order = asset->byte_order;
195 signed_ = asset->signed_;
196 header = asset->header;
197 dither = asset->dither;
198 mp3_bitrate = asset->mp3_bitrate;
199 use_header = asset->use_header;
200 aspect_ratio = asset->aspect_ratio;
201 interlace_autofixoption = asset->interlace_autofixoption;
202 interlace_mode = asset->interlace_mode;
203 interlace_fixmethod = asset->interlace_fixmethod;
205 video_data = asset->video_data;
206 layers = asset->layers;
207 program = asset->program;
208 frame_rate = asset->frame_rate;
209 width = asset->width;
210 height = asset->height;
211 actual_width = asset->actual_width;
212 actual_height = asset->actual_height;
213 strcpy(vcodec, asset->vcodec);
214 strcpy(acodec, asset->acodec);
216 strcpy(ff_audio_options, asset->ff_audio_options);
217 strcpy(ff_sample_format, asset->ff_sample_format);
218 ff_audio_bitrate = asset->ff_audio_bitrate;
219 ff_audio_quality = asset->ff_audio_quality;
220 strcpy(ff_video_options, asset->ff_video_options);
221 strcpy(ff_pixel_format, asset->ff_pixel_format);
222 ff_video_bitrate = asset->ff_video_bitrate;
223 ff_video_quality = asset->ff_video_quality;
225 this->audio_length = asset->audio_length;
226 this->video_length = asset->video_length;
227 this->single_frame = asset->single_frame;
229 ampeg_bitrate = asset->ampeg_bitrate;
230 ampeg_derivative = asset->ampeg_derivative;
232 jpeg_quality = asset->jpeg_quality;
235 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
236 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
237 vmpeg_progressive = asset->vmpeg_progressive;
238 vmpeg_denoise = asset->vmpeg_denoise;
239 vmpeg_bitrate = asset->vmpeg_bitrate;
240 vmpeg_derivative = asset->vmpeg_derivative;
241 vmpeg_quantization = asset->vmpeg_quantization;
242 vmpeg_cmodel = asset->vmpeg_cmodel;
243 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
244 vmpeg_seq_codes = asset->vmpeg_seq_codes;
245 vmpeg_preset = asset->vmpeg_preset;
246 vmpeg_field_order = asset->vmpeg_field_order;
248 ac3_bitrate = asset->ac3_bitrate;
250 png_use_alpha = asset->png_use_alpha;
251 exr_use_alpha = asset->exr_use_alpha;
252 exr_compression = asset->exr_compression;
254 tiff_cmodel = asset->tiff_cmodel;
255 tiff_compression = asset->tiff_compression;
258 mov_sphere = asset->mov_sphere;
259 jpeg_sphere = asset->jpeg_sphere;
262 int64_t Asset::get_index_offset(int channel)
264 return index_state->get_index_offset(channel);
267 int64_t Asset::get_index_size(int channel)
269 return index_state->get_index_size(channel);
273 char* Asset::get_compression_text(int audio, int video)
278 if( acodec[0] ) return acodec;
285 if( vcodec[0] ) return vcodec;
292 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
294 int result = format == asset.format ? 1 : 0;
295 if( result && strcmp(asset.path, path) ) {
296 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
297 char *sp = out_path ? strrchr(out_path,'/') : 0;
299 char *apath = FileSystem::basepath(asset.path);
300 char *tpath = FileSystem::basepath(this->path);
302 if( *apath != '/' ) {
303 char *cp = cstrcat(2, out_path, apath);
304 delete [] apath; apath = FileSystem::basepath(cp);
307 if( *tpath != '/' ) {
308 char *cp = cstrcat(2, out_path, tpath);
309 delete [] tpath; tpath = FileSystem::basepath(cp);
313 if( strcmp(apath, tpath) ) result = 0;
319 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
322 if(test_audio && result)
324 result = (channels == asset.channels &&
325 sample_rate == asset.sample_rate &&
326 bits == asset.bits &&
327 byte_order == asset.byte_order &&
328 signed_ == asset.signed_ &&
329 header == asset.header &&
330 dither == asset.dither &&
331 !strcmp(acodec, asset.acodec));
332 if(result && format == FILE_FFMPEG)
333 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
334 !strcmp(ff_sample_format, asset.ff_sample_format) &&
335 ff_audio_bitrate == asset.ff_audio_bitrate &&
336 ff_audio_quality == asset.ff_audio_quality;
340 if(test_video && result)
342 result = (layers == asset.layers &&
343 program == asset.program &&
344 frame_rate == asset.frame_rate &&
345 asset.interlace_autofixoption == interlace_autofixoption &&
346 asset.interlace_mode == interlace_mode &&
347 interlace_fixmethod == asset.interlace_fixmethod &&
348 width == asset.width &&
349 height == asset.height &&
350 !strcmp(vcodec, asset.vcodec) &&
351 mov_sphere == asset.mov_sphere &&
352 jpeg_sphere == asset.jpeg_sphere);
353 if(result && format == FILE_FFMPEG)
354 result = !strcmp(ff_video_options, asset.ff_video_options) &&
355 !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
356 ff_video_bitrate == asset.ff_video_bitrate &&
357 ff_video_quality == asset.ff_video_quality;
363 int Asset::test_path(const char *path)
365 if(!strcasecmp(this->path, path))
371 int Asset::read(FileXML *file,
376 // Check for relative path.
379 char new_path[BCTEXTLEN];
380 char asset_directory[BCTEXTLEN];
381 char input_directory[BCTEXTLEN];
384 strcpy(new_path, path);
385 fs.set_current_dir("");
387 fs.extract_dir(asset_directory, path);
390 // Take path of XML file.
391 if(!asset_directory[0])
393 fs.extract_dir(input_directory, file->filename);
395 // Input file has a path
396 if(input_directory[0])
398 fs.join_names(path, input_directory, new_path);
406 result = file->read_tag();
409 if(file->tag.title_is("/ASSET"))
414 if(file->tag.title_is("AUDIO"))
419 if(file->tag.title_is("AUDIO_OMIT"))
424 if(file->tag.title_is("FORMAT"))
426 const char *string = file->tag.get_property("TYPE");
427 format = File::strtoformat(string);
429 file->tag.get_property("USE_HEADER", use_header);
430 file->tag.get_property("FFORMAT", fformat);
433 if(file->tag.title_is("FOLDER"))
435 folder_no = file->tag.get_property("NUMBER", AW_MEDIA_FOLDER);
438 if(file->tag.title_is("VIDEO"))
443 if(file->tag.title_is("VIDEO_OMIT"))
448 if(file->tag.title_is("INDEX"))
456 //printf("Asset::read 2\n");
460 int Asset::read_audio(FileXML *file)
462 if(file->tag.title_is("AUDIO")) audio_data = 1;
463 channels = file->tag.get_property("CHANNELS", 2);
464 // This is loaded from the index file after the EDL but this
465 // should be overridable in the EDL.
466 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
467 bits = file->tag.get_property("BITS", 16);
468 byte_order = file->tag.get_property("BYTE_ORDER", 1);
469 signed_ = file->tag.get_property("SIGNED", 1);
470 header = file->tag.get_property("HEADER", 0);
471 dither = file->tag.get_property("DITHER", 0);
473 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
475 file->tag.get_property("ACODEC", acodec);
479 int Asset::read_video(FileXML *file)
481 char string[BCTEXTLEN];
483 if(file->tag.title_is("VIDEO")) video_data = 1;
484 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
485 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
486 height = file->tag.get_property("HEIGHT", height);
487 width = file->tag.get_property("WIDTH", width);
488 layers = file->tag.get_property("LAYERS", layers);
489 program = file->tag.get_property("PROGRAM", program);
490 // This is loaded from the index file after the EDL but this
491 // should be overridable in the EDL.
492 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
494 file->tag.get_property("VCODEC", vcodec);
496 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
497 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
498 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
499 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
501 interlace_autofixoption = file->tag.get_property("INTERLACE_AUTOFIX",0);
503 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
504 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
506 ilacefixmethod_to_xmltext(string, ILACE_FIXMETHOD_NONE);
507 interlace_fixmethod = ilacefixmethod_from_xmltext(file->tag.get_property("INTERLACE_FIXMETHOD",string), ILACE_FIXMETHOD_NONE);
512 int Asset::read_index(FileXML *file)
514 index_state->read_xml(file, channels);
518 // Output path is the path of the output file if name truncation is desired.
519 // It is a "" if complete names should be used.
521 int Asset::write(FileXML *file,
523 const char *output_path)
525 char new_path[BCTEXTLEN];
526 char asset_directory[BCTEXTLEN];
527 char output_directory[BCTEXTLEN];
530 // Make path relative
531 fs.extract_dir(asset_directory, path);
532 if(output_path && output_path[0])
533 fs.extract_dir(output_directory, output_path);
535 output_directory[0] = 0;
537 // Asset and EDL are in same directory. Extract just the name.
538 if(!strcmp(asset_directory, output_directory))
540 fs.extract_name(new_path, path);
544 strcpy(new_path, path);
547 file->tag.set_title("ASSET");
548 file->tag.set_property("SRC", new_path);
550 file->append_newline();
552 file->tag.set_title("FOLDER");
553 file->tag.set_property("NUMBER", folder_no);
555 file->tag.set_title("/FOLDER");
557 file->append_newline();
559 // Write the format information
560 file->tag.set_title("FORMAT");
562 file->tag.set_property("TYPE",
563 File::formattostr(format));
564 file->tag.set_property("USE_HEADER", use_header);
565 file->tag.set_property("FFORMAT", fformat);
568 file->tag.set_title("/FORMAT");
570 file->append_newline();
572 // Requiring data to exist caused batch render to lose settings.
573 // But the only way to know if an asset doesn't have audio or video data
574 // is to not write the block.
575 // So change the block name if the asset doesn't have the data.
578 // index goes after source
579 if( include_index && index_state &&
580 index_state->index_status == INDEX_READY )
583 file->tag.set_title("/ASSET");
585 file->append_newline();
589 int Asset::write_audio(FileXML *file)
591 // Let the reader know if the asset has the data by naming the block.
593 file->tag.set_title("AUDIO");
595 file->tag.set_title("AUDIO_OMIT");
596 // Necessary for PCM audio
597 file->tag.set_property("CHANNELS", channels);
598 file->tag.set_property("RATE", sample_rate);
599 file->tag.set_property("BITS", bits);
600 file->tag.set_property("BYTE_ORDER", byte_order);
601 file->tag.set_property("SIGNED", signed_);
602 file->tag.set_property("HEADER", header);
603 file->tag.set_property("DITHER", dither);
605 file->tag.set_property("ACODEC", acodec);
607 file->tag.set_property("AUDIO_LENGTH", audio_length);
611 // Rely on defaults operations for these.
613 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
614 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
615 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
621 file->tag.set_title("/AUDIO");
623 file->tag.set_title("/AUDIO_OMIT");
625 file->append_newline();
629 int Asset::write_video(FileXML *file)
631 char string[BCTEXTLEN];
634 file->tag.set_title("VIDEO");
636 file->tag.set_title("VIDEO_OMIT");
637 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
638 file->tag.set_property("ACTUAL_WIDTH", actual_width);
639 file->tag.set_property("HEIGHT", height);
640 file->tag.set_property("WIDTH", width);
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 file->tag.set_property("INTERLACE_AUTOFIX", interlace_autofixoption);
654 ilacemode_to_xmltext(string, interlace_mode);
655 file->tag.set_property("INTERLACE_MODE", string);
657 ilacefixmethod_to_xmltext(string, interlace_fixmethod);
658 file->tag.set_property("INTERLACE_FIXMETHOD", string);
662 file->tag.set_title("/VIDEO");
664 file->tag.set_title("/VIDEO_OMIT");
667 file->append_newline();
671 int Asset::write_index(FileXML *file)
673 index_state->write_xml(file);
678 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
681 sprintf(return_value, "%s%s", prefix, param);
683 strcpy(return_value, param);
687 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
688 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
690 void Asset::load_defaults(BC_Hash *defaults,
698 char string[BCTEXTLEN];
700 // Can't save codec here because it's specific to render, record, and effect.
701 // The codec has to be UNKNOWN for file probing to work.
705 GET_DEFAULT("PATH", path);
710 GET_DEFAULT("AUDIO_CODEC", acodec);
711 GET_DEFAULT("VIDEO_CODEC", vcodec);
716 format = GET_DEFAULT("FORMAT", format);
717 use_header = GET_DEFAULT("USE_HEADER", use_header);
718 GET_DEFAULT("FFORMAT", fformat);
723 audio_data = GET_DEFAULT("AUDIO", 1);
724 video_data = GET_DEFAULT("VIDEO", 1);
729 bits = GET_DEFAULT("BITS", 16);
730 dither = GET_DEFAULT("DITHER", 0);
731 signed_ = GET_DEFAULT("SIGNED", 1);
732 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
736 channels = GET_DEFAULT("CHANNELS", 2);
737 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
738 header = GET_DEFAULT("HEADER", 0);
739 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
743 height = GET_DEFAULT("HEIGHT", height);
744 width = GET_DEFAULT("WIDTH", width);
745 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
746 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
747 program = GET_DEFAULT("PROGRAM", program);
748 layers = GET_DEFAULT("LAYERS", layers);
749 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
750 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
751 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
754 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
755 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
757 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
758 GET_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
759 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
760 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
761 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
762 GET_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
763 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
764 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
766 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
768 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
769 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
771 interlace_autofixoption = ILACE_AUTOFIXOPTION_AUTO;
772 interlace_mode = ILACE_MODE_UNDETECTED;
773 interlace_fixmethod = ILACE_FIXMETHOD_UPONE;
775 // MPEG format information
776 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
777 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
778 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
779 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
780 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
781 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
782 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
783 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
784 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
785 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
786 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
787 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
789 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
791 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
792 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
793 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
794 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
795 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
797 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
798 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
802 void Asset::save_defaults(BC_Hash *defaults,
810 char string[BCTEXTLEN];
812 UPDATE_DEFAULT("PATH", path);
819 UPDATE_DEFAULT("FORMAT", format);
820 UPDATE_DEFAULT("USE_HEADER", use_header);
821 UPDATE_DEFAULT("FFORMAT", fformat);
826 UPDATE_DEFAULT("AUDIO", audio_data);
827 UPDATE_DEFAULT("VIDEO", video_data);
832 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
833 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
835 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
836 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
838 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
839 UPDATE_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
840 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
841 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
842 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
843 UPDATE_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
844 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
845 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
847 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
849 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
850 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
852 // MPEG format information
853 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
854 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
855 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
856 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
857 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
858 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
859 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
860 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
861 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
862 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
863 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
864 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
867 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
870 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
871 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
872 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
873 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
874 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
878 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
879 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
887 UPDATE_DEFAULT("BITS", bits);
888 UPDATE_DEFAULT("DITHER", dither);
889 UPDATE_DEFAULT("SIGNED", signed_);
890 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
897 UPDATE_DEFAULT("CHANNELS", channels);
898 UPDATE_DEFAULT("RATE", sample_rate);
899 UPDATE_DEFAULT("HEADER", header);
900 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
904 UPDATE_DEFAULT("HEIGHT", height);
905 UPDATE_DEFAULT("WIDTH", width);
906 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
907 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
908 UPDATE_DEFAULT("PROGRAM", program);
909 UPDATE_DEFAULT("LAYERS", layers);
910 UPDATE_DEFAULT("FRAMERATE", frame_rate);
911 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
912 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
925 int Asset::dump(FILE *fp)
927 fprintf(fp," asset::dump\n");
928 fprintf(fp," this=%p path=%s\n", this, path);
929 fprintf(fp," index_status %d\n", index_state->index_status);
930 fprintf(fp," format %d\n", format);
931 fprintf(fp," fformat=\"%s\"\n", fformat);
932 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
933 fprintf(fp," ff_sample_format=\"%s\"\n", ff_sample_format);
934 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
935 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
936 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
937 fprintf(fp," ff_pixel_format=\"%s\"\n", ff_pixel_format);
938 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
939 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
940 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
941 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
942 audio_data, channels, sample_rate, bits, byte_order, signed_,
943 header, dither, acodec);
944 fprintf(fp," audio_length %jd\n", audio_length);
945 char string[BCTEXTLEN];
946 ilacemode_to_xmltext(string, interlace_mode);
947 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
948 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
949 video_data, layers, program, frame_rate, width, height,
950 vcodec, aspect_ratio,string);
951 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
952 printf(" mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
958 int Asset::get_audio_channels()
963 int Asset::get_sample_rate()
968 int64_t Asset::get_audio_samples()
973 int Asset::have_audio()
978 int Asset::have_video()
993 double Asset::get_frame_rate()
999 int Asset::get_video_layers()
1004 int Asset::get_program()
1009 int64_t Asset::get_video_frames()
1011 return video_length;
1014 double Asset::total_length_framealigned(double fps)
1016 if (video_data && audio_data) {
1017 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1018 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1019 return MIN(aud,vid);
1023 return (double)audio_length / sample_rate;
1026 return (double)video_length / frame_rate;