CropScale Settings * mode:parity * * width - scale width * height - scale height * crop-top - top crop margin * crop-bottom - bottom crop margin * crop-left - left crop margin * crop-right - right crop margin * */
| 49 | * |
| 50 | */ |
| 51 | static int crop_scale_init(hb_filter_object_t * filter, hb_filter_init_t * init) |
| 52 | { |
| 53 | hb_filter_private_t * pv = NULL; |
| 54 | |
| 55 | pv = calloc(1, sizeof(struct hb_filter_private_s)); |
| 56 | filter->private_data = pv; |
| 57 | if (pv == NULL) |
| 58 | { |
| 59 | return 1; |
| 60 | } |
| 61 | pv->input = *init; |
| 62 | |
| 63 | hb_dict_t * settings = filter->settings; |
| 64 | hb_value_array_t * avfilters = hb_value_array_init(); |
| 65 | int width, height; |
| 66 | int cropped_width, cropped_height; |
| 67 | int top = 0, bottom = 0, left = 0, right = 0; |
| 68 | |
| 69 | // Convert crop settings to 'crop' avfilter |
| 70 | hb_dict_extract_int(&top, settings, "crop-top"); |
| 71 | hb_dict_extract_int(&bottom, settings, "crop-bottom"); |
| 72 | hb_dict_extract_int(&left, settings, "crop-left"); |
| 73 | hb_dict_extract_int(&right, settings, "crop-right"); |
| 74 | cropped_width = init->geometry.width - left - right; |
| 75 | cropped_height = init->geometry.height - top - bottom; |
| 76 | if (top > 0 || bottom > 0 || left > 0 || right > 0) |
| 77 | { |
| 78 | hb_dict_t * avfilter = hb_dict_init(); |
| 79 | hb_dict_t * avsettings = hb_dict_init(); |
| 80 | |
| 81 | hb_dict_set_int(avsettings, "x", left); |
| 82 | hb_dict_set_int(avsettings, "y", top); |
| 83 | hb_dict_set_int(avsettings, "w", cropped_width); |
| 84 | hb_dict_set_int(avsettings, "h", cropped_height); |
| 85 | hb_dict_set(avfilter, "crop", avsettings); |
| 86 | hb_value_array_append(avfilters, avfilter); |
| 87 | } |
| 88 | |
| 89 | width = cropped_width; |
| 90 | height = cropped_height; |
| 91 | |
| 92 | // Convert scale settings to 'scale' avfilter |
| 93 | hb_dict_extract_int(&width, settings, "width"); |
| 94 | hb_dict_extract_int(&height, settings, "height"); |
| 95 | |
| 96 | hb_dict_t * avfilter = hb_dict_init(); |
| 97 | hb_dict_t * avsettings = hb_dict_init(); |
| 98 | |
| 99 | #if HB_PROJECT_FEATURE_QSV && (defined( _WIN32 ) || defined( __MINGW32__ )) |
| 100 | if (init->hw_pix_fmt == AV_PIX_FMT_QSV) |
| 101 | { |
| 102 | if (top > 0 || bottom > 0 || left > 0 || right > 0) |
| 103 | { |
| 104 | hb_dict_set_int(avsettings, "cx", left); |
| 105 | hb_dict_set_int(avsettings, "cy", top); |
| 106 | hb_dict_set_int(avsettings, "cw", cropped_width); |
| 107 | hb_dict_set_int(avsettings, "ch", cropped_height); |
| 108 | } |
nothing calls this directly
no test coverage detected