[FFmpeg-cvslog] rational: test add/sub too

Michael Niedermayer git at videolan.org
Thu Nov 1 03:03:26 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Nov  1 02:42:47 2012 +0100| [6204ea17f16d7bcf94058e71877a6ce0266ee884] | committer: Michael Niedermayer

rational: test add/sub too

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6204ea17f16d7bcf94058e71877a6ce0266ee884
---

 libavutil/rational.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavutil/rational.c b/libavutil/rational.c
index 1a833eb..0fb855a 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -148,7 +148,7 @@ int av_find_nearest_q_idx(AVRational q, const AVRational* q_list)
 #ifdef TEST
 int main(void)
 {
-    AVRational a,b;
+    AVRational a,b,r;
     for (a.num = -2; a.num <= 2; a.num++) {
         for (a.den = -2; a.den <= 2; a.den++) {
             for (b.num = -2; b.num <= 2; b.num++) {
@@ -162,6 +162,9 @@ int main(void)
                     if (c != d)
                         av_log(0, AV_LOG_ERROR, "%d/%d %d/%d, %d %f\n", a.num,
                                a.den, b.num, b.den, c,d);
+                    r = av_sub_q(av_add_q(b,a), b);
+                    if(b.den && (r.num*a.den != a.num*r.den || !r.num != !a.num || !r.den != !a.den))
+                        av_log(0, AV_LOG_ERROR, "%d/%d ", r.num, r.den);
                 }
             }
         }



More information about the ffmpeg-cvslog mailing list