Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
oldma3095 committed Nov 27, 2024
1 parent d0a3484 commit bff991f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_STORE
coverage.out
coverage.out
/.idea
5 changes: 5 additions & 0 deletions mathematics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ func RescaleQ(a int64, b Rational, c Rational) int64 {
func RescaleQRnd(a int64, b Rational, c Rational, r Rounding) int64 {
return int64(C.av_rescale_q_rnd(C.int64_t(a), b.c, c.c, C.enum_AVRounding(r)))
}

// https://ffmpeg.org/doxygen/7.0/group__lavu__math__rational.html#ga935dbbf6bde8dfe5fa7ddb1da582eb07
func Q2D(a Rational) float64 {
return float64(C.av_q2d(a.c))
}
3 changes: 3 additions & 0 deletions mathematics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ func TestMathematics(t *testing.T) {
require.Equal(t, int64(1000), RescaleQ(100, NewRational(1, 100), NewRational(1, 1000)))
require.Equal(t, int64(0), RescaleQRnd(1, NewRational(1, 100), NewRational(1, 10), RoundingDown))
require.Equal(t, int64(1), RescaleQRnd(1, NewRational(1, 100), NewRational(1, 10), RoundingUp))
require.Equal(t, 0.04, Q2D(NewRational(1, 25)))
require.Equal(t, 0.3, Q2D(NewRational(3, 10)))
require.Equal(t, float64(30), Q2D(NewRational(30, 1)))
}

0 comments on commit bff991f

Please sign in to comment.