gimp-gap r778 - in trunk: . gap



Author: wolfgangh
Date: Sun Oct  5 12:30:58 2008
New Revision: 778
URL: http://svn.gnome.org/viewvc/gimp-gap?rev=778&view=rev

Log:
som bugfixes, including #523115

Modified:
   trunk/ChangeLog
   trunk/gap/gap_lib.c
   trunk/gap/gap_player_dialog.c
   trunk/gap/gap_story_main.h
   trunk/gap/gap_story_properties.c
   trunk/gap/gap_story_render_audio.c

Modified: trunk/gap/gap_lib.c
==============================================================================
--- trunk/gap/gap_lib.c	(original)
+++ trunk/gap/gap_lib.c	Sun Oct  5 12:30:58 2008
@@ -652,7 +652,7 @@
   }
 
   l_len = strlen(name);
-  l_str = g_malloc(l_len+1);
+  l_str = g_malloc(l_len+2);
   strcpy(l_str, name);
   if(l_len > 0)
   {

Modified: trunk/gap/gap_player_dialog.c
==============================================================================
--- trunk/gap/gap_player_dialog.c	(original)
+++ trunk/gap/gap_player_dialog.c	Sun Oct  5 12:30:58 2008
@@ -833,6 +833,13 @@
     }
   }
 
+  if(gap_debug)
+  {
+    printf("p_get_audio_relevant_FrameNr: framenr:%d localFrameNr:%d\n"
+      ,framenr
+      ,localFrameNr
+      );
+  }
 
   return (localFrameNr);
   
@@ -962,8 +969,8 @@
   gdouble flt_samplerate;
   gint32 l_samplerate;
   gint32 l_samples;
-
-
+  gdouble l_referedClipSpeed;
+    
 
   /* if (gap_debug) printf("p_audio_start_play\n"); */
 
@@ -977,16 +984,22 @@
 
   l_samples = gpp->audio_samples;
   l_samplerate = gpp->audio_samplerate;
+  l_referedClipSpeed = gpp->original_speed;
 
   if (gpp->audio_auto_offset_by_framenr == TRUE)
   {
     gint32 localFramenr;
+    if (gpp->gvahand)
+    {
+      l_referedClipSpeed = gpp->gvahand->framerate;
+      l_samplerate = gpp->gvahand->samplerate;
+    }
     
     localFramenr = p_get_audio_relevant_FrameNr(gpp, gpp->play_current_framenr);
     
     offset_start_sec = ( localFramenr
                      + gpp->audio_frame_offset
-                     ) / MAX(1, gpp->original_speed);
+                     ) / MAX(1, l_referedClipSpeed);
   }
   else
   {
@@ -997,11 +1010,26 @@
   }
 
   offset_start_samples = offset_start_sec * l_samplerate;
-  if(gpp->original_speed > 0)
+  
+  if(gap_debug)
+  {
+    printf("p_audio_start_play  original_speed:%.3f refSpeed:%.3f audio_frame_offset:%d l_samples:%d l_samplerate:%d (gvahand:%d) offset_start_samples:%d\n\n"
+      ,gpp->original_speed
+      ,l_referedClipSpeed
+      ,gpp->audio_frame_offset
+      ,l_samples
+      ,l_samplerate
+      ,gpp->gvahand->samplerate
+      ,offset_start_samples
+      );
+  }
+  
+  
+  if(l_referedClipSpeed > 0)
   {
     /* use moidfied samplerate if video is not played at original speed
      */
-    flt_samplerate = l_samplerate * gpp->speed / gpp->original_speed;
+    flt_samplerate = l_samplerate * gpp->speed / l_referedClipSpeed;
   }
   else
   {

Modified: trunk/gap/gap_story_main.h
==============================================================================
--- trunk/gap/gap_story_main.h	(original)
+++ trunk/gap/gap_story_main.h	Sun Oct  5 12:30:58 2008
@@ -187,6 +187,7 @@
   GtkWidget  *pw_flip_request_radio_button_arr[GAP_MAX_FLIP_REQUEST];
 
   /* for mask handling */
+  GtkWidget  *pw_mask_definition_name_label;
   gboolean   is_mask_definition;
   GtkWidget  *pw_mask_name_entry;
   GtkWidget  *pw_mask_enable_toggle;

Modified: trunk/gap/gap_story_properties.c
==============================================================================
--- trunk/gap/gap_story_properties.c	(original)
+++ trunk/gap/gap_story_properties.c	Sun Oct  5 12:30:58 2008
@@ -139,6 +139,8 @@
                        , GdkEvent  *event
                        , GapStbPropWidget *pw);
 static void     p_pw_check_ainfo_range(GapStbPropWidget *pw, char *filename);
+static gboolean p_pw_mask_definition_name_update(GapStbPropWidget *pw);
+static void     p_pw_mask_name_update_button_pressed_cb(GtkWidget *widget, GapStbPropWidget *pw);
 static void     p_pw_mask_name_entry_update_cb(GtkWidget *widget, GapStbPropWidget *pw);
 static void     p_pw_filename_entry_update_cb(GtkWidget *widget, GapStbPropWidget *pw);
 static void     p_pw_filename_changed(const char *filename, GapStbPropWidget *pw);
@@ -381,6 +383,14 @@
         pw->close_flag = TRUE;
         return;
       }
+      
+      if(FALSE == p_pw_mask_definition_name_update(pw))
+      {
+        /* occurs if a non-unique mask definition name was entered.
+         */
+        return;
+      }
+      
       if(pw->pw_filesel)
       {
         p_filesel_pw_close_cb(pw->pw_filesel, pw);
@@ -455,6 +465,9 @@
 /* ---------------------------------
  * p_pw_propagate_mask_name_changes
  * ---------------------------------
+ * this procedure is typically called to rename already existing
+ * mask_names of a mask definition property.
+ * In this case all references hav to be updated to use the new mask_name.
  */
 static void
 p_pw_propagate_mask_name_changes(GapStbPropWidget *pw
@@ -471,7 +484,7 @@
          gboolean updateOK;
          
          /* we have changed an already existing mask_name in a mask_definition
-          * element attributes.
+          * element attribute.
           * This requires update of all video track elements that are refering
           * to this mask definition.
           */
@@ -1683,6 +1696,116 @@
   p_pw_filename_changed(gtk_entry_get_text(GTK_ENTRY(widget)), pw);
 }  /* end p_pw_filename_entry_update_cb */
 
+/* ---------------------------------------
+ * p_pw_mask_definition_name_update
+ * ---------------------------------------
+ */
+static gboolean
+p_pw_mask_definition_name_update(GapStbPropWidget *pw)
+{
+  char *l_mask_name;
+  char *mask_name_old;
+  gboolean l_okFlag;
+
+  mask_name_old = NULL;
+  l_okFlag = TRUE;
+  
+  if (pw == NULL)
+  {
+    return (l_okFlag);
+  }
+  if (pw->pw_mask_name_entry == NULL)
+  {
+    return (l_okFlag);
+  }
+  
+  l_mask_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(pw->pw_mask_name_entry)));
+  if(l_mask_name)
+  {
+    if(pw->stb_elem_refptr)
+    {
+      gboolean is_check_required;
+      GapStoryElem      *stb_elem_ref;
+      
+      is_check_required = TRUE; /* in case a new name or different name was entered */
+      stb_elem_ref = NULL;
+      
+      if(pw->stb_elem_refptr->mask_name)
+      {
+          if(strcmp(pw->stb_elem_refptr->mask_name, l_mask_name) == 0)
+          {
+            /* NO check if we have still the same mask:name */
+            is_check_required = FALSE;
+          }
+      }
+      
+      if (is_check_required)
+      {
+        /* check if there are already references to mask_name_new */
+        stb_elem_ref = gap_story_find_mask_reference_by_name(pw->stb_refptr, l_mask_name);
+      }
+      
+      if(stb_elem_ref)
+      {
+        l_okFlag = FALSE;
+        g_message(_("Error: the mask name:  \"%s\" is already in use\n"
+                    "please enter another name.")
+                    ,l_mask_name
+                  );
+      
+      }
+      else
+      {
+        if(pw->stb_elem_refptr->mask_name)
+        {
+          if(strcmp(pw->stb_elem_refptr->mask_name, l_mask_name) != 0)
+          {
+             p_pw_push_undo_and_set_unsaved_changes(pw);
+
+             mask_name_old = g_strdup(pw->stb_elem_refptr->mask_name);
+             g_free(pw->stb_elem_refptr->mask_name);
+             pw->stb_elem_refptr->mask_name = g_strdup(l_mask_name);
+             p_pw_propagate_mask_name_changes(pw, mask_name_old);
+             p_pw_update_properties(pw);
+          }
+        }
+        else
+        {
+          p_pw_push_undo_and_set_unsaved_changes(pw);
+          pw->stb_elem_refptr->mask_name = g_strdup(l_mask_name);
+          p_pw_render_layermask(pw);
+        }
+        
+        gtk_label_set_text ( GTK_LABEL(pw->pw_mask_definition_name_label)
+                           , pw->stb_elem_refptr->mask_name);
+        
+      }
+
+    }
+    g_free(l_mask_name);
+  }
+  if(mask_name_old)
+  {
+    g_free(mask_name_old);
+  }
+  return (l_okFlag);
+}  /* end p_pw_mask_definition_name_update */
+
+/* ---------------------------------------
+ * p_pw_mask_name_update_button_pressed_cb
+ * ---------------------------------------
+ * in case of mask definition
+ * the update of mask_name is handled via button to confirm the change.
+ * (because automatic updates while typing the name in the entry may lead to
+ * unwanted changes in case the first few characters typed match another
+ * already existing mask_name)
+ */
+static void
+p_pw_mask_name_update_button_pressed_cb(GtkWidget *widget, GapStbPropWidget *pw)
+{
+  p_pw_mask_definition_name_update(pw);
+}  /* end p_pw_mask_name_update_button_pressed_cb */
+
 
 /* --------------------------------
  * p_pw_mask_name_entry_update_cb
@@ -1692,36 +1815,47 @@
 p_pw_mask_name_entry_update_cb(GtkWidget *widget, GapStbPropWidget *pw)
 {
   char *l_mask_name;
-  char *mask_name_old;
 
-  mask_name_old = NULL;
+  if(pw == NULL)
+  {
+    return;
+  }
+  if(pw->is_mask_definition)
+  {
+    /* ignore changes of the mask_name entry for mask definitions.
+     * (because automatic updates while typing the name in the entry may lead to
+     *  unwanted changes in case the first few characters typed do match another
+     *  already existing mask_name,
+     *  therfore the update is triggered explicitely via a button
+     *  see p_pw_mask_name_update_button_pressed_cb )
+     */
+    return;
+  }
+
   l_mask_name = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
-  if(pw->stb_elem_refptr)
+  if(l_mask_name)
   {
-    if(pw->stb_elem_refptr->mask_name)
+    if(pw->stb_elem_refptr)
     {
-      if(strcmp(pw->stb_elem_refptr->mask_name, l_mask_name) != 0)
+      if(pw->stb_elem_refptr->mask_name)
       {
-         p_pw_push_undo_and_set_unsaved_changes(pw);
+        if(strcmp(pw->stb_elem_refptr->mask_name, l_mask_name) != 0)
+        {
+           p_pw_push_undo_and_set_unsaved_changes(pw);
 
-         mask_name_old = g_strdup(pw->stb_elem_refptr->mask_name);
-         g_free(pw->stb_elem_refptr->mask_name);
-         pw->stb_elem_refptr->mask_name = g_strdup(l_mask_name);
-         p_pw_propagate_mask_name_changes(pw, mask_name_old);
-         p_pw_update_properties(pw);
+           g_free(pw->stb_elem_refptr->mask_name);
+           pw->stb_elem_refptr->mask_name = g_strdup(l_mask_name);
+           p_pw_update_properties(pw);
+        }
+      }
+      else
+      {
+        p_pw_push_undo_and_set_unsaved_changes(pw);
+        pw->stb_elem_refptr->mask_name = g_strdup(l_mask_name);
+        p_pw_render_layermask(pw);
       }
     }
-    else
-    {
-      p_pw_push_undo_and_set_unsaved_changes(pw);
-      pw->stb_elem_refptr->mask_name = g_strdup(l_mask_name);
-      p_pw_render_layermask(pw);
-    }
-  }
-  g_free(l_mask_name);
-  if(mask_name_old)
-  {
-    g_free(mask_name_old);
+    g_free(l_mask_name);
   }
 }  /* end p_pw_mask_name_entry_update_cb */
 
@@ -2134,7 +2268,7 @@
  * ---------------------------------
  * 1) update the info labels in the properties dialog window
  * 2) deferred update the storyboard table tabw in the master dialog window,
- *    where pw is atteched to.
+ *    where pw is attached to.
  *    (immediate reflect the change of properties in the corresponding table.)
  */
 static void
@@ -3605,11 +3739,26 @@
 
   row++;
 
-  /* the mask_name label */
-  label = gtk_label_new (_("Mask Name:"));
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach_defaults (GTK_TABLE(table), label, 0, 1, row, row+1);
-  gtk_widget_show (label);
+  if(pw->is_mask_definition)
+  {
+    GtkWidget *button;
+    /* the mask_name label */
+    button = gtk_button_new_with_label(_("Mask Name:"));
+    gimp_help_set_help_data(button, _("Set the mask name"), NULL);
+    gtk_table_attach_defaults (GTK_TABLE(table), button, 0, 1, row, row+1);
+    gtk_widget_show (button);
+    g_signal_connect(G_OBJECT(button), "clicked",
+                   G_CALLBACK(p_pw_mask_name_update_button_pressed_cb),
+                   pw);
+  }
+  else
+  {
+    /* the mask_name label */
+    label = gtk_label_new (_("Mask Name:"));
+    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+    gtk_table_attach_defaults (GTK_TABLE(table), label, 0, 1, row, row+1);
+    gtk_widget_show (label);
+  }
   
   /* the mask_name entry */
   entry = gtk_entry_new ();
@@ -3665,6 +3814,24 @@
                   G_CALLBACK (p_pw_mask_enable_toggle_update_callback),
                   pw);
 
+  /* the mask_definition_name label (only used for mask definition properties) */
+  label = gtk_label_new(" ");
+  pw->pw_mask_definition_name_label = label;
+  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+  if(pw->is_mask_definition)
+  {
+    if(pw->stb_elem_refptr)
+    {
+      if(pw->stb_elem_refptr->mask_name)
+      {
+        gtk_label_set_text ( GTK_LABEL(pw->pw_mask_definition_name_label)
+                           , pw->stb_elem_refptr->mask_name);
+      }
+    }
+    gtk_table_attach_defaults (GTK_TABLE(table), label, 2, 4, row, row+1);
+    gtk_widget_show (label);
+  }
+
 
   if(!pw->is_mask_definition)
   {

Modified: trunk/gap/gap_story_render_audio.c
==============================================================================
--- trunk/gap/gap_story_render_audio.c	(original)
+++ trunk/gap/gap_story_render_audio.c	Sun Oct  5 12:30:58 2008
@@ -859,7 +859,10 @@
   gdouble samples_to_skip;
 
 
-  if(gap_debug) printf("p_extract_audiopart: START\n");
+  if(gap_debug)
+  {
+    printf("p_extract_audiopart: START\n");
+  }
   
   l_audio_channels = gvahand->audio_cannels;
   l_sample_rate    = gvahand->samplerate;
@@ -896,7 +899,10 @@
                       , 16                          /* 16 bit sample resolution */
                       );
 
-      if(gap_debug) printf("samples_to_skip:%d\n", (int)samples_to_skip);
+      if(gap_debug)
+      {
+        printf("samples_to_skip:%d\n", (int)samples_to_skip);
+      }
       if(samples_to_skip > 0)
       {
         p_extract_audioblock(gvahand
@@ -907,7 +913,10 @@
 			    ,vidhand
 			    );
       }
-      if(gap_debug) printf("samples_to_extract:%d\n", (int)samples_to_extract);
+      if(gap_debug)
+      {
+        printf("samples_to_extract:%d\n", (int)samples_to_extract);
+      }
 
       p_extract_audioblock(gvahand
 	                  ,fp_wav      /* now write to file */
@@ -923,7 +932,10 @@
     }
   }
 
-  if(gap_debug) printf("p_extract_audiopart: END\n");
+  if(gap_debug)
+  {
+    printf("p_extract_audiopart: END\n");
+  }
 
 }  /* end p_extract_audiopart */
 
@@ -954,6 +966,7 @@
      {
        /* 1. element (or returned list) starts aud_list */
        vidhand->parsing_section->aud_list = aud_elem;
+       vidhand->aud_list = aud_elem;
      }
      else
      {
@@ -1006,8 +1019,8 @@
 		      ,GapStoryRenderVidHandle *vidhand  /* for progress */
                       )
 {
-  GapStoryRenderAudioRangeElem *aud_elem;
   GapStoryRenderAudioRangeElem *aud_known;
+  GapStoryRenderAudioRangeElem *aud_elem;
   gboolean l_audscan_required;
 
 
@@ -1083,7 +1096,14 @@
         return(NULL);
      }
 
-
+     if (known_aud_list == NULL)
+     {
+       if(gap_debug)
+       {
+         printf("gap_story_render_audio_new_audiorange_element: list of known audiofiles is empty (NULL)\n");
+       }
+     }
+     
      /* check the list for known audioranges
       * if audiofile is already known, we can skip the file scan
       * (that can save lot of time when the file must be converted or resampled)
@@ -1092,12 +1112,21 @@
      {
         if(aud_known->audiofile)
         {
-          if(gap_debug) printf("gap_story_render_audio_new_audiorange_element: check known audiofile:%s\n", aud_known->audiofile);
+          if(gap_debug)
+          {
+            printf("gap_story_render_audio_new_audiorange_element: check known audio_id:%d audiofile:%s\n"
+               , aud_elem->audio_id
+               , aud_known->audiofile
+               );
+          }
 
           if((strcmp(aud_elem->audiofile, aud_known->audiofile) == 0)
           && (aud_elem->aud_type == aud_type))
           {
-            if(gap_debug)  printf("gap_story_render_audio_new_audiorange_element: Range is already known audiofile:%s\n", aud_known->audiofile);
+            if(gap_debug)
+            {
+              printf("gap_story_render_audio_new_audiorange_element: Range is already known audiofile:%s\n", aud_known->audiofile);
+            }
             aud_elem->tmp_audiofile     = g_strdup(aud_known->tmp_audiofile);
             aud_elem->samplerate        = aud_known->samplerate;
             aud_elem->channels          = aud_known->channels;
@@ -1110,6 +1139,15 @@
             break;
           }
         }
+        else
+        {
+          if(gap_debug)
+          {
+            printf("gap_story_render_audio_new_audiorange_element: check known audio_id:%d audiofile: is NULL\n"
+              ,aud_elem->audio_id
+              );
+          }
+        }
      }
      if(l_audscan_required)
      {
@@ -1156,7 +1194,10 @@
 		       /* audio part of the video is OK, extract 1:1 as wavfile */
 		       aud_elem->tmp_audiofile = gimp_temp_name("tmp.wav");
 
-		       if(gap_debug) printf("Extracting Audiopart as file:%s\n", aud_elem->tmp_audiofile);
+		       if(gap_debug)
+                       {
+                         printf("Extracting Audiopart as file:%s\n", aud_elem->tmp_audiofile);
+                       }
 		       p_extract_audiopart(gvahand
 					  , aud_elem->tmp_audiofile
 					  , min_play_sec
@@ -1179,7 +1220,13 @@
 		       l_wavfilename = gimp_temp_name("tmp.wav");
 		       aud_elem->tmp_audiofile = gimp_temp_name("tmp.wav");
 
-		       if(gap_debug) printf("Resample Audiopart in file:%s outfile: %s\n", l_wavfilename, aud_elem->tmp_audiofile);
+		       if(gap_debug)
+                       {
+                         printf("Resample Audiopart in file:%s outfile: %s\n"
+                            , l_wavfilename
+                            , aud_elem->tmp_audiofile
+                            );
+                       }
 		       p_extract_audiopart(gvahand
 					  , l_wavfilename
 					  , min_play_sec
@@ -1198,6 +1245,13 @@
 		       /* fake some dummy progress */
 		       *vidhand->progress = 0.05;
 
+		       if(gap_debug)
+                       {
+                         printf("calling externeal Resample program: %s %s\n"
+                            , util_sox
+                            , util_sox_options
+                            );
+                       }
 		       gap_story_sox_exec_resample(l_wavfilename
 				       ,aud_elem->tmp_audiofile
 				       ,master_samplerate
@@ -1382,6 +1436,10 @@
                     l_errtxt = g_strdup_printf(_("cant use file:  %s as audioinput"), aud_elem->audiofile);
                     gap_story_render_set_stb_error(sterr, l_errtxt);
                     g_free(l_errtxt);
+                    if(gap_debug)
+                    {
+                      printf("gap_story_render_audio_new_audiorange_element CONVERSION FAILED.\n");
+                    }
                     return(NULL);
                   }
                }
@@ -1505,6 +1563,11 @@
   FILE   *l_fp;
   gboolean  l_retval;
 
+  if(gap_debug)
+  {
+    printf("gap_story_render_audio_create_composite_audiofile START comp_audiofile: %s\n"
+       , comp_audiofile);
+  }
   l_retval = FALSE;
   gap_story_render_audio_calculate_playtime(vidhand, &l_aud_total_sec);
 
@@ -1514,8 +1577,20 @@
   }
   *vidhand->progress = 0.0;
 
+  if(gap_debug)
+  {
+    printf("gap_story_render_audio_create_composite_audiofile CHECKING AUDIO PEAKS\n"
+       , comp_audiofile);
+  }
 
   p_check_audio_peaks(vidhand, l_aud_total_sec, &l_mix_scale);
+
+  if(gap_debug)
+  {
+    printf("gap_story_render_audio_create_composite_audiofile WRITE COMPOSITE AUDIO FILE\n"
+       , comp_audiofile);
+  }
+
   l_fp = g_fopen(comp_audiofile, "wb");
   if (l_fp)
   {
@@ -1540,13 +1615,24 @@
     p_mix_audio(l_fp, NULL, NULL, vidhand, l_aud_total_sec, &l_mix_scale);
 
     fclose(l_fp);
+    if(gap_debug)
+    {
+      printf("gap_story_render_audio_create_composite_audiofile COMPOSITE AUDIO FILE written OK file:%s\n"
+         , comp_audiofile);
+    }
     l_retval = TRUE;
   }
   else
   {
     char *l_errtext;
+
     l_errtext = g_strdup_printf(_("cant write audio to file: %s "), comp_audiofile);
     gap_story_render_set_stb_error(vidhand->sterr, l_errtext);
+
+    printf("gap_story_render_audio_create_composite_audiofile failed to write COMPOSITE AUDIO FILE file:%s\n  **ERROR: %s\n"
+         , comp_audiofile
+         , l_errtext
+         );
     g_free(l_errtext);
   }
 



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