MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / ghb_apply_crop

Function ghb_apply_crop

gtk/src/hb-backend.c:4039–4101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4037}
4038
4039void
4040ghb_apply_crop(GhbValue *settings, const hb_geometry_crop_t * geo, const hb_title_t * title)
4041{
4042 gboolean autocrop, conservativecrop, customcrop;
4043 gint crop[4] = {0,};
4044
4045 const gchar * crop_mode;
4046
4047 crop_mode = ghb_dict_get_string(settings, "crop_mode");
4048 autocrop = !strcmp(crop_mode, "auto");
4049 conservativecrop = !strcmp(crop_mode, "conservative");
4050 customcrop = !strcmp(crop_mode, "custom");
4051
4052 if (title && autocrop)
4053 {
4054 crop[0] = title->crop[0];
4055 crop[1] = title->crop[1];
4056 crop[2] = title->crop[2];
4057 crop[3] = title->crop[3];
4058 }
4059 else if (title && conservativecrop)
4060 {
4061 crop[0] = title->loose_crop[0];
4062 crop[1] = title->loose_crop[1];
4063 crop[2] = title->loose_crop[2];
4064 crop[3] = title->loose_crop[3];
4065 }
4066 else if (customcrop)
4067 {
4068 crop[0] = ghb_dict_get_int(settings, "PictureTopCrop");
4069 crop[1] = ghb_dict_get_int(settings, "PictureBottomCrop");
4070 crop[2] = ghb_dict_get_int(settings, "PictureLeftCrop");
4071 crop[3] = ghb_dict_get_int(settings, "PictureRightCrop");
4072 }
4073
4074 // Prevent crop from creating too small an image
4075 if (geo->geometry.height - crop[0] -crop[1] < 16)
4076 {
4077 crop[0] = geo->geometry.height - crop[1] - 16;
4078 if (crop[0] < 0)
4079 {
4080 crop[1] += crop[0];
4081 crop[0] = 0;
4082 }
4083 }
4084 if (geo->geometry.width - crop[2] - crop[3] < 16)
4085 {
4086 crop[2] = geo->geometry.width - crop[3] - 16;
4087 if (crop[2] < 0)
4088 {
4089 crop[3] += crop[2];
4090 crop[2] = 0;
4091 }
4092 }
4093 crop[0] = MOD_DOWN(crop[0], 2);
4094 crop[1] = MOD_DOWN(crop[1], 2);
4095 crop[2] = MOD_DOWN(crop[2], 2);
4096 crop[3] = MOD_DOWN(crop[3], 2);

Callers 2

ghb_set_scale_settingsFunction · 0.85
ghb_set_title_settingsFunction · 0.85

Calls 3

ghb_dict_get_stringFunction · 0.85
ghb_dict_get_intFunction · 0.85
ghb_dict_set_intFunction · 0.85

Tested by

no test coverage detected