Applied strategy pattern to Encoder, refactored and reorganized code
This commit is contained in:
@@ -4,21 +4,13 @@ using Microsoft.Net.Http.Headers;
|
||||
namespace Encoder;
|
||||
|
||||
public static class Utils {
|
||||
private static readonly Tuple<int, int>[] QPTable = new Tuple<int, int>[] {
|
||||
new(1280*720, 64),
|
||||
new(1920*1080, 96),
|
||||
new(3840*2160, 128),
|
||||
new(5760*2880, 96), //VR6K
|
||||
new(8128*4096, 120) //VR8K
|
||||
}.OrderBy(t => t.Item1).ToArray();
|
||||
|
||||
public static float Lerp(float v0, float v1, float t) {
|
||||
return v0 + t * (v1 - v0);
|
||||
}
|
||||
|
||||
public static float Remap(float value, float from1, float to1, float from2, float to2) => from2 + (value - from1) * (to2 - from2) / (to1 - from1);
|
||||
|
||||
public static int ToQPValue(int W, int H) {
|
||||
public static int ToQPValue(int W, int H, Tuple<int, int>[] QPTable) {
|
||||
int pixels = W * H;
|
||||
for (var i = 0; i < QPTable.Length; i++) {
|
||||
if (pixels <= QPTable[i].Item1) {
|
||||
|
||||
Reference in New Issue
Block a user