Coverage for pyguymer3/media/return_x264_crf.py: 100%

13 statements  

« prev     ^ index     » next       coverage.py v7.9.2, created at 2025-07-08 18:47 +0000

1#!/usr/bin/env python3 

2 

3# Define function ... 

4def return_x264_crf( 

5 w, 

6 h, 

7 /, 

8): 

9 # Import modules ... 

10 import math 

11 

12 # Define points ... 

13 x1 = 720.0 * 426.0 

14 y1 = 20.0 

15 x2 = 1920.0 * 800.0 

16 y2 = 22.0 

17 

18 # Fit a straight line to the two point in log(x)/linear(y) space ... 

19 xBar = (math.log(x1) + math.log(x2)) / 2.0 

20 yBar = (y1 + y2) / 2.0 

21 xDelta = math.log(x2) - math.log(x1) 

22 yDelta = y2 - y1 

23 m = yDelta / xDelta 

24 c = yBar - m * xBar 

25 

26 # Return answer ... 

27 return m * math.log(float(w * h)) + c