+/* update scaler target size according to user settings */
+static void update_layer_size(int w, int h)
+{
+ float mult;
+ int imult;
+
+ switch (g_scaler) {
+ case SCALE_1_1:
+ g_layer_w = w; g_layer_h = h;
+ break;
+
+ case SCALE_4_3v2:
+ if (h > g_menuscreen_h || (240 < h && h <= 360))
+ goto fractional_4_3;
+
+ // 4:3 that prefers integer scaling
+ imult = g_menuscreen_h / h;
+ g_layer_w = w * imult;
+ g_layer_h = h * imult;
+ mult = (float)g_layer_w / (float)g_layer_h;
+ if (mult < 1.25f || mult > 1.666f)
+ g_layer_w = 4.0f/3.0f * (float)g_layer_h;
+ printf(" -> %dx%d %.1f\n", g_layer_w, g_layer_h, mult);
+ break;
+
+ fractional_4_3:
+ case SCALE_4_3:
+ mult = 240.0f / (float)h * 4.0f / 3.0f;
+ if (h > 256)
+ mult *= 2.0f;
+ g_layer_w = mult * (float)g_menuscreen_h;
+ g_layer_h = g_menuscreen_h;
+ printf(" -> %dx%d %.1f\n", g_layer_w, g_layer_h, mult);
+ break;
+
+ case SCALE_FULLSCREEN:
+ g_layer_w = g_menuscreen_w;
+ g_layer_h = g_menuscreen_h;
+ break;
+
+ default:
+ break;
+ }
+
+ g_layer_x = g_menuscreen_w / 2 - g_layer_w / 2;
+ g_layer_y = g_menuscreen_h / 2 - g_layer_h / 2;
+ if (g_layer_x < 0) g_layer_x = 0;
+ if (g_layer_y < 0) g_layer_y = 0;
+ if (g_layer_w > g_menuscreen_w) g_layer_w = g_menuscreen_w;
+ if (g_layer_h > g_menuscreen_h) g_layer_h = g_menuscreen_h;
+}
+
+// XXX: this is platform specific really
+static int resolution_ok(int w, int h)
+{
+ return w <= 1024 && h <= 512;
+}
+
+static void pl_vout_set_mode(int w, int h, int raw_w, int raw_h, int bpp)