From: Carlos Lopez Date: Wed, 25 Aug 2010 14:24:02 +0000 (+0200) Subject: Apply patch #2958077. Fix incorrect FPS interpolation in ListImporter. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8cc7bc2ddda075644830b1bd8b871bee25c80f31;p=synfig.git Apply patch #2958077. Fix incorrect FPS interpolation in ListImporter. Thanks to Ray Frederikson --- diff --git a/synfig-core/src/modules/lyr_std/import.cpp b/synfig-core/src/modules/lyr_std/import.cpp index f7385a9..567f756 100644 --- a/synfig-core/src/modules/lyr_std/import.cpp +++ b/synfig-core/src/modules/lyr_std/import.cpp @@ -162,7 +162,7 @@ Import::set_param(const String & param, const ValueBase &value) } surface.clear(); - if(!newimporter->get_frame(surface,Time(0),trimmed,width,height,top,left)) + if(!newimporter->get_frame(surface,get_canvas()->rend_desc(),Time(0),trimmed,width,height,top,left)) { synfig::warning(strprintf("Unable to get frame from \"%s\"",filename_with_path.c_str())); } @@ -222,7 +222,7 @@ Import::set_time(Context context, Time time)const { if(get_amount() && importer && importer->is_animated()) - importer->get_frame(surface,time+time_offset,trimmed,width,height,top,left); + importer->get_frame(surface,get_canvas()->rend_desc(),time+time_offset,trimmed,width,height,top,left); context.set_time(time); } @@ -232,7 +232,7 @@ Import::set_time(Context context, Time time, const Point &pos)const { if(get_amount() && importer && importer->is_animated()) - importer->get_frame(surface,time+time_offset,trimmed,width,height,top,left); + importer->get_frame(surface,get_canvas()->rend_desc(),time+time_offset,trimmed,width,height,top,left); context.set_time(time,pos); } diff --git a/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp b/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp index d8c07b7..26b950c 100644 --- a/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp +++ b/synfig-core/src/modules/mod_bmp/mptr_bmp.cpp @@ -123,7 +123,7 @@ bmp_mptr::~bmp_mptr() } bool -bmp_mptr::get_frame(synfig::Surface &surface,Time /*time*/, synfig::ProgressCallback *cb) +bmp_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time /*time*/, synfig::ProgressCallback *cb) { FILE *file=fopen(filename.c_str(),"rb"); if(!file) diff --git a/synfig-core/src/modules/mod_bmp/mptr_bmp.h b/synfig-core/src/modules/mod_bmp/mptr_bmp.h index e7257bb..3833ef0 100644 --- a/synfig-core/src/modules/mod_bmp/mptr_bmp.h +++ b/synfig-core/src/modules/mod_bmp/mptr_bmp.h @@ -51,7 +51,7 @@ public: bmp_mptr(const char *filename); ~bmp_mptr(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.cpp b/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.cpp index f837c7b..1d7b3bb 100644 --- a/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.cpp +++ b/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.cpp @@ -258,7 +258,7 @@ ffmpeg_mptr::~ffmpeg_mptr() } bool -ffmpeg_mptr::get_frame(synfig::Surface &surface,Time time, synfig::ProgressCallback *) +ffmpeg_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time time, synfig::ProgressCallback *) { int i=(int)(time*fps); if(i!=cur_frame) diff --git a/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.h b/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.h index 3e53931..ccf09e8 100644 --- a/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.h +++ b/synfig-core/src/modules/mod_ffmpeg/mptr_ffmpeg.h @@ -69,7 +69,7 @@ public: virtual bool is_animated(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.cpp b/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.cpp index 2860c1f..d1c6428 100644 --- a/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.cpp +++ b/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.cpp @@ -93,7 +93,7 @@ imagemagick_mptr::~imagemagick_mptr() } bool -imagemagick_mptr::get_frame(synfig::Surface &surface,Time /*time*/, synfig::ProgressCallback *cb) +imagemagick_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time /*time*/, synfig::ProgressCallback *cb) { //#define HAS_LIBPNG 1 @@ -159,7 +159,7 @@ imagemagick_mptr::get_frame(synfig::Surface &surface,Time /*time*/, synfig::Prog return false; } - if(!importer->get_frame(surface,0,cb)) + if(!importer->get_frame(surface,renddesc,0,cb)) { if(cb)cb->error(_("Unable to get frame from ")+temp_file); else synfig::error(_("Unable to get frame from ")+temp_file); diff --git a/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.h b/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.h index fcd8bdb..8eabdbe 100644 --- a/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.h +++ b/synfig-core/src/modules/mod_imagemagick/mptr_imagemagick.h @@ -54,7 +54,7 @@ public: ~imagemagick_mptr(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/mod_jpeg/mptr_jpeg.cpp b/synfig-core/src/modules/mod_jpeg/mptr_jpeg.cpp index 84f5403..a7dd47f 100644 --- a/synfig-core/src/modules/mod_jpeg/mptr_jpeg.cpp +++ b/synfig-core/src/modules/mod_jpeg/mptr_jpeg.cpp @@ -249,7 +249,7 @@ jpeg_mptr::~jpeg_mptr() } bool -jpeg_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback */*cb*/) +jpeg_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback */*cb*/) { surface=surface_buffer; return true; diff --git a/synfig-core/src/modules/mod_jpeg/mptr_jpeg.h b/synfig-core/src/modules/mod_jpeg/mptr_jpeg.h index 416d827..282353b 100644 --- a/synfig-core/src/modules/mod_jpeg/mptr_jpeg.h +++ b/synfig-core/src/modules/mod_jpeg/mptr_jpeg.h @@ -59,7 +59,7 @@ public: jpeg_mptr(const char *filename); ~jpeg_mptr(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/mod_libavcodec/mptr.cpp b/synfig-core/src/modules/mod_libavcodec/mptr.cpp index 4c9bfb8..6b59cda 100644 --- a/synfig-core/src/modules/mod_libavcodec/mptr.cpp +++ b/synfig-core/src/modules/mod_libavcodec/mptr.cpp @@ -64,7 +64,7 @@ Importer_LibAVCodec::~Importer_LibAVCodec() } bool -Importer_LibAVCodec::get_frame(synfig::Surface &/*surface*/,Time, synfig::ProgressCallback */*cb*/) +Importer_LibAVCodec::get_frame(synfig::Surface &/*surface*/, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback */*cb*/) { return false; } diff --git a/synfig-core/src/modules/mod_libavcodec/mptr.h b/synfig-core/src/modules/mod_libavcodec/mptr.h index f7cb41f..e2ffbc1 100644 --- a/synfig-core/src/modules/mod_libavcodec/mptr.h +++ b/synfig-core/src/modules/mod_libavcodec/mptr.h @@ -49,7 +49,7 @@ public: Importer_LibAVCodec(const char *filename); ~Importer_LibAVCodec(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/modules/mod_openexr/mptr_openexr.cpp b/synfig-core/src/modules/mod_openexr/mptr_openexr.cpp index d29719e..27a667c 100644 --- a/synfig-core/src/modules/mod_openexr/mptr_openexr.cpp +++ b/synfig-core/src/modules/mod_openexr/mptr_openexr.cpp @@ -72,7 +72,7 @@ exr_mptr::~exr_mptr() } bool -exr_mptr::get_frame(synfig::Surface &out_surface,Time, synfig::ProgressCallback *cb) +exr_mptr::get_frame(synfig::Surface &out_surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback *cb) { try { diff --git a/synfig-core/src/modules/mod_openexr/mptr_openexr.h b/synfig-core/src/modules/mod_openexr/mptr_openexr.h index 2ab295f..2b88847 100644 --- a/synfig-core/src/modules/mod_openexr/mptr_openexr.h +++ b/synfig-core/src/modules/mod_openexr/mptr_openexr.h @@ -51,7 +51,7 @@ public: - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; diff --git a/synfig-core/src/modules/mod_png/mptr_png.cpp b/synfig-core/src/modules/mod_png/mptr_png.cpp index 748801d..ec601b5 100644 --- a/synfig-core/src/modules/mod_png/mptr_png.cpp +++ b/synfig-core/src/modules/mod_png/mptr_png.cpp @@ -407,7 +407,7 @@ png_mptr::~png_mptr() } bool -png_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback */*cb*/) +png_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback */*cb*/) { //assert(0); // shouldn't be called? surface=surface_buffer; @@ -415,7 +415,7 @@ png_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback */*c } bool -png_mptr::get_frame(synfig::Surface &surface,Time, +png_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, bool &trimmed, unsigned int &width, unsigned int &height, unsigned int &top, unsigned int &left, synfig::ProgressCallback */*cb*/) { diff --git a/synfig-core/src/modules/mod_png/mptr_png.h b/synfig-core/src/modules/mod_png/mptr_png.h index b348964..689326f 100644 --- a/synfig-core/src/modules/mod_png/mptr_png.h +++ b/synfig-core/src/modules/mod_png/mptr_png.h @@ -62,8 +62,8 @@ public: png_mptr(const char *filename); ~png_mptr(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, bool &trimmed, unsigned int &width, unsigned int &height, unsigned int &top, unsigned int &left, synfig::ProgressCallback *callback); }; diff --git a/synfig-core/src/modules/mod_ppm/mptr_ppm.cpp b/synfig-core/src/modules/mod_ppm/mptr_ppm.cpp index 6900c93..9db3c0b 100644 --- a/synfig-core/src/modules/mod_ppm/mptr_ppm.cpp +++ b/synfig-core/src/modules/mod_ppm/mptr_ppm.cpp @@ -70,7 +70,7 @@ ppm_mptr::~ppm_mptr() } bool -ppm_mptr::get_frame(synfig::Surface &surface,Time, synfig::ProgressCallback *cb) +ppm_mptr::get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, Time, synfig::ProgressCallback *cb) { SmartFILE file(fopen(filename.c_str(),"rb")); if(!file) diff --git a/synfig-core/src/modules/mod_ppm/mptr_ppm.h b/synfig-core/src/modules/mod_ppm/mptr_ppm.h index 64095b5..0c6f119 100644 --- a/synfig-core/src/modules/mod_ppm/mptr_ppm.h +++ b/synfig-core/src/modules/mod_ppm/mptr_ppm.h @@ -47,7 +47,7 @@ public: ppm_mptr(const char *filename); ~ppm_mptr(); - virtual bool get_frame(synfig::Surface &surface,synfig::Time time, synfig::ProgressCallback *callback); + virtual bool get_frame(synfig::Surface &surface, const synfig::RendDesc &renddesc, synfig::Time time, synfig::ProgressCallback *callback); }; // END of class ppm_mptr /* === E N D =============================================================== */ diff --git a/synfig-core/src/synfig/importer.h b/synfig-core/src/synfig/importer.h index 6185ab5..7244f2c 100644 --- a/synfig-core/src/synfig/importer.h +++ b/synfig-core/src/synfig/importer.h @@ -33,6 +33,7 @@ #include "string.h" #include "time.h" #include "gamma.h" +#include "renddesc.h" /* === M A C R O S ========================================================= */ @@ -124,8 +125,8 @@ public: ** \return \c true on success, \c false on error ** \see ProgressCallback, Surface */ - virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL)=0; - virtual bool get_frame(Surface &surface,Time time, + virtual bool get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *callback=NULL)=0; + virtual bool get_frame(Surface &surface, const RendDesc &renddesc,Time time, bool &trimmed __attribute__ ((unused)), unsigned int &width __attribute__ ((unused)), unsigned int &height __attribute__ ((unused)), @@ -133,7 +134,7 @@ public: unsigned int &left __attribute__ ((unused)), ProgressCallback *callback=NULL) { - return get_frame(surface,time,callback); + return get_frame(surface,renddesc,time,callback); } //! Returns \c true if the importer pays attention to the \a time parameter of get_frame() diff --git a/synfig-core/src/synfig/listimporter.cpp b/synfig-core/src/synfig/listimporter.cpp index 02680f0..b5d5f44 100644 --- a/synfig-core/src/synfig/listimporter.cpp +++ b/synfig-core/src/synfig/listimporter.cpp @@ -150,9 +150,11 @@ ListImporter::~ListImporter() } bool -ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) +ListImporter::get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *cb) { - int frame=round_to_int(time*fps); + float document_fps=renddesc.get_frame_rate(); + int document_frame=round_to_int(time*document_fps); + int frame=floor_to_int(document_frame*fps/document_fps); if(!filename_list.size()) { @@ -184,7 +186,7 @@ ListImporter::get_frame(Surface &surface,Time time, ProgressCallback *cb) return false; } - if(!importer->get_frame(surface,0,cb)) + if(!importer->get_frame(surface,renddesc,0,cb)) { if(cb)cb->error(_("Unable to get frame from ")+filename_list[frame]); else synfig::error(_("Unable to get frame from ")+filename_list[frame]); diff --git a/synfig-core/src/synfig/listimporter.h b/synfig-core/src/synfig/listimporter.h index 090570f..2a40fc5 100644 --- a/synfig-core/src/synfig/listimporter.h +++ b/synfig-core/src/synfig/listimporter.h @@ -59,7 +59,7 @@ public: virtual ~ListImporter(); - virtual bool get_frame(Surface &surface,Time time, ProgressCallback *callback=NULL); + virtual bool get_frame(Surface &surface, const RendDesc &renddesc, Time time, ProgressCallback *callback=NULL); virtual bool is_animated();