function floatsort($a, $b) { if (floatgtr($a[0], $b[0])) { return 1; } if (floatcmp($a[0], $b[0])) { return 0; } return -1; }
function __sortByStartTime($a, $b) { if (floatgtr($a['start'], $b['start'])) { return 1; } if (floatcmp($a['start'], $b['start'])) { return 0; } return -1; }
function scale_switches($orig_dims, $dims, $fill) { $target_w = floatval($dims[0]); $target_h = floatval($dims[1]); $vf = ''; $scale = 'scale=' . $target_w . ':' . $target_h; if ($fill && $fill != 'stretch') { $orig_even_w = floatval($orig_dims[0]); $orig_dims1 = floatval($orig_dims[1]); $extra0 = $orig_even_w % 2; $extra1 = $orig_dims1 % 2; $orig_even_w -= $extra0; $orig_dims1 -= $extra1; $ratio_w = $target_w / $orig_even_w; $ratio_h = $target_h / $orig_dims1; if (!floatcmp($ratio_w, $ratio_h)) { $multiplier = $fill == 'scale' ? floatmin($ratio_w, $ratio_h) : floatmax($ratio_w, $ratio_h); $scaled_w = round($target_w / $multiplier); $scaled_h = round($target_h / $multiplier); if (!floatcmp($orig_even_w, $scaled_w)) { if (floatgtr($orig_even_w, $scaled_w)) { //$a['cropleft'] = $a['cropright'] = floor((($orig_even_w - $scaled_w) / 2)); $vf .= 'crop=' . floor(($orig_even_w - $scaled_w) / 2) . ':0:' . $scaled_w . ':' . $scaled_h; } else { /*$pad_x = $pad_width = floor(($scaled_w -$orig_even_w) / 2); $pad_x -= $extra0; $dims[0] -= 2 * $pad_width; $dims[0] += $extra0; $dims[1] += $extra1; */ $vf .= 'pad=' . $scaled_w . ':' . $scaled_h . ':' . (floor(($scaled_w - $orig_even_w) / 2) - $extra0) . ':0'; } } if (!floatcmp($orig_dims1, $scaled_h)) { if (floatgtr($orig_dims1, $scaled_h)) { $vf .= 'crop=0:' . floor(($orig_dims1 - $scaled_h) / 2) . ':' . $scaled_w . ':' . $scaled_h; } else { /* $pad_y = $pad_height = floor(($scaled_h - $orig_dims1) / 2); $pad_y -= $extra1; $dims[1] -= 2 * $pad_height; $dims[1] += $extra1; $dims[0] += $extra0; */ $vf .= 'pad=' . $scaled_w . ':' . $scaled_h . ':0:' . (floor(($scaled_h - $orig_dims1) / 2) - $extra1); } } } //$a['s'] = $dims[0] . 'x' . $dims[1]; } if ($vf) { $vf .= ','; } $vf .= $scale; $a = array(); $a['vf'] = $vf; return $a; }