edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching0 forksRust370.3 MiBa31973fTahinli7 days ago3925 commits
| 1 | #!/usr/bin/env python3 |
| 2 | """Bjontegaard delta rate and delta PSNR between two rate-distortion curves. |
| 3 | |
| 4 | Usage: python3 -I bdrate.py [--metric y|yuv] <anchor.tsv> <test.tsv> |
| 5 | |
| 6 | Each TSV holds one operating point per line: `bytes<TAB>psnr_y<TAB>psnr_yuv`. |
| 7 | `--metric` picks the PSNR column the curves are judged by (default yuv). Four |
| 8 | points per curve is the usual Bjontegaard setup. The curves are fitted as cubic polynomials of |
| 9 | log10(bytes) against PSNR (least squares with exact interpolation at four |
| 10 | points), integrated over the PSNR range both cover. |
| 11 | |
| 12 | Prints `bd_rate_pct` (negative: the test curve needs fewer bytes for the same |
| 13 | quality) and `bd_psnr_db` (positive: the test curve has more quality for the |
| 14 | same bytes). |
| 15 | """ |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | = |
| 22 | = |
| 23 | |
| 24 | |
| 25 | = |
| 26 | |
| 27 | continue |
| 28 | = |
| 29 | |
| 30 | return |
| 31 | |
| 32 | |
| 33 | |
| 34 | """Solve a x = b by Gaussian elimination with partial pivoting.""" |
| 35 | = |
| 36 | = |
| 37 | |
| 38 | = |
| 39 | , = , |
| 40 | |
| 41 | |
| 42 | = / |
| 43 | |
| 44 | -= * |
| 45 | return |
| 46 | |
| 47 | |
| 48 | |
| 49 | """Cubic a0 + a1 x + a2 x^2 + a3 x^3 through the points (least squares |
| 50 | via the normal equations; exact for four points).""" |
| 51 | = |
| 52 | = |
| 53 | = |
| 54 | return |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | return |
| 60 | return / |
| 61 | |
| 62 | |
| 63 | |
| 64 | = |
| 65 | = |
| 66 | |
| 67 | = |
| 68 | = |
| 69 | = |
| 70 | = |
| 71 | = |
| 72 | = |
| 73 | = |
| 74 | = |
| 75 | |
| 76 | |
| 77 | return 1 |
| 78 | = |
| 79 | = |
| 80 | = |
| 81 | = |
| 82 | = |
| 83 | = |
| 84 | = * 100 |
| 85 | |
| 86 | # BD-PSNR: fit PSNR against log rate and average over the rate overlap. |
| 87 | = |
| 88 | = |
| 89 | = |
| 90 | = |
| 91 | = |
| 92 | = |
| 93 | = - |
| 94 | |
| 95 | return 0 |
| 96 | |
| 97 | |
| 98 | |
| 99 |