summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2012-03-27 20:11:26 +0000
committerjstebbins <[email protected]>2012-03-27 20:11:26 +0000
commit45b8f81a2e184e2b7deaf47afc49483766191a27 (patch)
tree30ed0892995cb4ad3255909f69269c453000800a /macosx
parent7eb7737023be00fa0dc9be75a4984b80c0e5ce57 (diff)
Rework filter pipeline
This patch enhances the filter objects. The 2 key improvements are: 1. A filter can change the image dimensions as frames pass through it. 2. A filter can output more than one frame. In addition, I have: Moved cropping & scalling into a filter object Added 90 degree rotation to the rotate filter Moved subtitle burn-in rendering to a filter object. Moved VFR/CFR handling into a framerate shaping filter object. Removed render.c since all it's responsibilities got moved to filters. Improves VOBSUB and SSA subtitle handling. Allows subtitle animations. SSA karaoke support. My apologies in advance if anything breaks ;) git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4546 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r--macosx/Controller.m145
-rw-r--r--macosx/HBPreviewController.m2
2 files changed, 86 insertions, 61 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m
index f0d58f9a9..69168b376 100644
--- a/macosx/Controller.m
+++ b/macosx/Controller.m
@@ -2747,6 +2747,8 @@ fWorkingCount = 0;
hb_add( fQueueEncodeLibhb, job );
}
+ hb_free_filters( job );
+
NSString *destinationDirectory = [[queueToApply objectForKey:@"DestinationPath"] stringByDeletingLastPathComponent];
[[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
/* Lets mark our new encode as 1 or "Encoding" */
@@ -3278,6 +3280,11 @@ bool one_burned = FALSE;
}
i++;
}
+ if( one_burned )
+ {
+ filter = hb_filter_init( HB_FILTER_RENDER_SUB );
+ hb_add_filter( job, filter, NULL );
+ }
@@ -3337,25 +3344,23 @@ bool one_burned = FALSE;
job->grayscale = 0;
}
- /* Initialize the filters list */
- job->filters = hb_list_init();
-
/* Now lets call the filters if applicable.
* The order of the filters is critical
*/
+ hb_filter_object_t * filter;
/* Detelecine */
hb_filter_detelecine.settings = NULL;
+ filter = hb_filter_init( HB_FILTER_DETELECINE );
if ([fPictureController detelecine] == 1)
{
/* use a custom detelecine string */
- hb_filter_detelecine.settings = (char *) [[fPictureController detelecineCustomString] UTF8String];
- hb_list_add( job->filters, &hb_filter_detelecine );
+ hb_add_filter( job, filter, [[fPictureController detelecineCustomString] UTF8String] );
}
if ([fPictureController detelecine] == 2)
{
/* Default */
- hb_list_add( job->filters, &hb_filter_detelecine );
+ hb_add_filter( job, filter, NULL );
}
@@ -3363,77 +3368,69 @@ bool one_burned = FALSE;
if ([fPictureController useDecomb] == 1)
{
/* Decomb */
+ filter = hb_filter_init( HB_FILTER_DECOMB );
if ([fPictureController decomb] == 1)
{
/* use a custom decomb string */
- hb_filter_decomb.settings = (char *) [[fPictureController decombCustomString] UTF8String];
- hb_list_add( job->filters, &hb_filter_decomb );
+ hb_add_filter( job, filter, [[fPictureController decombCustomString] UTF8String] );
}
if ([fPictureController decomb] == 2)
{
/* use libhb defaults */
- hb_filter_decomb.settings = NULL;
- hb_list_add( job->filters, &hb_filter_decomb );
+ hb_add_filter( job, filter, NULL );
}
if ([fPictureController decomb] == 3)
{
/* use old defaults (decomb fast) */
- hb_filter_decomb.settings = "7:2:6:9:1:80";
- hb_list_add( job->filters, &hb_filter_decomb );
+ hb_add_filter( job, filter, "7:2:6:9:1:80" );
}
}
else
{
/* Deinterlace */
+ filter = hb_filter_init( HB_FILTER_DEINTERLACE );
if ([fPictureController deinterlace] == 1)
{
/* we add the custom string if present */
- hb_filter_deinterlace.settings = (char *) [[fPictureController deinterlaceCustomString] UTF8String];
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, [[fPictureController deinterlaceCustomString] UTF8String] );
}
else if ([fPictureController deinterlace] == 2)
{
/* Run old deinterlacer fd by default */
- hb_filter_deinterlace.settings = "-1";
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, "-1" );
}
else if ([fPictureController deinterlace] == 3)
{
/* Yadif mode 0 (without spatial deinterlacing.) */
- hb_filter_deinterlace.settings = "2";
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, "2" );
}
else if ([fPictureController deinterlace] == 4)
{
/* Yadif (with spatial deinterlacing) */
- hb_filter_deinterlace.settings = "0";
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, "0" );
}
}
/* Denoise */
+ filter = hb_filter_init( HB_FILTER_DENOISE );
if ([fPictureController denoise] == 1) // custom in popup
{
/* we add the custom string if present */
- hb_filter_denoise.settings = (char *) [[fPictureController denoiseCustomString] UTF8String];
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, [[fPictureController denoiseCustomString] UTF8String] );
}
else if ([fPictureController denoise] == 2) // Weak in popup
{
- hb_filter_denoise.settings = "2:1:2:3";
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, "2:1:2:3" );
}
else if ([fPictureController denoise] == 3) // Medium in popup
{
- hb_filter_denoise.settings = "3:2:2:3";
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, "3:2:2:3" );
}
else if ([fPictureController denoise] == 4) // Strong in popup
{
- hb_filter_denoise.settings = "7:7:5:5";
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, "7:7:5:5" );
}
@@ -3442,13 +3439,28 @@ bool one_burned = FALSE;
* the macgui's purposes a value of 0 actually means to not even use the filter
* current hb_filter_deblock.settings valid ranges are from 5 - 15
*/
+ filter = hb_filter_init( HB_FILTER_DEBLOCK );
if ([fPictureController deblock] != 0)
{
NSString *deblockStringValue = [NSString stringWithFormat: @"%d",[fPictureController deblock]];
- hb_filter_deblock.settings = (char *) [deblockStringValue UTF8String];
- hb_list_add( job->filters, &hb_filter_deblock );
+ hb_add_filter( job, filter, [deblockStringValue UTF8String] );
}
+ /* Add Crop/Scale filter */
+ char * filter_str;
+ filter_str = hb_strdup_printf("%d:%d:%d:%d:%d:%d",
+ job->width, job->height,
+ job->crop[0], job->crop[1], job->crop[2], job->crop[3] );
+ filter = hb_filter_init( HB_FILTER_CROP_SCALE );
+ hb_add_filter( job, filter, filter_str );
+ free( filter_str );
+
+ // Add framerate shaping filter
+ filter_str = hb_strdup_printf("%d:%d:%d",
+ job->cfr, job->vrate, job->vrate_base );
+ filter = hb_filter_init( HB_FILTER_VFR );
+ hb_add_filter( job, filter, filter_str );
+ free( filter_str );
}
@@ -3817,6 +3829,11 @@ bool one_burned = FALSE;
}
i++;
}
+ if( one_burned )
+ {
+ filter = hb_filter_init( HB_FILTER_RENDER_SUB );
+ hb_add_filter( job, filter, NULL );
+ }
#pragma mark -
@@ -3875,46 +3892,41 @@ bool one_burned = FALSE;
}
}
- /* Filters */
- job->filters = hb_list_init();
-
+ hb_filter_object_t * filter;
/* Now lets call the filters if applicable.
* The order of the filters is critical
*/
/* Detelecine */
- hb_filter_detelecine.settings = NULL;
+ filter = hb_filter_init( HB_FILTER_DETELECINE );
if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 1)
{
/* use a custom detelecine string */
- hb_filter_detelecine.settings = (char *) [[queueToApply objectForKey:@"PictureDetelecineCustom"] UTF8String];
- hb_list_add( job->filters, &hb_filter_detelecine );
+ hb_add_filter( job, filter, [[queueToApply objectForKey:@"PictureDetelecineCustom"] UTF8String] );
}
if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 2)
{
/* Use libhb's default values */
- hb_list_add( job->filters, &hb_filter_detelecine );
+ hb_add_filter( job, filter, NULL );
}
if ([[queueToApply objectForKey:@"PictureDecombDeinterlace"] intValue] == 1)
{
/* Decomb */
+ filter = hb_filter_init( HB_FILTER_DECOMB );
if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 1)
{
/* use a custom decomb string */
- hb_filter_decomb.settings = (char *) [[queueToApply objectForKey:@"PictureDecombCustom"] UTF8String];
- hb_list_add( job->filters, &hb_filter_decomb );
+ hb_add_filter( job, filter, [[queueToApply objectForKey:@"PictureDecombCustom"] UTF8String] );
}
if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 2)
{
/* use libhb defaults */
- hb_filter_decomb.settings = NULL;
- hb_list_add( job->filters, &hb_filter_decomb );
+ hb_add_filter( job, filter, NULL );
}
if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 3)
{
/* use old defaults (decomb fast) */
- hb_filter_decomb.settings = "7:2:6:9:1:80";
- hb_list_add( job->filters, &hb_filter_decomb );
+ hb_add_filter( job, filter, "7:2:6:9:1:80" );
}
}
@@ -3922,54 +3934,48 @@ bool one_burned = FALSE;
{
/* Deinterlace */
+ filter = hb_filter_init( HB_FILTER_DEINTERLACE );
if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 1)
{
/* we add the custom string if present */
- hb_filter_deinterlace.settings = (char *) [[queueToApply objectForKey:@"PictureDeinterlaceCustom"] UTF8String];
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, [[queueToApply objectForKey:@"PictureDeinterlaceCustom"] UTF8String] );
}
else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 2)
{
/* Run old deinterlacer fd by default */
- hb_filter_deinterlace.settings = "-1";
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, "-1" );
}
else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 3)
{
/* Yadif mode 0 (without spatial deinterlacing.) */
- hb_filter_deinterlace.settings = "2";
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, "2" );
}
else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 4)
{
/* Yadif (with spatial deinterlacing) */
- hb_filter_deinterlace.settings = "0";
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ hb_add_filter( job, filter, "0" );
}
}
/* Denoise */
+ filter = hb_filter_init( HB_FILTER_DENOISE );
if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 1) // Custom in popup
{
/* we add the custom string if present */
- hb_filter_denoise.settings = (char *) [[queueToApply objectForKey:@"PictureDenoiseCustom"] UTF8String];
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, [[queueToApply objectForKey:@"PictureDenoiseCustom"] UTF8String] );
}
else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 2) // Weak in popup
{
- hb_filter_denoise.settings = "2:1:2:3";
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, "2:1:2:3" );
}
else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 3) // Medium in popup
{
- hb_filter_denoise.settings = "3:2:2:3";
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, "3:2:2:3" );
}
else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 4) // Strong in popup
{
- hb_filter_denoise.settings = "7:7:5:5";
- hb_list_add( job->filters, &hb_filter_denoise );
+ hb_add_filter( job, filter, "7:7:5:5" );
}
@@ -3978,11 +3984,28 @@ bool one_burned = FALSE;
* the macgui's purposes a value of 0 actually means to not even use the filter
* current hb_filter_deblock.settings valid ranges are from 5 - 15
*/
+ filter = hb_filter_init( HB_FILTER_DEBLOCK );
if ([[queueToApply objectForKey:@"PictureDeblock"] intValue] != 0)
{
- hb_filter_deblock.settings = (char *) [[queueToApply objectForKey:@"PictureDeblock"] UTF8String];
- hb_list_add( job->filters, &hb_filter_deblock );
+ hb_add_filter( job, filter, [[queueToApply objectForKey:@"PictureDeblock"] UTF8String] );
}
+
+ /* Add Crop/Scale filter */
+ char * filter_str;
+ filter_str = hb_strdup_printf("%d:%d:%d:%d:%d:%d",
+ job->width, job->height,
+ job->crop[0], job->crop[1], job->crop[2], job->crop[3] );
+ filter = hb_filter_init( HB_FILTER_CROP_SCALE );
+ hb_add_filter( job, filter, filter_str );
+ free( filter_str );
+
+ // Add framerate shaping filter
+ filter_str = hb_strdup_printf("%d:%d:%d",
+ job->cfr, job->vrate, job->vrate_base );
+ filter = hb_filter_init( HB_FILTER_VFR );
+ hb_add_filter( job, filter, filter_str );
+ free( filter_str );
+
[self writeToActivityLog: "prepareJob exiting"];
}
diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m
index 4d0826b1d..dd2cb6ec4 100644
--- a/macosx/HBPreviewController.m
+++ b/macosx/HBPreviewController.m
@@ -906,6 +906,8 @@
job->pass = 0;
hb_add( fPreviewLibhb, job );
+ hb_free_filters( job );
+
[fEncodingControlBox setHidden: NO];
[fPictureControlBox setHidden: YES];