gimp-gap r811 - in trunk: . gap libgapvidutil vid_common vid_enc_avi vid_enc_ffmpeg



Author: wolfgangh
Date: Fri Feb 13 19:04:39 2009
New Revision: 811
URL: http://svn.gnome.org/viewvc/gimp-gap?rev=811&view=rev

Log:
updated ffmpeg based encoder, build relevant fixes (relevant for #571444)

Added:
   trunk/gap/gap_decode_mplayer_main.c   (contents, props changed)
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/gap/Makefile.am
   trunk/gap/gap_frontends_main.c
   trunk/gap/gap_morph_dialog.c
   trunk/gap/gap_mov_dialog.c
   trunk/gap/gap_vex_dialog.c
   trunk/libgapvidutil/gap_gve_misc_util.c
   trunk/libgapvidutil/gap_gve_misc_util.h
   trunk/vid_common/gap_cme_gui.c
   trunk/vid_enc_avi/gap_enc_avi_gui.c
   trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_callbacks.c
   trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_gui.c
   trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
   trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.h
   trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_par.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Feb 13 19:04:39 2009
@@ -99,25 +99,24 @@
 dnl Test for unix-frontends
 dnl -----------------------
 AC_ARG_ENABLE(unixfrontends,
-              [  --disable-unix-frontends     don't build with UNIX specific frontends for mplayer, xanim and mpeg encoders])
-  dnl disable unix frontends per default on win32 systems (unless explicte specified yes)
-  if test "x$enable_unix_frontends" != "xyes"; then
+              [  --enable-unix-frontends     build with UNIX specific frontends for OLD programs xanim and mpeg encoders])
+  if test "x$enable_unix_frontends" = "xyes"; then
+
+    dnl disable unix frontends per default on win32 systems (unless explicte specified yes)
     if test "x$os_win32" = "xyes"; then
        enable_unix_frontends=no
+       frontends_warning="
+WARNING: the --enable-unix-frontends is ignored on  Windows build
+"
+    else
+       frontends_warning="
+gimp-gap is configured with Linux/UNIX specific frontends for OLD  xanim
+and OLD mpeg encoders.
+"
     fi
-  fi
 
-  if test "x$enable_unix_frontends" != "xno"; then
-    frontends_warning="
-gimp-gap is configured with Linux/UNIX specific frontends for mplayer, xanim
-and mpeg encoders. Non Linux/UNIX users should run configure with
-the --disable-unix-frontends option.
-"
   else
-    frontends_warning="
-The Linux/UNIX specific frontends for mplayer, xanim and mpeg encoders will
-not be built. This is OK for non Linux/UNIX users.
-"
+     enable_unix_frontends=no
   fi
 
 AM_CONDITIONAL(GAP_UNIX_FRONTENDS, test "x$enable_unix_frontends" != "xno")
@@ -305,11 +304,28 @@
 build_ffmpeg_libs_yesno="no"
 
 
+moved_old_ffmpeg_warn=""
 AC_ARG_ENABLE(libavformat,
               [  --disable-libavformat        don't build with libavformat/libavcodec/libavutil])
   if test "x$enable_libavformat" != "xno"; then
     dnl
 
+    dnl check if old version off ffmpeg is already there 
+    dnl (typically for already existing svn build after 1st svn update to new version)
+
+    FF_FILE_AVCODEC_H="$FFMPEG_DIR/libavcodec/avcodec.h"
+
+    if test -f "$FF_FILE_AVCODEC_H"; then
+      if  grep '#define LIBAVCODEC_VERSION      51.47.2' $FF_FILE_AVCODEC_H >/dev/null; then
+        mv "$FFMPEG_DIR" "$FFMPEG_DIR-OLD"
+        echo "** UPDATE of ffmpeg forced, moving $FFMPEG_DIR  to $FFMPEG_DIR-OLD"
+        moved_old_ffmpeg_warn="
+INFORMATION: old ffmpeg was moved to $FFMPEG_DIR-OLD
+(you may delete the old ffmpeg directory)
+"
+      fi
+    fi
+
     AC_DEFINE(ENABLE_GVA_LIBAVFORMAT, 1,
               [Define to 1 to enable compile and link with libavformat])
     dnl
@@ -651,6 +667,28 @@
     dnl requirement in its configuration script.
     dnl
 
+    dnl check if old version off ffmpeg is already there 
+    dnl (typically for already existing svn build after 1st svn update to new version)
+
+    LIBMPEG3_PRIVATE_H="$LMPEG3_DIR/mpeg3private.h"
+
+    if test -f "$LIBMPEG3_PRIVATE_H"; then
+      if  grep '#define MPEG3_MAJOR   1' $LIBMPEG3_PRIVATE_H >/dev/null; then
+        if  grep '#define MPEG3_MINOR   5' $LIBMPEG3_PRIVATE_H >/dev/null; then
+         if  grep '#define MPEG3_RELEASE 4' $LIBMPEG3_PRIVATE_H >/dev/null; then
+           mv "$LMPEG3_DIR" "$LMPEG3_DIR-OLD"
+           echo "** UPDATE of libmpeg3 forced, moving $LMPEG3_DIR  to $LMPEG3_DIR-OLD"
+           moved_old_libmpeg3_warn="
+INFORMATION: old libmpeg3 was moved to  $LMPEG3_DIR-OLD
+(you may delete the old libmpeg3 directory)
+"
+          fi
+        fi
+      fi
+    fi
+
+
+
     if test "x$pthread_err" != "x"; then
       enable_libmpeg3="no"
       vid_mpeg3_warning="
@@ -820,9 +858,15 @@
 
 
 dnl Test for audiosupport
+dnl audiosupport currently is based on wavplay that is available on UNIX systems
+dnl (the wavplay client does not compile on Windows)
 dnl ------------------------
 AC_ARG_ENABLE(audiosupport,
               [  --disable-audio-support      don't build with audio support])
+  if test "x$os_win32" = "xyes"; then
+     enable_audio_support=no
+  fi
+
   if test "x$enable_audio_support" != "xno"; then
     AC_CHECK_PROG(WAVPLAY_SERVER, wavplay, yes, no)
       if test $WAVPLAY_SERVER = no; then
@@ -930,4 +974,4 @@
 docs/reference/txt/Makefile
 ])
 
-AC_MSG_RESULT($frontends_warning $audio_warning $videoapi_warning $vid_ffmpeg_warning $vid_mpeg3_warning $vid_quicktime_warning $vid_xvidcore_warning)
+AC_MSG_RESULT($frontends_warning $audio_warning $videoapi_warning $moved_old_ffmpeg_warn $moved_old_libmpeg3_warn $vid_ffmpeg_warning $vid_mpeg3_warning $vid_quicktime_warning $vid_xvidcore_warning)

Modified: trunk/gap/Makefile.am
==============================================================================
--- trunk/gap/Makefile.am	(original)
+++ trunk/gap/Makefile.am	Fri Feb 13 19:04:39 2009
@@ -10,6 +10,8 @@
 GAP_FRONTENDS = gap_frontends
 endif
 
+GAP_DECODE_MPLAYER_FRONTEND = gap_decode_mplayer
+
 if GAP_AUDIO_SUPPORT
 WAVPLAYCLIENT = $(top_builddir)/libwavplayclient/libwavplayclient.a
 endif
@@ -95,6 +97,7 @@
 	gap_fmac		\
 	gap_fmac_varying	\
 	$(GAP_FRONTENDS)	\
+	$(GAP_DECODE_MPLAYER_FRONTEND)	\
 	gap_morph		\
 	gap_name2layer		\
 	gap_navigator_dialog	\
@@ -220,8 +223,6 @@
 	gap_libgimpgap.h	
 
 gap_frontends_SOURCES = \
-	gap_decode_mplayer.c	\
-	gap_decode_mplayer.h	\
 	gap_decode_xanim.c	\
 	gap_decode_xanim.h	\
 	gap_frontends_main.c	\
@@ -229,6 +230,12 @@
 	gap_mpege.h		\
 	gap_libgimpgap.h	
 
+gap_decode_mplayer_SOURCES = \
+	gap_decode_mplayer_main.c	\
+	gap_decode_mplayer.c	\
+	gap_decode_mplayer.h	\
+	gap_libgimpgap.h	
+
 #  gap_morph_SOURCES: gap_mov_exec.h should be removed when finished coding
 gap_morph_SOURCES = \
 	gap_morph_main.c	\
@@ -393,6 +400,7 @@
 gap_fmac_LDADD =             $(GAPVIDEOAPI) $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)
 gap_fmac_varying_LDADD =     $(GAPVIDEOAPI) $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)
 gap_frontends_LDADD =        $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)
+gap_decode_mplayer_LDADD =   $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)
 gap_morph_LDADD =            $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)
 gap_name2layer_LDADD =       $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)
 gap_navigator_dialog_LDADD = $(LIBGIMPGAP)  $(LIBGAPBASE) $(GIMP_LIBS)

Added: trunk/gap/gap_decode_mplayer_main.c
==============================================================================
--- (empty file)
+++ trunk/gap/gap_decode_mplayer_main.c	Fri Feb 13 19:04:39 2009
@@ -0,0 +1,254 @@
+/* gap_decode_mplayer_main.c
+ * 2009.02.12 hof (Wolfgang Hofer)
+ *
+ * GAP ... Gimp Animation Package
+ *
+ * This Module contains:
+ * - MAIN of frontend for the external program mplayer
+ *     that can be used to extract frames from videofiles
+ * 
+ *
+ */
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * This program 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 program 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* revision history:
+ * gimp    2.1.0;   2004/12/06  hof: added gap_decode_mplayer
+ * gimp    1.1.29b; 2000/11/25  hof: use gap lock procedures, update e-mail adress + main version
+ * gimp    1.1.11b; 1999/11/20  hof: added gap_decode_xanim, fixed typo in mpeg encoder menu path
+ *                                   based on parts that were found in gap_main.c before.
+ */
+ 
+/* SYTEM (UNIX) includes */ 
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+/* GIMP includes */
+#include "gtk/gtk.h"
+#include "config.h"
+#include "gap-intl.h"
+#include "libgimp/gimp.h"
+
+/* GAP includes */
+#include "gap_lib.h"
+#include "gap_decode_mplayer.h"
+#include "gap_arr_dialog.h"
+#include "gap_lock.h"
+
+/* ------------------------
+ * global gap DEBUG switch
+ * ------------------------
+ */
+
+/* int gap_debug = 1; */    /* print debug infos */
+/* int gap_debug = 0; */    /* 0: dont print debug infos */
+
+int gap_debug = 0;
+
+
+static void query(void);
+static void run(const gchar *name
+              , gint n_params
+	      , const GimpParam *param
+              , gint *nreturn_vals
+	      , GimpParam **return_vals);
+
+GimpPlugInInfo PLUG_IN_INFO =
+{
+  NULL,  /* init_proc */
+  NULL,  /* quit_proc */
+  query, /* query_proc */
+  run,   /* run_proc */
+};
+
+MAIN ()
+
+static void
+query ()
+{
+  static GimpParamDef args_mplayer[] =
+  {
+    {GIMP_PDB_INT32, "run_mode", "Interactive"},
+    {GIMP_PDB_IMAGE, "image", "(unused)"},
+    {GIMP_PDB_DRAWABLE, "drawable", "(unused)"},
+  };
+
+  static GimpParamDef args_mplayer_ext[] =
+  {
+    {GIMP_PDB_INT32, "run_mode", "Interactive"},
+  };
+
+
+  static GimpParamDef *return_vals = NULL;
+  static int nreturn_vals = 0;
+
+  gimp_plugin_domain_register (GETTEXT_PACKAGE, LOCALEDIR);
+
+  gimp_install_procedure(GAP_MPLAYER_PLUGIN_NAME,
+			 "This plugin calls mplayer to split any video to video frames. "
+			 "MPlayer 1.0 must be installed on your system.",
+			 "",
+			 "Wolfgang Hofer (hof gimp org)",
+			 "Wolfgang Hofer",
+			 GAP_VERSION_WITH_DATE,
+			 N_("MPlayer based extraction..."),
+			 NULL,
+			 GIMP_PLUGIN,
+			 G_N_ELEMENTS (args_mplayer), nreturn_vals,
+			 args_mplayer, return_vals);
+
+  gimp_install_procedure(GAP_MPLAYER_PLUGIN_NAME_TOOLBOX,
+			 "This plugin calls mplayer to split any video to video frames. "
+			 "MPlayer 1.0 must be installed on your system.",
+			 "",
+			 "Wolfgang Hofer (hof gimp org)",
+			 "Wolfgang Hofer",
+			 GAP_VERSION_WITH_DATE,
+			 N_("MPlayer based extraction..."),
+			 NULL,
+			 GIMP_PLUGIN,
+			 G_N_ELEMENTS (args_mplayer_ext), nreturn_vals,
+			 args_mplayer_ext, return_vals);
+
+
+  {
+    /* Menu names */
+    const char *menupath_image_video_split = N_("<Image>/Video/Split Video into Frames/");
+    const char *menupath_toolbox_video_split = N_("<Toolbox>/Xtns/Split Video into Frames/");
+
+    //gimp_plugin_menu_branch_register("<Image>", "Video");
+    //gimp_plugin_menu_branch_register("<Image>/Video", "Split Video into Frames");
+
+    //gimp_plugin_menu_branch_register("<Toolbox>", "Video");
+    //gimp_plugin_menu_branch_register("<Toolbox>/Video", "Split Video into Frames");
+
+    gimp_plugin_menu_register (GAP_MPLAYER_PLUGIN_NAME, menupath_image_video_split);
+    gimp_plugin_menu_register (GAP_MPLAYER_PLUGIN_NAME_TOOLBOX, menupath_toolbox_video_split);
+  }
+
+}	/* end query */
+
+
+
+static void run(const gchar *name
+              , gint n_params
+	      , const GimpParam *param
+              , gint *nreturn_vals
+	      , GimpParam **return_vals)
+{
+  const char *l_env;
+  
+  char        l_extension[32];
+  static GimpParam values[2];
+  GimpRunMode run_mode;
+  GimpPDBStatusType status = GIMP_PDB_SUCCESS;
+  gint32     image_id;
+  gint32     lock_image_id;
+  gint32     nr;
+   
+  gint32     l_rc;
+
+  *nreturn_vals = 1;
+  *return_vals = values;
+  nr = 0;
+  l_rc = 0;
+
+  INIT_I18N ();
+
+  l_env = g_getenv("GAP_DEBUG");
+  if(l_env != NULL)
+  {
+    if((*l_env != 'n') && (*l_env != 'N')) gap_debug = 1;
+  }
+
+  run_mode = param[0].data.d_int32;
+  image_id = -1;
+  lock_image_id = image_id;
+
+  if(gap_debug) fprintf(stderr, "\n\ngap_main: debug name = %s\n", name);
+
+  
+  if ((strcmp (name, GAP_MPLAYER_PLUGIN_NAME) == 0)
+  ||  (strcmp (name, GAP_MPLAYER_PLUGIN_NAME_TOOLBOX) == 0))
+  {
+      GapMPlayerParams mplayer_gpp;
+      GapMPlayerParams *gpp;
+      
+      /* only the INTERACTIVE runmode is supported, 
+       * extracting frames in batch mode can be done outside the gimp
+       * (mplayer has excellent commandline support)
+       */
+      if (run_mode == GIMP_RUN_NONINTERACTIVE)
+      {
+          status = GIMP_PDB_CALLING_ERROR;
+      }
+
+      if (status == GIMP_PDB_SUCCESS)
+      {
+        gpp = &mplayer_gpp;
+	
+	/* setup default values (for the 1.st call per session) */
+        gpp->video_filename[0] = '\0';
+        gpp->audio_filename[0] = '\0';
+	gpp->number_of_frames  = 100;
+	gpp->vtrack            = 1;
+	gpp->atrack            = 1;
+	gpp->png_compression   = 0;
+	gpp->jpg_quality       = 86;
+	gpp->jpg_optimize      = 100;
+	gpp->jpg_smooth        = 0;
+	gpp->jpg_progressive   = FALSE;
+	gpp->jpg_baseline      = TRUE;
+        gpp->start_hour        = 0;
+        gpp->start_minute      = 0;
+        gpp->start_second      = 0;
+
+	gpp->img_format        = MPENC_JPEG;
+	gpp->silent            = FALSE;
+	gpp->autoload          = TRUE;
+	gpp->run_mplayer_asynchron = TRUE;
+	
+        g_snprintf(gpp->basename, sizeof(gpp->basename), "frame_");
+
+	gimp_get_data(GAP_MPLAYER_PLUGIN_NAME, gpp);
+        mplayer_gpp.run_mode = run_mode;
+	
+        l_rc = gap_mplayer_decode(gpp);
+	
+	gimp_set_data(GAP_MPLAYER_PLUGIN_NAME, gpp, sizeof(mplayer_gpp));
+      }
+  }
+
+  /* ---------- return handling --------- */
+
+  if(l_rc < 0)
+  {
+    status = GIMP_PDB_EXECUTION_ERROR;
+  }
+ 
+  
+  if (run_mode != GIMP_RUN_NONINTERACTIVE)
+  {
+    gimp_displays_flush();
+  }
+  
+  values[0].type = GIMP_PDB_STATUS;
+  values[0].data.d_status = status;
+
+}

Modified: trunk/gap/gap_frontends_main.c
==============================================================================
--- trunk/gap/gap_frontends_main.c	(original)
+++ trunk/gap/gap_frontends_main.c	Fri Feb 13 19:04:39 2009
@@ -42,6 +42,10 @@
  */
 
 /* revision history:
+ * gimp    2.6.4;   2009/02/12  hof: moved gap_decode_mplayer to its own main program.
+ *                                   because all the other frontends are OLD and
+ *                                   will NO LONGER be installed per default but only on explicite
+ *                                   configuration request.
  * gimp    2.1.0;   2004/12/06  hof: added gap_decode_mplayer
  * gimp    1.1.29b; 2000/11/25  hof: use gap lock procedures, update e-mail adress + main version
  * gimp    1.1.11b; 1999/11/20  hof: added gap_decode_xanim, fixed typo in mpeg encoder menu path
@@ -63,7 +67,6 @@
 #include "gap_lib.h"
 #include "gap_mpege.h"
 #include "gap_decode_xanim.h"
-#include "gap_decode_mplayer.h"
 #include "gap_arr_dialog.h"
 #include "gap_lock.h"
 
@@ -103,18 +106,6 @@
 static void
 query ()
 {
-  static GimpParamDef args_mplayer[] =
-  {
-    {GIMP_PDB_INT32, "run_mode", "Interactive"},
-    {GIMP_PDB_IMAGE, "image", "(unused)"},
-    {GIMP_PDB_DRAWABLE, "drawable", "(unused)"},
-  };
-
-  static GimpParamDef args_mplayer_ext[] =
-  {
-    {GIMP_PDB_INT32, "run_mode", "Interactive"},
-  };
-
   static GimpParamDef args_xanim[] =
   {
     {GIMP_PDB_INT32, "run_mode", "Interactive"},
@@ -139,32 +130,6 @@
 
   gimp_plugin_domain_register (GETTEXT_PACKAGE, LOCALEDIR);
 
-  gimp_install_procedure(GAP_MPLAYER_PLUGIN_NAME,
-			 "This plugin calls mplayer to split any video to video frames. "
-			 "MPlayer 1.0 must be installed on your system.",
-			 "",
-			 "Wolfgang Hofer (hof gimp org)",
-			 "Wolfgang Hofer",
-			 GAP_VERSION_WITH_DATE,
-			 N_("MPlayer based extraction..."),
-			 NULL,
-			 GIMP_PLUGIN,
-			 G_N_ELEMENTS (args_mplayer), nreturn_vals,
-			 args_mplayer, return_vals);
-
-  gimp_install_procedure(GAP_MPLAYER_PLUGIN_NAME_TOOLBOX,
-			 "This plugin calls mplayer to split any video to video frames. "
-			 "MPlayer 1.0 must be installed on your system.",
-			 "",
-			 "Wolfgang Hofer (hof gimp org)",
-			 "Wolfgang Hofer",
-			 GAP_VERSION_WITH_DATE,
-			 N_("MPlayer based extraction..."),
-			 NULL,
-			 GIMP_PLUGIN,
-			 G_N_ELEMENTS (args_mplayer_ext), nreturn_vals,
-			 args_mplayer_ext, return_vals);
-
 
   gimp_install_procedure(GAP_XANIM_PLUGIN_NAME,
 			 "This plugin calls xanim to split any video to video frames. "
@@ -231,12 +196,10 @@
     //gimp_plugin_menu_branch_register("<Toolbox>/Video", "Encode");
     //gimp_plugin_menu_branch_register("<Toolbox>/Video", "Split Video into Frames");
 
-    gimp_plugin_menu_register (GAP_MPLAYER_PLUGIN_NAME, menupath_image_video_split);
     gimp_plugin_menu_register (GAP_XANIM_PLUGIN_NAME, menupath_image_video_split);
     gimp_plugin_menu_register (GAP_MPEG_ENCODE_PLUGIN_NAME, menupath_image_video_encode);
     gimp_plugin_menu_register (GAP_MPEG2_ENCODE_PLUGIN_NAME, menupath_image_video_encode);
 
-    gimp_plugin_menu_register (GAP_MPLAYER_PLUGIN_NAME_TOOLBOX, menupath_toolbox_video_split);
     gimp_plugin_menu_register (GAP_XANIM_PLUGIN_NAME_TOOLBOX, menupath_toolbox_video_split);
   }
 
@@ -301,57 +264,7 @@
     gap_lock_set_lock(lock_image_id);
   }
   
-  if ((strcmp (name, GAP_MPLAYER_PLUGIN_NAME) == 0)
-  ||  (strcmp (name, GAP_MPLAYER_PLUGIN_NAME_TOOLBOX) == 0))
-  {
-      GapMPlayerParams mplayer_gpp;
-      GapMPlayerParams *gpp;
-      
-      /* only the INTERACTIVE runmode is supported, 
-       * extracting frames in batch mode can be done outside the gimp
-       * (mplayer has excellent commandline support)
-       */
-      if (run_mode == GIMP_RUN_NONINTERACTIVE)
-      {
-          status = GIMP_PDB_CALLING_ERROR;
-      }
-
-      if (status == GIMP_PDB_SUCCESS)
-      {
-        gpp = &mplayer_gpp;
-	
-	/* setup default values (for the 1.st call per session) */
-        gpp->video_filename[0] = '\0';
-        gpp->audio_filename[0] = '\0';
-	gpp->number_of_frames  = 100;
-	gpp->vtrack            = 1;
-	gpp->atrack            = 1;
-	gpp->png_compression   = 0;
-	gpp->jpg_quality       = 86;
-	gpp->jpg_optimize      = 100;
-	gpp->jpg_smooth        = 0;
-	gpp->jpg_progressive   = FALSE;
-	gpp->jpg_baseline      = TRUE;
-        gpp->start_hour        = 0;
-        gpp->start_minute      = 0;
-        gpp->start_second      = 0;
-
-	gpp->img_format        = MPENC_JPEG;
-	gpp->silent            = FALSE;
-	gpp->autoload          = TRUE;
-	gpp->run_mplayer_asynchron = TRUE;
-	
-        g_snprintf(gpp->basename, sizeof(gpp->basename), "frame_");
-
-	gimp_get_data(GAP_MPLAYER_PLUGIN_NAME, gpp);
-        mplayer_gpp.run_mode = run_mode;
-	
-        l_rc = gap_mplayer_decode(gpp);
-	
-	gimp_set_data(GAP_MPLAYER_PLUGIN_NAME, gpp, sizeof(mplayer_gpp));
-      }
-  }
-  else if ((strcmp (name, GAP_XANIM_PLUGIN_NAME) == 0)
+  if ((strcmp (name, GAP_XANIM_PLUGIN_NAME) == 0)
   ||  (strcmp (name, GAP_XANIM_PLUGIN_NAME_TOOLBOX) == 0))
   {
       if (run_mode == GIMP_RUN_NONINTERACTIVE)

Modified: trunk/gap/gap_morph_dialog.c
==============================================================================
--- trunk/gap/gap_morph_dialog.c	(original)
+++ trunk/gap/gap_morph_dialog.c	Fri Feb 13 19:04:39 2009
@@ -3473,6 +3473,7 @@
                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                          GTK_STOCK_OK,     GTK_RESPONSE_OK,
                          NULL);
+  gtk_window_set_type_hint (dlg, GDK_WINDOW_TYPE_HINT_NORMAL);
 
   mgup->shell = dlg;
   mgup->src_win.startup_flag = TRUE;

Modified: trunk/gap/gap_mov_dialog.c
==============================================================================
--- trunk/gap/gap_mov_dialog.c	(original)
+++ trunk/gap/gap_mov_dialog.c	Fri Feb 13 19:04:39 2009
@@ -610,6 +610,7 @@
 #endif
   /* dialog */
   dlg = gtk_dialog_new ();
+  gtk_window_set_type_hint (dlg, GDK_WINDOW_TYPE_HINT_NORMAL);
   mgp->shell = dlg;
   mgp->first_nr = first_nr;
   mgp->last_nr = last_nr;

Modified: trunk/gap/gap_vex_dialog.c
==============================================================================
--- trunk/gap/gap_vex_dialog.c	(original)
+++ trunk/gap/gap_vex_dialog.c	Fri Feb 13 19:04:39 2009
@@ -2028,6 +2028,7 @@
 			 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 			 GTK_STOCK_OK,     GTK_RESPONSE_OK,
 			 NULL);
+  gtk_window_set_type_hint (mw__main_window, GDK_WINDOW_TYPE_HINT_NORMAL);
 
   g_signal_connect (G_OBJECT (mw__main_window), "response",
                     G_CALLBACK (on_mw_response),

Modified: trunk/libgapvidutil/gap_gve_misc_util.c
==============================================================================
--- trunk/libgapvidutil/gap_gve_misc_util.c	(original)
+++ trunk/libgapvidutil/gap_gve_misc_util.c	Fri Feb 13 19:04:39 2009
@@ -187,6 +187,7 @@
   encStatus->frames_processed = 0;
   encStatus->frames_encoded = 0;
   encStatus->frames_copied_lossless = 0;
+  encStatus->current_pass = 0;
 //  encStatus->pidOfRunningEncoder = 0;
 
   gap_gve_misc_do_master_encoder_progress(encStatus);

Modified: trunk/libgapvidutil/gap_gve_misc_util.h
==============================================================================
--- trunk/libgapvidutil/gap_gve_misc_util.h	(original)
+++ trunk/libgapvidutil/gap_gve_misc_util.h	Fri Feb 13 19:04:39 2009
@@ -55,6 +55,7 @@
   gint32 frames_processed;
   gint32 frames_encoded;
   gint32 frames_copied_lossless;
+  gint32 current_pass;          /* 0 for single pass encoders, 1 or 2 for two-pass encoder */
 } GapGveMasterEncoderStatus;
 
 

Modified: trunk/vid_common/gap_cme_gui.c
==============================================================================
--- trunk/vid_common/gap_cme_gui.c	(original)
+++ trunk/vid_common/gap_cme_gui.c	Fri Feb 13 19:04:39 2009
@@ -827,6 +827,10 @@
   gint32   tmin;
   gchar    txt[20];
 
+  if(lbl == NULL)
+  {
+    return;
+  }
 
   tms = tmsec % 1000;
   tsec = (tmsec / 1000) % 60;
@@ -865,6 +869,10 @@
   int         l_rc;
   gint32      tmsec;        /* audioplaytime in milli secs */
 
+  if ((lbl_info == NULL) || (lbl_time == NULL) || (lbl_time0))
+  {
+    return 0;
+  }
   if(*audioname == '\0')
   {
      p_print_time_label(lbl_time, 0);
@@ -971,9 +979,16 @@
  videoname = g_strdup_printf("%s%s", l_vid, &gpp->val.ecp_sel.video_extension[0]);
  g_snprintf(gpp->val.videoname, sizeof(gpp->val.videoname), "%s", videoname);
 
- gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_video), videoname);
- gtk_label_set_text(GTK_LABEL(gpp->cme__short_description)
+ if(gpp->cme__entry_video != NULL)
+ {
+   gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_video), videoname);
+ }
+ 
+ if(gpp->cme__short_description != NULL)
+ {
+   gtk_label_set_text(GTK_LABEL(gpp->cme__short_description)
                   , &gpp->val.ecp_sel.short_description[0]);
+ }
 
  g_free(l_vid);
  g_free(videoname);
@@ -1049,26 +1064,33 @@
   lbl_info_tmp = GTK_LABEL(gpp->cme__label_aud_tmp_info);
   lbl_tmp_audfile = GTK_LABEL(gpp->cme__label_tmp_audfile);
 
-  gtk_label_set_text(lbl_info, " ");
-
-  gpp->val.wav_samplerate1  =
-  p_update_aud_info(gpp, lbl_info, lbl_time, lbl_time0, gpp->val.audioname1);
+  if ((lbl_info != NULL)
+  &&  (lbl_time != NULL)
+  &&  (lbl_time0 != NULL)
+  &&  (lbl_time_tmp != NULL)
+  &&  (lbl_info_tmp != NULL)
+  &&  (lbl_tmp_audfile != NULL))
+  {
+    gtk_label_set_text(lbl_info, " ");
+
+    gpp->val.wav_samplerate1  =
+    p_update_aud_info(gpp, lbl_info, lbl_time, lbl_time0, gpp->val.audioname1);
+ 
+
+    gtk_label_set_text(lbl_time_tmp, " ");
+    gtk_label_set_text(lbl_info_tmp, " ");
+    gtk_label_set_text(lbl_tmp_audfile, " ");
 
-
-  gtk_label_set_text(lbl_time_tmp, " ");
-  gtk_label_set_text(lbl_info_tmp, " ");
-  gtk_label_set_text(lbl_tmp_audfile, " ");
-
-  if(gpp->val.tmp_audfile[0] != '\0')
-  {
-    if(g_file_test(gpp->val.tmp_audfile, G_FILE_TEST_EXISTS))
+    if(gpp->val.tmp_audfile[0] != '\0')
     {
-       gpp->val.wav_samplerate_tmp =
-       p_update_aud_info(gpp, lbl_info_tmp, lbl_time_tmp, lbl_time0, gpp->val.tmp_audfile);
-       gtk_label_set_text(lbl_tmp_audfile, gpp->val.tmp_audfile);
-   }
+      if(g_file_test(gpp->val.tmp_audfile, G_FILE_TEST_EXISTS))
+      {
+         gpp->val.wav_samplerate_tmp =
+         p_update_aud_info(gpp, lbl_info_tmp, lbl_time_tmp, lbl_time0, gpp->val.tmp_audfile);
+         gtk_label_set_text(lbl_tmp_audfile, gpp->val.tmp_audfile);
+      }
+    }
   }
-
   gap_cme_gui_upd_wgt_sensitivity (gpp);
 }  /* end gap_cme_gui_update_aud_labels */
 
@@ -1137,10 +1159,16 @@
   if(gap_debug) printf("gap_cme_gui_util_sox_widgets\n");
 
   entry = GTK_ENTRY(gpp->cme__entry_sox);
-  gtk_entry_set_text(entry, gpp->val.util_sox);
+  if(entry != NULL)
+  {
+    gtk_entry_set_text(entry, gpp->val.util_sox);
+  }
 
   entry = GTK_ENTRY(gpp->cme__entry_sox_options);
-  gtk_entry_set_text(entry, gpp->val.util_sox_options);
+  if(entry != NULL)
+  {
+    gtk_entry_set_text(entry, gpp->val.util_sox_options);
+  }
 }  /* end gap_cme_gui_util_sox_widgets */
 
 
@@ -1216,13 +1244,19 @@
   }
 
   /* label changes dependent from rangetype "From Frame", "From Layer" or "From Storyframe" */
-  lbl_text = g_strdup_printf(_("From %s:"),  range_text);
-  gtk_label_set_text(GTK_LABEL(gpp->cme__label_from), lbl_text);
-  g_free(lbl_text);
-
-  lbl_text = g_strdup_printf(_("To %s:"),  range_text);
-  gtk_label_set_text(GTK_LABEL(gpp->cme__label_to), lbl_text);
-  g_free(lbl_text);
+  if(gpp->cme__label_from != NULL)
+  {
+    lbl_text = g_strdup_printf(_("From %s:"),  range_text);
+    gtk_label_set_text(GTK_LABEL(gpp->cme__label_from), lbl_text);
+    g_free(lbl_text);
+  }
+
+  if(gpp->cme__label_to != NULL)
+  {
+    lbl_text = g_strdup_printf(_("To %s:"),  range_text);
+    gtk_label_set_text(GTK_LABEL(gpp->cme__label_to), lbl_text);
+    g_free(lbl_text);
+  }
 
   g_free(range_text);
 
@@ -1266,9 +1300,18 @@
  gtk_adjustment_set_value(GTK_ADJUSTMENT(gpp->cme__spinbutton_height_adj)
                          , (gfloat)gpp->val.vid_height);
 
- gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_video), gpp->val.videoname);
- gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_audio1), gpp->val.audioname1);
- gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_mac), gpp->val.filtermacro_file);
+ if(gpp->cme__entry_video != NULL)
+ {
+   gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_video), gpp->val.videoname);
+ }
+ if(gpp->cme__entry_audio1 != NULL)
+ {
+   gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_audio1), gpp->val.audioname1);
+ }
+ if (gpp->cme__entry_mac != NULL)
+ {
+   gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_mac), gpp->val.filtermacro_file);
+ }
 
  gap_cme_gui_update_aud_labels (gpp);
  gap_cme_gui_update_vid_labels (gpp);
@@ -1293,7 +1336,10 @@
    */
 
   status_lbl = gpp->cme__label_status;
-  if(status_lbl) gtk_label_set_text(GTK_LABEL(status_lbl), gstb->status_msg);
+  if(status_lbl)
+  {
+    gtk_label_set_text(GTK_LABEL(status_lbl), gstb->status_msg);
+  }
 
   pbar = gpp->cme__progressbar_status;
   if(pbar)
@@ -2471,7 +2517,8 @@
                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                          GTK_STOCK_OK,     GTK_RESPONSE_OK,
                          NULL);
-
+  gtk_window_set_type_hint (shell_window, GDK_WINDOW_TYPE_HINT_NORMAL);
+  
   g_signal_connect (G_OBJECT (shell_window), "response",
                     G_CALLBACK (on_cme__response),
                     gpp);
@@ -3896,7 +3943,7 @@
 static void
 p_set_label_to_numeric_value(GtkWidget *label, gint32 value)
 {
-  if(label)
+  if(label != NULL)
   {
     char *buffer;
     buffer = g_strdup_printf("%6d", value);
@@ -3974,15 +4021,48 @@
       gdouble l_progress;
       char *l_msg;
 
-      l_progress = CLAMP((gdouble)gpp->encStatus.frames_processed / (gdouble)(MAX(1.0, gpp->encStatus.total_frames))
-                      , 0.0, 1.0
+      switch (gpp->encStatus.current_pass)
+      {
+        case 1:
+          l_progress = CLAMP(
+                       (gdouble)gpp->encStatus.frames_processed 
+                        / (gdouble)(MAX(1.0, 2.0 * gpp->encStatus.total_frames))
+                      , 0.0
+                      , 1.0
                       );
-
-      gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR (pbar), l_progress);
-      l_msg = g_strdup_printf(_("Video encoding %d of %d frames done")
+          l_msg = g_strdup_printf(_("Video encoding %d of %d frames done, PASS 1 of 2")
                              , gpp->encStatus.frames_processed
                              , gpp->encStatus.total_frames
                              );
+          break;
+        case 2:
+          l_progress = CLAMP(
+                     (gdouble)(gpp->encStatus.frames_processed + gpp->encStatus.total_frames)
+                      / (gdouble)(MAX(1.0, 2.0 * gpp->encStatus.total_frames))
+                      , 0.0
+                      , 1.0
+                      );
+          l_msg = g_strdup_printf(_("Video encoding %d of %d frames done, PASS 2 of 2")
+                             , gpp->encStatus.frames_processed
+                             , gpp->encStatus.total_frames
+                             );
+          break;
+        default: 
+          /* current_pass is 0 for single pass encoders */
+          l_progress = CLAMP(
+                      (gdouble)gpp->encStatus.frames_processed
+                      / (gdouble)(MAX(1.0, gpp->encStatus.total_frames))
+                      , 0.0
+                      , 1.0
+                      );
+          l_msg = g_strdup_printf(_("Video encoding %d of %d frames done")
+                             , gpp->encStatus.frames_processed
+                             , gpp->encStatus.total_frames
+                             );
+          break;
+      }
+
+      gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR (pbar), l_progress);
       gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar), l_msg);
       g_free(l_msg);
     }
@@ -4201,7 +4281,7 @@
   gstb->total_stroyboard_frames = 0;
   gstb->aud_total_sec = 0.0;
 
-  gimp_ui_init ("gap_video_extract", FALSE);
+  gimp_ui_init ("gap_master_video_encoder", FALSE);
   gap_stock_init();
 
   l_rangetype = gpp->val.input_mode;
@@ -4238,10 +4318,11 @@
 
   p_init_shell_window_widgets(gpp);
   gtk_widget_show (gpp->shell_window);
-
+  
   if(l_rangetype == GAP_RNGTYPE_STORYBOARD)
   {
-    if(gpp->val.storyboard_file[0] != '\0')
+    if((gpp->val.storyboard_file[0] != '\0')
+    && (gpp->cme__entry_stb != NULL))
     {
       gtk_entry_set_text(GTK_ENTRY(gpp->cme__entry_stb), gpp->val.storyboard_file);
     }

Modified: trunk/vid_enc_avi/gap_enc_avi_gui.c
==============================================================================
--- trunk/vid_enc_avi/gap_enc_avi_gui.c	(original)
+++ trunk/vid_enc_avi/gap_enc_avi_gui.c	Fri Feb 13 19:04:39 2009
@@ -458,6 +458,7 @@
                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                          GTK_STOCK_OK,     GTK_RESPONSE_OK,
                          NULL);
+  gtk_window_set_type_hint (shell_window, GDK_WINDOW_TYPE_HINT_NORMAL);
 
   g_signal_connect (G_OBJECT (shell_window), "response",
                     G_CALLBACK (on_avi_response),
@@ -1177,7 +1178,7 @@
 {
   if(gap_debug) printf("gap_enc_avi_gui_dialog: Start\n");
 
-  gimp_ui_init ("gap_video_extract", FALSE);
+  gimp_ui_init ("gap_enc_avi_params", FALSE);
   gap_stock_init();
 
   /* ---------- dialog ----------*/

Modified: trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_callbacks.c
==============================================================================
--- trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_callbacks.c	(original)
+++ trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_callbacks.c	Fri Feb 13 19:04:39 2009
@@ -206,8 +206,6 @@
                                    gint32          *dest_value_ptr)
 {
   GapGveFFMpegGlobalParams *gpp;
-  gint32   l_true;
-  gint32   l_false;
   gboolean l_sensitive;
 
   if(gap_debug) printf("CB: on_ff_gdouble_spinbutton_changed widget: %d\n", (int)checkbutton);
@@ -218,9 +216,6 @@
     return; 
   }
 
-  l_true = TRUE;
-  l_false = FALSE;
-  
   gpp = g_object_get_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP);
   if(gpp)
   {
@@ -258,23 +253,15 @@
       }
     }
 
-    if((GtkWidget *)checkbutton ==  gpp->ff_pass_checkbutton)
-    {
-      if(gap_debug) printf("WGT is: gpp->ff_pass_checkbutton\n");
-      l_true  = 2;  /* if true number of passes is 2 */
-      l_false = 1;  /* if true number of passes is 1 */
-    }
   }
 
   if (checkbutton->active)
   {
-     *dest_value_ptr = l_true;
-     if(gap_debug) printf("TRUE represntation: %d\n", (int)l_true);
+     *dest_value_ptr = TRUE;
   }
   else
   {
-     *dest_value_ptr = l_false;
-     if(gap_debug) printf("FALSE represntation: %d\n", (int)l_false);
+     *dest_value_ptr = FALSE;
   }
 
 }  /* end on_ff_gint32_checkbutton_toggled */

Modified: trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_gui.c
==============================================================================
--- trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_gui.c	(original)
+++ trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_gui.c	Fri Feb 13 19:04:39 2009
@@ -86,6 +86,7 @@
 GtkWidget*      p_create_basic_options_frame (GapGveFFMpegGlobalParams *gpp);
 GtkWidget*      p_create_expert_algortihms_frame (GapGveFFMpegGlobalParams *gpp);
 GtkWidget*      p_create_expert_flags_frame (GapGveFFMpegGlobalParams *gpp);
+GtkWidget*      p_create_expert_flags2_frame (GapGveFFMpegGlobalParams *gpp);
 GtkWidget*      p_create_expert_options_frame (GapGveFFMpegGlobalParams *gpp);
 GtkWidget*      p_create_2pass_options_frame (GapGveFFMpegGlobalParams *gpp);
 GtkWidget*      p_create_file_comment_frame (GapGveFFMpegGlobalParams *gpp);
@@ -899,8 +900,6 @@
 static void
 p_init_vid_checkbuttons(GapGveFFMpegGlobalParams *gpp)
 {
-  gint32 flag;
-
   if(gpp->startup)
   {
     return;
@@ -921,8 +920,8 @@
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_partitioning_checkbutton)
                                , gpp->evl.partitioning);
 
-  flag = (gpp->evl.pass == 2) ? TRUE : FALSE;
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_pass_checkbutton), flag);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_pass_checkbutton)
+                               , gpp->evl.twoPassFlag);
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_dont_recode_checkbutton)
                                , gpp->evl.dont_recode_flag);
@@ -940,8 +939,6 @@
                                  , gpp->evl.do_interlace_me);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_use_aiv_checkbutton)
                                  , gpp->evl.use_aiv);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_use_trell_checkbutton)
-                                 , gpp->evl.use_trell);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_use_obmc_checkbutton)
                                  , gpp->evl.use_obmc);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_use_qpel_checkbutton)
@@ -966,6 +963,53 @@
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_no_output_checkbutton)
                                  , gpp->evl.no_output);
   }
+
+  /* new flags */
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG_GMC_checkbutton)
+                               , gpp->evl.codec_FLAG_GMC);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG_INPUT_PRESERVED_checkbutton)
+                               , gpp->evl.codec_FLAG_INPUT_PRESERVED);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG_GRAY_checkbutton)
+                               , gpp->evl.codec_FLAG_GRAY);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG_EMU_EDGE_checkbutton)
+                               , gpp->evl.codec_FLAG_EMU_EDGE);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG_TRUNCATED_checkbutton)
+                               , gpp->evl.codec_FLAG_TRUNCATED);
+
+  /* new flags2 */
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_FAST_checkbutton)
+                               , gpp->evl.codec_FLAG2_FAST);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_LOCAL_HEADER_checkbutton)
+                               , gpp->evl.codec_FLAG2_LOCAL_HEADER);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_BPYRAMID_checkbutton)
+                               , gpp->evl.codec_FLAG2_BPYRAMID);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_WPRED_checkbutton)
+                               , gpp->evl.codec_FLAG2_WPRED);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_MIXED_REFS_checkbutton)
+                               , gpp->evl.codec_FLAG2_MIXED_REFS);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_8X8DCT_checkbutton)
+                               , gpp->evl.codec_FLAG2_8X8DCT);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_FASTPSKIP_checkbutton)
+                               , gpp->evl.codec_FLAG2_FASTPSKIP);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_AUD_checkbutton)
+                               , gpp->evl.codec_FLAG2_AUD);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_BRDO_checkbutton)
+                               , gpp->evl.codec_FLAG2_BRDO);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_INTRA_VLC_checkbutton)
+                               , gpp->evl.codec_FLAG2_INTRA_VLC);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_MEMC_ONLY_checkbutton)
+                               , gpp->evl.codec_FLAG2_MEMC_ONLY);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_DROP_FRAME_TIMECODE_checkbutton)
+                               , gpp->evl.codec_FLAG2_DROP_FRAME_TIMECODE);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_SKIP_RD_checkbutton)
+                               , gpp->evl.codec_FLAG2_SKIP_RD);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_CHUNKS_checkbutton)
+                               , gpp->evl.codec_FLAG2_CHUNKS);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_NON_LINEAR_QUANT_checkbutton)
+                               , gpp->evl.codec_FLAG2_NON_LINEAR_QUANT);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gpp->ff_codec_FLAG2_BIT_RESERVOIR_checkbutton)
+                               , gpp->evl.codec_FLAG2_BIT_RESERVOIR);
+
 }   /* end p_init_vid_checkbuttons */
 
 /* --------------------------------
@@ -2048,14 +2092,6 @@
 
   row = 0;
 
-  /* Flags label */
-//  label = gtk_label_new (_("Flags:"));
-//  gtk_widget_show (label);
-//  gtk_table_attach (GTK_TABLE (table2), label, 0, 1, row, row+1,
-//                    (GtkAttachOptions) (GTK_FILL),
-//                    (GtkAttachOptions) (0), 0, 0);
-//  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-
   /* the (invisible) frame Flags container for the flag checkbuttons */
   flags_frame = gimp_frame_new (NULL);
   gtk_widget_show (flags_frame);
@@ -2297,7 +2333,6 @@
                       &gpp->evl.use_obmc);
 
 
-
     flags_row++;
 
     /* the quarter pel checkbutton */
@@ -2326,7 +2361,6 @@
                       G_CALLBACK (on_ff_gint32_checkbutton_toggled),
                       &gpp->evl.use_loop);
 
-
     flags_row++;
 
     /* the Use qprd checkbutton */
@@ -2357,7 +2391,6 @@
                       G_CALLBACK (on_ff_gint32_checkbutton_toggled),
                       &gpp->evl.use_cbprd);
 
-
     flags_row++;
 
     /* the Use MV0 checkbutton */
@@ -2409,19 +2442,6 @@
 
     flags_row++;
 
-    /* the Use trell checkbutton */
-    checkbutton = gtk_check_button_new_with_label (_("Use trell"));
-    gpp->ff_use_trell_checkbutton = checkbutton;
-    gtk_widget_show (checkbutton);
-    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
-                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-                      (GtkAttachOptions) (0), 0, 0);
-    gimp_help_set_help_data (checkbutton, _("Enable trellis quantization"), NULL);
-    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
-    g_signal_connect (G_OBJECT (checkbutton), "toggled",
-                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
-                      &gpp->evl.use_trell);
-
 
   }  /* end flags_table */
 
@@ -2453,6 +2473,406 @@
 
 
 /* --------------------------------
+ * p_create_expert_flags2_frame
+ * --------------------------------
+ */
+GtkWidget*
+p_create_expert_flags2_frame (GapGveFFMpegGlobalParams *gpp)
+{
+  GtkWidget *frame;
+  GtkWidget *flags_frame;
+  GtkWidget *table2;
+  GtkWidget *label;
+  GtkWidget *checkbutton;
+
+  gint       row;
+
+  frame = gimp_frame_new (_("FFMpeg Expert Flags2"));
+
+  table2 = gtk_table_new (7, 3, FALSE);
+  gtk_widget_show (table2);
+  gtk_container_add (GTK_CONTAINER (frame), table2);
+  gtk_container_set_border_width (GTK_CONTAINER (table2), 2);
+  gtk_table_set_row_spacings (GTK_TABLE (table2), 4);
+  gtk_table_set_col_spacings (GTK_TABLE (table2), 4);
+
+  row = 0;
+
+  /* the (invisible) frame Flags container for the flag checkbuttons */
+  flags_frame = gimp_frame_new (NULL);
+  gtk_widget_show (flags_frame);
+  gtk_table_attach (GTK_TABLE (table2), flags_frame, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+
+  /* the flags table */
+  {
+    int flags_row;
+    GtkWidget *flags_table;
+
+    flags_table = gtk_table_new (8, 2, FALSE);
+    gtk_widget_show (flags_table);
+    gtk_container_add (GTK_CONTAINER (flags_frame), flags_table);
+    gtk_container_set_border_width (GTK_CONTAINER (flags_table), 2);
+    gtk_table_set_row_spacings (GTK_TABLE (flags_table), 4);
+    gtk_table_set_col_spacings (GTK_TABLE (flags_table), 4);
+
+    flags_row = 0;
+
+    /* LABELS */
+    label = gtk_label_new (_("General flags2:"));
+    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+    gtk_widget_show (label);
+    gtk_table_attach (GTK_TABLE (flags_table), label, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+
+    label = gtk_label_new (_("H264:"));
+    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+    gtk_widget_show (label);
+    gtk_table_attach (GTK_TABLE (flags_table), label, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+
+
+
+
+    flags_row++;
+
+    /* CHECKBUTTONS */
+    /* the Fast checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Fast Non-Compliant"));
+    gpp->ff_codec_FLAG2_FAST_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Allow non spec compliant speedup tricks"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_FAST);
+
+
+    /* the use_bpyramid checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Bpyramid"));
+    gpp->ff_codec_FLAG2_BPYRAMID_checkbutton  = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("allow B-frames to be used as references for predicting.(for H264 codec)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_BPYRAMID);
+
+
+
+    flags_row++;
+
+    /* the use_local_header checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Local Header"));
+    gpp->ff_codec_FLAG2_LOCAL_HEADER_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Place global headers at every keyframe instead of in extradata"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_LOCAL_HEADER);
+
+    /* the use_wpred checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Weighted Biprediction"));
+    gpp->ff_codec_FLAG2_WPRED_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("weighted biprediction for B-frames (for H264 codec)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_WPRED);
+
+
+
+
+    flags_row++;
+
+    /* the use_brdo checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("B Rate Distortion"));
+    gpp->ff_codec_FLAG2_BRDO_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("B-frame rate-distortion optimization"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_BRDO);
+
+
+
+
+    /* the use_mixed_refs checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Mixed Refs"));
+    gpp->ff_codec_FLAG2_MIXED_REFS_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("one reference per partition, as opposed to one reference per macroblock (for H264 codec)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_MIXED_REFS);
+
+
+
+    flags_row++;
+
+    /* the use_ivlc checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Intra VLC"));
+    gpp->ff_codec_FLAG2_INTRA_VLC_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Use MPEG-2 intra VLC table."), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_INTRA_VLC);
+
+
+    /* the use_dct8x8 checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Use AIV"));
+    gpp->ff_codec_FLAG2_8X8DCT_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("high profile 8x8 transform (for H264 codec)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_8X8DCT);
+
+
+    flags_row++;
+
+    /* the use_memc_only checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Only ME/MC"));
+    gpp->ff_codec_FLAG2_MEMC_ONLY_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Only do ME/MC (I frames -> ref, P frame -> ME+MC)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_MEMC_ONLY);
+
+
+    /* the use_fastpskip checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Fast Pskip"));
+    gpp->ff_codec_FLAG2_FASTPSKIP_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("fast pskip (for H264 codec)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_FASTPSKIP);
+
+
+
+    flags_row++;
+
+    /* the use_drop_frame_timecode checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("DropFrame Timecode"));
+    gpp->ff_codec_FLAG2_DROP_FRAME_TIMECODE_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("timecode is in drop frame format"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_DROP_FRAME_TIMECODE);
+
+    /* the use_aud checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("AccessUnit"));
+    gpp->ff_codec_FLAG2_AUD_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 1, 2, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("use access unit delimiters (for H264 codec)"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_AUD);
+
+
+    flags_row++;
+
+    /* the use_skip_rd checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Use qprd"));
+    gpp->ff_codec_FLAG2_SKIP_RD_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("RD optimal MB level residual skipping"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_SKIP_RD);
+
+    flags_row++;
+
+    /* the use_chunks checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Use chunks"));
+    gpp->ff_codec_FLAG2_CHUNKS_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_CHUNKS);
+
+
+    flags_row++;
+
+    /* the use_non_linear_quant checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Nonlinear Quant"));
+    gpp->ff_codec_FLAG2_NON_LINEAR_QUANT_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Use MPEG-2 nonlinear quantizer"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_NON_LINEAR_QUANT);
+
+    flags_row++;
+
+    /* the use_bit_reservoir checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Bit Reservoir"));
+    gpp->ff_codec_FLAG2_BIT_RESERVOIR_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Use a bit reservoir when encoding if possible"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG2_BIT_RESERVOIR);
+
+
+
+    flags_row++;
+
+    /* the use_gmc checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Use GMC"));
+    gpp->ff_codec_FLAG_GMC_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Use GMC"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG_GMC);
+
+    flags_row++;
+
+    /* the input_preserved checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Input Preserved"));
+    gpp->ff_codec_FLAG_INPUT_PRESERVED_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Input Preserved"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG_INPUT_PRESERVED);
+
+    flags_row++;
+
+    /* the use_gray checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Use Gray"));
+    gpp->ff_codec_FLAG_GRAY_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Only encode grayscale"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG_GRAY);
+
+
+    flags_row++;
+
+    /* the use_emu_edge checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Emu Edges"));
+    gpp->ff_codec_FLAG_EMU_EDGE_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Dont draw edges"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG_EMU_EDGE);
+
+    flags_row++;
+
+    /* the use_truncated checkbutton */
+    checkbutton = gtk_check_button_new_with_label (_("Truncated"));
+    gpp->ff_codec_FLAG_TRUNCATED_checkbutton = checkbutton;
+    gtk_widget_show (checkbutton);
+    gtk_table_attach (GTK_TABLE (flags_table), checkbutton, 0, 1, flags_row, flags_row+1,
+                      (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                      (GtkAttachOptions) (0), 0, 0);
+    gimp_help_set_help_data (checkbutton, _("Input bitstream might be truncated at a random location instead of only at frame boundaries"), NULL);
+    g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
+    g_signal_connect (G_OBJECT (checkbutton), "toggled",
+                      G_CALLBACK (on_ff_gint32_checkbutton_toggled),
+                      &gpp->evl.codec_FLAG_TRUNCATED);
+
+    flags_row++;
+
+  }  /* end flags_table */
+
+
+  return(frame);
+}  /* end  p_create_expert_flags2_frame */
+
+
+
+/* --------------------------------
  * p_create_expert_options_frame
  * --------------------------------
  */
@@ -2488,7 +2908,7 @@
   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
   /* the qblur spinbutton */
-  adj = gtk_adjustment_new (0.5, 0, 100, 0.25, 10, 0);
+  adj = gtk_adjustment_new (0.5, 0, 1.0, 0.01, 0.1, 0);
   spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 2);
   gpp->ff_qblur_spinbutton_adj            = adj;
   gpp->ff_qblur_spinbutton                = spinbutton;
@@ -2496,7 +2916,8 @@
   gtk_table_attach (GTK_TABLE (table4), spinbutton, 1, 2, row, row+1,
                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gimp_help_set_help_data (spinbutton, _("Video quantiser scale blur (VBR)"), NULL);
+  gimp_help_set_help_data (spinbutton, _("Video quantiser scale blur (VBR) "
+                                         "amount of qscale smoothing over time (0.0-1.0)"), NULL);
   g_object_set_data (G_OBJECT (spinbutton), GAP_ENC_FFGUI_ADJ, (gpointer)adj);
   g_object_set_data (G_OBJECT (spinbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
   g_signal_connect (G_OBJECT (spinbutton), "changed",
@@ -2517,7 +2938,7 @@
   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
   /* the qcomp spinbutton */
-  adj = gtk_adjustment_new (0.5, 0, 100, 0.25, 10, 0);
+  adj = gtk_adjustment_new (0.5, 0, 1.0, 0.01, 0.1, 0);
   spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 2);
   gpp->ff_qcomp_spinbutton_adj            = adj;
   gpp->ff_qcomp_spinbutton                = spinbutton;
@@ -2525,7 +2946,8 @@
   gtk_table_attach (GTK_TABLE (table4), spinbutton, 1, 2, row, row+1,
                     (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
-  gimp_help_set_help_data (spinbutton, _("Video quantiser scale compression (VBR)"), NULL);
+  gimp_help_set_help_data (spinbutton, _("Video quantiser scale compression (VBR) "
+                                         "amount of qscale change between easy & hard scenes (0.0-1.0)"), NULL);
   g_object_set_data (G_OBJECT (spinbutton), GAP_ENC_FFGUI_ADJ, (gpointer)adj);
   g_object_set_data (G_OBJECT (spinbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
   g_signal_connect (G_OBJECT (spinbutton), "changed",
@@ -2786,7 +3208,7 @@
   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
   /* the strictness spinbutton */
-  adj = gtk_adjustment_new (1, 0, 100, 1, 10, 0);
+  adj = gtk_adjustment_new (1, -2, 2, 1, 10, 0);
   spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 1, 0);
   gpp->ff_strict_spinbutton_adj           = adj;
   gpp->ff_strict_spinbutton               = spinbutton;
@@ -2900,7 +3322,7 @@
   g_object_set_data (G_OBJECT (checkbutton), GAP_ENC_FFGUI_GPP, (gpointer)gpp);
   g_signal_connect (G_OBJECT (checkbutton), "toggled",
                       G_CALLBACK (on_ff_gint32_checkbutton_toggled),
-                      &gpp->evl.pass);
+                      &gpp->evl.twoPassFlag);
 
   row++;
 
@@ -3297,7 +3719,6 @@
   gpp->ff_use_obmc_checkbutton = NULL;
   gpp->ff_use_loop_checkbutton = NULL;
   gpp->ff_use_alt_scan_checkbutton = NULL;
-  gpp->ff_use_trell_checkbutton = NULL;
   gpp->ff_use_mv0_checkbutton = NULL;
   gpp->ff_do_normalize_aqp_checkbutton = NULL;
   gpp->ff_use_scan_offset_checkbutton = NULL;
@@ -3310,6 +3731,30 @@
   gpp->ff_strict_gop_checkbutton = NULL;
   gpp->ff_no_output_checkbutton = NULL;
 
+  gpp->ff_codec_FLAG_GMC_checkbutton = NULL;
+  gpp->ff_codec_FLAG_INPUT_PRESERVED_checkbutton = NULL;
+  gpp->ff_codec_FLAG_GRAY_checkbutton = NULL;
+  gpp->ff_codec_FLAG_EMU_EDGE_checkbutton = NULL;
+  gpp->ff_codec_FLAG_TRUNCATED_checkbutton = NULL;
+  
+  gpp->ff_codec_FLAG2_FAST_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_LOCAL_HEADER_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_BPYRAMID_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_WPRED_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_MIXED_REFS_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_8X8DCT_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_FASTPSKIP_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_AUD_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_BRDO_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_INTRA_VLC_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_MEMC_ONLY_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_DROP_FRAME_TIMECODE_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_SKIP_RD_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_CHUNKS_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_NON_LINEAR_QUANT_checkbutton = NULL;
+  gpp->ff_codec_FLAG2_BIT_RESERVOIR_checkbutton = NULL;
+
+
   shell_window = gimp_dialog_new (_("FFMPEG Video Encode Parameters"),
                          GAP_PLUGIN_NAME_FFMPEG_PARAMS,
                          NULL, 0,
@@ -3320,6 +3765,7 @@
                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                          GTK_STOCK_OK,     GTK_RESPONSE_OK,
                          NULL);
+  gtk_window_set_type_hint (shell_window, GDK_WINDOW_TYPE_HINT_NORMAL);
 
   g_signal_connect (G_OBJECT (shell_window), "response",
                     G_CALLBACK (on_ff_response),
@@ -3464,6 +3910,22 @@
   gtk_widget_show (nb1_label);
   gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), nb_page_nr), nb1_label);
 
+
+  nb_page_nr++;
+
+  /* the frame with expert_flags2 */
+  frame = p_create_expert_flags2_frame(gpp);
+  gtk_widget_show (frame);
+
+  gtk_container_add (GTK_CONTAINER (notebook1), frame);
+  gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
+
+  /* the notebook page label for expert flags */
+  nb1_label = gtk_label_new (_("Expert Flags2"));
+  gtk_widget_show (nb1_label);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), nb_page_nr), nb1_label);
+
+
   nb_page_nr++;
 
   /* the frame with expert_options */
@@ -3544,6 +4006,7 @@
   p_set_combo_box_callbacks(gpp);
   gap_enc_ffgui_init_main_dialog_widgets(gpp);
   gtk_widget_show (gpp->shell_window);
+  gtk_window_present(GTK_WINDOW(gpp->shell_window));
 
   gpp->val.run = 0;
   gtk_main ();

Modified: trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
==============================================================================
--- trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c	(original)
+++ trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c	Fri Feb 13 19:04:39 2009
@@ -11,7 +11,6 @@
 
 - RealVideo fileformat: Video+Audio encoding does not work. (unusable results) playback  blocks.
                         (Video only seems OK)
-- finish implementation of 2-pass handling
 */
 
 /* gap_enc_main_ffmpeg.c
@@ -194,69 +193,12 @@
 
  int frame_width;
  int frame_height;
- int frame_topBand;
- int frame_bottomBand;
- int frame_leftBand;
- int frame_rightBand;
- int video_bit_rate;
- int video_bit_rate_tolerance;
- float video_qscale;
- int video_qmin;
- int video_qmax;
- int video_qdiff;
- float video_qblur;
- float video_qcomp;
- char *video_rc_override_string;
- char *video_rc_eq;
- int video_rc_buffer_size;
- float video_rc_buffer_aggressivity;
- int video_rc_max_rate;
- int video_rc_min_rate;
- float video_rc_initial_cplx;
- float video_b_qfactor;
- float video_b_qoffset;
- float video_i_qfactor;
- float video_i_qoffset;
- int me_method;
- int video_disable;
- int video_codec_id;
- int same_quality;
- int b_frames;
- int mb_decision;
- int aic;
- int umv;
- int use_4mv;
- int workaround_bugs;
- int error_recognition;
- int error_concealment;
- int dct_algo;
- int idct_algo;
- int strict;
- int mb_qmin;
- int mb_qmax;
- int use_part;
- int packet_size;
 
- int gop_size;
- int intra_only;
  int audio_bit_rate;
  int audio_codec_id;
 
- int64_t recording_time;
  int file_overwrite;
- char *str_title;
- char *str_author;
- char *str_copyright;
- char *str_comment;
- int do_benchmark;
- int do_hex_dump;
- int do_play;
- int do_psnr;
- int do_vstats;
- int do_pass;
- char *pass_logfilename;
- int audio_stream_copy;
- int video_stream_copy;
+
  gdouble pts_stepsize_per_frame;
  gint32 encode_frame_nr;          /* number of frame to encode always starts at 1 and inc by one (base for monotone timecode calculation) */
 
@@ -280,12 +222,13 @@
 static void query(void);
 static void run(const gchar *name
               , gint n_params
-	      , const GimpParam *param
+              , const GimpParam *param
               , gint *nreturn_vals
-	      , GimpParam **return_vals);
+              , GimpParam **return_vals);
 
 
 static void   p_debug_print_dump_AVCodecContext(AVCodecContext *codecContext);
+static void   p_set_flag(gint32 value_bool32, int *flag_ptr, int maskbit);
 
 
 static void   p_gimp_get_data(const char *key, void *buffer, gint expected_size);
@@ -293,18 +236,18 @@
 
 static void              p_init_audio_workdata(t_awk_array *awp);
 static void              p_open_inwav_and_buffers(t_awk_array *awp
-                        	      , const char *wavefile
-                        	      , gint ii
-				      , long sample_rate
-				      , long channels
-				      , long bytes_per_sample
-				      , long bits
-				      , long samples
-				      );
+                                      , const char *wavefile
+                                      , gint ii
+                                      , long sample_rate
+                                      , long channels
+                                      , long bytes_per_sample
+                                      , long bits
+                                      , long samples
+                                      );
 static void              p_sound_precalculations(t_ffmpeg_handle *ffh
-                		      , t_awk_array *awp
-                		      , GapGveFFMpegGlobalParams *gpp
-				      );
+                                      , t_awk_array *awp
+                                      , GapGveFFMpegGlobalParams *gpp
+                                      );
 static void              p_process_audio_frame(t_ffmpeg_handle *ffh, t_awk_array *awp);
 static void              p_close_audio_input_files(t_awk_array *awp);
 static void              p_open_audio_input_files(t_awk_array *awp, GapGveFFMpegGlobalParams *gpp);
@@ -314,18 +257,18 @@
 
 static void              p_ffmpeg_open_init(t_ffmpeg_handle *ffh, GapGveFFMpegGlobalParams *gpp);
 static gboolean          p_init_video_codec(t_ffmpeg_handle *ffh
-        			      , gint ii
-        			      , GapGveFFMpegGlobalParams *gpp
-        			      , gint32 current_pass);
+                                      , gint ii
+                                      , GapGveFFMpegGlobalParams *gpp
+                                      , gint32 current_pass);
 
 static gboolean          p_init_and_open_audio_codec(t_ffmpeg_handle *ffh
-        			      , gint ii
-        			      , GapGveFFMpegGlobalParams *gpp
-        			      , long audio_samplerate
-        			      , long audio_channels);
+                                      , gint ii
+                                      , GapGveFFMpegGlobalParams *gpp
+                                      , long audio_samplerate
+                                      , long audio_channels);
 static t_ffmpeg_handle * p_ffmpeg_open(GapGveFFMpegGlobalParams *gpp
                                       , gint32 current_pass
-				      , t_awk_array *awp
+                                      , t_awk_array *awp
                                       , gint video_tracks
                                       );
 static int    p_ffmpeg_write_frame_chunk(t_ffmpeg_handle *ffh, gint32 encoded_size, gint vid_track);
@@ -373,12 +316,12 @@
     {GIMP_PDB_INT32, "samplerate", "audio samplerate in samples per seconds (is ignored .wav files are used)"},
     {GIMP_PDB_STRING, "audfile", "optional audiodata file .wav must contain uncompressed 16 bit samples."
                                  " pass empty string if no audiodata should be included."
-				 " optional you can pass a textfile as audiofile. this textfile must contain "
-				 " one filename of a .wav file per line and allows encoding of "
-				 " multiple audio tracks because each of the specified audiofiles "
-				 " is encoded as ist own audiostream (works only if the selected multimedia fileformat "
-				 " has multiple audio track support. For example multilingual MPEG2 .vob files "
-				 " do support multiple audio streams)"},
+                                 " optional you can pass a textfile as audiofile. this textfile must contain "
+                                 " one filename of a .wav file per line and allows encoding of "
+                                 " multiple audio tracks because each of the specified audiofiles "
+                                 " is encoded as ist own audiostream (works only if the selected multimedia fileformat "
+                                 " has multiple audio track support. For example multilingual MPEG2 .vob files "
+                                 " do support multiple audio streams)"},
     {GIMP_PDB_INT32, "use_rest", "0 == use default values for all encoder specific params, "
                                  "1 == use encoder specific params set by the parameter procedure:"
                                  GAP_PLUGIN_NAME_FFMPEG_PARAMS
@@ -387,7 +330,7 @@
     {GIMP_PDB_STRING, "storyboard_file", "textfile with list of one or more framesequences"},
     {GIMP_PDB_INT32,  "input_mode", "0 ... image is one of the frames to encode, range_from/to params refere to numberpart of the other frameimages on disc. \n"
                                     "1 ... image is multilayer, range_from/to params refere to layer index. \n"
-				    "2 ... image is ignored, input is specified by storyboard_file parameter."},
+                                    "2 ... image is ignored, input is specified by storyboard_file parameter."},
     {GIMP_PDB_INT32, "master_encoder_id", "id of the master encoder that called this plug-in (typically the pid)"},
   };
   static int nargs_ffmpeg_enc = sizeof(args_ffmpeg_enc) / sizeof(args_ffmpeg_enc[0]);
@@ -400,7 +343,7 @@
 
     {GIMP_PDB_STRING, "ffmpeg_encode_parameter_file", "name of an ffmpeg encoder parameter file."
                                                       " Such a file can be created via save button in the"
-						      " INTERACTIVE runmode"},
+                                                      " INTERACTIVE runmode"},
 
 
   };
@@ -450,8 +393,8 @@
   gimp_install_procedure(GAP_PLUGIN_NAME_FFMPEG_PARAMS,
                          _("Set Parameters for GAP ffmpeg video encoder Plugin"),
                          _("This plugin sets ffmpeg specific video encoding parameters."
-			   " Non-interactive callers must provide a parameterfile,"
-			   " Interactive calls provide a dialog window to specify and optionally save the parameters."),
+                           " Non-interactive callers must provide a parameterfile,"
+                           " Interactive calls provide a dialog window to specify and optionally save the parameters."),
                          "Wolfgang Hofer (hof gimp org)",
                          "Wolfgang Hofer",
                          GAP_VERSION_WITH_DATE,
@@ -598,22 +541,22 @@
            if(param[2].data.d_string)
            {
              g_snprintf(gpp->ffpar_filename, sizeof(gpp->ffpar_filename), "%s", param[2].data.d_string);
-	     if(g_file_test(gpp->ffpar_filename, G_FILE_TEST_EXISTS))
-	     {
+             if(g_file_test(gpp->ffpar_filename, G_FILE_TEST_EXISTS))
+             {
                gap_ffpar_get(gpp->ffpar_filename, &gpp->evl);
                l_set_it = TRUE;
-	     }
-	     else
-	     {
+             }
+             else
+             {
                values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
                l_set_it = FALSE;
-	     }
+             }
            }
-	   else
-	   {
+           else
+           {
              values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
              l_set_it = FALSE;
-	   }
+           }
 
         }
       }
@@ -782,7 +725,7 @@
   printf("(max_qdiff                    %d)\n", (int)    codecContext->max_qdiff);
   printf("(max_b_frames                 %d)\n", (int)    codecContext->max_b_frames);
   printf("(b_quant_factor               %f)\n", (float)  codecContext->b_quant_factor);
-  printf("(rc_strategy                  %d)\n", (int)    codecContext->rc_strategy);
+  printf("(rc_strategy  (OBSOLETE)      %d)\n", (int)    codecContext->rc_strategy);
   printf("(b_frame_strategy             %d)\n", (int)    codecContext->b_frame_strategy);
   printf("(hurry_up                     %d)\n", (int)    codecContext->hurry_up);
   printf("(codec (AVCodec *)            %d)\n", (int)    codecContext->codec);
@@ -958,6 +901,18 @@
 }  /* end p_debug_print_dump_AVCodecContext */
 
 
+/* --------------------------------
+ * p_set_flag
+ * --------------------------------
+ */
+static void
+p_set_flag(gint32 value_bool32, int *flag_ptr, int maskbit)
+{
+  if(value_bool32)
+  {
+    *flag_ptr |= maskbit;
+  }
+}  /* end p_set_flag */
 
 /* --------------------------------
  * p_gimp_get_data
@@ -1003,66 +958,65 @@
 gap_enc_ffmpeg_main_init_preset_params(GapGveFFMpegValues *epp, gint preset_idx)
 {
   gint l_idx;
-  /*                                                                        DivX def      best       low   MS-def         VCD	MPGbest      SVCD 	DVD 	 Real */
-  static gint32 tab_ntsc_width[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]        =  {     0,        0,        0,  	0,        352,        0,      480,      720,	    0 };
-  static gint32 tab_ntsc_height[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,  	0,        240,        0,      480,      480,	    0 };
-
-  static gint32 tab_pal_width[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {     0,        0,        0,  	0,        352,        0,      480,      720,	    0 };
-  static gint32 tab_pal_height[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]        =  {     0,        0,        0,  	0,        288,        0,      576,      576,	    0 };
-
-  static gint32 tab_pass[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]              =  {     1,        1,        1,  	1,          1,        1,	1,	  1,	    1 };
-  static gint32 tab_audio_bitrate[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]     =  {   160,      192,       96,     160,        224,      192,      224,	192,	  160 };
-  static gint32 tab_video_bitrate[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]     =  {   200,     1500,      150,     200,       1150,     6000,     2040,     6000,	 1200 };
-  static gint32 tab_gop_size[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {    12,       12,       96,      12,         18,       12,       18,	 18,	   18 };
-  static gint32 tab_intra[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-
-  static float  tab_qscale[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]            =  {     2,        1,        6,  	2,          1,        1,	1,	  1,	    2 };
-
-  static gint32 tab_qmin[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]              =  {     2,        2,        8,  	2,          2,        2,	2,	  2,	    2 };
-  static gint32 tab_qmax[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]              =  {    31,        8,       31,      31,         31,        8,       16,	  8,	   31 };
-  static gint32 tab_qdiff[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {     3,        2,        9,  	3,          3,        2,	2,	  2,	    3 };
-
-  static float  tab_qblur[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {   0.5,       0.5,      0.5,    0.5,        0.5,      0.5,      0.5,	0.5,	  0.5 };
-  static float  tab_qcomp[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {   0.5,       0.5,      0.5,    0.5,        0.5,      0.5,      0.5,	0.5,	  0.5 };
-  static float  tab_rc_init_cplx[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]      =  {   0.0,       0.0,      0.0,    0.0,        0.0,      0.0,      0.0,	0.0,	  0.0 };
-  static float  tab_b_qfactor[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {  1.25,      1.25,     1.25,   1.25,       1.25,     1.25,     1.25,     1.25,	 1.25 };
-  static float  tab_i_qfactor[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {  -0.8,      -0.8,     -0.8,   -0.8,       -0.8,     -0.8,     -0.8,     -0.8,	 -0.8 };
-  static float  tab_b_qoffset[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {  1.25,      1.25,     1.25,   1.25,       1.25,     1.25,     1.25,     1.25,	 1.25 };
-  static float  tab_i_qoffset[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {   0.0,       0.0,      0.0,    0.0,        0.0,      0.0,      0.0,	0.0,	  0.0 };
-
-  static gint32 tab_bitrate_tol[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {  4000,     6000,     2000,    4000,          0,     4000,     2000,     2000,	 5000 };
-  static gint32 tab_maxrate_tol[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,  	0,       1150,        0,     2516,     9000,	    0 };
-  static gint32 tab_minrate_tol[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,  	0,       1150,        0,	0,	  0,	    0 };
-  static gint32 tab_bufsize[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]           =  {     0,        0,        0,  	0,         40,        0,      224,	224,	    0 };
-
-  static gint32 tab_motion_estimation[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS] =  {     5,        5,        5,  	5,          5,        5,	5,	  5,	    5 };
-
-  static gint32 tab_dct_algo[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_idct_algo[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_strict[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]            =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_mb_qmin[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]           =  {     2,        2,        8,  	2,          2,        2,	2,	  2,	    2 };
-  static gint32 tab_mb_qmax[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]           =  {    31,       18,       31,      31,         31,       18,       31,	 31,	   31 };
-  static gint32 tab_mb_decision[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_aic[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]               =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_umv[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]               =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-
-  static gint32 tab_b_frames[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     2,        2,        4,  	0,          0,        0,	2,	  2,	    0 };
-  static gint32 tab_mv4[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]               =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_partitioning[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]      =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_packet_size[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_bitexact[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     0,        0,        0,  	0,          0,        0,	0,	  0,	    0 };
-  static gint32 tab_aspect[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]            =  {     1,        1,        1,  	1,          1,        1,	1,	  1,	    1 };
-  static gint32 tab_aspect_fact[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {   0.0,      0.0,      0.0,     0.0,        0.0,      0.0,      0.0,	0.0,	  0.0 };
+  /*                                                                        DivX def      best       low   MS-def         VCD   MPGbest      SVCD       DVD      Real */
+  static gint32 tab_ntsc_width[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]        =  {     0,        0,        0,       0,        352,        0,      480,      720,        0 };
+  static gint32 tab_ntsc_height[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,       0,        240,        0,      480,      480,        0 };
+
+  static gint32 tab_pal_width[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {     0,        0,        0,       0,        352,        0,      480,      720,        0 };
+  static gint32 tab_pal_height[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]        =  {     0,        0,        0,       0,        288,        0,      576,      576,        0 };
+
+  static gint32 tab_audio_bitrate[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]     =  {   160,      192,       96,     160,        224,      192,      224,      192,      160 };
+  static gint32 tab_video_bitrate[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]     =  {   200,     1500,      150,     200,       1150,     6000,     2040,     6000,     1200 };
+  static gint32 tab_gop_size[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {    12,       12,       96,      12,         18,       12,       18,       18,       18 };
+  static gint32 tab_intra[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+
+  static float  tab_qscale[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]            =  {     2,        1,        6,       2,          1,        1,        1,        1,        2 };
+
+  static gint32 tab_qmin[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]              =  {     2,        2,        8,       2,          2,        2,        2,        2,        2 };
+  static gint32 tab_qmax[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]              =  {    31,        8,       31,      31,         31,        8,       16,        8,       31 };
+  static gint32 tab_qdiff[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {     3,        2,        9,       3,          3,        2,        2,        2,        3 };
+
+  static float  tab_qblur[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {   0.5,       0.5,      0.5,    0.5,        0.5,      0.5,      0.5,      0.5,      0.5 };
+  static float  tab_qcomp[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]             =  {   0.5,       0.5,      0.5,    0.5,        0.5,      0.5,      0.5,      0.5,      0.5 };
+  static float  tab_rc_init_cplx[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]      =  {   0.0,       0.0,      0.0,    0.0,        0.0,      0.0,      0.0,      0.0,      0.0 };
+  static float  tab_b_qfactor[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {  1.25,      1.25,     1.25,   1.25,       1.25,     1.25,     1.25,     1.25,     1.25 };
+  static float  tab_i_qfactor[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {  -0.8,      -0.8,     -0.8,   -0.8,       -0.8,     -0.8,     -0.8,     -0.8,     -0.8 };
+  static float  tab_b_qoffset[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {  1.25,      1.25,     1.25,   1.25,       1.25,     1.25,     1.25,     1.25,     1.25 };
+  static float  tab_i_qoffset[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {   0.0,       0.0,      0.0,    0.0,        0.0,      0.0,      0.0,      0.0,      0.0 };
+
+  static gint32 tab_bitrate_tol[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {  4000,     6000,     2000,    4000,          0,     4000,     2000,     2000,     5000 };
+  static gint32 tab_maxrate_tol[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,       0,       1150,        0,     2516,     9000,        0 };
+  static gint32 tab_minrate_tol[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,       0,       1150,        0,        0,        0,        0 };
+  static gint32 tab_bufsize[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]           =  {     0,        0,        0,       0,         40,        0,      224,      224,        0 };
+
+  static gint32 tab_motion_estimation[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS] =  {     5,        5,        5,       5,          5,        5,        5,        5,        5 };
+
+  static gint32 tab_dct_algo[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_idct_algo[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]         =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_strict[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]            =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_mb_qmin[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]           =  {     2,        2,        8,       2,          2,        2,        2,        2,        2 };
+  static gint32 tab_mb_qmax[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]           =  {    31,       18,       31,      31,         31,       18,       31,       31,       31 };
+  static gint32 tab_mb_decision[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_aic[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]               =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_umv[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]               =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+
+  static gint32 tab_b_frames[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     2,        2,        4,       0,          0,        0,        2,        2,        0 };
+  static gint32 tab_mv4[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]               =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_partitioning[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]      =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_packet_size[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_bitexact[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     0,        0,        0,       0,          0,        0,        0,        0,        0 };
+  static gint32 tab_aspect[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]            =  {     1,        1,        1,       1,          1,        1,        1,        1,        1 };
+  static gint32 tab_aspect_fact[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {   0.0,      0.0,      0.0,     0.0,        0.0,      0.0,      0.0,      0.0,      0.0 };
 
   static char*  tab_format_name[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  { "avi",    "avi",    "avi",     "avi",     "vcd",   "mpeg",   "svcd",    "vob",     "rm" };
   static char*  tab_vcodec_name[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  { "mpeg4", "mpeg4", "mpeg4", "msmpeg4", "mpeg1video", "mpeg1video", "mpeg2video", "mpeg2video", "rv10" };
   static char*  tab_acodec_name[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  { "mp2",     "mp2",   "mp2",     "mp2",      "mp2",    "mp2",    "mp2",   "ac3",    "ac3" };
 
-  static gint32 tab_mux_rate[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     0,         0,     	0,	0,     1411200,       0,       0,   10080000,        0 };
-  static gint32 tab_mux_packet_size[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]   =  {     0,         0,     	0,	0,        2324,    2324,    2324,       2048,        0 };
+  static gint32 tab_mux_rate[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]          =  {     0,         0,        0,      0,     1411200,       0,       0,   10080000,        0 };
+  static gint32 tab_mux_packet_size[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]   =  {     0,         0,        0,      0,        2324,    2324,    2324,       2048,        0 };
   static float  tab_mux_preload[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]       =  {   0.5,       0.5,      0.5,    0.5,        0.44,     0.5,     0.5,        0.5,      0.5 };
   static float  tab_mux_max_delay[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]     =  {   0.7,       0.7,      0.7,    0.7,         0.7,     0.7,     0.7,        0.7,      0.7 };
-  static gint32 tab_use_scann_offset[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]  =  {     0,         0,     	0,	0,           0,       0,       1,          0,        0 };
+  static gint32 tab_use_scann_offset[GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS]  =  {     0,         0,        0,      0,           0,       0,       1,          0,        0 };
 
 
   l_idx = CLAMP(preset_idx, 0, GAP_GVE_FFMPEG_PRESET_MAX_ELEMENTS -1);
@@ -1076,7 +1030,8 @@
   g_snprintf(epp->acodec_name, sizeof(epp->acodec_name), tab_acodec_name[l_idx]);   /* "mp2" */
 
 
-  epp->pass                = tab_pass[l_idx];
+  epp->pass_nr             = 1;
+  epp->twoPassFlag         = FALSE;
   epp->audio_bitrate       = tab_audio_bitrate[l_idx];   /* 160 kbit */
   epp->video_bitrate       = tab_video_bitrate[l_idx];   /* 5000 kbit */
   epp->gop_size            = tab_gop_size[l_idx];        /* 12 group of pictures size (frames) */
@@ -1143,7 +1098,6 @@
   epp->use_obmc                     = 0;
   epp->use_loop                     = 0;
   epp->use_alt_scan                 = 0;
-  epp->use_trell                    = 0;
   epp->use_mv0                      = 0;
   epp->do_normalize_aqp             = 0;
   epp->use_scan_offset              = tab_use_scann_offset[l_idx];
@@ -1194,6 +1148,79 @@
   epp->pal_width                    = tab_pal_width[l_idx];
   epp->pal_height                   = tab_pal_height[l_idx];
 
+
+  /* new parms 2009.01.31 */
+  
+  epp->b_frame_strategy              = 0;
+  epp->workaround_bugs               = FF_BUG_AUTODETECT;
+  epp->error_recognition             = FF_ER_CAREFUL;
+  epp->mpeg_quant                    = 0;
+  epp->rc_qsquish                    = 0.0;   /* 0 = clip, 1 = use differentiable function */
+  epp->rc_qmod_amp                   = 0.0;
+  epp->rc_qmod_freq                  = 0;
+  epp->rc_eq[0]                      = '\0';  /* triggers use of use default equation */
+  epp->rc_buffer_aggressivity        = 1.0;
+  epp->dia_size                      = 0;
+  epp->last_predictor_count          = 0;
+  epp->pre_dia_size                  = 0;
+  epp->inter_threshold               = 0;
+  epp->border_masking                = 0.0;
+  epp->me_penalty_compensation       = 256;
+  epp->bidir_refine                  = 0;
+  epp->brd_scale                     = 0;
+  epp->crf                           = 0.0;
+  epp->cqp                           = -1;
+  epp->keyint_min                    = 25;   /* minimum GOP size */
+  epp->refs                          = 1;
+  epp->chromaoffset                  = 0;        
+  epp->bframebias                    = 0;
+  epp->trellis                       = 0;
+  epp->complexityblur                = 20.0;
+  epp->deblockalpha                  = 0;
+  epp->deblockbeta                   = 0;
+  epp->partitions                    = 0;
+  epp->directpred                    = 2;
+  epp->cutoff                        = 0;
+  epp->scenechange_factor            = 6;
+  epp->mv0_threshold                 = 256;
+  epp->b_sensitivity                 = 40;
+  epp->compression_level             = -1;
+  epp->use_lpc                       = -1;
+  epp->lpc_coeff_precision           = 0;
+  epp->min_prediction_order          = -1;
+  epp->max_prediction_order          = -1;
+  epp->prediction_order_method       = -1;
+  epp->min_partition_order           = -1;
+  epp->timecode_frame_start          = 0;
+  epp->bits_per_raw_sample           = 0;
+  epp->channel_layout                = 0;
+  epp->rc_max_available_vbv_use      = 1.0 / 3.0;
+  epp->rc_min_vbv_overflow_use       = 3.0;
+  
+  /* new flags/flags2 2009.01.31 */
+  epp->codec_FLAG_GMC                   = 0; /* 0: FALSE */
+  epp->codec_FLAG_INPUT_PRESERVED       = 0; /* 0: FALSE */
+  epp->codec_FLAG_GRAY                  = 0; /* 0: FALSE */
+  epp->codec_FLAG_EMU_EDGE              = 0; /* 0: FALSE */
+  epp->codec_FLAG_TRUNCATED             = 0; /* 0: FALSE */
+
+  epp->codec_FLAG2_FAST                 = 0; /* 0: FALSE */
+  epp->codec_FLAG2_LOCAL_HEADER         = 0; /* 0: FALSE */
+  epp->codec_FLAG2_BPYRAMID             = 0; /* 0: FALSE */
+  epp->codec_FLAG2_WPRED                = 0; /* 0: FALSE */
+  epp->codec_FLAG2_MIXED_REFS           = 0; /* 0: FALSE */
+  epp->codec_FLAG2_8X8DCT               = 0; /* 0: FALSE */
+  epp->codec_FLAG2_FASTPSKIP            = 0; /* 0: FALSE */
+  epp->codec_FLAG2_AUD                  = 0; /* 0: FALSE */
+  epp->codec_FLAG2_BRDO                 = 0; /* 0: FALSE */
+  epp->codec_FLAG2_INTRA_VLC            = 0; /* 0: FALSE */
+  epp->codec_FLAG2_MEMC_ONLY            = 0; /* 0: FALSE */
+  epp->codec_FLAG2_DROP_FRAME_TIMECODE  = 0; /* 0: FALSE */
+  epp->codec_FLAG2_SKIP_RD              = 0; /* 0: FALSE */
+  epp->codec_FLAG2_CHUNKS               = 0; /* 0: FALSE */
+  epp->codec_FLAG2_NON_LINEAR_QUANT     = 0; /* 0: FALSE */
+  epp->codec_FLAG2_BIT_RESERVOIR        = 0; /* 0: FALSE */
+
 }   /* end gap_enc_ffmpeg_main_init_preset_params */
 
 
@@ -1262,12 +1289,12 @@
 p_open_inwav_and_buffers(t_awk_array *awp
                         , const char *wavefile
                         , gint ii
-			, long sample_rate
-			, long channels
-			, long bytes_per_sample
-			, long bits
-			, long samples
-			)
+                        , long sample_rate
+                        , long channels
+                        , long bytes_per_sample
+                        , long bits
+                        , long samples
+                        )
 {
   FILE *fp_inwav;
 
@@ -1480,13 +1507,13 @@
   {
     p_open_inwav_and_buffers(awp
                             , gpp->val.audioname1
-			    , ii
+                            , ii
                             , l_sample_rate
-			    , l_channels
-			    , l_bytes_per_sample
-			    , l_bits
-			    , l_samples
-			    );
+                            , l_channels
+                            , l_bytes_per_sample
+                            , l_bits
+                            , l_samples
+                            );
     awp->audio_tracks = 1;
   }
   else
@@ -1509,15 +1536,15 @@
       while(NULL != fgets(l_buf, sizeof(l_buf)-1, l_fp))
       {
         if((l_buf[0] == '#') || (l_buf[0] == '\n') || (l_buf[0] == '\0'))
-	{
-	  continue;  /* skip comment lines, and empty lines */
-	}
+        {
+          continue;  /* skip comment lines, and empty lines */
+        }
 
         l_buf[sizeof(l_buf) -1] = '\0';  /* make sure we have a terminated string */
         gap_file_chop_trailingspace_and_nl(&l_buf[0]);
 
-	if(ii < MAX_AUDIO_STREAMS)
-	{
+        if(ii < MAX_AUDIO_STREAMS)
+        {
           int    l_rc;
 
           awp->awk[ii].referred_wavfile = gap_file_make_abspath_filename(&l_buf[0], gpp->val.audioname1);
@@ -1533,39 +1560,39 @@
           {
             p_open_inwav_and_buffers(awp
                             , awp->awk[ii].referred_wavfile
-			    , ii
+                            , ii
                             , l_sample_rate
-			    , l_channels
-			    , l_bytes_per_sample
-			    , l_bits
-			    , l_samples
-			    );
+                            , l_channels
+                            , l_bytes_per_sample
+                            , l_bits
+                            , l_samples
+                            );
 
-	    ii++;
+            ii++;
             awp->audio_tracks = ii;
-	  }
-	  else
-	  {
+          }
+          else
+          {
             g_message(_("The file: %s\n"
-	              "has unexpect content that will be ignored.\n"
-		      "You should specify an audio file in RIFF WAVE fileformat,\n"
-		      "or a textfile containing filenames of such audio files")
-		     , gpp->val.audioname1
-		     );
-	    break;
-	  }
-	}
-	else
-	{
+                      "has unexpect content that will be ignored.\n"
+                      "You should specify an audio file in RIFF WAVE fileformat,\n"
+                      "or a textfile containing filenames of such audio files")
+                     , gpp->val.audioname1
+                     );
+            break;
+          }
+        }
+        else
+        {
           g_message(_("The file: %s\n"
-	              "contains too many audio-input tracks\n"
-		      "(only %d tracks are used, the rest are ignored).")
-		   , gpp->val.audioname1
-		   , (int) MAX_AUDIO_STREAMS
-		   );
-	  break;
-	}
-	l_buf[0] = '\0';
+                      "contains too many audio-input tracks\n"
+                      "(only %d tracks are used, the rest are ignored).")
+                   , gpp->val.audioname1
+                   , (int) MAX_AUDIO_STREAMS
+                   );
+          break;
+        }
+        l_buf[0] = '\0';
       }
 
       fclose(l_fp);
@@ -1699,7 +1726,7 @@
     p_set_timebase_from_framerate(&l_time_base, gpp->val.framerate);
     ffh->pts_stepsize_per_frame = l_time_base.num;
 
-    //if(gap_debug)
+    if(gap_debug)
     {
       printf("p_ffmpeg_open_init  time_base: num:%d den:%d  pts_stepsize_per_frame:%.4f\n"
         ,(int)l_time_base.num
@@ -1713,70 +1740,11 @@
   /* initialize common things */
   ffh->frame_width                  = (int)gpp->val.vid_width;
   ffh->frame_height                 = (int)gpp->val.vid_height;
-  ffh->frame_topBand                = 0;
-  ffh->frame_bottomBand             = 0;
-  ffh->frame_leftBand               = 0;
-  ffh->frame_rightBand              = 0;
-  ffh->encode_frame_nr              = 0;
-  ffh->video_bit_rate               = epp->video_bitrate * 1000;
-  ffh->video_bit_rate_tolerance     = epp->bitrate_tol * 1000;
-  ffh->video_qscale                 = epp->qscale;
-  ffh->video_qmin                   = epp->qmin;
-  ffh->video_qmax                   = epp->qmax;
-  ffh->video_qdiff                  = epp->qdiff;
-  ffh->video_qblur                  = (float)epp->qblur;
-  ffh->video_qcomp                  = (float)epp->qcomp;
-  ffh->video_rc_override_string     = NULL;
-  ffh->video_rc_eq                  =  "tex^qComp";
-  ffh->video_rc_buffer_size         = epp->bufsize;
-  ffh->video_rc_buffer_aggressivity = 1.0;
-  ffh->video_rc_max_rate            = epp->maxrate_tol * 1000;
-  ffh->video_rc_min_rate            = epp->minrate_tol * 1000;
-  ffh->video_rc_initial_cplx        = (float)epp->rc_init_cplx;
-  ffh->video_b_qfactor              = (float)epp->b_qfactor;
-  ffh->video_b_qoffset              = (float)epp->b_qoffset;
-  ffh->video_i_qfactor              = (float)epp->i_qfactor;
-  ffh->video_i_qoffset              = (float)epp->i_qoffset;
-  ffh->me_method                    = epp->motion_estimation;
-  ffh->video_disable                = 0;
-  ffh->video_codec_id               = CODEC_ID_NONE;
-  ffh->same_quality                 = 0;
-  ffh->b_frames                     = epp->b_frames;
-  ffh->mb_decision                  = epp->mb_decision;
-  ffh->aic                          = epp->aic;
-  ffh->umv                          = epp->umv;
-  ffh->use_4mv                      = epp->mv4;
-  ffh->workaround_bugs              = FF_BUG_AUTODETECT;
-  ffh->error_recognition            = FF_ER_COMPLIANT;
-  ffh->error_concealment            = FF_EC_DEBLOCK;
-  ffh->dct_algo                     = epp->dct_algo;
-  ffh->idct_algo                    = epp->idct_algo;
-  ffh->strict                       = epp->strict;
-  ffh->mb_qmin                      = epp->mb_qmin;
-  ffh->mb_qmax                      = epp->mb_qmax;
-  ffh->use_part                     = epp->partitioning;
-  ffh->packet_size                  = epp->packet_size;
 
-  ffh->gop_size                     = epp->gop_size;
-  ffh->intra_only                   = epp->intra;
   ffh->audio_bit_rate               = epp->audio_bitrate * 1000;     /* 64000; */
   ffh->audio_codec_id               = CODEC_ID_NONE;
 
-  ffh->recording_time               = 0;
   ffh->file_overwrite               = 0;
-  ffh->str_title = NULL;            if (epp->title[0] != '\0')     {ffh->str_title     = &epp->title[0];}
-  ffh->str_author = NULL;           if (epp->author[0] != '\0')    {ffh->str_author    = &epp->author[0];}
-  ffh->str_copyright = NULL;        if (epp->copyright[0] != '\0') {ffh->str_copyright = &epp->copyright[0];}
-  ffh->str_comment = NULL;          if (epp->comment[0] != '\0')   {ffh->str_comment   = &epp->comment[0];}
-  ffh->do_benchmark                 = epp->benchmark;
-  ffh->do_hex_dump                  = epp->hex_dump;
-  ffh->do_play                      = 0;
-  ffh->do_psnr                      = epp->psnr;
-  ffh->do_vstats                    = epp->vstats;
-  ffh->do_pass                      = 0;
-  ffh->pass_logfilename = NULL;     if (epp->passlogfile[0] != '\0')   {ffh->pass_logfilename   = &epp->passlogfile[0];}
-  ffh->audio_stream_copy            = 0;
-  ffh->video_stream_copy            = 0;
 
 }  /* end p_ffmpeg_open_init */
 
@@ -1858,7 +1826,7 @@
   video_enc->width = gpp->val.vid_width;
   video_enc->height = gpp->val.vid_height;
 
-  //if (gap_debug)
+  if (gap_debug)
   {
     printf("VCODEC: id:%d (%s) time_base.num :%d  time_base.den:%d    float:%f\n"
            "            DEFAULT_FRAME_RATE_BASE: %d\n"
@@ -1939,24 +1907,24 @@
      */
     l_dbl = l_aspect_factor * (gdouble)gpp->val.vid_height / (gdouble)MAX(1,gpp->val.vid_width);
 
-    //if(gap_debug)
+    if(gap_debug)
     {
       printf("ASPECT ratio DEFAULT setting: NUM:%d  DEN:%d\n"
-	    ,(int)video_enc->sample_aspect_ratio.num
+            ,(int)video_enc->sample_aspect_ratio.num
             ,(int)video_enc->sample_aspect_ratio.den
-	    );
+            );
     }
     video_enc->sample_aspect_ratio = av_d2q(l_dbl, 255);
     ffh->vst[ii].vid_stream->sample_aspect_ratio = video_enc->sample_aspect_ratio;  /* 2009.01.31 must init stream sample_aspect_ratio to avoid crash */
 
-    //if(gap_debug)
+    if(gap_debug)
     {
       printf("ASPECT ratio (w/h): %f l_dbl:%f av_d2q NUM:%d  DEN:%d\n"
             ,(float)l_aspect_factor
             ,(float)l_dbl
-	    ,(int)video_enc->sample_aspect_ratio.num
+            ,(int)video_enc->sample_aspect_ratio.num
             ,(int)video_enc->sample_aspect_ratio.den
-	    );
+            );
     }
 
   }
@@ -1980,116 +1948,54 @@
   if(!epp->intra)  { video_enc->gop_size = epp->gop_size;  }
   else             { video_enc->gop_size = 0;              }
 
-
-  /* CODEC_FLAG_HQ no longer supported in ffmpeg-0.4.8  */
-  /*
-   *  if(epp->hq_settings)
-   *  {
-   *     video_enc->flags |= CODEC_FLAG_HQ;
-   *  }
-   */
-
-  if(epp->bitexact)
-  {
-    /* only use bit exact algorithms (for codec testing) */
-    video_enc->flags |= CODEC_FLAG_BITEXACT;
-  }
+  /* set codec flags */
+  p_set_flag(epp->bitexact,         &video_enc->flags, CODEC_FLAG_BITEXACT);
+  p_set_flag(epp->umv,              &video_enc->flags, CODEC_FLAG_H263P_UMV);
+  p_set_flag(epp->use_ss,           &video_enc->flags, CODEC_FLAG_H263P_SLICE_STRUCT);
+  p_set_flag(epp->use_aiv,          &video_enc->flags, CODEC_FLAG_H263P_AIV);
+  p_set_flag(epp->use_obmc,         &video_enc->flags, CODEC_FLAG_OBMC);
+  p_set_flag(epp->use_loop,         &video_enc->flags, CODEC_FLAG_LOOP_FILTER);
+  p_set_flag(epp->use_alt_scan,     &video_enc->flags, CODEC_FLAG_ALT_SCAN);
+  p_set_flag(epp->use_mv0,          &video_enc->flags, CODEC_FLAG_MV0);
+  p_set_flag(epp->do_normalize_aqp, &video_enc->flags, CODEC_FLAG_NORMALIZE_AQP);
+  p_set_flag(epp->use_scan_offset,  &video_enc->flags, CODEC_FLAG_SVCD_SCAN_OFFSET);
+  p_set_flag(epp->closed_gop,       &video_enc->flags, CODEC_FLAG_CLOSED_GOP);
+  p_set_flag(epp->use_qpel,         &video_enc->flags, CODEC_FLAG_QPEL);
+  p_set_flag(epp->use_qprd,         &video_enc->flags, CODEC_FLAG_QP_RD);
+  p_set_flag(epp->use_cbprd,        &video_enc->flags, CODEC_FLAG_CBP_RD);
+  p_set_flag(epp->do_interlace_dct, &video_enc->flags, CODEC_FLAG_INTERLACED_DCT);
+  p_set_flag(epp->do_interlace_me,  &video_enc->flags, CODEC_FLAG_INTERLACED_ME);
+  p_set_flag(epp->aic,              &video_enc->flags, CODEC_FLAG_AC_PRED);
+  p_set_flag(epp->mv4,              &video_enc->flags, CODEC_FLAG_4MV);
+  p_set_flag(epp->partitioning,     &video_enc->flags, CODEC_FLAG_PART);
+
+  p_set_flag(epp->codec_FLAG_GMC,             &video_enc->flags, CODEC_FLAG_GMC);
+  p_set_flag(epp->codec_FLAG_INPUT_PRESERVED, &video_enc->flags, CODEC_FLAG_INPUT_PRESERVED);
+  p_set_flag(epp->codec_FLAG_GRAY,            &video_enc->flags, CODEC_FLAG_GRAY);
+  p_set_flag(epp->codec_FLAG_EMU_EDGE,        &video_enc->flags, CODEC_FLAG_EMU_EDGE);
+  p_set_flag(epp->codec_FLAG_TRUNCATED,       &video_enc->flags, CODEC_FLAG_TRUNCATED);
+
+  /* set codec flags2 */
+  p_set_flag(epp->strict_gop,                      &video_enc->flags2, CODEC_FLAG2_STRICT_GOP);
+  p_set_flag(epp->no_output,                       &video_enc->flags2, CODEC_FLAG2_NO_OUTPUT);
+  p_set_flag(epp->codec_FLAG2_FAST,                &video_enc->flags2, CODEC_FLAG2_FAST);
+  p_set_flag(epp->codec_FLAG2_LOCAL_HEADER,        &video_enc->flags2, CODEC_FLAG2_LOCAL_HEADER);
+  p_set_flag(epp->codec_FLAG2_BPYRAMID,            &video_enc->flags2, CODEC_FLAG2_BPYRAMID);
+  p_set_flag(epp->codec_FLAG2_WPRED,               &video_enc->flags2, CODEC_FLAG2_WPRED);
+  p_set_flag(epp->codec_FLAG2_MIXED_REFS,          &video_enc->flags2, CODEC_FLAG2_MIXED_REFS);
+  p_set_flag(epp->codec_FLAG2_8X8DCT,              &video_enc->flags2, CODEC_FLAG2_8X8DCT);
+  p_set_flag(epp->codec_FLAG2_FASTPSKIP,           &video_enc->flags2, CODEC_FLAG2_FASTPSKIP);
+  p_set_flag(epp->codec_FLAG2_AUD,                 &video_enc->flags2, CODEC_FLAG2_AUD);
+  p_set_flag(epp->codec_FLAG2_BRDO,                &video_enc->flags2, CODEC_FLAG2_BRDO);
+  p_set_flag(epp->codec_FLAG2_INTRA_VLC,           &video_enc->flags2, CODEC_FLAG2_INTRA_VLC);
+  p_set_flag(epp->codec_FLAG2_MEMC_ONLY,           &video_enc->flags2, CODEC_FLAG2_MEMC_ONLY);
+  p_set_flag(epp->codec_FLAG2_DROP_FRAME_TIMECODE, &video_enc->flags2, CODEC_FLAG2_DROP_FRAME_TIMECODE);
+  p_set_flag(epp->codec_FLAG2_SKIP_RD,             &video_enc->flags2, CODEC_FLAG2_SKIP_RD);
+  p_set_flag(epp->codec_FLAG2_CHUNKS,              &video_enc->flags2, CODEC_FLAG2_CHUNKS);
+  p_set_flag(epp->codec_FLAG2_NON_LINEAR_QUANT,    &video_enc->flags2, CODEC_FLAG2_NON_LINEAR_QUANT);
+  p_set_flag(epp->codec_FLAG2_BIT_RESERVOIR,       &video_enc->flags2, CODEC_FLAG2_BIT_RESERVOIR);
 
 
-  if(epp->umv)
-  {
-     video_enc->flags |= CODEC_FLAG_H263P_UMV;
-  }
-
-  if (epp->use_ss)
-  {
-    video_enc->flags |= CODEC_FLAG_H263P_SLICE_STRUCT;
-  }
-
-  if (epp->use_aiv)
-  {
-    video_enc->flags |= CODEC_FLAG_H263P_AIV;
-  }
-
-  if (epp->use_obmc)
-  {
-      video_enc->flags |= CODEC_FLAG_OBMC;
-  }
-  if (epp->use_loop)
-  {
-      video_enc->flags |= CODEC_FLAG_LOOP_FILTER;
-  }
-
-  if (epp->use_alt_scan)
-  {
-    video_enc->flags |= CODEC_FLAG_ALT_SCAN;
-  }
-  if (epp->use_trell)
-  {
-    /// video_enc->flags |= CODEC_FLAG_TRELLIS_QUANT;  /// this flag is no longer supported (TODO remove all occurances)
-  }
-  if (epp->use_mv0)
-  {
-    video_enc->flags |= CODEC_FLAG_MV0;
-  }
-  if (epp->do_normalize_aqp)
-  {
-    video_enc->flags |= CODEC_FLAG_NORMALIZE_AQP;
-  }
-  if (epp->use_scan_offset)
-  {
-    video_enc->flags |= CODEC_FLAG_SVCD_SCAN_OFFSET;
-  }
-  if (epp->closed_gop)
-  {
-    video_enc->flags |= CODEC_FLAG_CLOSED_GOP;
-  }
-  if (epp->strict_gop)
-  {
-    video_enc->flags2 |= CODEC_FLAG2_STRICT_GOP;
-  }
-  if (epp->no_output)
-  {
-    video_enc->flags2 |= CODEC_FLAG2_NO_OUTPUT;
-  }
-  if (epp->use_qpel)
-  {
-    video_enc->flags |= CODEC_FLAG_QPEL;
-  }
-  if (epp->use_qprd)
-  {
-    video_enc->flags |= CODEC_FLAG_QP_RD;
-  }
-  if (epp->use_cbprd)
-  {
-    video_enc->flags |= CODEC_FLAG_CBP_RD;
-  }
-  if (epp->do_interlace_dct)
-  {
-    video_enc->flags |= CODEC_FLAG_INTERLACED_DCT;
-  }
-  if (epp->do_interlace_me)
-  {
-    video_enc->flags |= CODEC_FLAG_INTERLACED_ME;
-  }
-
-
-  if(epp->aic)
-  {
-     video_enc->flags |= CODEC_FLAG_AC_PRED;   /// old flag no longer supported CODEC_FLAG_H263P_AIC 
-  }
-
-  if (epp->mv4)
-  {
-      /* video_enc->flags |= CODEC_FLAG_HQ; */  /* CODEC_FLAG_HQ no longer supported in ffmpeg-0.4.8  */
-      video_enc->flags |= CODEC_FLAG_4MV;
-  }
-
-  if(epp->partitioning)
-  {
-      video_enc->flags |= CODEC_FLAG_PART;
-  }
-
   if ((epp->b_frames > 0) && (!epp->intra))
   {
     /* hof: TODO: here we should check if the selected codec
@@ -2105,19 +2011,18 @@
       case CODEC_ID_MSMPEG4V1:
       case CODEC_ID_MSMPEG4V2:
       case CODEC_ID_MSMPEG4V3:
-	if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
-	{
+        if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
+        {
           printf("\n### Warning: B frames encoding not supported by selected codec. (option ignored)\n");
-	}
-	else
-	{
+        }
+        else
+        {
           g_message("Warning: B frames encoding not supported by selected codec. (option ignored)\n");
-	}
+        }
         break;
       default:
-	video_enc->max_b_frames = epp->b_frames;
-	video_enc->b_frame_strategy = 0;
-	video_enc->b_quant_factor = 2.0;
+        video_enc->max_b_frames = epp->b_frames;
+        video_enc->b_frame_strategy = epp->b_frame_strategy;  /* default 0 */
         break;
     }
   }
@@ -2127,13 +2032,22 @@
   video_enc->max_qdiff = epp->qdiff;
   video_enc->qblur     = (float)epp->qblur;
   video_enc->qcompress = (float)epp->qcomp;
-  video_enc->rc_eq     = "tex^qComp";
+  if (epp->rc_eq[0] != '\0')
+  {
+    video_enc->rc_eq     = &epp->rc_eq[0];
+  }
+  else
+  {
+    /* use default rate control equation */
+    video_enc->rc_eq     = "tex^qComp";
+  }
 
   video_enc->rc_override_count      =0;
+  video_enc->inter_threshold        = epp->inter_threshold;
   video_enc->rc_max_rate            = epp->maxrate_tol * 1000;
   video_enc->rc_min_rate            = epp->minrate_tol * 1000;
   video_enc->rc_buffer_size         = epp->bufsize * 8*1024;
-  video_enc->rc_buffer_aggressivity = 1.0;
+  video_enc->rc_buffer_aggressivity = (float)epp->rc_buffer_aggressivity;
   video_enc->rc_initial_cplx        = (float)epp->rc_init_cplx;
   video_enc->i_quant_factor         = (float)epp->i_qfactor;
   video_enc->b_quant_factor         = (float)epp->b_qfactor;
@@ -2142,6 +2056,11 @@
   video_enc->dct_algo               = epp->dct_algo;
   video_enc->idct_algo              = epp->idct_algo;
   video_enc->strict_std_compliance  = epp->strict;
+  video_enc->workaround_bugs        = epp->workaround_bugs;
+  video_enc->error_recognition      = epp->error_recognition;
+  video_enc->mpeg_quant             = epp->mpeg_quant;
+  
+  
   video_enc->debug                  = 0;
   video_enc->mb_qmin                = epp->mb_qmin;
   video_enc->mb_qmax                = epp->mb_qmax;
@@ -2149,7 +2068,11 @@
   video_enc->rc_initial_buffer_occupancy = video_enc->rc_buffer_size * 3/4;
   video_enc->lmin                   = epp->video_lmin;
   video_enc->lmax                   = epp->video_lmax;
-  video_enc->rc_qsquish             = 1.0;  //experimental, (can be removed)
+  video_enc->rc_qsquish             = epp->rc_qsquish;
+  video_enc->rc_qmod_amp            = epp->rc_qmod_amp;
+  video_enc->rc_qmod_freq           = epp->rc_qmod_freq;
+  
+  
   video_enc->luma_elim_threshold    = epp->video_lelim;
   video_enc->chroma_elim_threshold  = epp->video_celim;
 
@@ -2175,15 +2098,52 @@
 
   video_enc->nsse_weight            = epp->nsse_weight;
   video_enc->me_subpel_quality      = epp->subpel_quality;
+  
+  video_enc->dia_size               = epp->dia_size;
+  video_enc->last_predictor_count   = epp->last_predictor_count;
+  video_enc->pre_dia_size           = epp->pre_dia_size;
+
+
+  video_enc->mb_lmin                  = epp->video_mb_lmin;
+  video_enc->mb_lmax                  = epp->video_mb_lmax;
+  video_enc->profile                  = epp->video_profile;
+  video_enc->level                    = epp->video_level;
+  video_enc->frame_skip_threshold     = epp->frame_skip_threshold;
+  video_enc->frame_skip_factor        = epp->frame_skip_factor;
+  video_enc->frame_skip_exp           = epp->frame_skip_exp;
+  video_enc->frame_skip_cmp           = epp->frame_skip_cmp;
+  video_enc->border_masking           = (float)epp->border_masking;
+  video_enc->me_penalty_compensation  = epp->me_penalty_compensation;
+  video_enc->bidir_refine             = epp->bidir_refine;
+  video_enc->brd_scale                = epp->brd_scale;
+  video_enc->crf                      = (float)epp->crf;
+  video_enc->cqp                      = epp->cqp;
+  video_enc->keyint_min               = epp->keyint_min;
+  video_enc->refs                     = epp->refs;
+  video_enc->chromaoffset             = epp->chromaoffset;        
+  video_enc->bframebias               = epp->bframebias;
+  video_enc->trellis                  = epp->trellis;
+  video_enc->complexityblur           = (float) epp->complexityblur;
+  video_enc->deblockalpha             = epp->deblockalpha;
+  video_enc->deblockbeta              = epp->deblockbeta;
+  video_enc->partitions               = epp->partitions;
+  video_enc->directpred               = epp->directpred;
+  video_enc->scenechange_factor       = epp->scenechange_factor;
+  video_enc->mv0_threshold            = epp->mv0_threshold;
+  video_enc->b_sensitivity            = epp->b_sensitivity;
+  video_enc->compression_level        = epp->compression_level;
+  video_enc->use_lpc                  = epp->use_lpc;
+  video_enc->lpc_coeff_precision      = epp->lpc_coeff_precision;
+  video_enc->min_prediction_order     = epp->min_prediction_order;
+  video_enc->max_prediction_order     = epp->max_prediction_order;
+  video_enc->prediction_order_method  = epp->prediction_order_method;
+  video_enc->min_partition_order      = epp->min_partition_order;
+  video_enc->timecode_frame_start     = epp->timecode_frame_start;
+  video_enc->bits_per_raw_sample      = epp->bits_per_raw_sample;
+  video_enc->rc_max_available_vbv_use = (float)epp->rc_max_available_vbv_use;
+  video_enc->rc_min_vbv_overflow_use  = (float)epp->rc_min_vbv_overflow_use;
+
 
-  video_enc->mb_lmin                = epp->video_mb_lmin;
-  video_enc->mb_lmax                = epp->video_mb_lmax;
-  video_enc->profile                = epp->video_profile;
-  video_enc->level                  = epp->video_level;
-  video_enc->frame_skip_threshold   = epp->frame_skip_threshold;
-  video_enc->frame_skip_factor      = epp->frame_skip_factor;
-  video_enc->frame_skip_exp         = epp->frame_skip_exp;
-  video_enc->frame_skip_cmp         = epp->frame_skip_cmp;
 
   if(epp->packet_size)
   {
@@ -2241,18 +2201,18 @@
           l_errno = errno;
           if (!fp)
           {
-	      if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
-	      {
+              if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
+              {
                 perror(logfilename);
-	      }
-	      else
-	      {
-		g_message(_("Could not create pass logfile:"
-			   "'%s'"
-			   "%s")
-			   ,logfilename
-			   ,g_strerror (l_errno) );
-	      }
+              }
+              else
+              {
+                g_message(_("Could not create pass logfile:"
+                           "'%s'"
+                           "%s")
+                           ,logfilename
+                           ,g_strerror (l_errno) );
+              }
               return(FALSE);  /* error */
           }
           ffh->vst[ii].passlog_fp = fp;
@@ -2264,18 +2224,18 @@
           l_errno = errno;
           if (!fp)
           {
-	      if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
-	      {
+              if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
+              {
                 perror(logfilename);
-	      }
-	      else
-	      {
-		g_message(_("Could not open pass logfile:"
-			   "'%s'"
-			   "%s")
-			   ,logfilename
-			   ,g_strerror (l_errno) );
-	      }
+              }
+              else
+              {
+                g_message(_("Could not open pass logfile:"
+                           "'%s'"
+                           "%s")
+                           ,logfilename
+                           ,g_strerror (l_errno) );
+              }
               return(FALSE);  /* error */
           }
           fseek(fp, 0, SEEK_END);
@@ -2358,21 +2318,25 @@
         /* open audio codec */
         if (avcodec_open(ffh->ast[ii].aud_codec_context, ffh->ast[ii].aud_codec) < 0)
         {
-	  if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
-	  {
+          if(gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
+          {
             printf("could not avcodec_open audio-codec: %s\n", epp->acodec_name);
-	  }
-	  else
-	  {
-	    g_message("could not open audio codec: %s\n", epp->acodec_name);
-	  }
+          }
+          else
+          {
+            g_message("could not open audio codec: %s\n", epp->acodec_name);
+          }
           ffh->ast[ii].aud_codec = NULL;
         }
 
         /* the following options were added after ffmpeg 0.4.8 */
-        audio_enc->thread_count = 1;
+        audio_enc->thread_count = epp->thread_count;
         audio_enc->strict_std_compliance = epp->strict;
-
+        audio_enc->workaround_bugs       = epp->workaround_bugs;
+        audio_enc->error_recognition     = epp->error_recognition;
+        audio_enc->cutoff                = epp->cutoff;
+        audio_enc->channel_layout        = epp->channel_layout;
+        
       }
     }
   }
@@ -2391,9 +2355,9 @@
 static t_ffmpeg_handle *
 p_ffmpeg_open(GapGveFFMpegGlobalParams *gpp
              , gint32 current_pass
-	     , t_awk_array *awp
+             , t_awk_array *awp
              , gint video_tracks
-	     )
+             )
 {
   t_ffmpeg_handle *ffh;
   GapGveFFMpegValues   *epp;
@@ -2434,7 +2398,7 @@
      return(NULL);
   }
 
-  //if(gap_debug)
+  if(gap_debug)
   {
     printf("AVOutputFormat ffh->file_oformat opened\n");
     printf("  name: %s\n", ffh->file_oformat->name);
@@ -2481,10 +2445,10 @@
 
     l_errno = errno;
     g_message(_("Could not create videofile:"
-	       "'%s'"
-	       "%s")
-	       ,gpp->val.videoname
-	       ,g_strerror (l_errno) );
+               "'%s'"
+               "%s")
+               ,gpp->val.videoname
+               ,g_strerror (l_errno) );
     return(NULL);
   }
 
@@ -2514,10 +2478,10 @@
     gboolean codec_ok;
     codec_ok = p_init_and_open_audio_codec(ffh
                                          , ii
-					 , gpp
-					 , awp->awk[ii].sample_rate
-					 , awp->awk[ii].channels
-					 );
+                                         , gpp
+                                         , awp->awk[ii].sample_rate
+                                         , awp->awk[ii].channels
+                                         );
     if(!codec_ok)
     {
       g_free(ffh);
@@ -2673,46 +2637,46 @@
        *   find a faster way to fix PTS
        */
       {
-	AVFrame   *big_picture_yuv;
-	AVPicture *picture_yuv;
-	AVPicture *picture_codec;
-
-	/* picture to feed the codec */
-	picture_codec = (AVPicture *)ffh->vst[ii].big_picture_codec;
-
-	/* source picture (YUV420) */
-	big_picture_yuv = avcodec_alloc_frame();
-	picture_yuv = (AVPicture *)big_picture_yuv;
+        AVFrame   *big_picture_yuv;
+        AVPicture *picture_yuv;
+        AVPicture *picture_codec;
+
+        /* picture to feed the codec */
+        picture_codec = (AVPicture *)ffh->vst[ii].big_picture_codec;
+
+        /* source picture (YUV420) */
+        big_picture_yuv = avcodec_alloc_frame();
+        picture_yuv = (AVPicture *)big_picture_yuv;
 
-	/* Feed the encoder with a (black) dummy frame
+        /* Feed the encoder with a (black) dummy frame
          */
-	avpicture_fill(picture_codec
+        avpicture_fill(picture_codec
                       ,ffh->vst[ii].yuv420_dummy_buffer
                       ,PIX_FMT_YUV420P          /* PIX_FMT_RGB24, PIX_FMT_RGBA32, PIX_FMT_BGRA32 */
                       ,ffh->frame_width
                       ,ffh->frame_height
                       );
 
-	ffh->vst[ii].big_picture_codec->quality = ffh->vst[ii].vid_stream->quality;
-	ffh->vst[ii].big_picture_codec->key_frame = 1;
+        ffh->vst[ii].big_picture_codec->quality = ffh->vst[ii].vid_stream->quality;
+        ffh->vst[ii].big_picture_codec->key_frame = 1;
 
         encoded_dummy_size = avcodec_encode_video(ffh->vst[ii].vid_codec_context
                                ,ffh->vst[ii].video_dummy_buffer, ffh->vst[ii].video_dummy_buffer_size
                                ,ffh->vst[ii].big_picture_codec);
 
-	g_free(big_picture_yuv);
+        g_free(big_picture_yuv);
       }
 
       if(encoded_dummy_size == 0)
       {
         /* on size 0 the encoder has buffered the dummy frame.
-	 * this unwanted frame might be added when there is a next non-dummy frame
-	 * to encode and to write. (dont know if there is a chance to clear
-	 * the encoder's internal buffer in this case.)
-	 * in my tests this case did not happen yet....
-	 * .. but display a warning to find out in further test
-	 */
-	 g_message(_("Black dummy frame was added"));
+         * this unwanted frame might be added when there is a next non-dummy frame
+         * to encode and to write. (dont know if there is a chance to clear
+         * the encoder's internal buffer in this case.)
+         * in my tests this case did not happen yet....
+         * .. but display a warning to find out in further test
+         */
+         g_message(_("Black dummy frame was added"));
       }
 
       chunk_frame_type = GVA_util_check_mpg_frame_type(ffh->vst[ii].video_buffer, encoded_size);
@@ -2725,12 +2689,12 @@
       if(gap_debug)
       {
         printf("CHUNK picture_number: enc_dummy_size:%d  frame_type:%d pic_number: %d %d PTS:%lld\n"
-	      , (int)encoded_dummy_size
-	      , (int)chunk_frame_type
-	      , (int)ffh->vst[ii].vid_codec_context->coded_frame->coded_picture_number
-	      , (int)ffh->vst[ii].vid_codec_context->coded_frame->display_picture_number
-	      , ffh->vst[ii].vid_codec_context->coded_frame->pts
-	      );
+              , (int)encoded_dummy_size
+              , (int)chunk_frame_type
+              , (int)ffh->vst[ii].vid_codec_context->coded_frame->coded_picture_number
+              , (int)ffh->vst[ii].vid_codec_context->coded_frame->display_picture_number
+              , ffh->vst[ii].vid_codec_context->coded_frame->pts
+              );
       }
 
       ///// pkt.pts = ffh->vst[ii].vid_codec_context->coded_frame->pts;  // OLD
@@ -2837,8 +2801,8 @@
     {
       printf("HAVE TO convert  pix_fmt: %d\n (PIX_FMT_YUV420P %d)"
             , (int)ffh->vst[ii].vid_codec_context->pix_fmt
-	    , (int)PIX_FMT_YUV420P
-	    );
+            , (int)PIX_FMT_YUV420P
+            );
     }
 
 
@@ -2918,14 +2882,14 @@
     if(encoded_size != 0)
     {
       {
-	AVPacket pkt;
+        AVPacket pkt;
         AVCodecContext *c;
 
-	av_init_packet (&pkt);
+        av_init_packet (&pkt);
         c = ffh->vst[ii].vid_codec_context;
 
 
-	///// pkt.pts = ffh->vst[ii].vid_codec_context->coded_frame->pts; // OLD
+        ///// pkt.pts = ffh->vst[ii].vid_codec_context->coded_frame->pts; // OLD
         
         if (c->coded_frame->pts != AV_NOPTS_VALUE)
         {
@@ -2941,17 +2905,17 @@
 //        }
 
         
-	if(c->coded_frame->key_frame)
-	{
+        if(c->coded_frame->key_frame)
+        {
           pkt.flags |= PKT_FLAG_KEY;
-	}
+        }
         
-	pkt.stream_index = ffh->vst[ii].video_stream_index;
-	pkt.data = ffh->vst[ii].video_buffer;
-	pkt.size = encoded_size;
+        pkt.stream_index = ffh->vst[ii].video_stream_index;
+        pkt.data = ffh->vst[ii].video_buffer;
+        pkt.size = encoded_size;
 
-	if(gap_debug)
-	{
+        if(gap_debug)
+        {
           AVStream *st;
           
           st = ffh->output_context->streams[pkt.stream_index];
@@ -2971,13 +2935,13 @@
              ,st->pts.val
              );
              
-	}
-	ret = av_write_frame(ffh->output_context, &pkt);
+        }
+        ret = av_write_frame(ffh->output_context, &pkt);
 
-	if(gap_debug)
-	{
-	  printf("after av_write_frame  encoded_size:%d\n", (int)encoded_size );
-	}
+        if(gap_debug)
+        {
+          printf("after av_write_frame  encoded_size:%d\n", (int)encoded_size );
+        }
       }
     }
   }
@@ -3390,8 +3354,9 @@
 
 
 
+
 /* ---------------------------
- * p_ffmpeg_encode
+ * p_ffmpeg_encode_pass
  * ---------------------------
  *    The main "productive" routine
  *    ffmpeg encoding of anim frames, based on ffmpeg lib (by Fabrice Bellard)
@@ -3402,7 +3367,7 @@
  *           (or -1 on error)
  */
 static gint
-p_ffmpeg_encode(GapGveFFMpegGlobalParams *gpp)
+p_ffmpeg_encode_pass(GapGveFFMpegGlobalParams *gpp, gint32 current_pass, GapGveMasterEncoderStatus *encStatusPtr)
 {
   GapGveFFMpegValues   *epp = NULL;
   t_ffmpeg_handle     *ffh = NULL;
@@ -3412,7 +3377,6 @@
   GimpDrawable *l_drawable = NULL;
   long          l_cur_frame_nr;
   long          l_step, l_begin, l_end;
-  gdouble       l_percentage, l_percentage_step;
   int           l_rc;
   gint32        l_max_master_frame_nr;
   gint32        l_cnt_encoded_frames;
@@ -3422,11 +3386,14 @@
   t_awk_array   l_awk_arr;
   t_awk_array   *awp;
   GapCodecNameElem    *l_vcodec_list;
-  GapGveMasterEncoderStatus encStatus;
 
 
   epp = &gpp->evl;
   awp = &l_awk_arr;
+
+  encStatusPtr->current_pass = current_pass;
+  encStatusPtr->frames_processed = 0;
+
   l_cnt_encoded_frames = 0;
   l_cnt_reused_frames = 0;
   p_init_audio_workdata(awp);
@@ -3437,6 +3404,7 @@
   //if(gap_debug)
   {
      printf("p_ffmpeg_encode: START\n");
+     printf("  current_pass: %d (twoPassFlag:%d)\n", current_pass, epp->twoPassFlag);
      printf("  videoname: %s\n", gpp->val.videoname);
      printf("  audioname1: %s\n", gpp->val.audioname1);
      printf("  basename: %s\n", gpp->ainfo.basename);
@@ -3457,6 +3425,8 @@
      printf("  master_encoder_id:%d:\n", gpp->val.master_encoder_id);
   }
 
+
+
   l_rc = 0;
   l_layer_id = -1;
 
@@ -3465,8 +3435,8 @@
     gint32 l_total_framecount;
     l_vidhand = gap_gve_story_open_vid_handle (gpp->val.input_mode
                                        ,gpp->val.image_ID
-				       ,gpp->val.storyboard_file
-				       ,gpp->ainfo.basename
+                                       ,gpp->val.storyboard_file
+                                       ,gpp->ainfo.basename
                                        ,gpp->ainfo.extension
                                        ,gpp->val.range_from
                                        ,gpp->val.range_to
@@ -3477,8 +3447,9 @@
     l_vidhand->do_gimp_progress = FALSE;
   }
 
-  /* TODO check for overwrite (in case we are called non-interactive) */
-
+  /* TODO check for overwrite (in case we are called non-interactive)
+   * overwrite check shall be done only if (current_pass < 2) 
+   */
 
   if (gap_debug) printf("Creating ffmpeg file.\n");
 
@@ -3490,7 +3461,7 @@
   /* OPEN the video file for write (create)
    *  successful open returns initialized FFMPEG handle structure
    */
-  ffh = p_ffmpeg_open(gpp, 0, awp, l_video_tracks);
+  ffh = p_ffmpeg_open(gpp, current_pass, awp, l_video_tracks);
   if(ffh == NULL)
   {
     p_close_audio_input_files(awp);
@@ -3498,15 +3469,6 @@
   }
 
 
-  l_percentage = 0.0;
-  if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
-  {
-    gap_gve_misc_initGapGveMasterEncoderStatus(&encStatus
-       , gpp->val.master_encoder_id
-       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
-       );
-  }
-
 
   /* Calculations for encoding the sound */
   p_sound_precalculations(ffh, awp, gpp);
@@ -3518,13 +3480,10 @@
   if(gpp->val.range_from > gpp->val.range_to)
   {
     l_step  = -1;     /* operate in descending (reverse) order */
-    l_percentage_step = 1.0 / ((1.0 + gpp->val.range_from) - gpp->val.range_to);
-
   }
   else
   {
     l_step  = 1;      /* operate in ascending order */
-    l_percentage_step = 1.0 / ((1.0 + gpp->val.range_to) - gpp->val.range_from);
   }
   l_begin = gpp->val.range_from;
   l_end   = gpp->val.range_to;
@@ -3560,8 +3519,8 @@
                                            , ffh->vst[0].video_buffer
                                            , &l_video_frame_chunk_size
                                            , ffh->vst[0].video_buffer_size    /* IN max size */
-					   , gpp->val.framerate
-					   , l_max_master_frame_nr
+                                           , gpp->val.framerate
+                                           , l_max_master_frame_nr
                                            , &l_video_frame_chunk_hdr_size
                                            , l_check_flags
                                            );
@@ -3582,9 +3541,9 @@
       {
         l_cnt_reused_frames++;
         if (gap_debug)
-	{
-	  printf("DEBUG: 1:1 copy of frame %d\n", (int)l_cur_frame_nr);
-	}
+        {
+          printf("DEBUG: 1:1 copy of frame %d\n", (int)l_cur_frame_nr);
+        }
 
         /* dont recode, just copy video chunk to output videofile */
         p_ffmpeg_write_frame_chunk(ffh, l_video_frame_chunk_size, 0 /* vid_track */);
@@ -3594,13 +3553,13 @@
         l_cnt_encoded_frames++;
         l_drawable = gimp_drawable_get (l_layer_id);
 
-	if (gap_debug)
-	{
-	  printf("DEBUG: %s encoding frame %d\n"
-	        , epp->vcodec_name
-		, (int)l_cur_frame_nr
-		);
-	}
+        if (gap_debug)
+        {
+          printf("DEBUG: %s encoding frame %d\n"
+                , epp->vcodec_name
+                , (int)l_cur_frame_nr
+                );
+        }
 
 
         /* fill the yuv420_buffer with current frame image data */
@@ -3625,22 +3584,17 @@
     }
 
 
-    l_percentage += l_percentage_step;
-    if(gap_debug)
-    {
-      printf("PROGRESS: %f\n", (float) l_percentage);
-    }
     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
     {
-      encStatus.frames_processed++;
-      encStatus.frames_encoded = l_cnt_encoded_frames;
-      encStatus.frames_copied_lossless = l_cnt_reused_frames;
+      encStatusPtr->frames_processed++;
+      encStatusPtr->frames_encoded = l_cnt_encoded_frames;
+      encStatusPtr->frames_copied_lossless = l_cnt_reused_frames;
 
-      gap_gve_misc_do_master_encoder_progress(&encStatus);
+      gap_gve_misc_do_master_encoder_progress(encStatusPtr);
     }
 
     /* terminate on cancel reqeuset (CANCEL button was pressed in the master encoder dialog) */
-    if(gap_gve_misc_is_master_encoder_cancel_request(&encStatus))
+    if(gap_gve_misc_is_master_encoder_cancel_request(encStatusPtr))
     {
        break;
     }
@@ -3692,10 +3646,63 @@
   /* statistics */
   if(gap_debug)
   {
+    printf("current_pass          %d\n", (int)current_pass);
     printf("encoded       frames: %d\n", (int)l_cnt_encoded_frames);
     printf("1:1 copied    frames: %d\n", (int)l_cnt_reused_frames);
     printf("total handled frames: %d\n", (int)l_cnt_encoded_frames + l_cnt_reused_frames);
   }
   
   return l_rc;
+}    /* end p_ffmpeg_encode_pass */
+
+
+/* ---------------------------
+ * p_ffmpeg_encode
+ * ---------------------------
+ *    The main "productive" routine
+ *    ffmpeg encoding of anim frames, based on ffmpeg lib (by Fabrice Bellard)
+ *    Audio encoding is Optional.
+ *    (wav_audiofile must be provided in that case)
+ *
+ * returns   value >= 0 if ok
+ *           (or -1 on error)
+ */
+static gint
+p_ffmpeg_encode(GapGveFFMpegGlobalParams *gpp)
+{
+  GapGveFFMpegValues   *epp = NULL;
+  gint32        l_current_pass = 0;  /* 0 for standard encoding, for 2-pass encoding loop from 1 to 2 */
+  gint l_rc;
+  GapGveMasterEncoderStatus encStatus;
+  GapGveMasterEncoderStatus *encStatusPtr;
+
+  epp = &gpp->evl;
+  encStatusPtr = &encStatus;
+
+  if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
+  {
+    gap_gve_misc_initGapGveMasterEncoderStatus(encStatusPtr
+       , gpp->val.master_encoder_id
+       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
+       );
+  }
+
+
+  if (epp->twoPassFlag == TRUE)
+  {
+    l_current_pass = 1;
+    l_rc = p_ffmpeg_encode_pass(gpp, l_current_pass, encStatusPtr);
+    if (l_rc >= 0)
+    {
+      l_current_pass = 2;
+      l_rc = p_ffmpeg_encode_pass(gpp, l_current_pass, encStatusPtr);
+    }
+  }
+  else
+  {
+    l_current_pass = 0;
+    l_rc = p_ffmpeg_encode_pass(gpp, l_current_pass, encStatusPtr);
+  }
+
+  return l_rc;
 }    /* end p_ffmpeg_encode */

Modified: trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.h
==============================================================================
--- trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.h	(original)
+++ trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.h	Fri Feb 13 19:04:39 2009
@@ -173,7 +173,7 @@
 
 
 
-/* ffmpeg specific encoder params */
+/* GapGveFFMpegValues ffmpeg specific encoder params */
 typedef struct {
   char    current_vid_extension[80];
 
@@ -186,7 +186,8 @@
   char    copyright[40];
   char    comment[80];
   char    passlogfile[512];
-  gint32  pass;
+  gint32  pass_nr;
+  gint32  twoPassFlag;
 
   gint32  audio_bitrate;
   gint32  video_bitrate;
@@ -253,7 +254,6 @@
   gint32 use_obmc;
   gint32 use_loop;
   gint32 use_alt_scan;
-  gint32 use_trell;
   gint32 use_mv0;
   gint32 do_normalize_aqp;
   gint32 use_scan_offset;
@@ -307,6 +307,77 @@
   gint32  pal_width;
   gint32  pal_height;
 
+  /* new parms 2009.01.31 */
+  
+  gint32  b_frame_strategy;
+  gint32  workaround_bugs;
+  gint32  error_recognition;
+  gint32  mpeg_quant;
+  gdouble rc_qsquish;
+  gdouble rc_qmod_amp;
+  gint32  rc_qmod_freq;
+  char    rc_eq[60];
+  gdouble rc_buffer_aggressivity;
+  gint32  dia_size;
+  gint32  last_predictor_count;
+  gint32  pre_dia_size;
+  gint32  inter_threshold;
+  gdouble border_masking;
+  gint32  me_penalty_compensation;
+  gint32  bidir_refine;
+  gint32  brd_scale;
+  gdouble crf;
+  gint32  cqp;
+  gint32  keyint_min;
+  gint32  refs;
+  gint32  chromaoffset;        
+  gint32  bframebias;
+  gint32  trellis;
+  gdouble complexityblur;
+  gint32  deblockalpha;
+  gint32  deblockbeta;
+  gint32  partitions;
+  gint32  directpred;
+  gint32  cutoff;
+  gint32  scenechange_factor;
+  gint32  mv0_threshold;
+  gint32  b_sensitivity;
+  gint32  compression_level;
+  gint32  use_lpc;
+  gint32  lpc_coeff_precision;
+  gint32  min_prediction_order;
+  gint32  max_prediction_order;
+  gint32  prediction_order_method;
+  gint32  min_partition_order;
+  gint64  timecode_frame_start;
+  gint64  bits_per_raw_sample;
+  gint64  channel_layout;
+  gdouble rc_max_available_vbv_use;
+  gdouble rc_min_vbv_overflow_use;
+
+  gint32 codec_FLAG_GMC;
+  gint32 codec_FLAG_INPUT_PRESERVED;
+  gint32 codec_FLAG_GRAY;
+  gint32 codec_FLAG_EMU_EDGE;
+  gint32 codec_FLAG_TRUNCATED;
+
+  gint32 codec_FLAG2_FAST;
+  gint32 codec_FLAG2_LOCAL_HEADER;
+  gint32 codec_FLAG2_BPYRAMID;
+  gint32 codec_FLAG2_WPRED;
+  gint32 codec_FLAG2_MIXED_REFS;
+  gint32 codec_FLAG2_8X8DCT;
+  gint32 codec_FLAG2_FASTPSKIP;
+  gint32 codec_FLAG2_AUD;
+  gint32 codec_FLAG2_BRDO;
+  gint32 codec_FLAG2_INTRA_VLC;
+  gint32 codec_FLAG2_MEMC_ONLY;
+  gint32 codec_FLAG2_DROP_FRAME_TIMECODE;
+  gint32 codec_FLAG2_SKIP_RD;
+  gint32 codec_FLAG2_CHUNKS;
+  gint32 codec_FLAG2_NON_LINEAR_QUANT;
+  gint32 codec_FLAG2_BIT_RESERVOIR;
+
 } GapGveFFMpegValues;
 
 
@@ -388,7 +459,6 @@
   GtkWidget *ff_use_obmc_checkbutton;
   GtkWidget *ff_use_loop_checkbutton;
   GtkWidget *ff_use_alt_scan_checkbutton;
-  GtkWidget *ff_use_trell_checkbutton;
   GtkWidget *ff_use_mv0_checkbutton;
   GtkWidget *ff_do_normalize_aqp_checkbutton;
   GtkWidget *ff_use_scan_offset_checkbutton;
@@ -401,6 +471,34 @@
   GtkWidget *ff_strict_gop_checkbutton;
   GtkWidget *ff_no_output_checkbutton;
 
+
+  GtkWidget *ff_codec_FLAG_GMC_checkbutton;
+  GtkWidget *ff_codec_FLAG_INPUT_PRESERVED_checkbutton;
+  GtkWidget *ff_codec_FLAG_GRAY_checkbutton;
+  GtkWidget *ff_codec_FLAG_EMU_EDGE_checkbutton;
+  GtkWidget *ff_codec_FLAG_TRUNCATED_checkbutton;
+
+  GtkWidget *ff_codec_FLAG2_FAST_checkbutton;
+  GtkWidget *ff_codec_FLAG2_LOCAL_HEADER_checkbutton;
+  GtkWidget *ff_codec_FLAG2_BPYRAMID_checkbutton;
+  GtkWidget *ff_codec_FLAG2_WPRED_checkbutton;
+  GtkWidget *ff_codec_FLAG2_MIXED_REFS_checkbutton;
+  GtkWidget *ff_codec_FLAG2_8X8DCT_checkbutton;
+  GtkWidget *ff_codec_FLAG2_FASTPSKIP_checkbutton;
+  GtkWidget *ff_codec_FLAG2_AUD_checkbutton;
+  GtkWidget *ff_codec_FLAG2_BRDO_checkbutton;
+  GtkWidget *ff_codec_FLAG2_INTRA_VLC_checkbutton;
+  GtkWidget *ff_codec_FLAG2_MEMC_ONLY_checkbutton;
+  GtkWidget *ff_codec_FLAG2_DROP_FRAME_TIMECODE_checkbutton;
+  GtkWidget *ff_codec_FLAG2_SKIP_RD_checkbutton;
+  GtkWidget *ff_codec_FLAG2_CHUNKS_checkbutton;
+  GtkWidget *ff_codec_FLAG2_NON_LINEAR_QUANT_checkbutton;
+  GtkWidget *ff_codec_FLAG2_BIT_RESERVOIR_checkbutton;
+
+
+
+
+
   GtkWidget *ff_mux_rate_spinbutton;
   GtkWidget *ff_mux_packet_size_spinbutton;
   GtkWidget *ff_mux_preload_spinbutton;

Modified: trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_par.c
==============================================================================
--- trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_par.c	(original)
+++ trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_par.c	Fri Feb 13 19:04:39 2009
@@ -43,131 +43,217 @@
 
 
 /* --------------------------
+ * p_set_keyword_bool32
+ * --------------------------
+ * helper procedure to set keyword for flags of type GAP_VAL_G32BOOLEAN.
+ */
+static void
+p_set_keyword_bool32(GapValKeyList *keylist, const char *key, void *addr, const char *comment)
+{
+   gap_val_set_keyword(keylist, key, addr,  GAP_VAL_G32BOOLEAN, 0, comment);
+}
+
+
+/* --------------------------
  * p_set_master_keywords
  * --------------------------
+ * set keywords for the ffmpeg encoder preset fileformat and assign
+ * adresspointers to the relevant parameter, datatype (how to scan value when parameter are read from file)
+ * and comment string (that is added to the parameter when saved to file)
  */
 static void
-p_set_master_keywords(GapValKeyList *keylist, GapGveFFMpegValues *ffpar_ptr)
+p_set_master_keywords(GapValKeyList *keylist, GapGveFFMpegValues *epp)
 {
 
-   gap_val_set_keyword(keylist, "(format_name ",   &ffpar_ptr->format_name[0], GAP_VAL_STRING, sizeof(ffpar_ptr->format_name), "\0");
-   gap_val_set_keyword(keylist, "(vcodec_name ",   &ffpar_ptr->vcodec_name[0], GAP_VAL_STRING, sizeof(ffpar_ptr->vcodec_name), "\0");
-   gap_val_set_keyword(keylist, "(acodec_name ",   &ffpar_ptr->acodec_name[0], GAP_VAL_STRING, sizeof(ffpar_ptr->acodec_name), "\0");
-   gap_val_set_keyword(keylist, "(title ",         &ffpar_ptr->title[0],       GAP_VAL_STRING, sizeof(ffpar_ptr->title), "\0");
-   gap_val_set_keyword(keylist, "(author ",        &ffpar_ptr->author[0],      GAP_VAL_STRING, sizeof(ffpar_ptr->author), "\0");
-   gap_val_set_keyword(keylist, "(copyright ",     &ffpar_ptr->copyright[0],   GAP_VAL_STRING, sizeof(ffpar_ptr->copyright), "\0");
-   gap_val_set_keyword(keylist, "(comment ",       &ffpar_ptr->comment[0],     GAP_VAL_STRING, sizeof(ffpar_ptr->comment), "\0");
-   gap_val_set_keyword(keylist, "(passlogfile ",   &ffpar_ptr->passlogfile[0], GAP_VAL_STRING, sizeof(ffpar_ptr->passlogfile), "\0");
-
-   gap_val_set_keyword(keylist, "(pass ",          &ffpar_ptr->pass,           GAP_VAL_GINT32, 0, "\0");
-   gap_val_set_keyword(keylist, "(audio_bitrate ", &ffpar_ptr->audio_bitrate,  GAP_VAL_GINT32, 0, "# audio bitrate in kBit/sec");
-   gap_val_set_keyword(keylist, "(video_bitrate ", &ffpar_ptr->video_bitrate,  GAP_VAL_GINT32, 0, "# video bitrate in kBit/sec\0");
-   gap_val_set_keyword(keylist, "(gop_size ",      &ffpar_ptr->gop_size,       GAP_VAL_GINT32, 0, "# group of picture size");
-   gap_val_set_keyword(keylist, "(intra ",         &ffpar_ptr->intra,          GAP_VAL_G32BOOLEAN, 0, "# use only intra frames");
-   gap_val_set_keyword(keylist, "(qscale ",        &ffpar_ptr->qscale,         GAP_VAL_GDOUBLE, 0, "# use fixed video quantiser scale (VBR). 0=const bitrate");
-   gap_val_set_keyword(keylist, "(qmin ",          &ffpar_ptr->qmin,           GAP_VAL_GINT32, 0, "# min video quantiser scale (VBR)");
-   gap_val_set_keyword(keylist, "(qmax ",          &ffpar_ptr->qmax,           GAP_VAL_GINT32, 0, "# max video quantiser scale (VBR)");
-   gap_val_set_keyword(keylist, "(qdiff ",         &ffpar_ptr->qdiff,          GAP_VAL_GINT32, 0, "# max difference between the quantiser scale (VBR)");
-   gap_val_set_keyword(keylist, "(qblur ",         &ffpar_ptr->qblur,          GAP_VAL_GDOUBLE, 0, "# video quantiser scale blur (VBR)");
-   gap_val_set_keyword(keylist, "(qcomp ",         &ffpar_ptr->qcomp,          GAP_VAL_GDOUBLE, 0, "# video quantiser scale compression (VBR)");
-   gap_val_set_keyword(keylist, "(rc_init_cplx ",  &ffpar_ptr->rc_init_cplx,   GAP_VAL_GDOUBLE, 0, "# initial complexity for 1-pass encoding");
-   gap_val_set_keyword(keylist, "(b_qfactor ",     &ffpar_ptr->b_qfactor,      GAP_VAL_GDOUBLE, 0, "# qp factor between p and b frames");
-   gap_val_set_keyword(keylist, "(i_qfactor ",     &ffpar_ptr->i_qfactor,      GAP_VAL_GDOUBLE, 0, "# qp factor between p and i frames");
-   gap_val_set_keyword(keylist, "(b_qoffset ",     &ffpar_ptr->b_qoffset,      GAP_VAL_GDOUBLE, 0, "# qp offset between p and b frames");
-   gap_val_set_keyword(keylist, "(i_qoffset ",     &ffpar_ptr->i_qoffset,      GAP_VAL_GDOUBLE, 0, "# qp offset between p and i frames");
-   gap_val_set_keyword(keylist, "(bitrate_tol ",   &ffpar_ptr->bitrate_tol,    GAP_VAL_GINT32, 0, "# set video bitrate tolerance (in kbit/s)");
-   gap_val_set_keyword(keylist, "(maxrate_tol ",   &ffpar_ptr->maxrate_tol,    GAP_VAL_GINT32, 0, "# set max video bitrate tolerance (in kbit/s)");
-   gap_val_set_keyword(keylist, "(minrate_tol ",   &ffpar_ptr->minrate_tol,    GAP_VAL_GINT32, 0, "# set min video bitrate tolerance (in kbit/s)");
-   gap_val_set_keyword(keylist, "(bufsize ",       &ffpar_ptr->bufsize,        GAP_VAL_GINT32, 0, "# set ratecontrol buffere size (in kbit)");
-   gap_val_set_keyword(keylist, "(motion_estimation ", &ffpar_ptr->motion_estimation,           GAP_VAL_GINT32, 0, "# algorithm for motion estimation (1-6)");
-   gap_val_set_keyword(keylist, "(dct_algo ",      &ffpar_ptr->dct_algo,       GAP_VAL_GINT32, 0, "# algorithm for DCT (0-6)");
-   gap_val_set_keyword(keylist, "(idct_algo ",     &ffpar_ptr->idct_algo,      GAP_VAL_GINT32, 0, "# algorithm for IDCT (0-11)");
-   gap_val_set_keyword(keylist, "(strict ",        &ffpar_ptr->strict,         GAP_VAL_GINT32, 0, "# how strictly to follow the standards");
-   gap_val_set_keyword(keylist, "(mb_qmin ",       &ffpar_ptr->mb_qmin,        GAP_VAL_GINT32, 0, "# min macroblock quantiser scale (VBR)");
-   gap_val_set_keyword(keylist, "(mb_qmax ",       &ffpar_ptr->mb_qmax,        GAP_VAL_GINT32, 0, "# max macroblock quantiser scale (VBR)");
-   gap_val_set_keyword(keylist, "(mb_decision ",   &ffpar_ptr->mb_decision,    GAP_VAL_GINT32, 0, "# algorithm for macroblock decision (0-2)");
-   gap_val_set_keyword(keylist, "(aic ",           &ffpar_ptr->aic,            GAP_VAL_G32BOOLEAN, 0, "# activate intra frame coding (only h263+ CODEC)");
-   gap_val_set_keyword(keylist, "(umv ",           &ffpar_ptr->umv,            GAP_VAL_G32BOOLEAN, 0, "# enable unlimited motion vector (only h263+ CODEC)");
-   gap_val_set_keyword(keylist, "(b_frames ",      &ffpar_ptr->b_frames,       GAP_VAL_GINT32, 0, "# max number of B-frames in sequence");
-   gap_val_set_keyword(keylist, "(mv4 ",           &ffpar_ptr->mv4,            GAP_VAL_G32BOOLEAN, 0, "# use four motion vector by macroblock (only MPEG-4 CODEC)");
-   gap_val_set_keyword(keylist, "(partitioning ",  &ffpar_ptr->partitioning,   GAP_VAL_G32BOOLEAN, 0, "# use data partitioning (only MPEG-4 CODEC)");
-   gap_val_set_keyword(keylist, "(packet_size ",   &ffpar_ptr->packet_size,    GAP_VAL_GINT32, 0, "\0");
-
-   /* debug options */
-   /* gint32  benchmark; */
-   /* gint32  hex_dump; */
-   /* gint32  psnr; */
-   /* gint32  vstats; */
-   gap_val_set_keyword(keylist, "(bitexact ",      &ffpar_ptr->bitexact,       GAP_VAL_G32BOOLEAN, 0, "\0");
-   gap_val_set_keyword(keylist, "(set_aspect_ratio ",     &ffpar_ptr->set_aspect_ratio,    GAP_VAL_G32BOOLEAN, 0, "# store aspectratio information (width/height) in the output video");
-   gap_val_set_keyword(keylist, "(factor_aspect_ratio ",  &ffpar_ptr->factor_aspect_ratio, GAP_VAL_GDOUBLE, 0, "# the aspect ratio (width/height). 0.0 = auto ratio assuming sqaure pixels");
-   gap_val_set_keyword(keylist, "(dont_recode_flag ",     &ffpar_ptr->dont_recode_flag,    GAP_VAL_GBOOLEAN, 0, "# bypass the video encoder where frames can be copied 1:1");
+   gap_val_set_keyword(keylist, "(format_name ",   &epp->format_name[0], GAP_VAL_STRING, sizeof(epp->format_name), "\0");
+   gap_val_set_keyword(keylist, "(vcodec_name ",   &epp->vcodec_name[0], GAP_VAL_STRING, sizeof(epp->vcodec_name), "\0");
+   gap_val_set_keyword(keylist, "(acodec_name ",   &epp->acodec_name[0], GAP_VAL_STRING, sizeof(epp->acodec_name), "\0");
+   gap_val_set_keyword(keylist, "(title ",         &epp->title[0],       GAP_VAL_STRING, sizeof(epp->title), "\0");
+   gap_val_set_keyword(keylist, "(author ",        &epp->author[0],      GAP_VAL_STRING, sizeof(epp->author), "\0");
+   gap_val_set_keyword(keylist, "(copyright ",     &epp->copyright[0],   GAP_VAL_STRING, sizeof(epp->copyright), "\0");
+   gap_val_set_keyword(keylist, "(comment ",       &epp->comment[0],     GAP_VAL_STRING, sizeof(epp->comment), "\0");
+   gap_val_set_keyword(keylist, "(passlogfile ",   &epp->passlogfile[0], GAP_VAL_STRING, sizeof(epp->passlogfile), "\0");
+
+   gap_val_set_keyword(keylist, "(pass ",          &epp->pass_nr,        GAP_VAL_GINT32, 0, "# 1: one pass encoding, 2: for two-pass encoding");
+   gap_val_set_keyword(keylist, "(audio_bitrate ", &epp->audio_bitrate,  GAP_VAL_GINT32, 0, "# audio bitrate in kBit/sec");
+   gap_val_set_keyword(keylist, "(video_bitrate ", &epp->video_bitrate,  GAP_VAL_GINT32, 0, "# video bitrate in kBit/sec\0");
+   gap_val_set_keyword(keylist, "(gop_size ",      &epp->gop_size,       GAP_VAL_GINT32, 0, "# group of picture size");
+   gap_val_set_keyword(keylist, "(qscale ",        &epp->qscale,         GAP_VAL_GDOUBLE, 0, "# use fixed video quantiser scale (VBR). 0=const bitrate");
+   gap_val_set_keyword(keylist, "(qmin ",          &epp->qmin,           GAP_VAL_GINT32, 0, "# min video quantiser scale (VBR)");
+   gap_val_set_keyword(keylist, "(qmax ",          &epp->qmax,           GAP_VAL_GINT32, 0, "# max video quantiser scale (VBR)");
+   gap_val_set_keyword(keylist, "(qdiff ",         &epp->qdiff,          GAP_VAL_GINT32, 0, "# max difference between the quantiser scale (VBR)");
+   gap_val_set_keyword(keylist, "(qblur ",         &epp->qblur,          GAP_VAL_GDOUBLE, 0, "# video quantiser scale blur (VBR)");
+   gap_val_set_keyword(keylist, "(qcomp ",         &epp->qcomp,          GAP_VAL_GDOUBLE, 0, "# video quantiser scale compression (VBR)");
+   gap_val_set_keyword(keylist, "(rc_init_cplx ",  &epp->rc_init_cplx,   GAP_VAL_GDOUBLE, 0, "# initial complexity for 1-pass encoding");
+   gap_val_set_keyword(keylist, "(b_qfactor ",     &epp->b_qfactor,      GAP_VAL_GDOUBLE, 0, "# qp factor between p and b frames");
+   gap_val_set_keyword(keylist, "(i_qfactor ",     &epp->i_qfactor,      GAP_VAL_GDOUBLE, 0, "# qp factor between p and i frames");
+   gap_val_set_keyword(keylist, "(b_qoffset ",     &epp->b_qoffset,      GAP_VAL_GDOUBLE, 0, "# qp offset between p and b frames");
+   gap_val_set_keyword(keylist, "(i_qoffset ",     &epp->i_qoffset,      GAP_VAL_GDOUBLE, 0, "# qp offset between p and i frames");
+   gap_val_set_keyword(keylist, "(bitrate_tol ",   &epp->bitrate_tol,    GAP_VAL_GINT32, 0, "# set video bitrate tolerance (in kbit/s)");
+   gap_val_set_keyword(keylist, "(maxrate_tol ",   &epp->maxrate_tol,    GAP_VAL_GINT32, 0, "# set max video bitrate tolerance (in kbit/s)");
+   gap_val_set_keyword(keylist, "(minrate_tol ",   &epp->minrate_tol,    GAP_VAL_GINT32, 0, "# set min video bitrate tolerance (in kbit/s)");
+   gap_val_set_keyword(keylist, "(bufsize ",       &epp->bufsize,        GAP_VAL_GINT32, 0, "# set ratecontrol buffere size (in kbit)");
+   gap_val_set_keyword(keylist, "(motion_estimation ", &epp->motion_estimation,           GAP_VAL_GINT32, 0, "# algorithm for motion estimation (1-6)");
+   gap_val_set_keyword(keylist, "(dct_algo ",      &epp->dct_algo,       GAP_VAL_GINT32, 0, "# algorithm for DCT (0-6)");
+   gap_val_set_keyword(keylist, "(idct_algo ",     &epp->idct_algo,      GAP_VAL_GINT32, 0, "# algorithm for IDCT (0-11)");
+   gap_val_set_keyword(keylist, "(strict ",        &epp->strict,         GAP_VAL_GINT32, 0, "# how strictly to follow the standards");
+   gap_val_set_keyword(keylist, "(mb_qmin ",       &epp->mb_qmin,        GAP_VAL_GINT32, 0, "# min macroblock quantiser scale (VBR)");
+   gap_val_set_keyword(keylist, "(mb_qmax ",       &epp->mb_qmax,        GAP_VAL_GINT32, 0, "# max macroblock quantiser scale (VBR)");
+   gap_val_set_keyword(keylist, "(mb_decision ",   &epp->mb_decision,    GAP_VAL_GINT32, 0, "# algorithm for macroblock decision (0-2)");
+   gap_val_set_keyword(keylist, "(b_frames ",      &epp->b_frames,       GAP_VAL_GINT32, 0, "# max number of B-frames in sequence");
+   gap_val_set_keyword(keylist, "(packet_size ",   &epp->packet_size,    GAP_VAL_GINT32, 0, "\0");
+
+   gap_val_set_keyword(keylist, "(intra ",                &epp->intra,               GAP_VAL_G32BOOLEAN, 0, "# use only intra frames");
+   gap_val_set_keyword(keylist, "(set_aspect_ratio ",     &epp->set_aspect_ratio,    GAP_VAL_G32BOOLEAN, 0, "# store aspectratio information (width/height) in the output video");
+   gap_val_set_keyword(keylist, "(factor_aspect_ratio ",  &epp->factor_aspect_ratio, GAP_VAL_GDOUBLE, 0, "# the aspect ratio (width/height). 0.0 = auto ratio assuming sqaure pixels");
+   gap_val_set_keyword(keylist, "(dont_recode_flag ",     &epp->dont_recode_flag,    GAP_VAL_GBOOLEAN, 0, "# bypass the video encoder where frames can be copied 1:1");
 
    /* new params (introduced with ffmpeg 0.4.9pre1) */
-   gap_val_set_keyword(keylist, "(thread_count ",         &ffpar_ptr->thread_count,        GAP_VAL_GINT32, 0, "\0");
-   gap_val_set_keyword(keylist, "(mb_cmp ",               &ffpar_ptr->mb_cmp,              GAP_VAL_GINT32, 0, "# macroblock compare function (0-13,255)");
-   gap_val_set_keyword(keylist, "(ildct_cmp ",            &ffpar_ptr->ildct_cmp,           GAP_VAL_GINT32, 0, "# ildct compare function (0-13,255)");
-   gap_val_set_keyword(keylist, "(sub_cmp ",              &ffpar_ptr->sub_cmp,             GAP_VAL_GINT32, 0, "# subpel compare function (0-13,255)");
-   gap_val_set_keyword(keylist, "(cmp ",                  &ffpar_ptr->cmp,                 GAP_VAL_GINT32, 0, "# fullpel compare function (0-13,255)");
-   gap_val_set_keyword(keylist, "(pre_cmp ",              &ffpar_ptr->pre_cmp,             GAP_VAL_GINT32, 0, "# pre motion estimation compare function (0-13,255)");
-   gap_val_set_keyword(keylist, "(pre_me ",               &ffpar_ptr->pre_me,              GAP_VAL_GINT32, 0, "# pre motion estimation");
-   gap_val_set_keyword(keylist, "(lumi_mask ",            &ffpar_ptr->lumi_mask,           GAP_VAL_GDOUBLE, 0, "# luminance masking");
-   gap_val_set_keyword(keylist, "(dark_mask ",            &ffpar_ptr->dark_mask,           GAP_VAL_GDOUBLE, 0, "# darkness masking");
-   gap_val_set_keyword(keylist, "(scplx_mask ",           &ffpar_ptr->scplx_mask,          GAP_VAL_GDOUBLE, 0, "# spatial complexity masking");
-   gap_val_set_keyword(keylist, "(tcplx_mask ",           &ffpar_ptr->tcplx_mask,          GAP_VAL_GDOUBLE, 0, "# temporary complexity masking");
-   gap_val_set_keyword(keylist, "(p_mask ",               &ffpar_ptr->p_mask,              GAP_VAL_GDOUBLE, 0, "# p block masking");
-   gap_val_set_keyword(keylist, "(qns ",                  &ffpar_ptr->qns,                 GAP_VAL_GINT32, 0, "# quantization noise shaping");
-   gap_val_set_keyword(keylist, "(use_ss ",               &ffpar_ptr->use_ss,              GAP_VAL_G32BOOLEAN, 0, "# enable Slice Structured mode (h263+)");
-   gap_val_set_keyword(keylist, "(use_aiv ",              &ffpar_ptr->use_aiv,             GAP_VAL_G32BOOLEAN, 0, "# enable Alternative inter vlc (h263+)");
-   gap_val_set_keyword(keylist, "(use_obmc ",             &ffpar_ptr->use_obmc,            GAP_VAL_G32BOOLEAN, 0, "# use overlapped block motion compensation (h263+)");
-   gap_val_set_keyword(keylist, "(use_loop ",             &ffpar_ptr->use_loop,            GAP_VAL_G32BOOLEAN, 0, "# use loop filter (h263+)");
-   gap_val_set_keyword(keylist, "(use_alt_scan ",         &ffpar_ptr->use_alt_scan,        GAP_VAL_G32BOOLEAN, 0, "# enable alternate scantable (MPEG2/MPEG4)");
-   gap_val_set_keyword(keylist, "(use_trell ",            &ffpar_ptr->use_trell,           GAP_VAL_G32BOOLEAN, 0, "# enable trellis quantization");
-   gap_val_set_keyword(keylist, "(use_mv0 ",              &ffpar_ptr->use_mv0,             GAP_VAL_G32BOOLEAN, 0, "# try to encode each MB with MV=<0,0> and choose the better one (has no effect if mbd=0)");
-   gap_val_set_keyword(keylist, "(do_normalize_aqp ",     &ffpar_ptr->do_normalize_aqp,    GAP_VAL_G32BOOLEAN, 0, "# normalize adaptive quantization");
-   gap_val_set_keyword(keylist, "(use_scan_offset ",      &ffpar_ptr->use_scan_offset,     GAP_VAL_G32BOOLEAN, 0, "# enable SVCD Scan Offset placeholder");
-   gap_val_set_keyword(keylist, "(closed_gop ",           &ffpar_ptr->closed_gop,          GAP_VAL_G32BOOLEAN, 0, "# closed gop");
-   gap_val_set_keyword(keylist, "(use_qpel ",             &ffpar_ptr->use_qpel,            GAP_VAL_G32BOOLEAN, 0, "# enable 1/4-pel");
-   gap_val_set_keyword(keylist, "(use_qprd ",             &ffpar_ptr->use_qprd,            GAP_VAL_G32BOOLEAN, 0, "# use rate distortion optimization for qp selection");
-   gap_val_set_keyword(keylist, "(use_cbprd ",            &ffpar_ptr->use_cbprd,           GAP_VAL_G32BOOLEAN, 0, "# use rate distortion optimization for cbp");
-   gap_val_set_keyword(keylist, "(do_interlace_dct ",     &ffpar_ptr->do_interlace_dct,    GAP_VAL_G32BOOLEAN, 0, "# use interlaced dct");
-   gap_val_set_keyword(keylist, "(do_interlace_me ",      &ffpar_ptr->do_interlace_me,     GAP_VAL_G32BOOLEAN, 0, "# interlaced motion estimation");
-
-   gap_val_set_keyword(keylist, "(video_lmin ",           &ffpar_ptr->video_lmin,          GAP_VAL_GINT32, 0, "# min video lagrange factor (VBR) 0-3658");
-   gap_val_set_keyword(keylist, "(video_lmax ",           &ffpar_ptr->video_lmax,          GAP_VAL_GINT32, 0, "# max video lagrange factor (VBR) 0-3658");
-   gap_val_set_keyword(keylist, "(video_lelim ",          &ffpar_ptr->video_lelim,         GAP_VAL_GINT32, 0, "# luma elimination threshold");
-   gap_val_set_keyword(keylist, "(video_celim ",          &ffpar_ptr->video_celim,         GAP_VAL_GINT32, 0, "# chroma elimination threshold");
-   gap_val_set_keyword(keylist, "(video_intra_quant_bias ", &ffpar_ptr->video_intra_quant_bias, GAP_VAL_GINT32, 0, "# intra quant bias");
-   gap_val_set_keyword(keylist, "(video_inter_quant_bias ", &ffpar_ptr->video_inter_quant_bias, GAP_VAL_GINT32, 0, "# inter quant bias");
-   gap_val_set_keyword(keylist, "(me_threshold ",         &ffpar_ptr->me_threshold,        GAP_VAL_GINT32, 0, "# motion estimaton threshold");
-   gap_val_set_keyword(keylist, "(mb_threshold ",         &ffpar_ptr->mb_threshold,        GAP_VAL_GINT32, 0, "# macroblock threshold");
-   gap_val_set_keyword(keylist, "(intra_dc_precision ",   &ffpar_ptr->intra_dc_precision,  GAP_VAL_GINT32, 0, "# precision of the intra dc coefficient - 8");
-   gap_val_set_keyword(keylist, "(error_rate ",           &ffpar_ptr->error_rate,          GAP_VAL_GINT32, 0, "# simulates errors in the bitstream to test error concealment");
-   gap_val_set_keyword(keylist, "(noise_reduction ",      &ffpar_ptr->noise_reduction,     GAP_VAL_GINT32, 0, "# noise reduction strength");
-   gap_val_set_keyword(keylist, "(sc_threshold ",         &ffpar_ptr->sc_threshold,        GAP_VAL_GINT32, 0, "# scene change detection threshold");
-   gap_val_set_keyword(keylist, "(me_range ",             &ffpar_ptr->me_range,            GAP_VAL_GINT32, 0, "# limit motion vectors range (1023 for DivX player, 0 = no limit)");
-   gap_val_set_keyword(keylist, "(coder ",                &ffpar_ptr->coder,               GAP_VAL_GINT32, 0, "# coder type 0=VLC 1=AC");
-   gap_val_set_keyword(keylist, "(context ",              &ffpar_ptr->context,             GAP_VAL_GINT32, 0, "# context model");
-   gap_val_set_keyword(keylist, "(predictor ",            &ffpar_ptr->predictor,           GAP_VAL_GINT32, 0, "# prediction method (0 LEFT, 1 PLANE, 2 MEDIAN");
-   gap_val_set_keyword(keylist, "(nsse_weight ",          &ffpar_ptr->nsse_weight,         GAP_VAL_GINT32, 0, "# noise vs. sse weight for the nsse comparsion function.");
-   gap_val_set_keyword(keylist, "(subpel_quality ",       &ffpar_ptr->subpel_quality,      GAP_VAL_GINT32, 0, "# subpel ME quality");
+   gap_val_set_keyword(keylist, "(thread_count ",         &epp->thread_count,        GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(mb_cmp ",               &epp->mb_cmp,              GAP_VAL_GINT32, 0, "# macroblock compare function (0-13,255)");
+   gap_val_set_keyword(keylist, "(ildct_cmp ",            &epp->ildct_cmp,           GAP_VAL_GINT32, 0, "# ildct compare function (0-13,255)");
+   gap_val_set_keyword(keylist, "(sub_cmp ",              &epp->sub_cmp,             GAP_VAL_GINT32, 0, "# subpel compare function (0-13,255)");
+   gap_val_set_keyword(keylist, "(cmp ",                  &epp->cmp,                 GAP_VAL_GINT32, 0, "# fullpel compare function (0-13,255)");
+   gap_val_set_keyword(keylist, "(pre_cmp ",              &epp->pre_cmp,             GAP_VAL_GINT32, 0, "# pre motion estimation compare function (0-13,255)");
+   gap_val_set_keyword(keylist, "(pre_me ",               &epp->pre_me,              GAP_VAL_GINT32, 0, "# pre motion estimation");
+   gap_val_set_keyword(keylist, "(lumi_mask ",            &epp->lumi_mask,           GAP_VAL_GDOUBLE, 0, "# luminance masking");
+   gap_val_set_keyword(keylist, "(dark_mask ",            &epp->dark_mask,           GAP_VAL_GDOUBLE, 0, "# darkness masking");
+   gap_val_set_keyword(keylist, "(scplx_mask ",           &epp->scplx_mask,          GAP_VAL_GDOUBLE, 0, "# spatial complexity masking");
+   gap_val_set_keyword(keylist, "(tcplx_mask ",           &epp->tcplx_mask,          GAP_VAL_GDOUBLE, 0, "# temporary complexity masking");
+   gap_val_set_keyword(keylist, "(p_mask ",               &epp->p_mask,              GAP_VAL_GDOUBLE, 0, "# p block masking");
+   gap_val_set_keyword(keylist, "(qns ",                  &epp->qns,                 GAP_VAL_GINT32, 0, "# quantization noise shaping");
+
+   gap_val_set_keyword(keylist, "(video_lmin ",           &epp->video_lmin,          GAP_VAL_GINT32, 0, "# min video lagrange factor (VBR) 0-3658");
+   gap_val_set_keyword(keylist, "(video_lmax ",           &epp->video_lmax,          GAP_VAL_GINT32, 0, "# max video lagrange factor (VBR) 0-3658");
+   gap_val_set_keyword(keylist, "(video_lelim ",          &epp->video_lelim,         GAP_VAL_GINT32, 0, "# luma elimination threshold");
+   gap_val_set_keyword(keylist, "(video_celim ",          &epp->video_celim,         GAP_VAL_GINT32, 0, "# chroma elimination threshold");
+   gap_val_set_keyword(keylist, "(video_intra_quant_bias ", &epp->video_intra_quant_bias, GAP_VAL_GINT32, 0, "# intra quant bias");
+   gap_val_set_keyword(keylist, "(video_inter_quant_bias ", &epp->video_inter_quant_bias, GAP_VAL_GINT32, 0, "# inter quant bias");
+   gap_val_set_keyword(keylist, "(me_threshold ",         &epp->me_threshold,        GAP_VAL_GINT32, 0, "# motion estimaton threshold");
+   gap_val_set_keyword(keylist, "(mb_threshold ",         &epp->mb_threshold,        GAP_VAL_GINT32, 0, "# macroblock threshold");
+   gap_val_set_keyword(keylist, "(intra_dc_precision ",   &epp->intra_dc_precision,  GAP_VAL_GINT32, 0, "# precision of the intra dc coefficient - 8");
+   gap_val_set_keyword(keylist, "(error_rate ",           &epp->error_rate,          GAP_VAL_GINT32, 0, "# simulates errors in the bitstream to test error concealment");
+   gap_val_set_keyword(keylist, "(noise_reduction ",      &epp->noise_reduction,     GAP_VAL_GINT32, 0, "# noise reduction strength");
+   gap_val_set_keyword(keylist, "(sc_threshold ",         &epp->sc_threshold,        GAP_VAL_GINT32, 0, "# scene change detection threshold");
+   gap_val_set_keyword(keylist, "(me_range ",             &epp->me_range,            GAP_VAL_GINT32, 0, "# limit motion vectors range (1023 for DivX player, 0 = no limit)");
+   gap_val_set_keyword(keylist, "(coder ",                &epp->coder,               GAP_VAL_GINT32, 0, "# coder type 0=VLC 1=AC");
+   gap_val_set_keyword(keylist, "(context ",              &epp->context,             GAP_VAL_GINT32, 0, "# context model");
+   gap_val_set_keyword(keylist, "(predictor ",            &epp->predictor,           GAP_VAL_GINT32, 0, "# prediction method (0 LEFT, 1 PLANE, 2 MEDIAN");
+   gap_val_set_keyword(keylist, "(nsse_weight ",          &epp->nsse_weight,         GAP_VAL_GINT32, 0, "# noise vs. sse weight for the nsse comparsion function.");
+   gap_val_set_keyword(keylist, "(subpel_quality ",       &epp->subpel_quality,      GAP_VAL_GINT32, 0, "# subpel ME quality");
 
    /* new parms (found CVS version 2005.03.02 == LIBAVCODEC_BUILD 4744 ) */
-   gap_val_set_keyword(keylist, "(strict_gop ",           &ffpar_ptr->strict_gop,          GAP_VAL_GINT32, 0, "# strictly enforce GOP size");
-   gap_val_set_keyword(keylist, "(no_output ",            &ffpar_ptr->no_output,           GAP_VAL_GINT32, 0, "# skip bitstream encoding");
-   gap_val_set_keyword(keylist, "(video_mb_lmin ",        &ffpar_ptr->video_mb_lmin,       GAP_VAL_GINT32, 0, "# min macroblock quantiser scale (VBR) 0-3658");
-   gap_val_set_keyword(keylist, "(video_mb_lmax ",        &ffpar_ptr->video_mb_lmax,       GAP_VAL_GINT32, 0, "# max macroblock quantiser scale (VBR) 0-3658");
-   gap_val_set_keyword(keylist, "(video_profile ",        &ffpar_ptr->video_profile,       GAP_VAL_GINT32, 0, "\0");
-   gap_val_set_keyword(keylist, "(video_level ",          &ffpar_ptr->video_level,         GAP_VAL_GINT32, 0, "\0");
-   gap_val_set_keyword(keylist, "(frame_skip_threshold ", &ffpar_ptr->frame_skip_threshold,GAP_VAL_GINT32, 0, "# frame skip threshold");
-   gap_val_set_keyword(keylist, "(frame_skip_factor ",    &ffpar_ptr->frame_skip_factor,   GAP_VAL_GINT32, 0, "# frame skip factor");
-   gap_val_set_keyword(keylist, "(frame_skip_exp ",       &ffpar_ptr->frame_skip_exp,      GAP_VAL_GINT32, 0, "# frame skip exponent");
-   gap_val_set_keyword(keylist, "(frame_skip_cmp ",       &ffpar_ptr->frame_skip_cmp,      GAP_VAL_GINT32, 0, "# frame skip comparission function");
-   gap_val_set_keyword(keylist, "(mux_rate ",             &ffpar_ptr->mux_rate,            GAP_VAL_GINT32, 0, "\0");
-   gap_val_set_keyword(keylist, "(mux_packet_size ",      &ffpar_ptr->mux_packet_size,     GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(strict_gop ",           &epp->strict_gop,          GAP_VAL_GINT32, 0, "# strictly enforce GOP size");
+   gap_val_set_keyword(keylist, "(no_output ",            &epp->no_output,           GAP_VAL_GINT32, 0, "# skip bitstream encoding");
+   gap_val_set_keyword(keylist, "(video_mb_lmin ",        &epp->video_mb_lmin,       GAP_VAL_GINT32, 0, "# min macroblock quantiser scale (VBR) 0-3658");
+   gap_val_set_keyword(keylist, "(video_mb_lmax ",        &epp->video_mb_lmax,       GAP_VAL_GINT32, 0, "# max macroblock quantiser scale (VBR) 0-3658");
+   gap_val_set_keyword(keylist, "(video_profile ",        &epp->video_profile,       GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(video_level ",          &epp->video_level,         GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(frame_skip_threshold ", &epp->frame_skip_threshold,GAP_VAL_GINT32, 0, "# frame skip threshold");
+   gap_val_set_keyword(keylist, "(frame_skip_factor ",    &epp->frame_skip_factor,   GAP_VAL_GINT32, 0, "# frame skip factor");
+   gap_val_set_keyword(keylist, "(frame_skip_exp ",       &epp->frame_skip_exp,      GAP_VAL_GINT32, 0, "# frame skip exponent");
+   gap_val_set_keyword(keylist, "(frame_skip_cmp ",       &epp->frame_skip_cmp,      GAP_VAL_GINT32, 0, "# frame skip comparission function");
+   gap_val_set_keyword(keylist, "(mux_rate ",             &epp->mux_rate,            GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(mux_packet_size ",      &epp->mux_packet_size,     GAP_VAL_GINT32, 0, "\0");
+
+   gap_val_set_keyword(keylist, "(mux_preload ",          &epp->mux_preload,         GAP_VAL_GDOUBLE, 0, "# set the initial demux-decode delay (secs)");
+   gap_val_set_keyword(keylist, "(mux_max_delay ",        &epp->mux_max_delay,       GAP_VAL_GDOUBLE, 0, "# set the maximum demux-decode delay (secs)");
+
+
+   /* new parms SVN snaphot 2009.01.31 */
+   gap_val_set_keyword(keylist, "(b_frame_strategy ",          &epp->b_frame_strategy,           GAP_VAL_GINT32, 0, "# strategy to choose between I/P/B-frames");
+   gap_val_set_keyword(keylist, "(workaround_bugs ",           &epp->workaround_bugs,            GAP_VAL_GINT32, 0, "# 1:FF_BUG_AUTODETECT, 2:FF_BUG_OLD_MSMPEG4 4:FF_BUG_XVID_ILACE 8:FF_BUG_UMP4 16:FF_BUG_NO_PADDING 32:FF_BUG_AMV 8192:FF_BUG_MS (Work around various bugs in Microsoft's broken decoders)");
+   gap_val_set_keyword(keylist, "(error_recognition ",         &epp->error_recognition,          GAP_VAL_GINT32, 0, "# 1:FF_ER_CAREFUL  2:FF_ER_COMPLIANT 3:FF_ER_AGGRESSIVE 4:FF_ER_VERY_AGGRESSIVE");
+   gap_val_set_keyword(keylist, "(mpeg_quant ",                &epp->mpeg_quant,                 GAP_VAL_GINT32, 0, "# 0-> h263 quant 1-> mpeg quant");
+   gap_val_set_keyword(keylist, "(rc_qsquish ",                &epp->rc_qsquish,                 GAP_VAL_GDOUBLE, 0, "# how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)");
+   gap_val_set_keyword(keylist, "(rc_qmod_amp ",               &epp->rc_qmod_amp,                GAP_VAL_GDOUBLE, 0, "# experimental quantizer modulation");
+   gap_val_set_keyword(keylist, "(rc_qmod_freq ",              &epp->rc_qmod_freq,               GAP_VAL_GINT32, 0, "# experimental quantizer modulation");
+   gap_val_set_keyword(keylist, "(rc_eq[60] ",                 &epp->rc_eq[60],                  GAP_VAL_STRING,   sizeof(epp->rc_eq), "# rate control equation (tex^qComp)");
+   gap_val_set_keyword(keylist, "(rc_buffer_aggressivity ",    &epp->rc_buffer_aggressivity,     GAP_VAL_GDOUBLE, 0, "# currently useless");
+   gap_val_set_keyword(keylist, "(dia_size ",                  &epp->dia_size,                   GAP_VAL_GINT32, 0, "# ME diamond size & shape");
+   gap_val_set_keyword(keylist, "(last_predictor_count ",      &epp->last_predictor_count,       GAP_VAL_GINT32, 0, "# amount of previous MV predictors (2a+1 x 2a+1 square)");
+   gap_val_set_keyword(keylist, "(pre_dia_size ",              &epp->pre_dia_size,               GAP_VAL_GINT32, 0, "# ME prepass diamond size & shape");
+   gap_val_set_keyword(keylist, "(inter_threshold ",           &epp->inter_threshold,            GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(border_masking ",            &epp->border_masking,             GAP_VAL_GDOUBLE, 0, "# increases the quantizer for macroblocks close to borders");
+   gap_val_set_keyword(keylist, "(me_penalty_compensation ",   &epp->me_penalty_compensation,    GAP_VAL_GINT32, 0, "# motion estimation bitrate penalty compensation (1.0 = 256)");
+   gap_val_set_keyword(keylist, "(bidir_refine ",              &epp->bidir_refine,               GAP_VAL_GINT32, 0, "# refine the two motion vectors used in bidirectional macroblocks");
+   gap_val_set_keyword(keylist, "(brd_scale ",                 &epp->brd_scale,                  GAP_VAL_GINT32, 0, "# downscales frames for dynamic B-frame decision");
+   gap_val_set_keyword(keylist, "(crf ",                       &epp->crf,                        GAP_VAL_GDOUBLE, 0, "# constant rate factor - quality-based VBR - values ~correspond to qps");
+   gap_val_set_keyword(keylist, "(cqp ",                       &epp->cqp,                        GAP_VAL_GINT32, 0, "# constant quantization parameter rate control method");
+   gap_val_set_keyword(keylist, "(keyint_min ",                &epp->keyint_min,                 GAP_VAL_GINT32, 0, "# minimum GOP size");
+   gap_val_set_keyword(keylist, "(refs ",                      &epp->refs,                       GAP_VAL_GINT32, 0, "# number of reference frames");
+   gap_val_set_keyword(keylist, "(chromaoffset ",              &epp->chromaoffset,               GAP_VAL_GINT32, 0, "# chroma qp offset from luma");
+   gap_val_set_keyword(keylist, "(bframebias ",                &epp->bframebias,                 GAP_VAL_GINT32, 0, "# Influences how often B-frames are used");
+   gap_val_set_keyword(keylist, "(trellis ",                   &epp->trellis,                    GAP_VAL_GINT32, 0, "# trellis RD quantization");
+   gap_val_set_keyword(keylist, "(complexityblur ",            &epp->complexityblur,             GAP_VAL_GDOUBLE, 0, "# Reduce fluctuations in qp (before curve compression)");
+   gap_val_set_keyword(keylist, "(deblockalpha ",              &epp->deblockalpha,               GAP_VAL_GINT32, 0, "# in-loop deblocking filter alphac0 parameter. alpha is in the range -6...6");
+   gap_val_set_keyword(keylist, "(deblockbeta ",               &epp->deblockbeta,                GAP_VAL_GINT32, 0, "# in-loop deblocking filter beta parameter. beta is in the range -6...6");
+   gap_val_set_keyword(keylist, "(partitions ",                &epp->partitions,                 GAP_VAL_GINT32, 0, "# macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4");
+   gap_val_set_keyword(keylist, "(directpred ",                &epp->directpred,                 GAP_VAL_GINT32, 0, "# direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)");
+   gap_val_set_keyword(keylist, "(cutoff ",                    &epp->cutoff,                     GAP_VAL_GINT32, 0, "# Audio cutoff bandwidth (0 means automatic)");
+   gap_val_set_keyword(keylist, "(scenechange_factor ",        &epp->scenechange_factor,         GAP_VAL_GINT32, 0, "#  Multiplied by qscale for each frame and added to scene_change_score.");
+   gap_val_set_keyword(keylist, "(mv0_threshold ",             &epp->mv0_threshold,              GAP_VAL_GINT32, 0, "# Value depends upon the compare function used for fullpel ME");
+   gap_val_set_keyword(keylist, "(b_sensitivity ",             &epp->b_sensitivity,              GAP_VAL_GINT32, 0, "# Adjusts sensitivity of b_frame_strategy 1");
+   gap_val_set_keyword(keylist, "(compression_level ",         &epp->compression_level,          GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(use_lpc ",                   &epp->use_lpc,                    GAP_VAL_GINT32, 0, "# Sets whether to use LPC mode - used by FLAC encoder");
+   gap_val_set_keyword(keylist, "(lpc_coeff_precision ",       &epp->lpc_coeff_precision,        GAP_VAL_GINT32, 0, "# LPC coefficient precision - used by FLAC encoder");
+   gap_val_set_keyword(keylist, "(min_prediction_order ",      &epp->min_prediction_order,       GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(max_prediction_order ",      &epp->max_prediction_order,       GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(prediction_order_method ",   &epp->prediction_order_method,    GAP_VAL_GINT32, 0, "# search method for selecting prediction order");
+   gap_val_set_keyword(keylist, "(min_partition_order ",       &epp->min_partition_order,        GAP_VAL_GINT32, 0, "\0");
+   gap_val_set_keyword(keylist, "(timecode_frame_start ",      &epp->timecode_frame_start,       GAP_VAL_GINT64, 0, "# GOP timecode frame start number, in non drop frame format");
+   gap_val_set_keyword(keylist, "(bits_per_raw_sample ",       &epp->bits_per_raw_sample,        GAP_VAL_GINT64, 0, "# This field is applicable only when sample_fmt is SAMPLE_FMT_S32");
+   gap_val_set_keyword(keylist, "(channel_layout ",            &epp->channel_layout,             GAP_VAL_GINT64, 0, "# Audio channel layout");
+   gap_val_set_keyword(keylist, "(rc_max_available_vbv_use ",  &epp->rc_max_available_vbv_use,   GAP_VAL_GDOUBLE, 0, "# Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow");
+   gap_val_set_keyword(keylist, "(rc_min_vbv_overflow_use ",   &epp->rc_min_vbv_overflow_use,    GAP_VAL_GDOUBLE, 0, "# Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow");
+
+
+   /* codec flags */
+
+   p_set_keyword_bool32(keylist, "(bitexact ",                &epp->bitexact,            "# CODEC_FLAG_BITEXACT (for testing, unused in productive version)");
+   p_set_keyword_bool32(keylist, "(use_ss ",                  &epp->use_ss,              "# CODEC_FLAG_H263P_SLICE_STRUCT enable Slice Structured mode (h263+)");
+   p_set_keyword_bool32(keylist, "(use_aiv ",                 &epp->use_aiv,             "# CODEC_FLAG_H263P_AIV  enable Alternative inter vlc (h263+)");
+   p_set_keyword_bool32(keylist, "(use_obmc ",                &epp->use_obmc,            "# CODEC_FLAG_OBMC use overlapped block motion compensation (h263+)");
+   p_set_keyword_bool32(keylist, "(use_loop ",                &epp->use_loop,            "# CODEC_FLAG_LOOP_FILTER use loop filter (h263+)");
+   p_set_keyword_bool32(keylist, "(use_alt_scan ",            &epp->use_alt_scan,        "# CODEC_FLAG_ALT_SCAN enable alternate scantable (MPEG2/MPEG4)");
+   p_set_keyword_bool32(keylist, "(use_mv0 ",                 &epp->use_mv0,             "# CODEC_FLAG_MV0 try to encode each MB with MV=<0,0> and choose the better one (has no effect if mbd=0)");
+   p_set_keyword_bool32(keylist, "(do_normalize_aqp ",        &epp->do_normalize_aqp,    "# CODEC_FLAG_NORMALIZE_AQP normalize adaptive quantization");
+   p_set_keyword_bool32(keylist, "(use_scan_offset ",         &epp->use_scan_offset,     "# CODEC_FLAG_SVCD_SCAN_OFFSET enable SVCD Scan Offset placeholder");
+   p_set_keyword_bool32(keylist, "(closed_gop ",              &epp->closed_gop,          "# CODEC_FLAG_CLOSED_GOP closed gop");
+   p_set_keyword_bool32(keylist, "(use_qpel ",                &epp->use_qpel,            "# CODEC_FLAG_QPEL enable 1/4-pel");
+   p_set_keyword_bool32(keylist, "(use_qprd ",                &epp->use_qprd,            "# CODEC_FLAG_QP_RD use rate distortion optimization for qp selection");
+   p_set_keyword_bool32(keylist, "(use_cbprd ",               &epp->use_cbprd,           "# CODEC_FLAG_CBP_RD use rate distortion optimization for cbp");
+   p_set_keyword_bool32(keylist, "(do_interlace_dct ",        &epp->do_interlace_dct,    "# CODEC_FLAG_INTERLACED_DCT use interlaced dct");
+   p_set_keyword_bool32(keylist, "(do_interlace_me ",         &epp->do_interlace_me,     "# CODEC_FLAG_INTERLACED_ME interlaced motion estimation");
+   p_set_keyword_bool32(keylist, "(aic ",                     &epp->aic,                 "# CODEC_FLAG_AC_PRED activate intra frame coding (only h263+ CODEC) ");
+   p_set_keyword_bool32(keylist, "(umv ",                     &epp->umv,                 "# CODEC_FLAG_H263P_UMV enable unlimited motion vector (only h263+ CODEC)");
+   p_set_keyword_bool32(keylist, "(mv4 ",                     &epp->mv4,                 "# CODEC_FLAG_4MV use four motion vector by macroblock (only MPEG-4 CODEC)");
+   p_set_keyword_bool32(keylist, "(partitioning ",            &epp->partitioning,        "# CODEC_FLAG_PART use data partitioning (only MPEG-4 CODEC)");
+
+   /* support for new codec flags */
+   p_set_keyword_bool32(keylist, "(use_gmc ",                 &epp->codec_FLAG_GMC,                     "# CODEC_FLAG_GMC                  Use GMC");
+   p_set_keyword_bool32(keylist, "(input_preserved ",         &epp->codec_FLAG_INPUT_PRESERVED,         "# CODEC_FLAG_INPUT_PRESERVED      ");
+   p_set_keyword_bool32(keylist, "(use_gray ",                &epp->codec_FLAG_GRAY,                    "# CODEC_FLAG_GRAY                 Only encode grayscale");
+   p_set_keyword_bool32(keylist, "(use_emu_edge ",            &epp->codec_FLAG_EMU_EDGE,                "# CODEC_FLAG_EMU_EDGE             Dont draw edges");
+   p_set_keyword_bool32(keylist, "(use_truncated ",           &epp->codec_FLAG_TRUNCATED,               "# CODEC_FLAG_TRUNCATED            Input bitstream might be truncated at a random location instead of only at frame boundaries");
+
+   p_set_keyword_bool32(keylist, "(use_fast ",                &epp->codec_FLAG2_FAST,                   "# CODEC_FLAG2_FAST                Allow non spec compliant speedup tricks");
+   p_set_keyword_bool32(keylist, "(use_local_header ",        &epp->codec_FLAG2_LOCAL_HEADER,           "# CODEC_FLAG2_LOCAL_HEADER        Place global headers at every keyframe instead of in extradata.");
+   p_set_keyword_bool32(keylist, "(use_bpyramid ",            &epp->codec_FLAG2_BPYRAMID,               "# CODEC_FLAG2_BPYRAMID            H.264 allow B-frames to be used as references for predicting.");
+   p_set_keyword_bool32(keylist, "(use_wpred ",               &epp->codec_FLAG2_WPRED,                  "# CODEC_FLAG2_WPRED               H.264 weighted biprediction for B-frames");
+   p_set_keyword_bool32(keylist, "(use_mixed_refs ",          &epp->codec_FLAG2_MIXED_REFS,             "# CODEC_FLAG2_MIXED_REFS          H.264 one reference per partition, as opposed to one reference per macroblock");
+   p_set_keyword_bool32(keylist, "(use_dct8x8 ",              &epp->codec_FLAG2_8X8DCT,                 "# CODEC_FLAG2_8X8DCT              H.264 high profile 8x8 transform");
+   p_set_keyword_bool32(keylist, "(use_fastpskip ",           &epp->codec_FLAG2_FASTPSKIP,              "# CODEC_FLAG2_FASTPSKIP           H.264 fast pskip");
+   p_set_keyword_bool32(keylist, "(use_aud ",                 &epp->codec_FLAG2_AUD,                    "# CODEC_FLAG2_AUD                 H.264 access unit delimiters");
+   p_set_keyword_bool32(keylist, "(use_brdo ",                &epp->codec_FLAG2_BRDO,                   "# CODEC_FLAG2_BRDO                B-frame rate-distortion optimization");
+   p_set_keyword_bool32(keylist, "(use_ivlc ",                &epp->codec_FLAG2_INTRA_VLC,              "# CODEC_FLAG2_INTRA_VLC           Use MPEG-2 intra VLC table.");
+   p_set_keyword_bool32(keylist, "(use_memc_only ",           &epp->codec_FLAG2_MEMC_ONLY,              "# CODEC_FLAG2_MEMC_ONLY           Only do ME/MC (I frames -> ref, P frame -> ME+MC)");
+   p_set_keyword_bool32(keylist, "(use_drop_frame_timecode ", &epp->codec_FLAG2_DROP_FRAME_TIMECODE,    "# CODEC_FLAG2_DROP_FRAME_TIMECODE timecode is in drop frame format");
+   p_set_keyword_bool32(keylist, "(use_skip_rd ",             &epp->codec_FLAG2_SKIP_RD,                "# CODEC_FLAG2_SKIP_RD             RD optimal MB level residual skipping");
+   p_set_keyword_bool32(keylist, "(use_chunks ",              &epp->codec_FLAG2_CHUNKS,                 "# CODEC_FLAG2_CHUNKS              Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries");
+   p_set_keyword_bool32(keylist, "(use_non_linear_quant ",    &epp->codec_FLAG2_NON_LINEAR_QUANT,       "# CODEC_FLAG2_NON_LINEAR_QUANT    Use MPEG-2 nonlinear quantizer");
+   p_set_keyword_bool32(keylist, "(use_bit_reservoir ",       &epp->codec_FLAG2_BIT_RESERVOIR,          "# CODEC_FLAG2_BIT_RESERVOIR       Use a bit reservoir when encoding if possible");
 
-   gap_val_set_keyword(keylist, "(mux_preload ",          &ffpar_ptr->mux_preload,         GAP_VAL_GDOUBLE, 0, "# set the initial demux-decode delay (secs)");
-   gap_val_set_keyword(keylist, "(mux_max_delay ",        &ffpar_ptr->mux_max_delay,       GAP_VAL_GDOUBLE, 0, "# set the maximum demux-decode delay (secs)");
 
 }  /* end p_set_master_keywords */
 
@@ -181,7 +267,7 @@
  * found in the file.
  */
 void
-gap_ffpar_get(const char *filename, GapGveFFMpegValues *ffpar_ptr)
+gap_ffpar_get(const char *filename, GapGveFFMpegValues *epp)
 {
   GapValKeyList    *keylist;
   gint              cnt_scanned_items;
@@ -189,10 +275,10 @@
   /* init with defaults the case where no video_info file available
    * (use preset index 0 for the default settings)
    */
-  gap_enc_ffmpeg_main_init_preset_params(ffpar_ptr, 0);
+  gap_enc_ffmpeg_main_init_preset_params(epp, 0);
 
   keylist = gap_val_new_keylist();
-  p_set_master_keywords(keylist, ffpar_ptr);
+  p_set_master_keywords(keylist, epp);
 
   cnt_scanned_items = gap_val_scann_filevalues(keylist, filename);
   gap_val_free_keylist(keylist);
@@ -202,56 +288,61 @@
     g_message(_("Could not read ffmpeg video encoder parameters from file:\n%s"), filename);
   }
 
+  epp->twoPassFlag = FALSE;
+  if (epp->pass_nr == 2)
+  {
+    epp->twoPassFlag = TRUE;
+  }
 
   if(gap_debug)
   {
-    printf("gap_ffpar_get: params loaded: ffpar_ptr:%d\n", (int)ffpar_ptr);
-    printf("format_name  %s\n", ffpar_ptr->format_name);
-    printf("vcodec_name  %s\n", ffpar_ptr->vcodec_name);
-    printf("acodec_name  %s\n", ffpar_ptr->acodec_name);
-    printf("title  %s\n", ffpar_ptr->title);
-    printf("author  %s\n", ffpar_ptr->author);
-    printf("copyright  %s\n", ffpar_ptr->copyright);
-    printf("comment  %s\n", ffpar_ptr->comment);
-    printf("passlogfile  %s\n", ffpar_ptr->passlogfile);
-    
-    printf("pass  %d\n", (int)ffpar_ptr->pass);
-    printf("audio_bitrate  %d\n", (int)ffpar_ptr->audio_bitrate);
-    printf("video_bitrate  %d\n", (int)ffpar_ptr->video_bitrate);
-    printf("gop_size  %d\n", (int)ffpar_ptr->gop_size);
-    printf("intra  %d\n", (int)ffpar_ptr->intra);
-    printf("qscale  %f\n", (float)ffpar_ptr->qscale);
-    printf("qmin  %d\n", (int)ffpar_ptr->qmin);
-    printf("qmax  %d\n", (int)ffpar_ptr->qmax);
-    printf("qdiff  %d\n", (int)ffpar_ptr->qdiff);
-    printf("qblur  %f\n", (float)ffpar_ptr->qblur);
-    printf("qcomp  %f\n", (float)ffpar_ptr->qcomp);
-    printf("rc_init_cplx  %f\n", (float)ffpar_ptr->rc_init_cplx);
-    printf("b_qfactor  %f\n", (float)ffpar_ptr->b_qfactor);
-    printf("i_qfactor  %f\n", (float)ffpar_ptr->i_qfactor);
-    printf("b_qoffset  %f\n", (float)ffpar_ptr->b_qoffset);
-    printf("i_qoffset  %f\n", (float)ffpar_ptr->i_qoffset);
-    printf("bitrate_tol  %d\n", (int)ffpar_ptr->bitrate_tol);
-    printf("maxrate_tol  %d\n", (int)ffpar_ptr->maxrate_tol);
-    printf("minrate_tol  %d\n", (int)ffpar_ptr->minrate_tol);
-    printf("bufsize  %d\n", (int)ffpar_ptr->bufsize);
-    printf("motion_estimation  %d\n", (int)ffpar_ptr->motion_estimation);
-    printf("dct_algo  %d\n", (int)ffpar_ptr->dct_algo);
-    printf("idct_algo  %d\n", (int)ffpar_ptr->idct_algo);
-    printf("strict  %d\n", (int)ffpar_ptr->strict);
-    printf("mb_qmin  %d\n", (int)ffpar_ptr->mb_qmin);
-    printf("mb_qmax  %d\n", (int)ffpar_ptr->mb_qmax);
-    printf("mb_decision  %d\n", (int)ffpar_ptr->mb_decision);
-    printf("aic  %d\n", (int)ffpar_ptr->aic);
-    printf("umv  %d\n", (int)ffpar_ptr->umv);
-    printf("b_frames  %d\n", (int)ffpar_ptr->b_frames);
-    printf("mv4  %d\n", (int)ffpar_ptr->mv4);
-    printf("partitioning  %d\n", (int)ffpar_ptr->partitioning);
-    printf("packet_size  %d\n", (int)ffpar_ptr->packet_size);
-    printf("bitexact  %d\n", (int)ffpar_ptr->bitexact);
-    printf("set_aspect_ratio  %d\n", (int)ffpar_ptr->set_aspect_ratio);
-    printf("dont_recode_flag  %d\n", (int)ffpar_ptr->dont_recode_flag);
-    printf("factor_aspect_ratio  %f\n", (float)ffpar_ptr->factor_aspect_ratio);
+    printf("gap_ffpar_get: params loaded: epp:%d\n", (int)epp);
+    printf("format_name  %s\n", epp->format_name);
+    printf("vcodec_name  %s\n", epp->vcodec_name);
+    printf("acodec_name  %s\n", epp->acodec_name);
+    printf("title  %s\n", epp->title);
+    printf("author  %s\n", epp->author);
+    printf("copyright  %s\n", epp->copyright);
+    printf("comment  %s\n", epp->comment);
+    printf("passlogfile  %s\n", epp->passlogfile);
+
+    printf("pass_nr  %d\n", (int)epp->pass_nr);
+    printf("audio_bitrate  %d\n", (int)epp->audio_bitrate);
+    printf("video_bitrate  %d\n", (int)epp->video_bitrate);
+    printf("gop_size  %d\n", (int)epp->gop_size);
+    printf("intra  %d\n", (int)epp->intra);
+    printf("qscale  %f\n", (float)epp->qscale);
+    printf("qmin  %d\n", (int)epp->qmin);
+    printf("qmax  %d\n", (int)epp->qmax);
+    printf("qdiff  %d\n", (int)epp->qdiff);
+    printf("qblur  %f\n", (float)epp->qblur);
+    printf("qcomp  %f\n", (float)epp->qcomp);
+    printf("rc_init_cplx  %f\n", (float)epp->rc_init_cplx);
+    printf("b_qfactor  %f\n", (float)epp->b_qfactor);
+    printf("i_qfactor  %f\n", (float)epp->i_qfactor);
+    printf("b_qoffset  %f\n", (float)epp->b_qoffset);
+    printf("i_qoffset  %f\n", (float)epp->i_qoffset);
+    printf("bitrate_tol  %d\n", (int)epp->bitrate_tol);
+    printf("maxrate_tol  %d\n", (int)epp->maxrate_tol);
+    printf("minrate_tol  %d\n", (int)epp->minrate_tol);
+    printf("bufsize  %d\n", (int)epp->bufsize);
+    printf("motion_estimation  %d\n", (int)epp->motion_estimation);
+    printf("dct_algo  %d\n", (int)epp->dct_algo);
+    printf("idct_algo  %d\n", (int)epp->idct_algo);
+    printf("strict  %d\n", (int)epp->strict);
+    printf("mb_qmin  %d\n", (int)epp->mb_qmin);
+    printf("mb_qmax  %d\n", (int)epp->mb_qmax);
+    printf("mb_decision  %d\n", (int)epp->mb_decision);
+    printf("aic  %d\n", (int)epp->aic);
+    printf("umv  %d\n", (int)epp->umv);
+    printf("b_frames  %d\n", (int)epp->b_frames);
+    printf("mv4  %d\n", (int)epp->mv4);
+    printf("partitioning  %d\n", (int)epp->partitioning);
+    printf("packet_size  %d\n", (int)epp->packet_size);
+    printf("bitexact  %d\n", (int)epp->bitexact);
+    printf("set_aspect_ratio  %d\n", (int)epp->set_aspect_ratio);
+    printf("dont_recode_flag  %d\n", (int)epp->dont_recode_flag);
+    printf("factor_aspect_ratio  %f\n", (float)epp->factor_aspect_ratio);
   }
 }  /* end gap_ffpar_get */
 
@@ -262,32 +353,37 @@
  * (re)write the specified ffmpeg videoencode parameter file
  */
 int
-gap_ffpar_set(const char *filename, GapGveFFMpegValues *ffpar_ptr)
+gap_ffpar_set(const char *filename, GapGveFFMpegValues *epp)
 {
   GapValKeyList    *keylist;
   int          l_rc;
 
+  epp->pass_nr = 1;
+  if (epp->twoPassFlag == TRUE)
+  {
+    epp->pass_nr = 2;
+  }
   keylist = gap_val_new_keylist();
 
-  p_set_master_keywords(keylist, ffpar_ptr);
+  p_set_master_keywords(keylist, epp);
   l_rc = gap_val_rewrite_file(keylist
                           ,filename
-			  ,"# GIMP / GAP FFMPEG videoencoder parameter file"   /*  hdr_text */
-			  ,")"                                                 /* terminate char */
-			  );
+                          ,"# GIMP / GAP FFMPEG videoencoder parameter file"   /*  hdr_text */
+                          ,")"                                                 /* terminate char */
+                          );
 
   gap_val_free_keylist(keylist);
-  
+
   if(l_rc != 0)
   {
     gint l_errno;
 
     l_errno = errno;
     g_message(_("Could not save ffmpeg video encoder parameterfile:"
-	       "'%s'"
-	       "%s")
-	       ,filename
-	       ,g_strerror (l_errno) );
+               "'%s'"
+               "%s")
+               ,filename
+               ,g_strerror (l_errno) );
   }
 
   return(l_rc);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]