Module: synfig
Branch: eldruin_ffmpeg2
Commit: ee0cc78c52143c3f4739076a3b3dff6e3106ecd8
URL:    
http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=ee0cc78c52143c3f4739076a3b3dff6e3106ecd8

Author: Diego Barrios Romero <eldr...@gmailcom>
Date:   Mon Feb 22 01:03:56 2010 +0100

Allowed video codecs check and improved parameters check.

---

 synfig-core/src/tool/main.cpp |   61 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/synfig-core/src/tool/main.cpp b/synfig-core/src/tool/main.cpp
index 409bd1a..7894651 100644
--- a/synfig-core/src/tool/main.cpp
+++ b/synfig-core/src/tool/main.cpp
@@ -539,6 +539,7 @@ int extract_target(arg_list_t &arg_list,string &type)
                if(*iter=="-t")
                {
                        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++;
@@ -550,6 +551,10 @@ int extract_target(arg_list_t &arg_list,string &type)
 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++)
@@ -558,18 +563,53 @@ int extract_target_params(arg_list_t& arg_list,
                {
                        // Target video codec
                        params.video_codec = extract_parameter(arg_list, iter, 
next);
+                       const char* allowed_video_codecs[] =
+                       {
+                               "flv", "gif", "h261", "h263", "h263p", 
"huffyuv",
+                               "libtheora", "libx264", "libxvid", "ljpeg", 
"mjpeg",
+                               "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
+                               "msmpeg4v1", "msmpegv2", "wmv1", "wmv2", NULL
+                       };
+
+                       // 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++;
        }
 
-       return SYNFIGTOOL_OK;
+       if (need_bitrate_parameter)
+               ret = SYNFIGTOOL_MISSINGARGUMENT;
+
+       return ret;
 }
 
 int extract_append(arg_list_t &arg_list,string &filename)
@@ -1086,7 +1126,24 @@ int main(int argc, char *argv[])
                        // Extract the extra parameters for the targets that
                        // need them.
                        if (target_name == "ffmpeg")
-                               extract_target_params(imageargs, 
target_parameters);
+                       {
+                               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;
+
+                                       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


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to