diff mbox series

[FFmpeg-devel,3/3] avformat/mov: remove an always true condition

Message ID tencent_C3E7DBEABC9331DC4DCB9A262710AF26F206@qq.com
State Accepted
Commit 345d04e8704cadf64d1b232b0d1be91566d1af06
Headers show
Series [FFmpeg-devel,1/3] avformat/mov: replace multiple avio_r8() by avio_skip() | expand

Checks

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

Commit Message

Zhao Zhili Sept. 18, 2020, 2:33 p.m. UTC
From: Zhao Zhili <zhilizhao@tencent.com>

---
 libavformat/mov.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Zhao Zhili Oct. 17, 2020, 3:46 p.m. UTC | #1
> On Sep 18, 2020, at 10:33 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> 
> From: Zhao Zhili <zhilizhao@tencent.com>
> 
> ---
> libavformat/mov.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 9fc0db24d5..f99605c2cd 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1475,7 +1475,7 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
>     // set the AVFormatContext duration because the duration of individual tracks
>     // may be inaccurate
> -    if (c->time_scale > 0 && !c->trex_data)
> +    if (!c->trex_data)
>         c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
>     avio_rb32(pb); /* preferred scale */

Ping for review.

The always true condition is not obvious in the patch. time_scale is checked a few lines before explicitly.

1471     if (c->time_scale <= 0) {
1472         av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d, defaulting to 1\n", c->time_scale);
1473         c->time_scale = 1;
1474     }
1475     av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale);
1476
1477     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
1478     // set the AVFormatContext duration because the duration of individual tracks
1479     // may be inaccurate
1480     if (c->time_scale > 0 && !c->trex_data)
1481         c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);


> 
> -- 
> 2.25.1
>
Jun Zhao Dec. 8, 2020, 8:43 a.m. UTC | #2
On Sat, Oct 17, 2020 at 11:48 PM Zhao Zhili <quinkblack@foxmail.com> wrote:
>
>
>
> > On Sep 18, 2020, at 10:33 PM, Zhao Zhili <quinkblack@foxmail.com> wrote:
> >
> > From: Zhao Zhili <zhilizhao@tencent.com>
> >
> > ---
> > libavformat/mov.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index 9fc0db24d5..f99605c2cd 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -1475,7 +1475,7 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> >     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
> >     // set the AVFormatContext duration because the duration of individual tracks
> >     // may be inaccurate
> > -    if (c->time_scale > 0 && !c->trex_data)
> > +    if (!c->trex_data)
> >         c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
> >     avio_rb32(pb); /* preferred scale */
>
> Ping for review.
>
> The always true condition is not obvious in the patch. time_scale is checked a few lines before explicitly.
>
> 1471     if (c->time_scale <= 0) {
> 1472         av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d, defaulting to 1\n", c->time_scale);
> 1473         c->time_scale = 1;
> 1474     }
> 1475     av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale);
> 1476
> 1477     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
> 1478     // set the AVFormatContext duration because the duration of individual tracks
> 1479     // may be inaccurate
> 1480     if (c->time_scale > 0 && !c->trex_data)
> 1481         c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
>
LGTM, will apply if no object
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 9fc0db24d5..f99605c2cd 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1475,7 +1475,7 @@  static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */
     // set the AVFormatContext duration because the duration of individual tracks
     // may be inaccurate
-    if (c->time_scale > 0 && !c->trex_data)
+    if (!c->trex_data)
         c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);
     avio_rb32(pb); /* preferred scale */