summaryrefslogtreecommitdiffstats
path: root/libhb/common.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2017-05-31 10:21:53 -0700
committerBradley Sepos <[email protected]>2017-06-06 11:42:09 -0400
commit021b3caa6efbfadb212bb1e686c2de08da6df2c6 (patch)
tree5b972504671f6bb1c19f99ad36a477f50dbe7cba /libhb/common.c
parentc365e557920c8911e638534b5fa5cc59487834a7 (diff)
filter: add frame parallelizing filter wrapper
This wrapper can be used to frame parallelize simple video filters. By simple, I mean there can be no temporal context that is shared from one frame to the next. Wrap unsharp and lapsharp filters. unsharp required a small rework to separate out temporary storage that is required when processing each frame. We now need to duplicate this storage for each thread. Closes #759.
Diffstat (limited to 'libhb/common.c')
-rw-r--r--libhb/common.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/libhb/common.c b/libhb/common.c
index 71a8d0e26..ebe51c6e5 100644
--- a/libhb/common.c
+++ b/libhb/common.c
@@ -3861,6 +3861,7 @@ hb_filter_object_t * hb_filter_copy( hb_filter_object_t * filter )
memcpy( filter_copy, filter, sizeof( hb_filter_object_t ) );
if( filter->settings )
filter_copy->settings = hb_value_dup(filter->settings);
+ filter_copy->sub_filter = hb_filter_copy(filter->sub_filter);
return filter_copy;
}
@@ -3997,6 +3998,10 @@ hb_filter_object_t * hb_filter_get( int filter_id )
break;
#endif
+ case HB_FILTER_MT_FRAME:
+ filter = &hb_filter_mt_frame;
+ break;
+
default:
filter = NULL;
break;
@@ -4006,7 +4011,23 @@ hb_filter_object_t * hb_filter_get( int filter_id )
hb_filter_object_t * hb_filter_init( int filter_id )
{
- return hb_filter_copy(hb_filter_get(filter_id));
+ switch (filter_id)
+ {
+ case HB_FILTER_UNSHARP:
+ case HB_FILTER_LAPSHARP:
+ {
+ hb_filter_object_t * wrapper;
+
+ wrapper = hb_filter_copy(hb_filter_get(HB_FILTER_MT_FRAME));
+ wrapper->sub_filter = hb_filter_copy(hb_filter_get(filter_id));
+ wrapper->id = filter_id;
+ wrapper->name = wrapper->sub_filter->name;
+ return wrapper;
+ } break;
+
+ default:
+ return hb_filter_copy(hb_filter_get(filter_id));
+ }
}
/**********************************************************************
@@ -4018,6 +4039,11 @@ void hb_filter_close( hb_filter_object_t ** _f )
{
hb_filter_object_t * f = *_f;
+ if (f == NULL)
+ {
+ return;
+ }
+ hb_filter_close(&f->sub_filter);
hb_value_free(&f->settings);
free( f );