Refactor crop border, swap aspect, screencap size, mode7 scaling and normal scaling

pull/311/head
IanSB 2023-02-25 21:32:57 +00:00
rodzic 810c86365d
commit 79a1342039
5 zmienionych plików z 25 dodań i 94 usunięć

Wyświetl plik

@ -56,7 +56,7 @@ static int generate_png(capture_info_t *capinfo, uint8_t **png, unsigned int *pn
int width = capinfo->width;
int width43 = width;
int height = capinfo->height;
int capscale = get_capscale();
int capscale = get_parameter(F_SCREENCAP_SIZE);
int hscale = get_hscale();
int vscale = get_vscale();

Wyświetl plik

@ -114,15 +114,10 @@ static geometry_t *geometry;
static geometry_t set1_geometry;
static geometry_t set2_geometry;
static int scaling = 0;
static int overscan = 0;
static int stretch = 0;
static int capscale = 0;
static int capvscale = 1;
static int caphscale = 1;
static int fhaspect = 1;
static int fvaspect = 1;
static int m7scaling = 0;
static int normalscaling = 0;
static int use_px_sampling = 1;
void geometry_init(int version) {
@ -355,44 +350,6 @@ int get_gscaling() {
return scaling;
}
void set_overscan(int value) {
overscan = value;
}
int get_overscan() {
return overscan;
}
void set_stretch(int value) {
stretch = value;
}
int get_stretch() {
return stretch;
}
void set_m7scaling(int value){
m7scaling = value;
}
int get_m7scaling() {
return m7scaling;
}
void set_normalscaling(int value){
normalscaling = value;
}
int get_normalscaling() {
return normalscaling;
}
void set_capscale(int value) {
capscale = value;
}
int get_capscale() {
return capscale;
}
void set_setup_mode(int mode) {
geometry_set_value(SETUP_MODE, mode);
//log_info("setup mode = %d", mode);
@ -484,7 +441,7 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
int h_aspect = geometry->h_aspect;
int v_aspect = geometry->v_aspect;
if (stretch) {
if (get_parameter(F_SWAP_ASPECT)) {
if (geometry->lines_per_frame > 287) {
if (h_aspect == v_aspect) {
h_aspect = 4;
@ -507,7 +464,7 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
}
}
//if (overscan == OVERSCAN_AUTO && (geometry->setup_mode == SETUP_NORMAL || geometry->setup_mode == SETUP_CLOCK)) {
//if (get_parameter(F_CROP_BORDER) == OVERSCAN_AUTO && (geometry->setup_mode == SETUP_NORMAL || geometry->setup_mode == SETUP_CLOCK)) {
//reduce max area by 4% to hide offscreen imperfections
// geometry_max_h_width = ((geometry_max_h_width * 96) / 100) & 0xfffffff8;
// geometry_max_v_height = ((geometry_max_v_height * 96) / 100) & 0xfffffffe;
@ -630,8 +587,8 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
scaled_min_h_width = geometry_min_h_width;
}
}
geometry_max_h_width = (geometry_max_h_width - ((geometry_max_h_width - scaled_min_h_width) * overscan / (NUM_OVERSCAN - 1))) & 0xfffffff8;
geometry_max_v_height = (geometry_max_v_height - ((geometry_max_v_height - scaled_min_v_height) * overscan / (NUM_OVERSCAN - 1))) & 0xfffffffe;
geometry_max_h_width = (geometry_max_h_width - ((geometry_max_h_width - scaled_min_h_width) * get_parameter(F_CROP_BORDER) / (NUM_OVERSCAN - 1))) & 0xfffffff8;
geometry_max_v_height = (geometry_max_v_height - ((geometry_max_v_height - scaled_min_v_height) * get_parameter(F_CROP_BORDER) / (NUM_OVERSCAN - 1))) & 0xfffffffe;
if (geometry_max_h_width < geometry_min_h_width) {
geometry_max_h_width = geometry_min_h_width;
}
@ -662,8 +619,8 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
//log_info("adjusted integer = %d, %d, %d, %d, %d, %d", geometry_h_offset, geometry_v_offset, geometry_min_h_width, geometry_min_v_height, geometry_max_h_width, geometry_max_v_height);
int h_size43_adj = h_size43;
if ((capinfo->mode7 && m7scaling == SCALING_UNEVEN)
|| (!capinfo->mode7 && normalscaling == SCALING_UNEVEN && geometry->h_aspect == 3 && (geometry->v_aspect == 2 || geometry->v_aspect == 4))) {
if ((capinfo->mode7 && get_parameter(F_MODE7_SCALING) == SCALING_UNEVEN)
|| (!capinfo->mode7 && get_parameter(F_NORMAL_SCALING) == SCALING_UNEVEN && geometry->h_aspect == 3 && (geometry->v_aspect == 2 || geometry->v_aspect == 4))) {
h_size43_adj = h_size43 * 3 / 4;
if (h_aspect == 3 && v_aspect == 2) {
h_aspect = 1;
@ -812,12 +769,12 @@ void geometry_get_fb_params(capture_info_t *capinfo) {
capinfo->width = adjusted_width + hborder;
capinfo->height = adjusted_height + vborder;
if ((capinfo->mode7 && m7scaling == SCALING_UNEVEN) // workaround mode 7 width so it looks like other modes
||(!capinfo->mode7 && normalscaling == SCALING_UNEVEN && geometry->h_aspect == 3 && (geometry->v_aspect == 2 || geometry->v_aspect == 4))) {
if ((capinfo->mode7 && get_parameter(F_MODE7_SCALING) == SCALING_UNEVEN) // workaround mode 7 width so it looks like other modes
||(!capinfo->mode7 && get_parameter(F_NORMAL_SCALING) == SCALING_UNEVEN && geometry->h_aspect == 3 && (geometry->v_aspect == 2 || geometry->v_aspect == 4))) {
capinfo->width = capinfo->width * 3 / 4;
}
if (capscale == SCREENCAP_FULL || capscale == SCREENCAP_FULL43) {
if (get_parameter(F_SCREENCAP_SIZE) == SCREENCAP_FULL || get_parameter(F_SCREENCAP_SIZE) == SCREENCAP_FULL43) {
caphscale = ((h_size << double_width) / capinfo->width);
capvscale = ((v_size << double_height) / capinfo->height);
}

Wyświetl plik

@ -79,16 +79,6 @@ void geometry_get_fb_params(capture_info_t *capinfo);
void geometry_get_clk_params(clk_info_t *clkinfo);
void set_gscaling(int value);
int get_gscaling();
void set_overscan(int value);
int get_overscan();
void set_stretch(int value);
int get_stretch();
void set_m7scaling(int value);
int get_m7scaling();
void set_normalscaling(int value);
int get_normalscaling();
void set_capscale(int value);
int get_capscale();
int get_hscale();
int get_vscale();
int get_haspect();

Wyświetl plik

@ -1110,13 +1110,13 @@ static int get_feature(int num) {
return get_scaling();
case F_FRONTEND:
return get_frontend();
case F_CROP_BORDER:
return get_overscan();
case F_SCREENCAP_SIZE:
return get_capscale();
case F_SWAP_ASPECT:
case F_NORMAL_SCALING:
case F_MODE7_SCALING:
case F_PROFILE:
case F_SAVED_CONFIG:
case F_SUB_PROFILE:
@ -1149,12 +1149,7 @@ static int get_feature(int num) {
case F_INTEGER_ASPECT:
return get_parameter(num);
case F_SWAP_ASPECT:
return get_stretch();
case F_NORMAL_SCALING:
return get_normalscaling();
case F_MODE7_SCALING:
return get_m7scaling();
case F_PALETTE:
@ -1210,6 +1205,11 @@ static void set_feature(int num, int value) {
break;
case F_CROP_BORDER:
case F_SCREENCAP_SIZE:
case F_SWAP_ASPECT:
case F_MODE7_SCALING:
case F_NORMAL_SCALING:
case F_HDMI_MODE_STANDBY:
case F_FFOSD:
case F_MODE7_DEINTERLACE:
@ -1289,22 +1289,6 @@ static void set_feature(int num, int value) {
break;
case F_CROP_BORDER:
set_overscan(value);
break;
case F_SCREENCAP_SIZE:
set_capscale(value);
break;
case F_SWAP_ASPECT:
set_stretch(value);
break;
case F_MODE7_SCALING:
set_m7scaling(value);
break;
case F_NORMAL_SCALING:
set_normalscaling(value);
break;
case F_PALETTE:
palette = value;

Wyświetl plik

@ -443,8 +443,8 @@ int height = 0;
int adjusted_height = capinfo->height;
if (get_gscaling() == GSCALING_INTEGER) {
if (!((capinfo->mode7 && get_m7scaling() == SCALING_UNEVEN)
||(!capinfo->mode7 && get_normalscaling() == SCALING_UNEVEN))) {
if (!((capinfo->mode7 && parameters[F_MODE7_SCALING] == SCALING_UNEVEN)
||(!capinfo->mode7 && parameters[F_NORMAL_SCALING] == SCALING_UNEVEN))) {
int width = adjusted_width >> ((capinfo->sizex2 & SIZEX2_DOUBLE_WIDTH) >> 1);
int hscale = h_size / width;
h_overscan = h_size - (hscale * width);
@ -2691,8 +2691,8 @@ void set_scaling(int mode, int reboot) {
}
int video_type = geometry_get_value(VIDEO_TYPE);
geometry_set_mode(modeset);
if ((video_type == VIDEO_TELETEXT && get_m7scaling() == SCALING_UNEVEN) // workaround mode 7 width so it looks like other modes
||( video_type != VIDEO_TELETEXT && get_normalscaling() == SCALING_UNEVEN && get_haspect() == 3 && (get_vaspect() == 2 || get_vaspect() == 4))) {
if ((video_type == VIDEO_TELETEXT && parameters[F_MODE7_SCALING] == SCALING_UNEVEN) // workaround mode 7 width so it looks like other modes
||( video_type != VIDEO_TELETEXT && parameters[F_NORMAL_SCALING] == SCALING_UNEVEN && get_haspect() == 3 && (get_vaspect() == 2 || get_vaspect() == 4))) {
width = width * 4 / 3;
}
if ((width > 340 && h_size43 < 1440 && (h_size43 % width) > (width / 3)) || (parameters[F_AUTO_SWITCH] == AUTOSWITCH_MODE7 && v_size == 1024)) {