diff options
author | John Stebbins <[email protected]> | 2016-02-20 18:00:46 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-03-09 13:10:10 -0700 |
commit | a44ccb49f182d4eeb122fbe675b28deb5c36b793 (patch) | |
tree | 6cc064cc24dacc2a80d41fb9543640c9004895af /libhb/cropscale.c | |
parent | 96c02dd6f256f4a4e74f8962f56502d28e5e65a3 (diff) |
filters: make job filter settings an hb_dict_t
This simplifies accessing and changing filter parameters
programatically. It also changes the custom filter string format to a
':' separated list of key/value pairs.
Diffstat (limited to 'libhb/cropscale.c')
-rw-r--r-- | libhb/cropscale.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/libhb/cropscale.c b/libhb/cropscale.c index 4c505ff20..63475990e 100644 --- a/libhb/cropscale.c +++ b/libhb/cropscale.c @@ -43,16 +43,22 @@ static hb_filter_info_t * hb_crop_scale_info( hb_filter_object_t * filter ); static void hb_crop_scale_close( hb_filter_object_t * filter ); +static const char crop_scale_template[] = + "width=^"HB_INT_REG"$:height=^"HB_INT_REG"$:" + "crop-top=^"HB_INT_REG"$:crop-bottom=^"HB_INT_REG"$:" + "crop-left=^"HB_INT_REG"$:crop-right=^"HB_INT_REG"$"; + hb_filter_object_t hb_filter_crop_scale = { - .id = HB_FILTER_CROP_SCALE, - .enforce_order = 1, - .name = "Crop and Scale", - .settings = NULL, - .init = hb_crop_scale_init, - .work = hb_crop_scale_work, - .close = hb_crop_scale_close, - .info = hb_crop_scale_info, + .id = HB_FILTER_CROP_SCALE, + .enforce_order = 1, + .name = "Crop and Scale", + .settings = NULL, + .init = hb_crop_scale_init, + .work = hb_crop_scale_work, + .close = hb_crop_scale_close, + .info = hb_crop_scale_info, + .settings_template = crop_scale_template, }; static int hb_crop_scale_init( hb_filter_object_t * filter, @@ -81,12 +87,13 @@ static int hb_crop_scale_init( hb_filter_object_t * filter, } memcpy( pv->crop, init->crop, sizeof( int[4] ) ); - if( filter->settings ) - { - sscanf( filter->settings, "%d:%d:%d:%d:%d:%d", - &pv->width_out, &pv->height_out, - &pv->crop[0], &pv->crop[1], &pv->crop[2], &pv->crop[3] ); - } + hb_dict_extract_int(&pv->width_out, filter->settings, "width"); + hb_dict_extract_int(&pv->height_out, filter->settings, "height"); + hb_dict_extract_int(&pv->crop[0], filter->settings, "crop-top"); + hb_dict_extract_int(&pv->crop[1], filter->settings, "crop-bottom"); + hb_dict_extract_int(&pv->crop[2], filter->settings, "crop-left"); + hb_dict_extract_int(&pv->crop[3], filter->settings, "crop-right"); + // Set init values so the next stage in the pipline // knows what it will be getting init->pix_fmt = pv->pix_fmt; |