diff mbox series

[FFmpeg-devel,1/6] avutil/timecode: allow drop frame timecodes for multiples of 30000/1001 fps

Message ID 20201119205123.21968-1-cus@passwd.hu
State Superseded
Headers show
Series [FFmpeg-devel,1/6] avutil/timecode: allow drop frame timecodes for multiples of 30000/1001 fps | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Marton Balint Nov. 19, 2020, 8:51 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavutil/timecode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Marton Balint Nov. 26, 2020, 8:41 p.m. UTC | #1
On Thu, 19 Nov 2020, Marton Balint wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavutil/timecode.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/timecode.c b/libavutil/timecode.c
> index f2db21c52c..8fcdf320ee 100644
> --- a/libavutil/timecode.c
> +++ b/libavutil/timecode.c
> @@ -196,8 +196,8 @@ static int check_timecode(void *log_ctx, AVTimecode *tc)
>         av_log(log_ctx, AV_LOG_ERROR, "Valid timecode frame rate must be specified. Minimum value is 1\n");
>         return AVERROR(EINVAL);
>     }
> -    if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps != 30 && tc->fps != 60) {
> -        av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n");
> +    if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps % 30 != 0) {
> +        av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with multiples of 30000/1001 FPS\n");
>         return AVERROR(EINVAL);
>     }
>     if (check_fps(tc->fps) < 0) {
> @@ -252,7 +252,7 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st
>     tc->start = (hh*3600 + mm*60 + ss) * tc->fps + ff;
>     if (tc->flags & AV_TIMECODE_FLAG_DROPFRAME) { /* adjust frame number */
>         int tmins = 60*hh + mm;
> -        tc->start -= (tc->fps == 30 ? 2 : 4) * (tmins - tmins/10);
> +        tc->start -= (tc->fps / 30 * 2) * (tmins - tmins/10);
>     }
>     return 0;
> }

Ping for the series, will apply soon.

Thanks,
Marton
diff mbox series

Patch

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index f2db21c52c..8fcdf320ee 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -196,8 +196,8 @@  static int check_timecode(void *log_ctx, AVTimecode *tc)
         av_log(log_ctx, AV_LOG_ERROR, "Valid timecode frame rate must be specified. Minimum value is 1\n");
         return AVERROR(EINVAL);
     }
-    if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps != 30 && tc->fps != 60) {
-        av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n");
+    if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps % 30 != 0) {
+        av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with multiples of 30000/1001 FPS\n");
         return AVERROR(EINVAL);
     }
     if (check_fps(tc->fps) < 0) {
@@ -252,7 +252,7 @@  int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *st
     tc->start = (hh*3600 + mm*60 + ss) * tc->fps + ff;
     if (tc->flags & AV_TIMECODE_FLAG_DROPFRAME) { /* adjust frame number */
         int tmins = 60*hh + mm;
-        tc->start -= (tc->fps == 30 ? 2 : 4) * (tmins - tmins/10);
+        tc->start -= (tc->fps / 30 * 2) * (tmins - tmins/10);
     }
     return 0;
 }