Browse code

avformat/hlsenc: Refactored 'get_int_from_double' function to allow reuse

Karthick J authored on 2017/11/30 11:54:54
Showing 2 changed files
... ...
@@ -203,11 +203,6 @@ typedef struct HLSContext {
203 203
     int http_persistent;
204 204
 } HLSContext;
205 205
 
206
-static int get_int_from_double(double val)
207
-{
208
-    return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
209
-}
210
-
211 206
 static int mkdir_p(const char *path) {
212 207
     int ret = 0;
213 208
     char *temp = av_strdup(path);
... ...
@@ -1211,7 +1206,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
1211 1211
 
1212 1212
     for (en = vs->segments; en; en = en->next) {
1213 1213
         if (target_duration <= en->duration)
1214
-            target_duration = get_int_from_double(en->duration);
1214
+            target_duration = hls_get_int_from_double(en->duration);
1215 1215
     }
1216 1216
 
1217 1217
     vs->discontinuity_set = 0;
... ...
@@ -36,6 +36,11 @@ typedef enum {
36 36
     PLAYLIST_TYPE_NB,
37 37
 } PlaylistType;
38 38
 
39
+static inline int hls_get_int_from_double(double val)
40
+{
41
+    return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
42
+}
43
+
39 44
 void ff_hls_write_playlist_version(AVIOContext *out, int version);
40 45
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
41 46
                               int bandwidth, char *filename);