summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libhb/common.h11
-rw-r--r--libhb/rendersub.c22
-rw-r--r--libhb/work.c48
3 files changed, 51 insertions, 30 deletions
diff --git a/libhb/common.h b/libhb/common.h
index 0478d2b5d..4a55a6f8a 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -1148,13 +1148,14 @@ struct hb_filter_object_s
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;
diff --git a/libhb/rendersub.c b/libhb/rendersub.c
index ac05f635a..6dabf39a7 100644
--- a/libhb/rendersub.c
+++ b/libhb/rendersub.c
@@ -75,6 +75,8 @@ static void pgssub_close( hb_filter_object_t * filter );
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 );
@@ -88,6 +90,7 @@ hb_filter_object_t hb_filter_render_sub =
.name = "Subtitle renderer",
.settings = NULL,
.init = hb_rendersub_init,
+ .post_init = hb_rendersub_post_init,
.work = hb_rendersub_work,
.close = hb_rendersub_close,
};
@@ -826,13 +829,14 @@ static int pgssub_work( hb_filter_object_t * filter,
}
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",
@@ -893,6 +897,22 @@ static int hb_rendersub_init( hb_filter_object_t * filter,
}
}
+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 )
diff --git a/libhb/work.c b/libhb/work.c
index 607658e70..39cd6829c 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -679,30 +679,13 @@ static void do_job(hb_job_t *job)
}
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);
}
}
@@ -900,6 +883,23 @@ static void do_job(hb_job_t *job)
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
{