diff mbox series

[FFmpeg-devel,1/2] avformat/utils: remove always true if()

Message ID tencent_96490D4EA225517314C84A73E6D370F5C805@qq.com
State New
Headers show
Series [FFmpeg-devel,1/2] avformat/utils: remove always true if()
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

zhilizhao(赵志立) July 28, 2020, 5:02 p.m. UTC
---
 libavformat/utils.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

zhilizhao(赵志立) Aug. 5, 2020, 3:16 p.m. UTC | #1
Ping for the trivial patch.

> On Jul 29, 2020, at 1:02 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> ---
> libavformat/utils.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 807d9f10cb..af1cca0c7d 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -2543,6 +2543,8 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
> int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>                        int64_t ts, int64_t max_ts, int flags)
> {
> +    int ret;
> +    int dir;
>     if (min_ts > ts || max_ts < ts)
>         return -1;
>     if (stream_index < -1 || stream_index >= (int)s->nb_streams)
> @@ -2553,7 +2555,6 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>     flags &= ~AVSEEK_FLAG_BACKWARD;
> 
>     if (s->iformat->read_seek2) {
> -        int ret;
>         ff_read_frame_flush(s);
> 
>         if (stream_index == -1 && s->nb_streams == 1) {
> @@ -2582,19 +2583,14 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
> 
>     // Fall back on old API if new is not implemented but old is.
>     // Note the old API has somewhat different semantics.
> -    if (s->iformat->read_seek || 1) {
> -        int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
> -        int ret = av_seek_frame(s, stream_index, ts, flags | dir);
> +        dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
> +        ret = av_seek_frame(s, stream_index, ts, flags | dir);
>         if (ret<0 && ts != min_ts && max_ts != ts) {
>             ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
>             if (ret >= 0)
>                 ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));
>         }
>         return ret;
> -    }
> -
> -    // try some generic seek like seek_frame_generic() but with new ts semantics
> -    return -1; //unreachable
> }
> 
> int avformat_flush(AVFormatContext *s)
> -- 
> 2.25.1
> 
> _______________________________________________
> 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".
zhilizhao(赵志立) Aug. 24, 2020, 5:16 p.m. UTC | #2
Ping again.

> On Aug 5, 2020, at 11:16 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> Ping for the trivial patch.
> 
>> On Jul 29, 2020, at 1:02 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
>> 
>> ---
>> libavformat/utils.c | 12 ++++--------
>> 1 file changed, 4 insertions(+), 8 deletions(-)
>> 
>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>> index 807d9f10cb..af1cca0c7d 100644
>> --- a/libavformat/utils.c
>> +++ b/libavformat/utils.c
>> @@ -2543,6 +2543,8 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
>> int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>>                       int64_t ts, int64_t max_ts, int flags)
>> {
>> +    int ret;
>> +    int dir;
>>    if (min_ts > ts || max_ts < ts)
>>        return -1;
>>    if (stream_index < -1 || stream_index >= (int)s->nb_streams)
>> @@ -2553,7 +2555,6 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>>    flags &= ~AVSEEK_FLAG_BACKWARD;
>> 
>>    if (s->iformat->read_seek2) {
>> -        int ret;
>>        ff_read_frame_flush(s);
>> 
>>        if (stream_index == -1 && s->nb_streams == 1) {
>> @@ -2582,19 +2583,14 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>> 
>>    // Fall back on old API if new is not implemented but old is.
>>    // Note the old API has somewhat different semantics.
>> -    if (s->iformat->read_seek || 1) {
>> -        int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
>> -        int ret = av_seek_frame(s, stream_index, ts, flags | dir);
>> +        dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
>> +        ret = av_seek_frame(s, stream_index, ts, flags | dir);
>>        if (ret<0 && ts != min_ts && max_ts != ts) {
>>            ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
>>            if (ret >= 0)
>>                ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));
>>        }
>>        return ret;
>> -    }
>> -
>> -    // try some generic seek like seek_frame_generic() but with new ts semantics
>> -    return -1; //unreachable
>> }
>> 
>> int avformat_flush(AVFormatContext *s)
>> -- 
>> 2.25.1
>> 
>> _______________________________________________
>> 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".
>
zhilizhao(赵志立) Sept. 26, 2020, 4:28 p.m. UTC | #3
Ping for the patch set.

> On Aug 25, 2020, at 1:16 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> Ping again.
> 
>> On Aug 5, 2020, at 11:16 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:
>> 
>> Ping for the trivial patch.
>> 
>>> On Jul 29, 2020, at 1:02 AM, Zhao Zhili <quinkblack@foxmail.com> wrote:
>>> 
>>> ---
>>> libavformat/utils.c | 12 ++++--------
>>> 1 file changed, 4 insertions(+), 8 deletions(-)
>>> 
>>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>>> index 807d9f10cb..af1cca0c7d 100644
>>> --- a/libavformat/utils.c
>>> +++ b/libavformat/utils.c
>>> @@ -2543,6 +2543,8 @@ int av_seek_frame(AVFormatContext *s, int stream_index,
>>> int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>>>                      int64_t ts, int64_t max_ts, int flags)
>>> {
>>> +    int ret;
>>> +    int dir;
>>>   if (min_ts > ts || max_ts < ts)
>>>       return -1;
>>>   if (stream_index < -1 || stream_index >= (int)s->nb_streams)
>>> @@ -2553,7 +2555,6 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>>>   flags &= ~AVSEEK_FLAG_BACKWARD;
>>> 
>>>   if (s->iformat->read_seek2) {
>>> -        int ret;
>>>       ff_read_frame_flush(s);
>>> 
>>>       if (stream_index == -1 && s->nb_streams == 1) {
>>> @@ -2582,19 +2583,14 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
>>> 
>>>   // Fall back on old API if new is not implemented but old is.
>>>   // Note the old API has somewhat different semantics.
>>> -    if (s->iformat->read_seek || 1) {
>>> -        int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
>>> -        int ret = av_seek_frame(s, stream_index, ts, flags | dir);
>>> +        dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
>>> +        ret = av_seek_frame(s, stream_index, ts, flags | dir);
>>>       if (ret<0 && ts != min_ts && max_ts != ts) {
>>>           ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
>>>           if (ret >= 0)
>>>               ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));
>>>       }
>>>       return ret;
>>> -    }
>>> -
>>> -    // try some generic seek like seek_frame_generic() but with new ts semantics
>>> -    return -1; //unreachable
>>> }
>>> 
>>> int avformat_flush(AVFormatContext *s)
>>> -- 
>>> 2.25.1
>>> 
>>> _______________________________________________
>>> 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".
>> 
>
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 807d9f10cb..af1cca0c7d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2543,6 +2543,8 @@  int av_seek_frame(AVFormatContext *s, int stream_index,
 int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
                        int64_t ts, int64_t max_ts, int flags)
 {
+    int ret;
+    int dir;
     if (min_ts > ts || max_ts < ts)
         return -1;
     if (stream_index < -1 || stream_index >= (int)s->nb_streams)
@@ -2553,7 +2555,6 @@  int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
     flags &= ~AVSEEK_FLAG_BACKWARD;
 
     if (s->iformat->read_seek2) {
-        int ret;
         ff_read_frame_flush(s);
 
         if (stream_index == -1 && s->nb_streams == 1) {
@@ -2582,19 +2583,14 @@  int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
 
     // Fall back on old API if new is not implemented but old is.
     // Note the old API has somewhat different semantics.
-    if (s->iformat->read_seek || 1) {
-        int dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
-        int ret = av_seek_frame(s, stream_index, ts, flags | dir);
+        dir = (ts - (uint64_t)min_ts > (uint64_t)max_ts - ts ? AVSEEK_FLAG_BACKWARD : 0);
+        ret = av_seek_frame(s, stream_index, ts, flags | dir);
         if (ret<0 && ts != min_ts && max_ts != ts) {
             ret = av_seek_frame(s, stream_index, dir ? max_ts : min_ts, flags | dir);
             if (ret >= 0)
                 ret = av_seek_frame(s, stream_index, ts, flags | (dir^AVSEEK_FLAG_BACKWARD));
         }
         return ret;
-    }
-
-    // try some generic seek like seek_frame_generic() but with new ts semantics
-    return -1; //unreachable
 }
 
 int avformat_flush(AVFormatContext *s)