OSDN Git Service

swr: make the default of nopts for first_pts actually work
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 25 Feb 2013 02:04:03 +0000 (03:04 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 25 Feb 2013 03:39:26 +0000 (04:39 +0100)
Fixes Ticket2210

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/swresample.c

index f85f88f..9b71b2e 100644 (file)
@@ -339,7 +339,8 @@ av_cold int swr_init(struct SwrContext *s){
             s->async = 1;
         s->firstpts =
         s->outpts   = s->firstpts_in_samples * s->out_sample_rate;
-    }
+    } else
+        s->firstpts = AV_NOPTS_VALUE;
 
     if (s->async) {
         if (s->min_compensation >= FLT_MAX/2)
@@ -899,6 +900,10 @@ int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensatio
 int64_t swr_next_pts(struct SwrContext *s, int64_t pts){
     if(pts == INT64_MIN)
         return s->outpts;
+
+    if (s->firstpts == AV_NOPTS_VALUE)
+        s->outpts = s->firstpts = pts;
+
     if(s->min_compensation >= FLT_MAX) {
         return (s->outpts = pts - swr_get_delay(s, s->in_sample_rate * (int64_t)s->out_sample_rate));
     } else {