gimp-gap r791 - in trunk: . gap libgapvidutil vid_common vid_enc_avi vid_enc_ffmpeg vid_enc_rawframes vid_enc_single



Author: wolfgangh
Date: Sun Nov  2 12:10:50 2008
New Revision: 791
URL: http://svn.gnome.org/viewvc/gimp-gap?rev=791&view=rev

Log:
fix #558529 and video master encoder dialog encoding status

Modified:
   trunk/ChangeLog
   trunk/gap/gap_story_file.c
   trunk/libgapvidutil/gap_gve_misc_util.c
   trunk/libgapvidutil/gap_gve_misc_util.h
   trunk/libgapvidutil/gap_gvetypes.h
   trunk/vid_common/gap_cme_callbacks.c
   trunk/vid_common/gap_cme_gui.c
   trunk/vid_common/gap_cme_gui.h
   trunk/vid_common/gap_cme_main.c
   trunk/vid_common/gap_cme_main.h
   trunk/vid_enc_avi/gap_enc_avi_main.c
   trunk/vid_enc_ffmpeg/gap_enc_ffmpeg_main.c
   trunk/vid_enc_rawframes/gap_enc_rawframes_main.c
   trunk/vid_enc_single/gap_enc_singleframes_main.c

Modified: trunk/gap/gap_story_file.c
==============================================================================
--- trunk/gap/gap_story_file.c	(original)
+++ trunk/gap/gap_story_file.c	Sun Nov  2 12:10:50 2008
@@ -4923,7 +4923,7 @@
    }
 
   /* print PREFERRED_DECODER */
-  if(stb->preferred_decoder > 0)
+  if(stb->preferred_decoder)
   {
     if(*stb->preferred_decoder != '\0')
     {

Modified: trunk/libgapvidutil/gap_gve_misc_util.c
==============================================================================
--- trunk/libgapvidutil/gap_gve_misc_util.c	(original)
+++ trunk/libgapvidutil/gap_gve_misc_util.c	Sun Nov  2 12:10:50 2008
@@ -97,5 +97,128 @@
 
 
 
+/* ---------------------------------
+ * p_snprintf_master_encoder_progress_keyname
+ * ---------------------------------
+ *
+ */
+static void
+p_snprintf_master_encoder_progress_keyname(char *key, gint32 key_max_size, gint32 master_encoder_id)
+{
+  g_snprintf(key, key_max_size, "GAP_MASTER_ENCODER_PROGRESS_%d", (int)master_encoder_id);
+}
 
+static void
+p_snprintf_master_encoder_cancel_keyname(char *key, gint32 key_max_size, gint32 master_encoder_id)
+{
+  g_snprintf(key, key_max_size, "GAP_MASTER_ENCODER_CANCEL_%d", (int)master_encoder_id);
+}
+
+
+/* ------------------------------------------
+ * gap_gve_misc_initGapGveMasterEncoderStatus
+ * ---------................-----------------
+ * This pocedure is typically called at start of video encoding
+ */
+void
+gap_gve_misc_initGapGveMasterEncoderStatus(GapGveMasterEncoderStatus *encStatus
+   , gint32 master_encoder_id, gint32 total_frames)
+{
+  encStatus->master_encoder_id = master_encoder_id;
+  encStatus->total_frames = total_frames;
+  encStatus->frames_processed = 0;
+  encStatus->frames_encoded = 0;
+  encStatus->frames_copied_lossless = 0;
+//  encStatus->pidOfRunningEncoder = 0;
+
+  gap_gve_misc_do_master_encoder_progress(encStatus);
+}
+
+/* ----------------------------------------
+ * gap_gve_misc_do_master_encoder_progress
+ * ----------------------------------------
+ * This pocedure is typically called in video encoder plug-ins
+ * to report the current encoding status.
+ * (including the process id of the encoder plug-in)
+ */
+void
+gap_gve_misc_do_master_encoder_progress(GapGveMasterEncoderStatus *encStatus)
+{
+  char key[50];
+  
+  p_snprintf_master_encoder_progress_keyname(&key[0], sizeof(key), encStatus->master_encoder_id);
+  gimp_set_data(key, encStatus, sizeof(GapGveMasterEncoderStatus));
+}
+
+
+/* ---------------------------------------------
+ * gap_gve_misc_is_master_encoder_cancel_request
+ * ---------------------------------------------
+ * This pocedure is typically called in video encoder plug-ins
+ * to query for cancel request (Cancel button pressed in the master encoder)
+ */
+gboolean
+gap_gve_misc_is_master_encoder_cancel_request(GapGveMasterEncoderStatus *encStatus)
+{
+  char key[50];
+  gboolean cancelRequest;
+
+  cancelRequest = FALSE;
+  p_snprintf_master_encoder_cancel_keyname(&key[0], sizeof(key), encStatus->master_encoder_id);
+  if(gimp_get_data_size(key) == sizeof(gboolean))
+  {
+      gimp_get_data(key, &cancelRequest);
+  }
+  return (cancelRequest);
+}
+
+
+/* -----------------------------------------
+ * gap_gve_misc_get_master_encoder_progress
+ * -----------------------------------------
+ * This pocedure is typically called in the master encoder dialog
+ * to get the status of the running video encoder plug-in.
+ */
+void
+gap_gve_misc_get_master_encoder_progress(GapGveMasterEncoderStatus *encStatus)
+{
+  char key[50];
+  
+  p_snprintf_master_encoder_progress_keyname(&key[0], sizeof(key), encStatus->master_encoder_id);
+
+  if(gimp_get_data_size(key) == sizeof(GapGveMasterEncoderStatus))
+  {
+      if(gap_debug)
+      {
+        printf("p_gimp_get_data: key:%s\n", key);
+      }
+      gimp_get_data(key, encStatus);
+  }
+  else
+  {
+     if(gap_debug)
+     {
+       printf("ERROR: gimp_get_data key:%s failed\n", key);
+       printf("ERROR: gimp_get_data_size:%d  expected size:%d\n"
+             , (int)gimp_get_data_size(key)
+             , (int)sizeof(GapGveMasterEncoderStatus));
+     }
+  }
+}
+
+
+/* ----------------------------------------------
+ * gap_gve_misc_set_master_encoder_cancel_request
+ * ----------------------------------------------
+ * This pocedure is typically called in the master video encoder
+ * to request the already started video encoder plug-in to terminate.
+ */
+void
+gap_gve_misc_set_master_encoder_cancel_request(GapGveMasterEncoderStatus *encStatus, gboolean cancelRequest)
+{
+  char key[50];
+
+  p_snprintf_master_encoder_cancel_keyname(&key[0], sizeof(key), encStatus->master_encoder_id);
+  gimp_set_data(key, &cancelRequest, sizeof(gboolean));
+}
 

Modified: trunk/libgapvidutil/gap_gve_misc_util.h
==============================================================================
--- trunk/libgapvidutil/gap_gve_misc_util.h	(original)
+++ trunk/libgapvidutil/gap_gve_misc_util.h	Sun Nov  2 12:10:50 2008
@@ -32,6 +32,10 @@
 
 #include "libgimp/gimp.h"
 
+#include <sys/types.h>
+#include <unistd.h>
+
+
 
 typedef struct GapGveEncAInfo {
    long         first_frame_nr;
@@ -43,6 +47,17 @@
    gdouble      framerate;
 } GapGveEncAInfo;
 
+
+typedef struct GapGveMasterEncoderStatus {                     /* nick:  */
+ /* Status for monitoring video encoding progress */
+  gint32 master_encoder_id;  /* typically the PID */
+  gint32 total_frames;
+  gint32 frames_processed;
+  gint32 frames_encoded;
+  gint32 frames_copied_lossless;
+} GapGveMasterEncoderStatus;
+
+
 /* --------------------------*/
 /* PROCEDURE DECLARATIONS    */
 /* --------------------------*/
@@ -50,6 +65,13 @@
 
 void        gap_gve_misc_get_ainfo(gint32 image_ID, GapGveEncAInfo *ainfo);
 
+void        gap_gve_misc_initGapGveMasterEncoderStatus(GapGveMasterEncoderStatus *encStatus
+                                 , gint32 master_encoder_id, gint32 total_frames);
+void        gap_gve_misc_do_master_encoder_progress(GapGveMasterEncoderStatus *encStatus);
+gboolean    gap_gve_misc_is_master_encoder_cancel_request(GapGveMasterEncoderStatus *encStatus);
+
+void        gap_gve_misc_get_master_encoder_progress(GapGveMasterEncoderStatus *encStatus);
+void        gap_gve_misc_set_master_encoder_cancel_request(GapGveMasterEncoderStatus *encStatus, gboolean cancelRequest);
 
 
 extern int gap_debug;

Modified: trunk/libgapvidutil/gap_gvetypes.h
==============================================================================
--- trunk/libgapvidutil/gap_gvetypes.h	(original)
+++ trunk/libgapvidutil/gap_gvetypes.h	Sun Nov  2 12:10:50 2008
@@ -51,7 +51,7 @@
 
 
 
-#define GAP_VENC_NUM_STANDARD_PARAM 16
+#define GAP_VENC_NUM_STANDARD_PARAM 17
 
 /* SYTEM (UNIX) includes */
 #include <stdlib.h>
@@ -133,6 +133,8 @@
   gchar   filtermacro_file[256];
   gchar   storyboard_file[256];
   gint32  storyboard_total_frames;
+
+  gint32  master_encoder_id;  
 } GapGveCommonValues;
 
 

Modified: trunk/vid_common/gap_cme_callbacks.c
==============================================================================
--- trunk/vid_common/gap_cme_callbacks.c	(original)
+++ trunk/vid_common/gap_cme_callbacks.c	Sun Nov  2 12:10:50 2008
@@ -41,6 +41,176 @@
 #include "gap_gve_story.h"
 #include "gap_cme_callbacks.h"
 
+static void            p_start_encoder_status_poll_timer(GapCmeGlobalParams *gpp);
+static void            p_remove_encoder_status_poll_timer(GapCmeGlobalParams *gpp);
+static gint32          p_drop_chache_and_start_video_encoder(GapCmeGlobalParams *gpp);
+static void            on_encoder_status_poll_timer(gpointer   user_data);
+
+
+static void
+p_start_encoder_status_poll_timer(GapCmeGlobalParams *gpp)
+{
+  if(gpp)
+  {
+    gpp->encoder_status_poll_timertag =
+       (gint32) g_timeout_add(250, (GSourceFunc) on_encoder_status_poll_timer, gpp);
+  }
+}
+static void
+p_remove_encoder_status_poll_timer(GapCmeGlobalParams *gpp)
+{
+  if(gpp)
+  {
+    if(gpp->encoder_status_poll_timertag >= 0)
+    {
+      g_source_remove(gpp->encoder_status_poll_timertag);
+      gpp->productive_encoder_timertag = -1;
+    }
+  }
+}
+
+static void
+on_encoder_status_poll_timer(gpointer   user_data)
+{
+  GapCmeGlobalParams *gpp;
+
+  if(gap_debug)
+  {
+    printf("\n on_encoder_status_poll_timer: START\n");
+  }
+
+  gpp = (GapCmeGlobalParams *)user_data;
+  
+  if(gpp)
+  {
+    p_remove_encoder_status_poll_timer(gpp);
+    gap_cme_gui_update_encoder_status(gpp);
+    
+    if(gpp->video_encoder_run_state == GAP_CME_ENC_RUN_STATE_RUNNING)
+    {
+      /* restart timer for next poll cycle */
+      p_start_encoder_status_poll_timer(gpp);
+    }
+  }
+  
+}  /* end on_encoder_status_poll_timer */
+
+static void
+on_productive_encoder_start(gpointer   user_data)
+{
+  GapCmeGlobalParams *gpp;
+
+  if(gap_debug)
+  {
+    printf("\n on_productive_encoder_start: START\n");
+  }
+
+  gpp = (GapCmeGlobalParams *)user_data;
+  
+  if(gpp)
+  {
+    if(gpp->productive_encoder_timertag >= 0)
+    {
+      if(gap_debug)
+      {
+        printf("MAIN on_productive_encoder_start remove productive_encoder_timertag:%d\n", (int)gpp->productive_encoder_timertag);
+      }
+      g_source_remove(gpp->productive_encoder_timertag);
+      gpp->productive_encoder_timertag = -1;
+    }
+
+    if(gap_debug)
+    {
+      printf("MAIN on_productive_encoder_start VIDEO ENCODER START ------------------\n");
+    }
+
+    gap_cme_gui_start_video_encoder_as_thread(gpp);
+
+
+    if(gap_debug)
+    {
+      printf("MAIN on_productive_encoder_start VIDEO ENCODER finished ------------------\n");
+    }
+    p_start_encoder_status_poll_timer(gpp);
+  }
+  
+}  /* end on_productive_encoder_start */
+
+/* ----------------------------------------
+ * p_drop_chache_and_start_video_encoder
+ * ----------------------------------------
+ */
+static gint32
+p_drop_chache_and_start_video_encoder(GapCmeGlobalParams *gpp)
+{
+  /* delete images in the cache
+   * (the cache may have been filled while parsing
+   * storyboard file in the common dialog
+   */
+  gap_gve_story_drop_image_cache();
+  if(gap_debug)
+  {
+    printf("MAIN after gap_gve_story_drop_image_cache ------------------\n");
+  }
+
+  /* start timer (encoder start after 800 millisecs) */
+  gpp->productive_encoder_timertag =
+    (gint32) g_timeout_add(800, (GSourceFunc) on_productive_encoder_start, gpp);
+
+
+}  /* end p_drop_chache_and_start_video_encoder */
+
+
+/* ------------------------------------------
+ * p_switch_gui_to_running_encoder_state
+ * ------------------------------------------
+ * disable video output entry and all existing notebook tabs,
+ * and add the ncoder status frame
+ * as last tab to the notebook
+ * (that is updated while encoder thread is running via polling)
+ * then establish the encoding state.
+ */
+static void
+p_switch_gui_to_running_encoder_state(GapCmeGlobalParams *gpp)
+{
+  GtkWidget *label;
+  GtkWidget *frame;
+  GtkWidget *notebook;
+  gint idx;
+  gint npages;
+ 
+  gtk_widget_set_sensitive(gpp->cme__entry_video, FALSE);
+  gtk_widget_set_sensitive(gpp->cme__button_video_filesel, FALSE);
+
+  frame = gpp->cme__encoder_status_frame;
+  notebook = gpp->cme__notebook;
+
+  gtk_widget_show(frame);
+  
+  gtk_container_set_border_width (GTK_CONTAINER (gpp->cme__encoder_status_frame), 4);
+  gtk_widget_show(gpp->cme__encoder_status_frame);
+
+  npages = gtk_notebook_get_n_pages(notebook);
+  for (idx = 0; idx < npages; idx++)
+  {
+    gtk_widget_set_sensitive(gtk_notebook_get_nth_page(notebook, idx), FALSE);
+  }
+
+  /* add the Encoding notebook tab */
+  label = gtk_label_new (_("Encoding"));
+  gtk_widget_show (label);
+  gtk_widget_show (frame);
+  gtk_container_add (GTK_CONTAINER (notebook), frame);
+  gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
+  gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook)
+                            , gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), npages)
+			    , label);
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), npages);
+
+  gpp->video_encoder_run_state =  GAP_CME_ENC_RUN_STATE_RUNNING;
+}  /* end p_switch_gui_to_running_encoder_state */
+
+
 /* ------------------------------------------------------ */
 /* BEGIN callbacks                                        */
 /* ------------------------------------------------------ */
@@ -67,30 +237,53 @@
     case GTK_RESPONSE_OK:
       if(gpp)
       {
-        if(gpp->val.gui_proc_thread)
+        switch(gpp->video_encoder_run_state)
         {
-          if(gap_cme_gui_check_gui_thread_is_active(gpp)) return;
+          case GAP_CME_ENC_RUN_STATE_READY:
+            if(gpp->val.gui_proc_thread)
+            {
+              if(gap_cme_gui_check_gui_thread_is_active(gpp))
+              {
+                return;
+              }
+            }
+            if(gpp->ow__dialog_window != NULL)
+            {
+              /* Overwrite dialog is already open
+               * but the User pressed the OK button in the qte main dialog again.
+               */
+              gtk_window_present(GTK_WINDOW(gpp->ow__dialog_window));
+              return;
+            }
+            if(FALSE == gap_cme_gui_check_encode_OK (gpp))
+            {
+              return;  /* can not start, illegal parameter value combinations */
+            }
+            gpp->val.run = TRUE;
+            p_switch_gui_to_running_encoder_state(gpp);
+            p_drop_chache_and_start_video_encoder(gpp);
+            return;
+            break;
+          case GAP_CME_ENC_RUN_STATE_RUNNING:
+            return;  /* ignore further clicks on OK button while encoder is running */
+            break;
+          case GAP_CME_ENC_RUN_STATE_FINISHED:
+            /* close the master encoder window if OK button clicked after while encoder has finished */
+            break;
         }
-        if(gpp->ow__dialog_window != NULL)
-        {
-          /* Overwrite dialog is already open
-           * but the User pressed the OK button in the qte main dialog again.
-           */
-          gtk_window_present(GTK_WINDOW(gpp->ow__dialog_window));
-          return;
-        }
-        if(FALSE == gap_cme_gui_check_encode_OK (gpp))
-        {
-          return;  /* can not start, illegal parameter value combinations */
-        }
-        gpp->val.run = TRUE;
-      }
+      }  
+      
+
       /* now run into the default case, to close the shell_window (dont break) */
+      
     default:
       dialog = NULL;
       if(gpp)
       {
+        gap_gve_misc_set_master_encoder_cancel_request(&gpp->encStatus, TRUE);
+
         gap_cme_gui_remove_poll_timer(gpp);
+        p_remove_encoder_status_poll_timer(gpp);
         dialog = gpp->shell_window;
         if(dialog)
         {
@@ -99,6 +292,7 @@
         }
       }
       gtk_main_quit ();
+
       break;
   }
 }  /* end on_cme__response */
@@ -142,6 +336,9 @@
                , l_ecp->menu_name
                , l_ecp->vid_enc_plugin);
      }
+
+    gtk_label_set_text(GTK_LABEL(gpp->cme__label_active_encoder_name), l_ecp->menu_name);
+
      /* copy the selected ecp record */
      memcpy(&gpp->val.ecp_sel, l_ecp, sizeof(GapGveEncList));
      gap_cme_gui_upd_wgt_sensitivity(gpp);

Modified: trunk/vid_common/gap_cme_gui.c
==============================================================================
--- trunk/vid_common/gap_cme_gui.c	(original)
+++ trunk/vid_common/gap_cme_gui.c	Sun Nov  2 12:10:50 2008
@@ -134,6 +134,7 @@
 static void            p_input_mode_radio_callback(GtkWidget *widget, GapCmeGlobalParams *gpp);
 static void            p_create_input_mode_widgets(GtkWidget *table, int row, int col, GapCmeGlobalParams *gpp);
 
+static GtkWidget*      p_create_encoder_status_frame (GapCmeGlobalParams *gpp);
 static GtkWidget*      p_create_encode_extras_frame (GapCmeGlobalParams *gpp);
 static GtkWidget*      p_create_audiotool_cfg_frame (GapCmeGlobalParams *gpp);
 static GtkWidget*      p_create_audio_options_frame (GapCmeGlobalParams *gpp);
@@ -142,6 +143,7 @@
 static GtkWidget*      p_create_shell_window (GapCmeGlobalParams *gpp);
 
 static gint            p_overwrite_dialog(GapCmeGlobalParams *gpp, gchar *filename, gint overwrite_mode);
+static gint            p_call_encoder_procedure(GapCmeGlobalParams *gpp);
 
 /* ----------------------------------------
  * p_gap_message
@@ -193,6 +195,7 @@
    return (FALSE);
 }  /* end gap_cme_gui_check_gui_thread_is_active */
 
+
 /* ----------------------------------------
  * gap_cme_gui_pdb_call_encoder_gui_plugin
  * ----------------------------------------
@@ -2478,10 +2481,23 @@
   gtk_widget_show (cme__dialog_vbox1);
 
   cme__vbox_main = gtk_vbox_new (FALSE, 0);
+  gpp->cme__vbox_main = cme__vbox_main;
   gtk_widget_show (cme__vbox_main);
   gtk_box_pack_start (GTK_BOX (cme__dialog_vbox1), cme__vbox_main, TRUE, TRUE, 0);
 
+  /* the encoder status frame is hidden until encoding starts
+   * it will be added as notebook tab later, when encoding is active.
+   * (see callback p_switch_gui_to_running_encoder_state)
+   */
+  frame = p_create_encoder_status_frame(gpp);
+  gpp->cme__encoder_status_frame = frame;
+  gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
+  gtk_widget_show (frame);
+  
+
+  /* the notebook with encoding options */
   notebook = gtk_notebook_new ();
+  gpp->cme__notebook = notebook;
   gtk_widget_show (notebook);
   gtk_box_pack_start (GTK_BOX (cme__vbox_main), notebook, TRUE, TRUE, 0);
 
@@ -2537,12 +2553,14 @@
 
 
   /* the output frame */
+
+  /* the hbox */
   frame = gimp_frame_new (_("Output"));
   gtk_widget_show (frame);
-  gtk_box_pack_start (GTK_BOX (cme__vbox_main), frame, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (cme__vbox_main), frame, FALSE /* expand*/, TRUE /* fill */, 0);
   gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
 
-  /* the hbox */
+
   hbox = gtk_hbox_new (FALSE, 0);
   gtk_widget_show (hbox);
   gtk_container_add (GTK_CONTAINER (frame), hbox);
@@ -2563,7 +2581,9 @@
                       gpp);
 
   /* the (output) video filebrowser button */
+  
   button = gtk_button_new_with_label (_("..."));
+  gpp->cme__button_video_filesel = button;
   gtk_widget_show (button);
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
   gtk_widget_set_size_request (button, 80, -1);
@@ -2573,7 +2593,6 @@
                       gpp);
 
 
-
   /* the Status frame */
   frame = gimp_frame_new (_("Status"));
   gtk_widget_show (frame);
@@ -2644,6 +2663,136 @@
 }  /* end p_overwrite_dialog */
 
 
+/* ----------------------------------------
+ * p_create_encoder_status_frame
+ * ----------------------------------------
+ */
+static GtkWidget*
+p_create_encoder_status_frame (GapCmeGlobalParams *gpp)
+{
+  GtkWidget *frame;
+  GtkWidget *table;
+  GtkWidget *label;
+  GtkObject *adj;
+  GtkWidget *spinbutton;
+  GtkWidget *combo;
+  GtkWidget *button;
+  GtkWidget *entry;
+  gint       row;
+
+  frame = gimp_frame_new (_("Video Encoder Status"));
+
+
+  table = gtk_table_new (4, 2, FALSE);
+  gtk_widget_show (table);
+  gtk_container_add (GTK_CONTAINER (frame), table);
+  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
+  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
+
+
+  row = 0;
+
+  label = gtk_label_new (_("Active Encoder:"));
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+
+  label = gtk_label_new ("#");
+  gpp->cme__label_active_encoder_name          = label;
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+  row++;
+
+  label = gtk_label_new (" ");
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+  row++;
+
+  label = gtk_label_new (_("Total Frames:"));
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+
+  label = gtk_label_new ("1");
+  gpp->cme__label_enc_stat_frames_total          = label;
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+  row++;
+
+
+  label = gtk_label_new (_("Frames Done:"));
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+
+  label = gtk_label_new ("0");
+  gpp->cme__label_enc_stat_frames_done          = label;
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+  row++;
+
+
+  label = gtk_label_new (_("Frames Encoded:"));
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_widget_show (label);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+
+  label = gtk_label_new ("0");
+  gpp->cme__label_enc_stat_frames_encoded          = label;
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+  row++;
+
+
+  label = gtk_label_new (_("Frames Copied (lossless):"));
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+
+  label = gtk_label_new ("0");
+  gpp->cme__label_enc_stat_frames_copied_lossless          = label;
+  gtk_widget_show (label);
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 1, 2, row, row+1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+
+  return(frame);
+}  /* end p_create_encoder_status_frame */
 
 /* ----------------------------------------
  * p_create_encode_extras_frame
@@ -3583,6 +3732,361 @@
 
 
 /* ----------------------------------------
+ * p_call_encoder_procedure
+ * ----------------------------------------
+ */
+static gint
+p_call_encoder_procedure(GapCmeGlobalParams *gpp)
+{
+  GimpParam* l_params;
+  gint   l_retvals;
+  gint             l_nparams;
+  gint             l_nreturn_vals;
+  GimpPDBProcType   l_proc_type;
+  gchar            *l_proc_blurb;
+  gchar            *l_proc_help;
+  gchar            *l_proc_author;
+  gchar            *l_proc_copyright;
+  gchar            *l_proc_date;
+  GimpParamDef    *l_paramdef;
+  GimpParamDef    *l_return_vals;
+  char *l_msg;
+  gint  l_use_encoderspecific_params;
+  gint  l_rc;
+  gchar            *l_16bit_wav_file;
+  gint32           dummy_layer_id;
+
+  l_rc = -1;
+
+  l_use_encoderspecific_params = 0;  /* run with default values */
+
+
+  if(gpp->val.ecp_sel.vid_enc_plugin[0] == '\0')
+  {
+     printf("p_call_encoder_procedure: No encoder available (exit)\n");
+     return -1;
+  }
+
+  if(gpp->val.ecp_sel.gui_proc[0] != '\0')
+  {
+    l_use_encoderspecific_params = 1;  /* run with encoder specific values */
+  }
+
+  if(gap_debug)
+  {
+     printf("p_call_encoder_procedure %s: START\n", gpp->val.ecp_sel.vid_enc_plugin);
+     printf("  videoname: %s\n", gpp->val.videoname);
+     printf("  audioname1: %s\n", gpp->val.audioname1);
+     printf("  basename: %s\n", gpp->ainfo.basename);
+     printf("  extension: %s\n", gpp->ainfo.extension);
+     printf("  range_from: %d\n", (int)gpp->val.range_from);
+     printf("  range_to: %d\n", (int)gpp->val.range_to);
+     printf("  framerate: %f\n", (float)gpp->val.framerate);
+     printf("  samplerate: %d\n", (int)gpp->val.samplerate);
+     printf("  wav_samplerate: %d\n", (int)gpp->val.wav_samplerate1);
+     printf("  vid_width: %d\n", (int)gpp->val.vid_width);
+     printf("  vid_height: %d\n", (int)gpp->val.vid_height);
+     printf("  vid_format: %d\n", (int)gpp->val.vid_format);
+     printf("  image_ID: %d\n", (int)gpp->val.image_ID);
+     printf("  l_use_encoderspecific_params: %d\n", (int)l_use_encoderspecific_params);
+     printf("  filtermacro_file: %s\n", gpp->val.filtermacro_file);
+     printf("  storyboard_file: %s\n", gpp->val.storyboard_file);
+     printf("  input_mode: %d\n", gpp->val.input_mode);
+  }
+
+  if(FALSE == gimp_procedural_db_proc_info (gpp->val.ecp_sel.vid_enc_plugin,
+                          &l_proc_blurb,
+                          &l_proc_help,
+                          &l_proc_author,
+                          &l_proc_copyright,
+                          &l_proc_date,
+                          &l_proc_type,
+                          &l_nparams,
+                          &l_nreturn_vals,
+                          &l_paramdef,
+                          &l_return_vals))
+  {
+     l_msg = g_strdup_printf(_("Required Plugin %s not available"), gpp->val.ecp_sel.vid_enc_plugin);
+     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
+     {
+       g_message(l_msg);
+     }
+     g_free(l_msg);
+     return -1;
+  }
+
+  l_16bit_wav_file = &gpp->val.audioname1[0];
+  if(gpp->val.tmp_audfile[0] != '\0')
+  {
+     l_16bit_wav_file = &gpp->val.tmp_audfile[0];
+  }
+
+
+  /* generic call of GAP video encoder plugin */
+  dummy_layer_id = gap_image_get_any_layer(gpp->val.image_ID);
+  l_params = gimp_run_procedure (gpp->val.ecp_sel.vid_enc_plugin,
+                     &l_retvals,
+                     GIMP_PDB_INT32,  gpp->val.run_mode,
+                     GIMP_PDB_IMAGE,  gpp->val.image_ID,
+                     GIMP_PDB_DRAWABLE, dummy_layer_id,
+                     GIMP_PDB_STRING, gpp->val.videoname,
+                     GIMP_PDB_INT32,  gpp->val.range_from,
+                     GIMP_PDB_INT32,  gpp->val.range_to,
+                     GIMP_PDB_INT32,  gpp->val.vid_width,
+                     GIMP_PDB_INT32,  gpp->val.vid_height,
+                     GIMP_PDB_INT32,  gpp->val.vid_format,
+                     GIMP_PDB_FLOAT,  gpp->val.framerate,
+                     GIMP_PDB_INT32,  gpp->val.samplerate,
+                     GIMP_PDB_STRING, l_16bit_wav_file,
+                     GIMP_PDB_INT32,  l_use_encoderspecific_params,
+                     GIMP_PDB_STRING, gpp->val.filtermacro_file,
+                     GIMP_PDB_STRING, gpp->val.storyboard_file,
+                     GIMP_PDB_INT32,  gpp->val.input_mode,
+                     GIMP_PDB_INT32,  gpp->encStatus.master_encoder_id,
+                     GIMP_PDB_END);
+  if(l_params[0].data.d_status == GIMP_PDB_SUCCESS)
+  {
+    l_rc = 0;
+  }
+  g_free(l_params);
+
+  if(l_rc < 0)
+  {
+     l_msg = g_strdup_printf(_("Call of Required Plugin %s failed"), gpp->val.ecp_sel.vid_enc_plugin);
+     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
+     {
+       g_message(l_msg);
+     }
+     g_free(l_msg);
+  }
+
+
+  return (l_rc);
+}  /* end p_call_encoder_procedure */
+
+
+
+static void
+p_set_label_to_numeric_value(GtkWidget *label, gint32 value)
+{
+  char buffer[100];
+  
+  if(label)
+  {
+    g_snprintf(&buffer[0], sizeof(buffer), "%d", value);
+    gtk_label_set_text(GTK_LABEL(label), &buffer[0]);
+  }
+}
+
+/* ----------------------------------------
+ * gap_cme_gui_update_encoder_status
+ * ----------------------------------------
+ * 
+ */
+void
+gap_cme_gui_update_encoder_status(GapCmeGlobalParams *gpp)
+{
+  if(gap_debug)
+  {
+    printf("  gap_cme_gui_update_encoder_status -- frames_processed:%d\n"
+      , gpp->encStatus.frames_processed
+      );
+  }
+
+  if (gpp)
+  {
+    GtkWidget  *pbar;
+    gap_gve_misc_get_master_encoder_progress(&gpp->encStatus);
+
+    gtk_widget_show(gpp->cme__encoder_status_frame);
+  
+    p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_total, gpp->encStatus.total_frames);
+    p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_done, gpp->encStatus.frames_processed);
+    p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_encoded, gpp->encStatus.frames_encoded);
+    p_set_label_to_numeric_value(gpp->cme__label_enc_stat_frames_copied_lossless, gpp->encStatus.frames_copied_lossless);
+
+    pbar = gpp->cme__progressbar_status;
+    if(pbar)
+    {
+      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
+                      );
+      
+      gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR (pbar), l_progress);
+      l_msg = g_strdup_printf(_("Video encoding %d of %d frames done")
+                             , gpp->encStatus.frames_processed
+                             , gpp->encStatus.total_frames
+                             );
+      gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar), l_msg);
+      g_free(l_msg);
+    }
+  }
+}
+
+
+/* ----------------------------------------
+ * gap_cme_gui_start_video_encoder
+ * ----------------------------------------
+ * start the selected video encoder plug-in
+ */
+gint32
+gap_cme_gui_start_video_encoder(GapCmeGlobalParams *gpp)
+{
+   gint32     l_rc;
+   char *l_tmpname;
+   gint32 l_tmp_image_id;
+
+   l_tmpname = NULL;
+   l_tmp_image_id = -1;
+
+   if((gpp->ainfo.last_frame_nr - gpp->ainfo.first_frame_nr == 0)
+   && (gpp->val.storyboard_file[0] == '\0'))
+   {
+     char *l_current_name;
+
+     if((strcmp(gpp->ainfo.extension, ".xcf") == 0)
+     || (strcmp(gpp->ainfo.extension, ".xjt") == 0))
+     {
+       /* for xcf and xjt just save without making a temp copy */
+       l_tmpname = gimp_image_get_filename(gpp->val.image_ID);
+     }
+     else
+     {
+       /* prepare encoder params to run the encoder on the (saved) duplicate of the image */
+       g_snprintf(gpp->ainfo.basename, sizeof(gpp->ainfo.basename), "%s", l_tmpname);
+
+       /* save a temporary copy of the image */
+       l_tmp_image_id = gimp_image_duplicate(gpp->val.image_ID);
+
+       /* l_tmpname = gimp_temp_name("xcf"); */
+       l_current_name = gimp_image_get_filename(gpp->val.image_ID);
+       l_tmpname = g_strdup_printf("%s_temp_copy.xcf", l_current_name);
+       gimp_image_set_filename (l_tmp_image_id, l_tmpname);
+       gpp->ainfo.extension[0] = '\0';
+       gpp->val.image_ID = l_tmp_image_id;
+       g_free(l_current_name);
+     }
+
+     gimp_file_save(GIMP_RUN_NONINTERACTIVE
+                   , gpp->val.image_ID
+                   , 1 /* dummy layer_id */
+                   ,l_tmpname
+                   ,l_tmpname
+                   );
+
+   }
+
+   gap_gve_misc_initGapGveMasterEncoderStatus(&gpp->encStatus
+       , getpid() /* master_encoder_id */
+       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
+       );
+
+   /* ------------------------------------------- HERE WE GO, start Video Encoder ---- */
+   l_rc = p_call_encoder_procedure(gpp);
+   gpp->video_encoder_run_state =  GAP_CME_ENC_RUN_STATE_FINISHED;
+
+   if(l_tmp_image_id >= 0)
+   {
+     gap_image_delete_immediate(l_tmp_image_id);
+     g_remove(l_tmpname);
+   }
+   if(l_tmpname)
+   {
+     g_free(l_tmpname);
+   }
+   
+   return (l_rc);
+}  /* end gap_cme_gui_start_video_encoder */
+
+
+/* ----------------------------------------
+ * gap_cme_encoder_worker_thread
+ * ----------------------------------------
+ */
+gpointer
+gap_cme_encoder_worker_thread(gpointer data)
+{
+  GapCmeGlobalParams *gpp;
+
+  gpp = (GapCmeGlobalParams *) data;
+
+  if(gap_debug)
+  {
+    printf("THREAD: gap_cme_encoder_worker_thread &gpp: %d\n", (int)gpp);
+  }
+
+  gap_cme_gui_start_video_encoder(gpp);
+  
+  if(gap_debug)
+  {
+    printf("THREAD gap_cme_encoder_worker_thread TERMINATING: %d\n", (int)gpp->val.gui_proc_thread);
+  }
+
+  gpp->productive_encoder_thread = NULL;
+
+  return (NULL);
+}  /* end gap_cme_encoder_worker_thread */
+
+
+/* ----------------------------------------
+ * gap_cme_gui_start_video_encoder
+ * ----------------------------------------
+ * start the selected video encoder plug-in
+ */
+gint32
+gap_cme_gui_start_video_encoder_as_thread(GapCmeGlobalParams *gpp)
+{
+  gboolean joinable;
+  if(gpp->ecp == NULL)
+  {
+    return -1;
+  }
+
+#ifdef GAP_USE_GTHREAD
+  if(gpp->productive_encoder_thread != NULL)
+  {
+    return -1;
+  }
+
+  /* start a thread for asynchron PDB call of the gui_ procedure
+   */
+  if(gap_debug)
+  {
+    printf("MASTER: Before g_thread_create encode video worker\n");
+  }
+
+  joinable = TRUE;
+  gpp->productive_encoder_thread =
+      g_thread_create((GThreadFunc)gap_cme_encoder_worker_thread
+                     , gpp  /* data */
+		     , joinable
+		     , NULL  /* GError **error (NULL dont report errors) */
+		     );
+
+  if(gap_debug)
+  {
+    printf("MASTER: After g_thread_create encode video worker\n");
+  }
+#else
+  /* if threads are not used simply call the procedure
+   * (the common GUI window is not refreshed until the called gui_proc ends)
+   */
+  gap_cme_encoder_worker_thread(gpp);
+
+#endif
+
+  return 0;
+}  /* end gap_cme_gui_start_video_encoder_as_thread */
+
+
+
+
+
+
+/* ----------------------------------------
  * gap_cme_gui_master_encoder_dialog
  * ----------------------------------------
  * common GUI dialog
@@ -3622,6 +4126,15 @@
 
 
   /* ---------- dialog ----------*/
+  gap_gve_misc_initGapGveMasterEncoderStatus(&gpp->encStatus
+       , getpid()  /* master_encoder_id */
+       , 1         /* total_frames */
+       );
+  gap_gve_misc_set_master_encoder_cancel_request(&gpp->encStatus, FALSE);
+  gpp->video_encoder_run_state = GAP_CME_ENC_RUN_STATE_READY;
+  gpp->productive_encoder_thread = NULL;
+  gpp->productive_encoder_timertag = -1;
+  gpp->encoder_status_poll_timertag = -1;
   gpp->storyboard_create_composite_audio = FALSE;
   gpp->fsv__fileselection = NULL;
   gpp->fsb__fileselection = NULL;
@@ -3657,6 +4170,20 @@
 
   gpp->shell_window = NULL;
 
+  /* is the encoder specific gui_thread still open ? */
+  if(gpp->val.gui_proc_thread != NULL)
+  {
+     /* wait until thread exits */
+     g_thread_join(gpp->val.gui_proc_thread);
+     gpp->val.gui_proc_thread = NULL;
+  }
+  if(gpp->productive_encoder_thread != NULL)
+  {
+     /* wait until thread exits */
+     g_thread_join(gpp->productive_encoder_thread);
+     gpp->productive_encoder_thread = NULL;
+  }
+
   if(gpp->val.run)
   {
     return 0;

Modified: trunk/vid_common/gap_cme_gui.h
==============================================================================
--- trunk/vid_common/gap_cme_gui.h	(original)
+++ trunk/vid_common/gap_cme_gui.h	Sun Nov  2 12:10:50 2008
@@ -63,6 +63,11 @@
 GtkWidget*	gap_cme_gui_create_fsb__fileselection (GapCmeGlobalParams *gpp);
 GtkWidget*	gap_cme_gui_create_fsa__fileselection (GapCmeGlobalParams *gpp);
 
+void            gap_cme_gui_update_encoder_status(GapCmeGlobalParams *gpp);
+gint32          gap_cme_gui_start_video_encoder(GapCmeGlobalParams *gpp);
+gint32          gap_cme_gui_start_video_encoder_as_thread(GapCmeGlobalParams *gpp);
+
+
 
 gint32 gap_cme_gui_master_encoder_dialog(GapCmeGlobalParams *gpp);
 

Modified: trunk/vid_common/gap_cme_main.c
==============================================================================
--- trunk/vid_common/gap_cme_main.c	(original)
+++ trunk/vid_common/gap_cme_main.c	Sun Nov  2 12:10:50 2008
@@ -171,137 +171,8 @@
 }       /* end query */
 
 
-/* ----------------------------------------
- * p_call_encoder_procedure
- * ----------------------------------------
- */
-static gint
-p_call_encoder_procedure(GapCmeGlobalParams *gpp)
-{
-  GimpParam* l_params;
-  gint   l_retvals;
-  gint             l_nparams;
-  gint             l_nreturn_vals;
-  GimpPDBProcType   l_proc_type;
-  gchar            *l_proc_blurb;
-  gchar            *l_proc_help;
-  gchar            *l_proc_author;
-  gchar            *l_proc_copyright;
-  gchar            *l_proc_date;
-  GimpParamDef    *l_paramdef;
-  GimpParamDef    *l_return_vals;
-  char *l_msg;
-  gint  l_use_encoderspecific_params;
-  gint  l_rc;
-  gchar            *l_16bit_wav_file;
-  gint32           dummy_layer_id;
-
-  l_rc = -1;
-
-  l_use_encoderspecific_params = 0;  /* run with default values */
-
-
-  if(gpp->val.ecp_sel.vid_enc_plugin[0] == '\0')
-  {
-     printf("p_call_encoder_procedure: No encoder available (exit)\n");
-     return -1;
-  }
-
-  if(gpp->val.ecp_sel.gui_proc[0] != '\0')
-  {
-    l_use_encoderspecific_params = 1;  /* run with encoder specific values */
-  }
-
-  if(gap_debug)
-  {
-     printf("p_call_encoder_procedure %s: START\n", gpp->val.ecp_sel.vid_enc_plugin);
-     printf("  videoname: %s\n", gpp->val.videoname);
-     printf("  audioname1: %s\n", gpp->val.audioname1);
-     printf("  basename: %s\n", gpp->ainfo.basename);
-     printf("  extension: %s\n", gpp->ainfo.extension);
-     printf("  range_from: %d\n", (int)gpp->val.range_from);
-     printf("  range_to: %d\n", (int)gpp->val.range_to);
-     printf("  framerate: %f\n", (float)gpp->val.framerate);
-     printf("  samplerate: %d\n", (int)gpp->val.samplerate);
-     printf("  wav_samplerate: %d\n", (int)gpp->val.wav_samplerate1);
-     printf("  vid_width: %d\n", (int)gpp->val.vid_width);
-     printf("  vid_height: %d\n", (int)gpp->val.vid_height);
-     printf("  vid_format: %d\n", (int)gpp->val.vid_format);
-     printf("  image_ID: %d\n", (int)gpp->val.image_ID);
-     printf("  l_use_encoderspecific_params: %d\n", (int)l_use_encoderspecific_params);
-     printf("  filtermacro_file: %s\n", gpp->val.filtermacro_file);
-     printf("  storyboard_file: %s\n", gpp->val.storyboard_file);
-     printf("  input_mode: %d\n", gpp->val.input_mode);
-  }
-
-  if(FALSE == gimp_procedural_db_proc_info (gpp->val.ecp_sel.vid_enc_plugin,
-                          &l_proc_blurb,
-                          &l_proc_help,
-                          &l_proc_author,
-                          &l_proc_copyright,
-                          &l_proc_date,
-                          &l_proc_type,
-                          &l_nparams,
-                          &l_nreturn_vals,
-                          &l_paramdef,
-                          &l_return_vals))
-  {
-     l_msg = g_strdup_printf(_("Required Plugin %s not available"), gpp->val.ecp_sel.vid_enc_plugin);
-     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
-     {
-       g_message(l_msg);
-     }
-     g_free(l_msg);
-     return -1;
-  }
-
-  l_16bit_wav_file = &gpp->val.audioname1[0];
-  if(gpp->val.tmp_audfile[0] != '\0')
-  {
-     l_16bit_wav_file = &gpp->val.tmp_audfile[0];
-  }
 
 
-  /* generic call of GAP video encoder plugin */
-  dummy_layer_id = gap_image_get_any_layer(gpp->val.image_ID);
-  l_params = gimp_run_procedure (gpp->val.ecp_sel.vid_enc_plugin,
-                     &l_retvals,
-                     GIMP_PDB_INT32,  gpp->val.run_mode,
-                     GIMP_PDB_IMAGE,  gpp->val.image_ID,
-                     GIMP_PDB_DRAWABLE, dummy_layer_id,
-                     GIMP_PDB_STRING, gpp->val.videoname,
-                     GIMP_PDB_INT32,  gpp->val.range_from,
-                     GIMP_PDB_INT32,  gpp->val.range_to,
-                     GIMP_PDB_INT32,  gpp->val.vid_width,
-                     GIMP_PDB_INT32,  gpp->val.vid_height,
-                     GIMP_PDB_INT32,  gpp->val.vid_format,
-                     GIMP_PDB_FLOAT,  gpp->val.framerate,
-                     GIMP_PDB_INT32,  gpp->val.samplerate,
-                     GIMP_PDB_STRING, l_16bit_wav_file,
-                     GIMP_PDB_INT32,  l_use_encoderspecific_params,
-                     GIMP_PDB_STRING, gpp->val.filtermacro_file,
-                     GIMP_PDB_STRING, gpp->val.storyboard_file,
-                     GIMP_PDB_INT32,  gpp->val.input_mode,
-                     GIMP_PDB_END);
-  if(l_params[0].data.d_status == GIMP_PDB_SUCCESS)
-  {
-    l_rc = 0;
-  }
-  g_free(l_params);
-
-  if(l_rc < 0)
-  {
-     l_msg = g_strdup_printf(_("Call of Required Plugin %s failed"), gpp->val.ecp_sel.vid_enc_plugin);
-     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
-     {
-       g_message(l_msg);
-     }
-     g_free(l_msg);
-  }
-
-
-  return (l_rc);
-}  /* end p_call_encoder_procedure */
 
 /* ----------------------------------------
  * gap_cme_main_get_global_params
@@ -396,7 +267,10 @@
 
       if (gpp->val.run_mode == GIMP_RUN_NONINTERACTIVE)
       {
-        if (n_params == GAP_VENC_NUM_STANDARD_PARAM)
+        /* the masterencoder is called without the master_encoder_id parameter
+         * (therefore its number of arguments is GAP_VENC_NUM_STANDARD_PARAM -1)
+         */
+        if (n_params >= GAP_VENC_NUM_STANDARD_PARAM -1)
         {
 	  l_copy_parameters = TRUE;
         }
@@ -409,7 +283,7 @@
       {
 	if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
 	{
-          if (n_params == GAP_VENC_NUM_STANDARD_PARAM)
+          if (n_params >= GAP_VENC_NUM_STANDARD_PARAM -1)
           {
 	    l_copy_parameters = TRUE;
 	  }
@@ -459,19 +333,18 @@
          if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
          {
             if(gap_debug) printf("MAIN before gap_cme_gui_master_encoder_dialog ------------------\n");
+            
+            /* note that the dialog alrady performs the encoding (as worker thread)
+             */
             l_rc = gap_cme_gui_master_encoder_dialog (gpp);
+            
+            
             if(gap_debug) printf("MAIN after gap_cme_gui_master_encoder_dialog ------------------\n");
 	    if(l_rc < 0)
 	    {
               values[0].data.d_status = GIMP_PDB_CANCEL;
 	    }
 
-            /* delete images in the cache
-             * (the cache may have been filled while parsing
-             * storyboard file in the common dialog
-             */
-             gap_gve_story_drop_image_cache();
-            if(gap_debug) printf("MAIN after gap_gve_story_drop_image_cache ------------------\n");
          }
          else
          {
@@ -480,65 +353,9 @@
              * but in noninteractive modes we have to resample now.
              */
             l_rc =   gap_gve_sox_chk_and_resample(&gpp->val);
-         }
-
-
-         if (l_rc >= 0 )
-         {
-            char *l_tmpname;
-            gint32 l_tmp_image_id;
-
-            l_tmpname = NULL;
-            l_tmp_image_id = -1;
-
-            if((gpp->ainfo.last_frame_nr - gpp->ainfo.first_frame_nr == 0)
-            && (gpp->val.storyboard_file[0] == '\0'))
+            if (l_rc >= 0 )
             {
-              char *l_current_name;
-
-              if((strcmp(gpp->ainfo.extension, ".xcf") == 0)
-              || (strcmp(gpp->ainfo.extension, ".xjt") == 0))
-              {
-                /* for xcf and xjt just save without making a temp copy */
-                l_tmpname = gimp_image_get_filename(gpp->val.image_ID);
-              }
-              else
-              {
-                /* prepare encoder params to run the encoder on the (saved) duplicate of the image */
-                g_snprintf(gpp->ainfo.basename, sizeof(gpp->ainfo.basename), "%s", l_tmpname);
-
-                /* save a temporary copy of the image */
-                l_tmp_image_id = gimp_image_duplicate(gpp->val.image_ID);
-
-                /* l_tmpname = gimp_temp_name("xcf"); */
-                l_current_name = gimp_image_get_filename(gpp->val.image_ID);
-                l_tmpname = g_strdup_printf("%s_temp_copy.xcf", l_current_name);
-                gimp_image_set_filename (l_tmp_image_id, l_tmpname);
-                gpp->ainfo.extension[0] = '\0';
-                gpp->val.image_ID = l_tmp_image_id;
-                g_free(l_current_name);
-              }
-
-              gimp_file_save(GIMP_RUN_NONINTERACTIVE
-                            , gpp->val.image_ID
-                            , 1 /* dummy layer_id */
-                            ,l_tmpname
-                            ,l_tmpname
-                            );
-
-            }
-
-            /* ------------------------------------------- HERE WE GO, start Video Encoder ---- */
-            l_rc = p_call_encoder_procedure(gpp);
-
-            if(l_tmp_image_id >= 0)
-            {
-              gap_image_delete_immediate(l_tmp_image_id);
-              g_remove(l_tmpname);
-            }
-            if(l_tmpname)
-            {
-              g_free(l_tmpname);
+               l_rc = gap_cme_gui_start_video_encoder(gpp);
             }
          }
 
@@ -547,13 +364,6 @@
            g_remove(gpp->val.tmp_audfile);
          }
 
-         /* is the encoder specific gui_thread still open ? */
-         if(gpp->val.gui_proc_thread != NULL)
-         {
-            /* wait until thread exits */
-            g_thread_join(gpp->val.gui_proc_thread);
-	    gpp->val.gui_proc_thread = NULL;
-         }
       }
   }
   else

Modified: trunk/vid_common/gap_cme_main.h
==============================================================================
--- trunk/vid_common/gap_cme_main.h	(original)
+++ trunk/vid_common/gap_cme_main.h	Sun Nov  2 12:10:50 2008
@@ -33,6 +33,9 @@
 #include <config.h>
 #include "gap_gvetypes.h"
 
+#include <sys/types.h>
+#include <unistd.h>
+
 #define GAP_CME_PLUGIN_NAME_VID_ENCODE_MASTER    "plug-in-gap-vid-encode-master"
 #define GAP_CME_PLUGIN_HELP_ID_VID_ENCODE_MASTER "plug-in-gap-vid-encode-master"
 
@@ -81,7 +84,12 @@
 #define GAP_CME_STANDARD_SAMPLERATE_MAX_ELEMENTS  9
 
 
-
+typedef enum
+{
+   GAP_CME_ENC_RUN_STATE_READY       = 0
+ , GAP_CME_ENC_RUN_STATE_RUNNING     = 1
+ , GAP_CME_ENC_RUN_STATE_FINISHED    = 2 
+} GapCmeEncoderRunState;
 
 typedef struct GapCmeGlobalParams {                    /* nick: gpp */
   GapGveCommonValues   val;
@@ -110,6 +118,7 @@
   GtkWidget *cme__entry_sox_options;
   GtkWidget *cme__entry_stb;
   GtkWidget *cme__entry_video;
+  GtkWidget *cme__button_video_filesel;
   GtkWidget *cme__label_aud0_time;
   GtkWidget *cme__label_aud1_info;
   GtkWidget *cme__label_aud1_time;
@@ -146,6 +155,22 @@
   GtkObject *cme__spinbutton_framerate_adj;
   GtkObject *cme__spinbutton_samplerate_adj;
 
+
+  GtkWidget *cme__notebook;
+  GtkWidget *cme__encoder_status_frame;
+  GtkWidget *cme__vbox_main;
+  GtkWidget *cme__label_enc_stat_frames_total;
+  GtkWidget *cme__label_enc_stat_frames_done;
+  GtkWidget *cme__label_enc_stat_frames_encoded;
+  GtkWidget *cme__label_enc_stat_frames_copied_lossless;
+  GtkWidget *cme__label_active_encoder_name;
+
+  GapCmeEncoderRunState  video_encoder_run_state;
+  gint32 productive_encoder_timertag;
+  gint32 encoder_status_poll_timertag;
+  GThread    *productive_encoder_thread; 
+  GapGveMasterEncoderStatus encStatus;
+  
 } GapCmeGlobalParams;
 
 GapCmeGlobalParams * gap_cme_main_get_global_params(void);

Modified: trunk/vid_enc_avi/gap_enc_avi_main.c
==============================================================================
--- trunk/vid_enc_avi/gap_enc_avi_main.c	(original)
+++ trunk/vid_enc_avi/gap_enc_avi_main.c	Sun Nov  2 12:10:50 2008
@@ -141,6 +141,7 @@
     {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."},
+    {GIMP_PDB_INT32, "master_encoder_id", "id of the master encoder that called this plug-in (typically the pid)"},
   };
   static int nargs_avi_enc = sizeof(args_avi_enc) / sizeof(args_avi_enc[0]);
 
@@ -481,6 +482,8 @@
         if (param[13].data.d_string[0] != '\0') { g_snprintf(gpp->val.filtermacro_file, sizeof(gpp->val.filtermacro_file), "%s", param[13].data.d_string); }
         if (param[14].data.d_string[0] != '\0') { g_snprintf(gpp->val.storyboard_file, sizeof(gpp->val.storyboard_file), "%s", param[14].data.d_string); }
         if (param[15].data.d_int32 >= 0) { gpp->val.input_mode   =    param[15].data.d_int32; }
+        
+        gpp->val.master_encoder_id = param[16].data.d_int32;
       }
 
       if (values[0].data.d_status == GIMP_PDB_SUCCESS)
@@ -637,6 +640,7 @@
   gint32   l_video_frame_chunk_size;
   gint32   l_video_frame_chunk_hdr_size;
   gboolean l_dont_recode_frames;
+  GapGveMasterEncoderStatus encStatus;
 
 #ifdef ENABLE_LIBXVIDCORE
   GapGveXvidControl      *xvid_control = NULL;
@@ -662,6 +666,7 @@
      printf("  input_mode: %d\n", gpp->val.input_mode);
 
      printf("  codec_name:%s:\n", epp->codec_name);
+     printf("  master_encoder_id:%d:\n", gpp->val.master_encoder_id);
   }
 
   l_maxSizeOfRawFrame = p_dimSizeOfRawFrame(gpp);
@@ -678,17 +683,20 @@
   l_video_frame_chunk_hdr_size = 0;
   l_dont_recode_frames = FALSE;
 
+
   /* make list of frameranges */
-  { 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->ainfo.extension
-                                       ,gpp->val.range_from
-                                       ,gpp->val.range_to
-                                       ,&l_total_framecount
-                                       );
+  {
+    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->ainfo.extension
+                                         ,gpp->val.range_from
+                                         ,gpp->val.range_to
+                                         ,&l_total_framecount
+                                         );
+    l_vidhand->do_gimp_progress = FALSE;
   }
 
   /* TODO check for overwrite */
@@ -704,7 +712,10 @@
   l_percentage = 0.0;
   if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
   {
-    gimp_progress_init(_("AVI Video Encoding .."));
+    gap_gve_misc_initGapGveMasterEncoderStatus(&encStatus
+       , gpp->val.master_encoder_id
+       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
+       );
   }
 
 
@@ -1066,10 +1077,23 @@
 
 
     l_percentage += l_percentage_step;
-    if(gap_debug) printf("PROGRESS: %f\n", (float) l_percentage);
+    if(gap_debug)
+    {
+      printf("PROGRESS: %f\n", (float) l_percentage);
+    }
     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
     {
-      gimp_progress_update (l_percentage);
+      encStatus.frames_processed++;
+      encStatus.frames_encoded = l_cnt_encoded_frames;
+      encStatus.frames_copied_lossless = l_cnt_reused_frames;
+
+      gap_gve_misc_do_master_encoder_progress(&encStatus);
+    }
+
+    /* terminate on cancel reqeuset (CANCEL button was pressed in the master encoder dialog) */
+    if(gap_gve_misc_is_master_encoder_cancel_request(&encStatus))
+    {
+       break;
     }
 
     /* advance to next frame */
@@ -1105,10 +1129,12 @@
   }
 
   /* statistics */
-  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);
-
+  if(gap_debug)
+  {
+    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);
+  }
   g_free(l_video_chunk_ptr);
   return l_rc;
 }    /* end p_avi_encode */

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	Sun Nov  2 12:10:50 2008
@@ -377,6 +377,7 @@
     {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."},
+    {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]);
 
@@ -699,6 +700,8 @@
         if (param[13].data.d_string[0] != '\0') { g_snprintf(gpp->val.filtermacro_file, sizeof(gpp->val.filtermacro_file), "%s", param[13].data.d_string); }
         if (param[14].data.d_string[0] != '\0') { g_snprintf(gpp->val.storyboard_file, sizeof(gpp->val.storyboard_file), "%s", param[14].data.d_string); }
         if (param[15].data.d_int32 >= 0) { gpp->val.input_mode   =    param[15].data.d_int32; }
+
+        gpp->val.master_encoder_id = param[16].data.d_int32;
       }
 
       if (values[0].data.d_status == GIMP_PDB_SUCCESS)
@@ -3093,6 +3096,7 @@
   t_awk_array   l_awk_arr;
   t_awk_array   *awp;
   GapCodecNameElem    *l_vcodec_list;
+  GapGveMasterEncoderStatus encStatus;
 
 
   epp = &gpp->evl;
@@ -3124,6 +3128,7 @@
      printf("  acodec_name: %s\n", epp->acodec_name);
      printf("  vcodec_name: %s\n", epp->vcodec_name);
      printf("  format_name: %s\n", epp->format_name);
+     printf("  master_encoder_id:%d:\n", gpp->val.master_encoder_id);
   }
 
   l_rc = 0;
@@ -3143,6 +3148,7 @@
                                        );
 
     l_video_tracks = 1;
+    l_vidhand->do_gimp_progress = FALSE;
   }
 
   /* TODO check for overwrite (in case we are called non-interactive) */
@@ -3169,7 +3175,10 @@
   l_percentage = 0.0;
   if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
   {
-    gimp_progress_init(_("FFMPEG initializing for video encoding .."));
+    gap_gve_misc_initGapGveMasterEncoderStatus(&encStatus
+       , gpp->val.master_encoder_id
+       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
+       );
   }
 
 
@@ -3290,28 +3299,23 @@
 
 
     l_percentage += l_percentage_step;
-    if(gap_debug) printf("PROGRESS: %f\n", (float) l_percentage);
+    if(gap_debug)
+    {
+      printf("PROGRESS: %f\n", (float) l_percentage);
+    }
     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
     {
-      char *msg;
+      encStatus.frames_processed++;
+      encStatus.frames_encoded = l_cnt_encoded_frames;
+      encStatus.frames_copied_lossless = l_cnt_reused_frames;
 
-      if (l_video_frame_chunk_size > 0)
-      {
-        msg = g_strdup_printf(_("FFMPEG lossless copy frame %d (%d)")
-                           ,(int)l_cnt_encoded_frames + l_cnt_reused_frames
-                           ,(int)l_max_master_frame_nr
-			   );
-      }
-      else
-      {
-        msg = g_strdup_printf(_("FFMPEG encoding frame %d (%d)")
-                           ,(int)l_cnt_encoded_frames + l_cnt_reused_frames
-                           ,(int)l_max_master_frame_nr
-			   );
-      }
-      gimp_progress_init(msg);
-      g_free(msg);
-      gimp_progress_update (l_percentage);
+      gap_gve_misc_do_master_encoder_progress(&encStatus);
+    }
+
+    /* terminate on cancel reqeuset (CANCEL button was pressed in the master encoder dialog) */
+    if(gap_gve_misc_is_master_encoder_cancel_request(&encStatus))
+    {
+       break;
     }
 
     /* advance to next frame */
@@ -3358,9 +3362,12 @@
   }
 
   /* statistics */
-  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);
-
+  if(gap_debug)
+  {
+    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 */

Modified: trunk/vid_enc_rawframes/gap_enc_rawframes_main.c
==============================================================================
--- trunk/vid_enc_rawframes/gap_enc_rawframes_main.c	(original)
+++ trunk/vid_enc_rawframes/gap_enc_rawframes_main.c	Sun Nov  2 12:10:50 2008
@@ -145,6 +145,7 @@
     {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."},
+    {GIMP_PDB_INT32, "master_encoder_id", "id of the master encoder that called this plug-in (typically the pid)"},
   };
   static int nargs_raw_enc = sizeof(args_raw_enc) / sizeof(args_raw_enc[0]);
 
@@ -441,6 +442,8 @@
         if (param[13].data.d_string[0] != '\0') { g_snprintf(gpp->val.filtermacro_file, sizeof(gpp->val.filtermacro_file), "%s", param[13].data.d_string); }
         if (param[14].data.d_string[0] != '\0') { g_snprintf(gpp->val.storyboard_file, sizeof(gpp->val.storyboard_file), "%s", param[14].data.d_string); }
         if (param[15].data.d_int32 >= 0) { gpp->val.input_mode   =    param[15].data.d_int32; }
+
+        gpp->val.master_encoder_id = param[16].data.d_int32;
       }
 
       if (values[0].data.d_status == GIMP_PDB_SUCCESS)
@@ -716,6 +719,7 @@
   gchar         *l_frame_fmt;      /* format string has one %d for the framenumber */
   gint32         l_out_frame_nr;
   GimpRunMode    l_save_runmode;
+  GapGveMasterEncoderStatus encStatus;
 
   //if(gap_debug)
   {
@@ -733,6 +737,7 @@
      printf("  image_ID: %d\n", (int)gpp->val.image_ID);
      printf("  storyboard_file: %s\n", gpp->val.storyboard_file);
      printf("  input_mode: %d\n", gpp->val.input_mode);
+     printf("  master_encoder_id:%d:\n", gpp->val.master_encoder_id);
   }
 
   l_maxSizeOfRawFrame = p_dimSizeOfRawFrame(gpp);
@@ -762,16 +767,18 @@
 
 
   /* make list of frameranges */
-  { 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->ainfo.extension
-                                       ,gpp->val.range_from
-                                       ,gpp->val.range_to
-                                       ,&l_total_framecount
-                                       );
+  {
+    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->ainfo.extension
+                                         ,gpp->val.range_from
+                                         ,gpp->val.range_to
+                                         ,&l_total_framecount
+                                         );
+    l_vidhand->do_gimp_progress = FALSE;
   }
 
   /* TODO check for overwrite */
@@ -782,7 +789,10 @@
   l_percentage = 0.0;
   if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
   {
-    gimp_progress_init(_("Rawframes Video Eextract .."));
+    gap_gve_misc_initGapGveMasterEncoderStatus(&encStatus
+       , gpp->val.master_encoder_id
+       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
+       );
   }
 
 
@@ -920,7 +930,17 @@
     if(gap_debug) printf("PROGRESS: %f\n", (float) l_percentage);
     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
     {
-      gimp_progress_update (l_percentage);
+      encStatus.frames_processed++;
+      encStatus.frames_encoded = l_cnt_encoded_frames;
+      encStatus.frames_copied_lossless = l_cnt_reused_frames;
+
+      gap_gve_misc_do_master_encoder_progress(&encStatus);
+    }
+
+    /* terminate on cancel reqeuset (CANCEL button was pressed in the master encoder dialog) */
+    if(gap_gve_misc_is_master_encoder_cancel_request(&encStatus))
+    {
+       break;
     }
 
     /* advance to next frame */
@@ -940,9 +960,12 @@
   }
 
   /* statistics */
-  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);
+  if(gap_debug)
+  {
+    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_rawframe_encode */

Modified: trunk/vid_enc_single/gap_enc_singleframes_main.c
==============================================================================
--- trunk/vid_enc_single/gap_enc_singleframes_main.c	(original)
+++ trunk/vid_enc_single/gap_enc_singleframes_main.c	Sun Nov  2 12:10:50 2008
@@ -142,6 +142,7 @@
     {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."},
+    {GIMP_PDB_INT32, "master_encoder_id", "id of the master encoder that called this plug-in (typically the pid)"},
   };
   static int nargs_single_enc = sizeof(args_single_enc) / sizeof(args_single_enc[0]);
 
@@ -432,6 +433,8 @@
         if (param[13].data.d_string[0] != '\0') { g_snprintf(gpp->val.filtermacro_file, sizeof(gpp->val.filtermacro_file), "%s", param[13].data.d_string); }
         if (param[14].data.d_string[0] != '\0') { g_snprintf(gpp->val.storyboard_file, sizeof(gpp->val.storyboard_file), "%s", param[14].data.d_string); }
         if (param[15].data.d_int32 >= 0) { gpp->val.input_mode   =    param[15].data.d_int32; }
+
+        gpp->val.master_encoder_id = param[16].data.d_int32;
       }
 
       if (values[0].data.d_status == GIMP_PDB_SUCCESS)
@@ -627,6 +630,7 @@
   gchar          *l_frame_fmt;      /* format string has one %d for the framenumber */
   gint32          l_out_frame_nr;
   GimpRunMode     l_save_runmode;
+  GapGveMasterEncoderStatus encStatus;
 
   if(gap_debug)
   {
@@ -644,6 +648,7 @@
      printf("  image_ID: %d\n", (int)gpp->val.image_ID);
      printf("  storyboard_file: %s\n", gpp->val.storyboard_file);
      printf("  input_mode: %d\n", gpp->val.input_mode);
+     printf("  master_encoder_id:%d:\n", gpp->val.master_encoder_id);
   }
 
   l_out_frame_nr = 0;
@@ -656,16 +661,18 @@
 
 
   /* make list of frameranges */
-  { 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->ainfo.extension
-                                       ,gpp->val.range_from
-                                       ,gpp->val.range_to
-                                       ,&l_total_framecount
-                                       );
+  {
+    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->ainfo.extension
+                                         ,gpp->val.range_from
+                                         ,gpp->val.range_to
+                                         ,&l_total_framecount
+                                         );
+    l_vidhand->do_gimp_progress = FALSE;
   }
 
   /* TODO check for overwrite */
@@ -676,7 +683,10 @@
   l_percentage = 0.0;
   if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
   {
-    gimp_progress_init(_("Singleframes Video Encoding .."));
+    gap_gve_misc_initGapGveMasterEncoderStatus(&encStatus
+       , gpp->val.master_encoder_id
+       , abs(gpp->val.range_to - gpp->val.range_from) + 1   /* total_frames */
+       );
   }
 
 
@@ -757,7 +767,17 @@
     if(gap_debug) printf("PROGRESS: %f\n", (float) l_percentage);
     if(gpp->val.run_mode == GIMP_RUN_INTERACTIVE)
     {
-      gimp_progress_update (l_percentage);
+      encStatus.frames_processed++;
+      encStatus.frames_encoded = encStatus.frames_processed;
+      encStatus.frames_copied_lossless = 0;
+
+      gap_gve_misc_do_master_encoder_progress(&encStatus);
+    }
+
+    /* terminate on cancel reqeuset (CANCEL button was pressed in the master encoder dialog) */
+    if(gap_gve_misc_is_master_encoder_cancel_request(&encStatus))
+    {
+       break;
     }
 
     /* advance to next frame */



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