On Tue, 27 Aug 2013, Hendrik Leppkes wrote:

Using a 64-bit integer as default value can cause problems with the
comparison later on, since the integer may not be accurately represented
by the double floating point, failing the comparison later.

This results in an infite loop in various FATE tests on x86_64 MSVC.

Not only on x86_64, but on all MSVC 2012 instances.

The problem is that INT64_C(0x8000000000000000) is expanded differently on MSVC 2010 and 2012 - when assigned to a double, the 2010 version ends up with a positive value while the 2012 version gets a negative one. The expression parser in c99conv doesn't handle all those details and always ends up with a positive one.

---
libavfilter/vf_fps.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 4583c89..5b28185 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -21,6 +21,8 @@
 * a filter enforcing given constant framerate
 */

+#include <float.h>
+
#include "libavutil/common.h"
#include "libavutil/fifo.h"
#include "libavutil/mathematics.h"
@@ -56,7 +58,7 @@ typedef struct FPSContext {
#define V AV_OPT_FLAG_VIDEO_PARAM
static const AVOption options[] = {
    { "fps", "A string describing desired output framerate", OFFSET(fps), 
AV_OPT_TYPE_STRING, { .str = "25" }, .flags = V },
-    { "start_time", "Assume the first PTS should be this value.", 
OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = AV_NOPTS_VALUE}, INT64_MIN, INT64_MAX, V },
+    { "start_time", "Assume the first PTS should be this value.", 
OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX}, -DBL_MAX, DBL_MAX, V },
    { NULL },
};

@@ -181,7 +183,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
            if (ret < 0)
                return ret;

-            if (s->start_time != AV_NOPTS_VALUE) {
+            if (s->start_time != DBL_MAX) {
                double first_pts = s->start_time * AV_TIME_BASE;
                first_pts = FFMIN(FFMAX(first_pts, INT64_MIN), INT64_MAX);
                s->first_pts = s->pts = av_rescale_q(first_pts, AV_TIME_BASE_Q,
--
1.8.3.msysgit.0

The patch itself is ok with me. And is a bit cleaner - comparing floats to AV_NOPTS_VALUE is ugly...

// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to