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;
150 proxy_scale = 0; // not a proxy
153 vmpeg_cmodel = BC_YUV420P;
159 void Asset::boundaries()
161 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
162 // sample_rate & frame_rate are user defined
163 // CLAMP(sample_rate, 1, 1000000);
164 // CLAMP(frame_rate, 0.001, 1000000);
165 CLAMP(channels, 0, 16);
166 CLAMP(width, 0, 10000);
167 CLAMP(height, 0, 10000);
168 //printf("Asset::boundaries %d %d %f\n", __LINE__, sample_rate, frame_rate);
171 void Asset::copy_from(Asset *asset, int do_index)
173 copy_location(asset);
174 copy_format(asset, do_index);
177 void Asset::copy_location(Asset *asset)
179 strcpy(path, asset->path);
180 folder_no = asset->folder_no;
183 void Asset::copy_format(Asset *asset, int do_index)
185 if(do_index) update_index(asset);
187 audio_data = asset->audio_data;
188 format = asset->format;
189 strcpy(fformat, asset->fformat);
190 channels = asset->channels;
191 sample_rate = asset->sample_rate;
193 byte_order = asset->byte_order;
194 signed_ = asset->signed_;
195 header = asset->header;
196 dither = asset->dither;
197 mp3_bitrate = asset->mp3_bitrate;
198 use_header = asset->use_header;
199 aspect_ratio = asset->aspect_ratio;
200 interlace_mode = asset->interlace_mode;
202 video_data = asset->video_data;
203 layers = asset->layers;
204 program = asset->program;
205 frame_rate = asset->frame_rate;
206 width = asset->width;
207 height = asset->height;
208 actual_width = asset->actual_width;
209 actual_height = asset->actual_height;
210 proxy_scale = asset->proxy_scale;
211 strcpy(vcodec, asset->vcodec);
212 strcpy(acodec, asset->acodec);
214 strcpy(ff_audio_options, asset->ff_audio_options);
215 strcpy(ff_sample_format, asset->ff_sample_format);
216 ff_audio_bitrate = asset->ff_audio_bitrate;
217 ff_audio_quality = asset->ff_audio_quality;
218 strcpy(ff_video_options, asset->ff_video_options);
219 strcpy(ff_pixel_format, asset->ff_pixel_format);
220 ff_video_bitrate = asset->ff_video_bitrate;
221 ff_video_quality = asset->ff_video_quality;
223 this->audio_length = asset->audio_length;
224 this->video_length = asset->video_length;
225 this->single_frame = asset->single_frame;
227 ampeg_bitrate = asset->ampeg_bitrate;
228 ampeg_derivative = asset->ampeg_derivative;
230 jpeg_quality = asset->jpeg_quality;
233 vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
234 vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
235 vmpeg_progressive = asset->vmpeg_progressive;
236 vmpeg_denoise = asset->vmpeg_denoise;
237 vmpeg_bitrate = asset->vmpeg_bitrate;
238 vmpeg_derivative = asset->vmpeg_derivative;
239 vmpeg_quantization = asset->vmpeg_quantization;
240 vmpeg_cmodel = asset->vmpeg_cmodel;
241 vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
242 vmpeg_seq_codes = asset->vmpeg_seq_codes;
243 vmpeg_preset = asset->vmpeg_preset;
244 vmpeg_field_order = asset->vmpeg_field_order;
246 ac3_bitrate = asset->ac3_bitrate;
248 png_use_alpha = asset->png_use_alpha;
249 exr_use_alpha = asset->exr_use_alpha;
250 exr_compression = asset->exr_compression;
252 tiff_cmodel = asset->tiff_cmodel;
253 tiff_compression = asset->tiff_compression;
256 mov_sphere = asset->mov_sphere;
257 jpeg_sphere = asset->jpeg_sphere;
260 int64_t Asset::get_index_offset(int channel)
262 return index_state->get_index_offset(channel);
265 int64_t Asset::get_index_size(int channel)
267 return index_state->get_index_size(channel);
271 char* Asset::get_compression_text(int audio, int video)
276 if( acodec[0] ) return acodec;
283 if( vcodec[0] ) return vcodec;
290 int Asset::equivalent(Asset &asset, int test_audio, int test_video, EDL *edl)
292 int result = format == asset.format ? 1 : 0;
293 if( result && strcmp(asset.path, path) ) {
294 char *out_path = edl ? FileSystem::basepath(edl->path) : 0;
295 char *sp = out_path ? strrchr(out_path,'/') : 0;
297 char *apath = FileSystem::basepath(asset.path);
298 char *tpath = FileSystem::basepath(this->path);
300 if( *apath != '/' ) {
301 char *cp = cstrcat(2, out_path, apath);
302 delete [] apath; apath = FileSystem::basepath(cp);
305 if( *tpath != '/' ) {
306 char *cp = cstrcat(2, out_path, tpath);
307 delete [] tpath; tpath = FileSystem::basepath(cp);
311 if( strcmp(apath, tpath) ) result = 0;
317 if(result && format == FILE_FFMPEG && strcmp(fformat, asset.fformat) )
320 if(test_audio && result)
322 result = (channels == asset.channels &&
323 sample_rate == asset.sample_rate &&
324 bits == asset.bits &&
325 byte_order == asset.byte_order &&
326 signed_ == asset.signed_ &&
327 header == asset.header &&
328 dither == asset.dither &&
329 !strcmp(acodec, asset.acodec));
330 if(result && format == FILE_FFMPEG)
331 result = !strcmp(ff_audio_options, asset.ff_audio_options) &&
332 !strcmp(ff_sample_format, asset.ff_sample_format) &&
333 ff_audio_bitrate == asset.ff_audio_bitrate &&
334 ff_audio_quality == asset.ff_audio_quality;
338 if(test_video && result)
340 result = (layers == asset.layers &&
341 program == asset.program &&
342 frame_rate == asset.frame_rate &&
343 asset.interlace_mode == interlace_mode &&
344 width == asset.width &&
345 height == asset.height &&
346 !strcmp(vcodec, asset.vcodec) &&
347 mov_sphere == asset.mov_sphere &&
348 jpeg_sphere == asset.jpeg_sphere);
349 if(result && format == FILE_FFMPEG)
350 result = !strcmp(ff_video_options, asset.ff_video_options) &&
351 !strcmp(ff_pixel_format, asset.ff_pixel_format) &&
352 ff_video_bitrate == asset.ff_video_bitrate &&
353 ff_video_quality == asset.ff_video_quality;
359 int Asset::test_path(const char *path)
361 if(!strcasecmp(this->path, path))
367 int Asset::read(FileXML *file,
372 // Check for relative path.
375 char new_path[BCTEXTLEN];
376 char asset_directory[BCTEXTLEN];
377 char input_directory[BCTEXTLEN];
380 strcpy(new_path, path);
381 fs.set_current_dir("");
383 fs.extract_dir(asset_directory, path);
386 // Take path of XML file.
387 if(!asset_directory[0])
389 fs.extract_dir(input_directory, file->filename);
391 // Input file has a path
392 if(input_directory[0])
394 fs.join_names(path, input_directory, new_path);
402 result = file->read_tag();
405 if(file->tag.title_is("/ASSET"))
410 if(file->tag.title_is("AUDIO"))
415 if(file->tag.title_is("AUDIO_OMIT"))
420 if(file->tag.title_is("FORMAT"))
422 const char *string = file->tag.get_property("TYPE");
423 format = File::strtoformat(string);
425 file->tag.get_property("USE_HEADER", use_header);
426 file->tag.get_property("FFORMAT", fformat);
429 if(file->tag.title_is("FOLDER"))
431 folder_no = file->tag.get_property("NUMBER", AW_MEDIA_FOLDER);
434 if(file->tag.title_is("VIDEO"))
439 if(file->tag.title_is("VIDEO_OMIT"))
444 if(file->tag.title_is("INDEX"))
452 //printf("Asset::read 2\n");
456 int Asset::read_audio(FileXML *file)
458 if(file->tag.title_is("AUDIO")) audio_data = 1;
459 channels = file->tag.get_property("CHANNELS", 2);
460 // This is loaded from the index file after the EDL but this
461 // should be overridable in the EDL.
462 if(!sample_rate) sample_rate = file->tag.get_property("RATE", 48000);
463 bits = file->tag.get_property("BITS", 16);
464 byte_order = file->tag.get_property("BYTE_ORDER", 1);
465 signed_ = file->tag.get_property("SIGNED", 1);
466 header = file->tag.get_property("HEADER", 0);
467 dither = file->tag.get_property("DITHER", 0);
469 audio_length = file->tag.get_property("AUDIO_LENGTH", (int64_t)0);
471 file->tag.get_property("ACODEC", acodec);
475 int Asset::read_video(FileXML *file)
477 char string[BCTEXTLEN];
479 if(file->tag.title_is("VIDEO")) video_data = 1;
480 actual_height = file->tag.get_property("ACTUAL_HEIGHT", actual_height);
481 actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
482 height = file->tag.get_property("HEIGHT", height);
483 width = file->tag.get_property("WIDTH", width);
484 proxy_scale = file->tag.get_property("PROXY_SCALE", 0);
485 layers = file->tag.get_property("LAYERS", layers);
486 program = file->tag.get_property("PROGRAM", program);
487 // This is loaded from the index file after the EDL but this
488 // should be overridable in the EDL.
489 if(EQUIV(frame_rate, 0)) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
491 file->tag.get_property("VCODEC", vcodec);
493 video_length = file->tag.get_property("VIDEO_LENGTH", (int64_t)0);
494 mov_sphere = file->tag.get_property("MOV_SPHERE", 0);
495 jpeg_sphere = file->tag.get_property("JPEG_SPHERE", 0);
496 single_frame = file->tag.get_property("SINGLE_FRAME", (int64_t)0);
497 ilacemode_to_xmltext(string, ILACE_MODE_NOTINTERLACED);
498 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE",string), ILACE_MODE_NOTINTERLACED);
503 int Asset::read_index(FileXML *file)
505 index_state->read_xml(file, channels);
509 // Output path is the path of the output file if name truncation is desired.
510 // It is a "" if complete names should be used.
512 int Asset::write(FileXML *file,
514 const char *output_path)
516 char new_path[BCTEXTLEN];
517 char asset_directory[BCTEXTLEN];
518 char output_directory[BCTEXTLEN];
521 // Make path relative
522 fs.extract_dir(asset_directory, path);
523 if(output_path && output_path[0])
524 fs.extract_dir(output_directory, output_path);
526 output_directory[0] = 0;
528 // Asset and EDL are in same directory. Extract just the name.
529 if(!strcmp(asset_directory, output_directory))
531 fs.extract_name(new_path, path);
535 strcpy(new_path, path);
538 file->tag.set_title("ASSET");
539 file->tag.set_property("SRC", new_path);
541 file->append_newline();
543 file->tag.set_title("FOLDER");
544 file->tag.set_property("NUMBER", folder_no);
546 file->tag.set_title("/FOLDER");
548 file->append_newline();
550 // Write the format information
551 file->tag.set_title("FORMAT");
553 file->tag.set_property("TYPE",
554 File::formattostr(format));
555 file->tag.set_property("USE_HEADER", use_header);
556 file->tag.set_property("FFORMAT", fformat);
559 file->tag.set_title("/FORMAT");
561 file->append_newline();
563 // Requiring data to exist caused batch render to lose settings.
564 // But the only way to know if an asset doesn't have audio or video data
565 // is to not write the block.
566 // So change the block name if the asset doesn't have the data.
569 // index goes after source
570 if( include_index && index_state &&
571 index_state->index_status == INDEX_READY )
574 file->tag.set_title("/ASSET");
576 file->append_newline();
580 int Asset::write_audio(FileXML *file)
582 // Let the reader know if the asset has the data by naming the block.
584 file->tag.set_title("AUDIO");
586 file->tag.set_title("AUDIO_OMIT");
587 // Necessary for PCM audio
588 file->tag.set_property("CHANNELS", channels);
589 file->tag.set_property("RATE", sample_rate);
590 file->tag.set_property("BITS", bits);
591 file->tag.set_property("BYTE_ORDER", byte_order);
592 file->tag.set_property("SIGNED", signed_);
593 file->tag.set_property("HEADER", header);
594 file->tag.set_property("DITHER", dither);
596 file->tag.set_property("ACODEC", acodec);
598 file->tag.set_property("AUDIO_LENGTH", audio_length);
602 // Rely on defaults operations for these.
604 // file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
605 // file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
606 // file->tag.set_property("MP3_BITRATE", mp3_bitrate);
612 file->tag.set_title("/AUDIO");
614 file->tag.set_title("/AUDIO_OMIT");
616 file->append_newline();
620 int Asset::write_video(FileXML *file)
622 char string[BCTEXTLEN];
625 file->tag.set_title("VIDEO");
627 file->tag.set_title("VIDEO_OMIT");
628 file->tag.set_property("ACTUAL_HEIGHT", actual_height);
629 file->tag.set_property("ACTUAL_WIDTH", actual_width);
630 file->tag.set_property("HEIGHT", height);
631 file->tag.set_property("WIDTH", width);
632 file->tag.set_property("PROXY_SCALE", proxy_scale);
633 file->tag.set_property("LAYERS", layers);
634 file->tag.set_property("PROGRAM", program);
635 file->tag.set_property("FRAMERATE", frame_rate);
637 file->tag.set_property("VCODEC", vcodec);
639 file->tag.set_property("VIDEO_LENGTH", video_length);
640 file->tag.set_property("MOV_SPHERE", mov_sphere);
641 file->tag.set_property("JPEG_SPHERE", jpeg_sphere);
642 file->tag.set_property("SINGLE_FRAME", single_frame);
644 ilacemode_to_xmltext(string, interlace_mode);
645 file->tag.set_property("INTERLACE_MODE", string);
649 file->tag.set_title("/VIDEO");
651 file->tag.set_title("/VIDEO_OMIT");
654 file->append_newline();
658 int Asset::write_index(FileXML *file)
660 index_state->write_xml(file);
665 char* Asset::construct_param(const char *param, const char *prefix, char *return_value)
668 sprintf(return_value, "%s%s", prefix, param);
670 strcpy(return_value, param);
674 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
675 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
677 void Asset::load_defaults(BC_Hash *defaults,
685 char string[BCTEXTLEN];
687 // Can't save codec here because it's specific to render, record, and effect.
688 // The codec has to be UNKNOWN for file probing to work.
692 GET_DEFAULT("PATH", path);
697 GET_DEFAULT("AUDIO_CODEC", acodec);
698 GET_DEFAULT("VIDEO_CODEC", vcodec);
703 format = GET_DEFAULT("FORMAT", format);
704 use_header = GET_DEFAULT("USE_HEADER", use_header);
705 GET_DEFAULT("FFORMAT", fformat);
710 audio_data = GET_DEFAULT("AUDIO", 1);
711 video_data = GET_DEFAULT("VIDEO", 1);
716 bits = GET_DEFAULT("BITS", 16);
717 dither = GET_DEFAULT("DITHER", 0);
718 signed_ = GET_DEFAULT("SIGNED", 1);
719 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
723 channels = GET_DEFAULT("CHANNELS", 2);
724 if(!sample_rate) sample_rate = GET_DEFAULT("RATE", 48000);
725 header = GET_DEFAULT("HEADER", 0);
726 audio_length = GET_DEFAULT("AUDIO_LENGTH", (int64_t)0);
730 height = GET_DEFAULT("HEIGHT", height);
731 width = GET_DEFAULT("WIDTH", width);
732 actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
733 actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
734 proxy_scale = GET_DEFAULT("PROXY_SCALE", proxy_scale);
735 program = GET_DEFAULT("PROGRAM", program);
736 layers = GET_DEFAULT("LAYERS", layers);
737 if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
738 video_length = GET_DEFAULT("VIDEO_LENGTH", (int64_t)0);
739 single_frame = GET_DEFAULT("SINGLE_FRAME", (int64_t)0);
742 ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
743 ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
745 GET_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
746 GET_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
747 ff_audio_bitrate = GET_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
748 ff_audio_quality = GET_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
749 GET_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
750 GET_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
751 ff_video_bitrate = GET_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
752 ff_video_quality = GET_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
754 mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
756 jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
757 aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
758 interlace_mode = ILACE_MODE_UNDETECTED;
760 // MPEG format information
761 vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
762 vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
763 vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
764 vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
765 vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
766 vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
767 vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
768 vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
769 vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
770 vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
771 vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
772 vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
774 ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
776 png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
777 exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
778 exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
779 tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
780 tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
782 mov_sphere = GET_DEFAULT("MOV_SPHERE", mov_sphere);
783 jpeg_sphere = GET_DEFAULT("JPEG_SPHERE", jpeg_sphere);
787 void Asset::save_defaults(BC_Hash *defaults,
795 char string[BCTEXTLEN];
797 UPDATE_DEFAULT("PATH", path);
804 UPDATE_DEFAULT("FORMAT", format);
805 UPDATE_DEFAULT("USE_HEADER", use_header);
806 UPDATE_DEFAULT("FFORMAT", fformat);
811 UPDATE_DEFAULT("AUDIO", audio_data);
812 UPDATE_DEFAULT("VIDEO", video_data);
817 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
818 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
820 UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
821 UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
823 UPDATE_DEFAULT("FF_AUDIO_OPTIONS", ff_audio_options);
824 UPDATE_DEFAULT("FF_SAMPLE_FORMAT", ff_sample_format);
825 UPDATE_DEFAULT("FF_AUDIO_BITRATE", ff_audio_bitrate);
826 UPDATE_DEFAULT("FF_AUDIO_QUALITY", ff_audio_quality);
827 UPDATE_DEFAULT("FF_VIDEO_OPTIONS", ff_video_options);
828 UPDATE_DEFAULT("FF_PIXEL_FORMAT", ff_pixel_format);
829 UPDATE_DEFAULT("FF_VIDEO_BITRATE", ff_video_bitrate);
830 UPDATE_DEFAULT("FF_VIDEO_QUALITY", ff_video_quality);
832 UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
834 UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
835 UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
837 // MPEG format information
838 UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
839 UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
840 UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
841 UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
842 UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
843 UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
844 UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
845 UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
846 UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
847 UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
848 UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
849 UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
852 UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
855 UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
856 UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
857 UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
858 UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
859 UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
863 UPDATE_DEFAULT("MOV_SPHERE", mov_sphere);
864 UPDATE_DEFAULT("JPEG_SPHERE", jpeg_sphere);
872 UPDATE_DEFAULT("BITS", bits);
873 UPDATE_DEFAULT("DITHER", dither);
874 UPDATE_DEFAULT("SIGNED", signed_);
875 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
882 UPDATE_DEFAULT("CHANNELS", channels);
883 UPDATE_DEFAULT("RATE", sample_rate);
884 UPDATE_DEFAULT("HEADER", header);
885 UPDATE_DEFAULT("AUDIO_LENGTH", audio_length);
889 UPDATE_DEFAULT("HEIGHT", height);
890 UPDATE_DEFAULT("WIDTH", width);
891 UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
892 UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
893 UPDATE_DEFAULT("PROXY_SCALE", proxy_scale);
894 UPDATE_DEFAULT("PROGRAM", program);
895 UPDATE_DEFAULT("LAYERS", layers);
896 UPDATE_DEFAULT("FRAMERATE", frame_rate);
897 UPDATE_DEFAULT("VIDEO_LENGTH", video_length);
898 UPDATE_DEFAULT("SINGLE_FRAME", single_frame);
911 int Asset::dump(FILE *fp)
913 fprintf(fp," asset::dump\n");
914 fprintf(fp," this=%p path=%s\n", this, path);
915 fprintf(fp," index_status %d\n", index_state->index_status);
916 fprintf(fp," format %d\n", format);
917 fprintf(fp," fformat=\"%s\"\n", fformat);
918 fprintf(fp," ff_audio_options=\"%s\"\n", ff_audio_options);
919 fprintf(fp," ff_sample_format=\"%s\"\n", ff_sample_format);
920 fprintf(fp," ff_audio_bitrate=%d\n", ff_audio_bitrate);
921 fprintf(fp," ff_audio_quality=%d\n", ff_audio_quality);
922 fprintf(fp," ff_video_options=\"%s\"\n", ff_video_options);
923 fprintf(fp," ff_pixel_format=\"%s\"\n", ff_pixel_format);
924 fprintf(fp," ff_video_bitrate=%d\n", ff_video_bitrate);
925 fprintf(fp," ff_video_quality=%d\n", ff_video_quality);
926 fprintf(fp," audio_data %d channels %d samplerate %d bits %d"
927 " byte_order %d signed %d header %d dither %d acodec %4.4s\n",
928 audio_data, channels, sample_rate, bits, byte_order, signed_,
929 header, dither, acodec);
930 fprintf(fp," audio_length %jd\n", audio_length);
931 char string[BCTEXTLEN];
932 ilacemode_to_xmltext(string, interlace_mode);
933 fprintf(fp," video_data %d program %d layers %d framerate %f width %d"
934 " height %d vcodec %s aspect_ratio %f ilace_mode %s\n",
935 video_data, layers, program, frame_rate, width, height,
936 vcodec, aspect_ratio,string);
937 fprintf(fp," actual_width %d actual_height %d proxy_scale %d"
938 " video_length %jd repeat %d\n",
939 actual_width, actual_height, proxy_scale, video_length,
941 fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame);
942 fprintf(fp," mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
948 int Asset::get_audio_channels()
953 int Asset::get_sample_rate()
958 int64_t Asset::get_audio_samples()
963 int Asset::have_audio()
968 int Asset::have_video()
983 double Asset::get_frame_rate()
989 int Asset::get_video_layers()
994 int Asset::get_program()
999 int64_t Asset::get_video_frames()
1001 return video_length;
1004 double Asset::total_length_framealigned(double fps)
1006 if (video_data && audio_data) {
1007 double aud = floor(( (double)audio_length / sample_rate) * fps) / fps;
1008 double vid = floor(( (double)video_length / frame_rate) * fps) / fps;
1009 return MIN(aud,vid);
1013 return (double)audio_length / sample_rate;
1016 return (double)video_length / frame_rate;