diff --git a/gopro_8:7/compute_gopro_8:7.py b/gopro_8:7/compute_gopro_8:7.py index 16f11c2..3668249 100644 --- a/gopro_8:7/compute_gopro_8:7.py +++ b/gopro_8:7/compute_gopro_8:7.py @@ -9,6 +9,7 @@ import math frame_width = 8 frame_height = 7 +input_ratio = frame_width / frame_height input_vertical_fov = 108.0 input_diagonal_fov = 156.0 @@ -20,14 +21,14 @@ output_horizontal_length = math.sqrt((input_diagonal_length ** 2) / (input_verti output_diagonal_length = math.hypot(output_horizontal_length, input_vertical_length) output_diagonal_fov = math.degrees(math.atan(output_diagonal_length)) * 2.0 -output_ratio = output_horizontal_length / input_vertical_length +output_ratio = 1.0 / (output_horizontal_length / input_vertical_length) print("Output FOV = %f" % output_diagonal_fov) print("Output Ratio = %f" % output_ratio) print("= Resolutions =====================") def width_rounded_8(height): - width = int(round(height * output_ratio)) + width = int(round(height * input_ratio)) return ((width + 4) // 8) * 8 print("QHD = %i x 540" % width_rounded_8(540)) diff --git a/gopro_8:7/preset_gopro_8:7_4K_2160p.py b/gopro_8:7/preset_gopro_8:7_4K_2160p.py index 48d5572..c2b1b96 100644 --- a/gopro_8:7/preset_gopro_8:7_4K_2160p.py +++ b/gopro_8:7/preset_gopro_8:7_4K_2160p.py @@ -91,7 +91,7 @@ adm.addVideoFilter( "shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl") adm.addVideoFilter( "swscale", - "width=3312", + "width=2472", "height=2160", "algo=1", "sourceAR=0", diff --git a/gopro_8:7/preset_gopro_8:7_FullHD_1080p.py b/gopro_8:7/preset_gopro_8:7_FullHD_1080p.py index 3d9302c..7fb9900 100644 --- a/gopro_8:7/preset_gopro_8:7_FullHD_1080p.py +++ b/gopro_8:7/preset_gopro_8:7_FullHD_1080p.py @@ -91,7 +91,7 @@ adm.addVideoFilter( "shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl") adm.addVideoFilter( "swscale", - "width=1656", + "width=1232", "height=1080", "algo=1", "sourceAR=0", diff --git a/gopro_8:7/preset_gopro_8:7_HD_720p.py b/gopro_8:7/preset_gopro_8:7_HD_720p.py index 4ab2b10..7482c78 100644 --- a/gopro_8:7/preset_gopro_8:7_HD_720p.py +++ b/gopro_8:7/preset_gopro_8:7_HD_720p.py @@ -91,7 +91,7 @@ adm.addVideoFilter( "shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl") adm.addVideoFilter( "swscale", - "width=1104", + "width=824", "height=720", "algo=1", "sourceAR=0", diff --git a/gopro_8:7/preset_gopro_8:7_QHD_540p.py b/gopro_8:7/preset_gopro_8:7_QHD_540p.py index c650acf..262600d 100644 --- a/gopro_8:7/preset_gopro_8:7_QHD_540p.py +++ b/gopro_8:7/preset_gopro_8:7_QHD_540p.py @@ -91,7 +91,7 @@ adm.addVideoFilter( "shaderFile=/opt/rk/avidemux/unfish_gopro_8:7.glsl") adm.addVideoFilter( "swscale", - "width=832", + "width=616", "height=540", "algo=1", "sourceAR=0", diff --git a/gopro_8:7/unfish_gopro_8:7.glsl b/gopro_8:7/unfish_gopro_8:7.glsl index cfe28a6..e683006 100644 --- a/gopro_8:7/unfish_gopro_8:7.glsl +++ b/gopro_8:7/unfish_gopro_8:7.glsl @@ -13,17 +13,19 @@ uniform float pts; const vec2 half_pixel = vec2(0.5, 0.5); +const vec2 input_scale = vec2(0.652485, 1.0); const float input_fov = 156.0; const float output_fov = 119.789529; vec2 unfish(vec2 coord) { float diameter = sqrt(dot(myResolution, myResolution)); vec2 center = myResolution * 0.5; - vec2 position = coord - center; - float input_distance = length(position); - float input_foc = diameter / radians(input_fov); - float output_foc = diameter / (2.0 * tan(radians(output_fov) * 0.5)); - return center + position * (input_foc * atan(input_distance / output_foc) / input_distance); + vec2 input_position = (coord - center) * input_scale; + float input_distance = length(input_position); + float input_len = diameter / radians(input_fov); + float output_len = diameter / (2.0 * tan(radians(output_fov) * 0.5)); + float unfish_ratio = input_len * atan(input_distance / output_len) / input_distance; + return center + input_position * unfish_ratio; } void main() {