History

avformat/mov: fix timecode with rounded down tmcd nb_frames

Regression since 8dd5bb728038f21d17ec789e21d65fe8f3f364a6. Fixes ticket #5978.

Marton Balint committed 4 years ago

Commit 0a58fdf1 parent 5ccd8f41 file · +10 −3Browse files

Unified · Split

libavformat/mov.c+10−3
@@ -8034,12 +8034,13 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st) · 8033 unmodified lines
8034 int64_t cur_pos = avio_tell(sc->pb);8034 int64_t cur_pos = avio_tell(sc->pb);
8035 int64_t value;8035 int64_t value;
8036 AVRational tc_rate = st->avg_frame_rate;8036 AVRational tc_rate = st->avg_frame_rate;
8037 int tmcd_nb_frames = sc->tmcd_nb_frames;
8037 int rounded_tc_rate;8038 int rounded_tc_rate;
8038 8039
8039 if (!sti->nb_index_entries)8040 if (!sti->nb_index_entries)
8040 return -1;8041 return -1;
8041 8042
8042 if (!tc_rate.num || !tc_rate.den || !sc->tmcd_nb_frames)8043 if (!tc_rate.num || !tc_rate.den || !tmcd_nb_frames)
8043 return -1;8044 return -1;
8044 8045
8045 avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET);8046 avio_seek(sc->pb, sti->index_entries->pos, SEEK_SET);
@@ -8056,9 +8057,15 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st) · 10 unmodified lines
8056 * format). */8057 * format). */
8057 8058
8058 /* 60 fps content have tmcd_nb_frames set to 30 but tc_rate set to 60, so8059 /* 60 fps content have tmcd_nb_frames set to 30 but tc_rate set to 60, so
8059 * we multiply the frame number with the quotient. */8060 * we multiply the frame number with the quotient.
8061 * See tickets #9492, #9710. */
8060 rounded_tc_rate = (tc_rate.num + tc_rate.den / 2) / tc_rate.den;8062 rounded_tc_rate = (tc_rate.num + tc_rate.den / 2) / tc_rate.den;
8061 value = av_rescale(value, rounded_tc_rate, sc->tmcd_nb_frames);8063 /* Work around files where tmcd_nb_frames is rounded down from frame rate
8064 * instead of up. See ticket #5978. */
8065 if (tmcd_nb_frames == tc_rate.num / tc_rate.den &&
8066 s->strict_std_compliance < FF_COMPLIANCE_STRICT)
8067 tmcd_nb_frames = rounded_tc_rate;
8068 value = av_rescale(value, rounded_tc_rate, tmcd_nb_frames);
8062 8069
8063 parse_timecode_in_framenum_format(s, st, value, flags);8070 parse_timecode_in_framenum_format(s, st, value, flags);
8064 8071

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t