smoothstreamingenc: Simplify code by removing a redundant variable

Message ID 1413065127-91554-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö Oct. 11, 2014, 10:05 p.m.
---
Produced the patch with some extra content, to easier see why
this is correct - with the normal amount of context the diff
looked very suspicious.
---
 libavformat/smoothstreamingenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Luca Barbato Oct. 12, 2014, 7:56 a.m. | #1
On 12/10/14 00:05, Martin Storsjö wrote:
> ---
> Produced the patch with some extra content, to easier see why
> this is correct - with the normal amount of context the diff
> looked very suspicious.
> ---
>   libavformat/smoothstreamingenc.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>

Ok.

Patch

diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c
index b9f1dcb..a6d0a36 100644
--- a/libavformat/smoothstreamingenc.c
+++ b/libavformat/smoothstreamingenc.c
@@ -510,44 +510,45 @@  static int copy_moof(AVFormatContext *s, const char* infile, const char *outfile
 
 static int ism_flush(AVFormatContext *s, int final)
 {
     SmoothStreamingContext *c = s->priv_data;
     int i, ret = 0;
 
     for (i = 0; i < s->nb_streams; i++) {
         OutputStream *os = &c->streams[i];
         char filename[1024], target_filename[1024], header_filename[1024];
-        int64_t start_pos = os->tail_pos, size;
+        int64_t size;
         int64_t start_ts, duration, moof_size;
         if (!os->packets_written)
             continue;
 
         snprintf(filename, sizeof(filename), "%s/temp", os->dirname);
         ret = ffurl_open(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
         if (ret < 0)
             break;
         os->cur_start_pos = os->tail_pos;
         av_write_frame(os->ctx, NULL);
         avio_flush(os->ctx->pb);
         os->packets_written = 0;
         if (!os->out || os->tail_out)
             return AVERROR(EIO);
 
         ffurl_close(os->out);
         os->out = NULL;
-        size = os->tail_pos - start_pos;
+        size = os->tail_pos - os->cur_start_pos;
         if ((ret = parse_fragment(s, filename, &start_ts, &duration, &moof_size, size)) < 0)
             break;
         snprintf(header_filename, sizeof(header_filename), "%s/FragmentInfo(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
         snprintf(target_filename, sizeof(target_filename), "%s/Fragments(%s=%"PRIu64")", os->dirname, os->stream_type_tag, start_ts);
         copy_moof(s, filename, header_filename, moof_size);
         rename(filename, target_filename);
-        add_fragment(os, target_filename, header_filename, start_ts, duration, start_pos, size);
+        add_fragment(os, target_filename, header_filename, start_ts, duration,
+                     os->cur_start_pos, size);
     }
 
     if (c->window_size || (final && c->remove_at_exit)) {
         for (i = 0; i < s->nb_streams; i++) {
             OutputStream *os = &c->streams[i];
             int j;
             int remove = os->nb_fragments - c->window_size - c->extra_window_size - c->lookahead_count;
             if (final && c->remove_at_exit)
                 remove = os->nb_fragments;