diff mbox

[FFmpeg-devel,v2,1/2] avformat/hlsenc: Refactored 'get_int_from_double' function to allow reuse

Message ID 1511970255-12569-1-git-send-email-kjeyapal@akamai.com
State New
Headers show

Commit Message

Jeyapal, Karthick Nov. 29, 2017, 3:44 p.m. UTC
From: Karthick Jeyapal <kjeyapal@akamai.com>

---
 libavformat/hlsenc.c      | 7 +------
 libavformat/hlsplaylist.h | 5 +++++
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Steven Liu Nov. 30, 2017, 3:17 a.m. UTC | #1
2017-11-29 23:44 GMT+08:00 Karthick J <kjeyapal@akamai.com>:
> From: Karthick Jeyapal <kjeyapal@akamai.com>
>
> ---
>  libavformat/hlsenc.c      | 7 +------
>  libavformat/hlsplaylist.h | 5 +++++
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index f63b08d..cdfbf45 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -203,11 +203,6 @@ typedef struct HLSContext {
>      int http_persistent;
>  } HLSContext;
>
> -static int get_int_from_double(double val)
> -{
> -    return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
> -}
> -
>  static int mkdir_p(const char *path) {
>      int ret = 0;
>      char *temp = av_strdup(path);
> @@ -1211,7 +1206,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
>
>      for (en = vs->segments; en; en = en->next) {
>          if (target_duration <= en->duration)
> -            target_duration = get_int_from_double(en->duration);
> +            target_duration = hls_get_int_from_double(en->duration);
>      }
>
>      vs->discontinuity_set = 0;
> diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
> index fd36c7e..68ef8d4 100644
> --- a/libavformat/hlsplaylist.h
> +++ b/libavformat/hlsplaylist.h
> @@ -32,6 +32,11 @@ typedef enum {
>      PLAYLIST_TYPE_NB,
>  } PlaylistType;
>
> +static inline int hls_get_int_from_double(double val)
> +{
> +    return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
> +}
> +
>  void ff_hls_write_playlist_version(AVIOContext *out, int version);
>  void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
>                                int bandwidth, char *filename);
> --
> 1.9.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Patchset pushed


Thanks
Jeyapal, Karthick Nov. 30, 2017, 5:04 a.m. UTC | #2
On 11/30/17, 8:47 AM, "Steven Liu" <lingjiujianke@gmail.com> wrote:
[..]
>Patchset pushed

Thanks.

>

>

>Thanks


regards,
Karthick
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f63b08d..cdfbf45 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -203,11 +203,6 @@  typedef struct HLSContext {
     int http_persistent;
 } HLSContext;
 
-static int get_int_from_double(double val)
-{
-    return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
-}
-
 static int mkdir_p(const char *path) {
     int ret = 0;
     char *temp = av_strdup(path);
@@ -1211,7 +1206,7 @@  static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
 
     for (en = vs->segments; en; en = en->next) {
         if (target_duration <= en->duration)
-            target_duration = get_int_from_double(en->duration);
+            target_duration = hls_get_int_from_double(en->duration);
     }
 
     vs->discontinuity_set = 0;
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
index fd36c7e..68ef8d4 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -32,6 +32,11 @@  typedef enum {
     PLAYLIST_TYPE_NB,
 } PlaylistType;
 
+static inline int hls_get_int_from_double(double val)
+{
+    return (int)((val - (int)val) >= 0.001) ? (int)(val + 1) : (int)val;
+}
+
 void ff_hls_write_playlist_version(AVIOContext *out, int version);
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
                               int bandwidth, char *filename);