Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2022-05-01 14:31:40 +0300
committerMarton Balint <cus@passwd.hu>2022-05-09 23:21:59 +0300
commit0a58fdfd3e7a063cc652ddd4510ae064dcdc9de1 (patch)
tree23a89e523f145bee8767b45f90fb359d193d66f2 /libavformat/mov.c
parent5ccd8f492bc807dbf084bf13f3f288b2f4ac41f1 (diff)
avformat/mov: fix timecode with rounded down tmcd nb_frames
Regression since 8dd5bb728038f21d17ec789e21d65fe8f3f364a6. Fixes ticket #5978. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/mov.c')
-rw-r--r--libavformat/mov.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 87760cab95..c85b6e1915 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8034,12 +8034,13 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
int64_t cur_pos = avio_tell(sc->pb);
int64_t value;
AVRational tc_rate = st->avg_frame_rate;
+ int tmcd_nb_frames = sc->tmcd_nb_frames;
int rounded_tc_rate;
if (!sti->nb_index_entries)
return -1;
- if (!tc_rate.num || !tc_rate.den || !sc->tmcd_nb_frames)
+ if (!tc_rate.num || !tc_rate.den || !tmcd_nb_frames)
return -1;
avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET);
@@ -8056,9 +8057,15 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st)
* format). */
/* 60 fps content have tmcd_nb_frames set to 30 but tc_rate set to 60, so
- * we multiply the frame number with the quotient. */
+ * we multiply the frame number with the quotient.
+ * See tickets #9492, #9710. */
rounded_tc_rate = (tc_rate.num + tc_rate.den / 2) / tc_rate.den;
- value = av_rescale(value, rounded_tc_rate, sc->tmcd_nb_frames);
+ /* Work around files where tmcd_nb_frames is rounded down from frame rate
+ * instead of up. See ticket #5978. */
+ if (tmcd_nb_frames == tc_rate.num / tc_rate.den &&
+ s->strict_std_compliance < FF_COMPLIANCE_STRICT)
+ tmcd_nb_frames = rounded_tc_rate;
+ value = av_rescale(value, rounded_tc_rate, tmcd_nb_frames);
parse_timecode_in_framenum_format(s, st, value, flags);