This requires the addition of a filter->post_init function to inform
filters of the final job configuration after all filters have been
initialized. Rendersub needs to know cropping, but cropping isn't known
till after crop_scale filter is initialized. Since crop_scale is initialized
*after* rendersub is initialized, post_init is needed. Currently, rendersub
is the only filter that defines post_init.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6830
b64f7644-9d1e-0410-96f1-
a4d463321fa5
char * settings;
#ifdef __LIBHB__
- int (* init) ( hb_filter_object_t *, hb_filter_init_t * );
+ int (* init) ( hb_filter_object_t *, hb_filter_init_t * );
+ int (* post_init) ( hb_filter_object_t *, hb_job_t * );
- int (* work) ( hb_filter_object_t *,
- hb_buffer_t **, hb_buffer_t ** );
+ int (* work) ( hb_filter_object_t *,
+ hb_buffer_t **, hb_buffer_t ** );
- void (* close) ( hb_filter_object_t * );
- int (* info) ( hb_filter_object_t *, hb_filter_info_t * );
+ void (* close) ( hb_filter_object_t * );
+ int (* info) ( hb_filter_object_t *, hb_filter_info_t * );
hb_fifo_t * fifo_in;
hb_fifo_t * fifo_out;
static int hb_rendersub_init( hb_filter_object_t * filter,
hb_filter_init_t * init );
+static int hb_rendersub_post_init( hb_filter_object_t * filter, hb_job_t *job );
+
static int hb_rendersub_work( hb_filter_object_t * filter,
hb_buffer_t ** buf_in,
hb_buffer_t ** buf_out );
.name = "Subtitle renderer",
.settings = NULL,
.init = hb_rendersub_init,
+ .post_init = hb_rendersub_post_init,
.work = hb_rendersub_work,
.close = hb_rendersub_close,
};
}
static int hb_rendersub_init( hb_filter_object_t * filter,
- hb_filter_init_t * init )
+ hb_filter_init_t * init )
{
filter->private_data = calloc( 1, sizeof(struct hb_filter_private_s) );
hb_filter_private_t * pv = filter->private_data;
hb_subtitle_t *subtitle;
int ii;
+ pv->crop[0] = pv->crop[1] = pv->crop[2] = pv->crop[3] = -1;
if( filter->settings )
{
sscanf( filter->settings, "%d:%d:%d:%d",
}
}
+static int hb_rendersub_post_init( hb_filter_object_t * filter, hb_job_t *job )
+{
+ hb_filter_private_t * pv = filter->private_data;
+
+ if (pv->crop[0] == -1)
+ pv->crop[0] = job->crop[0];
+ if (pv->crop[1] == -1)
+ pv->crop[1] = job->crop[1];
+ if (pv->crop[2] == -1)
+ pv->crop[2] = job->crop[2];
+ if (pv->crop[3] == -1)
+ pv->crop[3] = job->crop[3];
+
+ return 0;
+}
+
static int hb_rendersub_work( hb_filter_object_t * filter,
hb_buffer_t ** buf_in,
hb_buffer_t ** buf_out )
}
if (one_burned)
{
- int found = 0;
- // Check that the HB_FILTER_RENDER_SUB is in the filter chain.
- // We can not add it automatically because it needs crop
- // values which only the frontend knows.
- if (job->list_filter != NULL)
- {
- int ii;
- for (ii = 0; ii < hb_list_count(job->list_filter); ii++)
- {
- hb_filter_object_t *filter;
- filter = hb_list_item(job->list_filter, ii);
- if (filter->id == HB_FILTER_RENDER_SUB)
- {
- found = 1;
- break;
- }
- }
- }
- if (!found)
- {
- // If this happens, it is a programming error that
- // needs to be fixed in the frontend
- hb_error("Subtitle burned, but no rendering filter");
- }
+ // Add subtitle rendering filter
+ // Note that if the filter is already in the filter chain, this
+ // has no effect. Note also that this means the front-end is
+ // not required to add the subtitle rendering filter since
+ // we will always try to do it here.
+ hb_filter_object_t *filter = hb_filter_init(HB_FILTER_RENDER_SUB);
+ hb_add_filter(job, filter, NULL);
}
}
memcpy(job->crop, init.crop, sizeof(int[4]));
job->vrate = init.vrate;
job->cfr = init.cfr;
+
+ // Perform filter post_init which informs filters of final
+ // job configuration. e.g. rendersub filter needs to know the
+ // final crop dimensions.
+ for( i = 0; i < hb_list_count( job->list_filter ); )
+ {
+ hb_filter_object_t * filter = hb_list_item( job->list_filter, i );
+ if (filter->post_init != NULL && filter->post_init(filter, job))
+ {
+ hb_log( "Failure to initialise filter '%s', disabling",
+ filter->name );
+ hb_list_rem( job->list_filter, filter );
+ hb_filter_close( &filter );
+ continue;
+ }
+ i++;
+ }
}
else
{