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

Showing the changes to libavformat (1 of 1 file). Show all

Unified · Split

libavformat/mov.c+10−3
@@ -8034,12 +8034,13 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st) · 8033 unmodified lines
80348034 int64_t cur_pos = avio_tell(sc->pb);
80358035 int64_t value;
80368036 AVRational tc_rate = st->avg_frame_rate;
8037+ int tmcd_nb_frames = sc->tmcd_nb_frames;
80378038 int rounded_tc_rate;
80388039
80398040 if (!sti->nb_index_entries)
80408041 return -1;
80418042
8042− if (!tc_rate.num || !tc_rate.den || !sc->tmcd_nb_frames)
8043+ if (!tc_rate.num || !tc_rate.den || !tmcd_nb_frames)
80438044 return -1;
80448045
80458046 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
80568057 * format). */
80578058
80588059 /* 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. */
80608062 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);
80628069
80638070 parse_timecode_in_framenum_format(s, st, value, flags);
80648071

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