summaryrefslogtreecommitdiffstats
path: root/test/test.c
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 /test/test.c
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 'test/test.c')
-rw-r--r--test/test.c98
1 files changed, 66 insertions, 32 deletions
diff --git a/test/test.c b/test/test.c
index b600577d3..411c0adc6 100644
--- a/test/test.c
+++ b/test/test.c
@@ -61,6 +61,7 @@ static int decomb = 0;
static char * decomb_opt = 0;
static int rotate = 0;
static char * rotate_opt = 0;
+static int rotate_val = 0;
static int grayscale = 0;
static int vcodec = HB_VCODEC_FFMPEG_MPEG4;
static hb_list_t * audios = NULL;
@@ -1343,44 +1344,50 @@ static int HandleEvents( hb_handle_t * h )
job->deinterlace = deinterlace;
job->grayscale = grayscale;
+ hb_filter_object_t * filter;
+
/* Add selected filters */
- job->filters = hb_list_init();
-
- if( rotate )
- {
- hb_filter_rotate.settings = rotate_opt;
- hb_list_add( job->filters, &hb_filter_rotate);
- }
if( detelecine )
{
- hb_filter_detelecine.settings = detelecine_opt;
- hb_list_add( job->filters, &hb_filter_detelecine );
+ filter = hb_filter_init( HB_FILTER_DETELECINE );
+ hb_add_filter( job, filter, detelecine_opt );
}
if( decomb )
{
- hb_filter_decomb.settings = decomb_opt;
- hb_list_add( job->filters, &hb_filter_decomb );
+ filter = hb_filter_init( HB_FILTER_DECOMB );
+ hb_add_filter( job, filter, decomb_opt );
}
if( deinterlace )
{
- hb_filter_deinterlace.settings = deinterlace_opt;
- hb_list_add( job->filters, &hb_filter_deinterlace );
+ filter = hb_filter_init( HB_FILTER_DEINTERLACE );
+ hb_add_filter( job, filter, deinterlace_opt );
}
if( deblock )
{
- hb_filter_deblock.settings = deblock_opt;
- hb_list_add( job->filters, &hb_filter_deblock );
+ filter = hb_filter_init( HB_FILTER_DEBLOCK );
+ hb_add_filter( job, filter, deblock_opt );
}
if( denoise )
{
- hb_filter_denoise.settings = denoise_opt;
- hb_list_add( job->filters, &hb_filter_denoise );
+ filter = hb_filter_init( HB_FILTER_DENOISE );
+ hb_add_filter( job, filter, denoise_opt );
+ }
+ if( rotate )
+ {
+ filter = hb_filter_init( HB_FILTER_ROTATE );
+ hb_add_filter( job, filter, rotate_opt);
}
+
+ if (maxWidth)
+ job->maxWidth = maxWidth;
+ if (maxHeight)
+ job->maxHeight = maxHeight;
+
switch( anamorphic_mode )
{
case 0: // Non-anamorphic
-
+
if (modulus)
{
job->modulus = modulus;
@@ -1540,6 +1547,38 @@ static int HandleEvents( hb_handle_t * h )
break;
}
+ // Validate and adjust job picture dimensions
+ hb_validate_size( job );
+
+ // Add filter that does cropping and scaling
+ 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
+ if( vrate )
+ {
+ job->cfr = cfr;
+ job->vrate = 27000000;
+ job->vrate_base = vrate;
+ }
+ else if ( cfr )
+ {
+ // cfr or pfr flag with no rate specified implies
+ // use the title rate.
+ job->cfr = cfr;
+ job->vrate = title->rate;
+ job->vrate_base = title->rate_base;
+ }
+ 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 );
if( vquality >= 0.0 )
{
@@ -1555,20 +1594,6 @@ static int HandleEvents( hb_handle_t * h )
{
job->vcodec = vcodec;
}
- if( vrate )
- {
- job->cfr = cfr;
- job->vrate = 27000000;
- job->vrate_base = vrate;
- }
- else if ( cfr )
- {
- // cfr or pfr flag with no rate specified implies
- // use the title rate.
- job->cfr = cfr;
- job->vrate = title->rate;
- job->vrate_base = title->rate_base;
- }
/* Grab audio tracks */
if( atracks )
@@ -2235,6 +2260,12 @@ static int HandleEvents( hb_handle_t * h )
}
}
+ if ( sub_burned )
+ {
+ filter = hb_filter_init( HB_FILTER_RENDER_SUB );
+ hb_add_filter( job, filter, NULL);
+ }
+
if( srtfile )
{
char * token;
@@ -2377,6 +2408,7 @@ static int HandleEvents( hb_handle_t * h )
{
job->advanced_opts = NULL;
}
+
job->x264_profile = x264_profile;
job->x264_preset = x264_preset;
job->x264_tune = x264_tune;
@@ -2514,6 +2546,7 @@ static int HandleEvents( hb_handle_t * h )
job->pass = 0;
hb_add( h, job );
}
+ hb_reset_job( job );
hb_start( h );
break;
}
@@ -3507,6 +3540,7 @@ static int ParseOptions( int argc, char ** argv )
if( optarg != NULL )
{
rotate_opt = strdup( optarg );
+ rotate_val = atoi( optarg );
}
rotate = 1;
break;