* [FFmpeg-devel] [PATCH] avformat/mov: fix timecode with rounded down tmcd nb_frames
@ 2022-05-01 12:11 Marton Balint
2022-05-08 21:43 ` Marton Balint
0 siblings, 1 reply; 2+ messages in thread
From: Marton Balint @ 2022-05-01 12:11 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Marton Balint
Regression since 8dd5bb728038f21d17ec789e21d65fe8f3f364a6.
Fixes ticket #5978.
Signed-off-by: Marton Balint <cus@passwd.hu>
---
libavformat/mov.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 0f63d997fc..dfd5720bf4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8038,12 +8038,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);
@@ -8060,9 +8061,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);
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avformat/mov: fix timecode with rounded down tmcd nb_frames
2022-05-01 12:11 [FFmpeg-devel] [PATCH] avformat/mov: fix timecode with rounded down tmcd nb_frames Marton Balint
@ 2022-05-08 21:43 ` Marton Balint
0 siblings, 0 replies; 2+ messages in thread
From: Marton Balint @ 2022-05-08 21:43 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Sun, 1 May 2022, Marton Balint wrote:
> Regression since 8dd5bb728038f21d17ec789e21d65fe8f3f364a6.
> Fixes ticket #5978.
Will apply tomorrow.
Regards,
Marton
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavformat/mov.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 0f63d997fc..dfd5720bf4 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -8038,12 +8038,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);
> @@ -8060,9 +8061,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);
>
> --
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-08 21:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-01 12:11 [FFmpeg-devel] [PATCH] avformat/mov: fix timecode with rounded down tmcd nb_frames Marton Balint
2022-05-08 21:43 ` Marton Balint
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git