Regression since 8dd5bb728038f21d17ec789e21d65fe8f3f364a6. Fixes ticket #5978.
Unified · Split
| @@ -8034,12 +8034,13 @@ static int mov_read_timecode_track(AVFormatContext *s, AVStream *st) · 8033 unmodified lines | ||
| 8034 | 8034 | int64_t cur_pos = avio_tell(sc->pb); |
| 8035 | 8035 | int64_t value; |
| 8036 | 8036 | AVRational tc_rate = st->avg_frame_rate; |
| 8037 | + int tmcd_nb_frames = sc->tmcd_nb_frames; | |
| 8037 | 8038 | int rounded_tc_rate; |
| 8038 | 8039 | |
| 8039 | 8040 | if (!sti->nb_index_entries) |
| 8040 | 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 | 8044 | return -1; |
| 8044 | 8045 | |
| 8045 | 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 | 8057 | * format). */ |
| 8057 | 8058 | |
| 8058 | 8059 | /* 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 | 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 | 8070 | parse_timecode_in_framenum_format(s, st, value, flags); |
| 8064 | 8071 | |