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_mode = ILACE_MODE_UNDETECTED;
102 ampeg_derivative = 3;
105 vmpeg_iframe_distance = 45;
106 vmpeg_pframe_distance = 0;
107 vmpeg_progressive = 0;
109 vmpeg_bitrate = 1000000;
110 vmpeg_derivative = 1;
111 vmpeg_quantization = 15;
112 vmpeg_cmodel = BC_YUV420P;
113 vmpeg_fix_bitrate = 0;
116 vmpeg_field_order = 0;
126 tiff_compression = 0;
136 void Asset::reset_audio()
144 void Asset::reset_video()
148 actual_width = width = 0;
149 actual_height = height = 0;
152 vmpeg_cmodel = BC_YUV420P;
158 void Asset::boundaries()
160 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
161 // sample_rate & frame_rate are user defined
162 // CLAMP(sample_rate, 1, 1000000);
163 // CLAMP(frame_rate, 0.001, 1000000);
164 CLAMP(channels, 0, 16);
165 CLAMP(width, 0, 10000);
166 CLAMP(height, 0, 10000);
167 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
170 void Asset::copy_from(Asset *asset, int do_index)
172 copy_location(asset);
173 copy_format(asset, do_index);
176 void Asset::copy_location(Asset *asset)
178 strcpy(path, asset->path);
179 folder_no = asset->folder_no;
182 void Asset::copy_format(Asset *asset, int do_index)
184 if(do_index) update_index(asset);
186 audio_data = asset->audio_data;
187 format = asset->format;
188 strcpy(fformat, asset->fformat);
189 channels = asset->channels;
190 sample_rate = asset->sample_rate;
192 byte_order = asset->byte_order;
193 signed_ = asset->signed_;
194 header = asset->header;
195 dither = asset->dither;
196 mp3_bitrate = asset->mp3_bitrate;
197 use_header = asset->use_header;
198 aspect_ratio = asset->aspect_ratio;
199 interlace_mode = asset->interlace_mode;
201 video_data = asset->video_data;
202 layers = asset->layers;
203 program = asset->program;
204 frame_rate = asset->frame_rate;
205 width = asset->width;
206 height = asset->height;
207 actual_width = asset->actual_width;
208 actual_height = asset->actual_height;
209 strcpy(vcodec, asset->vcodec);
210 strcpy(acodec, asset->acodec);
212 strcpy(ff_audio_options, asset->ff_audio_options);
213 strcpy(ff_sample_format, asset->ff_sample_format);
214 ff_audio_bitrate = asset->ff_audio_bitrate;
215 ff_audio_quality = asset->ff_audio_quality;
216 strcpy(ff_video_options, asset->ff_video_options);
217 strcpy(ff_pixel_format, asset->ff_pixel_format);
218 ff_video_bitrate = asset->ff_video_bitrate;
219 ff_video_quality = asset->ff_video_quality;
221 this->audio_length = asset->audio_length;
222 this->video_length = asset->video_length;
223 this->single_frame = asset->single_frame;
225 ampeg_bitrate = asset->ampeg_bitrate;
226 ampeg_derivative = asset->ampeg_derivative;
228 jpeg_quality = asset->jpeg_quality;
231 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
232 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
233 vmpeg_progressive = asset->vmpeg_progressive;
234 vmpeg_denoise = asset->vmpeg_denoise;
235 vmpeg_bitrate = asset->vmpeg_bitrate;
236 vmpeg_derivative = asset->vmpeg_derivative;
237 vmpeg_quantization = asset->vmpeg_quantization;
238 vmpeg_cmodel = asset->vmpeg_cmodel;
239 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
240 vmpeg_seq_codes = asset->vmpeg_seq_codes;
241 vmpeg_preset = asset->vmpeg_preset;
242 vmpeg_field_order = asset->vmpeg_field_order;
244 ac3_bitrate = asset->ac3_bitrate;
246 png_use_alpha = asset->png_use_alpha;
247 exr_use_alpha = asset->exr_use_alpha;
248 exr_compression = asset->exr_compression;
250 tiff_cmodel = asset->tiff_cmodel;
251 tiff_compression = asset->tiff_compression;
254 mov_sphere = asset->mov_sphere;
255 jpeg_sphere = asset->jpeg_sphere;
258 int64_t Asset::get_index_offset(int channel)
260 return index_state->get_index_offset(channel);
263 int64_t Asset::get_index_size(int channel)
265 return index_state->get_index_size(channel);
269 char* Asset::get_compression_text(int audio, int video)
274 if( acodec[0] ) return acodec;
281 if( vcodec[0] ) return vcodec;
288 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
290 int result = format == asset.format ? 1 : 0;
291 if( result && strcmp(asset.path, path) ) {
292 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
293 char *sp = out_path ? strrchr(out_path,'/') : 0;
295 char *apath = FileSystem::basepath(asset.path);
296 char *tpath = FileSystem::basepath(this->path);
298 if( *apath != '/' ) {
299 char *cp = cstrcat(2, out_path, apath);
300 delete [] apath; apath = FileSystem::basepath(cp);
303 if( *tpath != '/' ) {
304 char *cp = cstrcat(2, out_path, tpath);
305 delete [] tpath; tpath = FileSystem::basepath(cp);
309 if( strcmp(apath, tpath) ) result = 0;
315 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
318 if(test_audio && result)
320 result = (channels == asset.channels &&
321 sample_rate == asset.sample_rate &&
322 bits == asset.bits &&
323 byte_order == asset.byte_order &&
324 signed_ == asset.signed_ &&
325 header == asset.header &&
326 dither == asset.dither &&
327 !strcmp(acodec, asset.acodec));
328 if(result && format == FILE_FFMPEG)
329 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
330 !strcmp(ff_sample_format, asset.ff_sample_format) &&
331 ff_audio_bitrate == asset.ff_audio_bitrate &&
332 ff_audio_quality == asset.ff_audio_quality;
336 if(test_video && result)
338 result = (layers == asset.layers &&
339 program == asset.program &&
340 frame_rate == asset.frame_rate &&
341 asset.interlace_mode == interlace_mode &&
342 width == asset.width &&
343 height == asset.height &&
344 !strcmp(vcodec, asset.vcodec) &&
345 mov_sphere == asset.mov_sphere &&
346 jpeg_sphere == asset.jpeg_sphere);
347 if(result && format == FILE_FFMPEG)
348 result = !strcmp(ff_video_options, asset.ff_video_options) &&
349 !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
350 ff_video_bitrate == asset.ff_video_bitrate &&
351 ff_video_quality == asset.ff_video_quality;
357 int Asset::test_path(const char *path)
359 if(!strcasecmp(this->path, path))
365 int Asset::read(FileXML *file,
370 // Check for relative path.
373 char new_path[BCTEXTLEN];
374 char asset_directory[BCTEXTLEN];
375 char input_directory[BCTEXTLEN];
378 strcpy(new_path, path);
379 fs.set_current_dir("");
381 fs.extract_dir(asset_directory, path);
384 // Take path of XML file.
385 if(!asset_directory[0])
387 fs.extract_dir(input_directory, file->filename);
389 // Input file has a path
390 if(input_directory[0])
392 fs.join_names(path, input_directory, new_path);
400 result = file->read_tag();
403 if(file->tag.title_is("/ASSET"))
408 if(file->tag.title_is("AUDIO"))
413 if(file->tag.title_is("AUDIO_OMIT"))
418 if(file->tag.title_is("FORMAT"))
420 const char *string = file->tag.get_property("TYPE");
421 format = File::strtoformat(string);
423 file->tag.get_property("USE_HEADER", use_header);
424 file->tag.get_property("FFORMAT", fformat);
427 if(file->tag.title_is("FOLDER"))
429 folder_no = file->tag.get_property("NUMBER", AW_MEDIA_FOLDER);
432 if(file->tag.title_is("VIDEO"))
437 if(file->tag.title_is("VIDEO_OMIT"))
442 if(file->tag.title_is("INDEX"))
450 //printf("Asset::read 2\n");
454 int Asset::read_audio(FileXML *file)
456 if(file->tag.title_is("AUDIO")) audio_data = 1;
457 channels = file->tag.get_property("CHANNELS", 2);
458 // This is loaded from the index file after the EDL but this
459 // should be overridable in the EDL.
460 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
461 bits = file->tag.get_property("BITS", 16);
462 byte_order = file->tag.get_property("BYTE_ORDER", 1);
463 signed_ = file->tag.get_property("SIGNED", 1);
464 header = file->tag.get_property("HEADER", 0);
465 dither = file->tag.get_property("DITHER", 0);
467 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
469 file->tag.get_property("ACODEC", acodec);
473 int Asset::read_video(FileXML *file)
475 char string[BCTEXTLEN];
477 if(file->tag.title_is("VIDEO")) video_data = 1;
478 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
479 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
480 height = file->tag.get_property("HEIGHT", height);
481 width = file->tag.get_property("WIDTH", width);
482 layers = file->tag.get_property("LAYERS", layers);
483 program = file->tag.get_property("PROGRAM", program);
484 // This is loaded from the index file after the EDL but this
485 // should be overridable in the EDL.
486 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
488 file->tag.get_property("VCODEC", vcodec);
490 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
491 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
492 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
493 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
494 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
495 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
500 int Asset::read_index(FileXML *file)
502 index_state->read_xml(file, channels);
506 // Output path is the path of the output file if name truncation is desired.
507 // It is a "" if complete names should be used.
509 int Asset::write(FileXML *file,
511 const char *output_path)
513 char new_path[BCTEXTLEN];
514 char asset_directory[BCTEXTLEN];
515 char output_directory[BCTEXTLEN];
518 // Make path relative
519 fs.extract_dir(asset_directory, path);
520 if(output_path && output_path[0])
521 fs.extract_dir(output_directory, output_path);
523 output_directory[0] = 0;
525 // Asset and EDL are in same directory. Extract just the name.
526 if(!strcmp(asset_directory, output_directory))
528 fs.extract_name(new_path, path);
532 strcpy(new_path, path);
535 file->tag.set_title("ASSET");
536 file->tag.set_property("SRC", new_path);
538 file->append_newline();
540 file->tag.set_title("FOLDER");
541 file->tag.set_property("NUMBER", folder_no);
543 file->tag.set_title("/FOLDER");
545 file->append_newline();
547 // Write the format information
548 file->tag.set_title("FORMAT");
550 file->tag.set_property("TYPE",
551 File::formattostr(format));
552 file->tag.set_property("USE_HEADER", use_header);
553 file->tag.set_property("FFORMAT", fformat);
556 file->tag.set_title("/FORMAT");
558 file->append_newline();
560 // Requiring data to exist caused batch render to lose settings.
561 // But the only way to know if an asset doesn't have audio or video data
562 // is to not write the block.
563 // So change the block name if the asset doesn't have the data.
566 // index goes after source
567 if( include_index && index_state &&
568 index_state->index_status == INDEX_READY )
571 file->tag.set_title("/ASSET");
573 file->append_newline();
577 int Asset::write_audio(FileXML *file)
579 // Let the reader know if the asset has the data by naming the block.
581 file->tag.set_title("AUDIO");
583 file->tag.set_title("AUDIO_OMIT");
584 // Necessary for PCM audio
585 file->tag.set_property("CHANNELS", channels);
586 file->tag.set_property("RATE", sample_rate);
587 file->tag.set_property("BITS", bits);
588 file->tag.set_property("BYTE_ORDER", byte_order);
589 file->tag.set_property("SIGNED", signed_);
590 file->tag.set_property("HEADER", header);
591 file->tag.set_property("DITHER", dither);
593 file->tag.set_property("ACODEC", acodec);
595 file->tag.set_property("AUDIO_LENGTH", audio_length);
599 // Rely on defaults operations for these.
601 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
602 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
603 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
609 file->tag.set_title("/AUDIO");
611 file->tag.set_title("/AUDIO_OMIT");
613 file->append_newline();
617 int Asset::write_video(FileXML *file)
619 char string[BCTEXTLEN];
622 file->tag.set_title("VIDEO");
624 file->tag.set_title("VIDEO_OMIT");
625 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
626 file->tag.set_property("ACTUAL_WIDTH", actual_width);
627 file->tag.set_property("HEIGHT", height);
628 file->tag.set_property("WIDTH", width);
629 file->tag.set_property("LAYERS", layers);
630 file->tag.set_property("PROGRAM", program);
631 file->tag.set_property("FRAMERATE", frame_rate);
633 file->tag.set_property("VCODEC", vcodec);
635 file->tag.set_property("VIDEO_LENGTH", video_length);
636 file->tag.set_property("MOV_SPHERE", mov_sphere);
637 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
638 file->tag.set_property("SINGLE_FRAME", single_frame);
640 ilacemode_to_xmltext(string, interlace_mode);
641 file->tag.set_property("INTERLACE_MODE", string);
645 file->tag.set_title("/VIDEO");
647 file->tag.set_title("/VIDEO_OMIT");
650 file->append_newline();
654 int Asset::write_index(FileXML *file)
656 index_state->write_xml(file);
661 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
664 sprintf(return_value, "%s%s", prefix, param);
666 strcpy(return_value, param);
670 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
671 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
673 void Asset::load_defaults(BC_Hash *defaults,
681 char string[BCTEXTLEN];
683 // Can't save codec here because it's specific to render, record, and effect.
684 // The codec has to be UNKNOWN for file probing to work.
688 GET_DEFAULT("PATH", path);
693 GET_DEFAULT("AUDIO_CODEC", acodec);
694 GET_DEFAULT("VIDEO_CODEC", vcodec);
699 format = GET_DEFAULT("FORMAT", format);
700 use_header = GET_DEFAULT("USE_HEADER", use_header);
701 GET_DEFAULT("FFORMAT", fformat);
706 audio_data = GET_DEFAULT("AUDIO", 1);
707 video_data = GET_DEFAULT("VIDEO", 1);
712 bits = GET_DEFAULT("BITS", 16);
713 dither = GET_DEFAULT("DITHER", 0);
714 signed_ = GET_DEFAULT("SIGNED", 1);
715 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
719 channels = GET_DEFAULT("CHANNELS", 2);
720 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
721 header = GET_DEFAULT("HEADER", 0);
722 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
726 height = GET_DEFAULT("HEIGHT", height);
727 width = GET_DEFAULT("WIDTH", width);
728 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
729 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
730 program = GET_DEFAULT("PROGRAM", program);
731 layers = GET_DEFAULT("LAYERS", layers);
732 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
733 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
734 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
737 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
738 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
740 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
741 GET_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
742 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
743 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
744 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
745 GET_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
746 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
747 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
749 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
751 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
752 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
753 interlace_mode = ILACE_MODE_UNDETECTED;
755 // MPEG format information
756 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
757 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
758 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
759 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
760 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
761 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
762 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
763 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
764 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
765 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
766 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
767 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
769 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
771 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
772 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
773 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
774 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
775 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
777 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
778 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
782 void Asset::save_defaults(BC_Hash *defaults,
790 char string[BCTEXTLEN];
792 UPDATE_DEFAULT("PATH", path);
799 UPDATE_DEFAULT("FORMAT", format);
800 UPDATE_DEFAULT("USE_HEADER", use_header);
801 UPDATE_DEFAULT("FFORMAT", fformat);
806 UPDATE_DEFAULT("AUDIO", audio_data);
807 UPDATE_DEFAULT("VIDEO", video_data);
812 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
813 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
815 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
816 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
818 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
819 UPDATE_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
820 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
821 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
822 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
823 UPDATE_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
824 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
825 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
827 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
829 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
830 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
832 // MPEG format information
833 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
834 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
835 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
836 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
837 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
838 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
839 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
840 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
841 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
842 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
843 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
844 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
847 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
850 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
851 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
852 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
853 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
854 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
858 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
859 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
867 UPDATE_DEFAULT("BITS", bits);
868 UPDATE_DEFAULT("DITHER", dither);
869 UPDATE_DEFAULT("SIGNED", signed_);
870 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
877 UPDATE_DEFAULT("CHANNELS", channels);
878 UPDATE_DEFAULT("RATE", sample_rate);
879 UPDATE_DEFAULT("HEADER", header);
880 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
884 UPDATE_DEFAULT("HEIGHT", height);
885 UPDATE_DEFAULT("WIDTH", width);
886 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
887 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
888 UPDATE_DEFAULT("PROGRAM", program);
889 UPDATE_DEFAULT("LAYERS", layers);
890 UPDATE_DEFAULT("FRAMERATE", frame_rate);
891 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
892 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
905 int Asset::dump(FILE *fp)
907 fprintf(fp," asset::dump\n");
908 fprintf(fp," this=%p path=%s\n", this, path);
909 fprintf(fp," index_status %d\n", index_state->index_status);
910 fprintf(fp," format %d\n", format);
911 fprintf(fp," fformat=\"%s\"\n", fformat);
912 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
913 fprintf(fp," ff_sample_format=\"%s\"\n", ff_sample_format);
914 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
915 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
916 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
917 fprintf(fp," ff_pixel_format=\"%s\"\n", ff_pixel_format);
918 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
919 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
920 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
921 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
922 audio_data, channels, sample_rate, bits, byte_order, signed_,
923 header, dither, acodec);
924 fprintf(fp," audio_length %jd\n", audio_length);
925 char string[BCTEXTLEN];
926 ilacemode_to_xmltext(string, interlace_mode);
927 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
928 " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
929 video_data, layers, program, frame_rate, width, height,
930 vcodec, aspect_ratio,string);
931 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
932 fprintf(fp," mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
938 int Asset::get_audio_channels()
943 int Asset::get_sample_rate()
948 int64_t Asset::get_audio_samples()
953 int Asset::have_audio()
958 int Asset::have_video()
973 double Asset::get_frame_rate()
979 int Asset::get_video_layers()
984 int Asset::get_program()
989 int64_t Asset::get_video_frames()
994 double Asset::total_length_framealigned(double fps)
996 if (video_data && audio_data) {
997 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
998 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1003 return (double)audio_length / sample_rate;
1006 return (double)video_length / frame_rate;