diff mbox

[FFmpeg-devel,V1] lavf/dashdec: drop unnecessary check before ff_format_io_close

Message ID 1569256871-4807-1-git-send-email-mypopydev@gmail.com
State Accepted
Commit e7000389905f1ac2858ea2804d621e72f753a7eb
Headers show

Commit Message

Jun Zhao Sept. 23, 2019, 4:41 p.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

ff_format_io_close will check the AVIOContext pointer pb, so drop
the unnecessary check before ff_format_io_close.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/dashdec.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

Comments

Jun Zhao Nov. 4, 2019, 2:31 a.m. UTC | #1
On Tue, Sep 24, 2019 at 12:41 AM Jun Zhao <mypopydev@gmail.com> wrote:

> From: Jun Zhao <barryjzhao@tencent.com>
>
> ff_format_io_close will check the AVIOContext pointer pb, so drop
> the unnecessary check before ff_format_io_close.
>
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavformat/dashdec.c |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 8c0a9b0..5a49e15 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -363,8 +363,7 @@ static void free_representation(struct representation
> *pls)
>      free_fragment(&pls->init_section);
>      av_freep(&pls->init_sec_buf);
>      av_freep(&pls->pb.buffer);
> -    if (pls->input)
> -        ff_format_io_close(pls->parent, &pls->input);
> +    ff_format_io_close(pls->parent, &pls->input);
>      if (pls->ctx) {
>          pls->ctx->pb = NULL;
>          avformat_close_input(&pls->ctx);
> @@ -2182,8 +2181,7 @@ static void recheck_discard_flags(AVFormatContext
> *s, struct representation **p,
>              av_log(s, AV_LOG_INFO, "Now receiving stream_index %d\n",
> pls->stream_index);
>          } else if (!needed && pls->ctx) {
>              close_demux_for_component(pls);
> -            if (pls->input)
> -                ff_format_io_close(pls->parent, &pls->input);
> +            ff_format_io_close(pls->parent, &pls->input);
>              av_log(s, AV_LOG_INFO, "No longer receiving stream_index
> %d\n", pls->stream_index);
>          }
>      }
> @@ -2244,8 +2242,7 @@ static int dash_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>          if (cur->is_restart_needed) {
>              cur->cur_seg_offset = 0;
>              cur->init_sec_buf_read_offset = 0;
> -            if (cur->input)
> -                ff_format_io_close(cur->parent, &cur->input);
> +            ff_format_io_close(cur->parent, &cur->input);
>              ret = reopen_demux_for_component(s, cur);
>              cur->is_restart_needed = 0;
>          }
> @@ -2283,8 +2280,7 @@ static int dash_seek(AVFormatContext *s, struct
> representation *pls, int64_t see
>          return av_seek_frame(pls->ctx, -1, seek_pos_msec * 1000, flags);
>      }
>
> -    if (pls->input)
> -        ff_format_io_close(pls->parent, &pls->input);
> +    ff_format_io_close(pls->parent, &pls->input);
>
>      // find the nearest fragment
>      if (pls->n_timelines > 0 && pls->fragment_timescale > 0) {
> --
> 1.7.1
>
> Ping :)
Liu Steven Nov. 4, 2019, 2:43 a.m. UTC | #2
> 在 2019年11月4日,10:31,mypopy@gmail.com 写道:
> 
> On Tue, Sep 24, 2019 at 12:41 AM Jun Zhao <mypopydev@gmail.com> wrote:
> 
>> From: Jun Zhao <barryjzhao@tencent.com>
>> 
>> ff_format_io_close will check the AVIOContext pointer pb, so drop
>> the unnecessary check before ff_format_io_close.
>> 
>> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
>> ---
>> libavformat/dashdec.c |   12 ++++--------
>> 1 files changed, 4 insertions(+), 8 deletions(-)
>> 
>> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
>> index 8c0a9b0..5a49e15 100644
>> --- a/libavformat/dashdec.c
>> +++ b/libavformat/dashdec.c
>> @@ -363,8 +363,7 @@ static void free_representation(struct representation
>> *pls)
>>     free_fragment(&pls->init_section);
>>     av_freep(&pls->init_sec_buf);
>>     av_freep(&pls->pb.buffer);
>> -    if (pls->input)
>> -        ff_format_io_close(pls->parent, &pls->input);
>> +    ff_format_io_close(pls->parent, &pls->input);
>>     if (pls->ctx) {
>>         pls->ctx->pb = NULL;
>>         avformat_close_input(&pls->ctx);
>> @@ -2182,8 +2181,7 @@ static void recheck_discard_flags(AVFormatContext
>> *s, struct representation **p,
>>             av_log(s, AV_LOG_INFO, "Now receiving stream_index %d\n",
>> pls->stream_index);
>>         } else if (!needed && pls->ctx) {
>>             close_demux_for_component(pls);
>> -            if (pls->input)
>> -                ff_format_io_close(pls->parent, &pls->input);
>> +            ff_format_io_close(pls->parent, &pls->input);
>>             av_log(s, AV_LOG_INFO, "No longer receiving stream_index
>> %d\n", pls->stream_index);
>>         }
>>     }
>> @@ -2244,8 +2242,7 @@ static int dash_read_packet(AVFormatContext *s,
>> AVPacket *pkt)
>>         if (cur->is_restart_needed) {
>>             cur->cur_seg_offset = 0;
>>             cur->init_sec_buf_read_offset = 0;
>> -            if (cur->input)
>> -                ff_format_io_close(cur->parent, &cur->input);
>> +            ff_format_io_close(cur->parent, &cur->input);
>>             ret = reopen_demux_for_component(s, cur);
>>             cur->is_restart_needed = 0;
>>         }
>> @@ -2283,8 +2280,7 @@ static int dash_seek(AVFormatContext *s, struct
>> representation *pls, int64_t see
>>         return av_seek_frame(pls->ctx, -1, seek_pos_msec * 1000, flags);
>>     }
>> 
>> -    if (pls->input)
>> -        ff_format_io_close(pls->parent, &pls->input);
>> +    ff_format_io_close(pls->parent, &pls->input);
>> 
>>     // find the nearest fragment
>>     if (pls->n_timelines > 0 && pls->fragment_timescale > 0) {
>> --
>> 1.7.1
>> 
>> Ping :)
You can push it if you think this is ok :D
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

Thanks
Steven
diff mbox

Patch

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 8c0a9b0..5a49e15 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -363,8 +363,7 @@  static void free_representation(struct representation *pls)
     free_fragment(&pls->init_section);
     av_freep(&pls->init_sec_buf);
     av_freep(&pls->pb.buffer);
-    if (pls->input)
-        ff_format_io_close(pls->parent, &pls->input);
+    ff_format_io_close(pls->parent, &pls->input);
     if (pls->ctx) {
         pls->ctx->pb = NULL;
         avformat_close_input(&pls->ctx);
@@ -2182,8 +2181,7 @@  static void recheck_discard_flags(AVFormatContext *s, struct representation **p,
             av_log(s, AV_LOG_INFO, "Now receiving stream_index %d\n", pls->stream_index);
         } else if (!needed && pls->ctx) {
             close_demux_for_component(pls);
-            if (pls->input)
-                ff_format_io_close(pls->parent, &pls->input);
+            ff_format_io_close(pls->parent, &pls->input);
             av_log(s, AV_LOG_INFO, "No longer receiving stream_index %d\n", pls->stream_index);
         }
     }
@@ -2244,8 +2242,7 @@  static int dash_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (cur->is_restart_needed) {
             cur->cur_seg_offset = 0;
             cur->init_sec_buf_read_offset = 0;
-            if (cur->input)
-                ff_format_io_close(cur->parent, &cur->input);
+            ff_format_io_close(cur->parent, &cur->input);
             ret = reopen_demux_for_component(s, cur);
             cur->is_restart_needed = 0;
         }
@@ -2283,8 +2280,7 @@  static int dash_seek(AVFormatContext *s, struct representation *pls, int64_t see
         return av_seek_frame(pls->ctx, -1, seek_pos_msec * 1000, flags);
     }
 
-    if (pls->input)
-        ff_format_io_close(pls->parent, &pls->input);
+    ff_format_io_close(pls->parent, &pls->input);
 
     // find the nearest fragment
     if (pls->n_timelines > 0 && pls->fragment_timescale > 0) {