OSDN Git Service

Maintains separate filter settings for each job. This prevents the MacGui from using...
authorjbrjake <jbrjake@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 22 Jan 2008 19:53:33 +0000 (19:53 +0000)
committerjbrjake <jbrjake@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 22 Jan 2008 19:53:33 +0000 (19:53 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@1228 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
libhb/hb.c
libhb/internal.h
libhb/render.c
libhb/work.c

index 39e6140..b23f42d 100644 (file)
@@ -613,3 +613,23 @@ void hb_title_close( hb_title_t ** _t )
     *_t = NULL;
 }
 
+/**********************************************************************
+ * hb_filter_close
+ **********************************************************************
+ * 
+ *********************************************************************/
+void hb_filter_close( hb_filter_object_t ** _f )
+{
+    hb_filter_object_t * f = *_f;
+
+    f->close( f->private_data );
+
+    if( f->name )
+        free( f->name );
+    if( f->settings )
+        free( f->settings );
+
+    free( f );
+    *_f = NULL;
+}
+
index 6c2e503..9f1b6be 100644 (file)
@@ -935,8 +935,22 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
         job_copy->filters = hb_list_init();        
         for( i = 0; i < filter_count; i++ )
         {
+            /*
+             * Copy the filters, since the MacGui reuses the global filter objects
+             * meaning that queued up jobs overwrite the previous filter settings.
+             * In reality, settings is probably the only field that needs duplicating
+             * since it's the only value that is ever changed. But name is duplicated
+             * as well for completeness. Not copying private_data since it gets
+             * created for each job in renderInit.
+             */
             hb_filter_object_t * filter = hb_list_item( job->filters, i );
-            hb_list_add( job_copy->filters, filter );
+            hb_filter_object_t * filter_copy = malloc( sizeof( hb_filter_object_t ) );
+            memcpy( filter_copy, filter, sizeof( hb_filter_object_t ) );
+            if( filter->name )
+                filter_copy->name = strdup( filter->name );
+            if( filter->settings )
+                filter_copy->settings = strdup( filter->settings );
+            hb_list_add( job_copy->filters, filter_copy );
         }        
     }
     
index e4d5bee..3a4e86a 100644 (file)
@@ -19,6 +19,8 @@ void hb_list_empty( hb_list_t ** );
 hb_title_t * hb_title_init( char * dvd, int index );
 void         hb_title_close( hb_title_t ** );
 
+void         hb_filter_close( hb_filter_object_t ** );
+
 /***********************************************************************
  * hb.c
  **********************************************************************/
index 4253a92..3a0a025 100644 (file)
@@ -447,25 +447,6 @@ void renderClose( hb_work_object_t * w )
         hb_fifo_close( &pv->delay_queue );
     }
    
-    /* Cleanup filters */
-    /* TODO: Move to work.c? */
-    if( pv->job->filters )
-    {
-        int filter_count = hb_list_count( pv->job->filters );
-        int i;
-        
-        for( i = 0; i < filter_count; i++ )
-        {
-            hb_filter_object_t * filter = hb_list_item( pv->job->filters, i );
-            
-            if( !filter ) continue;
-
-            filter->close( filter->private_data );
-        }
-        
-        hb_list_close( &pv->job->filters );
-    }    
-   
     /* Cleanup render work structure */
     free( pv );
     w->private_data = NULL;    
index e1d342f..2f7bed9 100644 (file)
@@ -178,7 +178,19 @@ static void do_job( hb_job_t * job, int cpu_count )
         }
         
         if (!detelecine_present)
-            hb_list_add( job->filters, &hb_filter_detelecine );
+        {
+            /* Allocate the filter. */
+            hb_filter_object_t * filter =  malloc( sizeof( hb_filter_object_t ) );
+            
+            /* Copy in the contents of the detelecine struct. */
+            memcpy( filter, &hb_filter_detelecine, sizeof( hb_filter_object_t ) );
+
+            /* Set the name to a copy of the template name so render.c has something to free. */
+            filter->name = strdup(hb_filter_detelecine.name);
+            
+            /* Add it to the list. */
+            hb_list_add( job->filters, filter );
+        }
         
         hb_log("work: VFR mode -- Switching FPS to 29.97 and detelecining.");
     }
@@ -728,6 +740,16 @@ static void do_job( hb_job_t * job, int cpu_count )
         }
     }
 
+    if( job->filters )
+    {
+        for( i = 0; i < hb_list_count( job->filters ); i++ )
+        {
+            hb_filter_object_t * filter = hb_list_item( job->filters, i );
+            hb_filter_close( &filter );
+        }
+        hb_list_close( &job->filters );
+    }    
+
     hb_buffer_pool_free();
 
     hb_title_close( &job->title );