floatdsp: move vector_fmul_add from dsputil to avfloatdsp.
[ffmpeg.git] / libavformat / hlsenc.c
index 71c0c34..89980d7 100644 (file)
@@ -38,7 +38,8 @@ typedef struct ListEntry {
 
 typedef struct HLSContext {
     const AVClass *class;  // Class for private options.
-    int number;
+    unsigned number;
+    int64_t sequence;
     AVOutputFormat *oformat;
     AVFormatContext *avf;
     float time;            // Set by a private option.
@@ -105,6 +106,8 @@ static int append_entry(HLSContext *hls, uint64_t duration)
     } else
         hls->nb_entries++;
 
+    hls->sequence++;
+
     return 0;
 }
 
@@ -138,8 +141,8 @@ static int hls_window(AVFormatContext *s, int last)
     avio_printf(hls->pb, "#EXTM3U\n");
     avio_printf(hls->pb, "#EXT-X-VERSION:3\n");
     avio_printf(hls->pb, "#EXT-X-TARGETDURATION:%d\n", target_duration);
-    avio_printf(hls->pb, "#EXT-X-MEDIA-SEQUENCE:%d\n",
-                FFMAX(0, hls->number - hls->size));
+    avio_printf(hls->pb, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
+                FFMAX(0, hls->sequence - hls->size));
 
     for (en = hls->list; en; en = en->next) {
         avio_printf(hls->pb, "#EXTINF:%d,\n", en->duration);
@@ -253,10 +256,10 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         hls->start_pts = pkt->pts;
         hls->end_pts   = pkt->pts;
     }
-    end_pts += hls->start_pts;
 
     if ((hls->has_video && st->codec->codec_type == AVMEDIA_TYPE_VIDEO)      &&
-        av_compare_ts(pkt->pts, st->time_base, end_pts, AV_TIME_BASE_Q) >= 0 &&
+        av_compare_ts(pkt->pts - hls->start_pts, st->time_base,
+                      end_pts, AV_TIME_BASE_Q) >= 0 &&
         pkt->flags & AV_PKT_FLAG_KEY) {
 
         ret = append_entry(hls, av_rescale(pkt->pts - hls->end_pts,
@@ -305,7 +308,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 #define OFFSET(x) offsetof(HLSContext, x)
 #define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-    { "start_number", "first number in the sequence",            OFFSET(number),  AV_OPT_TYPE_INT,    {.i64 = 0},     0, INT_MAX, E},
+    {"start_number",  "first number in the sequence",            OFFSET(sequence),AV_OPT_TYPE_INT64,  {.i64 = 0},     0, INT64_MAX, E},
     {"hls_time",      "segment length in seconds",               OFFSET(time),    AV_OPT_TYPE_FLOAT,  {.dbl = 2},     0, FLT_MAX, E},
     {"hls_list_size", "maximum number of playlist entries",      OFFSET(size),    AV_OPT_TYPE_INT,    {.i64 = 5},     0, INT_MAX, E},
     {"hls_wrap",      "number after which the index wraps",      OFFSET(wrap),    AV_OPT_TYPE_INT,    {.i64 = 0},     0, INT_MAX, E},