[FFmpeg-devel,1/2] avformat/hlsenc: remove unnecessary variate and logic

Submitted by Steven Liu on March 13, 2018, 10:05 a.m.

Details

Message ID 20180313100505.2563-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu March 13, 2018, 10:05 a.m.
write init file and first segment at the same time,
so remove the unnecessary variate and logic.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/hlsenc.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d319cba764..185e3442f6 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -111,7 +111,6 @@  typedef struct VariantStream {
     AVOutputFormat *oformat;
     AVOutputFormat *vtt_oformat;
     AVIOContext *out;
-    int packets_written;
     int init_range_length;
 
     AVFormatContext *avf;
@@ -745,7 +744,6 @@  static int hls_mux_init(AVFormatContext *s, VariantStream *vs)
         av_dict_copy(&st->metadata, vs->streams[i]->metadata, 0);
     }
 
-    vs->packets_written = 1;
     vs->start_pos = 0;
     vs->new_start = 1;
     vs->fmp4_init_mode = 0;
@@ -756,7 +754,6 @@  static int hls_mux_init(AVFormatContext *s, VariantStream *vs)
             return AVERROR_PATCHWELCOME;
         }
 
-        vs->packets_written = 0;
         vs->init_range_length = 0;
         vs->fmp4_init_mode = !byterange_mode;
         set_http_options(s, &options, hls);
@@ -2170,7 +2167,7 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 
     }
 
-    if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base,
+    if (can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base,
                                                           end_pts, AV_TIME_BASE_Q) >= 0) {
         int64_t new_start_pos;
         char *old_filename = NULL;
@@ -2192,7 +2189,6 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                 avio_write(vs->out, buffer, range_length);
                 vs->init_range_length = range_length;
                 avio_open_dyn_buf(&oc->pb);
-                vs->packets_written = 0;
                 vs->start_pos = range_length;
                 if (!byterange_mode) {
                     ff_format_io_close(s, &vs->out);
@@ -2216,10 +2212,6 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
             hls_rename_temp_file(s, oc);
         }
 
-        if (vs->fmp4_init_mode) {
-            vs->number--;
-        }
-
         if (hls->segment_type == SEGMENT_TYPE_FMP4) {
             if (hls->flags & HLS_SINGLE_FILE) {
                 ret = flush_dynbuf(vs, &range_length);
@@ -2295,7 +2287,6 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
             }
     }
 
-    vs->packets_written++;
     ret = ff_write_chained(oc, stream_index, pkt, s, 0);
 
     return ret;