Merge branch 'eldruin_ffmpeg2'
authorCarlos Lopez <genetita@gmail.com>
Fri, 12 Mar 2010 17:07:14 +0000 (18:07 +0100)
committerCarlos Lopez <genetita@gmail.com>
Fri, 12 Mar 2010 17:07:14 +0000 (18:07 +0100)
44 files changed:
synfig-core/src/modules/mod_bmp/trgt_bmp.cpp
synfig-core/src/modules/mod_bmp/trgt_bmp.h
synfig-core/src/modules/mod_dv/trgt_dv.cpp
synfig-core/src/modules/mod_dv/trgt_dv.h
synfig-core/src/modules/mod_ffmpeg/main.cpp
synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp
synfig-core/src/modules/mod_ffmpeg/trgt_ffmpeg.h
synfig-core/src/modules/mod_gif/trgt_gif.cpp
synfig-core/src/modules/mod_gif/trgt_gif.h
synfig-core/src/modules/mod_imagemagick/trgt_imagemagick.cpp
synfig-core/src/modules/mod_imagemagick/trgt_imagemagick.h
synfig-core/src/modules/mod_jpeg/trgt_jpeg.cpp
synfig-core/src/modules/mod_jpeg/trgt_jpeg.h
synfig-core/src/modules/mod_libavcodec/trgt_av.cpp
synfig-core/src/modules/mod_libavcodec/trgt_av.h
synfig-core/src/modules/mod_magickpp/trgt_magickpp.h
synfig-core/src/modules/mod_mng/trgt_mng.cpp
synfig-core/src/modules/mod_mng/trgt_mng.h
synfig-core/src/modules/mod_openexr/trgt_openexr.cpp
synfig-core/src/modules/mod_openexr/trgt_openexr.h
synfig-core/src/modules/mod_png/trgt_png.cpp
synfig-core/src/modules/mod_png/trgt_png.h
synfig-core/src/modules/mod_ppm/trgt_mpg.cpp
synfig-core/src/modules/mod_ppm/trgt_mpg.h
synfig-core/src/modules/mod_ppm/trgt_ppm.cpp
synfig-core/src/modules/mod_ppm/trgt_ppm.h
synfig-core/src/modules/mod_yuv420p/trgt_yuv.cpp
synfig-core/src/modules/mod_yuv420p/trgt_yuv.h
synfig-core/src/synfig/Makefile.am
synfig-core/src/synfig/module.h
synfig-core/src/synfig/target.cpp
synfig-core/src/synfig/target.h
synfig-core/src/synfig/targetparam.h [new file with mode: 0644]
synfig-core/src/tool/Makefile.am
synfig-core/src/tool/definitions.h [new file with mode: 0644]
synfig-core/src/tool/job.h [new file with mode: 0644]
synfig-core/src/tool/main.cpp
synfig-core/src/tool/progress.h [new file with mode: 0644]
synfig-core/src/tool/renderprogress.h [new file with mode: 0644]
synfig-studio/src/gtkmm/Makefile.am
synfig-studio/src/gtkmm/dialog_targetparam.cpp [new file with mode: 0644]
synfig-studio/src/gtkmm/dialog_targetparam.h [new file with mode: 0644]
synfig-studio/src/gtkmm/render.cpp
synfig-studio/src/gtkmm/render.h

index 2985c53..fe2d433 100644 (file)
@@ -110,7 +110,7 @@ inline short little_endian_short(const short &x)
 #define little_endian_short(x) (x)
 #endif
 
-bmp::bmp(const char *Filename)
+bmp::bmp(const char *Filename, const synfig::TargetParam& /* params */)
 {
        file=NULL;
        filename=Filename;
index 8a045c7..9d93b97 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 
 /* === M A C R O S ========================================================= */
@@ -51,7 +52,7 @@ private:
        synfig::PixelFormat pf;
 
 public:
-       bmp(const char *filename);
+       bmp(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~bmp();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index 13fed5c..6174af0 100644 (file)
@@ -80,7 +80,8 @@ SYNFIG_TARGET_SET_CVS_ID(dv_trgt,"$Id$");
 /* === M E T H O D S ======================================================= */
 
 
-dv_trgt::dv_trgt(const char *Filename)
+dv_trgt::dv_trgt(const char *Filename,
+                                const synfig::TargetParam& /* params */)
 {
        pid=-1;
        file=NULL;
index 11ba75e..7cb544c 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <sys/types.h>
 #include <cstdio>
 
@@ -53,7 +54,7 @@ private:
        unsigned char *buffer;
        synfig::Color *color_buffer;
 public:
-       dv_trgt(const char *filename);
+       dv_trgt(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~dv_trgt();
 
 
index 0f0cb82..783339b 100644 (file)
@@ -52,12 +52,13 @@ MODULE_INVENTORY_BEGIN(mod_ffmpeg)
        BEGIN_TARGETS
                TARGET(ffmpeg_trgt)
                TARGET_EXT(ffmpeg_trgt,"avi")
+               TARGET_EXT(ffmpeg_trgt,"flv")
+               TARGET_EXT(ffmpeg_trgt,"mkv")
                TARGET_EXT(ffmpeg_trgt,"mpg")
-               TARGET_EXT(ffmpeg_trgt,"rm")
-               TARGET_EXT(ffmpeg_trgt,"asf")
-               TARGET_EXT(ffmpeg_trgt,"swf")
-               TARGET_EXT(ffmpeg_trgt,"yuv")
+               TARGET_EXT(ffmpeg_trgt,"ogv")
                TARGET_EXT(ffmpeg_trgt,"rgb")
+               TARGET_EXT(ffmpeg_trgt,"wmv")
+               TARGET_EXT(ffmpeg_trgt,"yuv")
        END_TARGETS
        BEGIN_IMPORTERS
                IMPORTER_EXT(ffmpeg_mptr,"avi")
index 5b5b2bc..d1b9219 100644 (file)
@@ -7,6 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2010 Diego Barrios Romero
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -79,7 +80,8 @@ SYNFIG_TARGET_SET_CVS_ID(ffmpeg_trgt,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
-ffmpeg_trgt::ffmpeg_trgt(const char *Filename)
+ffmpeg_trgt::ffmpeg_trgt(const char *Filename,
+                                                const synfig::TargetParam& params)
 {
        pid=-1;
        file=NULL;
@@ -88,6 +90,17 @@ ffmpeg_trgt::ffmpeg_trgt(const char *Filename)
        buffer=NULL;
        color_buffer=0;
        set_remove_alpha();
+
+       // Set default video codec and bitrate if they weren't given.
+       if (params.video_codec == "none")
+               video_codec = "mpeg1video";
+       else
+               video_codec = params.video_codec;
+
+       if (params.bitrate == -1)
+               bitrate = 200;
+       else
+               bitrate = params.bitrate;
 }
 
 ffmpeg_trgt::~ffmpeg_trgt()
@@ -158,9 +171,25 @@ ffmpeg_trgt::init()
        string command;
 
        if( filename.c_str()[0] == '-' )
-                       command=strprintf("ffmpeg -f image2pipe -vcodec ppm -an -r %f -i pipe: -loop -hq -title \"%s\" -vcodec mpeg1video -y -- \"%s\"\n",desc.get_frame_rate(),get_canvas()->get_name().c_str(),filename.c_str());
+               command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an"
+                                                       " -r %f -i pipe: -loop_input"
+                                                       " -metadata title=\"%s\" "
+                                                       " -vcodec %s -b %ik"
+                                                       " -y -- \"%s\"\n",
+                                                       desc.get_frame_rate(),
+                                                       get_canvas()->get_name().c_str(),
+                                                       video_codec.c_str(), bitrate,
+                                                       filename.c_str());
        else
-                       command=strprintf("ffmpeg -f image2pipe -vcodec ppm -an -r %f -i pipe: -loop -hq -title \"%s\" -vcodec mpeg1video -y \"%s\"\n",desc.get_frame_rate(),get_canvas()->get_name().c_str(),filename.c_str());
+               command = strprintf("ffmpeg -f image2pipe -vcodec ppm -an"
+                                                       " -r %f -i pipe: -loop_input"
+                                                       " -metadata title=\"%s\" "
+                                                       "-vcodec %s -b %ik"
+                                                       " -y -- \"%s\"\n",
+                                                       desc.get_frame_rate(),
+                                                       get_canvas()->get_name().c_str(),
+                                                       video_codec.c_str(), bitrate,
+                                                       filename.c_str());
 
        file=popen(command.c_str(),POPEN_BINARY_WRITE_TYPE);
 
@@ -192,9 +221,53 @@ ffmpeg_trgt::init()
                // Close the unneeded pipeout
                close(p[0]);
                if( filename.c_str()[0] == '-' )
-                       execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", "ppm", "-an", "-r", strprintf("%f", desc.get_frame_rate()).c_str(), "-i", "pipe:", "-loop", "-hq", "-title", get_canvas()->get_name().c_str(), "-vcodec", "mpeg1video", "-y", "--", filename.c_str(), (const char *)NULL);
+               {
+                       // x264 codec needs -vpre hq parameters
+                       if (video_codec == "libx264")
+                               execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+                                          "ppm", "-an", "-r",
+                                          strprintf("%f", desc.get_frame_rate()).c_str(),
+                                          "-i", "pipe:", "-loop_input", "-metadata",
+                                               strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+                                               "-vcodec", video_codec.c_str(),
+                                               "-b", strprintf("%ik", bitrate).c_str(),
+                                               "-vpre", "hq",
+                                               "-y", "--", filename.c_str(), (const char *)NULL);
+                       else
+                               execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+                                          "ppm", "-an", "-r",
+                                          strprintf("%f", desc.get_frame_rate()).c_str(),
+                                          "-i", "pipe:", "-loop_input", "-metadata",
+                                               strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+                                               "-vcodec", video_codec.c_str(),
+                                               "-b", strprintf("%ik", bitrate).c_str(),
+                                               "-y", "--", filename.c_str(), (const char *)NULL);
+               }
                else
-                       execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec", "ppm", "-an", "-r", strprintf("%f", desc.get_frame_rate()).c_str(), "-i", "pipe:", "-loop", "-hq", "-title", get_canvas()->get_name().c_str(), "-vcodec", "mpeg1video", "-y", filename.c_str(), (const char *)NULL);
+               {
+                       if (video_codec == "libx264")
+                               execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+                                          "ppm", "-an", "-r",
+                                          strprintf("%f", desc.get_frame_rate()).c_str(),
+                                          "-i", "pipe:", "-loop_input",
+                                          "-metadata",
+                                          strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+                                          "-vcodec", video_codec.c_str(),
+                                          "-b", strprintf("%ik", bitrate).c_str(),
+                                          "-vpre", "hq",
+                                          "-y", filename.c_str(), (const char *)NULL);
+                       else
+                               execlp("ffmpeg", "ffmpeg", "-f", "image2pipe", "-vcodec",
+                                          "ppm", "-an", "-r",
+                                          strprintf("%f", desc.get_frame_rate()).c_str(),
+                                          "-i", "pipe:", "-loop_input",
+                                          "-metadata",
+                                          strprintf("title=\"%s\"", get_canvas()->get_name().c_str()).c_str(),
+                                          "-vcodec", video_codec.c_str(),
+                                          "-b", strprintf("%ik", bitrate).c_str(),
+                                          "-y", filename.c_str(), (const char *)NULL);
+               }
+
                // We should never reach here unless the exec failed
                synfig::error(_("Unable to open pipe to ffmpeg"));
                return false;
index c5fc1ae..d723bae 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2010 Diego Barrios Romero
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -31,6 +32,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <sys/types.h>
 #include <cstdio>
 
@@ -40,6 +42,8 @@
 
 /* === C L A S S E S & S T R U C T S ======================================= */
 
+class TargetParam;
+
 class ffmpeg_trgt : public synfig::Target_Scanline
 {
        SYNFIG_TARGET_MODULE_EXT
@@ -51,8 +55,11 @@ private:
        synfig::String filename;
        unsigned char *buffer;
        synfig::Color *color_buffer;
+       std::string video_codec;
+       int bitrate;
 public:
-       ffmpeg_trgt(const char *filename);
+       ffmpeg_trgt(const char *filename,
+                               const synfig::TargetParam& params);
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
        virtual bool init();
index 2068995..a520ff3 100644 (file)
@@ -57,7 +57,7 @@ SYNFIG_TARGET_SET_CVS_ID(gif,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
-gif::gif(const char *filename_):
+gif::gif(const char *filename_, const synfig::TargetParam& /* params */):
        filename(filename_),
        file( (filename=="-")?stdout:fopen(filename_,POPEN_BINARY_WRITE_TYPE) ),
        imagecount(0),
index ae10e31..fa90efd 100644 (file)
@@ -35,6 +35,7 @@
 #include <cstdio>
 #include <synfig/surface.h>
 #include <synfig/palette.h>
+#include <synfig/targetparam.h>
 
 /* === M A C R O S ========================================================= */
 
@@ -194,7 +195,7 @@ private:
        void output_curr_palette();
 
 public:
-       gif(const char *filename);
+       gif(const char *filename, const synfig::TargetParam& /* params */);
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
        virtual bool init();
index 32dd839..dc024ae 100644 (file)
@@ -80,7 +80,8 @@ SYNFIG_TARGET_SET_CVS_ID(imagemagick_trgt,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
-imagemagick_trgt::imagemagick_trgt(const char *Filename)
+imagemagick_trgt::imagemagick_trgt(const char *Filename,
+                                                                  const synfig::TargetParam& /* params */)
 {
        pid=-1;
        file=NULL;
index 2a9a171..253fb4c 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <sys/types.h>
 #include <cstdio>
 
@@ -54,7 +55,8 @@ private:
        synfig::Color *color_buffer;
        synfig::PixelFormat pf;
 public:
-       imagemagick_trgt(const char *filename);
+       imagemagick_trgt(const char *filename,
+                                        const synfig::TargetParam& /* params */);
        virtual ~imagemagick_trgt();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index 3ff854d..b0def32 100644 (file)
@@ -58,7 +58,8 @@ SYNFIG_TARGET_SET_CVS_ID(jpeg_trgt,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
-jpeg_trgt::jpeg_trgt(const char *Filename)
+jpeg_trgt::jpeg_trgt(const char *Filename,
+                                        const synfig::TargetParam& /* params */)
 {
        file=NULL;
        filename=Filename;
index 65518d0..8cbb4dc 100644 (file)
@@ -32,6 +32,7 @@
 #define NOMINMAX
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 _ETL_BEGIN_CDECLS
 #include <jpeglib.h>
@@ -60,7 +61,7 @@ private:
        unsigned char *buffer;
        synfig::Color *color_buffer;
 public:
-       jpeg_trgt(const char *filename);
+       jpeg_trgt(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~jpeg_trgt();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index 5ad733a..f329081 100644 (file)
@@ -815,7 +815,8 @@ public:
 
 /* === M E T H O D S ======================================================= */
 
-Target_LibAVCodec::Target_LibAVCodec(const char *Filename):
+Target_LibAVCodec::Target_LibAVCodec(const char *Filename,
+                                                                        const synfig::TargetParam& /* params */):
        filename(Filename)
 {
        if(!registered)
index a2df7d7..3b09af2 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 #include "synfig/surface.h"
 
@@ -52,7 +53,8 @@ private:
        synfig::Surface surface;
 
 public:
-       Target_LibAVCodec(const char *filename);
+       Target_LibAVCodec(const char *filename,
+                                         const synfig::TargetParam& /* params */);
        virtual ~Target_LibAVCodec();
 
        virtual bool init();
index 57a0c01..8705e1d 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 
 #include <vector>
@@ -54,7 +55,9 @@ private:
 
 public:
 
-       magickpp_trgt(const char *filename) : filename(filename) { }
+       magickpp_trgt(const char *filename,
+                                 const synfig::TargetParam& /* params */) :
+               filename(filename) { }
        virtual ~magickpp_trgt();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index 7a97c7c..3540490 100644 (file)
@@ -99,7 +99,9 @@ mng_error_proc(mng_handle mng __attribute__ ((unused)), mng_int32 error __attrib
        return MNG_TRUE;
 }
 
-mng_trgt::mng_trgt(const char *Filename) : filename(Filename)
+mng_trgt::mng_trgt(const char *Filename,
+                                  const synfig::TargetParam& /* params */) :
+       filename(Filename)
 {
        file=NULL;
        buffer=NULL;
index a194b35..6fc848a 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 
 // #include <png.h>
@@ -82,7 +83,7 @@ private:
 
 public:
 
-       mng_trgt(const char *filename);
+       mng_trgt(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~mng_trgt();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index ccfa576..2ad34f5 100644 (file)
@@ -63,7 +63,8 @@ exr_trgt::ready()
        return (bool)exr_file;
 }
 
-exr_trgt::exr_trgt(const char *Filename):
+exr_trgt::exr_trgt(const char *Filename,
+                                  const synfig::TargetParam& /* params */):
        multi_image(false),
        imagecount(0),
        filename(Filename),
index 9a4e13f..a7bfb28 100644 (file)
@@ -32,6 +32,7 @@
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
 #include <synfig/surface.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 #include <OpenEXR/ImfArray.h>
 #include <OpenEXR/ImfRgbaFile.h>
@@ -59,7 +60,7 @@ private:
 
        bool ready();
 public:
-       exr_trgt(const char *filename);
+       exr_trgt(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~exr_trgt();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index bc38548..a0a58b1 100644 (file)
@@ -79,7 +79,8 @@ png_trgt::png_out_warning(png_struct *png_data,const char *msg)
 
 //Target *png_trgt::New(const char *filename){ return new png_trgt(filename);}
 
-png_trgt::png_trgt(const char *Filename)
+png_trgt::png_trgt(const char *Filename,
+                                  const synfig::TargetParam& /* params */)
 {
        file=NULL;
        filename=Filename;
index 19dd82b..350b6f2 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 #include <png.h>
 
@@ -57,7 +58,7 @@ private:
        unsigned char *buffer;
        synfig::Color *color_buffer;
 public:
-       png_trgt(const char *filename);
+       png_trgt(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~png_trgt();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index e379eb0..c90ebfd 100644 (file)
@@ -64,7 +64,8 @@ bsd_mpeg1::New(const char *filename)
        return new bsd_mpeg1(filename);
 }
 
-bsd_mpeg1::bsd_mpeg1(const char *Filename)
+bsd_mpeg1::bsd_mpeg1(const char *Filename,
+                                        const synfig::TargetParam& /* params */)
 {
        filename=Filename;
        passthru=ppm::New((tmp_dir+"temp.ppm").c_str());
index 5ce96dc..e1707d9 100644 (file)
@@ -49,7 +49,7 @@ private:
        String filename;
        FILE *paramfile;
 public:
-       bsd_mpeg1(const char *filename);
+       bsd_mpeg1(const char *filename, const synfig::TargetParam& /* params */);
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
        virtual bool start_frame(synfig::ProgressCallback *cb);
index 8fc4810..0859d84 100644 (file)
@@ -57,7 +57,7 @@ SYNFIG_TARGET_SET_CVS_ID(ppm,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
-ppm::ppm(const char *Filename)
+ppm::ppm(const char *Filename, const synfig::TargetParam& /* params */)
 {
        filename=Filename;
        multi_image=false;
index f1a5134..fd93e38 100644 (file)
@@ -32,6 +32,7 @@
 #include <synfig/target_scanline.h>
 #include <synfig/string.h>
 #include <synfig/smartfile.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 
 /* === M A C R O S ========================================================= */
@@ -52,7 +53,7 @@ private:
        synfig::Color *color_buffer;
        unsigned char *buffer;
 public:
-       ppm(const char *filename);
+       ppm(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~ppm();
 
        virtual bool set_rend_desc(synfig::RendDesc *desc);
index bad2dca..a6d3455 100644 (file)
@@ -63,7 +63,7 @@ SYNFIG_TARGET_SET_CVS_ID(yuv,"$Id$");
 
 /* === M E T H O D S ======================================================= */
 
-yuv::yuv(const char *FILENAME):
+yuv::yuv(const char *FILENAME, const synfig::TargetParam& /* params */):
        filename(FILENAME),
        file( (filename=="-")?stdout:fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE) ),
        dithering(true)
index f176607..8ffa7bd 100644 (file)
@@ -32,6 +32,7 @@
 #include <synfig/string.h>
 #include <synfig/surface.h>
 #include <synfig/smartfile.h>
+#include <synfig/targetparam.h>
 #include <cstdio>
 
 /* === M A C R O S ========================================================= */
@@ -54,7 +55,7 @@ private:
 
 public:
 
-       yuv(const char *filename);
+       yuv(const char *filename, const synfig::TargetParam& /* params */);
        virtual ~yuv();
 
        virtual bool init();
index 4ed8b13..ac0ddca 100644 (file)
@@ -42,7 +42,8 @@ TARGETHEADERS = \
        target_null.h \
        target_null_tile.h \
        target_scanline.h \
-       target_tile.h
+       target_tile.h \
+       targetparam.h
 
 TARGETSOURCES = \
        target_multi.cpp \
index d064fe9..29455e3 100644 (file)
 //! Marks the start of the targets in the module's inventory
 #define BEGIN_TARGETS {
 
-#define TARGET(x)                                                       \
-       synfig::Target::book()[synfig::String(x::name__)].factory =           \
-               reinterpret_cast<synfig::Target::Factory>       (x::create);              \
-  synfig::Target::book()[synfig::String(x::name__)].filename =          \
-    synfig::String(x::ext__);                                           \
+#define TARGET(x)                                                                                                              \
+       synfig::Target::book()[synfig::String(x::name__)].factory =                     \
+               reinterpret_cast<synfig::Target::Factory> (x::create);                  \
+       synfig::Target::book()[synfig::String(x::name__)].filename =            \
+               synfig::String(x::ext__);                                                                               \
+       synfig::Target::book()[synfig::String(x::name__)].target_param =        \
+               synfig::TargetParam();                                                                                                  \
        synfig::Target::ext_book()[synfig::String(x::ext__)]=x::name__;
 
 #define TARGET_EXT(x,y) synfig::Target::ext_book()[synfig::String(y)]=x::name__;
index 47727be..b6aa1c4 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2010 Diego Barrios Romero
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -33,6 +34,7 @@
 #include "canvas.h"
 #include "target_null.h"
 #include "target_null_tile.h"
+#include "targetparam.h"
 
 using namespace synfig;
 using namespace etl;
@@ -57,12 +59,14 @@ Target::subsys_init()
        // At least one target must be available.
        book()["null"].factory =
                reinterpret_cast<synfig::Target::Factory>(&Target_Null::create);
-  book()["null"].filename = "null";
+       book()["null"].filename = "null";
+       book()["null"].target_param = TargetParam();
        ext_book()["null"]="null";
 
        book()["null-tile"].factory =
-    reinterpret_cast<synfig::Target::Factory>(&Target_Null_Tile::create);
-  book()["null-tile"].filename = "null-tile";
+               reinterpret_cast<synfig::Target::Factory>(&Target_Null_Tile::create);
+       book()["null-tile"].filename = "null-tile";
+       book()["null-tile"].target_param = TargetParam();
        ext_book()["null-tile"]="null-tile";
 
        return true;
@@ -110,10 +114,11 @@ synfig::Target::set_canvas(etl::handle<Canvas> c)
 
 
 Target::Handle
-Target::create(const String &name, const String &filename)
+Target::create(const String &name, const String &filename,
+                          synfig::TargetParam params)
 {
        if(!book().count(name))
                return handle<Target>();
 
-       return Target::Handle(book()[name].factory(filename.c_str()));
+       return Target::Handle(book()[name].factory(filename.c_str(), params));
 }
index f93cf87..5fcaaeb 100644 (file)
@@ -7,6 +7,7 @@
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
 **     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2010 Diego Barrios Romero
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
 //#include "general.h"
 #include "color.h"
 #include "canvas.h"
+#include "targetparam.h"
 
 /* === M A C R O S ========================================================= */
 
 //! \writeme
-#define SYNFIG_TARGET_MODULE_EXT public: static const char name__[], version__[], ext__[],cvs_id__[]; static Target *create(const char *filename);
+#define SYNFIG_TARGET_MODULE_EXT public: static const char name__[],   \
+               version__[], ext__[], cvs_id__[];                                                               \
+       static Target* create (const char *filename,                                            \
+                                                  synfig::TargetParam p);
 
 //! Sets the name of the target
 #define SYNFIG_TARGET_SET_NAME(class,x) const char class::name__[]=x
 #define SYNFIG_TARGET_SET_CVS_ID(class,x) const char class::cvs_id__[]=x
 
 //! \writeme
-#define SYNFIG_TARGET_INIT(class) synfig::Target* class::create(const char *filename) { return new class(filename); }
+#define SYNFIG_TARGET_INIT(class)                                                                              \
+       synfig::Target* class::create (const char *filename,                            \
+                                                                  synfig::TargetParam p)                               \
+       { return new class(filename, p); }
 
 /* === T Y P E D E F S ===================================================== */
 
@@ -69,6 +77,7 @@ class Surface;
 class RendDesc;
 class Canvas;
 class ProgressCallback;
+class TargetParam;
 
 /*!    \class Target
 **     \brief Render-target
@@ -106,12 +115,13 @@ public:
        /*! As a pointer to the constructor, it represents a "factory" of targets.
        **  Receives the output filename (including path).
        */
-       typedef Target* (*Factory)(const char *filename);
-       
+       typedef Target* (*Factory)(const char *filename, TargetParam p);
+
        struct BookEntry
        {
                Factory factory;
                String filename; ///< Output filename including path
+               TargetParam target_param; ///< Target module parameters
        };
 
        //! Book of types of targets indexed by the name of the Target.
@@ -186,7 +196,8 @@ public:
        virtual bool init() { return true; }
 
        //! Creates a new Target described by \a type, outputting to a file described by \a filename.
-       static Handle create(const String &type, const String &filename);
+       static Handle create(const String &type, const String &filename,
+                                                synfig::TargetParam params);
 }; // END of class Target
 
 }; // END of namespace synfig
diff --git a/synfig-core/src/synfig/targetparam.h b/synfig-core/src/synfig/targetparam.h
new file mode 100644 (file)
index 0000000..05c815d
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file synfig/targetparam.h
+**     \brief Class for extra parameters of the target modules
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2010 Diego Barrios Romero
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_TARGETPARAM_H
+#define __SYNFIG_TARGETPARAM_H
+
+#include <string>
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfig {
+
+struct TargetParam
+{
+       //! Default constructor
+       /*! Not valid default values, if they are not modified before
+        *  passing them to the target module, it would override them with
+        *  its own valid default settings.
+        */
+       TargetParam (): video_codec("none"), bitrate(-1) { }
+
+       TargetParam (const std::string& Video_codec, int Bitrate):
+               video_codec(Video_codec), bitrate(Bitrate)
+       { }
+
+       std::string video_codec;
+       int bitrate;
+};
+
+}; // END of namespace synfig
+
+/* === E N D =============================================================== */
+
+#endif
+
index dabe04e..2109b1d 100644 (file)
@@ -14,8 +14,11 @@ INCLUDES = \
 bin_PROGRAMS = \
        synfig
 
-
 synfig_SOURCES = \
+       definitions.h \
+       progress.h \
+       renderprogress.h \
+       job.h \ 
        main.cpp
 
 synfig_LDADD = \
diff --git a/synfig-core/src/tool/definitions.h b/synfig-core/src/tool/definitions.h
new file mode 100644 (file)
index 0000000..bea4b7d
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/definitions.h
+**     \brief Definitions for synfig tool
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_DEFINITIONS_H
+#define __SYNFIG_DEFINITIONS_H
+
+/* === M A C R O S ========================================================= */
+
+#ifdef ENABLE_NLS
+#undef _
+#define _(x) gettext(x)
+#else
+#undef _
+#define _(x) (x)
+#endif
+
+enum exit_code
+{
+       SYNFIGTOOL_OK                           = 0,
+       SYNFIGTOOL_FILENOTFOUND         = 1,
+       SYNFIGTOOL_BORED                        = 2,
+       SYNFIGTOOL_HELP                         = 3,
+       SYNFIGTOOL_UNKNOWNARGUMENT      = 4,
+       SYNFIGTOOL_UNKNOWNERROR         = 5,
+       SYNFIGTOOL_INVALIDTARGET        = 6,
+       SYNFIGTOOL_RENDERFAILURE        = 7,
+       SYNFIGTOOL_BLANK                        = 8,
+       SYNFIGTOOL_BADVERSION           = 9,
+       SYNFIGTOOL_MISSINGARGUMENT      =10
+};
+
+#ifndef VERSION
+#define VERSION "unknown"
+#define PACKAGE "synfig-tool"
+#endif
+
+#ifdef DEFAULT_QUALITY
+#undef DEFAULT_QUALITY
+#endif
+
+#define DEFAULT_QUALITY                2
+#define VERBOSE_OUT(x) if(verbosity>=(x))std::cerr
+
+/* === G L O B A L S ======================================================= */
+
+extern const char *progname;
+extern int verbosity;
+extern bool be_quiet;
+extern bool print_benchmarks;
+
+#endif
diff --git a/synfig-core/src/tool/job.h b/synfig-core/src/tool/job.h
new file mode 100644 (file)
index 0000000..e0bc66f
--- /dev/null
@@ -0,0 +1,62 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/job.h
+**     \brief Job class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_JOB_H
+#define __SYNFIG_JOB_H
+
+using namespace synfig;
+
+#include <synfig/string.h>
+#include <synfig/canvas.h>
+#include <synfig/target.h>
+#include "definitions.h"
+
+struct Job
+{
+       String filename;
+       String outfilename;
+
+       RendDesc desc;
+
+       Canvas::Handle root;
+       Canvas::Handle canvas;
+       Target::Handle target;
+
+       int quality;
+       bool sifout;
+       bool list_canvases;
+
+       bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
+                canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
+                canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
+                canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
+                canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
+                canvas_info_bg_color, canvas_info_metadata;
+
+       Job()
+       {
+               canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
+       };
+};
+
+#endif
index e325515..03d9a08 100644 (file)
 #include <synfig/layer.h>
 #include <synfig/canvas.h>
 #include <synfig/target.h>
+#include <synfig/targetparam.h>
 #include <synfig/time.h>
 #include <synfig/string.h>
 #include <synfig/paramdesc.h>
 #include <synfig/main.h>
 #include <synfig/guid.h>
 #include <autorevision.h>
+#include "definitions.h"
+#include "progress.h"
+#include "renderprogress.h"
+#include "job.h"
 #endif
 
 using namespace std;
 using namespace etl;
 using namespace synfig;
 
-/* === M A C R O S ========================================================= */
-
-#ifdef ENABLE_NLS
-#undef _
-#define _(x) gettext(x)
-#else
-#undef _
-#define _(x) (x)
-#endif
-
-enum exit_code
-{
-       SYNFIGTOOL_OK                           = 0,
-       SYNFIGTOOL_FILENOTFOUND         = 1,
-       SYNFIGTOOL_BORED                        = 2,
-       SYNFIGTOOL_HELP                         = 3,
-       SYNFIGTOOL_UNKNOWNARGUMENT      = 4,
-       SYNFIGTOOL_UNKNOWNERROR         = 5,
-       SYNFIGTOOL_INVALIDTARGET        = 6,
-       SYNFIGTOOL_RENDERFAILURE        = 7,
-       SYNFIGTOOL_BLANK                        = 8,
-       SYNFIGTOOL_BADVERSION           = 9,
-       SYNFIGTOOL_MISSINGARGUMENT      =10
-};
-
-#ifndef VERSION
-#define VERSION "unknown"
-#define PACKAGE "synfig-tool"
-#endif
-
-#ifdef DEFAULT_QUALITY
-#undef DEFAULT_QUALITY
-#endif
-
-#define DEFAULT_QUALITY                2
-#define VERBOSE_OUT(x) if(verbosity>=(x))std::cerr
-
 /* === G L O B A L S ======================================================= */
 
 const char *progname;
@@ -101,182 +69,50 @@ int verbosity=0;
 bool be_quiet=false;
 bool print_benchmarks=false;
 
-/* === M E T H O D S ======================================================= */
-
-class Progress : public synfig::ProgressCallback
+//! Allowed video codecs
+/*! \warning This variable is linked to allowed_video_codecs_description,
+ *  if you change this you must change the other acordingly.
+ *  \warning These codecs are linked to the filename extensions for
+ *  mod_ffmpeg. If you change this you must change the others acordingly.
+ */
+const char* allowed_video_codecs[] =
 {
-       const char *program;
-
-public:
-
-       Progress(const char *name):program(name) { }
-
-       virtual bool
-       task(const String &task)
-       {
-               VERBOSE_OUT(1)<<program<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       error(const String &task)
-       {
-               std::cerr<<program<<": "<<_("error")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       warning(const String &task)
-       {
-               std::cerr<<program<<": "<<_("warning")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       amount_complete(int /*current*/, int /*total*/)
-       {
-               return true;
-       }
+       "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
+       "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
+       "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
 };
 
-class RenderProgress : public synfig::ProgressCallback
+//! Allowed video codecs description.
+/*! \warning This variable is linked to allowed_video_codecs,
+ *  if you change this you must change the other acordingly.
+ */
+const char* allowed_video_codecs_description[] =
 {
-       string taskname;
-
-       etl::clock clk;
-       int clk_scanline; // The scanline at which the clock was reset
-       etl::clock clk2;
-
-       float last_time;
-public:
-
-       RenderProgress():clk_scanline(0), last_time(0) { }
-
-       virtual bool
-       task(const String &thetask)
-       {
-               taskname=thetask;
-               return true;
-       }
-
-       virtual bool
-       error(const String &task)
-       {
-               std::cout<<_("error")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       warning(const String &task)
-       {
-               std::cout<<_("warning")<<": "<<task<<std::endl;
-               return true;
-       }
-
-       virtual bool
-       amount_complete(int scanline, int h)
-       {
-               if(be_quiet)return true;
-               if(scanline!=h)
-               {
-                       const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
-                       const float delta(time-last_time);
-
-                       int weeks=0,days=0,hours=0,minutes=0,seconds=0;
-
-                       last_time=time;
-
-                       if(clk2()<0.2)
-                               return true;
-                       clk2.reset();
-
-                       if(scanline)
-                               seconds=(int)time+1;
-                       else
-                       {
-                               //cerr<<"reset"<<endl;
-                               clk.reset();
-                               clk_scanline=scanline;
-                       }
-
-                       if(seconds<0)
-                       {
-                               clk.reset();
-                               clk_scanline=scanline;
-                               seconds=0;
-                       }
-                       while(seconds>=60)
-                               minutes++,seconds-=60;
-                       while(minutes>=60)
-                               hours++,minutes-=60;
-                       while(hours>=24)
-                               days++,hours-=24;
-                       while(days>=7)
-                               weeks++,days-=7;
-
-                       cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
-                       //cerr<<time/(h-clk_scanline)<<" ";
-                       /*
-                       if(delta>=-time/(h-clk_scanline)  )
-                               cerr<<">";
-                       */
-                       if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
-                       {
-                               //cerr<<"reset"<<endl;
-                               clk.reset();
-                               clk_scanline=scanline;
-                       }
-
-                       if(weeks)
-                               cerr<<weeks<<"w ";
-                       if(days)
-                               cerr<<days<<"d ";
-                       if(hours)
-                               cerr<<hours<<"h ";
-                       if(minutes)
-                               cerr<<minutes<<"m ";
-                       if(seconds)
-                               cerr<<seconds<<"s ";
-
-                       cerr<<"           \r";
-               }
-               else
-                       cerr<<taskname<<": "<<_("DONE")<<"                        "<<endl;;
-               return true;
-       }
+       "Flash Video (FLV) / Sorenson Spark / Sorenson H.263.",
+       "H.263+ / H.263-1998 / H.263 version 2.",
+       "Huffyuv / HuffYUV.",
+       "libtheora Theora.",
+       "libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10.",
+       "libxvidcore MPEG-4 part 2.",
+       "MJPEG (Motion JPEG).",
+       "raw MPEG-1 video.",
+       "raw MPEG-2 video.",
+       "MPEG-4 part 2.",
+       "MPEG-4 part 2 Microsoft variant version 3.",
+       "MPEG-4 part 2 Microsoft variant version 1.",
+       "MPEG-4 part 2 Microsoft variant version 2.",
+       "Windows Media Video 7.",
+       "Windows Media Video 8.",
+       NULL
 };
 
-struct Job
-{
-       String filename;
-       String outfilename;
-
-       RendDesc desc;
-
-       Canvas::Handle root;
-       Canvas::Handle canvas;
-       Target::Handle target;
-
-       int quality;
-       bool sifout;
-       bool list_canvases;
-
-       bool canvas_info, canvas_info_all, canvas_info_time_start, canvas_info_time_end, canvas_info_frame_rate,
-                canvas_info_frame_start, canvas_info_frame_end, canvas_info_w, canvas_info_h, canvas_info_image_aspect,
-                canvas_info_pw, canvas_info_ph, canvas_info_pixel_aspect, canvas_info_tl, canvas_info_br,
-                canvas_info_physical_w, canvas_info_physical_h, canvas_info_x_res, canvas_info_y_res, canvas_info_span,
-                canvas_info_interlaced, canvas_info_antialias, canvas_info_clamp, canvas_info_flags, canvas_info_focus,
-                canvas_info_bg_color, canvas_info_metadata;
-
-       Job()
-       {
-               canvas_info = canvas_info_all = canvas_info_time_start = canvas_info_time_end = canvas_info_frame_rate = canvas_info_frame_start = canvas_info_frame_end = canvas_info_w = canvas_info_h = canvas_info_image_aspect = canvas_info_pw = canvas_info_ph = canvas_info_pixel_aspect = canvas_info_tl = canvas_info_br = canvas_info_physical_w = canvas_info_physical_h = canvas_info_x_res = canvas_info_y_res = canvas_info_span = canvas_info_interlaced = canvas_info_antialias = canvas_info_clamp = canvas_info_flags = canvas_info_focus = canvas_info_bg_color = canvas_info_metadata = false;
-       };
-};
+/* === T Y P E D E F S ===================================================== */
 
 typedef list<String> arg_list_t;
 typedef list<Job> job_list_t;
 
+/* === M E T H O D S ======================================================= */
+
 void guid_test()
 {
        cout<<"GUID Test"<<endl;
@@ -349,6 +185,7 @@ void display_help(bool full)
                display_help_option("--layer-info", "<layer>", _("Print out layer's description, parameter info, etc."));
                display_help_option("--layers", NULL, _("Print out the list of available layers"));
                display_help_option("--targets", NULL, _("Print out the list of available targets"));
+               display_help_option("--target-video-codecs", NULL, _("Print out the list of available target video codecs"));
                display_help_option("--importers", NULL, _("Print out the list of available importers"));
                display_help_option("--valuenodes", NULL, _("Print out the list of available ValueNodes"));
                display_help_option("--modules", NULL, _("Print out the list of loaded modules"));
@@ -367,6 +204,15 @@ void display_help(bool full)
        cerr << endl;
 }
 
+void display_target_video_codecs_help ()
+{
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               cout << " " << allowed_video_codecs[i] << ":   \t"
+                        << allowed_video_codecs_description[i]
+                        << endl;
+}
+
 int process_global_flags(arg_list_t &arg_list)
 {
        arg_list_t::iterator iter, next;
@@ -477,6 +323,13 @@ int process_global_flags(arg_list_t &arg_list)
                        return SYNFIGTOOL_HELP;
                }
 
+               if(*iter == "--target-video-codecs")
+               {
+                       display_target_video_codecs_help();
+
+                       return SYNFIGTOOL_HELP;
+               }
+
                if(*iter == "--valuenodes")
                {
                        Progress p(PACKAGE);
@@ -550,7 +403,7 @@ bool flag_requires_value(String flag)
                        flag=="-Q"                      || flag=="-s"                   || flag=="-t"                   || flag=="-T"                   || flag=="-w"                   ||
                        flag=="--append"        || flag=="--begin-time" || flag=="--canvas-info"|| flag=="--dpi"                || flag=="--dpi-x"              ||
                        flag=="--dpi-y"         || flag=="--end-time"   || flag=="--fps"                || flag=="--layer-info" || flag=="--start-time" ||
-                       flag=="--time"          );
+                       flag=="--time"          || flag=="-vc"                  || flag=="-vb");
 }
 
 int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster)
@@ -584,6 +437,25 @@ int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster)
        return SYNFIGTOOL_OK;
 }
 
+/*! Extract a parameter from the argument list
+ *
+ * \param arg_list Argument list from wich the parameter is extracted.
+ * \param iter Iterator pointing to the argument list parameter to be
+ * extracted.
+ * \param next Iterator pointing to the next argument.
+ */
+string extract_parameter (arg_list_t& arg_list,
+                                                 arg_list_t::iterator& iter,
+                                                 arg_list_t::iterator& next)
+{
+       string parameter;
+       arg_list.erase(iter);
+       iter = next++;
+       parameter = *iter;
+       arg_list.erase(iter);
+       return parameter;
+}
+
 int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
 {
        arg_list_t::iterator iter, next;
@@ -593,107 +465,74 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc)
        {
                if(*iter=="-w")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       w=atoi(iter->c_str());
-                       arg_list.erase(iter);
+                       w = atoi(extract_parameter(arg_list, iter, next).c_str());
                }
                else if(*iter=="-h")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       h=atoi(iter->c_str());
-                       arg_list.erase(iter);
+                       h = atoi(extract_parameter(arg_list, iter, next).c_str());
                }
                else if(*iter=="-a")
                {
             int a;
-                       arg_list.erase(iter);
-                       iter=next++;
-                       a=atoi(iter->c_str());
+                       a = atoi(extract_parameter(arg_list, iter, next).c_str());
                        desc.set_antialias(a);
                        VERBOSE_OUT(1)<<strprintf(_("Antialiasing set to %d, (%d samples per pixel)"),a,a*a)<<endl;
-                       arg_list.erase(iter);
                }
                else if(*iter=="-s")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       span=atof(iter->c_str());
+                       span = atoi(extract_parameter(arg_list, iter, next).c_str());
                        VERBOSE_OUT(1)<<strprintf(_("Span set to %d units"),span)<<endl;
-                       arg_list.erase(iter);
                }
                else if(*iter=="--fps")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       float fps=atof(iter->c_str());
+                       float fps = atof(extract_parameter(arg_list, iter, next).c_str());
                        desc.set_frame_rate(fps);
-                       arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Frame rate set to %d frames per second"),fps)<<endl;
                }
                else if(*iter=="--dpi")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       float dpi=atof(iter->c_str());
+                       float dpi = atof(extract_parameter(arg_list, iter, next).c_str());
                        float dots_per_meter=dpi*39.3700787402;
                        desc.set_x_res(dots_per_meter).set_y_res(dots_per_meter);
-                       arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Physical resolution set to %f dpi"),dpi)<<endl;
                }
                else if(*iter=="--dpi-x")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       float dpi=atof(iter->c_str());
+                       float dpi = atof(extract_parameter(arg_list, iter, next).c_str());
                        float dots_per_meter=dpi*39.3700787402;
                        desc.set_x_res(dots_per_meter);
-                       arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Physical X resolution set to %f dpi"),dpi)<<endl;
                }
                else if(*iter=="--dpi-y")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       float dpi=atof(iter->c_str());
+                       float dpi = atof(extract_parameter(arg_list, iter, next).c_str());
                        float dots_per_meter=dpi*39.3700787402;
                        desc.set_y_res(dots_per_meter);
-                       arg_list.erase(iter);
                        VERBOSE_OUT(1)<<strprintf(_("Physical Y resolution set to %f dpi"),dpi)<<endl;
                }
                else if(*iter=="--start-time" || *iter=="--begin-time")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       desc.set_time_start(Time(*iter,desc.get_frame_rate()));
-                       arg_list.erase(iter);
+                       desc.set_time_start(Time(extract_parameter(arg_list, iter, next),
+                                                               desc.get_frame_rate()));
                }
                else if(*iter=="--end-time")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       desc.set_time_end(Time(*iter,desc.get_frame_rate()));
-                       arg_list.erase(iter);
+                       desc.set_time_end(Time(extract_parameter(arg_list, iter, next),
+                                                                  desc.get_frame_rate()));
                }
                else if(*iter=="--time")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       desc.set_time(Time(*iter,desc.get_frame_rate()));
+                       desc.set_time(Time(extract_parameter(arg_list, iter, next),
+                                                          desc.get_frame_rate()));
                        VERBOSE_OUT(1)<<_("Rendering frame at ")<<desc.get_time_start().get_string(desc.get_frame_rate())<<endl;
-                       arg_list.erase(iter);
                }
                else if(*iter=="-g")
                {
                        synfig::warning("Gamma argument is currently ignored");
-                       arg_list.erase(iter);
-                       iter=next++;
-                       //desc.set_gamma(Gamma(atof(iter->c_str())));
-                       arg_list.erase(iter);
+                       //desc.set_gamma(Gamma(atoi(extract_parameter(arg_list, iter, next).c_str())));
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
        if (w||h)
        {
@@ -717,14 +556,11 @@ int extract_quality(arg_list_t &arg_list,int &quality)
        {
                if(*iter=="-Q")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       quality=atoi(iter->c_str());
+                       quality = atoi(extract_parameter(arg_list, iter, next).c_str());
                        VERBOSE_OUT(1)<<strprintf(_("Quality set to %d"),quality)<<endl;
-                       arg_list.erase(iter);
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
 
        return SYNFIGTOOL_OK;
@@ -737,14 +573,11 @@ int extract_threads(arg_list_t &arg_list,int &threads)
        {
                if(*iter=="-T")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       threads=atoi(iter->c_str());
+                       threads = atoi(extract_parameter(arg_list, iter, next).c_str());
                        VERBOSE_OUT(1)<<strprintf(_("Threads set to %d"),threads)<<endl;
-                       arg_list.erase(iter);
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
 
        return SYNFIGTOOL_OK;
@@ -759,18 +592,73 @@ int extract_target(arg_list_t &arg_list,string &type)
        {
                if(*iter=="-t")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       type=*iter;
-                       arg_list.erase(iter);
+                       type = extract_parameter(arg_list, iter, next);
+                       VERBOSE_OUT(1)<<strprintf(_("Target set to %s"), type.c_str())<<endl;
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
 
        return SYNFIGTOOL_OK;
 }
 
+int extract_target_params(arg_list_t& arg_list,
+                                                 TargetParam& params)
+{
+       int ret;
+       ret = SYNFIGTOOL_OK;
+       // If -vc parameter is provided, -vb parameter is needed.
+       bool need_bitrate_parameter = false;
+       arg_list_t::iterator iter, next;
+
+       for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++)
+       {
+               if(*iter=="-vc")
+               {
+                       // Target video codec
+                       params.video_codec = extract_parameter(arg_list, iter, next);
+
+                       // video_codec string to lowercase
+                       transform (params.video_codec.begin(),
+                                          params.video_codec.end(),
+                                          params.video_codec.begin(),
+                                          ::tolower);
+
+                       int local_ret;
+                       local_ret = SYNFIGTOOL_UNKNOWNARGUMENT;
+
+                       // Check if the given video codec is allowed.
+                       for (int i = 0; local_ret != SYNFIGTOOL_OK &&
+                                                       allowed_video_codecs[i] != NULL; i++)
+                               if (params.video_codec == allowed_video_codecs[i])
+                                       local_ret = SYNFIGTOOL_OK;
+
+                       ret = local_ret;
+
+                       if (ret == SYNFIGTOOL_OK)
+                       {
+                               VERBOSE_OUT(1)<<strprintf(_("Target video codec set to %s"), params.video_codec.c_str())<<endl;
+                               need_bitrate_parameter = true;
+                       }
+               }
+               else if(*iter=="-vb")
+               {
+                       need_bitrate_parameter = false;
+                       // Target bitrate
+                       params.bitrate =
+                               atoi(extract_parameter(arg_list, iter, next).c_str());
+                       VERBOSE_OUT(1)<<strprintf(_("Target bitrate set to %dk"),params.bitrate)<<endl;
+               }
+               else if (flag_requires_value(*iter))
+                       iter++;
+       }
+
+       if (need_bitrate_parameter)
+               ret = SYNFIGTOOL_MISSINGARGUMENT;
+
+       return ret;
+}
+
 int extract_append(arg_list_t &arg_list,string &filename)
 {
        arg_list_t::iterator iter, next;
@@ -780,13 +668,10 @@ int extract_append(arg_list_t &arg_list,string &filename)
        {
                if(*iter=="--append")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       filename=*iter;
-                       arg_list.erase(iter);
+                       filename = extract_parameter(arg_list, iter, next);
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
 
        return SYNFIGTOOL_OK;
@@ -802,14 +687,11 @@ int extract_outfile(arg_list_t &arg_list,string &outfile)
        {
                if(*iter=="-o")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       outfile=*iter;
-                       arg_list.erase(iter);
+                       outfile = extract_parameter(arg_list, iter, next);
                        ret=SYNFIGTOOL_OK;
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
 
        return ret;
@@ -824,13 +706,10 @@ int extract_canvasid(arg_list_t &arg_list,string &canvasid)
        {
                if(*iter=="-c")
                {
-                       arg_list.erase(iter);
-                       iter=next++;
-                       canvasid=*iter;
-                       arg_list.erase(iter);
+                       canvasid = extract_parameter(arg_list, iter, next);
                }
                else if (flag_requires_value(*iter))
-                       iter=next++;
+                       iter++;
        }
 
        return SYNFIGTOOL_OK;
@@ -840,7 +719,8 @@ int extract_list_canvases(arg_list_t &arg_list,bool &list_canvases)
 {
        arg_list_t::iterator iter, next;
 
-       for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++)
+       for(next=arg_list.begin(), iter = next++; iter!=arg_list.end();
+               iter = next++)
                if(*iter=="--list-canvases")
                {
                        list_canvases = true;
@@ -858,10 +738,7 @@ void extract_canvas_info(arg_list_t &arg_list, Job &job)
                if(*iter=="--canvas-info")
                {
                        job.canvas_info = true;
-                       arg_list.erase(iter);
-                       iter=next++;
-                       String values(*iter), value;
-                       arg_list.erase(iter);
+                       String values(extract_parameter(arg_list, iter, next)), value;
 
                        std::string::size_type pos;
                        while (!values.empty())
@@ -1292,6 +1169,32 @@ int main(int argc, char *argv[])
                                }
                        }
 
+                       TargetParam target_parameters;
+                       // Extract the extra parameters for the targets that
+                       // need them.
+                       if (target_name == "ffmpeg")
+                       {
+                               int status;
+                               status = extract_target_params(imageargs, target_parameters);
+                               if (status == SYNFIGTOOL_UNKNOWNARGUMENT)
+                               {
+                                       cerr << strprintf(_("Unknown target video codec: %s."),
+                                                                        target_parameters.video_codec.c_str())
+                                                << endl;
+                                       cerr << _("Available target video codecs are:")
+                                                << endl;
+                                       display_target_video_codecs_help();
+
+                                       return SYNFIGTOOL_UNKNOWNARGUMENT;
+                               }
+                               else if (status == SYNFIGTOOL_MISSINGARGUMENT)
+                               {
+                                       cerr << _("Missing argument: \"-vb\".") << endl;
+
+                                       return SYNFIGTOOL_MISSINGARGUMENT;
+                               }
+                       }
+
                        // If the target type is STILL not yet defined, then
                        // set it to a some sort of default
                        if(target_name.empty())
@@ -1316,7 +1219,10 @@ int main(int argc, char *argv[])
                        VERBOSE_OUT(4)<<"outfile_name="<<job_list.front().outfilename<<endl;
 
                        VERBOSE_OUT(4)<<_("Creating the target...")<<endl;
-                       job_list.front().target=synfig::Target::create(target_name,job_list.front().outfilename);
+                       job_list.front().target =
+                               synfig::Target::create(target_name,
+                                                                          job_list.front().outfilename,
+                                                                          target_parameters);
 
                        if(target_name=="sif")
                                job_list.front().sifout=true;
diff --git a/synfig-core/src/tool/progress.h b/synfig-core/src/tool/progress.h
new file mode 100644 (file)
index 0000000..76ce97e
--- /dev/null
@@ -0,0 +1,70 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/progress.h
+**     \brief Progress class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_PROGRESS_H
+#define __SYNFIG_PROGRESS_H
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+#include <synfig/string.h>
+#include "definitions.h"
+
+class Progress : public synfig::ProgressCallback
+{
+       const char *program;
+
+public:
+
+       Progress(const char *name):program(name) { }
+
+       virtual bool
+       task(const String &task)
+       {
+               VERBOSE_OUT(1)<<program<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       error(const String &task)
+       {
+               std::cerr<<program<<": "<<_("error")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       warning(const String &task)
+       {
+               std::cerr<<program<<": "<<_("warning")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       amount_complete(int /*current*/, int /*total*/)
+       {
+               return true;
+       }
+};
+
+#endif
diff --git a/synfig-core/src/tool/renderprogress.h b/synfig-core/src/tool/renderprogress.h
new file mode 100644 (file)
index 0000000..34aee80
--- /dev/null
@@ -0,0 +1,141 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file tool/renderprogress.h
+**     \brief RenderProgress class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+#ifndef __SYNFIG_RENDERPROGRESS_H
+#define __SYNFIG_RENDERPROGRESS_H
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+#include <synfig/string.h>
+#include "definitions.h"
+
+class RenderProgress : public synfig::ProgressCallback
+{
+       string taskname;
+
+       etl::clock clk;
+       int clk_scanline; // The scanline at which the clock was reset
+       etl::clock clk2;
+
+       float last_time;
+public:
+
+       RenderProgress():clk_scanline(0), last_time(0) { }
+
+       virtual bool
+       task(const String &thetask)
+       {
+               taskname=thetask;
+               return true;
+       }
+
+       virtual bool
+       error(const String &task)
+       {
+               std::cout<<_("error")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       warning(const String &task)
+       {
+               std::cout<<_("warning")<<": "<<task<<std::endl;
+               return true;
+       }
+
+       virtual bool
+       amount_complete(int scanline, int h)
+       {
+               if(be_quiet)return true;
+               if(scanline!=h)
+               {
+                       const float time(clk()*(float)(h-scanline)/(float)(scanline-clk_scanline));
+                       const float delta(time-last_time);
+
+                       int weeks=0,days=0,hours=0,minutes=0,seconds=0;
+
+                       last_time=time;
+
+                       if(clk2()<0.2)
+                               return true;
+                       clk2.reset();
+
+                       if(scanline)
+                               seconds=(int)time+1;
+                       else
+                       {
+                               //cerr<<"reset"<<endl;
+                               clk.reset();
+                               clk_scanline=scanline;
+                       }
+
+                       if(seconds<0)
+                       {
+                               clk.reset();
+                               clk_scanline=scanline;
+                               seconds=0;
+                       }
+                       while(seconds>=60)
+                               minutes++,seconds-=60;
+                       while(minutes>=60)
+                               hours++,minutes-=60;
+                       while(hours>=24)
+                               days++,hours-=24;
+                       while(days>=7)
+                               weeks++,days-=7;
+
+                       cerr<<taskname<<": "<<_("Line")<<" "<<scanline<<_(" of ")<<h<<" -- ";
+                       //cerr<<time/(h-clk_scanline)<<" ";
+                       /*
+                       if(delta>=-time/(h-clk_scanline)  )
+                               cerr<<">";
+                       */
+                       if(delta>=0 && clk()>4.0 && scanline>clk_scanline+200)
+                       {
+                               //cerr<<"reset"<<endl;
+                               clk.reset();
+                               clk_scanline=scanline;
+                       }
+
+                       if(weeks)
+                               cerr<<weeks<<"w ";
+                       if(days)
+                               cerr<<days<<"d ";
+                       if(hours)
+                               cerr<<hours<<"h ";
+                       if(minutes)
+                               cerr<<minutes<<"m ";
+                       if(seconds)
+                               cerr<<seconds<<"s ";
+
+                       cerr<<"           \r";
+               }
+               else
+                       cerr<<taskname<<": "<<_("DONE")<<"                        "<<endl;;
+               return true;
+       }
+};
+
+#endif
index c5cc73d..384a865 100644 (file)
@@ -68,6 +68,7 @@ DIALOG_HH = \
        dialog_preview.h \
        dialog_setup.h \
        dialog_soundselect.h \
+       dialog_targetparam.h \
        dialog_waypoint.h
 
 DIALOG_CC = \
@@ -77,6 +78,7 @@ DIALOG_CC = \
        dialog_preview.cpp \
        dialog_setup.cpp \
        dialog_soundselect.cpp \
+       dialog_targetparam.cpp \
        dialog_waypoint.cpp
 
 
diff --git a/synfig-studio/src/gtkmm/dialog_targetparam.cpp b/synfig-studio/src/gtkmm/dialog_targetparam.cpp
new file mode 100644 (file)
index 0000000..29cce71
--- /dev/null
@@ -0,0 +1,150 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_targetparam.cpp
+**     \brief Implementation for the TargetParam Dialog
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2010 Carlos López González
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dialog_targetparam.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+//! Allowed video codecs
+/*! \warning This variable is linked to allowed_video_codecs_description,
+ *  if you change this you must change the other acordingly.
+ *  \warning These codecs are linked to the filename extensions for
+ *  mod_ffmpeg. If you change this you must change the others acordingly.
+ */
+const char* allowed_video_codecs[] =
+{
+       "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
+       "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
+       "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
+};
+
+//! Allowed video codecs description.
+/*! \warning This variable is linked to allowed_video_codecs,
+ *  if you change this you must change the other acordingly.
+ */
+const char* allowed_video_codecs_description[] =
+{
+       "Flash Video (FLV) / Sorenson Spark / Sorenson H.263.",
+       "H.263+ / H.263-1998 / H.263 version 2.",
+       "Huffyuv / HuffYUV.",
+       "libtheora Theora.",
+       "libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10.",
+       "libxvidcore MPEG-4 part 2.",
+       "MJPEG (Motion JPEG).",
+       "raw MPEG-1 video.",
+       "raw MPEG-2 video.",
+       "MPEG-4 part 2.",
+       "MPEG-4 part 2 Microsoft variant version 3.",
+       "MPEG-4 part 2 Microsoft variant version 1.",
+       "MPEG-4 part 2 Microsoft variant version 2.",
+       "Windows Media Video 7.",
+       "Windows Media Video 8.",
+       NULL
+};
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+Dialog_TargetParam::Dialog_TargetParam(synfig::TargetParam &tparam)
+{
+       set_title("TargetParam Dialog");
+       set_tparam(tparam);
+       // Available Video Codecs Combo Box Text.
+       vcodec = Gtk::manage(new Gtk::ComboBoxText());
+       Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:"))));
+       label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       get_vbox()->pack_start(*label, true, true, 0);
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               vcodec->append_text(allowed_video_codecs_description[i]);
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               if(!get_tparam().video_codec.compare(allowed_video_codecs[i]))
+                       vcodec->set_active_text(allowed_video_codecs_description[i]);
+
+       get_vbox()->pack_start(*vcodec, true, true, 0);
+
+       //Bitrate Spin Button
+       Gtk::Adjustment* bradj(manage(new class Gtk::Adjustment(double(tparam.bitrate), 10.0,1000.0)));
+       bitrate = Gtk::manage(new class Gtk::SpinButton(*bradj));
+       Gtk::Label* label2(manage(new Gtk::Label(_("Video Bit Rate:"))));
+       label2->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       get_vbox()->pack_start(*label2, true, true, 0);
+       get_vbox()->pack_start(*bitrate,true, true, 0);
+
+       get_vbox()->show_all();
+
+       ok_button = manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+       ok_button->show();
+       add_action_widget(*ok_button,Gtk::RESPONSE_OK);
+       ok_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_ok));
+
+       cancel_button = manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+       cancel_button->show();
+       add_action_widget(*cancel_button,Gtk::RESPONSE_CANCEL);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_cancel));
+
+}
+
+void
+Dialog_TargetParam::on_ok()
+{
+       std::string codecnamed = vcodec->get_active_text();
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               if(!codecnamed.compare(allowed_video_codecs_description[i]))
+                       tparam_.video_codec=allowed_video_codecs[i];
+       tparam_.bitrate=bitrate->get_value();
+       hide();
+}
+
+void
+Dialog_TargetParam::on_cancel()
+{
+       hide();
+}
+
+Dialog_TargetParam::~Dialog_TargetParam()
+{
+}
+
diff --git a/synfig-studio/src/gtkmm/dialog_targetparam.h b/synfig-studio/src/gtkmm/dialog_targetparam.h
new file mode 100644 (file)
index 0000000..8fa8cfb
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_targetparam.h
+**     \brief Targetparam Dialog Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2010 Carlos López González
+**
+**     This package is free software; you can redistribute it and/or
+**     modify it under the terms of the GNU General Public License as
+**     published by the Free Software Foundation; either version 2 of
+**     the License, or (at your option) any later version.
+**
+**     This package is distributed in the hope that it will be useful,
+**     but WITHOUT ANY WARRANTY; without even the implied warranty of
+**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+**     General Public License for more details.
+**     \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_DIALOG_TARGETPARAM_H
+#define __SYNFIG_STUDIO_DIALOG_TARGETPARAM_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/dialog.h>
+#include <gtkmm/button.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/spinbutton.h>
+
+#include <synfig/targetparam.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace studio {
+
+class Dialog_TargetParam : public Gtk::Dialog
+{
+       synfig::TargetParam tparam_;
+       Gtk::Button *ok_button;
+       Gtk::Button *cancel_button;
+       Gtk::SpinButton *bitrate;
+       Gtk::ComboBoxText *vcodec;
+
+       void on_ok();
+       void on_cancel();
+
+public:
+       Dialog_TargetParam(synfig::TargetParam &tparam);
+       ~Dialog_TargetParam();
+
+       synfig::TargetParam get_tparam() const { return tparam_; }
+       void set_tparam(const synfig::TargetParam &tp) {tparam_=tp; }
+
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
+
+
+
index cec4215..e958682 100644 (file)
@@ -37,6 +37,7 @@
 #include <synfig/target_scanline.h>
 #include <synfig/canvas.h>
 #include "asyncrenderer.h"
+#include "dialog_targetparam.h"
 
 #include "general.h"
 
@@ -66,7 +67,8 @@ RenderSettings::RenderSettings(Gtk::Window& parent, etl::handle<synfigapp::Canva
        entry_quality(adjustment_quality,1,0),
        adjustment_antialias(1,1,31),
        entry_antialias(adjustment_antialias,1,0),
-       toggle_single_frame(_("Use _current frame"), true)
+       toggle_single_frame(_("Use _current frame"), true),
+       tparam("libxvid",200)
 {
        widget_rend_desc.show();
        widget_rend_desc.signal_changed().connect(sigc::mem_fun(*this,&studio::RenderSettings::on_rend_desc_changed));
@@ -104,6 +106,10 @@ RenderSettings::RenderSettings(Gtk::Window& parent, etl::handle<synfigapp::Canva
        choose_button->show();
        choose_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_choose_pressed));
 
+       Gtk::Button *tparam_button(manage(new class Gtk::Button(Gtk::StockID(_("Parameters...")))));
+       tparam_button->show();
+       tparam_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_targetparam_pressed));
+
        Gtk::Frame *target_frame=manage(new Gtk::Frame(_("Target")));
        target_frame->set_shadow_type(Gtk::SHADOW_NONE);
        ((Gtk::Label *) target_frame->get_label_widget())->set_markup(_("<b>Target</b>"));
@@ -128,7 +134,8 @@ RenderSettings::RenderSettings(Gtk::Window& parent, etl::handle<synfigapp::Canva
        targetLabel->set_alignment(0, 0.5);
        targetLabel->set_mnemonic_widget(optionmenu_target);
        target_table->attach(*targetLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       target_table->attach(optionmenu_target, 1, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       target_table->attach(optionmenu_target, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       target_table->attach(*tparam_button, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
 
        toggle_single_frame.signal_toggled().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_single_frame_toggle));
 
@@ -239,6 +246,16 @@ RenderSettings::on_choose_pressed()
 }
 
 void
+RenderSettings::on_targetparam_pressed()
+{
+       Dialog_TargetParam *dialogtp = new Dialog_TargetParam(tparam);
+       if(dialogtp->run()==Gtk::RESPONSE_OK)
+               tparam=dialogtp->get_tparam();
+
+       delete dialogtp;
+}
+
+void
 RenderSettings::on_render_pressed()
 {
        String filename=entry_filename.get_text();
@@ -283,7 +300,7 @@ RenderSettings::on_render_pressed()
                return;
        }
 
-       Target::Handle target=Target::create(calculated_target_name,filename);
+       Target::Handle target=Target::create(calculated_target_name,filename, tparam);
        if(!target)
        {
                canvas_interface_->get_ui_interface()->error(_("Unable to create target for ")+filename);
index 0a6263a..729251b 100644 (file)
@@ -39,6 +39,7 @@
 #include <gtkmm/optionmenu.h>
 
 #include <synfig/string.h>
+#include <synfig/targetparam.h>
 
 #include <synfigapp/canvasinterface.h>
 
@@ -80,6 +81,8 @@ class RenderSettings : public Gtk::Dialog
 
        etl::handle<AsyncRenderer> async_renderer;
 
+       synfig::TargetParam tparam;
+
 public:
        RenderSettings(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
        ~RenderSettings();
@@ -92,6 +95,7 @@ private:
        void on_choose_pressed();
        void on_render_pressed();
        void on_cancel_pressed();
+       void on_targetparam_pressed();
 
        void on_finished();
 }; // END of class RenderSettings