Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

asset.C

Go to the documentation of this file.
00001 #include "asset.h"
00002 #include "defaults.h"
00003 #include "assets.h"
00004 #include "edl.h"
00005 #include "file.h"
00006 #include "filesystem.h"
00007 #include "filexml.h"
00008 #include "quicktime.h"
00009 #include "interlacemodes.h"
00010 
00011 #include <stdio.h>
00012 #include <string.h>
00013 
00014 
00015 Asset::Asset() : ListItem<Asset>()
00016 {
00017         init_values();
00018 }
00019 
00020 Asset::Asset(Asset &asset) : ListItem<Asset>()
00021 {
00022         init_values();
00023         *this = asset;
00024 }
00025 
00026 Asset::Asset(const char *path) : ListItem<Asset>()
00027 {
00028         init_values();
00029         strcpy(this->path, path);
00030 }
00031 
00032 Asset::Asset(const int plugin_type, const char *plugin_title) : ListItem<Asset>()
00033 {
00034         init_values();
00035 }
00036 
00037 Asset::~Asset()
00038 {
00039         delete [] index_offsets;
00040         delete [] index_sizes;
00041 // Don't delete index buffer since it is shared with the index thread.
00042 }
00043 
00044 
00045 int Asset::init_values()
00046 {
00047         path[0] = 0;
00048         strcpy(folder, MEDIA_FOLDER);
00049 //      format = FILE_MOV;
00050 // Has to be unknown for file probing to succeed
00051         format = FILE_UNKNOWN;
00052         channels = 0;
00053         sample_rate = 0;
00054         bits = 0;
00055         byte_order = 0;
00056         signed_ = 0;
00057         header = 0;
00058         dither = 0;
00059         audio_data = 0;
00060         video_data = 0;
00061         audio_length = 0;
00062         video_length = 0;
00063 
00064         layers = 0;
00065         frame_rate = 0;
00066         width = 0;
00067         height = 0;
00068         strcpy(vcodec, QUICKTIME_YUV2);
00069         strcpy(acodec, QUICKTIME_TWOS);
00070         jpeg_quality = 100;
00071         aspect_ratio = -1;
00072         interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
00073         interlace_mode = BC_ILACE_MODE_UNDETECTED;
00074         interlace_fixmethod = BC_ILACE_FIXMETHOD_NONE;
00075 
00076         ampeg_bitrate = 256;
00077         ampeg_derivative = 3;
00078 
00079         vorbis_vbr = 0;
00080         vorbis_min_bitrate = -1;
00081         vorbis_bitrate = 128000;
00082         vorbis_max_bitrate = -1;
00083 
00084         theora_fix_bitrate = 1;
00085         theora_bitrate = 860000;
00086         theora_quality = 16;
00087         theora_sharpness = 2;
00088         theora_keyframe_frequency = 64;
00089         theora_keyframe_force_frequency = 64;
00090 
00091         mp3_bitrate = 256000;
00092 
00093 
00094         mp4a_bitrate = 256000;
00095         mp4a_quantqual = 100;
00096 
00097 
00098 
00099 // mpeg parameters
00100         vmpeg_iframe_distance = 45;
00101         vmpeg_pframe_distance = 0;
00102         vmpeg_progressive = 0;
00103         vmpeg_denoise = 1;
00104         vmpeg_bitrate = 1000000;
00105         vmpeg_derivative = 1;
00106         vmpeg_quantization = 15;
00107         vmpeg_cmodel = 0;
00108         vmpeg_fix_bitrate = 0;
00109         vmpeg_seq_codes = 0;
00110         vmpeg_preset = 0;
00111         vmpeg_field_order = 0;
00112 
00113 // Divx parameters.  Defaults from encore2
00114         divx_bitrate = 2000000;
00115         divx_rc_period = 50;
00116         divx_rc_reaction_ratio = 45;
00117         divx_rc_reaction_period = 10;
00118         divx_max_key_interval = 250;
00119         divx_max_quantizer = 31;
00120         divx_min_quantizer = 1;
00121         divx_quantizer = 5;
00122         divx_quality = 5;
00123         divx_fix_bitrate = 1;
00124         divx_use_deblocking = 1;
00125 
00126         h264_bitrate = 2000000;
00127         h264_quantizer = 5;
00128         h264_fix_bitrate = 0;
00129 
00130         ms_bitrate = 1000000;
00131         ms_bitrate_tolerance = 500000;
00132         ms_quantization = 10;
00133         ms_interlaced = 0;
00134         ms_gop_size = 45;
00135         ms_fix_bitrate = 1;
00136 
00137         ac3_bitrate = 128;
00138 
00139         png_use_alpha = 0;
00140         exr_use_alpha = 0;
00141         exr_compression = 0;
00142 
00143         tiff_cmodel = 0;
00144         tiff_compression = 0;
00145 
00146         use_header = 1;
00147 
00148 
00149         reset_index();
00150         id = EDL::next_id();
00151 
00152         pipe[0] = 0;
00153         use_pipe = 0;
00154 
00155         strcpy(prefix, "");
00156 
00157         reset_timecode();
00158 
00159         return 0;
00160 }
00161 
00162 int Asset::reset_index()
00163 {
00164         index_status = INDEX_NOTTESTED;
00165         index_start = old_index_end = index_end = 0;
00166         index_offsets = 0;
00167         index_sizes = 0;
00168         index_zoom = 0;
00169         index_bytes = 0;
00170         index_buffer = 0;
00171         return 0;
00172 }
00173 
00174 int Asset::reset_timecode()
00175 {
00176         strcpy(reel_name, "cin0000");
00177         reel_number = 0;
00178         tcstart = 0;
00179         tcend = 0;
00180         tcformat = 0;
00181         
00182         return 0;
00183 }
00184 
00185 void Asset::copy_from(Asset *asset, int do_index)
00186 {
00187         copy_location(asset);
00188         copy_format(asset, do_index);
00189 }
00190 
00191 void Asset::copy_location(Asset *asset)
00192 {
00193         strcpy(this->path, asset->path);
00194         strcpy(this->folder, asset->folder);
00195 }
00196 
00197 void Asset::copy_format(Asset *asset, int do_index)
00198 {
00199         if(do_index) update_index(asset);
00200 
00201         audio_data = asset->audio_data;
00202         format = asset->format;
00203         channels = asset->channels;
00204         sample_rate = asset->sample_rate;
00205         bits = asset->bits;
00206         byte_order = asset->byte_order;
00207         signed_ = asset->signed_;
00208         header = asset->header;
00209         dither = asset->dither;
00210         mp3_bitrate = asset->mp3_bitrate;
00211         mp4a_bitrate = asset->mp4a_bitrate;
00212         mp4a_quantqual = asset->mp4a_quantqual;
00213         use_header = asset->use_header;
00214         aspect_ratio = asset->aspect_ratio;
00215         interlace_autofixoption = asset->interlace_autofixoption;
00216         interlace_mode = asset->interlace_mode;
00217         interlace_fixmethod = asset->interlace_fixmethod;
00218 
00219         video_data = asset->video_data;
00220         layers = asset->layers;
00221         frame_rate = asset->frame_rate;
00222         width = asset->width;
00223         height = asset->height;
00224         strcpy(vcodec, asset->vcodec);
00225         strcpy(acodec, asset->acodec);
00226 
00227         this->audio_length = asset->audio_length;
00228         this->video_length = asset->video_length;
00229 
00230 
00231         ampeg_bitrate = asset->ampeg_bitrate;
00232         ampeg_derivative = asset->ampeg_derivative;
00233 
00234 
00235         vorbis_vbr = asset->vorbis_vbr;
00236         vorbis_min_bitrate = asset->vorbis_min_bitrate;
00237         vorbis_bitrate = asset->vorbis_bitrate;
00238         vorbis_max_bitrate = asset->vorbis_max_bitrate;
00239         
00240         theora_fix_bitrate = asset->theora_fix_bitrate;
00241         theora_bitrate = asset->theora_bitrate;
00242         theora_quality = asset->theora_quality;
00243         theora_sharpness = asset->theora_sharpness;
00244         theora_keyframe_frequency = asset->theora_keyframe_frequency;
00245         theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
00246 
00247         
00248         theora_fix_bitrate = asset->theora_fix_bitrate;
00249         theora_bitrate = asset->theora_bitrate;
00250         theora_quality = asset->theora_quality;
00251         theora_sharpness = asset->theora_sharpness;
00252         theora_keyframe_frequency = asset->theora_keyframe_frequency;
00253         theora_keyframe_force_frequency = asset->theora_keyframe_frequency;
00254 
00255 
00256         jpeg_quality = asset->jpeg_quality;
00257 
00258 // mpeg parameters
00259         vmpeg_iframe_distance = asset->vmpeg_iframe_distance;
00260         vmpeg_pframe_distance = asset->vmpeg_pframe_distance;
00261         vmpeg_progressive = asset->vmpeg_progressive;
00262         vmpeg_denoise = asset->vmpeg_denoise;
00263         vmpeg_bitrate = asset->vmpeg_bitrate;
00264         vmpeg_derivative = asset->vmpeg_derivative;
00265         vmpeg_quantization = asset->vmpeg_quantization;
00266         vmpeg_cmodel = asset->vmpeg_cmodel;
00267         vmpeg_fix_bitrate = asset->vmpeg_fix_bitrate;
00268         vmpeg_seq_codes = asset->vmpeg_seq_codes;
00269         vmpeg_preset = asset->vmpeg_preset;
00270         vmpeg_field_order = asset->vmpeg_field_order;
00271 
00272 
00273         divx_bitrate = asset->divx_bitrate;
00274         divx_rc_period = asset->divx_rc_period;
00275         divx_rc_reaction_ratio = asset->divx_rc_reaction_ratio;
00276         divx_rc_reaction_period = asset->divx_rc_reaction_period;
00277         divx_max_key_interval = asset->divx_max_key_interval;
00278         divx_max_quantizer = asset->divx_max_quantizer;
00279         divx_min_quantizer = asset->divx_min_quantizer;
00280         divx_quantizer = asset->divx_quantizer;
00281         divx_quality = asset->divx_quality;
00282         divx_fix_bitrate = asset->divx_fix_bitrate;
00283         divx_use_deblocking = asset->divx_use_deblocking;
00284 
00285         h264_bitrate = asset->h264_bitrate;
00286         h264_quantizer = asset->h264_quantizer;
00287         h264_fix_bitrate = asset->h264_fix_bitrate;
00288 
00289 
00290         ms_bitrate = asset->ms_bitrate;
00291         ms_bitrate_tolerance = asset->ms_bitrate_tolerance;
00292         ms_interlaced = asset->ms_interlaced;
00293         ms_quantization = asset->ms_quantization;
00294         ms_gop_size = asset->ms_gop_size;
00295         ms_fix_bitrate = asset->ms_fix_bitrate;
00296 
00297         
00298         ac3_bitrate = asset->ac3_bitrate;
00299         
00300         png_use_alpha = asset->png_use_alpha;
00301         exr_use_alpha = asset->exr_use_alpha;
00302         exr_compression = asset->exr_compression;
00303 
00304         tiff_cmodel = asset->tiff_cmodel;
00305         tiff_compression = asset->tiff_compression;
00306 
00307         strcpy(pipe, asset->pipe);
00308         use_pipe = asset->use_pipe;
00309 
00310         // FUTURE: should this be here or in copy_from()?
00311         strcpy(prefix, asset->prefix);
00312 
00313         strcpy(reel_name, asset->reel_name);
00314         reel_number = asset->reel_number;
00315         tcstart = asset->tcstart;
00316         tcend = asset->tcend;
00317         tcformat = asset->tcformat;
00318 }
00319 
00320 int64_t Asset::get_index_offset(int channel)
00321 {
00322         if(channel < channels && index_offsets)
00323                 return index_offsets[channel];
00324         else
00325                 return 0;
00326 }
00327 
00328 int64_t Asset::get_index_size(int channel)
00329 {
00330         if(channel < channels && index_sizes)
00331                 return index_sizes[channel];
00332         else
00333                 return 0;
00334 }
00335 
00336 
00337 char* Asset::get_compression_text(int audio, int video)
00338 {
00339         if(audio)
00340         {
00341                 switch(format)
00342                 {
00343                         case FILE_MOV:
00344                         case FILE_AVI:
00345                                 if(acodec[0])
00346                                         return quicktime_acodec_title(acodec);
00347                                 else
00348                                         return 0;
00349                                 break;
00350                 }
00351         }
00352         else
00353         if(video)
00354         {
00355                 switch(format)
00356                 {
00357                         case FILE_MOV:
00358                         case FILE_AVI:
00359                                 if(vcodec[0])
00360                                         return quicktime_vcodec_title(vcodec);
00361                                 else
00362                                         return 0;
00363                                 break;
00364                 }
00365         }
00366         return 0;
00367 }
00368 
00369 Asset& Asset::operator=(Asset &asset)
00370 {
00371         copy_location(&asset);
00372         copy_format(&asset);
00373         return *this;
00374 }
00375 
00376 
00377 int Asset::equivalent(Asset &asset, 
00378         int test_audio, 
00379         int test_video)
00380 {
00381         int result = (!strcmp(asset.path, path) &&
00382                 format == asset.format);
00383 
00384         if(test_audio && result)
00385         {
00386                 result = (channels == asset.channels && 
00387                         sample_rate == asset.sample_rate && 
00388                         bits == asset.bits && 
00389                         byte_order == asset.byte_order && 
00390                         signed_ == asset.signed_ && 
00391                         header == asset.header && 
00392                         dither == asset.dither &&
00393                         !strcmp(acodec, asset.acodec));
00394         }
00395 
00396 
00397         if(test_video && result)
00398         {
00399                 result = (layers == asset.layers && 
00400                         frame_rate == asset.frame_rate &&
00401                         asset.interlace_autofixoption == interlace_autofixoption &&
00402                         asset.interlace_mode    == interlace_mode &&
00403                         interlace_fixmethod     == asset.interlace_fixmethod &&
00404                         width == asset.width &&
00405                         height == asset.height &&
00406                         !strcmp(vcodec, asset.vcodec) &&
00407                         strcmp(reel_name, asset.reel_name) == 0 &&
00408                         reel_number == asset.reel_number &&
00409                         tcstart == asset.tcstart &&
00410                         tcend == asset.tcend &&
00411                         tcformat == asset.tcformat);
00412         }
00413 
00414         return result;
00415 }
00416 
00417 int Asset::operator==(Asset &asset)
00418 {
00419 
00420         return equivalent(asset, 
00421                 1, 
00422                 1);
00423 }
00424 
00425 int Asset::operator!=(Asset &asset)
00426 {
00427         return !(*this == asset);
00428 }
00429 
00430 int Asset::test_path(const char *path)
00431 {
00432         if(!strcasecmp(this->path, path)) 
00433                 return 1; 
00434         else 
00435                 return 0;
00436 }
00437 
00438 int Asset::test_plugin_title(const char *path)
00439 {
00440 }
00441 
00442 int Asset::read(FileXML *file, 
00443         int expand_relative)
00444 {
00445         int result = 0;
00446 
00447 // Check for relative path.
00448         if(expand_relative)
00449         {
00450                 char new_path[BCTEXTLEN];
00451                 char asset_directory[BCTEXTLEN];
00452                 char input_directory[BCTEXTLEN];
00453                 FileSystem fs;
00454 
00455                 strcpy(new_path, path);
00456                 fs.set_current_dir("");
00457 
00458                 fs.extract_dir(asset_directory, path);
00459 
00460 // No path in asset.
00461 // Take path of XML file.
00462                 if(!asset_directory[0])
00463                 {
00464                         fs.extract_dir(input_directory, file->filename);
00465 
00466 // Input file has a path
00467                         if(input_directory[0])
00468                         {
00469                                 fs.join_names(path, input_directory, new_path);
00470                         }
00471                 }
00472         }
00473 
00474 
00475         while(!result)
00476         {
00477                 result = file->read_tag();
00478                 if(!result)
00479                 {
00480                         if(file->tag.title_is("/ASSET"))
00481                         {
00482                                 result = 1;
00483                         }
00484                         else
00485                         if(file->tag.title_is("AUDIO"))
00486                         {
00487                                 read_audio(file);
00488                         }
00489                         else
00490                         if(file->tag.title_is("AUDIO_OMIT"))
00491                         {
00492                                 read_audio(file);
00493                         }
00494                         else
00495                         if(file->tag.title_is("FORMAT"))
00496                         {
00497                                 char *string = file->tag.get_property("TYPE");
00498                                 format = File::strtoformat(string);
00499                                 use_header = 
00500                                         file->tag.get_property("USE_HEADER", use_header);
00501                         }
00502                         else
00503                         if(file->tag.title_is("FOLDER"))
00504                         {
00505                                 strcpy(folder, file->read_text());
00506                         }
00507                         else
00508                         if(file->tag.title_is("VIDEO"))
00509                         {
00510                                 read_video(file);
00511                         }
00512                         else
00513                         if(file->tag.title_is("VIDEO_OMIT"))
00514                         {
00515                                 read_video(file);
00516                         }
00517                         else
00518                         if(file->tag.title_is("INDEX"))
00519                         {
00520                                 read_index(file);
00521                         }
00522                 }
00523         }
00524 
00525 //printf("Asset::read 2\n");
00526         return 0;
00527 }
00528 
00529 int Asset::read_audio(FileXML *file)
00530 {
00531         if(file->tag.title_is("AUDIO")) audio_data = 1;
00532         channels = file->tag.get_property("CHANNELS", 2);
00533 // This is loaded from the index file after the EDL but this 
00534 // should be overridable in the EDL.
00535         if(!sample_rate) sample_rate = file->tag.get_property("RATE", 44100);
00536         bits = file->tag.get_property("BITS", 16);
00537         byte_order = file->tag.get_property("BYTE_ORDER", 1);
00538         signed_ = file->tag.get_property("SIGNED", 1);
00539         header = file->tag.get_property("HEADER", 0);
00540         dither = file->tag.get_property("DITHER", 0);
00541 
00542         audio_length = file->tag.get_property("AUDIO_LENGTH", 0);
00543         acodec[0] = 0;
00544         file->tag.get_property("ACODEC", acodec);
00545         
00546 
00547 
00548 //      ampeg_bitrate = file->tag.get_property("AMPEG_BITRATE", ampeg_bitrate);
00549 //      ampeg_derivative = file->tag.get_property("AMPEG_DERIVATIVE", ampeg_derivative);
00550 // 
00551 //      vorbis_vbr = file->tag.get_property("VORBIS_VBR", vorbis_vbr);
00552 //      vorbis_min_bitrate = file->tag.get_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
00553 //      vorbis_bitrate = file->tag.get_property("VORBIS_BITRATE", vorbis_bitrate);
00554 //      vorbis_max_bitrate = file->tag.get_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
00555 // 
00556 //      mp3_bitrate = file->tag.get_property("MP3_BITRATE", mp3_bitrate);
00557 
00558         if(!video_data)
00559         {
00560                 tcstart = 0;
00561                 tcend = audio_length;
00562                 tcformat = 0;
00563         }
00564 
00565         return 0;
00566 }
00567 
00568 int Asset::read_video(FileXML *file)
00569 {
00570         if(file->tag.title_is("VIDEO")) video_data = 1;
00571         height = file->tag.get_property("HEIGHT", height);
00572         width = file->tag.get_property("WIDTH", width);
00573         layers = file->tag.get_property("LAYERS", layers);
00574 // This is loaded from the index file after the EDL but this 
00575 // should be overridable in the EDL.
00576         if(!frame_rate) frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
00577         vcodec[0] = 0;
00578         file->tag.get_property("VCODEC", vcodec);
00579 
00580         video_length = file->tag.get_property("VIDEO_LENGTH", 0);
00581 
00582 
00583         file->tag.get_property("REEL_NAME", reel_name);
00584         reel_number = file->tag.get_property("REEL_NUMBER", reel_number);
00585         tcstart = file->tag.get_property("TCSTART", tcstart);
00586         tcend = file->tag.get_property("TCEND", tcend);
00587         tcformat = file->tag.get_property("TCFORMAT", tcformat);
00588 
00589         return 0;
00590 }
00591 
00592 int Asset::read_index(FileXML *file)
00593 {
00594         delete [] index_offsets;
00595         index_offsets = new int64_t[channels];
00596         delete [] index_sizes;
00597         index_sizes = new int64_t[channels];
00598         for(int i = 0; i < channels; i++) 
00599         {
00600                 index_offsets[i] = 0;
00601                 index_sizes[i] = 0;
00602         }
00603 
00604         int current_offset = 0;
00605         int current_size = 0;
00606         int result = 0;
00607 
00608         index_zoom = file->tag.get_property("ZOOM", 1);
00609         index_bytes = file->tag.get_property("BYTES", (int64_t)0);
00610 
00611         while(!result)
00612         {
00613                 result = file->read_tag();
00614                 if(!result)
00615                 {
00616                         if(file->tag.title_is("/INDEX"))
00617                         {
00618                                 result = 1;
00619                         }
00620                         else
00621                         if(file->tag.title_is("OFFSET"))
00622                         {
00623                                 if(current_offset < channels)
00624                                 {
00625                                         index_offsets[current_offset++] = file->tag.get_property("FLOAT", 0);
00626 //printf("Asset::read_index %d %d\n", current_offset - 1, index_offsets[current_offset - 1]);
00627                                 }
00628                         }
00629                         else
00630                         if(file->tag.title_is("SIZE"))
00631                         {
00632                                 if(current_size < channels)
00633                                 {
00634                                         index_sizes[current_size++] = file->tag.get_property("FLOAT", 0);
00635                                 }
00636                         }
00637                 }
00638         }
00639         return 0;
00640 }
00641 
00642 int Asset::write_index(char *path, int data_bytes)
00643 {
00644         FILE *file;
00645         if(!(file = fopen(path, "wb")))
00646         {
00647 // failed to create it
00648                 printf(_("Asset::write_index Couldn't write index file %s to disk.\n"), path);
00649         }
00650         else
00651         {
00652                 FileXML xml;
00653 // Pad index start position
00654                 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
00655 
00656                 index_status = INDEX_READY;
00657 // Write encoding information
00658                 write(&xml, 
00659                         1, 
00660                         "");
00661                 xml.write_to_file(file);
00662                 index_start = ftell(file);
00663                 fseek(file, 0, SEEK_SET);
00664 // Write index start
00665                 fwrite((char*)&(index_start), sizeof(int64_t), 1, file);
00666                 fseek(file, index_start, SEEK_SET);
00667 
00668 // Write index data
00669                 fwrite(index_buffer, 
00670                         data_bytes, 
00671                         1, 
00672                         file);
00673                 fclose(file);
00674         }
00675 
00676 // Force reread of header
00677         index_status = INDEX_NOTTESTED;
00678 //      index_status = INDEX_READY;
00679         index_end = audio_length;
00680         old_index_end = 0;
00681         index_start = 0;
00682 }
00683 
00684 // Output path is the path of the output file if name truncation is desired.
00685 // It is a "" if complete names should be used.
00686 
00687 int Asset::write(FileXML *file, 
00688         int include_index, 
00689         char *output_path)
00690 {
00691         char new_path[BCTEXTLEN];
00692         char asset_directory[BCTEXTLEN];
00693         char output_directory[BCTEXTLEN];
00694         FileSystem fs;
00695 
00696 // Make path relative
00697         fs.extract_dir(asset_directory, path);
00698         if(output_path && output_path[0]) 
00699                 fs.extract_dir(output_directory, output_path);
00700         else
00701                 output_directory[0] = 0;
00702 
00703 // Asset and EDL are in same directory.  Extract just the name.
00704         if(!strcmp(asset_directory, output_directory))
00705         {
00706                 fs.extract_name(new_path, path);
00707         }
00708         else
00709         {
00710                 strcpy(new_path, path);
00711         }
00712 
00713         file->tag.set_title("ASSET");
00714         file->tag.set_property("SRC", new_path);
00715         file->append_tag();
00716         file->append_newline();
00717 
00718         file->tag.set_title("FOLDER");
00719         file->append_tag();
00720         file->append_text(folder);
00721         file->tag.set_title("/FOLDER");
00722         file->append_tag();
00723         file->append_newline();
00724 
00725 // Write the format information
00726         file->tag.set_title("FORMAT");
00727 
00728         file->tag.set_property("TYPE", 
00729                 File::formattostr(format));
00730         file->tag.set_property("USE_HEADER", use_header);
00731 
00732         file->append_tag();
00733         file->tag.set_title("/FORMAT");
00734         file->append_tag();
00735         file->append_newline();
00736 
00737 // Requiring data to exist caused batch render to lose settings.
00738 // But the only way to know if an asset doesn't have audio or video data 
00739 // is to not write the block.
00740 // So change the block name if the asset doesn't have the data.
00741         /* if(audio_data) */ write_audio(file);
00742         /* if(video_data) */ write_video(file);
00743         if(index_status == 0 && include_index) write_index(file);  // index goes after source
00744 
00745         file->tag.set_title("/ASSET");
00746         file->append_tag();
00747         file->append_newline();
00748         return 0;
00749 }
00750 
00751 int Asset::write_audio(FileXML *file)
00752 {
00753 // Let the reader know if the asset has the data by naming the block.
00754         if(audio_data)
00755                 file->tag.set_title("AUDIO");
00756         else
00757                 file->tag.set_title("AUDIO_OMIT");
00758 // Necessary for PCM audio
00759         file->tag.set_property("CHANNELS", channels);
00760         file->tag.set_property("RATE", sample_rate);
00761         file->tag.set_property("BITS", bits);
00762         file->tag.set_property("BYTE_ORDER", byte_order);
00763         file->tag.set_property("SIGNED", signed_);
00764         file->tag.set_property("HEADER", header);
00765         file->tag.set_property("DITHER", dither);
00766         if(acodec[0])
00767                 file->tag.set_property("ACODEC", acodec);
00768         
00769         file->tag.set_property("AUDIO_LENGTH", audio_length);
00770 
00771 
00772 
00773 // Rely on defaults operations for these.
00774 
00775 //      file->tag.set_property("AMPEG_BITRATE", ampeg_bitrate);
00776 //      file->tag.set_property("AMPEG_DERIVATIVE", ampeg_derivative);
00777 // 
00778 //      file->tag.set_property("VORBIS_VBR", vorbis_vbr);
00779 //      file->tag.set_property("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
00780 //      file->tag.set_property("VORBIS_BITRATE", vorbis_bitrate);
00781 //      file->tag.set_property("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
00782 // 
00783 //      file->tag.set_property("MP3_BITRATE", mp3_bitrate);
00784 // 
00785 
00786 
00787 
00788         file->append_tag();
00789         if(audio_data)
00790           file->tag.set_title("/AUDIO");
00791         else
00792           file->tag.set_title("/AUDIO_OMIT");
00793         file->append_tag();
00794         file->append_newline();
00795         return 0;
00796 }
00797 
00798 int Asset::write_video(FileXML *file)
00799 {
00800         if(video_data)
00801                 file->tag.set_title("VIDEO");
00802         else
00803                 file->tag.set_title("VIDEO_OMIT");
00804         file->tag.set_property("HEIGHT", height);
00805         file->tag.set_property("WIDTH", width);
00806         file->tag.set_property("LAYERS", layers);
00807         file->tag.set_property("FRAMERATE", frame_rate);
00808         if(vcodec[0])
00809                 file->tag.set_property("VCODEC", vcodec);
00810 
00811         file->tag.set_property("VIDEO_LENGTH", video_length);
00812 
00813 
00814 
00815         file->tag.set_property("REEL_NAME", reel_name);
00816         file->tag.set_property("REEL_NUMBER", reel_number);
00817         file->tag.set_property("TCSTART", tcstart);
00818         file->tag.set_property("TCEND", tcend);
00819         file->tag.set_property("TCFORMAT", tcformat);
00820 
00821         file->append_tag();
00822         if(video_data)
00823                 file->tag.set_title("/VIDEO");
00824         else
00825                 file->tag.set_title("/VIDEO_OMIT");
00826 
00827         file->append_tag();
00828         file->append_newline();
00829         return 0;
00830 }
00831 
00832 int Asset::write_index(FileXML *file)
00833 {
00834         file->tag.set_title("INDEX");
00835         file->tag.set_property("ZOOM", index_zoom);
00836         file->tag.set_property("BYTES", index_bytes);
00837         file->append_tag();
00838         file->append_newline();
00839 
00840         if(index_offsets)
00841         {
00842                 for(int i = 0; i < channels; i++)
00843                 {
00844                         file->tag.set_title("OFFSET");
00845                         file->tag.set_property("FLOAT", index_offsets[i]);
00846                         file->append_tag();
00847                         file->tag.set_title("/OFFSET");
00848                         file->append_tag();
00849                         file->tag.set_title("SIZE");
00850                         file->tag.set_property("FLOAT", index_sizes[i]);
00851                         file->append_tag();
00852                         file->tag.set_title("/SIZE");
00853                         file->append_tag();
00854                 }
00855         }
00856 
00857         file->append_newline();
00858         file->tag.set_title("/INDEX");
00859         file->append_tag();
00860         file->append_newline();
00861         return 0;
00862 }
00863 
00864 
00865 
00866 
00867 char* Asset::construct_param(char *param, char *prefix, char *return_value)
00868 {
00869         if(prefix)
00870                 sprintf(return_value, "%s%s", prefix, param);
00871         else
00872                 strcpy(return_value, param);
00873         return return_value;
00874 }
00875 
00876 #define UPDATE_DEFAULT(x, y) defaults->update(construct_param(x, prefix, string), y);
00877 #define GET_DEFAULT(x, y) defaults->get(construct_param(x, prefix, string), y);
00878 
00879 void Asset::load_defaults(Defaults *defaults, 
00880         char *prefix, 
00881         int do_format,
00882         int do_compression,
00883         int do_path,
00884         int do_data_types,
00885         int do_bits)
00886 {
00887         char string[BCTEXTLEN];
00888 
00889 // Can't save codec here because it's specific to render, record, and effect.
00890 // The codec has to be UNKNOWN for file probing to work.
00891 
00892         if(do_path)
00893         {
00894                 GET_DEFAULT("PATH", path);
00895         }
00896 
00897         if(do_compression)
00898         {
00899                 GET_DEFAULT("AUDIO_CODEC", acodec);
00900                 GET_DEFAULT("VIDEO_CODEC", vcodec);
00901         }
00902 
00903         if(do_format)
00904         {
00905                 format = GET_DEFAULT("FORMAT", format);
00906         }
00907 
00908         if(do_data_types)
00909         {
00910                 audio_data = GET_DEFAULT("AUDIO", 1);
00911                 video_data = GET_DEFAULT("VIDEO", 1);
00912         }
00913 
00914         if(do_bits)
00915         {
00916                 bits = GET_DEFAULT("BITS", 16);
00917                 dither = GET_DEFAULT("DITHER", 0);
00918                 signed_ = GET_DEFAULT("SIGNED", 1);
00919                 byte_order = GET_DEFAULT("BYTE_ORDER", 1);
00920         }
00921 
00922         // NOTE: this should never be saved
00923         strcpy(this->prefix, prefix ? prefix : "");
00924 
00925         ampeg_bitrate = GET_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
00926         ampeg_derivative = GET_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
00927 
00928         vorbis_vbr = GET_DEFAULT("VORBIS_VBR", vorbis_vbr);
00929         vorbis_min_bitrate = GET_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
00930         vorbis_bitrate = GET_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
00931         vorbis_max_bitrate = GET_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
00932 
00933         theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
00934         theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
00935         theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
00936         theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
00937         theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
00938         theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
00939 
00940 
00941 
00942         mp3_bitrate = GET_DEFAULT("MP3_BITRATE", mp3_bitrate);
00943         mp4a_bitrate = GET_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
00944         mp4a_quantqual = GET_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
00945 
00946         jpeg_quality = GET_DEFAULT("JPEG_QUALITY", jpeg_quality);
00947         aspect_ratio = GET_DEFAULT("ASPECT_RATIO", aspect_ratio);
00948 
00949         interlace_autofixoption = BC_ILACE_AUTOFIXOPTION_AUTO;
00950         interlace_mode          = BC_ILACE_MODE_UNDETECTED;
00951         interlace_fixmethod     = BC_ILACE_FIXMETHOD_UPONE;
00952 
00953 // MPEG format information
00954         vmpeg_iframe_distance = GET_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
00955         vmpeg_pframe_distance = GET_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
00956         vmpeg_progressive = GET_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
00957         vmpeg_denoise = GET_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
00958         vmpeg_bitrate = GET_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
00959         vmpeg_derivative = GET_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
00960         vmpeg_quantization = GET_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
00961         vmpeg_cmodel = GET_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
00962         vmpeg_fix_bitrate = GET_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
00963         vmpeg_seq_codes = GET_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
00964         vmpeg_preset = GET_DEFAULT("VMPEG_PRESET", vmpeg_preset);
00965         vmpeg_field_order = GET_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
00966 
00967         h264_bitrate = GET_DEFAULT("H264_BITRATE", h264_bitrate);
00968         h264_quantizer = GET_DEFAULT("H264_QUANTIZER", h264_quantizer);
00969         h264_fix_bitrate = GET_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
00970 
00971 
00972         divx_bitrate = GET_DEFAULT("DIVX_BITRATE", divx_bitrate);
00973         divx_rc_period = GET_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
00974         divx_rc_reaction_ratio = GET_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
00975         divx_rc_reaction_period = GET_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
00976         divx_max_key_interval = GET_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
00977         divx_max_quantizer = GET_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
00978         divx_min_quantizer = GET_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
00979         divx_quantizer = GET_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
00980         divx_quality = GET_DEFAULT("DIVX_QUALITY", divx_quality);
00981         divx_fix_bitrate = GET_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
00982         divx_use_deblocking = GET_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
00983 
00984         theora_fix_bitrate = GET_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
00985         theora_bitrate = GET_DEFAULT("THEORA_BITRATE", theora_bitrate);
00986         theora_quality = GET_DEFAULT("THEORA_QUALITY", theora_quality);
00987         theora_sharpness = GET_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
00988         theora_keyframe_frequency = GET_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
00989         theora_keyframe_force_frequency = GET_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
00990 
00991 
00992         ms_bitrate = GET_DEFAULT("MS_BITRATE", ms_bitrate);
00993         ms_bitrate_tolerance = GET_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
00994         ms_interlaced = GET_DEFAULT("MS_INTERLACED", ms_interlaced);
00995         ms_quantization = GET_DEFAULT("MS_QUANTIZATION", ms_quantization);
00996         ms_gop_size = GET_DEFAULT("MS_GOP_SIZE", ms_gop_size);
00997         ms_fix_bitrate = GET_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
00998 
00999         ac3_bitrate = GET_DEFAULT("AC3_BITRATE", ac3_bitrate);
01000 
01001         png_use_alpha = GET_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
01002         exr_use_alpha = GET_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
01003         exr_compression = GET_DEFAULT("EXR_COMPRESSION", exr_compression);
01004         tiff_cmodel = GET_DEFAULT("TIFF_CMODEL", tiff_cmodel);
01005         tiff_compression = GET_DEFAULT("TIFF_COMPRESSION", tiff_compression);
01006 
01007         GET_DEFAULT("REEL_NAME", reel_name);
01008         reel_number = GET_DEFAULT("REEL_NUMBER", reel_number);
01009         tcstart = GET_DEFAULT("TCSTART", tcstart);
01010         tcend = GET_DEFAULT("TCEND", tcend);
01011         tcformat = GET_DEFAULT("TCFORMAT", tcformat);
01012 
01013         load_format_defaults(defaults);
01014 }
01015 
01016 // FUTURE: put more of the format specific variables in here
01017 void Asset::load_format_defaults(Defaults *defaults) {
01018         char temp[BCTEXTLEN];
01019         char string[BCTEXTLEN];
01020         if (! format) return;
01021 
01022         // NOTE: old value is used if no init value set before GET_DEFAULT 
01023 
01024         // override the defaults with those for this format
01025         sprintf(temp, "FORMAT_%s_USE_PIPE", FILE_FORMAT_PREFIX(format));
01026         use_pipe = 0;  
01027         use_pipe = GET_DEFAULT(temp, use_pipe);
01028 
01029         sprintf(temp, "FORMAT_%s_PIPE", FILE_FORMAT_PREFIX(format));
01030         sprintf(pipe, "");
01031         GET_DEFAULT(temp, pipe);
01032 
01033         sprintf(temp, "FORMAT_%s_PATH", FILE_FORMAT_PREFIX(format));
01034         sprintf(path, "");
01035         GET_DEFAULT(temp, path);
01036 }
01037         
01038 
01039 void Asset::save_defaults(Defaults *defaults, 
01040         char *prefix,
01041         int do_format,
01042         int do_compression,
01043         int do_path,
01044         int do_data_types,
01045         int do_bits)
01046 {
01047         char string[BCTEXTLEN];
01048 
01049         UPDATE_DEFAULT("PATH", path);
01050 
01051         if(do_format)
01052         {
01053                 UPDATE_DEFAULT("FORMAT", format);
01054         }
01055 
01056         if(do_data_types)
01057         {
01058                 UPDATE_DEFAULT("AUDIO", audio_data);
01059                 UPDATE_DEFAULT("VIDEO", video_data);
01060         }
01061 
01062         if(do_compression)
01063         {
01064                 UPDATE_DEFAULT("AUDIO_CODEC", acodec);
01065                 UPDATE_DEFAULT("VIDEO_CODEC", vcodec);
01066         }
01067 
01068         if(do_bits)
01069         {
01070                 UPDATE_DEFAULT("BITS", bits);
01071                 UPDATE_DEFAULT("DITHER", dither);
01072                 UPDATE_DEFAULT("SIGNED", signed_);
01073                 UPDATE_DEFAULT("BYTE_ORDER", byte_order);
01074         }
01075 
01076         UPDATE_DEFAULT("AMPEG_BITRATE", ampeg_bitrate);
01077         UPDATE_DEFAULT("AMPEG_DERIVATIVE", ampeg_derivative);
01078 
01079         UPDATE_DEFAULT("VORBIS_VBR", vorbis_vbr);
01080         UPDATE_DEFAULT("VORBIS_MIN_BITRATE", vorbis_min_bitrate);
01081         UPDATE_DEFAULT("VORBIS_BITRATE", vorbis_bitrate);
01082         UPDATE_DEFAULT("VORBIS_MAX_BITRATE", vorbis_max_bitrate);
01083 
01084 
01085         UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
01086         UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
01087         UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
01088         UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
01089         UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
01090         UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
01091 
01092 
01093 
01094         UPDATE_DEFAULT("MP3_BITRATE", mp3_bitrate);
01095         UPDATE_DEFAULT("MP4A_BITRATE", mp4a_bitrate);
01096         UPDATE_DEFAULT("MP4A_QUANTQUAL", mp4a_quantqual);
01097 
01098 
01099 
01100 
01101 
01102         UPDATE_DEFAULT("JPEG_QUALITY", jpeg_quality);
01103         UPDATE_DEFAULT("ASPECT_RATIO", aspect_ratio);
01104         UPDATE_DEFAULT("INTERLACE_AUTOFIXOPTION", interlace_autofixoption);
01105         UPDATE_DEFAULT("INTERLACE_MODE", interlace_mode);
01106         UPDATE_DEFAULT("INTERLACE_FIXMETHOD", interlace_fixmethod);
01107 
01108 
01109 // MPEG format information
01110         UPDATE_DEFAULT("VMPEG_IFRAME_DISTANCE", vmpeg_iframe_distance);
01111         UPDATE_DEFAULT("VMPEG_PFRAME_DISTANCE", vmpeg_pframe_distance);
01112         UPDATE_DEFAULT("VMPEG_PROGRESSIVE", vmpeg_progressive);
01113         UPDATE_DEFAULT("VMPEG_DENOISE", vmpeg_denoise);
01114         UPDATE_DEFAULT("VMPEG_BITRATE", vmpeg_bitrate);
01115         UPDATE_DEFAULT("VMPEG_DERIVATIVE", vmpeg_derivative);
01116         UPDATE_DEFAULT("VMPEG_QUANTIZATION", vmpeg_quantization);
01117         UPDATE_DEFAULT("VMPEG_CMODEL", vmpeg_cmodel);
01118         UPDATE_DEFAULT("VMPEG_FIX_BITRATE", vmpeg_fix_bitrate);
01119         UPDATE_DEFAULT("VMPEG_SEQ_CODES", vmpeg_seq_codes);
01120         UPDATE_DEFAULT("VMPEG_PRESET", vmpeg_preset);
01121         UPDATE_DEFAULT("VMPEG_FIELD_ORDER", vmpeg_field_order);
01122 
01123         UPDATE_DEFAULT("H264_BITRATE", h264_bitrate);
01124         UPDATE_DEFAULT("H264_QUANTIZER", h264_quantizer);
01125         UPDATE_DEFAULT("H264_FIX_BITRATE", h264_fix_bitrate);
01126 
01127         UPDATE_DEFAULT("DIVX_BITRATE", divx_bitrate);
01128         UPDATE_DEFAULT("DIVX_RC_PERIOD", divx_rc_period);
01129         UPDATE_DEFAULT("DIVX_RC_REACTION_RATIO", divx_rc_reaction_ratio);
01130         UPDATE_DEFAULT("DIVX_RC_REACTION_PERIOD", divx_rc_reaction_period);
01131         UPDATE_DEFAULT("DIVX_MAX_KEY_INTERVAL", divx_max_key_interval);
01132         UPDATE_DEFAULT("DIVX_MAX_QUANTIZER", divx_max_quantizer);
01133         UPDATE_DEFAULT("DIVX_MIN_QUANTIZER", divx_min_quantizer);
01134         UPDATE_DEFAULT("DIVX_QUANTIZER", divx_quantizer);
01135         UPDATE_DEFAULT("DIVX_QUALITY", divx_quality);
01136         UPDATE_DEFAULT("DIVX_FIX_BITRATE", divx_fix_bitrate);
01137         UPDATE_DEFAULT("DIVX_USE_DEBLOCKING", divx_use_deblocking);
01138 
01139         UPDATE_DEFAULT("THEORA_FIX_BITRATE", theora_fix_bitrate);
01140         UPDATE_DEFAULT("THEORA_BITRATE", theora_bitrate);
01141         UPDATE_DEFAULT("THEORA_QUALITY", theora_quality);
01142         UPDATE_DEFAULT("THEORA_SHARPNESS", theora_sharpness);
01143         UPDATE_DEFAULT("THEORA_KEYFRAME_FREQUENCY", theora_keyframe_frequency);
01144         UPDATE_DEFAULT("THEORA_FORCE_KEYFRAME_FEQUENCY", theora_keyframe_force_frequency);
01145 
01146 
01147         UPDATE_DEFAULT("MS_BITRATE", ms_bitrate);
01148         UPDATE_DEFAULT("MS_BITRATE_TOLERANCE", ms_bitrate_tolerance);
01149         UPDATE_DEFAULT("MS_INTERLACED", ms_interlaced);
01150         UPDATE_DEFAULT("MS_QUANTIZATION", ms_quantization);
01151         UPDATE_DEFAULT("MS_GOP_SIZE", ms_gop_size);
01152         UPDATE_DEFAULT("MS_FIX_BITRATE", ms_fix_bitrate);
01153 
01154         UPDATE_DEFAULT("AC3_BITRATE", ac3_bitrate);
01155 
01156 
01157         UPDATE_DEFAULT("PNG_USE_ALPHA", png_use_alpha);
01158         UPDATE_DEFAULT("EXR_USE_ALPHA", exr_use_alpha);
01159         UPDATE_DEFAULT("EXR_COMPRESSION", exr_compression);
01160         UPDATE_DEFAULT("TIFF_CMODEL", tiff_cmodel);
01161         UPDATE_DEFAULT("TIFF_COMPRESSION", tiff_compression);
01162 
01163         UPDATE_DEFAULT("REEL_NAME", reel_name);
01164         UPDATE_DEFAULT("REEL_NUMBER", reel_number);
01165         UPDATE_DEFAULT("TCSTART", tcstart);
01166         UPDATE_DEFAULT("TCEND", tcend);
01167         UPDATE_DEFAULT("TCFORMAT", tcformat);
01168 
01169         save_format_defaults(defaults);
01170 }
01171 
01172 
01173 // FUTURE: put more of the format specific variables in here
01174 void Asset::save_format_defaults(Defaults *defaults) {
01175         char temp[BCTEXTLEN];
01176         char string[BCTEXTLEN];
01177         if (! format) return;
01178 
01179         sprintf(temp, "FORMAT_%s_USE_PIPE", FILE_FORMAT_PREFIX(format));
01180         UPDATE_DEFAULT(temp, use_pipe);
01181 
01182         sprintf(temp, "FORMAT_%s_PIPE", FILE_FORMAT_PREFIX(format));
01183         UPDATE_DEFAULT(temp, pipe);
01184 
01185         sprintf(temp, "FORMAT_%s_PATH", FILE_FORMAT_PREFIX(format));
01186         UPDATE_DEFAULT(temp, path);
01187 }
01188 
01189 
01190 int Asset::update_path(char *new_path)
01191 {
01192         strcpy(path, new_path);
01193         return 0;
01194 }
01195 
01196 void Asset::update_index(Asset *asset)
01197 {
01198 //printf("Asset::update_index 1 %d\n", index_status);
01199         index_status = asset->index_status;
01200         index_zoom = asset->index_zoom;          // zoom factor of index data
01201         index_start = asset->index_start;        // byte start of index data in the index file
01202         index_bytes = asset->index_bytes;        // Total bytes in source file for comparison before rebuilding the index
01203         index_end = asset->index_end;
01204         old_index_end = asset->old_index_end;    // values for index build
01205 
01206         delete [] index_offsets;
01207         delete [] index_sizes;
01208         index_offsets = 0;
01209         index_sizes = 0;
01210         
01211         if(asset->index_offsets)
01212         {
01213                 index_offsets = new int64_t[asset->channels];
01214                 index_sizes = new int64_t[asset->channels];
01215 
01216                 int i;
01217                 for(i = 0; i < asset->channels; i++)
01218                 {
01219 // offsets of channels in index file in floats
01220                         index_offsets[i] = asset->index_offsets[i];  
01221                         index_sizes[i] = asset->index_sizes[i];
01222                 }
01223         }
01224         index_buffer = asset->index_buffer;    // pointer
01225 }
01226 
01227 int Asset::set_timecode(char *tc, int format, int end)
01228 {
01229         int hr, min, sec;
01230 
01231         hr = ((int) tc[0] - 48) * 10 + (int) tc[1] - 48;
01232         min = ((int) tc[3] - 48) * 10 + (int) tc[4] - 48;
01233         sec = ((int) tc[6] - 48) * 10 + (int) tc[7] - 48;
01234         
01235         // This needs to be modified to handle drop-frame
01236         
01237         if(end)
01238                 tcend = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
01239         else
01240                 tcstart = (int64_t) (((hr * 3600) + (min * 60) + sec) * frame_rate);
01241 
01242         tcformat = format;
01243         return 0;
01244 }
01245 
01246 int Asset::dump()
01247 {
01248         printf("  asset::dump\n");
01249         printf("   %p %s\n", this, path);
01250         printf("   index_status %d\n", index_status);
01251         printf("   format %d\n", format);
01252         printf("   audio_data %d channels %d samplerate %d bits %d byte_order %d signed %d header %d dither %d acodec %c%c%c%c\n",
01253                 audio_data, channels, sample_rate, bits, byte_order, signed_, header, dither, acodec[0], acodec[1], acodec[2], acodec[3]);
01254         printf("   audio_length %lld\n", audio_length);
01255         printf("   video_data %d layers %d framerate %f width %d height %d vcodec %c%c%c%c aspect_ratio %f\n",
01256                 video_data, layers, frame_rate, width, height, vcodec[0], vcodec[1], vcodec[2], vcodec[3], aspect_ratio);
01257         printf("   video_length %lld \n", video_length);
01258         printf("   reel_name %s reel_number %i tcstart %d tcend %d tcf %d\n",
01259                 reel_name, reel_number, tcstart, tcend, tcformat);
01260         
01261         return 0;
01262 }
01263 
01264 

Generated on Sun Jan 8 13:38:49 2006 for Cinelerra-svn by  doxygen 1.4.4