X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Flistimporter.cpp;h=ce038b97bf7b9cd0f61ad591cb54afc9eca543e4;hb=d85b18fe6e3691c9b537ac1222bdc2884667b40d;hp=30bb8992fdcbe36dedbba9159aee47c243ecfbf1;hpb=f2638e74c212a3d28a943350ed500440cb706074;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/listimporter.cpp b/synfig-core/trunk/src/synfig/listimporter.cpp index 30bb899..ce038b9 100644 --- a/synfig-core/trunk/src/synfig/listimporter.cpp +++ b/synfig-core/trunk/src/synfig/listimporter.cpp @@ -64,6 +64,62 @@ ListImporter::ListImporter(const String &filename) } String line; String prefix=etl::dirname(filename)+ETL_DIRECTORY_SEPARATOR; + getline(stream,line); // read first line and check whether it is a Papagayo lip sync file + + if (line == "MohoSwitch1") // it is a Papagayo lipsync file + { + String phoneme, prevphoneme, prevext, ext(".jpg"); // default image format + int frame, prevframe = -1; // it means that the previous phoneme is not known + + while(!stream.eof()) + { + getline(stream,line); + + if(line.find(String("FPS ")) == 0) + { + float f = atof(String(line.begin()+4,line.end()).c_str()); + if (f) fps = f; + continue; + } + + if (line == "bmp" || + line == "gif" || + line == "jpg" || + line == "png" || + line == "ppm" || + line == "tiff" ) + { + ext = String(".") + line; + continue; + } + + size_t pos = line.find(String(" ")); // find space position. The format is "frame phoneme-name". + if(pos != String::npos) + { + frame = atoi(String(line.begin(),line.begin()+pos).c_str()); + phoneme = String(line.begin()+pos+1, line.end()); + + if (prevframe != -1) + while (prevframe < frame) + { + filename_list.push_back(prefix + prevphoneme + prevext); + synfig::info("frame %d, phoneme = %s, path = '%s'", prevframe, prevphoneme.c_str(), (prefix + prevphoneme + prevext).c_str()); + prevframe++; + } + + prevext = ext; + prevframe = frame; + prevphoneme = phoneme; + } + } + + filename_list.push_back(prefix + prevphoneme + prevext); // do it one more time for the last phoneme + synfig::info("finally, frame %d, phoneme = %s, path = '%s'", prevframe, prevphoneme.c_str(), (prefix + prevphoneme + prevext).c_str()); + + return; + } + + stream.seekg(ios_base::beg); while(!stream.eof()) { getline(stream,line); @@ -95,9 +151,7 @@ ListImporter::~ListImporter() bool ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) { -// DEBUGPOINT(); - int frame=static_cast(time*fps); -// DEBUGPOINT(); + int frame=round_to_int(time*fps); if(!filename_list.size()) { @@ -106,18 +160,15 @@ ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) return false; } -// DEBUGPOINT(); if(frame<0)frame=0; if(frame>=(signed)filename_list.size())frame=filename_list.size()-1; -// DEBUGPOINT(); // See if that frame is cached std::list >::iterator iter; for(iter=frame_cache.begin();iter!=frame_cache.end();++iter) { if(iter->first==filename_list[frame]) { -// DEBUGPOINT(); surface.mirror(iter->second); return static_cast(surface); } @@ -125,8 +176,6 @@ ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) Importer::Handle importer(Importer::open(filename_list[frame])); -// DEBUGPOINT(); - if(!importer) { if(cb)cb->error(_("Unable to open ")+filename_list[frame]); @@ -134,8 +183,6 @@ ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) return false; } -// DEBUGPOINT(); - if(!importer->get_frame(surface,0,cb)) { if(cb)cb->error(_("Unable to get frame from ")+filename_list[frame]); @@ -143,21 +190,13 @@ ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) return false; } -// DEBUGPOINT(); - if(frame_cache.size()>=LIST_IMPORTER_CACHE_SIZE) frame_cache.pop_front(); -// DEBUGPOINT(); - frame_cache.push_back(std::pair(filename_list[frame],surface)); -// DEBUGPOINT(); - surface.mirror(frame_cache.back().second); -// DEBUGPOINT(); - return static_cast(surface); }